dp_ipa.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /*
  2. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef _DP_IPA_H_
  17. #define _DP_IPA_H_
  18. #define IPA_TCL_DATA_RING_IDX 2
  19. #ifdef IPA_OFFLOAD
  20. #define DP_IPA_MAX_IFACE 3
  21. #define IPA_REO_DEST_RING_IDX 3
  22. #define IPA_RX_REFILL_BUF_RING_IDX 2
  23. /* Adding delay before disabling ipa pipes if any Tx Completions are pending */
  24. #define TX_COMP_DRAIN_WAIT_MS 50
  25. #define TX_COMP_DRAIN_WAIT_TIMEOUT_MS 100
  26. #ifdef IPA_WDI3_TX_TWO_PIPES
  27. #define IPA_TX_ALT_RING_IDX 1
  28. /*
  29. * must be same as IPA_TX_ALT_RING_IDX as tcl and wbm ring
  30. * are initialized with same index as a pair.
  31. */
  32. #define IPA_TX_ALT_COMP_RING_IDX 1
  33. #define IPA_SESSION_ID_SHIFT 1
  34. #endif
  35. /**
  36. * struct dp_ipa_uc_tx_hdr - full tx header registered to IPA hardware
  37. * @eth: ether II header
  38. */
  39. struct dp_ipa_uc_tx_hdr {
  40. struct ethhdr eth;
  41. } __packed;
  42. /**
  43. * struct dp_ipa_uc_rx_hdr - full rx header registered to IPA hardware
  44. * @eth: ether II header
  45. */
  46. struct dp_ipa_uc_rx_hdr {
  47. struct ethhdr eth;
  48. } __packed;
  49. #define DP_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct dp_ipa_uc_tx_hdr)
  50. #define DP_IPA_UC_WLAN_RX_HDR_LEN sizeof(struct dp_ipa_uc_rx_hdr)
  51. #define DP_IPA_UC_WLAN_HDR_DES_MAC_OFFSET 0
  52. /**
  53. * dp_ipa_get_resource() - Client request resource information
  54. * @soc_hdl - data path soc handle
  55. * @pdev_id - device instance id
  56. *
  57. * IPA client will request IPA UC related resource information
  58. * Resource information will be distributed to IPA module
  59. * All of the required resources should be pre-allocated
  60. *
  61. * Return: QDF_STATUS
  62. */
  63. QDF_STATUS dp_ipa_get_resource(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  64. /**
  65. * dp_ipa_set_doorbell_paddr () - Set doorbell register physical address to SRNG
  66. * @soc_hdl - data path soc handle
  67. * @pdev_id - device instance id
  68. *
  69. * Set TX_COMP_DOORBELL register physical address to WBM Head_Ptr_MemAddr_LSB
  70. * Set RX_READ_DOORBELL register physical address to REO Head_Ptr_MemAddr_LSB
  71. *
  72. * Return: none
  73. */
  74. QDF_STATUS dp_ipa_set_doorbell_paddr(struct cdp_soc_t *soc_hdl,
  75. uint8_t pdev_id);
  76. QDF_STATUS dp_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  77. bool uc_active, bool is_tx);
  78. /**
  79. * dp_ipa_op_response() - Handle OP command response from firmware
  80. * @soc_hdl - data path soc handle
  81. * @pdev_id - device instance id
  82. * @op_msg: op response message from firmware
  83. *
  84. * Return: none
  85. */
  86. QDF_STATUS dp_ipa_op_response(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  87. uint8_t *op_msg);
  88. /**
  89. * dp_ipa_register_op_cb() - Register OP handler function
  90. * @soc_hdl - data path soc handle
  91. * @pdev_id - device instance id
  92. * @op_cb: handler function pointer
  93. *
  94. * Return: none
  95. */
  96. QDF_STATUS dp_ipa_register_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  97. ipa_uc_op_cb_type op_cb, void *usr_ctxt);
  98. /**
  99. * dp_ipa_register_op_cb() - Deregister OP handler function
  100. * @soc_hdl - data path soc handle
  101. * @pdev_id - device instance id
  102. *
  103. * Return: none
  104. */
  105. void dp_ipa_deregister_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  106. /**
  107. * dp_ipa_get_stat() - Get firmware wdi status
  108. * @soc_hdl - data path soc handle
  109. * @pdev_id - device instance id
  110. *
  111. * Return: none
  112. */
  113. QDF_STATUS dp_ipa_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  114. /**
  115. * dp_tx_send_ipa_data_frame() - send IPA data frame
  116. * @soc_hdl: datapath soc handle
  117. * @vdev_id: virtual device/interface id
  118. * @skb: skb
  119. *
  120. * Return: skb/ NULL is for success
  121. */
  122. qdf_nbuf_t dp_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  123. qdf_nbuf_t skb);
  124. /**
  125. * dp_ipa_enable_autonomy() – Enable autonomy RX path
  126. * @soc_hdl - data path soc handle
  127. * @pdev_id - device instance id
  128. *
  129. * Set all RX packet route to IPA REO ring
  130. * Program Destination_Ring_Ctrl_IX_0 REO register to point IPA REO ring
  131. * Return: none
  132. */
  133. QDF_STATUS dp_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  134. /**
  135. * dp_ipa_disable_autonomy() – Disable autonomy RX path
  136. * @soc_hdl - data path soc handle
  137. * @pdev_id - device instance id
  138. *
  139. * Disable RX packet routing to IPA REO
  140. * Program Destination_Ring_Ctrl_IX_0 REO register to disable
  141. * Return: none
  142. */
  143. QDF_STATUS dp_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  144. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \
  145. defined(CONFIG_IPA_WDI_UNIFIED_API)
  146. /**
  147. * dp_ipa_setup() - Setup and connect IPA pipes
  148. * @soc_hdl - data path soc handle
  149. * @pdev_id - device instance id
  150. * @ipa_i2w_cb: IPA to WLAN callback
  151. * @ipa_w2i_cb: WLAN to IPA callback
  152. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  153. * @ipa_desc_size: IPA descriptor size
  154. * @ipa_priv: handle to the HTT instance
  155. * @is_rm_enabled: Is IPA RM enabled or not
  156. * @tx_pipe_handle: pointer to Tx pipe handle
  157. * @rx_pipe_handle: pointer to Rx pipe handle
  158. * @is_smmu_enabled: Is SMMU enabled or not
  159. * @sys_in: parameters to setup sys pipe in mcc mode
  160. *
  161. * Return: QDF_STATUS
  162. */
  163. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  164. void *ipa_i2w_cb, void *ipa_w2i_cb,
  165. void *ipa_wdi_meter_notifier_cb,
  166. uint32_t ipa_desc_size, void *ipa_priv,
  167. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  168. uint32_t *rx_pipe_handle,
  169. bool is_smmu_enabled,
  170. qdf_ipa_sys_connect_params_t *sys_in, bool over_gsi);
  171. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  172. /**
  173. * dp_ipa_setup() - Setup and connect IPA pipes
  174. * @soc_hdl - data path soc handle
  175. * @pdev_id - device instance id
  176. * @ipa_i2w_cb: IPA to WLAN callback
  177. * @ipa_w2i_cb: WLAN to IPA callback
  178. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  179. * @ipa_desc_size: IPA descriptor size
  180. * @ipa_priv: handle to the HTT instance
  181. * @is_rm_enabled: Is IPA RM enabled or not
  182. * @tx_pipe_handle: pointer to Tx pipe handle
  183. * @rx_pipe_handle: pointer to Rx pipe handle
  184. *
  185. * Return: QDF_STATUS
  186. */
  187. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  188. void *ipa_i2w_cb, void *ipa_w2i_cb,
  189. void *ipa_wdi_meter_notifier_cb,
  190. uint32_t ipa_desc_size, void *ipa_priv,
  191. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  192. uint32_t *rx_pipe_handle);
  193. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  194. QDF_STATUS dp_ipa_cleanup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  195. uint32_t tx_pipe_handle,
  196. uint32_t rx_pipe_handle);
  197. QDF_STATUS dp_ipa_remove_header(char *name);
  198. int dp_ipa_add_header_info(char *ifname, uint8_t *mac_addr,
  199. uint8_t session_id, bool is_ipv6_enabled);
  200. int dp_ipa_register_interface(char *ifname, bool is_ipv6_enabled);
  201. QDF_STATUS dp_ipa_setup_iface(char *ifname, uint8_t *mac_addr,
  202. qdf_ipa_client_type_t prod_client,
  203. qdf_ipa_client_type_t cons_client,
  204. uint8_t session_id, bool is_ipv6_enabled);
  205. QDF_STATUS dp_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled);
  206. /**
  207. * dp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  208. * @soc_hdl - handle to the soc
  209. * @pdev_id - pdev id number, to get the handle
  210. *
  211. * Return: QDF_STATUS
  212. */
  213. QDF_STATUS dp_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  214. /**
  215. * dp_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
  216. * @soc_hdl - handle to the soc
  217. * @pdev_id - pdev id number, to get the handle
  218. *
  219. * Return: QDF_STATUS
  220. */
  221. QDF_STATUS dp_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  222. QDF_STATUS dp_ipa_set_perf_level(int client,
  223. uint32_t max_supported_bw_mbps);
  224. /**
  225. * dp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  226. *
  227. * @soc_hdl: data path soc handle
  228. * @vdev_id: virtual device/interface id
  229. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  230. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  231. *
  232. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  233. *
  234. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  235. * network stack. false if packet needs to be passed to network stack.
  236. */
  237. bool dp_ipa_rx_intrabss_fwd(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  238. qdf_nbuf_t nbuf, bool *fwd_success);
  239. int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev);
  240. int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev);
  241. int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  242. struct dp_pdev *pdev);
  243. QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  244. qdf_nbuf_t nbuf,
  245. uint32_t size,
  246. bool create);
  247. bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap1,
  248. uint32_t *remap2);
  249. bool dp_ipa_is_mdm_platform(void);
  250. qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, qdf_nbuf_t nbuf);
  251. /**
  252. * dp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA
  253. * allocated TX buffers
  254. * @soc_hdl: handle to the soc
  255. * @pdev_id: pdev id number, to get the handle
  256. *
  257. * Return: QDF_STATUS
  258. */
  259. QDF_STATUS dp_ipa_tx_buf_smmu_mapping(
  260. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  261. /**
  262. * dp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for IPA
  263. * allocated TX buffers
  264. * @soc_hdl: handle to the soc
  265. * @pdev_id: pdev id number, to get the handle
  266. *
  267. * Return: QDF_STATUS
  268. */
  269. QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(
  270. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  271. #else
  272. static inline int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev)
  273. {
  274. return QDF_STATUS_SUCCESS;
  275. }
  276. static inline int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev)
  277. {
  278. return QDF_STATUS_SUCCESS;
  279. }
  280. static inline int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  281. struct dp_pdev *pdev)
  282. {
  283. return 0;
  284. }
  285. static inline QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  286. qdf_nbuf_t nbuf,
  287. uint32_t size,
  288. bool create)
  289. {
  290. return QDF_STATUS_SUCCESS;
  291. }
  292. static inline qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc,
  293. qdf_nbuf_t nbuf)
  294. {
  295. return nbuf;
  296. }
  297. static inline QDF_STATUS dp_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
  298. uint8_t pdev_id)
  299. {
  300. return QDF_STATUS_SUCCESS;
  301. }
  302. static inline QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
  303. uint8_t pdev_id)
  304. {
  305. return QDF_STATUS_SUCCESS;
  306. }
  307. #endif
  308. #endif /* _DP_IPA_H_ */