qmi_rmnet_i.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _RMNET_QMI_I_H
  14. #define _RMNET_QMI_I_H
  15. #include <linux/netdevice.h>
  16. #include <linux/skbuff.h>
  17. #define MAX_MQ_NUM 16
  18. #define MAX_CLIENT_NUM 2
  19. #define MAX_FLOW_NUM 32
  20. #define DEFAULT_GRANT 1
  21. #define DEFAULT_CALL_GRANT 20480
  22. #define DFC_MAX_BEARERS_V01 16
  23. #define DEFAULT_MQ_NUM 0
  24. #define ACK_MQ_OFFSET (MAX_MQ_NUM - 1)
  25. #define INVALID_MQ 0xFF
  26. #define DFC_MODE_FLOW_ID 2
  27. #define DFC_MODE_MQ_NUM 3
  28. #define DFC_MODE_SA 4
  29. #define CONFIG_QTI_QMI_RMNET 1
  30. #define CONFIG_QTI_QMI_DFC 1
  31. #define CONFIG_QTI_QMI_POWER_COLLAPSE 1
  32. extern int dfc_mode;
  33. extern int dfc_qmap;
  34. struct rmnet_bearer_map {
  35. struct list_head list;
  36. u8 bearer_id;
  37. int flow_ref;
  38. u32 grant_size;
  39. u32 grant_thresh;
  40. u16 seq;
  41. u8 ack_req;
  42. u32 last_grant;
  43. u16 last_seq;
  44. bool tcp_bidir;
  45. bool rat_switch;
  46. bool tx_off;
  47. u32 ack_txid;
  48. u32 mq_idx;
  49. u32 ack_mq_idx;
  50. };
  51. struct rmnet_flow_map {
  52. struct list_head list;
  53. u8 bearer_id;
  54. u32 flow_id;
  55. int ip_type;
  56. u32 mq_idx;
  57. struct rmnet_bearer_map *bearer;
  58. };
  59. struct svc_info {
  60. u32 instance;
  61. u32 ep_type;
  62. u32 iface_id;
  63. };
  64. struct mq_map {
  65. struct rmnet_bearer_map *bearer;
  66. };
  67. struct qos_info {
  68. struct list_head list;
  69. u8 mux_id;
  70. struct net_device *real_dev;
  71. struct list_head flow_head;
  72. struct list_head bearer_head;
  73. struct mq_map mq[MAX_MQ_NUM];
  74. u32 tran_num;
  75. spinlock_t qos_lock;
  76. };
  77. struct qmi_info {
  78. int flag;
  79. void *wda_client;
  80. void *wda_pending;
  81. void *dfc_clients[MAX_CLIENT_NUM];
  82. void *dfc_pending[MAX_CLIENT_NUM];
  83. unsigned long ps_work_active;
  84. bool ps_enabled;
  85. bool dl_msg_active;
  86. bool ps_ignore_grant;
  87. };
  88. enum data_ep_type_enum_v01 {
  89. DATA_EP_TYPE_ENUM_MIN_ENUM_VAL_V01 = INT_MIN,
  90. DATA_EP_TYPE_RESERVED_V01 = 0x00,
  91. DATA_EP_TYPE_HSIC_V01 = 0x01,
  92. DATA_EP_TYPE_HSUSB_V01 = 0x02,
  93. DATA_EP_TYPE_PCIE_V01 = 0x03,
  94. DATA_EP_TYPE_EMBEDDED_V01 = 0x04,
  95. DATA_EP_TYPE_ENUM_MAX_ENUM_VAL_V01 = INT_MAX
  96. };
  97. struct data_ep_id_type_v01 {
  98. enum data_ep_type_enum_v01 ep_type;
  99. u32 iface_id;
  100. };
  101. extern struct qmi_elem_info data_ep_id_type_v01_ei[];
  102. void *qmi_rmnet_has_dfc_client(struct qmi_info *qmi);
  103. #ifdef CONFIG_QTI_QMI_DFC
  104. struct rmnet_flow_map *
  105. qmi_rmnet_get_flow_map(struct qos_info *qos_info,
  106. u32 flow_id, int ip_type);
  107. struct rmnet_bearer_map *
  108. qmi_rmnet_get_bearer_map(struct qos_info *qos_info, u8 bearer_id);
  109. unsigned int qmi_rmnet_grant_per(unsigned int grant);
  110. int dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
  111. struct qmi_info *qmi);
  112. void dfc_qmi_client_exit(void *dfc_data);
  113. void dfc_qmi_burst_check(struct net_device *dev, struct qos_info *qos,
  114. int ip_type, u32 mark, unsigned int len);
  115. int qmi_rmnet_flow_control(struct net_device *dev, u32 mq_idx, int enable);
  116. void dfc_qmi_query_flow(void *dfc_data);
  117. int dfc_bearer_flow_ctl(struct net_device *dev,
  118. struct rmnet_bearer_map *bearer,
  119. struct qos_info *qos);
  120. int dfc_qmap_client_init(void *port, int index, struct svc_info *psvc,
  121. struct qmi_info *qmi);
  122. void dfc_qmap_client_exit(void *dfc_data);
  123. void dfc_qmap_send_ack(struct qos_info *qos, u8 bearer_id, u16 seq, u8 type);
  124. struct rmnet_bearer_map *qmi_rmnet_get_bearer_noref(struct qos_info *qos_info,
  125. u8 bearer_id);
  126. #else
  127. static inline struct rmnet_flow_map *
  128. qmi_rmnet_get_flow_map(struct qos_info *qos_info,
  129. uint32_t flow_id, int ip_type)
  130. {
  131. return NULL;
  132. }
  133. static inline struct rmnet_bearer_map *
  134. qmi_rmnet_get_bearer_map(struct qos_info *qos_info, u8 bearer_id)
  135. {
  136. return NULL;
  137. }
  138. static inline int
  139. dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
  140. struct qmi_info *qmi)
  141. {
  142. return -EINVAL;
  143. }
  144. static inline void dfc_qmi_client_exit(void *dfc_data)
  145. {
  146. }
  147. static inline int
  148. dfc_bearer_flow_ctl(struct net_device *dev,
  149. struct rmnet_bearer_map *bearer,
  150. struct qos_info *qos)
  151. {
  152. return 0;
  153. }
  154. static inline int
  155. dfc_qmap_client_init(void *port, int index, struct svc_info *psvc,
  156. struct qmi_info *qmi)
  157. {
  158. return -EINVAL;
  159. }
  160. static inline void dfc_qmap_client_exit(void *dfc_data)
  161. {
  162. }
  163. #endif
  164. #ifdef CONFIG_QTI_QMI_POWER_COLLAPSE
  165. int
  166. wda_qmi_client_init(void *port, struct svc_info *psvc, struct qmi_info *qmi);
  167. void wda_qmi_client_exit(void *wda_data);
  168. int wda_set_powersave_mode(void *wda_data, u8 enable);
  169. void qmi_rmnet_flush_ps_wq(void);
  170. #else
  171. static inline int
  172. wda_qmi_client_init(void *port, struct svc_info *psvc, struct qmi_info *qmi)
  173. {
  174. return -EINVAL;
  175. }
  176. static inline void wda_qmi_client_exit(void *wda_data)
  177. {
  178. }
  179. static inline int wda_set_powersave_mode(void *wda_data, u8 enable)
  180. {
  181. return -EINVAL;
  182. }
  183. static inline void qmi_rmnet_flush_ps_wq(void)
  184. {
  185. }
  186. #endif
  187. #endif /*_RMNET_QMI_I_H*/