dp_ipa.h 9.4 KB

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