qmi_rmnet_i.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright (c) 2018-2021, 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. #include <linux/timer.h>
  18. #define MAX_MQ_NUM 16
  19. #define MAX_CLIENT_NUM 2
  20. #define MAX_FLOW_NUM 32
  21. #define DEFAULT_GRANT 1
  22. #define DEFAULT_CALL_GRANT 20480
  23. #define DFC_MAX_BEARERS_V01 16
  24. #define DEFAULT_MQ_NUM 0
  25. #define ACK_MQ_OFFSET (MAX_MQ_NUM - 1)
  26. #define INVALID_MQ 0xFF
  27. #define DFC_MODE_SA 4
  28. #define CONFIG_QTI_QMI_RMNET 1
  29. #define CONFIG_QTI_QMI_DFC 1
  30. #define CONFIG_QTI_QMI_POWER_COLLAPSE 1
  31. extern int dfc_mode;
  32. extern int dfc_qmap;
  33. struct qos_info;
  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. u32 bytes_in_flight;
  45. u32 last_adjusted_grant;
  46. bool is_low_latency;
  47. bool tcp_bidir;
  48. bool rat_switch;
  49. bool tx_off;
  50. u32 ack_txid;
  51. u32 mq_idx;
  52. u32 ack_mq_idx;
  53. struct qos_info *qos;
  54. struct timer_list watchdog;
  55. bool watchdog_started;
  56. bool watchdog_quit;
  57. u32 watchdog_expire_cnt;
  58. };
  59. struct rmnet_flow_map {
  60. struct list_head list;
  61. u8 bearer_id;
  62. u32 flow_id;
  63. int ip_type;
  64. u32 mq_idx;
  65. struct rmnet_bearer_map *bearer;
  66. };
  67. struct svc_info {
  68. u32 instance;
  69. u32 ep_type;
  70. u32 iface_id;
  71. };
  72. struct mq_map {
  73. struct rmnet_bearer_map *bearer;
  74. };
  75. struct qos_info {
  76. struct list_head list;
  77. u8 mux_id;
  78. struct net_device *real_dev;
  79. struct net_device *vnd_dev;
  80. struct list_head flow_head;
  81. struct list_head bearer_head;
  82. struct mq_map mq[MAX_MQ_NUM];
  83. u32 tran_num;
  84. spinlock_t qos_lock;
  85. struct rmnet_bearer_map *removed_bearer;
  86. };
  87. struct qmi_info {
  88. int flag;
  89. void *wda_client;
  90. void *wda_pending;
  91. void *dfc_clients[MAX_CLIENT_NUM];
  92. void *dfc_pending[MAX_CLIENT_NUM];
  93. bool dfc_client_exiting[MAX_CLIENT_NUM];
  94. unsigned long ps_work_active;
  95. bool ps_enabled;
  96. bool dl_msg_active;
  97. bool ps_ignore_grant;
  98. };
  99. enum data_ep_type_enum_v01 {
  100. DATA_EP_TYPE_ENUM_MIN_ENUM_VAL_V01 = INT_MIN,
  101. DATA_EP_TYPE_RESERVED_V01 = 0x00,
  102. DATA_EP_TYPE_HSIC_V01 = 0x01,
  103. DATA_EP_TYPE_HSUSB_V01 = 0x02,
  104. DATA_EP_TYPE_PCIE_V01 = 0x03,
  105. DATA_EP_TYPE_EMBEDDED_V01 = 0x04,
  106. DATA_EP_TYPE_ENUM_MAX_ENUM_VAL_V01 = INT_MAX
  107. };
  108. struct data_ep_id_type_v01 {
  109. enum data_ep_type_enum_v01 ep_type;
  110. u32 iface_id;
  111. };
  112. extern struct qmi_elem_info data_ep_id_type_v01_ei[];
  113. void *qmi_rmnet_has_dfc_client(struct qmi_info *qmi);
  114. #ifdef CONFIG_QTI_QMI_DFC
  115. struct rmnet_flow_map *
  116. qmi_rmnet_get_flow_map(struct qos_info *qos_info,
  117. u32 flow_id, int ip_type);
  118. struct rmnet_bearer_map *
  119. qmi_rmnet_get_bearer_map(struct qos_info *qos_info, u8 bearer_id);
  120. unsigned int qmi_rmnet_grant_per(unsigned int grant);
  121. int dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
  122. struct qmi_info *qmi);
  123. void dfc_qmi_client_exit(void *dfc_data);
  124. void dfc_qmi_burst_check(struct net_device *dev, struct qos_info *qos,
  125. int ip_type, u32 mark, unsigned int len);
  126. int qmi_rmnet_flow_control(struct net_device *dev, u32 mq_idx, int enable);
  127. void dfc_qmi_query_flow(void *dfc_data);
  128. int dfc_bearer_flow_ctl(struct net_device *dev,
  129. struct rmnet_bearer_map *bearer,
  130. struct qos_info *qos);
  131. int dfc_qmap_client_init(void *port, int index, struct svc_info *psvc,
  132. struct qmi_info *qmi);
  133. void dfc_qmap_client_exit(void *dfc_data);
  134. void dfc_qmap_send_ack(struct qos_info *qos, u8 bearer_id, u16 seq, u8 type);
  135. struct rmnet_bearer_map *qmi_rmnet_get_bearer_noref(struct qos_info *qos_info,
  136. u8 bearer_id);
  137. void qmi_rmnet_watchdog_add(struct rmnet_bearer_map *bearer);
  138. void qmi_rmnet_watchdog_remove(struct rmnet_bearer_map *bearer);
  139. #else
  140. static inline struct rmnet_flow_map *
  141. qmi_rmnet_get_flow_map(struct qos_info *qos_info,
  142. uint32_t flow_id, int ip_type)
  143. {
  144. return NULL;
  145. }
  146. static inline struct rmnet_bearer_map *
  147. qmi_rmnet_get_bearer_map(struct qos_info *qos_info, u8 bearer_id)
  148. {
  149. return NULL;
  150. }
  151. static inline int
  152. dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
  153. struct qmi_info *qmi)
  154. {
  155. return -EINVAL;
  156. }
  157. static inline void dfc_qmi_client_exit(void *dfc_data)
  158. {
  159. }
  160. static inline int
  161. dfc_bearer_flow_ctl(struct net_device *dev,
  162. struct rmnet_bearer_map *bearer,
  163. struct qos_info *qos)
  164. {
  165. return 0;
  166. }
  167. static inline int
  168. dfc_qmap_client_init(void *port, int index, struct svc_info *psvc,
  169. struct qmi_info *qmi)
  170. {
  171. return -EINVAL;
  172. }
  173. static inline void dfc_qmap_client_exit(void *dfc_data)
  174. {
  175. }
  176. static inline void qmi_rmnet_watchdog_remove(struct rmnet_bearer_map *bearer)
  177. {
  178. }
  179. #endif
  180. #ifdef CONFIG_QTI_QMI_POWER_COLLAPSE
  181. int
  182. wda_qmi_client_init(void *port, struct svc_info *psvc, struct qmi_info *qmi);
  183. void wda_qmi_client_exit(void *wda_data);
  184. int wda_set_powersave_mode(void *wda_data, u8 enable);
  185. void qmi_rmnet_flush_ps_wq(void);
  186. void wda_qmi_client_release(void *wda_data);
  187. #else
  188. static inline int
  189. wda_qmi_client_init(void *port, struct svc_info *psvc, struct qmi_info *qmi)
  190. {
  191. return -EINVAL;
  192. }
  193. static inline void wda_qmi_client_exit(void *wda_data)
  194. {
  195. }
  196. static inline int wda_set_powersave_mode(void *wda_data, u8 enable)
  197. {
  198. return -EINVAL;
  199. }
  200. static inline void qmi_rmnet_flush_ps_wq(void)
  201. {
  202. }
  203. static inline void wda_qmi_client_release(void *wda_data)
  204. {
  205. }
  206. #endif
  207. #endif /*_RMNET_QMI_I_H*/