dp_ipa.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * Copyright (c) 2017-2020, 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. /**
  27. * struct dp_ipa_uc_tx_hdr - full tx header registered to IPA hardware
  28. * @eth: ether II header
  29. */
  30. struct dp_ipa_uc_tx_hdr {
  31. struct ethhdr eth;
  32. } __packed;
  33. /**
  34. * struct dp_ipa_uc_rx_hdr - full rx header registered to IPA hardware
  35. * @eth: ether II header
  36. */
  37. struct dp_ipa_uc_rx_hdr {
  38. struct ethhdr eth;
  39. } __packed;
  40. #define DP_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct dp_ipa_uc_tx_hdr)
  41. #define DP_IPA_UC_WLAN_RX_HDR_LEN sizeof(struct dp_ipa_uc_rx_hdr)
  42. #define DP_IPA_UC_WLAN_HDR_DES_MAC_OFFSET 0
  43. /**
  44. * dp_ipa_get_resource() - Client request resource information
  45. * @soc_hdl - data path soc handle
  46. * @pdev_id - device instance id
  47. *
  48. * IPA client will request IPA UC related resource information
  49. * Resource information will be distributed to IPA module
  50. * All of the required resources should be pre-allocated
  51. *
  52. * Return: QDF_STATUS
  53. */
  54. QDF_STATUS dp_ipa_get_resource(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  55. /**
  56. * dp_ipa_set_doorbell_paddr () - Set doorbell register physical address to SRNG
  57. * @soc_hdl - data path soc handle
  58. * @pdev_id - device instance id
  59. *
  60. * Set TX_COMP_DOORBELL register physical address to WBM Head_Ptr_MemAddr_LSB
  61. * Set RX_READ_DOORBELL register physical address to REO Head_Ptr_MemAddr_LSB
  62. *
  63. * Return: none
  64. */
  65. QDF_STATUS dp_ipa_set_doorbell_paddr(struct cdp_soc_t *soc_hdl,
  66. uint8_t pdev_id);
  67. QDF_STATUS dp_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  68. bool uc_active, bool is_tx);
  69. /**
  70. * dp_ipa_op_response() - Handle OP command response from firmware
  71. * @soc_hdl - data path soc handle
  72. * @pdev_id - device instance id
  73. * @op_msg: op response message from firmware
  74. *
  75. * Return: none
  76. */
  77. QDF_STATUS dp_ipa_op_response(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  78. uint8_t *op_msg);
  79. /**
  80. * dp_ipa_register_op_cb() - Register OP handler function
  81. * @soc_hdl - data path soc handle
  82. * @pdev_id - device instance id
  83. * @op_cb: handler function pointer
  84. *
  85. * Return: none
  86. */
  87. QDF_STATUS dp_ipa_register_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  88. ipa_uc_op_cb_type op_cb, void *usr_ctxt);
  89. /**
  90. * dp_ipa_register_op_cb() - Deregister OP handler function
  91. * @soc_hdl - data path soc handle
  92. * @pdev_id - device instance id
  93. *
  94. * Return: none
  95. */
  96. void dp_ipa_deregister_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  97. /**
  98. * dp_ipa_get_stat() - Get firmware wdi status
  99. * @soc_hdl - data path soc handle
  100. * @pdev_id - device instance id
  101. *
  102. * Return: none
  103. */
  104. QDF_STATUS dp_ipa_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  105. /**
  106. * dp_tx_send_ipa_data_frame() - send IPA data frame
  107. * @soc_hdl: datapath soc handle
  108. * @vdev_id: virtual device/interface id
  109. * @skb: skb
  110. *
  111. * Return: skb/ NULL is for success
  112. */
  113. qdf_nbuf_t dp_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  114. qdf_nbuf_t skb);
  115. /**
  116. * dp_ipa_enable_autonomy() – Enable autonomy RX path
  117. * @soc_hdl - data path soc handle
  118. * @pdev_id - device instance id
  119. *
  120. * Set all RX packet route to IPA REO ring
  121. * Program Destination_Ring_Ctrl_IX_0 REO register to point IPA REO ring
  122. * Return: none
  123. */
  124. QDF_STATUS dp_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  125. /**
  126. * dp_ipa_disable_autonomy() – Disable autonomy RX path
  127. * @soc_hdl - data path soc handle
  128. * @pdev_id - device instance id
  129. *
  130. * Disable RX packet routing to IPA REO
  131. * Program Destination_Ring_Ctrl_IX_0 REO register to disable
  132. * Return: none
  133. */
  134. QDF_STATUS dp_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  135. #ifdef CONFIG_IPA_WDI_UNIFIED_API
  136. /**
  137. * dp_ipa_setup() - Setup and connect IPA pipes
  138. * @soc_hdl - data path soc handle
  139. * @pdev_id - device instance id
  140. * @ipa_i2w_cb: IPA to WLAN callback
  141. * @ipa_w2i_cb: WLAN to IPA callback
  142. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  143. * @ipa_desc_size: IPA descriptor size
  144. * @ipa_priv: handle to the HTT instance
  145. * @is_rm_enabled: Is IPA RM enabled or not
  146. * @tx_pipe_handle: pointer to Tx pipe handle
  147. * @rx_pipe_handle: pointer to Rx pipe handle
  148. * @is_smmu_enabled: Is SMMU enabled or not
  149. * @sys_in: parameters to setup sys pipe in mcc mode
  150. *
  151. * Return: QDF_STATUS
  152. */
  153. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  154. void *ipa_i2w_cb, void *ipa_w2i_cb,
  155. void *ipa_wdi_meter_notifier_cb,
  156. uint32_t ipa_desc_size, void *ipa_priv,
  157. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  158. uint32_t *rx_pipe_handle,
  159. bool is_smmu_enabled,
  160. qdf_ipa_sys_connect_params_t *sys_in, bool over_gsi);
  161. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  162. /**
  163. * dp_ipa_setup() - Setup and connect IPA pipes
  164. * @soc_hdl - data path soc handle
  165. * @pdev_id - device instance id
  166. * @ipa_i2w_cb: IPA to WLAN callback
  167. * @ipa_w2i_cb: WLAN to IPA callback
  168. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  169. * @ipa_desc_size: IPA descriptor size
  170. * @ipa_priv: handle to the HTT instance
  171. * @is_rm_enabled: Is IPA RM enabled or not
  172. * @tx_pipe_handle: pointer to Tx pipe handle
  173. * @rx_pipe_handle: pointer to Rx pipe handle
  174. *
  175. * Return: QDF_STATUS
  176. */
  177. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  178. void *ipa_i2w_cb, void *ipa_w2i_cb,
  179. void *ipa_wdi_meter_notifier_cb,
  180. uint32_t ipa_desc_size, void *ipa_priv,
  181. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  182. uint32_t *rx_pipe_handle);
  183. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  184. QDF_STATUS dp_ipa_cleanup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  185. uint32_t tx_pipe_handle,
  186. uint32_t rx_pipe_handle);
  187. QDF_STATUS dp_ipa_remove_header(char *name);
  188. int dp_ipa_add_header_info(char *ifname, uint8_t *mac_addr,
  189. uint8_t session_id, bool is_ipv6_enabled);
  190. int dp_ipa_register_interface(char *ifname, bool is_ipv6_enabled);
  191. QDF_STATUS dp_ipa_setup_iface(char *ifname, uint8_t *mac_addr,
  192. qdf_ipa_client_type_t prod_client,
  193. qdf_ipa_client_type_t cons_client,
  194. uint8_t session_id, bool is_ipv6_enabled);
  195. QDF_STATUS dp_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled);
  196. /**
  197. * dp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  198. * @soc_hdl - handle to the soc
  199. * @pdev_id - pdev id number, to get the handle
  200. *
  201. * Return: QDF_STATUS
  202. */
  203. QDF_STATUS dp_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  204. /**
  205. * dp_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
  206. * @soc_hdl - handle to the soc
  207. * @pdev_id - pdev id number, to get the handle
  208. *
  209. * Return: QDF_STATUS
  210. */
  211. QDF_STATUS dp_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  212. QDF_STATUS dp_ipa_set_perf_level(int client,
  213. uint32_t max_supported_bw_mbps);
  214. /**
  215. * dp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  216. *
  217. * @soc_hdl: data path soc handle
  218. * @vdev_id: virtual device/interface id
  219. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  220. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  221. *
  222. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  223. *
  224. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  225. * network stack. false if packet needs to be passed to network stack.
  226. */
  227. bool dp_ipa_rx_intrabss_fwd(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  228. qdf_nbuf_t nbuf, bool *fwd_success);
  229. int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev);
  230. int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev);
  231. int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  232. struct dp_pdev *pdev);
  233. QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  234. qdf_nbuf_t nbuf,
  235. uint32_t size,
  236. bool create);
  237. bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap1,
  238. uint32_t *remap2);
  239. bool dp_ipa_is_mdm_platform(void);
  240. qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, qdf_nbuf_t nbuf);
  241. /**
  242. * dp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA
  243. * allocated TX buffers
  244. * @soc_hdl: handle to the soc
  245. * @pdev_id: pdev id number, to get the handle
  246. *
  247. * Return: QDF_STATUS
  248. */
  249. QDF_STATUS dp_ipa_tx_buf_smmu_mapping(
  250. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  251. /**
  252. * dp_ipa_tx_buf_smmu_unmapping() - Release 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_unmapping(
  260. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  261. #else
  262. static inline int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev)
  263. {
  264. return QDF_STATUS_SUCCESS;
  265. }
  266. static inline int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev)
  267. {
  268. return QDF_STATUS_SUCCESS;
  269. }
  270. static inline int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  271. struct dp_pdev *pdev)
  272. {
  273. return 0;
  274. }
  275. static inline QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  276. qdf_nbuf_t nbuf,
  277. uint32_t size,
  278. bool create)
  279. {
  280. return QDF_STATUS_SUCCESS;
  281. }
  282. static inline qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc,
  283. qdf_nbuf_t nbuf)
  284. {
  285. return nbuf;
  286. }
  287. static inline QDF_STATUS dp_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
  288. uint8_t pdev_id)
  289. {
  290. return QDF_STATUS_SUCCESS;
  291. }
  292. static inline QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
  293. uint8_t pdev_id)
  294. {
  295. return QDF_STATUS_SUCCESS;
  296. }
  297. #endif
  298. #endif /* _DP_IPA_H_ */