dp_be_tx.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. /**
  48. * dp_tx_comp_get_peer_id_be() - Get peer ID from TX Comp Desc
  49. * @soc: Handle to DP Soc structure
  50. * @tx_comp_hal_desc: TX comp ring descriptor
  51. *
  52. * Return: Peer ID
  53. */
  54. static inline uint16_t dp_tx_comp_get_peer_id_be(struct dp_soc *soc,
  55. void *tx_comp_hal_desc)
  56. {
  57. uint16_t peer_id = hal_tx_comp_get_peer_id(tx_comp_hal_desc);
  58. struct dp_tx_comp_peer_id *tx_peer_id =
  59. (struct dp_tx_comp_peer_id *)&peer_id;
  60. return (tx_peer_id->peer_id |
  61. (tx_peer_id->ml_peer_valid << soc->peer_id_shift));
  62. }
  63. #else
  64. static inline uint16_t dp_tx_comp_get_peer_id_be(struct dp_soc *soc,
  65. void *tx_comp_hal_desc)
  66. {
  67. return hal_tx_comp_get_peer_id(tx_comp_hal_desc);
  68. }
  69. #endif
  70. /**
  71. * dp_tx_hw_enqueue_be() - Enqueue to TCL HW for transmit for BE target
  72. * @soc: DP Soc Handle
  73. * @vdev: DP vdev handle
  74. * @tx_desc: Tx Descriptor Handle
  75. * @fw_metadata: Metadata to send to Target Firmware along with frame
  76. * @metadata: Handle that holds exception path meta data
  77. * @msdu_info: msdu_info containing information about TX buffer
  78. *
  79. * Gets the next free TCL HW DMA descriptor and sets up required parameters
  80. * from software Tx descriptor
  81. *
  82. * Return: QDF_STATUS_SUCCESS: success
  83. * QDF_STATUS_E_RESOURCES: Error return
  84. */
  85. QDF_STATUS dp_tx_hw_enqueue_be(struct dp_soc *soc, struct dp_vdev *vdev,
  86. struct dp_tx_desc_s *tx_desc,
  87. uint16_t fw_metadata,
  88. struct cdp_tx_exception_metadata *metadata,
  89. struct dp_tx_msdu_info_s *msdu_info);
  90. #ifdef QCA_DP_TX_NBUF_LIST_FREE
  91. /**
  92. * dp_tx_fast_send_be() - Transmit a frame on a given VAP
  93. * @soc_hdl: DP soc handle
  94. * @vdev_id: id of DP vdev handle
  95. * @nbuf: skb
  96. *
  97. * Entry point for Core Tx layer (DP_TX) invoked from
  98. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  99. * cases
  100. *
  101. * Return: NULL on success,
  102. * nbuf when it fails to send
  103. */
  104. qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  105. qdf_nbuf_t nbuf);
  106. #else
  107. static inline qdf_nbuf_t dp_tx_fast_send_be(struct cdp_soc_t *soc, uint8_t vdev_id,
  108. qdf_nbuf_t nbuf)
  109. {
  110. return NULL;
  111. }
  112. #endif
  113. /**
  114. * dp_tx_comp_get_params_from_hal_desc_be() - Get TX desc from HAL comp desc
  115. * @soc: DP soc handle
  116. * @tx_comp_hal_desc: HAL TX Comp Descriptor
  117. * @r_tx_desc: SW Tx Descriptor retrieved from HAL desc.
  118. *
  119. * Return: None
  120. */
  121. void dp_tx_comp_get_params_from_hal_desc_be(struct dp_soc *soc,
  122. void *tx_comp_hal_desc,
  123. struct dp_tx_desc_s **r_tx_desc);
  124. /**
  125. * dp_tx_process_htt_completion_be() - Tx HTT Completion Indication Handler
  126. * @soc: Handle to DP soc structure
  127. * @tx_desc: software descriptor head pointer
  128. * @status: Tx completion status from HTT descriptor
  129. * @ring_id: ring number
  130. *
  131. * This function will process HTT Tx indication messages from Target
  132. *
  133. * Return: none
  134. */
  135. void dp_tx_process_htt_completion_be(struct dp_soc *soc,
  136. struct dp_tx_desc_s *tx_desc,
  137. uint8_t *status,
  138. uint8_t ring_id);
  139. /**
  140. * dp_tx_init_bank_profiles() - Init TX bank profiles
  141. * @soc: DP soc handle
  142. *
  143. * Return: QDF_STATUS_SUCCESS or QDF error code.
  144. */
  145. QDF_STATUS dp_tx_init_bank_profiles(struct dp_soc_be *soc);
  146. /**
  147. * dp_tx_deinit_bank_profiles() - De-Init TX bank profiles
  148. * @soc: DP soc handle
  149. *
  150. * Return: None
  151. */
  152. void dp_tx_deinit_bank_profiles(struct dp_soc_be *soc);
  153. /**
  154. * dp_tx_get_bank_profile() - get TX bank profile for vdev
  155. * @soc: DP soc handle
  156. * @be_vdev: BE vdev pointer
  157. *
  158. * Return: bank profile allocated to vdev or DP_BE_INVALID_BANK_ID
  159. */
  160. int dp_tx_get_bank_profile(struct dp_soc_be *soc,
  161. struct dp_vdev_be *be_vdev);
  162. /**
  163. * dp_tx_put_bank_profile() - release TX bank profile for vdev
  164. * @soc: DP soc handle
  165. * @be_vdev: pointer to be_vdev structure
  166. *
  167. * Return: None
  168. */
  169. void dp_tx_put_bank_profile(struct dp_soc_be *soc, struct dp_vdev_be *be_vdev);
  170. /**
  171. * dp_tx_update_bank_profile() - release existing and allocate new bank profile
  172. * @be_soc: DP soc handle
  173. * @be_vdev: pointer to be_vdev structure
  174. *
  175. * The function releases the existing bank profile allocated to the vdev and
  176. * looks for a new bank profile based on updated dp_vdev TX params.
  177. *
  178. * Return: None
  179. */
  180. void dp_tx_update_bank_profile(struct dp_soc_be *be_soc,
  181. struct dp_vdev_be *be_vdev);
  182. /**
  183. * dp_tx_desc_pool_init_be() - Initialize Tx Descriptor pool(s)
  184. * @soc: Handle to DP Soc structure
  185. * @num_elem: number of descriptor in pool
  186. * @pool_id: pool ID to allocate
  187. *
  188. * Return: QDF_STATUS_SUCCESS - success, others - failure
  189. */
  190. QDF_STATUS dp_tx_desc_pool_init_be(struct dp_soc *soc,
  191. uint32_t num_elem,
  192. uint8_t pool_id);
  193. /**
  194. * dp_tx_desc_pool_deinit_be() - De-initialize Tx Descriptor pool(s)
  195. * @soc: Handle to DP Soc structure
  196. * @tx_desc_pool: Tx descriptor pool handler
  197. * @pool_id: pool ID to deinit
  198. *
  199. * Return: None
  200. */
  201. void dp_tx_desc_pool_deinit_be(struct dp_soc *soc,
  202. struct dp_tx_desc_pool_s *tx_desc_pool,
  203. uint8_t pool_id);
  204. #ifdef WLAN_SUPPORT_PPEDS
  205. /**
  206. * dp_ppeds_tx_comp_handler()- Handle tx completions for ppe2tcl ring
  207. * @be_soc: Handle to DP Soc structure
  208. * @quota: Max number of tx completions to process
  209. *
  210. * Return: Number of tx completions processed
  211. */
  212. int dp_ppeds_tx_comp_handler(struct dp_soc_be *be_soc, uint32_t quota);
  213. /*
  214. * dp_ppeds_stats() - Accounting fw2wbm_tx_drop drops in Tx path
  215. * @soc: Handle to DP Soc structure
  216. * @peer_id: Peer ID in the descriptor
  217. *
  218. * Return: NONE
  219. */
  220. static inline
  221. void dp_ppeds_stats(struct dp_soc *soc, uint16_t peer_id);
  222. #endif
  223. #ifdef WLAN_FEATURE_11BE_MLO
  224. /**
  225. * dp_tx_mlo_mcast_handler_be() - Tx handler for Mcast packets
  226. * @soc: Handle to DP Soc structure
  227. * @vdev: DP vdev handle
  228. * @nbuf: nbuf to be enqueued
  229. *
  230. * Return: None
  231. */
  232. void dp_tx_mlo_mcast_handler_be(struct dp_soc *soc,
  233. struct dp_vdev *vdev,
  234. qdf_nbuf_t nbuf);
  235. /**
  236. * dp_tx_mlo_is_mcast_primary_be() - Function to check for primary mcast vdev
  237. * @soc: Handle to DP Soc structure
  238. * @vdev: DP vdev handle
  239. *
  240. * Return: True if vdev is mcast primary
  241. * False for all othercase
  242. */
  243. bool dp_tx_mlo_is_mcast_primary_be(struct dp_soc *soc,
  244. struct dp_vdev *vdev);
  245. #ifdef WLAN_MCAST_MLO
  246. #ifdef WLAN_MLO_MULTI_CHIP
  247. #ifdef CONFIG_MLO_SINGLE_DEV
  248. /**
  249. * dp_tx_mlo_mcast_send_be() - Tx send handler for mlo mcast enhance
  250. * @soc: DP soc handle
  251. * @vdev: DP vdev handle
  252. * @nbuf: skb
  253. * @tx_exc_metadata: Handle that holds exception path meta data
  254. *
  255. * Return: NULL for success
  256. * nbuf for failure
  257. */
  258. qdf_nbuf_t dp_tx_mlo_mcast_send_be(struct dp_soc *soc, struct dp_vdev *vdev,
  259. qdf_nbuf_t nbuf,
  260. struct cdp_tx_exception_metadata
  261. *tx_exc_metadata);
  262. #endif
  263. /**
  264. * dp_tx_mlo_mcast_pkt_send() - handler to send MLO Mcast packets
  265. * @be_vdev: Handle to DP be_vdev structure
  266. * @ptnr_vdev: DP ptnr_vdev handle
  267. * @arg: nbuf to be enqueued
  268. *
  269. * Return: None
  270. */
  271. void dp_tx_mlo_mcast_pkt_send(struct dp_vdev_be *be_vdev,
  272. struct dp_vdev *ptnr_vdev,
  273. void *arg);
  274. #endif
  275. #endif
  276. #endif
  277. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  278. /**
  279. * dp_tx_comp_nf_handler() - Tx completion ring Near full scenario handler
  280. * @int_ctx: Interrupt context
  281. * @soc: Datapath SoC handle
  282. * @hal_ring_hdl: TX completion ring handle
  283. * @ring_id: TX completion ring number
  284. * @quota: Quota of the work to be done
  285. *
  286. * Return: work done
  287. */
  288. uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  289. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  290. uint32_t quota);
  291. #else
  292. static inline
  293. uint32_t dp_tx_comp_nf_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  294. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  295. uint32_t quota)
  296. {
  297. return 0;
  298. }
  299. #endif /* WLAN_FEATURE_NEAR_FULL_IRQ */
  300. /**
  301. * dp_tx_compute_tx_delay_be() - Compute HW Tx completion delay
  302. * @soc: Handle to DP Soc structure
  303. * @vdev: vdev
  304. * @ts: Tx completion status
  305. * @delay_us: Delay to be calculated in microseconds
  306. *
  307. * Return: QDF_STATUS
  308. */
  309. QDF_STATUS dp_tx_compute_tx_delay_be(struct dp_soc *soc,
  310. struct dp_vdev *vdev,
  311. struct hal_tx_completion_status *ts,
  312. uint32_t *delay_us);
  313. /**
  314. * dp_tx_desc_pool_alloc_be() - Allocate TX descriptor pool
  315. * @soc: Handle to DP Soc structure
  316. * @num_elem: Number of elements to allocate
  317. * @pool_id: TCL descriptor pool ID
  318. *
  319. * Return: QDF_STATUS
  320. */
  321. QDF_STATUS dp_tx_desc_pool_alloc_be(struct dp_soc *soc, uint32_t num_elem,
  322. uint8_t pool_id);
  323. /**
  324. * dp_tx_desc_pool_free_be() - Free TX descriptor pool
  325. * @soc: Handle to DP Soc structure
  326. * @pool_id: TCL descriptor pool ID
  327. *
  328. * Return: none
  329. */
  330. void dp_tx_desc_pool_free_be(struct dp_soc *soc, uint8_t pool_id);
  331. #endif