dp_ipa.h 12 KB

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