qmi_rmnet_i.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. #include <uapi/linux/rtnetlink.h>
  19. #include <linux/soc/qcom/qmi.h>
  20. #define MAX_MQ_NUM 16
  21. #define MAX_CLIENT_NUM 2
  22. #define MAX_FLOW_NUM 32
  23. #define DEFAULT_GRANT 1
  24. #define DEFAULT_CALL_GRANT 20480
  25. #define DFC_MAX_BEARERS_V01 16
  26. #define DEFAULT_MQ_NUM 0
  27. #define ACK_MQ_OFFSET (MAX_MQ_NUM - 1)
  28. #define INVALID_MQ 0xFF
  29. #define DFC_MODE_SA 4
  30. #define CONFIG_QTI_QMI_RMNET 1
  31. #define CONFIG_QTI_QMI_DFC 1
  32. #define CONFIG_QTI_QMI_POWER_COLLAPSE 1
  33. extern int dfc_mode;
  34. extern int dfc_qmap;
  35. struct qos_info;
  36. enum {
  37. RMNET_CH_DEFAULT,
  38. RMNET_CH_LL,
  39. RMNET_CH_MAX,
  40. RMNET_CH_CTL = 0xFF
  41. };
  42. enum rmnet_ch_switch_state {
  43. CH_SWITCH_NONE,
  44. CH_SWITCH_STARTED,
  45. CH_SWITCH_ACKED,
  46. CH_SWITCH_FAILED_RETRY
  47. };
  48. struct rmnet_ch_switch {
  49. u8 current_ch;
  50. u8 switch_to_ch;
  51. u8 retry_left;
  52. u8 status_code;
  53. enum rmnet_ch_switch_state state;
  54. __be32 switch_txid;
  55. u32 flags;
  56. bool timer_quit;
  57. struct timer_list guard_timer;
  58. u32 nl_pid;
  59. u32 nl_seq;
  60. };
  61. struct rmnet_bearer_map {
  62. struct list_head list;
  63. u8 bearer_id;
  64. int flow_ref;
  65. u32 grant_size;
  66. u32 grant_thresh;
  67. u16 seq;
  68. u8 ack_req;
  69. u32 last_grant;
  70. u16 last_seq;
  71. u32 bytes_in_flight;
  72. u32 last_adjusted_grant;
  73. bool tcp_bidir;
  74. bool rat_switch;
  75. bool tx_off;
  76. u32 ack_txid;
  77. u32 mq_idx;
  78. u32 ack_mq_idx;
  79. struct qos_info *qos;
  80. struct timer_list watchdog;
  81. bool watchdog_started;
  82. bool watchdog_quit;
  83. u32 watchdog_expire_cnt;
  84. struct rmnet_ch_switch ch_switch;
  85. };
  86. struct rmnet_flow_map {
  87. struct list_head list;
  88. u8 bearer_id;
  89. u32 flow_id;
  90. int ip_type;
  91. u32 mq_idx;
  92. struct rmnet_bearer_map *bearer;
  93. };
  94. struct svc_info {
  95. u32 instance;
  96. u32 ep_type;
  97. u32 iface_id;
  98. };
  99. struct mq_map {
  100. struct rmnet_bearer_map *bearer;
  101. bool is_ll_ch;
  102. };
  103. struct qos_info {
  104. struct list_head list;
  105. u8 mux_id;
  106. struct net_device *real_dev;
  107. struct net_device *vnd_dev;
  108. struct list_head flow_head;
  109. struct list_head bearer_head;
  110. struct mq_map mq[MAX_MQ_NUM];
  111. u32 tran_num;
  112. spinlock_t qos_lock;
  113. struct rmnet_bearer_map *removed_bearer;
  114. };
  115. struct qmi_info {
  116. int flag;
  117. void *wda_client;
  118. void *wda_pending;
  119. void *dfc_clients[MAX_CLIENT_NUM];
  120. void *dfc_pending[MAX_CLIENT_NUM];
  121. bool dfc_client_exiting[MAX_CLIENT_NUM];
  122. unsigned long ps_work_active;
  123. bool ps_enabled;
  124. bool dl_msg_active;
  125. bool ps_ignore_grant;
  126. int ps_ext;
  127. };
  128. enum data_ep_type_enum_v01 {
  129. DATA_EP_TYPE_ENUM_MIN_ENUM_VAL_V01 = INT_MIN,
  130. DATA_EP_TYPE_RESERVED_V01 = 0x00,
  131. DATA_EP_TYPE_HSIC_V01 = 0x01,
  132. DATA_EP_TYPE_HSUSB_V01 = 0x02,
  133. DATA_EP_TYPE_PCIE_V01 = 0x03,
  134. DATA_EP_TYPE_EMBEDDED_V01 = 0x04,
  135. DATA_EP_TYPE_ENUM_MAX_ENUM_VAL_V01 = INT_MAX
  136. };
  137. struct data_ep_id_type_v01 {
  138. enum data_ep_type_enum_v01 ep_type;
  139. u32 iface_id;
  140. };
  141. extern struct qmi_elem_info data_ep_id_type_v01_ei[];
  142. void *qmi_rmnet_has_dfc_client(struct qmi_info *qmi);
  143. #ifdef CONFIG_QTI_QMI_DFC
  144. struct rmnet_flow_map *
  145. qmi_rmnet_get_flow_map(struct qos_info *qos_info,
  146. u32 flow_id, int ip_type);
  147. struct rmnet_bearer_map *
  148. qmi_rmnet_get_bearer_map(struct qos_info *qos_info, u8 bearer_id);
  149. unsigned int qmi_rmnet_grant_per(unsigned int grant);
  150. int dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
  151. struct qmi_info *qmi);
  152. void dfc_qmi_client_exit(void *dfc_data);
  153. void dfc_qmi_burst_check(struct net_device *dev, struct qos_info *qos,
  154. int ip_type, u32 mark, unsigned int len);
  155. int qmi_rmnet_flow_control(struct net_device *dev, u32 mq_idx, int enable);
  156. void dfc_qmi_query_flow(void *dfc_data);
  157. int dfc_bearer_flow_ctl(struct net_device *dev,
  158. struct rmnet_bearer_map *bearer,
  159. struct qos_info *qos);
  160. int dfc_qmap_client_init(void *port, int index, struct svc_info *psvc,
  161. struct qmi_info *qmi);
  162. void dfc_qmap_client_exit(void *dfc_data);
  163. void dfc_qmap_send_ack(struct qos_info *qos, u8 bearer_id, u16 seq, u8 type);
  164. struct rmnet_bearer_map *qmi_rmnet_get_bearer_noref(struct qos_info *qos_info,
  165. u8 bearer_id);
  166. void qmi_rmnet_watchdog_add(struct rmnet_bearer_map *bearer);
  167. void qmi_rmnet_watchdog_remove(struct rmnet_bearer_map *bearer);
  168. int rmnet_ll_switch(struct net_device *dev, struct tcmsg *tcm, int attrlen);
  169. void rmnet_ll_guard_fn(struct timer_list *t);
  170. void rmnet_ll_wq_init(void);
  171. void rmnet_ll_wq_exit(void);
  172. #else
  173. static inline struct rmnet_flow_map *
  174. qmi_rmnet_get_flow_map(struct qos_info *qos_info,
  175. uint32_t flow_id, int ip_type)
  176. {
  177. return NULL;
  178. }
  179. static inline struct rmnet_bearer_map *
  180. qmi_rmnet_get_bearer_map(struct qos_info *qos_info, u8 bearer_id)
  181. {
  182. return NULL;
  183. }
  184. static inline int
  185. dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
  186. struct qmi_info *qmi)
  187. {
  188. return -EINVAL;
  189. }
  190. static inline void dfc_qmi_client_exit(void *dfc_data)
  191. {
  192. }
  193. static inline int
  194. dfc_bearer_flow_ctl(struct net_device *dev,
  195. struct rmnet_bearer_map *bearer,
  196. struct qos_info *qos)
  197. {
  198. return 0;
  199. }
  200. static inline int
  201. dfc_qmap_client_init(void *port, int index, struct svc_info *psvc,
  202. struct qmi_info *qmi)
  203. {
  204. return -EINVAL;
  205. }
  206. static inline void dfc_qmap_client_exit(void *dfc_data)
  207. {
  208. }
  209. static inline void qmi_rmnet_watchdog_remove(struct rmnet_bearer_map *bearer)
  210. {
  211. }
  212. static int rmnet_ll_switch(struct net_device *dev,
  213. struct tcmsg *tcm, int attrlen)
  214. {
  215. return -EINVAL;
  216. }
  217. #endif
  218. #ifdef CONFIG_QTI_QMI_POWER_COLLAPSE
  219. int
  220. wda_qmi_client_init(void *port, struct svc_info *psvc, struct qmi_info *qmi);
  221. void wda_qmi_client_exit(void *wda_data);
  222. int wda_set_powersave_mode(void *wda_data, u8 enable);
  223. void qmi_rmnet_flush_ps_wq(void);
  224. void wda_qmi_client_release(void *wda_data);
  225. int dfc_qmap_set_powersave(u8 enable, u8 num_bearers, u8 *bearer_id);
  226. #else
  227. static inline int
  228. wda_qmi_client_init(void *port, struct svc_info *psvc, struct qmi_info *qmi)
  229. {
  230. return -EINVAL;
  231. }
  232. static inline void wda_qmi_client_exit(void *wda_data)
  233. {
  234. }
  235. static inline int wda_set_powersave_mode(void *wda_data, u8 enable)
  236. {
  237. return -EINVAL;
  238. }
  239. static inline void qmi_rmnet_flush_ps_wq(void)
  240. {
  241. }
  242. static inline void wda_qmi_client_release(void *wda_data)
  243. {
  244. }
  245. #endif
  246. #endif /*_RMNET_QMI_I_H*/