dp_tx.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef __DP_TX_H
  20. #define __DP_TX_H
  21. #include <qdf_types.h>
  22. #include <qdf_nbuf.h>
  23. #include "dp_types.h"
  24. #ifdef FEATURE_PERPKT_INFO
  25. #if defined(QCA_SUPPORT_LATENCY_CAPTURE) || \
  26. defined(QCA_TX_CAPTURE_SUPPORT) || \
  27. defined(QCA_MCOPY_SUPPORT)
  28. #include "if_meta_hdr.h"
  29. #endif
  30. #endif
  31. #include "dp_internal.h"
  32. #include "hal_tx.h"
  33. #include <qdf_tracepoint.h>
  34. #ifdef CONFIG_SAWF
  35. #include "dp_sawf.h"
  36. #endif
  37. #include <qdf_pkt_add_timestamp.h>
  38. #define DP_INVALID_VDEV_ID 0xFF
  39. #define DP_TX_MAX_NUM_FRAGS 6
  40. /*
  41. * DP_TX_DESC_FLAG_FRAG flags should always be defined to 0x1
  42. * please do not change this flag's definition
  43. */
  44. #define DP_TX_DESC_FLAG_FRAG 0x1
  45. #define DP_TX_DESC_FLAG_TO_FW 0x2
  46. #define DP_TX_DESC_FLAG_SIMPLE 0x4
  47. #define DP_TX_DESC_FLAG_RAW 0x8
  48. #define DP_TX_DESC_FLAG_MESH 0x10
  49. #define DP_TX_DESC_FLAG_QUEUED_TX 0x20
  50. #define DP_TX_DESC_FLAG_COMPLETED_TX 0x40
  51. #define DP_TX_DESC_FLAG_ME 0x80
  52. #define DP_TX_DESC_FLAG_TDLS_FRAME 0x100
  53. #define DP_TX_DESC_FLAG_ALLOCATED 0x200
  54. #define DP_TX_DESC_FLAG_MESH_MODE 0x400
  55. #define DP_TX_DESC_FLAG_UNMAP_DONE 0x800
  56. #define DP_TX_DESC_FLAG_TX_COMP_ERR 0x1000
  57. #define DP_TX_DESC_FLAG_FLUSH 0x2000
  58. #define DP_TX_DESC_FLAG_TRAFFIC_END_IND 0x4000
  59. #define DP_TX_EXT_DESC_FLAG_METADATA_VALID 0x1
  60. #define DP_TX_FREE_SINGLE_BUF(soc, buf) \
  61. do { \
  62. qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_TO_DEVICE); \
  63. qdf_nbuf_free(buf); \
  64. } while (0)
  65. #define OCB_HEADER_VERSION 1
  66. #ifdef TX_PER_PDEV_DESC_POOL
  67. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  68. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
  69. #else /* QCA_LL_TX_FLOW_CONTROL_V2 */
  70. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->pdev->pdev_id)
  71. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  72. #define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
  73. #else
  74. #ifdef TX_PER_VDEV_DESC_POOL
  75. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
  76. #define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
  77. #endif /* TX_PER_VDEV_DESC_POOL */
  78. #endif /* TX_PER_PDEV_DESC_POOL */
  79. #define DP_TX_QUEUE_MASK 0x3
  80. #define MAX_CDP_SEC_TYPE 12
  81. /* number of dwords for htt_tx_msdu_desc_ext2_t */
  82. #define DP_TX_MSDU_INFO_META_DATA_DWORDS 7
  83. #define dp_tx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX, params)
  84. #define dp_tx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX, params)
  85. #define dp_tx_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DP_TX, params)
  86. #define dp_tx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX, params)
  87. #define dp_tx_info(params...) \
  88. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX, ## params)
  89. #define dp_tx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX, params)
  90. #define dp_tx_comp_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX_COMP, params)
  91. #define dp_tx_comp_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX_COMP, params)
  92. #define dp_tx_comp_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX_COMP, params)
  93. #define dp_tx_comp_info(params...) \
  94. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
  95. #define dp_tx_comp_info_rl(params...) \
  96. __QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
  97. #define dp_tx_comp_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX_COMP, params)
  98. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  99. /**
  100. * struct dp_tx_frag_info_s
  101. * @vaddr: hlos vritual address for buffer
  102. * @paddr_lo: physical address lower 32bits
  103. * @paddr_hi: physical address higher bits
  104. * @len: length of the buffer
  105. */
  106. struct dp_tx_frag_info_s {
  107. uint8_t *vaddr;
  108. uint32_t paddr_lo;
  109. uint16_t paddr_hi;
  110. uint16_t len;
  111. };
  112. /**
  113. * struct dp_tx_seg_info_s - Segmentation Descriptor
  114. * @nbuf: NBUF pointer if segment corresponds to separate nbuf
  115. * @frag_cnt: Fragment count in this segment
  116. * @total_len: Total length of segment
  117. * @frags: per-Fragment information
  118. * @next: pointer to next MSDU segment
  119. */
  120. struct dp_tx_seg_info_s {
  121. qdf_nbuf_t nbuf;
  122. uint16_t frag_cnt;
  123. uint16_t total_len;
  124. struct dp_tx_frag_info_s frags[DP_TX_MAX_NUM_FRAGS];
  125. struct dp_tx_seg_info_s *next;
  126. };
  127. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  128. /**
  129. * struct dp_tx_sg_info_s - Scatter Gather Descriptor
  130. * @num_segs: Number of segments (TSO/ME) in the frame
  131. * @total_len: Total length of the frame
  132. * @curr_seg: Points to current segment descriptor to be processed. Chain of
  133. * descriptors for SG frames/multicast-unicast converted packets.
  134. *
  135. * Used for SG (802.3 or Raw) frames and Multicast-Unicast converted frames to
  136. * carry fragmentation information
  137. * Raw Frames will be handed over to driver as an SKB chain with MPDU boundaries
  138. * indicated through flags in SKB CB (first_msdu and last_msdu). This will be
  139. * converted into set of skb sg (nr_frags) structures.
  140. */
  141. struct dp_tx_sg_info_s {
  142. uint32_t num_segs;
  143. uint32_t total_len;
  144. struct dp_tx_seg_info_s *curr_seg;
  145. };
  146. /**
  147. * struct dp_tx_queue - Tx queue
  148. * @desc_pool_id: Descriptor Pool to be used for the tx queue
  149. * @ring_id: TCL descriptor ring ID corresponding to the tx queue
  150. *
  151. * Tx queue contains information of the software (Descriptor pool)
  152. * and hardware resources (TCL ring id) to be used for a particular
  153. * transmit queue (obtained from skb_queue_mapping in case of linux)
  154. */
  155. struct dp_tx_queue {
  156. uint8_t desc_pool_id;
  157. uint8_t ring_id;
  158. };
  159. /**
  160. * struct dp_tx_msdu_info_s - MSDU Descriptor
  161. * @frm_type: Frame type - Regular/TSO/SG/Multicast enhancement
  162. * @tx_queue: Tx queue on which this MSDU should be transmitted
  163. * @num_seg: Number of segments (TSO)
  164. * @tid: TID (override) that is sent from HLOS
  165. * @u.tso_info: TSO information for TSO frame types
  166. * (chain of the TSO segments, number of segments)
  167. * @u.sg_info: Scatter Gather information for non-TSO SG frames
  168. * @meta_data: Mesh meta header information
  169. * @exception_fw: Duplicate frame to be sent to firmware
  170. * @ppdu_cookie: 16-bit ppdu_cookie that has to be replayed back in completions
  171. * @ix_tx_sniffer: Indicates if the packet has to be sniffed
  172. * @gsn: global sequence for reinjected mcast packets
  173. * @vdev_id : vdev_id for reinjected mcast packets
  174. * @skip_hp_update : Skip HP update for TSO segments and update in last segment
  175. *
  176. * This structure holds the complete MSDU information needed to program the
  177. * Hardware TCL and MSDU extension descriptors for different frame types
  178. *
  179. */
  180. struct dp_tx_msdu_info_s {
  181. enum dp_tx_frm_type frm_type;
  182. struct dp_tx_queue tx_queue;
  183. uint32_t num_seg;
  184. uint8_t tid;
  185. uint8_t exception_fw;
  186. uint8_t is_tx_sniffer;
  187. union {
  188. struct qdf_tso_info_t tso_info;
  189. struct dp_tx_sg_info_s sg_info;
  190. } u;
  191. uint32_t meta_data[DP_TX_MSDU_INFO_META_DATA_DWORDS];
  192. uint16_t ppdu_cookie;
  193. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  194. #ifdef WLAN_MCAST_MLO
  195. uint16_t gsn;
  196. uint8_t vdev_id;
  197. #endif
  198. #endif
  199. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  200. uint8_t skip_hp_update;
  201. #endif
  202. };
  203. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  204. /**
  205. * dp_tx_deinit_pair_by_index() - Deinit TX rings based on index
  206. * @soc: core txrx context
  207. * @index: index of ring to deinit
  208. *
  209. * Deinit 1 TCL and 1 WBM2SW release ring on as needed basis using
  210. * index of the respective TCL/WBM2SW release in soc structure.
  211. * For example, if the index is 2 then &soc->tcl_data_ring[2]
  212. * and &soc->tx_comp_ring[2] will be deinitialized.
  213. *
  214. * Return: none
  215. */
  216. void dp_tx_deinit_pair_by_index(struct dp_soc *soc, int index);
  217. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  218. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool);
  219. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool);
  220. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool);
  221. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool);
  222. QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
  223. uint8_t num_pool,
  224. uint32_t num_desc);
  225. QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
  226. uint8_t num_pool,
  227. uint32_t num_desc);
  228. qdf_nbuf_t dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc,
  229. bool delayed_free);
  230. void dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id);
  231. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  232. uint8_t tid, uint8_t ring_id);
  233. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  234. struct dp_tx_desc_s *tx_desc,
  235. struct hal_tx_completion_status *ts,
  236. struct dp_txrx_peer *txrx_peer,
  237. uint8_t ring_id);
  238. void dp_tx_comp_process_desc(struct dp_soc *soc,
  239. struct dp_tx_desc_s *desc,
  240. struct hal_tx_completion_status *ts,
  241. struct dp_txrx_peer *txrx_peer);
  242. void dp_tx_reinject_handler(struct dp_soc *soc,
  243. struct dp_vdev *vdev,
  244. struct dp_tx_desc_s *tx_desc,
  245. uint8_t *status,
  246. uint8_t reinject_reason);
  247. void dp_tx_inspect_handler(struct dp_soc *soc,
  248. struct dp_vdev *vdev,
  249. struct dp_tx_desc_s *tx_desc,
  250. uint8_t *status);
  251. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  252. uint32_t length, uint8_t tx_status,
  253. bool update);
  254. #ifdef DP_UMAC_HW_RESET_SUPPORT
  255. qdf_nbuf_t dp_tx_drop(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
  256. qdf_nbuf_t dp_tx_exc_drop(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  257. qdf_nbuf_t nbuf,
  258. struct cdp_tx_exception_metadata *tx_exc_metadata);
  259. #endif
  260. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  261. /**
  262. * dp_tso_attach() - TSO Attach handler
  263. * @txrx_soc: Opaque Dp handle
  264. *
  265. * Reserve TSO descriptor buffers
  266. *
  267. * Return: QDF_STATUS_E_FAILURE on failure or
  268. * QDF_STATUS_SUCCESS on success
  269. */
  270. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc);
  271. /**
  272. * dp_tso_detach() - TSO Detach handler
  273. * @txrx_soc: Opaque Dp handle
  274. *
  275. * Deallocate TSO descriptor buffers
  276. *
  277. * Return: QDF_STATUS_E_FAILURE on failure or
  278. * QDF_STATUS_SUCCESS on success
  279. */
  280. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc);
  281. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
  282. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc, uint8_t vdev_id,
  283. qdf_nbuf_t nbuf);
  284. qdf_nbuf_t dp_tx_send_exception(struct cdp_soc_t *soc, uint8_t vdev_id,
  285. qdf_nbuf_t nbuf,
  286. struct cdp_tx_exception_metadata *tx_exc);
  287. qdf_nbuf_t dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc,
  288. uint8_t vdev_id,
  289. qdf_nbuf_t nbuf,
  290. struct cdp_tx_exception_metadata *tx_exc);
  291. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
  292. qdf_nbuf_t nbuf);
  293. qdf_nbuf_t
  294. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  295. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  296. struct cdp_tx_exception_metadata *tx_exc_metadata);
  297. #if QDF_LOCK_STATS
  298. noinline qdf_nbuf_t
  299. dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  300. struct dp_tx_msdu_info_s *msdu_info);
  301. #else
  302. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  303. struct dp_tx_msdu_info_s *msdu_info);
  304. #endif
  305. #ifdef FEATURE_WLAN_TDLS
  306. /**
  307. * dp_tx_non_std() - Allow the control-path SW to send data frames
  308. * @soc_hdl: Datapath soc handle
  309. * @vdev_id: id of vdev
  310. * @tx_spec: what non-standard handling to apply to the tx data frames
  311. * @msdu_list: NULL-terminated list of tx MSDUs
  312. *
  313. * Return: NULL on success,
  314. * nbuf when it fails to send
  315. */
  316. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  317. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
  318. #endif
  319. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac);
  320. /**
  321. * dp_tx_comp_handler() - Tx completion handler
  322. * @int_ctx: pointer to DP interrupt context
  323. * @soc: core txrx main context
  324. * @hal_srng: Opaque HAL SRNG pointer
  325. * @ring_id: completion ring id
  326. * @quota: No. of packets/descriptors that can be serviced in one loop
  327. *
  328. * This function will collect hardware release ring element contents and
  329. * handle descriptor contents. Based on contents, free packet or handle error
  330. * conditions
  331. *
  332. * Return: Number of TX completions processed
  333. */
  334. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  335. hal_ring_handle_t hal_srng, uint8_t ring_id,
  336. uint32_t quota);
  337. QDF_STATUS
  338. dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  339. QDF_STATUS
  340. dp_tx_prepare_send_igmp_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  341. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  342. #if defined(QCA_HOST_MODE_WIFI_DISABLED) || !defined(ATH_SUPPORT_IQUE)
  343. static inline void dp_tx_me_exit(struct dp_pdev *pdev)
  344. {
  345. return;
  346. }
  347. #endif
  348. /**
  349. * dp_tx_pdev_init() - dp tx pdev init
  350. * @pdev: physical device instance
  351. *
  352. * Return: QDF_STATUS_SUCCESS: success
  353. * QDF_STATUS_E_RESOURCES: Error return
  354. */
  355. static inline QDF_STATUS dp_tx_pdev_init(struct dp_pdev *pdev)
  356. {
  357. struct dp_soc *soc = pdev->soc;
  358. /* Initialize Flow control counters */
  359. qdf_atomic_init(&pdev->num_tx_outstanding);
  360. pdev->tx_descs_max = 0;
  361. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  362. /* Initialize descriptors in TCL Ring */
  363. hal_tx_init_data_ring(soc->hal_soc,
  364. soc->tcl_data_ring[pdev->pdev_id].hal_srng);
  365. }
  366. return QDF_STATUS_SUCCESS;
  367. }
  368. /**
  369. * dp_tx_prefetch_hw_sw_nbuf_desc() - function to prefetch HW and SW desc
  370. * @soc: Handle to HAL Soc structure
  371. * @hal_soc: HAL SOC handle
  372. * @num_avail_for_reap: descriptors available for reap
  373. * @hal_ring_hdl: ring pointer
  374. * @last_prefetched_hw_desc: pointer to the last prefetched HW descriptor
  375. * @last_prefetched_sw_desc: pointer to last prefetch SW desc
  376. *
  377. * Return: None
  378. */
  379. #ifdef QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH
  380. static inline
  381. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  382. hal_soc_handle_t hal_soc,
  383. uint32_t num_avail_for_reap,
  384. hal_ring_handle_t hal_ring_hdl,
  385. void **last_prefetched_hw_desc,
  386. struct dp_tx_desc_s
  387. **last_prefetched_sw_desc)
  388. {
  389. if (*last_prefetched_sw_desc) {
  390. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf);
  391. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf + 64);
  392. }
  393. if (num_avail_for_reap && *last_prefetched_hw_desc) {
  394. soc->arch_ops.tx_comp_get_params_from_hal_desc(soc,
  395. *last_prefetched_hw_desc,
  396. last_prefetched_sw_desc);
  397. if ((uintptr_t)*last_prefetched_hw_desc & 0x3f)
  398. *last_prefetched_hw_desc =
  399. hal_srng_dst_prefetch_next_cached_desc(
  400. hal_soc,
  401. hal_ring_hdl,
  402. (uint8_t *)*last_prefetched_hw_desc);
  403. else
  404. *last_prefetched_hw_desc =
  405. hal_srng_dst_get_next_32_byte_desc(hal_soc,
  406. hal_ring_hdl,
  407. (uint8_t *)*last_prefetched_hw_desc);
  408. }
  409. }
  410. #else
  411. static inline
  412. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  413. hal_soc_handle_t hal_soc,
  414. uint32_t num_avail_for_reap,
  415. hal_ring_handle_t hal_ring_hdl,
  416. void **last_prefetched_hw_desc,
  417. struct dp_tx_desc_s
  418. **last_prefetched_sw_desc)
  419. {
  420. }
  421. #endif
  422. #ifndef FEATURE_WDS
  423. static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
  424. {
  425. return;
  426. }
  427. #endif
  428. #ifndef QCA_MULTIPASS_SUPPORT
  429. static inline
  430. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  431. qdf_nbuf_t nbuf,
  432. struct dp_tx_msdu_info_s *msdu_info)
  433. {
  434. return true;
  435. }
  436. static inline
  437. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev)
  438. {
  439. }
  440. #else
  441. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  442. qdf_nbuf_t nbuf,
  443. struct dp_tx_msdu_info_s *msdu_info);
  444. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev);
  445. void dp_tx_remove_vlan_tag(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  446. void dp_tx_add_groupkey_metadata(struct dp_vdev *vdev,
  447. struct dp_tx_msdu_info_s *msdu_info,
  448. uint16_t group_key);
  449. #endif
  450. /**
  451. * dp_tx_hw_to_qdf()- convert hw status to qdf status
  452. * @status: hw status
  453. *
  454. * Return: qdf tx rx status
  455. */
  456. static inline enum qdf_dp_tx_rx_status dp_tx_hw_to_qdf(uint16_t status)
  457. {
  458. switch (status) {
  459. case HAL_TX_TQM_RR_FRAME_ACKED:
  460. return QDF_TX_RX_STATUS_OK;
  461. case HAL_TX_TQM_RR_REM_CMD_TX:
  462. return QDF_TX_RX_STATUS_NO_ACK;
  463. case HAL_TX_TQM_RR_REM_CMD_REM:
  464. case HAL_TX_TQM_RR_REM_CMD_NOTX:
  465. case HAL_TX_TQM_RR_REM_CMD_AGED:
  466. return QDF_TX_RX_STATUS_FW_DISCARD;
  467. default:
  468. return QDF_TX_RX_STATUS_DEFAULT;
  469. }
  470. }
  471. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  472. /**
  473. * dp_tx_get_queue() - Returns Tx queue IDs to be used for this Tx frame
  474. * @vdev: DP Virtual device handle
  475. * @nbuf: Buffer pointer
  476. * @queue: queue ids container for nbuf
  477. *
  478. * TX packet queue has 2 instances, software descriptors id and dma ring id
  479. * Based on tx feature and hardware configuration queue id combination could be
  480. * different.
  481. * For example -
  482. * With XPS enabled,all TX descriptor pools and dma ring are assigned per cpu id
  483. * With no XPS,lock based resource protection, Descriptor pool ids are different
  484. * for each vdev, dma ring id will be same as single pdev id
  485. *
  486. * Return: None
  487. */
  488. #ifdef QCA_OL_TX_MULTIQ_SUPPORT
  489. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  490. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  491. {
  492. queue->ring_id = qdf_get_cpu();
  493. queue->desc_pool_id = queue->ring_id;
  494. }
  495. /*
  496. * dp_tx_get_hal_ring_hdl()- Get the hal_tx_ring_hdl for data transmission
  497. * @dp_soc - DP soc structure pointer
  498. * @ring_id - Transmit Queue/ring_id to be used when XPS is enabled
  499. *
  500. * Return - HAL ring handle
  501. */
  502. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  503. uint8_t ring_id)
  504. {
  505. if (ring_id == soc->num_tcl_data_rings)
  506. return soc->tcl_cmd_credit_ring.hal_srng;
  507. return soc->tcl_data_ring[ring_id].hal_srng;
  508. }
  509. #else /* QCA_OL_TX_MULTIQ_SUPPORT */
  510. #ifdef TX_MULTI_TCL
  511. #ifdef IPA_OFFLOAD
  512. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  513. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  514. {
  515. /* get flow id */
  516. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  517. if (vdev->pdev->soc->wlan_cfg_ctx->ipa_enabled)
  518. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  519. else
  520. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  521. vdev->pdev->soc->num_tcl_data_rings);
  522. }
  523. #else
  524. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  525. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  526. {
  527. /* get flow id */
  528. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  529. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  530. vdev->pdev->soc->num_tcl_data_rings);
  531. }
  532. #endif
  533. #else
  534. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  535. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  536. {
  537. /* get flow id */
  538. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  539. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  540. }
  541. #endif
  542. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  543. uint8_t ring_id)
  544. {
  545. return soc->tcl_data_ring[ring_id].hal_srng;
  546. }
  547. #endif
  548. #ifdef QCA_OL_TX_LOCK_LESS_ACCESS
  549. /*
  550. * dp_tx_hal_ring_access_start()- hal_tx_ring access for data transmission
  551. * @dp_soc - DP soc structure pointer
  552. * @hal_ring_hdl - HAL ring handle
  553. *
  554. * Return - None
  555. */
  556. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  557. hal_ring_handle_t hal_ring_hdl)
  558. {
  559. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  560. }
  561. /*
  562. * dp_tx_hal_ring_access_end()- hal_tx_ring access for data transmission
  563. * @dp_soc - DP soc structure pointer
  564. * @hal_ring_hdl - HAL ring handle
  565. *
  566. * Return - None
  567. */
  568. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  569. hal_ring_handle_t hal_ring_hdl)
  570. {
  571. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  572. }
  573. /*
  574. * dp_tx_hal_ring_access_reap()- hal_tx_ring access for data transmission
  575. * @dp_soc - DP soc structure pointer
  576. * @hal_ring_hdl - HAL ring handle
  577. *
  578. * Return - None
  579. */
  580. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  581. hal_ring_handle_t
  582. hal_ring_hdl)
  583. {
  584. }
  585. #else
  586. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  587. hal_ring_handle_t hal_ring_hdl)
  588. {
  589. return hal_srng_access_start(soc->hal_soc, hal_ring_hdl);
  590. }
  591. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  592. hal_ring_handle_t hal_ring_hdl)
  593. {
  594. hal_srng_access_end(soc->hal_soc, hal_ring_hdl);
  595. }
  596. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  597. hal_ring_handle_t
  598. hal_ring_hdl)
  599. {
  600. hal_srng_access_end_reap(soc->hal_soc, hal_ring_hdl);
  601. }
  602. #endif
  603. #ifdef ATH_TX_PRI_OVERRIDE
  604. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
  605. ((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
  606. #else
  607. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
  608. #endif
  609. /* TODO TX_FEATURE_NOT_YET */
  610. static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
  611. {
  612. return;
  613. }
  614. /* TODO TX_FEATURE_NOT_YET */
  615. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  616. bool force_free);
  617. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
  618. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
  619. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
  620. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc);
  621. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc);
  622. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc);
  623. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc);
  624. void
  625. dp_handle_wbm_internal_error(struct dp_soc *soc, void *hal_desc,
  626. uint32_t buf_type);
  627. #else /* QCA_HOST_MODE_WIFI_DISABLED */
  628. static inline
  629. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  630. {
  631. return QDF_STATUS_SUCCESS;
  632. }
  633. static inline
  634. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  635. {
  636. return QDF_STATUS_SUCCESS;
  637. }
  638. static inline void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  639. {
  640. }
  641. static inline void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  642. {
  643. }
  644. static inline
  645. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  646. bool force_free)
  647. {
  648. }
  649. static inline QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  650. {
  651. return QDF_STATUS_SUCCESS;
  652. }
  653. static inline QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  654. {
  655. return QDF_STATUS_SUCCESS;
  656. }
  657. static inline void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  658. {
  659. }
  660. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  661. #if defined(QCA_SUPPORT_LATENCY_CAPTURE) || \
  662. defined(QCA_TX_CAPTURE_SUPPORT) || \
  663. defined(QCA_MCOPY_SUPPORT)
  664. #ifdef FEATURE_PERPKT_INFO
  665. QDF_STATUS
  666. dp_get_completion_indication_for_stack(struct dp_soc *soc,
  667. struct dp_pdev *pdev,
  668. struct dp_txrx_peer *peer,
  669. struct hal_tx_completion_status *ts,
  670. qdf_nbuf_t netbuf,
  671. uint64_t time_latency);
  672. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  673. uint16_t peer_id, uint32_t ppdu_id,
  674. qdf_nbuf_t netbuf);
  675. #endif
  676. #else
  677. static inline
  678. QDF_STATUS dp_get_completion_indication_for_stack(struct dp_soc *soc,
  679. struct dp_pdev *pdev,
  680. struct dp_txrx_peer *peer,
  681. struct hal_tx_completion_status *ts,
  682. qdf_nbuf_t netbuf,
  683. uint64_t time_latency)
  684. {
  685. return QDF_STATUS_E_NOSUPPORT;
  686. }
  687. static inline
  688. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  689. uint16_t peer_id, uint32_t ppdu_id,
  690. qdf_nbuf_t netbuf)
  691. {
  692. }
  693. #endif
  694. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  695. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  696. struct dp_tx_desc_s *desc,
  697. struct hal_tx_completion_status *ts);
  698. #else
  699. static inline void
  700. dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  701. struct dp_tx_desc_s *desc,
  702. struct hal_tx_completion_status *ts)
  703. {
  704. }
  705. #endif
  706. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  707. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  708. /**
  709. * dp_tx_update_stats() - Update soc level tx stats
  710. * @soc: DP soc handle
  711. * @tx_desc: TX descriptor reference
  712. * @ring_id: TCL ring id
  713. *
  714. * Returns: none
  715. */
  716. void dp_tx_update_stats(struct dp_soc *soc,
  717. struct dp_tx_desc_s *tx_desc,
  718. uint8_t ring_id);
  719. /**
  720. * dp_tx_attempt_coalescing() - Check and attempt TCL register write coalescing
  721. * @soc: Datapath soc handle
  722. * @tx_desc: tx packet descriptor
  723. * @tid: TID for pkt transmission
  724. * @msdu_info: MSDU info of tx packet
  725. * @ring_id: TCL ring id
  726. *
  727. * Returns: 1, if coalescing is to be done
  728. * 0, if coalescing is not to be done
  729. */
  730. int
  731. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  732. struct dp_tx_desc_s *tx_desc,
  733. uint8_t tid,
  734. struct dp_tx_msdu_info_s *msdu_info,
  735. uint8_t ring_id);
  736. /**
  737. * dp_tx_ring_access_end() - HAL ring access end for data transmission
  738. * @soc: Datapath soc handle
  739. * @hal_ring_hdl: HAL ring handle
  740. * @coalesce: Coalesce the current write or not
  741. *
  742. * Returns: none
  743. */
  744. void
  745. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  746. int coalesce);
  747. #else
  748. /**
  749. * dp_tx_update_stats() - Update soc level tx stats
  750. * @soc: DP soc handle
  751. * @tx_desc: TX descriptor reference
  752. * @ring_id: TCL ring id
  753. *
  754. * Returns: none
  755. */
  756. static inline void dp_tx_update_stats(struct dp_soc *soc,
  757. struct dp_tx_desc_s *tx_desc,
  758. uint8_t ring_id){ }
  759. static inline void
  760. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  761. int coalesce)
  762. {
  763. dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
  764. }
  765. static inline int
  766. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  767. struct dp_tx_desc_s *tx_desc,
  768. uint8_t tid,
  769. struct dp_tx_msdu_info_s *msdu_info,
  770. uint8_t ring_id)
  771. {
  772. return 0;
  773. }
  774. #endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */
  775. #ifdef FEATURE_RUNTIME_PM
  776. /**
  777. * dp_set_rtpm_tput_policy_requirement() - Update RTPM throughput policy
  778. * @soc_hdl: DP soc handle
  779. * @is_high_tput: flag to indicate whether throughput is high
  780. *
  781. * Returns: none
  782. */
  783. static inline
  784. void dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  785. bool is_high_tput)
  786. {
  787. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  788. qdf_atomic_set(&soc->rtpm_high_tput_flag, is_high_tput);
  789. }
  790. void
  791. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  792. hal_ring_handle_t hal_ring_hdl,
  793. int coalesce);
  794. #else
  795. #ifdef DP_POWER_SAVE
  796. void
  797. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  798. hal_ring_handle_t hal_ring_hdl,
  799. int coalesce);
  800. #else
  801. static inline void
  802. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  803. hal_ring_handle_t hal_ring_hdl,
  804. int coalesce)
  805. {
  806. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  807. }
  808. #endif
  809. static inline void
  810. dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  811. bool is_high_tput)
  812. { }
  813. #endif
  814. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  815. #ifdef DP_TX_HW_DESC_HISTORY
  816. static inline void
  817. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  818. hal_ring_handle_t hal_ring_hdl,
  819. struct dp_soc *soc, uint8_t ring_id)
  820. {
  821. struct dp_tx_hw_desc_history *tx_hw_desc_history =
  822. &soc->tx_hw_desc_history;
  823. struct dp_tx_hw_desc_evt *evt;
  824. uint32_t idx = 0;
  825. uint16_t slot = 0;
  826. if (!tx_hw_desc_history->allocated)
  827. return;
  828. dp_get_frag_hist_next_atomic_idx(&tx_hw_desc_history->index, &idx,
  829. &slot,
  830. DP_TX_HW_DESC_HIST_SLOT_SHIFT,
  831. DP_TX_HW_DESC_HIST_PER_SLOT_MAX,
  832. DP_TX_HW_DESC_HIST_MAX);
  833. evt = &tx_hw_desc_history->entry[slot][idx];
  834. qdf_mem_copy(evt->tcl_desc, hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  835. evt->posted = qdf_get_log_timestamp();
  836. evt->tcl_ring_id = ring_id;
  837. hal_get_sw_hptp(soc->hal_soc, hal_ring_hdl, &evt->tp, &evt->hp);
  838. }
  839. #else
  840. static inline void
  841. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  842. hal_ring_handle_t hal_ring_hdl,
  843. struct dp_soc *soc, uint8_t ring_id)
  844. {
  845. }
  846. #endif
  847. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(WLAN_CONFIG_TX_DELAY)
  848. /**
  849. * dp_tx_compute_hw_delay_us() - Compute hardware Tx completion delay
  850. * @ts: Tx completion status
  851. * @delta_tsf: Difference between TSF clock and qtimer
  852. * @delay_us: Delay in microseconds
  853. *
  854. * Return: QDF_STATUS_SUCCESS : Success
  855. * QDF_STATUS_E_INVAL : Tx completion status is invalid or
  856. * delay_us is NULL
  857. * QDF_STATUS_E_FAILURE : Error in delay calculation
  858. */
  859. QDF_STATUS
  860. dp_tx_compute_hw_delay_us(struct hal_tx_completion_status *ts,
  861. uint32_t delta_tsf,
  862. uint32_t *delay_us);
  863. /**
  864. * dp_set_delta_tsf() - Set delta_tsf to dp_soc structure
  865. * @soc_hdl: cdp soc pointer
  866. * @vdev_id: vdev id
  867. * @delta_tsf: difference between TSF clock and qtimer
  868. *
  869. * Return: None
  870. */
  871. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  872. uint32_t delta_tsf);
  873. #endif
  874. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  875. /**
  876. * dp_set_tsf_report_ul_delay() - Enable or disable reporting uplink delay
  877. * @soc_hdl: cdp soc pointer
  878. * @vdev_id: vdev id
  879. * @enable: true to enable and false to disable
  880. *
  881. * Return: QDF_STATUS
  882. */
  883. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  884. uint8_t vdev_id, bool enable);
  885. /**
  886. * dp_get_uplink_delay() - Get uplink delay value
  887. * @soc_hdl: cdp soc pointer
  888. * @vdev_id: vdev id
  889. * @val: pointer to save uplink delay value
  890. *
  891. * Return: QDF_STATUS
  892. */
  893. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  894. uint32_t *val);
  895. #endif /* WLAN_FEATURE_TSF_UPLINK_TSF */
  896. /**
  897. * dp_tx_pkt_tracepoints_enabled() - Get the state of tx pkt tracepoint
  898. *
  899. * Return: True if any tx pkt tracepoint is enabled else false
  900. */
  901. static inline
  902. bool dp_tx_pkt_tracepoints_enabled(void)
  903. {
  904. return (qdf_trace_dp_tx_comp_tcp_pkt_enabled() ||
  905. qdf_trace_dp_tx_comp_udp_pkt_enabled() ||
  906. qdf_trace_dp_tx_comp_pkt_enabled());
  907. }
  908. #ifdef DP_TX_TRACKING
  909. /**
  910. * dp_tx_desc_set_timestamp() - set timestamp in tx descriptor
  911. * @tx_desc - tx descriptor
  912. *
  913. * Return: None
  914. */
  915. static inline
  916. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  917. {
  918. tx_desc->timestamp_tick = qdf_system_ticks();
  919. }
  920. /**
  921. * dp_tx_desc_check_corruption() - Verify magic pattern in tx descriptor
  922. * @tx_desc: tx descriptor
  923. *
  924. * Check for corruption in tx descriptor, if magic pattern is not matching
  925. * trigger self recovery
  926. *
  927. * Return: none
  928. */
  929. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc);
  930. #else
  931. static inline
  932. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  933. {
  934. }
  935. static inline
  936. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  937. {
  938. }
  939. #endif
  940. #ifndef CONFIG_SAWF
  941. static inline bool dp_sawf_tag_valid_get(qdf_nbuf_t nbuf)
  942. {
  943. return false;
  944. }
  945. #endif
  946. #ifdef HW_TX_DELAY_STATS_ENABLE
  947. /**
  948. * dp_tx_desc_set_ktimestamp() - set kernel timestamp in tx descriptor
  949. * @vdev: DP vdev handle
  950. * @tx_desc: tx descriptor
  951. *
  952. * Return: true when descriptor is timestamped, false otherwise
  953. */
  954. static inline
  955. bool dp_tx_desc_set_ktimestamp(struct dp_vdev *vdev,
  956. struct dp_tx_desc_s *tx_desc)
  957. {
  958. if (qdf_unlikely(vdev->pdev->delay_stats_flag) ||
  959. qdf_unlikely(vdev->pdev->soc->wlan_cfg_ctx->pext_stats_enabled) ||
  960. qdf_unlikely(dp_tx_pkt_tracepoints_enabled()) ||
  961. qdf_unlikely(vdev->pdev->soc->peerstats_enabled) ||
  962. qdf_unlikely(dp_is_vdev_tx_delay_stats_enabled(vdev))) {
  963. tx_desc->timestamp = qdf_ktime_real_get();
  964. return true;
  965. }
  966. return false;
  967. }
  968. #else
  969. static inline
  970. bool dp_tx_desc_set_ktimestamp(struct dp_vdev *vdev,
  971. struct dp_tx_desc_s *tx_desc)
  972. {
  973. if (qdf_unlikely(vdev->pdev->delay_stats_flag) ||
  974. qdf_unlikely(vdev->pdev->soc->wlan_cfg_ctx->pext_stats_enabled) ||
  975. qdf_unlikely(dp_tx_pkt_tracepoints_enabled()) ||
  976. qdf_unlikely(vdev->pdev->soc->peerstats_enabled)) {
  977. tx_desc->timestamp = qdf_ktime_real_get();
  978. return true;
  979. }
  980. return false;
  981. }
  982. #endif
  983. #ifdef CONFIG_DP_PKT_ADD_TIMESTAMP
  984. /**
  985. * dp_pkt_add_timestamp() - add timestamp in data payload
  986. *
  987. * @vdev: dp vdev
  988. * @index: index to decide offset in payload
  989. * @time: timestamp to add in data payload
  990. * @nbuf: network buffer
  991. *
  992. * Return: none
  993. */
  994. void dp_pkt_add_timestamp(struct dp_vdev *vdev,
  995. enum qdf_pkt_timestamp_index index, uint64_t time,
  996. qdf_nbuf_t nbuf);
  997. /**
  998. * dp_pkt_get_timestamp() - get current system time
  999. *
  1000. * @time: return current system time
  1001. *
  1002. * Return: none
  1003. */
  1004. void dp_pkt_get_timestamp(uint64_t *time);
  1005. #else
  1006. #define dp_pkt_add_timestamp(vdev, index, time, nbuf)
  1007. static inline
  1008. void dp_pkt_get_timestamp(uint64_t *time)
  1009. {
  1010. }
  1011. #endif
  1012. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  1013. /**
  1014. * dp_update_tx_desc_stats - Update the increase or decrease in
  1015. * outstanding tx desc count
  1016. * values on pdev and soc
  1017. * @vdev: DP pdev handle
  1018. *
  1019. * Return: void
  1020. */
  1021. static inline void
  1022. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  1023. {
  1024. int32_t tx_descs_cnt =
  1025. qdf_atomic_read(&pdev->num_tx_outstanding);
  1026. if (pdev->tx_descs_max < tx_descs_cnt)
  1027. pdev->tx_descs_max = tx_descs_cnt;
  1028. qdf_mem_tx_desc_cnt_update(pdev->num_tx_outstanding,
  1029. pdev->tx_descs_max);
  1030. }
  1031. #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
  1032. static inline void
  1033. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  1034. {
  1035. }
  1036. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  1037. #ifdef QCA_TX_LIMIT_CHECK
  1038. /**
  1039. * dp_tx_limit_check - Check if allocated tx descriptors reached
  1040. * soc max limit and pdev max limit
  1041. * @vdev: DP vdev handle
  1042. *
  1043. * Return: true if allocated tx descriptors reached max configured value, else
  1044. * false
  1045. */
  1046. static inline bool
  1047. dp_tx_limit_check(struct dp_vdev *vdev)
  1048. {
  1049. struct dp_pdev *pdev = vdev->pdev;
  1050. struct dp_soc *soc = pdev->soc;
  1051. if (qdf_atomic_read(&soc->num_tx_outstanding) >=
  1052. soc->num_tx_allowed) {
  1053. dp_tx_info("queued packets are more than max tx, drop the frame");
  1054. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1055. return true;
  1056. }
  1057. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  1058. pdev->num_tx_allowed) {
  1059. dp_tx_info("queued packets are more than max tx, drop the frame");
  1060. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1061. DP_STATS_INC(vdev, tx_i.dropped.desc_na_exc_outstand.num, 1);
  1062. return true;
  1063. }
  1064. return false;
  1065. }
  1066. /**
  1067. * dp_tx_exception_limit_check - Check if allocated tx exception descriptors
  1068. * reached soc max limit
  1069. * @vdev: DP vdev handle
  1070. *
  1071. * Return: true if allocated tx descriptors reached max configured value, else
  1072. * false
  1073. */
  1074. static inline bool
  1075. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  1076. {
  1077. struct dp_pdev *pdev = vdev->pdev;
  1078. struct dp_soc *soc = pdev->soc;
  1079. if (qdf_atomic_read(&soc->num_tx_exception) >=
  1080. soc->num_msdu_exception_desc) {
  1081. dp_info("exc packets are more than max drop the exc pkt");
  1082. DP_STATS_INC(vdev, tx_i.dropped.exc_desc_na.num, 1);
  1083. return true;
  1084. }
  1085. return false;
  1086. }
  1087. /**
  1088. * dp_tx_outstanding_inc - Increment outstanding tx desc values on pdev and soc
  1089. * @vdev: DP pdev handle
  1090. *
  1091. * Return: void
  1092. */
  1093. static inline void
  1094. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1095. {
  1096. struct dp_soc *soc = pdev->soc;
  1097. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1098. qdf_atomic_inc(&soc->num_tx_outstanding);
  1099. dp_update_tx_desc_stats(pdev);
  1100. }
  1101. /**
  1102. * dp_tx_outstanding__dec - Decrement outstanding tx desc values on pdev and soc
  1103. * @vdev: DP pdev handle
  1104. *
  1105. * Return: void
  1106. */
  1107. static inline void
  1108. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1109. {
  1110. struct dp_soc *soc = pdev->soc;
  1111. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1112. qdf_atomic_dec(&soc->num_tx_outstanding);
  1113. dp_update_tx_desc_stats(pdev);
  1114. }
  1115. #else //QCA_TX_LIMIT_CHECK
  1116. static inline bool
  1117. dp_tx_limit_check(struct dp_vdev *vdev)
  1118. {
  1119. return false;
  1120. }
  1121. static inline bool
  1122. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  1123. {
  1124. return false;
  1125. }
  1126. static inline void
  1127. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1128. {
  1129. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1130. dp_update_tx_desc_stats(pdev);
  1131. }
  1132. static inline void
  1133. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1134. {
  1135. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1136. dp_update_tx_desc_stats(pdev);
  1137. }
  1138. #endif //QCA_TX_LIMIT_CHECK
  1139. #endif