diagfwd_bridge.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef DIAGFWD_BRIDGE_H
  13. #define DIAGFWD_BRIDGE_H
  14. /*
  15. * Add Data channels at the top half and the DCI channels at the
  16. * bottom half of this list.
  17. */
  18. #define DIAGFWD_MDM 0
  19. #define DIAGFWD_SMUX 1
  20. #define NUM_REMOTE_DATA_DEV 2
  21. #define DIAGFWD_MDM_DCI NUM_REMOTE_DATA_DEV
  22. #define NUM_REMOTE_DCI_DEV (DIAGFWD_MDM_DCI - NUM_REMOTE_DATA_DEV + 1)
  23. #define NUM_REMOTE_DEV (NUM_REMOTE_DATA_DEV + NUM_REMOTE_DCI_DEV)
  24. #define DIAG_BRIDGE_NAME_SZ 24
  25. #define DIAG_BRIDGE_GET_NAME(x) (bridge_info[x].name)
  26. struct diag_remote_dev_ops {
  27. int (*open)(int id);
  28. int (*close)(int id);
  29. int (*queue_read)(int id);
  30. int (*write)(int id, unsigned char *buf, int len, int ctxt);
  31. int (*fwd_complete)(int id, unsigned char *buf, int len, int ctxt);
  32. };
  33. struct diagfwd_bridge_info {
  34. int id;
  35. int type;
  36. int inited;
  37. int ctxt;
  38. char name[DIAG_BRIDGE_NAME_SZ];
  39. struct diag_remote_dev_ops *dev_ops;
  40. /* DCI related variables. These would be NULL for data channels */
  41. void *dci_read_ptr;
  42. unsigned char *dci_read_buf;
  43. int dci_read_len;
  44. struct workqueue_struct *dci_wq;
  45. struct work_struct dci_read_work;
  46. };
  47. extern struct diagfwd_bridge_info bridge_info[NUM_REMOTE_DEV];
  48. int diagfwd_bridge_init(void);
  49. void diagfwd_bridge_exit(void);
  50. int diagfwd_bridge_close(int id);
  51. int diagfwd_bridge_write(int id, unsigned char *buf, int len);
  52. uint16_t diag_get_remote_device_mask(void);
  53. /* The following functions must be called by Diag remote devices only. */
  54. int diagfwd_bridge_register(int id, int ctxt, struct diag_remote_dev_ops *ops);
  55. int diag_remote_dev_open(int id);
  56. void diag_remote_dev_close(int id);
  57. int diag_remote_dev_read_done(int id, unsigned char *buf, int len);
  58. int diag_remote_dev_write_done(int id, unsigned char *buf, int len, int ctxt);
  59. #endif