dp_ipa.h 10 KB

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