dp_ipa.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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. * @id: IPA instance id
  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. bool is_smmu_enabled,
  196. qdf_ipa_sys_connect_params_t *sys_in, bool over_gsi,
  197. qdf_ipa_wdi_hdl_t hdl,
  198. qdf_ipa_wdi_hdl_t id);
  199. #else /* CONFIG_IPA_WDI_UNIFIED_API */
  200. /**
  201. * dp_ipa_setup() - Setup and connect IPA pipes
  202. * @soc_hdl - data path soc handle
  203. * @pdev_id - device instance id
  204. * @ipa_i2w_cb: IPA to WLAN callback
  205. * @ipa_w2i_cb: WLAN to IPA callback
  206. * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
  207. * @ipa_desc_size: IPA descriptor size
  208. * @ipa_priv: handle to the HTT instance
  209. * @is_rm_enabled: Is IPA RM enabled or not
  210. * @tx_pipe_handle: pointer to Tx pipe handle
  211. * @rx_pipe_handle: pointer to Rx pipe handle
  212. * @hdl: IPA handle
  213. *
  214. * Return: QDF_STATUS
  215. */
  216. QDF_STATUS dp_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  217. void *ipa_i2w_cb, void *ipa_w2i_cb,
  218. void *ipa_wdi_meter_notifier_cb,
  219. uint32_t ipa_desc_size, void *ipa_priv,
  220. bool is_rm_enabled, uint32_t *tx_pipe_handle,
  221. uint32_t *rx_pipe_handle);
  222. #endif /* CONFIG_IPA_WDI_UNIFIED_API */
  223. QDF_STATUS dp_ipa_cleanup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  224. uint32_t tx_pipe_handle,
  225. uint32_t rx_pipe_handle, qdf_ipa_wdi_hdl_t hdl);
  226. QDF_STATUS dp_ipa_remove_header(char *name);
  227. int dp_ipa_add_header_info(char *ifname, uint8_t *mac_addr,
  228. uint8_t session_id, bool is_ipv6_enabled);
  229. int dp_ipa_register_interface(char *ifname, bool is_ipv6_enabled);
  230. QDF_STATUS dp_ipa_setup_iface(char *ifname, uint8_t *mac_addr,
  231. qdf_ipa_client_type_t prod_client,
  232. qdf_ipa_client_type_t cons_client,
  233. uint8_t session_id, bool is_ipv6_enabled,
  234. qdf_ipa_wdi_hdl_t hdl);
  235. QDF_STATUS dp_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled,
  236. qdf_ipa_wdi_hdl_t hdl);
  237. /**
  238. * dp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
  239. * @soc_hdl - handle to the soc
  240. * @pdev_id - pdev id number, to get the handle
  241. * @hdl: IPA handle
  242. *
  243. * Return: QDF_STATUS
  244. */
  245. QDF_STATUS dp_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  246. qdf_ipa_wdi_hdl_t hdl);
  247. /**
  248. * dp_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
  249. * @soc_hdl - handle to the soc
  250. * @pdev_id - pdev id number, to get the handle
  251. * @hdl: IPA handle
  252. *
  253. * Return: QDF_STATUS
  254. */
  255. QDF_STATUS dp_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
  256. qdf_ipa_wdi_hdl_t hdl);
  257. QDF_STATUS dp_ipa_set_perf_level(int client, uint32_t max_supported_bw_mbps,
  258. qdf_ipa_wdi_hdl_t hdl);
  259. /**
  260. * dp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
  261. *
  262. * @soc_hdl: data path soc handle
  263. * @vdev_id: virtual device/interface id
  264. * @nbuf: pointer to skb of ethernet packet received from IPA RX path
  265. * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
  266. *
  267. * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
  268. *
  269. * Return: true if packet is intra-bss fwd-ed and no need to pass to
  270. * network stack. false if packet needs to be passed to network stack.
  271. */
  272. bool dp_ipa_rx_intrabss_fwd(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  273. qdf_nbuf_t nbuf, bool *fwd_success);
  274. int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev);
  275. int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev);
  276. int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  277. struct dp_pdev *pdev);
  278. QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  279. qdf_nbuf_t nbuf,
  280. uint32_t size,
  281. bool create);
  282. bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap0,
  283. uint32_t *remap1, uint32_t *remap2);
  284. bool dp_ipa_is_mdm_platform(void);
  285. qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc, qdf_nbuf_t nbuf);
  286. /**
  287. * dp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA
  288. * allocated TX buffers
  289. * @soc_hdl: handle to the soc
  290. * @pdev_id: pdev id number, to get the handle
  291. *
  292. * Return: QDF_STATUS
  293. */
  294. QDF_STATUS dp_ipa_tx_buf_smmu_mapping(
  295. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  296. /**
  297. * dp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for IPA
  298. * allocated TX buffers
  299. * @soc_hdl: handle to the soc
  300. * @pdev_id: pdev id number, to get the handle
  301. *
  302. * Return: QDF_STATUS
  303. */
  304. QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(
  305. struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
  306. #ifndef QCA_OL_DP_SRNG_LOCK_LESS_ACCESS
  307. static inline void
  308. dp_ipa_rx_buf_smmu_mapping_lock(struct dp_soc *soc)
  309. {
  310. if (soc->ipa_rx_buf_map_lock_initialized)
  311. qdf_spin_lock_bh(&soc->ipa_rx_buf_map_lock);
  312. }
  313. static inline void
  314. dp_ipa_rx_buf_smmu_mapping_unlock(struct dp_soc *soc)
  315. {
  316. if (soc->ipa_rx_buf_map_lock_initialized)
  317. qdf_spin_unlock_bh(&soc->ipa_rx_buf_map_lock);
  318. }
  319. static inline void
  320. dp_ipa_reo_ctx_buf_mapping_lock(struct dp_soc *soc,
  321. uint32_t reo_ring_num)
  322. {
  323. if (!soc->ipa_reo_ctx_lock_required[reo_ring_num])
  324. return;
  325. qdf_spin_lock_bh(&soc->ipa_rx_buf_map_lock);
  326. }
  327. static inline void
  328. dp_ipa_reo_ctx_buf_mapping_unlock(struct dp_soc *soc,
  329. uint32_t reo_ring_num)
  330. {
  331. if (!soc->ipa_reo_ctx_lock_required[reo_ring_num])
  332. return;
  333. qdf_spin_unlock_bh(&soc->ipa_rx_buf_map_lock);
  334. }
  335. #else
  336. static inline void
  337. dp_ipa_rx_buf_smmu_mapping_lock(struct dp_soc *soc)
  338. {
  339. }
  340. static inline void
  341. dp_ipa_rx_buf_smmu_mapping_unlock(struct dp_soc *soc)
  342. {
  343. }
  344. static inline void
  345. dp_ipa_reo_ctx_buf_mapping_lock(struct dp_soc *soc,
  346. uint32_t reo_ring_num)
  347. {
  348. }
  349. static inline void
  350. dp_ipa_reo_ctx_buf_mapping_unlock(struct dp_soc *soc,
  351. uint32_t reo_ring_num)
  352. {
  353. }
  354. #endif
  355. #else
  356. static inline int dp_ipa_uc_detach(struct dp_soc *soc, struct dp_pdev *pdev)
  357. {
  358. return QDF_STATUS_SUCCESS;
  359. }
  360. static inline int dp_ipa_uc_attach(struct dp_soc *soc, struct dp_pdev *pdev)
  361. {
  362. return QDF_STATUS_SUCCESS;
  363. }
  364. static inline int dp_ipa_ring_resource_setup(struct dp_soc *soc,
  365. struct dp_pdev *pdev)
  366. {
  367. return 0;
  368. }
  369. static inline QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,
  370. qdf_nbuf_t nbuf,
  371. uint32_t size,
  372. bool create)
  373. {
  374. return QDF_STATUS_SUCCESS;
  375. }
  376. static inline void
  377. dp_ipa_rx_buf_smmu_mapping_lock(struct dp_soc *soc)
  378. {
  379. }
  380. static inline void
  381. dp_ipa_rx_buf_smmu_mapping_unlock(struct dp_soc *soc)
  382. {
  383. }
  384. static inline void
  385. dp_ipa_reo_ctx_buf_mapping_lock(struct dp_soc *soc,
  386. uint32_t reo_ring_num)
  387. {
  388. }
  389. static inline void
  390. dp_ipa_reo_ctx_buf_mapping_unlock(struct dp_soc *soc,
  391. uint32_t reo_ring_num)
  392. {
  393. }
  394. static inline qdf_nbuf_t dp_ipa_handle_rx_reo_reinject(struct dp_soc *soc,
  395. qdf_nbuf_t nbuf)
  396. {
  397. return nbuf;
  398. }
  399. static inline QDF_STATUS dp_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
  400. uint8_t pdev_id)
  401. {
  402. return QDF_STATUS_SUCCESS;
  403. }
  404. static inline QDF_STATUS dp_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
  405. uint8_t pdev_id)
  406. {
  407. return QDF_STATUS_SUCCESS;
  408. }
  409. #endif
  410. #endif /* _DP_IPA_H_ */