dp_be_tx.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef __DP_BE_TX_H
  20. #define __DP_BE_TX_H
  21. /**
  22. * DOC: dp_be_tx.h
  23. *
  24. * BE specific TX Datapath header file. Need not be exposed to common DP code.
  25. *
  26. */
  27. #include <dp_types.h>
  28. #include "dp_be.h"
  29. struct __attribute__((__packed__)) dp_tx_comp_peer_id {
  30. uint16_t peer_id:13,
  31. ml_peer_valid:1,
  32. reserved:2;
  33. };
  34. /* Invalid TX Bank ID value */
  35. #define DP_BE_INVALID_BANK_ID -1
  36. /* Extraction of msdu queue information from per packet sawf metadata */
  37. #define DP_TX_HLOS_TID_GET(_var) \
  38. (((_var) & 0x0e) >> 1)
  39. #define DP_TX_FLOW_OVERRIDE_GET(_var) \
  40. ((_var >> 3) & 0x1)
  41. #define DP_TX_WHO_CLFY_INF_SEL_GET(_var) \
  42. (((_var) & 0x30) >> 4)
  43. #define DP_TX_FLOW_OVERRIDE_ENABLE 0x1
  44. #define DP_TX_FAST_DESC_SIZE 28
  45. #define DP_TX_L3_L4_CSUM_ENABLE 0x1f
  46. #ifdef DP_USE_REDUCED_PEER_ID_FIELD_WIDTH
  47. static inline uint16_t
  48. dp_tx_comp_adjust_peer_id_be(struct dp_soc *soc, uint16_t peer_id)
  49. {
  50. struct dp_tx_comp_peer_id *tx_peer_id =
  51. (struct dp_tx_comp_peer_id *)&peer_id;
  52. return (tx_peer_id->peer_id |
  53. (tx_peer_id->ml_peer_valid << soc->peer_id_shift));
  54. }
  55. /**
  56. * dp_tx_comp_get_peer_id_be() - Get peer ID from TX Comp Desc
  57. * @soc: Handle to DP Soc structure
  58. * @tx_comp_hal_desc: TX comp ring descriptor
  59. *
  60. * Return: Peer ID
  61. */
  62. static inline uint16_t dp_tx_comp_get_peer_id_be(struct dp_soc *soc,
  63. void *tx_comp_hal_desc)
  64. {
  65. uint16_t peer_id = hal_tx_comp_get_peer_id(tx_comp_hal_desc);
  66. return dp_tx_comp_adjust_peer_id_be(soc, peer_id);
  67. }
  68. #else
  69. static inline uint16_t
  70. dp_tx_comp_adjust_peer_id_be(struct dp_soc *soc, uint16_t peer_id)
  71. {
  72. return peer_id;
  73. }
  74. static inline uint16_t dp_tx_comp_get_peer_id_be(struct dp_soc *soc,
  75. void *tx_comp_hal_desc)
  76. {
  77. return hal_tx_comp_get_peer_id(tx_comp_hal_desc);
  78. }
  79. #endif
  80. /**
  81. * dp_tx_hw_enqueue_be() - Enqueue to TCL HW for transmit for BE target
  82. * @soc: DP Soc Handle
  83. * @vdev: DP vdev handle
  84. * @tx_desc: Tx Descriptor Handle
  85. * @fw_metadata: Metadata to send to Target Firmware along with frame
  86. * @metadata: Handle that holds exception path meta data
  87. * @msdu_info: msdu_info containing information about TX buffer
  88. *
  89. * Gets the next free TCL HW DMA descriptor and sets up required parameters
  90. * from software Tx descriptor
  91. *
  92. * Return: QDF_STATUS_SUCCESS: success
  93. * QDF_STATUS_E_RESOURCES: Error return
  94. */
  95. QDF_STATUS dp_tx_hw_enqueue_be(struct dp_soc *soc, struct dp_vdev *vdev,
  96. struct dp_tx_desc_s *tx_desc,
  97. uint16_t fw_metadata,
  98. struct cdp_tx_exception_metadata *metadata,
  99. struct dp_tx_msdu_info_s *msdu_info);
  100. #ifdef QCA_DP_TX_NBUF_LIST_FREE
  101. /**
  102. * dp_tx_fast_send_be() - Transmit a frame on a given VAP
  103. * @soc_hdl: DP soc handle
  104. * @vdev_id: id of DP vdev handle
  105. * @nbuf: skb
  106. *
  107. * Entry point for Core Tx layer (DP_TX) invoked from
  108. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  109. * cases
  110. *
  111. * Return: NULL on success,
  112. * nbuf when it fails to send
  113. */
  114. qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  115. qdf_nbuf_t nbuf);
  116. #else
  117. static inline qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc, uint8_t vdev_id,
  118. qdf_nbuf_t nbuf)
  119. {
  120. return NULL;
  121. }
  122. #endif
  123. /**
  124. * dp_tx_comp_get_params_from_hal_desc_be() - Get TX desc from HAL comp desc
  125. * @soc: DP soc handle
  126. * @tx_comp_hal_desc: HAL TX Comp Descriptor
  127. * @r_tx_desc: SW Tx Descriptor retrieved from HAL desc.
  128. *
  129. * Return: None
  130. */
  131. void dp_tx_comp_get_params_from_hal_desc_be(struct dp_soc *soc,
  132. void *tx_comp_hal_desc,
  133. struct dp_tx_desc_s **r_tx_desc);
  134. /**
  135. * dp_tx_process_htt_completion_be() - Tx HTT Completion Indication Handler
  136. * @soc: Handle to DP soc structure
  137. * @tx_desc: software descriptor head pointer
  138. * @status: Tx completion status from HTT descriptor
  139. * @ring_id: ring number
  140. *
  141. * This function will process HTT Tx indication messages from Target
  142. *
  143. * Return: none
  144. */
  145. void dp_tx_process_htt_completion_be(struct dp_soc *soc,
  146. struct dp_tx_desc_s *tx_desc,
  147. uint8_t *status,
  148. uint8_t ring_id);
  149. /**
  150. * dp_tx_init_bank_profiles() - Init TX bank profiles
  151. * @soc: DP soc handle
  152. *
  153. * Return: QDF_STATUS_SUCCESS or QDF error code.
  154. */
  155. QDF_STATUS dp_tx_init_bank_profiles(struct dp_soc_be *soc);
  156. /**
  157. * dp_tx_deinit_bank_profiles() - De-Init TX bank profiles
  158. * @soc: DP soc handle
  159. *
  160. * Return: None
  161. */
  162. void dp_tx_deinit_bank_profiles(struct dp_soc_be *soc);
  163. /**
  164. * dp_tx_get_bank_profile() - get TX bank profile for vdev
  165. * @soc: DP soc handle
  166. * @be_vdev: BE vdev pointer
  167. *
  168. * Return: bank profile allocated to vdev or DP_BE_INVALID_BANK_ID
  169. */
  170. int dp_tx_get_bank_profile(struct dp_soc_be *soc,
  171. struct dp_vdev_be *be_vdev);
  172. /**
  173. * dp_tx_put_bank_profile() - release TX bank profile for vdev
  174. * @soc: DP soc handle
  175. * @be_vdev: pointer to be_vdev structure
  176. *
  177. * Return: None
  178. */
  179. void dp_tx_put_bank_profile(struct dp_soc_be *soc, struct dp_vdev_be *be_vdev);
  180. /**
  181. * dp_tx_update_bank_profile() - release existing and allocate new bank profile
  182. * @be_soc: DP soc handle
  183. * @be_vdev: pointer to be_vdev structure
  184. *
  185. * The function releases the existing bank profile allocated to the vdev and
  186. * looks for a new bank profile based on updated dp_vdev TX params.
  187. *
  188. * Return: None
  189. */
  190. void dp_tx_update_bank_profile(struct dp_soc_be *be_soc,
  191. struct dp_vdev_be *be_vdev);
  192. /**
  193. * dp_tx_desc_pool_init_be() - Initialize Tx Descriptor pool(s)
  194. * @soc: Handle to DP Soc structure
  195. * @num_elem: number of descriptor in pool
  196. * @pool_id: pool ID to allocate
  197. * @spcl_tx_desc: if special desc
  198. *
  199. * Return: QDF_STATUS_SUCCESS - success, others - failure
  200. */
  201. QDF_STATUS dp_tx_desc_pool_init_be(struct dp_soc *soc,
  202. uint32_t num_elem,
  203. uint8_t pool_id,
  204. bool spcl_tx_desc);
  205. /**
  206. * dp_tx_desc_pool_deinit_be() - De-initialize Tx Descriptor pool(s)
  207. * @soc: Handle to DP Soc structure
  208. * @tx_desc_pool: Tx descriptor pool handler
  209. * @pool_id: pool ID to deinit
  210. * @spcl_tx_desc: if special desc
  211. *
  212. * Return: None
  213. */
  214. void dp_tx_desc_pool_deinit_be(struct dp_soc *soc,
  215. struct dp_tx_desc_pool_s *tx_desc_pool,
  216. uint8_t pool_id, bool spcl_tx_desc);
  217. #ifdef WLAN_SUPPORT_PPEDS
  218. /**
  219. * dp_ppeds_tx_comp_handler()- Handle tx completions for ppe2tcl ring
  220. * @be_soc: Handle to DP Soc structure
  221. * @quota: Max number of tx completions to process
  222. *
  223. * Return: Number of tx completions processed
  224. */
  225. int dp_ppeds_tx_comp_handler(struct dp_soc_be *be_soc, uint32_t quota);
  226. /*
  227. * dp_ppeds_stats() - Accounting fw2wbm_tx_drop drops in Tx path
  228. * @soc: Handle to DP Soc structure
  229. * @peer_id: Peer ID in the descriptor
  230. *
  231. * Return: NONE
  232. */
  233. static inline
  234. void dp_ppeds_stats(struct dp_soc *soc, uint16_t peer_id);
  235. #endif
  236. #ifdef WLAN_FEATURE_11BE_MLO
  237. /**
  238. * dp_tx_mlo_mcast_handler_be() - Tx handler for Mcast packets
  239. * @soc: Handle to DP Soc structure
  240. * @vdev: DP vdev handle
  241. * @nbuf: nbuf to be enqueued
  242. *
  243. * Return: None
  244. */
  245. void dp_tx_mlo_mcast_handler_be(struct dp_soc *soc,
  246. struct dp_vdev *vdev,
  247. qdf_nbuf_t nbuf);
  248. /**
  249. * dp_tx_mlo_is_mcast_primary_be() - Function to check for primary mcast vdev
  250. * @soc: Handle to DP Soc structure
  251. * @vdev: DP vdev handle
  252. *
  253. * Return: True if vdev is mcast primary
  254. * False for all othercase
  255. */
  256. bool dp_tx_mlo_is_mcast_primary_be(struct dp_soc *soc,
  257. struct dp_vdev *vdev);
  258. #ifdef WLAN_MCAST_MLO
  259. #ifdef WLAN_MLO_MULTI_CHIP
  260. #ifdef CONFIG_MLO_SINGLE_DEV
  261. /**
  262. * dp_tx_mlo_mcast_send_be() - Tx send handler for mlo mcast enhance
  263. * @soc: DP soc handle
  264. * @vdev: DP vdev handle
  265. * @nbuf: skb
  266. * @tx_exc_metadata: Handle that holds exception path meta data
  267. *
  268. * Return: NULL for success
  269. * nbuf for failure
  270. */
  271. qdf_nbuf_t dp_tx_mlo_mcast_send_be(struct dp_soc *soc, struct dp_vdev *vdev,
  272. qdf_nbuf_t nbuf,
  273. struct cdp_tx_exception_metadata
  274. *tx_exc_metadata);
  275. #endif
  276. /**
  277. * dp_tx_mlo_mcast_pkt_send() - handler to send MLO Mcast packets
  278. * @be_vdev: Handle to DP be_vdev structure
  279. * @ptnr_vdev: DP ptnr_vdev handle
  280. * @arg: nbuf to be enqueued
  281. *
  282. * Return: None
  283. */
  284. void dp_tx_mlo_mcast_pkt_send(struct dp_vdev_be *be_vdev,
  285. struct dp_vdev *ptnr_vdev,
  286. void *arg);
  287. #endif
  288. #endif
  289. #endif
  290. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  291. /**
  292. * dp_tx_comp_nf_handler() - Tx completion ring Near full scenario handler
  293. * @int_ctx: Interrupt context
  294. * @soc: Datapath SoC handle
  295. * @hal_ring_hdl: TX completion ring handle
  296. * @ring_id: TX completion ring number
  297. * @quota: Quota of the work to be done
  298. *
  299. * Return: work done
  300. */
  301. uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  302. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  303. uint32_t quota);
  304. #else
  305. static inline
  306. uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  307. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  308. uint32_t quota)
  309. {
  310. return 0;
  311. }
  312. #endif /* WLAN_FEATURE_NEAR_FULL_IRQ */
  313. /**
  314. * dp_tx_compute_tx_delay_be() - Compute HW Tx completion delay
  315. * @soc: Handle to DP Soc structure
  316. * @vdev: vdev
  317. * @ts: Tx completion status
  318. * @delay_us: Delay to be calculated in microseconds
  319. *
  320. * Return: QDF_STATUS
  321. */
  322. QDF_STATUS dp_tx_compute_tx_delay_be(struct dp_soc *soc,
  323. struct dp_vdev *vdev,
  324. struct hal_tx_completion_status *ts,
  325. uint32_t *delay_us);
  326. /**
  327. * dp_tx_desc_pool_alloc_be() - Allocate TX descriptor pool
  328. * @soc: Handle to DP Soc structure
  329. * @num_elem: Number of elements to allocate
  330. * @pool_id: TCL descriptor pool ID
  331. *
  332. * Return: QDF_STATUS
  333. */
  334. QDF_STATUS dp_tx_desc_pool_alloc_be(struct dp_soc *soc, uint32_t num_elem,
  335. uint8_t pool_id);
  336. /**
  337. * dp_tx_desc_pool_free_be() - Free TX descriptor pool
  338. * @soc: Handle to DP Soc structure
  339. * @pool_id: TCL descriptor pool ID
  340. *
  341. * Return: none
  342. */
  343. void dp_tx_desc_pool_free_be(struct dp_soc *soc, uint8_t pool_id);
  344. #endif