dp_ipa.h 12 KB

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