dp_tx.h 28 KB

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