dp_ipa.h 12 KB

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