dp_ipa.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. /*
  2. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 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. #define DP_IPA_HDL_INVALID 0xFF
  55. #define DP_IPA_HDL_FIRST 0
  56. #define DP_IPA_HDL_SECOND 1
  57. /**
  58. * wlan_ipa_get_hdl() - Get ipa handle from IPA component
  59. * @psoc - control psoc object
  60. * @pdev_id - pdev id
  61. *
  62. * IPA componenet will return the IPA handle based on pdev_id
  63. *
  64. * Return: IPA handle
  65. */
  66. qdf_ipa_wdi_hdl_t wlan_ipa_get_hdl(void *psoc, uint8_t pdev_id);
  67. /**
  68. * dp_ipa_get_resource() - Client request resource information
  69. * @soc_hdl - data path soc handle
  70. * @pdev_id - device instance id
  71. *
  72. * IPA client will request IPA UC related resource information
  73. * Resource information will be distributed to IPA module
  74. * All of the required resources should be pre-allocated
  75. *
  76. * Return: QDF_STATUS
  77. */
  78. QDF_STATUS dp_ipa_get_resource(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  79. /**
  80. * dp_ipa_set_doorbell_paddr () - Set doorbell register physical address to SRNG
  81. * @soc_hdl - data path soc handle
  82. * @pdev_id - device instance id
  83. *
  84. * Set TX_COMP_DOORBELL register physical address to WBM Head_Ptr_MemAddr_LSB
  85. * Set RX_READ_DOORBELL register physical address to REO Head_Ptr_MemAddr_LSB
  86. *
  87. * Return: none
  88. */
  89. QDF_STATUS dp_ipa_set_doorbell_paddr(struct cdp_soc_t *soc_hdl,
  90. uint8_t pdev_id);
  91. /**
  92. * dp_ipa_iounmap_doorbell_vaddr() - unmap ipa RX db vaddr
  93. * @soc_hdl - data path soc handle
  94. * @pdev_id - device instance id
  95. *
  96. * Return: none
  97. */
  98. QDF_STATUS dp_ipa_iounmap_doorbell_vaddr(struct cdp_soc_t *soc_hdl,
  99. uint8_t pdev_id);
  100. QDF_STATUS dp_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  101. bool uc_active, bool is_tx);
  102. /**
  103. * dp_ipa_op_response() - Handle OP command response from firmware
  104. * @soc_hdl - data path soc handle
  105. * @pdev_id - device instance id
  106. * @op_msg: op response message from firmware
  107. *
  108. * Return: none
  109. */
  110. QDF_STATUS dp_ipa_op_response(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  111. uint8_t *op_msg);
  112. /**
  113. * dp_ipa_register_op_cb() - Register OP handler function
  114. * @soc_hdl - data path soc handle
  115. * @pdev_id - device instance id
  116. * @op_cb: handler function pointer
  117. *
  118. * Return: none
  119. */
  120. QDF_STATUS dp_ipa_register_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  121. ipa_uc_op_cb_type op_cb, void *usr_ctxt);
  122. /**
  123. * dp_ipa_register_op_cb() - Deregister OP handler function
  124. * @soc_hdl - data path soc handle
  125. * @pdev_id - device instance id
  126. *
  127. * Return: none
  128. */
  129. void dp_ipa_deregister_op_cb(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  130. /**
  131. * dp_ipa_get_stat() - Get firmware wdi status
  132. * @soc_hdl - data path soc handle
  133. * @pdev_id - device instance id
  134. *
  135. * Return: none
  136. */
  137. QDF_STATUS dp_ipa_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  138. /**
  139. * dp_tx_send_ipa_data_frame() - send IPA data frame
  140. * @soc_hdl: datapath soc handle
  141. * @vdev_id: virtual device/interface id
  142. * @skb: skb
  143. *
  144. * Return: skb/ NULL is for success
  145. */
  146. qdf_nbuf_t dp_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  147. qdf_nbuf_t skb);
  148. /**
  149. * dp_ipa_enable_autonomy() – Enable autonomy RX path
  150. * @soc_hdl - data path soc handle
  151. * @pdev_id - device instance id
  152. *
  153. * Set all RX packet route to IPA REO ring
  154. * Program Destination_Ring_Ctrl_IX_0 REO register to point IPA REO ring
  155. * Return: none
  156. */
  157. QDF_STATUS dp_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  158. /**
  159. * dp_ipa_disable_autonomy() – Disable autonomy RX path
  160. * @soc_hdl - data path soc handle
  161. * @pdev_id - device instance id
  162. *
  163. * Disable RX packet routing to IPA REO
  164. * Program Destination_Ring_Ctrl_IX_0 REO register to disable
  165. * Return: none
  166. */
  167. QDF_STATUS dp_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  168. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \
  169. defined(CONFIG_IPA_WDI_UNIFIED_API)
  170. /**
  171. * dp_ipa_setup() - Setup and connect IPA pipes
  172. * @soc_hdl - data path soc handle
  173. * @pdev_id - device instance id
  174. * @ipa_i2w_cb: IPA to WLAN callback
  175. * @ipa_w2i_cb: WLAN to IPA callback
  176. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  177. * @ipa_desc_size: IPA descriptor size
  178. * @ipa_priv: handle to the HTT instance
  179. * @is_rm_enabled: Is IPA RM enabled or not
  180. * @tx_pipe_handle: pointer to Tx pipe handle
  181. * @rx_pipe_handle: pointer to Rx pipe handle
  182. * @is_smmu_enabled: Is SMMU enabled or not
  183. * @sys_in: parameters to setup sys pipe in mcc mode
  184. * @hdl: IPA handle
  185. *
  186. * Return: QDF_STATUS
  187. */
  188. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  189. void *ipa_i2w_cb, void *ipa_w2i_cb,
  190. void *ipa_wdi_meter_notifier_cb,
  191. uint32_t ipa_desc_size, void *ipa_priv,
  192. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  193. uint32_t *rx_pipe_handle,
  194. bool is_smmu_enabled,
  195. qdf_ipa_sys_connect_params_t *sys_in, bool over_gsi,
  196. qdf_ipa_wdi_hdl_t hdl);
  197. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  198. /**
  199. * dp_ipa_setup() - Setup and connect IPA pipes
  200. * @soc_hdl - data path soc handle
  201. * @pdev_id - device instance id
  202. * @ipa_i2w_cb: IPA to WLAN callback
  203. * @ipa_w2i_cb: WLAN to IPA callback
  204. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  205. * @ipa_desc_size: IPA descriptor size
  206. * @ipa_priv: handle to the HTT instance
  207. * @is_rm_enabled: Is IPA RM enabled or not
  208. * @tx_pipe_handle: pointer to Tx pipe handle
  209. * @rx_pipe_handle: pointer to Rx pipe handle
  210. * @hdl: IPA handle
  211. *
  212. * Return: QDF_STATUS
  213. */
  214. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  215. void *ipa_i2w_cb, void *ipa_w2i_cb,
  216. void *ipa_wdi_meter_notifier_cb,
  217. uint32_t ipa_desc_size, void *ipa_priv,
  218. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  219. uint32_t *rx_pipe_handle);
  220. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  221. QDF_STATUS dp_ipa_cleanup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  222. uint32_t tx_pipe_handle,
  223. uint32_t rx_pipe_handle, qdf_ipa_wdi_hdl_t hdl);
  224. QDF_STATUS dp_ipa_remove_header(char *name);
  225. int dp_ipa_add_header_info(char *ifname, uint8_t *mac_addr,
  226. uint8_t session_id, bool is_ipv6_enabled);
  227. int dp_ipa_register_interface(char *ifname, bool is_ipv6_enabled);
  228. QDF_STATUS dp_ipa_setup_iface(char *ifname, uint8_t *mac_addr,
  229. qdf_ipa_client_type_t prod_client,
  230. qdf_ipa_client_type_t cons_client,
  231. uint8_t session_id, bool is_ipv6_enabled,
  232. qdf_ipa_wdi_hdl_t hdl);
  233. QDF_STATUS dp_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled,
  234. qdf_ipa_wdi_hdl_t hdl);
  235. /**
  236. * dp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  237. * @soc_hdl - handle to the soc
  238. * @pdev_id - pdev id number, to get the handle
  239. * @hdl: IPA handle
  240. *
  241. * Return: QDF_STATUS
  242. */
  243. QDF_STATUS dp_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  244. qdf_ipa_wdi_hdl_t hdl);
  245. /**
  246. * dp_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
  247. * @soc_hdl - handle to the soc
  248. * @pdev_id - pdev id number, to get the handle
  249. * @hdl: IPA handle
  250. *
  251. * Return: QDF_STATUS
  252. */
  253. QDF_STATUS dp_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  254. qdf_ipa_wdi_hdl_t hdl);
  255. QDF_STATUS dp_ipa_set_perf_level(int client, uint32_t max_supported_bw_mbps,
  256. qdf_ipa_wdi_hdl_t hdl);
  257. /**
  258. * dp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  259. *
  260. * @soc_hdl: data path soc handle
  261. * @vdev_id: virtual device/interface id
  262. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  263. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  264. *
  265. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  266. *
  267. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  268. * network stack. false if packet needs to be passed to network stack.
  269. */
  270. bool dp_ipa_rx_intrabss_fwd(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  271. qdf_nbuf_t nbuf, bool *fwd_success);
  272. int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev);
  273. int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev);
  274. int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  275. struct dp_pdev *pdev);
  276. QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  277. qdf_nbuf_t nbuf,
  278. uint32_t size,
  279. bool create);
  280. bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap0,
  281. uint32_t *remap1, uint32_t *remap2);
  282. bool dp_ipa_is_mdm_platform(void);
  283. qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, qdf_nbuf_t nbuf);
  284. /**
  285. * dp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA
  286. * allocated TX buffers
  287. * @soc_hdl: handle to the soc
  288. * @pdev_id: pdev id number, to get the handle
  289. *
  290. * Return: QDF_STATUS
  291. */
  292. QDF_STATUS dp_ipa_tx_buf_smmu_mapping(
  293. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  294. /**
  295. * dp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for IPA
  296. * allocated TX buffers
  297. * @soc_hdl: handle to the soc
  298. * @pdev_id: pdev id number, to get the handle
  299. *
  300. * Return: QDF_STATUS
  301. */
  302. QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(
  303. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  304. #ifndef QCA_OL_DP_SRNG_LOCK_LESS_ACCESS
  305. static inline void
  306. dp_ipa_rx_buf_smmu_mapping_lock(struct dp_soc *soc)
  307. {
  308. if (soc->ipa_rx_buf_map_lock_initialized)
  309. qdf_spin_lock_bh(&soc->ipa_rx_buf_map_lock);
  310. }
  311. static inline void
  312. dp_ipa_rx_buf_smmu_mapping_unlock(struct dp_soc *soc)
  313. {
  314. if (soc->ipa_rx_buf_map_lock_initialized)
  315. qdf_spin_unlock_bh(&soc->ipa_rx_buf_map_lock);
  316. }
  317. static inline void
  318. dp_ipa_reo_ctx_buf_mapping_lock(struct dp_soc *soc,
  319. uint32_t reo_ring_num)
  320. {
  321. if (!soc->ipa_reo_ctx_lock_required[reo_ring_num])
  322. return;
  323. qdf_spin_lock_bh(&soc->ipa_rx_buf_map_lock);
  324. }
  325. static inline void
  326. dp_ipa_reo_ctx_buf_mapping_unlock(struct dp_soc *soc,
  327. uint32_t reo_ring_num)
  328. {
  329. if (!soc->ipa_reo_ctx_lock_required[reo_ring_num])
  330. return;
  331. qdf_spin_unlock_bh(&soc->ipa_rx_buf_map_lock);
  332. }
  333. #else
  334. static inline void
  335. dp_ipa_rx_buf_smmu_mapping_lock(struct dp_soc *soc)
  336. {
  337. }
  338. static inline void
  339. dp_ipa_rx_buf_smmu_mapping_unlock(struct dp_soc *soc)
  340. {
  341. }
  342. static inline void
  343. dp_ipa_reo_ctx_buf_mapping_lock(struct dp_soc *soc,
  344. uint32_t reo_ring_num)
  345. {
  346. }
  347. static inline void
  348. dp_ipa_reo_ctx_buf_mapping_unlock(struct dp_soc *soc,
  349. uint32_t reo_ring_num)
  350. {
  351. }
  352. #endif
  353. #else
  354. static inline int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev)
  355. {
  356. return QDF_STATUS_SUCCESS;
  357. }
  358. static inline int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev)
  359. {
  360. return QDF_STATUS_SUCCESS;
  361. }
  362. static inline int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  363. struct dp_pdev *pdev)
  364. {
  365. return 0;
  366. }
  367. static inline QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  368. qdf_nbuf_t nbuf,
  369. uint32_t size,
  370. bool create)
  371. {
  372. return QDF_STATUS_SUCCESS;
  373. }
  374. static inline void
  375. dp_ipa_rx_buf_smmu_mapping_lock(struct dp_soc *soc)
  376. {
  377. }
  378. static inline void
  379. dp_ipa_rx_buf_smmu_mapping_unlock(struct dp_soc *soc)
  380. {
  381. }
  382. static inline void
  383. dp_ipa_reo_ctx_buf_mapping_lock(struct dp_soc *soc,
  384. uint32_t reo_ring_num)
  385. {
  386. }
  387. static inline void
  388. dp_ipa_reo_ctx_buf_mapping_unlock(struct dp_soc *soc,
  389. uint32_t reo_ring_num)
  390. {
  391. }
  392. static inline qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc,
  393. qdf_nbuf_t nbuf)
  394. {
  395. return nbuf;
  396. }
  397. static inline QDF_STATUS dp_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
  398. uint8_t pdev_id)
  399. {
  400. return QDF_STATUS_SUCCESS;
  401. }
  402. static inline QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
  403. uint8_t pdev_id)
  404. {
  405. return QDF_STATUS_SUCCESS;
  406. }
  407. #endif
  408. #endif /* _DP_IPA_H_ */