dp_tx.h 24 KB

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