dp_tx.h 23 KB

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