qmi_rmnet_i.h 5.5 KB

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