qmi_interface_priv.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* Copyright (c) 2012-2015, 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 _QMI_INTERFACE_PRIV_H_
  13. #define _QMI_INTERFACE_PRIV_H_
  14. #include <linux/types.h>
  15. #include <linux/errno.h>
  16. #include <linux/mm.h>
  17. #include <linux/list.h>
  18. #include <linux/socket.h>
  19. #include <linux/gfp.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/qmi_encdec.h>
  22. #include <soc/qcom/msm_qmi_interface.h>
  23. enum txn_type {
  24. QMI_SYNC_TXN = 1,
  25. QMI_ASYNC_TXN,
  26. };
  27. /**
  28. * handle_type - Enum to identify QMI handle type
  29. */
  30. enum handle_type {
  31. QMI_CLIENT_HANDLE = 1,
  32. QMI_SERVICE_HANDLE,
  33. };
  34. struct qmi_txn {
  35. struct list_head list;
  36. uint16_t txn_id;
  37. enum txn_type type;
  38. struct qmi_handle *handle;
  39. void *enc_data;
  40. unsigned int enc_data_len;
  41. struct msg_desc *resp_desc;
  42. void *resp;
  43. unsigned int resp_len;
  44. int resp_received;
  45. int send_stat;
  46. void (*resp_cb)(struct qmi_handle *handle, unsigned int msg_id,
  47. void *msg, void *resp_cb_data, int stat);
  48. void *resp_cb_data;
  49. wait_queue_head_t wait_q;
  50. };
  51. /**
  52. * svc_addr - Data structure to maintain a list of service addresses.
  53. * @list_node: Service address list node used by "svc_addr_list"
  54. * @port_addr: Service address in <node_id:port_id>.
  55. */
  56. struct svc_addr {
  57. struct list_head list_node;
  58. struct msm_ipc_port_addr port_addr;
  59. };
  60. /**
  61. * svc_event_nb - Service event notification structure.
  62. * @nb_lock: Spinlock for the notifier block lists.
  63. * @service_id: Service id for which list of notifier blocks are maintained.
  64. * @instance_id: Instance id for which list of notifier blocks are maintained.
  65. * @svc_event_rcvr_list: List of notifier blocks which clients have registered.
  66. * @list: Used to chain this structure in a global list.
  67. * @svc_addr_list_lock: Lock to protect @svc_addr_list.
  68. * @svc_addr_list: List for mantaining all the address for a specific
  69. * <service_id:instance_id>.
  70. */
  71. struct svc_event_nb {
  72. spinlock_t nb_lock;
  73. uint32_t service_id;
  74. uint32_t instance_id;
  75. struct raw_notifier_head svc_event_rcvr_list;
  76. struct list_head list;
  77. struct mutex svc_addr_list_lock;
  78. struct list_head svc_addr_list;
  79. };
  80. /**
  81. * req_handle - Data structure to store request information
  82. * @list: Points to req_handle_list maintained per connection.
  83. * @conn_h: Connection handle on which the concerned request is received.
  84. * @msg_id: Message ID of the request.
  85. * @txn_id: Transaction ID of the request.
  86. */
  87. struct req_handle {
  88. struct list_head list;
  89. struct qmi_svc_clnt_conn *conn_h;
  90. uint16_t msg_id;
  91. uint16_t txn_id;
  92. };
  93. /**
  94. * qmi_svc_clnt_conn - Data structure to identify client service connection
  95. * @list: List to chain up the client conncection to the connection list.
  96. * @svc_handle: Service side information of the connection.
  97. * @clnt_addr: Client side information of the connection.
  98. * @clnt_addr_len: Length of the client address.
  99. * @req_handle_list: Pending requests in this connection.
  100. * @pending_tx_list: Pending response/indications awaiting flow control.
  101. */
  102. struct qmi_svc_clnt_conn {
  103. struct list_head list;
  104. void *svc_handle;
  105. void *clnt_addr;
  106. size_t clnt_addr_len;
  107. struct list_head req_handle_list;
  108. struct delayed_work resume_tx_work;
  109. struct list_head pending_txn_list;
  110. struct mutex pending_txn_lock;
  111. };
  112. #endif