dp_tx.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. /*
  2. * Copyright (c) 2016-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
  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_TX_H
  20. #define __DP_TX_H
  21. #include <qdf_types.h>
  22. #include <qdf_nbuf.h>
  23. #include "dp_types.h"
  24. #ifdef FEATURE_PERPKT_INFO
  25. #if defined(QCA_SUPPORT_LATENCY_CAPTURE) || \
  26. defined(QCA_TX_CAPTURE_SUPPORT) || \
  27. defined(QCA_MCOPY_SUPPORT)
  28. #include "if_meta_hdr.h"
  29. #endif
  30. #endif
  31. #include "dp_internal.h"
  32. #include "hal_tx.h"
  33. #include <qdf_tracepoint.h>
  34. #ifdef CONFIG_SAWF
  35. #include "dp_sawf.h"
  36. #endif
  37. #define DP_INVALID_VDEV_ID 0xFF
  38. #define DP_TX_MAX_NUM_FRAGS 6
  39. /*
  40. * DP_TX_DESC_FLAG_FRAG flags should always be defined to 0x1
  41. * please do not change this flag's definition
  42. */
  43. #define DP_TX_DESC_FLAG_FRAG 0x1
  44. #define DP_TX_DESC_FLAG_TO_FW 0x2
  45. #define DP_TX_DESC_FLAG_SIMPLE 0x4
  46. #define DP_TX_DESC_FLAG_RAW 0x8
  47. #define DP_TX_DESC_FLAG_MESH 0x10
  48. #define DP_TX_DESC_FLAG_QUEUED_TX 0x20
  49. #define DP_TX_DESC_FLAG_COMPLETED_TX 0x40
  50. #define DP_TX_DESC_FLAG_ME 0x80
  51. #define DP_TX_DESC_FLAG_TDLS_FRAME 0x100
  52. #define DP_TX_DESC_FLAG_ALLOCATED 0x200
  53. #define DP_TX_DESC_FLAG_MESH_MODE 0x400
  54. #define DP_TX_DESC_FLAG_UNMAP_DONE 0x800
  55. #define DP_TX_DESC_FLAG_TX_COMP_ERR 0x1000
  56. #define DP_TX_DESC_FLAG_FLUSH 0x2000
  57. #define DP_TX_EXT_DESC_FLAG_METADATA_VALID 0x1
  58. #define DP_TX_FREE_SINGLE_BUF(soc, buf) \
  59. do { \
  60. qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_TO_DEVICE); \
  61. qdf_nbuf_free(buf); \
  62. } while (0)
  63. #define OCB_HEADER_VERSION 1
  64. #ifdef TX_PER_PDEV_DESC_POOL
  65. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  66. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
  67. #else /* QCA_LL_TX_FLOW_CONTROL_V2 */
  68. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->pdev->pdev_id)
  69. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  70. #define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
  71. #else
  72. #ifdef TX_PER_VDEV_DESC_POOL
  73. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
  74. #define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
  75. #endif /* TX_PER_VDEV_DESC_POOL */
  76. #endif /* TX_PER_PDEV_DESC_POOL */
  77. #define DP_TX_QUEUE_MASK 0x3
  78. #define MAX_CDP_SEC_TYPE 12
  79. /* number of dwords for htt_tx_msdu_desc_ext2_t */
  80. #define DP_TX_MSDU_INFO_META_DATA_DWORDS 7
  81. #define dp_tx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX, params)
  82. #define dp_tx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX, params)
  83. #define dp_tx_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DP_TX, params)
  84. #define dp_tx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX, params)
  85. #define dp_tx_info(params...) \
  86. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX, ## params)
  87. #define dp_tx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX, params)
  88. #define dp_tx_comp_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX_COMP, params)
  89. #define dp_tx_comp_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX_COMP, params)
  90. #define dp_tx_comp_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX_COMP, params)
  91. #define dp_tx_comp_info(params...) \
  92. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
  93. #define dp_tx_comp_info_rl(params...) \
  94. __QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
  95. #define dp_tx_comp_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX_COMP, params)
  96. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  97. /**
  98. * struct dp_tx_frag_info_s
  99. * @vaddr: hlos vritual address for buffer
  100. * @paddr_lo: physical address lower 32bits
  101. * @paddr_hi: physical address higher bits
  102. * @len: length of the buffer
  103. */
  104. struct dp_tx_frag_info_s {
  105. uint8_t *vaddr;
  106. uint32_t paddr_lo;
  107. uint16_t paddr_hi;
  108. uint16_t len;
  109. };
  110. /**
  111. * struct dp_tx_seg_info_s - Segmentation Descriptor
  112. * @nbuf: NBUF pointer if segment corresponds to separate nbuf
  113. * @frag_cnt: Fragment count in this segment
  114. * @total_len: Total length of segment
  115. * @frags: per-Fragment information
  116. * @next: pointer to next MSDU segment
  117. */
  118. struct dp_tx_seg_info_s {
  119. qdf_nbuf_t nbuf;
  120. uint16_t frag_cnt;
  121. uint16_t total_len;
  122. struct dp_tx_frag_info_s frags[DP_TX_MAX_NUM_FRAGS];
  123. struct dp_tx_seg_info_s *next;
  124. };
  125. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  126. /**
  127. * struct dp_tx_sg_info_s - Scatter Gather Descriptor
  128. * @num_segs: Number of segments (TSO/ME) in the frame
  129. * @total_len: Total length of the frame
  130. * @curr_seg: Points to current segment descriptor to be processed. Chain of
  131. * descriptors for SG frames/multicast-unicast converted packets.
  132. *
  133. * Used for SG (802.3 or Raw) frames and Multicast-Unicast converted frames to
  134. * carry fragmentation information
  135. * Raw Frames will be handed over to driver as an SKB chain with MPDU boundaries
  136. * indicated through flags in SKB CB (first_msdu and last_msdu). This will be
  137. * converted into set of skb sg (nr_frags) structures.
  138. */
  139. struct dp_tx_sg_info_s {
  140. uint32_t num_segs;
  141. uint32_t total_len;
  142. struct dp_tx_seg_info_s *curr_seg;
  143. };
  144. /**
  145. * struct dp_tx_queue - Tx queue
  146. * @desc_pool_id: Descriptor Pool to be used for the tx queue
  147. * @ring_id: TCL descriptor ring ID corresponding to the tx queue
  148. *
  149. * Tx queue contains information of the software (Descriptor pool)
  150. * and hardware resources (TCL ring id) to be used for a particular
  151. * transmit queue (obtained from skb_queue_mapping in case of linux)
  152. */
  153. struct dp_tx_queue {
  154. uint8_t desc_pool_id;
  155. uint8_t ring_id;
  156. };
  157. /**
  158. * struct dp_tx_msdu_info_s - MSDU Descriptor
  159. * @frm_type: Frame type - Regular/TSO/SG/Multicast enhancement
  160. * @tx_queue: Tx queue on which this MSDU should be transmitted
  161. * @num_seg: Number of segments (TSO)
  162. * @tid: TID (override) that is sent from HLOS
  163. * @u.tso_info: TSO information for TSO frame types
  164. * (chain of the TSO segments, number of segments)
  165. * @u.sg_info: Scatter Gather information for non-TSO SG frames
  166. * @meta_data: Mesh meta header information
  167. * @exception_fw: Duplicate frame to be sent to firmware
  168. * @ppdu_cookie: 16-bit ppdu_cookie that has to be replayed back in completions
  169. * @ix_tx_sniffer: Indicates if the packet has to be sniffed
  170. * @gsn: global sequence for reinjected mcast packets
  171. * @vdev_id : vdev_id for reinjected mcast packets
  172. *
  173. * This structure holds the complete MSDU information needed to program the
  174. * Hardware TCL and MSDU extension descriptors for different frame types
  175. *
  176. */
  177. struct dp_tx_msdu_info_s {
  178. enum dp_tx_frm_type frm_type;
  179. struct dp_tx_queue tx_queue;
  180. uint32_t num_seg;
  181. uint8_t tid;
  182. uint8_t exception_fw;
  183. uint8_t is_tx_sniffer;
  184. union {
  185. struct qdf_tso_info_t tso_info;
  186. struct dp_tx_sg_info_s sg_info;
  187. } u;
  188. uint32_t meta_data[DP_TX_MSDU_INFO_META_DATA_DWORDS];
  189. uint16_t ppdu_cookie;
  190. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  191. #ifdef WLAN_MCAST_MLO
  192. uint16_t gsn;
  193. uint8_t vdev_id;
  194. #endif
  195. #endif
  196. };
  197. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  198. /**
  199. * dp_tx_deinit_pair_by_index() - Deinit TX rings based on index
  200. * @soc: core txrx context
  201. * @index: index of ring to deinit
  202. *
  203. * Deinit 1 TCL and 1 WBM2SW release ring on as needed basis using
  204. * index of the respective TCL/WBM2SW release in soc structure.
  205. * For example, if the index is 2 then &soc->tcl_data_ring[2]
  206. * and &soc->tx_comp_ring[2] will be deinitialized.
  207. *
  208. * Return: none
  209. */
  210. void dp_tx_deinit_pair_by_index(struct dp_soc *soc, int index);
  211. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  212. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool);
  213. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool);
  214. QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
  215. uint8_t num_pool,
  216. uint16_t num_desc);
  217. QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
  218. uint8_t num_pool,
  219. uint16_t num_desc);
  220. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool);
  221. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool);
  222. QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
  223. uint8_t num_pool,
  224. uint16_t num_desc);
  225. QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
  226. uint8_t num_pool,
  227. uint16_t num_desc);
  228. void dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc);
  229. void dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id);
  230. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  231. uint8_t tid, uint8_t ring_id);
  232. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  233. struct dp_tx_desc_s *tx_desc,
  234. struct hal_tx_completion_status *ts,
  235. struct dp_txrx_peer *txrx_peer,
  236. uint8_t ring_id);
  237. void dp_tx_comp_process_desc(struct dp_soc *soc,
  238. struct dp_tx_desc_s *desc,
  239. struct hal_tx_completion_status *ts,
  240. struct dp_txrx_peer *txrx_peer);
  241. void dp_tx_reinject_handler(struct dp_soc *soc,
  242. struct dp_vdev *vdev,
  243. struct dp_tx_desc_s *tx_desc,
  244. uint8_t *status,
  245. uint8_t reinject_reason);
  246. void dp_tx_inspect_handler(struct dp_soc *soc,
  247. struct dp_vdev *vdev,
  248. struct dp_tx_desc_s *tx_desc,
  249. uint8_t *status);
  250. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  251. uint32_t length, uint8_t tx_status,
  252. bool update);
  253. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  254. /**
  255. * dp_tso_attach() - TSO Attach handler
  256. * @txrx_soc: Opaque Dp handle
  257. *
  258. * Reserve TSO descriptor buffers
  259. *
  260. * Return: QDF_STATUS_E_FAILURE on failure or
  261. * QDF_STATUS_SUCCESS on success
  262. */
  263. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc);
  264. /**
  265. * dp_tso_detach() - TSO Detach handler
  266. * @txrx_soc: Opaque Dp handle
  267. *
  268. * Deallocate TSO descriptor buffers
  269. *
  270. * Return: QDF_STATUS_E_FAILURE on failure or
  271. * QDF_STATUS_SUCCESS on success
  272. */
  273. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc);
  274. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
  275. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc, uint8_t vdev_id,
  276. qdf_nbuf_t nbuf);
  277. qdf_nbuf_t dp_tx_send_exception(struct cdp_soc_t *soc, uint8_t vdev_id,
  278. qdf_nbuf_t nbuf,
  279. struct cdp_tx_exception_metadata *tx_exc);
  280. qdf_nbuf_t dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc,
  281. uint8_t vdev_id,
  282. qdf_nbuf_t nbuf,
  283. struct cdp_tx_exception_metadata *tx_exc);
  284. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
  285. qdf_nbuf_t nbuf);
  286. qdf_nbuf_t
  287. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  288. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  289. struct cdp_tx_exception_metadata *tx_exc_metadata);
  290. #if QDF_LOCK_STATS
  291. noinline qdf_nbuf_t
  292. dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  293. struct dp_tx_msdu_info_s *msdu_info);
  294. #else
  295. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  296. struct dp_tx_msdu_info_s *msdu_info);
  297. #endif
  298. #ifdef FEATURE_WLAN_TDLS
  299. /**
  300. * dp_tx_non_std() - Allow the control-path SW to send data frames
  301. * @soc_hdl: Datapath soc handle
  302. * @vdev_id: id of vdev
  303. * @tx_spec: what non-standard handling to apply to the tx data frames
  304. * @msdu_list: NULL-terminated list of tx MSDUs
  305. *
  306. * Return: NULL on success,
  307. * nbuf when it fails to send
  308. */
  309. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  310. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
  311. #endif
  312. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac);
  313. /**
  314. * dp_tx_comp_handler() - Tx completion handler
  315. * @int_ctx: pointer to DP interrupt context
  316. * @soc: core txrx main context
  317. * @hal_srng: Opaque HAL SRNG pointer
  318. * @ring_id: completion ring id
  319. * @quota: No. of packets/descriptors that can be serviced in one loop
  320. *
  321. * This function will collect hardware release ring element contents and
  322. * handle descriptor contents. Based on contents, free packet or handle error
  323. * conditions
  324. *
  325. * Return: Number of TX completions processed
  326. */
  327. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  328. hal_ring_handle_t hal_srng, uint8_t ring_id,
  329. uint32_t quota);
  330. QDF_STATUS
  331. dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  332. QDF_STATUS
  333. dp_tx_prepare_send_igmp_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  334. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  335. #if defined(QCA_HOST_MODE_WIFI_DISABLED) || !defined(ATH_SUPPORT_IQUE)
  336. static inline void dp_tx_me_exit(struct dp_pdev *pdev)
  337. {
  338. return;
  339. }
  340. #endif
  341. /**
  342. * dp_tx_pdev_init() - dp tx pdev init
  343. * @pdev: physical device instance
  344. *
  345. * Return: QDF_STATUS_SUCCESS: success
  346. * QDF_STATUS_E_RESOURCES: Error return
  347. */
  348. static inline QDF_STATUS dp_tx_pdev_init(struct dp_pdev *pdev)
  349. {
  350. struct dp_soc *soc = pdev->soc;
  351. /* Initialize Flow control counters */
  352. qdf_atomic_init(&pdev->num_tx_outstanding);
  353. pdev->tx_descs_max = 0;
  354. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  355. /* Initialize descriptors in TCL Ring */
  356. hal_tx_init_data_ring(soc->hal_soc,
  357. soc->tcl_data_ring[pdev->pdev_id].hal_srng);
  358. }
  359. return QDF_STATUS_SUCCESS;
  360. }
  361. /**
  362. * dp_tx_prefetch_hw_sw_nbuf_desc() - function to prefetch HW and SW desc
  363. * @soc: Handle to HAL Soc structure
  364. * @hal_soc: HAL SOC handle
  365. * @num_avail_for_reap: descriptors available for reap
  366. * @hal_ring_hdl: ring pointer
  367. * @last_prefetched_hw_desc: pointer to the last prefetched HW descriptor
  368. * @last_prefetched_sw_desc: pointer to last prefetch SW desc
  369. *
  370. * Return: None
  371. */
  372. #ifdef QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH
  373. static inline
  374. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  375. hal_soc_handle_t hal_soc,
  376. uint32_t num_avail_for_reap,
  377. hal_ring_handle_t hal_ring_hdl,
  378. void **last_prefetched_hw_desc,
  379. struct dp_tx_desc_s
  380. **last_prefetched_sw_desc)
  381. {
  382. if (*last_prefetched_sw_desc) {
  383. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf);
  384. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf + 64);
  385. }
  386. if (num_avail_for_reap && *last_prefetched_hw_desc) {
  387. dp_tx_comp_get_prefetched_params_from_hal_desc(
  388. soc,
  389. *last_prefetched_hw_desc,
  390. last_prefetched_sw_desc);
  391. *last_prefetched_hw_desc =
  392. hal_srng_dst_prefetch_next_cached_desc(
  393. hal_soc,
  394. hal_ring_hdl,
  395. (uint8_t *)*last_prefetched_hw_desc);
  396. }
  397. }
  398. #else
  399. static inline
  400. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  401. hal_soc_handle_t hal_soc,
  402. uint32_t num_avail_for_reap,
  403. hal_ring_handle_t hal_ring_hdl,
  404. void **last_prefetched_hw_desc,
  405. struct dp_tx_desc_s
  406. **last_prefetched_sw_desc)
  407. {
  408. }
  409. #endif
  410. #ifndef FEATURE_WDS
  411. static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
  412. {
  413. return;
  414. }
  415. #endif
  416. #ifndef QCA_MULTIPASS_SUPPORT
  417. static inline
  418. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  419. qdf_nbuf_t nbuf,
  420. struct dp_tx_msdu_info_s *msdu_info)
  421. {
  422. return true;
  423. }
  424. static inline
  425. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev)
  426. {
  427. }
  428. #else
  429. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  430. qdf_nbuf_t nbuf,
  431. struct dp_tx_msdu_info_s *msdu_info);
  432. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev);
  433. #endif
  434. /**
  435. * dp_tx_hw_to_qdf()- convert hw status to qdf status
  436. * @status: hw status
  437. *
  438. * Return: qdf tx rx status
  439. */
  440. static inline enum qdf_dp_tx_rx_status dp_tx_hw_to_qdf(uint16_t status)
  441. {
  442. switch (status) {
  443. case HAL_TX_TQM_RR_FRAME_ACKED:
  444. return QDF_TX_RX_STATUS_OK;
  445. case HAL_TX_TQM_RR_REM_CMD_TX:
  446. return QDF_TX_RX_STATUS_NO_ACK;
  447. case HAL_TX_TQM_RR_REM_CMD_REM:
  448. case HAL_TX_TQM_RR_REM_CMD_NOTX:
  449. case HAL_TX_TQM_RR_REM_CMD_AGED:
  450. return QDF_TX_RX_STATUS_FW_DISCARD;
  451. default:
  452. return QDF_TX_RX_STATUS_DEFAULT;
  453. }
  454. }
  455. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  456. /**
  457. * dp_tx_get_queue() - Returns Tx queue IDs to be used for this Tx frame
  458. * @vdev: DP Virtual device handle
  459. * @nbuf: Buffer pointer
  460. * @queue: queue ids container for nbuf
  461. *
  462. * TX packet queue has 2 instances, software descriptors id and dma ring id
  463. * Based on tx feature and hardware configuration queue id combination could be
  464. * different.
  465. * For example -
  466. * With XPS enabled,all TX descriptor pools and dma ring are assigned per cpu id
  467. * With no XPS,lock based resource protection, Descriptor pool ids are different
  468. * for each vdev, dma ring id will be same as single pdev id
  469. *
  470. * Return: None
  471. */
  472. #ifdef QCA_OL_TX_MULTIQ_SUPPORT
  473. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  474. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  475. {
  476. uint16_t queue_offset = qdf_nbuf_get_queue_mapping(nbuf) &
  477. DP_TX_QUEUE_MASK;
  478. queue->desc_pool_id = queue_offset;
  479. queue->ring_id = qdf_get_cpu();
  480. dp_tx_debug("pool_id:%d ring_id: %d",
  481. queue->desc_pool_id, queue->ring_id);
  482. }
  483. /*
  484. * dp_tx_get_hal_ring_hdl()- Get the hal_tx_ring_hdl for data transmission
  485. * @dp_soc - DP soc structure pointer
  486. * @ring_id - Transmit Queue/ring_id to be used when XPS is enabled
  487. *
  488. * Return - HAL ring handle
  489. */
  490. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  491. uint8_t ring_id)
  492. {
  493. if (ring_id == soc->num_tcl_data_rings)
  494. return soc->tcl_cmd_credit_ring.hal_srng;
  495. return soc->tcl_data_ring[ring_id].hal_srng;
  496. }
  497. #else /* QCA_OL_TX_MULTIQ_SUPPORT */
  498. #ifdef TX_MULTI_TCL
  499. #ifdef IPA_OFFLOAD
  500. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  501. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  502. {
  503. /* get flow id */
  504. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  505. if (vdev->pdev->soc->wlan_cfg_ctx->ipa_enabled)
  506. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  507. else
  508. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  509. vdev->pdev->soc->num_tcl_data_rings);
  510. }
  511. #else
  512. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  513. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  514. {
  515. /* get flow id */
  516. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  517. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  518. vdev->pdev->soc->num_tcl_data_rings);
  519. }
  520. #endif
  521. #else
  522. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  523. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  524. {
  525. /* get flow id */
  526. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  527. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  528. }
  529. #endif
  530. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  531. uint8_t ring_id)
  532. {
  533. return soc->tcl_data_ring[ring_id].hal_srng;
  534. }
  535. #endif
  536. #ifdef QCA_OL_TX_LOCK_LESS_ACCESS
  537. /*
  538. * dp_tx_hal_ring_access_start()- hal_tx_ring access for data transmission
  539. * @dp_soc - DP soc structure pointer
  540. * @hal_ring_hdl - HAL ring handle
  541. *
  542. * Return - None
  543. */
  544. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  545. hal_ring_handle_t hal_ring_hdl)
  546. {
  547. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  548. }
  549. /*
  550. * dp_tx_hal_ring_access_end()- hal_tx_ring access for data transmission
  551. * @dp_soc - DP soc structure pointer
  552. * @hal_ring_hdl - HAL ring handle
  553. *
  554. * Return - None
  555. */
  556. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  557. hal_ring_handle_t hal_ring_hdl)
  558. {
  559. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  560. }
  561. /*
  562. * dp_tx_hal_ring_access_reap()- hal_tx_ring access for data transmission
  563. * @dp_soc - DP soc structure pointer
  564. * @hal_ring_hdl - HAL ring handle
  565. *
  566. * Return - None
  567. */
  568. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  569. hal_ring_handle_t
  570. hal_ring_hdl)
  571. {
  572. }
  573. #else
  574. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  575. hal_ring_handle_t hal_ring_hdl)
  576. {
  577. return hal_srng_access_start(soc->hal_soc, hal_ring_hdl);
  578. }
  579. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  580. hal_ring_handle_t hal_ring_hdl)
  581. {
  582. hal_srng_access_end(soc->hal_soc, hal_ring_hdl);
  583. }
  584. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  585. hal_ring_handle_t
  586. hal_ring_hdl)
  587. {
  588. hal_srng_access_end_reap(soc->hal_soc, hal_ring_hdl);
  589. }
  590. #endif
  591. #ifdef ATH_TX_PRI_OVERRIDE
  592. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
  593. ((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
  594. #else
  595. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
  596. #endif
  597. /* TODO TX_FEATURE_NOT_YET */
  598. static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
  599. {
  600. return;
  601. }
  602. /* TODO TX_FEATURE_NOT_YET */
  603. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  604. bool force_free);
  605. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
  606. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
  607. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
  608. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc);
  609. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc);
  610. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc);
  611. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc);
  612. void
  613. dp_handle_wbm_internal_error(struct dp_soc *soc, void *hal_desc,
  614. uint32_t buf_type);
  615. #else /* QCA_HOST_MODE_WIFI_DISABLED */
  616. static inline
  617. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  618. {
  619. return QDF_STATUS_SUCCESS;
  620. }
  621. static inline
  622. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  623. {
  624. return QDF_STATUS_SUCCESS;
  625. }
  626. static inline void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  627. {
  628. }
  629. static inline void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  630. {
  631. }
  632. static inline
  633. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  634. bool force_free)
  635. {
  636. }
  637. static inline QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  638. {
  639. return QDF_STATUS_SUCCESS;
  640. }
  641. static inline QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  642. {
  643. return QDF_STATUS_SUCCESS;
  644. }
  645. static inline void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  646. {
  647. }
  648. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  649. #if defined(QCA_SUPPORT_LATENCY_CAPTURE) || \
  650. defined(QCA_TX_CAPTURE_SUPPORT) || \
  651. defined(QCA_MCOPY_SUPPORT)
  652. #ifdef FEATURE_PERPKT_INFO
  653. QDF_STATUS
  654. dp_get_completion_indication_for_stack(struct dp_soc *soc,
  655. struct dp_pdev *pdev,
  656. struct dp_txrx_peer *peer,
  657. struct hal_tx_completion_status *ts,
  658. qdf_nbuf_t netbuf,
  659. uint64_t time_latency);
  660. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  661. uint16_t peer_id, uint32_t ppdu_id,
  662. qdf_nbuf_t netbuf);
  663. #endif
  664. #else
  665. static inline
  666. QDF_STATUS dp_get_completion_indication_for_stack(struct dp_soc *soc,
  667. struct dp_pdev *pdev,
  668. struct dp_txrx_peer *peer,
  669. struct hal_tx_completion_status *ts,
  670. qdf_nbuf_t netbuf,
  671. uint64_t time_latency)
  672. {
  673. return QDF_STATUS_E_NOSUPPORT;
  674. }
  675. static inline
  676. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  677. uint16_t peer_id, uint32_t ppdu_id,
  678. qdf_nbuf_t netbuf)
  679. {
  680. }
  681. #endif
  682. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  683. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  684. struct dp_tx_desc_s *desc,
  685. struct hal_tx_completion_status *ts);
  686. #else
  687. static inline void
  688. dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  689. struct dp_tx_desc_s *desc,
  690. struct hal_tx_completion_status *ts)
  691. {
  692. }
  693. #endif
  694. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  695. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  696. /**
  697. * dp_tx_update_stats() - Update soc level tx stats
  698. * @soc: DP soc handle
  699. * @nbuf: packet being transmitted
  700. *
  701. * Returns: none
  702. */
  703. void dp_tx_update_stats(struct dp_soc *soc,
  704. qdf_nbuf_t nbuf);
  705. /**
  706. * dp_tx_attempt_coalescing() - Check and attempt TCL register write coalescing
  707. * @soc: Datapath soc handle
  708. * @tx_desc: tx packet descriptor
  709. * @tid: TID for pkt transmission
  710. *
  711. * Returns: 1, if coalescing is to be done
  712. * 0, if coalescing is not to be done
  713. */
  714. int
  715. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  716. struct dp_tx_desc_s *tx_desc,
  717. uint8_t tid);
  718. /**
  719. * dp_tx_ring_access_end() - HAL ring access end for data transmission
  720. * @soc: Datapath soc handle
  721. * @hal_ring_hdl: HAL ring handle
  722. * @coalesce: Coalesce the current write or not
  723. *
  724. * Returns: none
  725. */
  726. void
  727. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  728. int coalesce);
  729. #else
  730. /**
  731. * dp_tx_update_stats() - Update soc level tx stats
  732. * @soc: DP soc handle
  733. * @nbuf: packet being transmitted
  734. *
  735. * Returns: none
  736. */
  737. static inline void dp_tx_update_stats(struct dp_soc *soc,
  738. qdf_nbuf_t nbuf) { }
  739. static inline void
  740. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  741. int coalesce)
  742. {
  743. dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
  744. }
  745. static inline int
  746. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  747. struct dp_tx_desc_s *tx_desc,
  748. uint8_t tid)
  749. {
  750. return 0;
  751. }
  752. #endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */
  753. #ifdef FEATURE_RUNTIME_PM
  754. /**
  755. * dp_set_rtpm_tput_policy_requirement() - Update RTPM throughput policy
  756. * @soc_hdl: DP soc handle
  757. * @is_high_tput: flag to indicate whether throughput is high
  758. *
  759. * Returns: none
  760. */
  761. static inline
  762. void dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  763. bool is_high_tput)
  764. {
  765. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  766. qdf_atomic_set(&soc->rtpm_high_tput_flag, is_high_tput);
  767. }
  768. void
  769. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  770. hal_ring_handle_t hal_ring_hdl,
  771. int coalesce);
  772. #else
  773. #ifdef DP_POWER_SAVE
  774. void
  775. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  776. hal_ring_handle_t hal_ring_hdl,
  777. int coalesce);
  778. #else
  779. static inline void
  780. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  781. hal_ring_handle_t hal_ring_hdl,
  782. int coalesce)
  783. {
  784. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  785. }
  786. #endif
  787. static inline void
  788. dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  789. bool is_high_tput)
  790. { }
  791. #endif
  792. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  793. #ifdef DP_TX_HW_DESC_HISTORY
  794. static inline void
  795. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  796. hal_ring_handle_t hal_ring_hdl,
  797. struct dp_soc *soc)
  798. {
  799. struct dp_tx_hw_desc_evt *evt;
  800. uint64_t idx = 0;
  801. if (!soc->tx_hw_desc_history)
  802. return;
  803. idx = ++soc->tx_hw_desc_history->index;
  804. if (idx == DP_TX_HW_DESC_HIST_MAX)
  805. soc->tx_hw_desc_history->index = 0;
  806. idx = qdf_do_div_rem(idx, DP_TX_HW_DESC_HIST_MAX);
  807. evt = &soc->tx_hw_desc_history->entry[idx];
  808. qdf_mem_copy(evt->tcl_desc, hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  809. evt->posted = qdf_get_log_timestamp();
  810. hal_get_sw_hptp(soc->hal_soc, hal_ring_hdl, &evt->tp, &evt->hp);
  811. }
  812. #else
  813. static inline void
  814. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  815. hal_ring_handle_t hal_ring_hdl,
  816. struct dp_soc *soc)
  817. {
  818. }
  819. #endif
  820. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(CONFIG_SAWF)
  821. /**
  822. * dp_set_delta_tsf() - Set delta_tsf to dp_soc structure
  823. * @soc_hdl: cdp soc pointer
  824. * @vdev_id: vdev id
  825. * @delta_tsf: difference between TSF clock and qtimer
  826. *
  827. * Return: None
  828. */
  829. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  830. uint32_t delta_tsf);
  831. #endif
  832. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  833. /**
  834. * dp_set_tsf_report_ul_delay() - Enable or disable reporting uplink delay
  835. * @soc_hdl: cdp soc pointer
  836. * @vdev_id: vdev id
  837. * @enable: true to enable and false to disable
  838. *
  839. * Return: QDF_STATUS
  840. */
  841. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  842. uint8_t vdev_id, bool enable);
  843. /**
  844. * dp_get_uplink_delay() - Get uplink delay value
  845. * @soc_hdl: cdp soc pointer
  846. * @vdev_id: vdev id
  847. * @val: pointer to save uplink delay value
  848. *
  849. * Return: QDF_STATUS
  850. */
  851. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  852. uint32_t *val);
  853. #endif /* WLAN_FEATURE_TSF_UPLINK_TSF */
  854. /**
  855. * dp_tx_pkt_tracepoints_enabled() - Get the state of tx pkt tracepoint
  856. *
  857. * Return: True if any tx pkt tracepoint is enabled else false
  858. */
  859. static inline
  860. bool dp_tx_pkt_tracepoints_enabled(void)
  861. {
  862. return (qdf_trace_dp_tx_comp_tcp_pkt_enabled() ||
  863. qdf_trace_dp_tx_comp_udp_pkt_enabled() ||
  864. qdf_trace_dp_tx_comp_pkt_enabled());
  865. }
  866. #ifdef DP_TX_TRACKING
  867. /**
  868. * dp_tx_desc_set_timestamp() - set timestamp in tx descriptor
  869. * @tx_desc - tx descriptor
  870. *
  871. * Return: None
  872. */
  873. static inline
  874. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  875. {
  876. tx_desc->timestamp = qdf_system_ticks();
  877. }
  878. /**
  879. * dp_tx_desc_check_corruption() - Verify magic pattern in tx descriptor
  880. * @tx_desc: tx descriptor
  881. *
  882. * Check for corruption in tx descriptor, if magic pattern is not matching
  883. * trigger self recovery
  884. *
  885. * Return: none
  886. */
  887. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc);
  888. #else
  889. static inline
  890. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  891. {
  892. }
  893. static inline
  894. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  895. {
  896. }
  897. #endif
  898. #ifndef CONFIG_SAWF
  899. static inline bool dp_sawf_tag_valid_get(qdf_nbuf_t nbuf)
  900. {
  901. return false;
  902. }
  903. #endif
  904. #endif