dp_tx.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  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. void dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc);
  229. void dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id);
  230. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  231. uint8_t tid, uint8_t ring_id);
  232. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  233. struct dp_tx_desc_s *tx_desc,
  234. struct hal_tx_completion_status *ts,
  235. struct dp_txrx_peer *txrx_peer,
  236. uint8_t ring_id);
  237. void dp_tx_comp_process_desc(struct dp_soc *soc,
  238. struct dp_tx_desc_s *desc,
  239. struct hal_tx_completion_status *ts,
  240. struct dp_txrx_peer *txrx_peer);
  241. void dp_tx_reinject_handler(struct dp_soc *soc,
  242. struct dp_vdev *vdev,
  243. struct dp_tx_desc_s *tx_desc,
  244. uint8_t *status,
  245. uint8_t reinject_reason);
  246. void dp_tx_inspect_handler(struct dp_soc *soc,
  247. struct dp_vdev *vdev,
  248. struct dp_tx_desc_s *tx_desc,
  249. uint8_t *status);
  250. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  251. uint32_t length, uint8_t tx_status,
  252. bool update);
  253. #ifdef DP_UMAC_HW_RESET_SUPPORT
  254. qdf_nbuf_t dp_tx_drop(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
  255. qdf_nbuf_t dp_tx_exc_drop(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  256. qdf_nbuf_t nbuf,
  257. struct cdp_tx_exception_metadata *tx_exc_metadata);
  258. #endif
  259. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  260. /**
  261. * dp_tso_attach() - TSO Attach handler
  262. * @txrx_soc: Opaque Dp handle
  263. *
  264. * Reserve TSO descriptor buffers
  265. *
  266. * Return: QDF_STATUS_E_FAILURE on failure or
  267. * QDF_STATUS_SUCCESS on success
  268. */
  269. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc);
  270. /**
  271. * dp_tso_detach() - TSO Detach handler
  272. * @txrx_soc: Opaque Dp handle
  273. *
  274. * Deallocate TSO descriptor buffers
  275. *
  276. * Return: QDF_STATUS_E_FAILURE on failure or
  277. * QDF_STATUS_SUCCESS on success
  278. */
  279. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc);
  280. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
  281. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc, uint8_t vdev_id,
  282. qdf_nbuf_t nbuf);
  283. qdf_nbuf_t dp_tx_send_exception(struct cdp_soc_t *soc, uint8_t vdev_id,
  284. qdf_nbuf_t nbuf,
  285. struct cdp_tx_exception_metadata *tx_exc);
  286. qdf_nbuf_t dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc,
  287. uint8_t vdev_id,
  288. qdf_nbuf_t nbuf,
  289. struct cdp_tx_exception_metadata *tx_exc);
  290. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
  291. qdf_nbuf_t nbuf);
  292. qdf_nbuf_t
  293. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  294. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  295. struct cdp_tx_exception_metadata *tx_exc_metadata);
  296. #if QDF_LOCK_STATS
  297. noinline qdf_nbuf_t
  298. dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  299. struct dp_tx_msdu_info_s *msdu_info);
  300. #else
  301. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  302. struct dp_tx_msdu_info_s *msdu_info);
  303. #endif
  304. #ifdef FEATURE_WLAN_TDLS
  305. /**
  306. * dp_tx_non_std() - Allow the control-path SW to send data frames
  307. * @soc_hdl: Datapath soc handle
  308. * @vdev_id: id of vdev
  309. * @tx_spec: what non-standard handling to apply to the tx data frames
  310. * @msdu_list: NULL-terminated list of tx MSDUs
  311. *
  312. * Return: NULL on success,
  313. * nbuf when it fails to send
  314. */
  315. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  316. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
  317. #endif
  318. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac);
  319. /**
  320. * dp_tx_comp_handler() - Tx completion handler
  321. * @int_ctx: pointer to DP interrupt context
  322. * @soc: core txrx main context
  323. * @hal_srng: Opaque HAL SRNG pointer
  324. * @ring_id: completion ring id
  325. * @quota: No. of packets/descriptors that can be serviced in one loop
  326. *
  327. * This function will collect hardware release ring element contents and
  328. * handle descriptor contents. Based on contents, free packet or handle error
  329. * conditions
  330. *
  331. * Return: Number of TX completions processed
  332. */
  333. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  334. hal_ring_handle_t hal_srng, uint8_t ring_id,
  335. uint32_t quota);
  336. QDF_STATUS
  337. dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  338. QDF_STATUS
  339. dp_tx_prepare_send_igmp_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  340. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  341. #if defined(QCA_HOST_MODE_WIFI_DISABLED) || !defined(ATH_SUPPORT_IQUE)
  342. static inline void dp_tx_me_exit(struct dp_pdev *pdev)
  343. {
  344. return;
  345. }
  346. #endif
  347. /**
  348. * dp_tx_pdev_init() - dp tx pdev init
  349. * @pdev: physical device instance
  350. *
  351. * Return: QDF_STATUS_SUCCESS: success
  352. * QDF_STATUS_E_RESOURCES: Error return
  353. */
  354. static inline QDF_STATUS dp_tx_pdev_init(struct dp_pdev *pdev)
  355. {
  356. struct dp_soc *soc = pdev->soc;
  357. /* Initialize Flow control counters */
  358. qdf_atomic_init(&pdev->num_tx_outstanding);
  359. pdev->tx_descs_max = 0;
  360. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  361. /* Initialize descriptors in TCL Ring */
  362. hal_tx_init_data_ring(soc->hal_soc,
  363. soc->tcl_data_ring[pdev->pdev_id].hal_srng);
  364. }
  365. return QDF_STATUS_SUCCESS;
  366. }
  367. /**
  368. * dp_tx_prefetch_hw_sw_nbuf_desc() - function to prefetch HW and SW desc
  369. * @soc: Handle to HAL Soc structure
  370. * @hal_soc: HAL SOC handle
  371. * @num_avail_for_reap: descriptors available for reap
  372. * @hal_ring_hdl: ring pointer
  373. * @last_prefetched_hw_desc: pointer to the last prefetched HW descriptor
  374. * @last_prefetched_sw_desc: pointer to last prefetch SW desc
  375. *
  376. * Return: None
  377. */
  378. #ifdef QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH
  379. static inline
  380. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  381. hal_soc_handle_t hal_soc,
  382. uint32_t num_avail_for_reap,
  383. hal_ring_handle_t hal_ring_hdl,
  384. void **last_prefetched_hw_desc,
  385. struct dp_tx_desc_s
  386. **last_prefetched_sw_desc)
  387. {
  388. if (*last_prefetched_sw_desc) {
  389. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf);
  390. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf + 64);
  391. }
  392. if (num_avail_for_reap && *last_prefetched_hw_desc) {
  393. dp_tx_comp_get_prefetched_params_from_hal_desc(
  394. soc,
  395. *last_prefetched_hw_desc,
  396. last_prefetched_sw_desc);
  397. *last_prefetched_hw_desc =
  398. hal_srng_dst_prefetch_next_cached_desc(
  399. hal_soc,
  400. hal_ring_hdl,
  401. (uint8_t *)*last_prefetched_hw_desc);
  402. }
  403. }
  404. #else
  405. static inline
  406. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  407. hal_soc_handle_t hal_soc,
  408. uint32_t num_avail_for_reap,
  409. hal_ring_handle_t hal_ring_hdl,
  410. void **last_prefetched_hw_desc,
  411. struct dp_tx_desc_s
  412. **last_prefetched_sw_desc)
  413. {
  414. }
  415. #endif
  416. #ifndef FEATURE_WDS
  417. static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
  418. {
  419. return;
  420. }
  421. #endif
  422. #ifndef QCA_MULTIPASS_SUPPORT
  423. static inline
  424. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  425. qdf_nbuf_t nbuf,
  426. struct dp_tx_msdu_info_s *msdu_info)
  427. {
  428. return true;
  429. }
  430. static inline
  431. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev)
  432. {
  433. }
  434. #else
  435. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  436. qdf_nbuf_t nbuf,
  437. struct dp_tx_msdu_info_s *msdu_info);
  438. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev);
  439. void dp_tx_remove_vlan_tag(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  440. void dp_tx_add_groupkey_metadata(struct dp_vdev *vdev,
  441. struct dp_tx_msdu_info_s *msdu_info,
  442. uint16_t group_key);
  443. #endif
  444. /**
  445. * dp_tx_hw_to_qdf()- convert hw status to qdf status
  446. * @status: hw status
  447. *
  448. * Return: qdf tx rx status
  449. */
  450. static inline enum qdf_dp_tx_rx_status dp_tx_hw_to_qdf(uint16_t status)
  451. {
  452. switch (status) {
  453. case HAL_TX_TQM_RR_FRAME_ACKED:
  454. return QDF_TX_RX_STATUS_OK;
  455. case HAL_TX_TQM_RR_REM_CMD_TX:
  456. return QDF_TX_RX_STATUS_NO_ACK;
  457. case HAL_TX_TQM_RR_REM_CMD_REM:
  458. case HAL_TX_TQM_RR_REM_CMD_NOTX:
  459. case HAL_TX_TQM_RR_REM_CMD_AGED:
  460. return QDF_TX_RX_STATUS_FW_DISCARD;
  461. default:
  462. return QDF_TX_RX_STATUS_DEFAULT;
  463. }
  464. }
  465. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  466. /**
  467. * dp_tx_get_queue() - Returns Tx queue IDs to be used for this Tx frame
  468. * @vdev: DP Virtual device handle
  469. * @nbuf: Buffer pointer
  470. * @queue: queue ids container for nbuf
  471. *
  472. * TX packet queue has 2 instances, software descriptors id and dma ring id
  473. * Based on tx feature and hardware configuration queue id combination could be
  474. * different.
  475. * For example -
  476. * With XPS enabled,all TX descriptor pools and dma ring are assigned per cpu id
  477. * With no XPS,lock based resource protection, Descriptor pool ids are different
  478. * for each vdev, dma ring id will be same as single pdev id
  479. *
  480. * Return: None
  481. */
  482. #ifdef QCA_OL_TX_MULTIQ_SUPPORT
  483. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  484. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  485. {
  486. queue->ring_id = qdf_get_cpu();
  487. queue->desc_pool_id = queue->ring_id;
  488. }
  489. /*
  490. * dp_tx_get_hal_ring_hdl()- Get the hal_tx_ring_hdl for data transmission
  491. * @dp_soc - DP soc structure pointer
  492. * @ring_id - Transmit Queue/ring_id to be used when XPS is enabled
  493. *
  494. * Return - HAL ring handle
  495. */
  496. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  497. uint8_t ring_id)
  498. {
  499. if (ring_id == soc->num_tcl_data_rings)
  500. return soc->tcl_cmd_credit_ring.hal_srng;
  501. return soc->tcl_data_ring[ring_id].hal_srng;
  502. }
  503. #else /* QCA_OL_TX_MULTIQ_SUPPORT */
  504. #ifdef TX_MULTI_TCL
  505. #ifdef IPA_OFFLOAD
  506. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  507. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  508. {
  509. /* get flow id */
  510. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  511. if (vdev->pdev->soc->wlan_cfg_ctx->ipa_enabled)
  512. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  513. else
  514. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  515. vdev->pdev->soc->num_tcl_data_rings);
  516. }
  517. #else
  518. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  519. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  520. {
  521. /* get flow id */
  522. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  523. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  524. vdev->pdev->soc->num_tcl_data_rings);
  525. }
  526. #endif
  527. #else
  528. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  529. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  530. {
  531. /* get flow id */
  532. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  533. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  534. }
  535. #endif
  536. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  537. uint8_t ring_id)
  538. {
  539. return soc->tcl_data_ring[ring_id].hal_srng;
  540. }
  541. #endif
  542. #ifdef QCA_OL_TX_LOCK_LESS_ACCESS
  543. /*
  544. * dp_tx_hal_ring_access_start()- hal_tx_ring access for data transmission
  545. * @dp_soc - DP soc structure pointer
  546. * @hal_ring_hdl - HAL ring handle
  547. *
  548. * Return - None
  549. */
  550. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  551. hal_ring_handle_t hal_ring_hdl)
  552. {
  553. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  554. }
  555. /*
  556. * dp_tx_hal_ring_access_end()- hal_tx_ring access for data transmission
  557. * @dp_soc - DP soc structure pointer
  558. * @hal_ring_hdl - HAL ring handle
  559. *
  560. * Return - None
  561. */
  562. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  563. hal_ring_handle_t hal_ring_hdl)
  564. {
  565. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  566. }
  567. /*
  568. * dp_tx_hal_ring_access_reap()- hal_tx_ring access for data transmission
  569. * @dp_soc - DP soc structure pointer
  570. * @hal_ring_hdl - HAL ring handle
  571. *
  572. * Return - None
  573. */
  574. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  575. hal_ring_handle_t
  576. hal_ring_hdl)
  577. {
  578. }
  579. #else
  580. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  581. hal_ring_handle_t hal_ring_hdl)
  582. {
  583. return hal_srng_access_start(soc->hal_soc, hal_ring_hdl);
  584. }
  585. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  586. hal_ring_handle_t hal_ring_hdl)
  587. {
  588. hal_srng_access_end(soc->hal_soc, hal_ring_hdl);
  589. }
  590. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  591. hal_ring_handle_t
  592. hal_ring_hdl)
  593. {
  594. hal_srng_access_end_reap(soc->hal_soc, hal_ring_hdl);
  595. }
  596. #endif
  597. #ifdef ATH_TX_PRI_OVERRIDE
  598. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
  599. ((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
  600. #else
  601. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
  602. #endif
  603. /* TODO TX_FEATURE_NOT_YET */
  604. static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
  605. {
  606. return;
  607. }
  608. /* TODO TX_FEATURE_NOT_YET */
  609. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  610. bool force_free);
  611. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
  612. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
  613. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
  614. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc);
  615. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc);
  616. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc);
  617. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc);
  618. void
  619. dp_handle_wbm_internal_error(struct dp_soc *soc, void *hal_desc,
  620. uint32_t buf_type);
  621. #else /* QCA_HOST_MODE_WIFI_DISABLED */
  622. static inline
  623. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  624. {
  625. return QDF_STATUS_SUCCESS;
  626. }
  627. static inline
  628. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  629. {
  630. return QDF_STATUS_SUCCESS;
  631. }
  632. static inline void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  633. {
  634. }
  635. static inline void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  636. {
  637. }
  638. static inline
  639. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  640. bool force_free)
  641. {
  642. }
  643. static inline QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  644. {
  645. return QDF_STATUS_SUCCESS;
  646. }
  647. static inline QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  648. {
  649. return QDF_STATUS_SUCCESS;
  650. }
  651. static inline void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  652. {
  653. }
  654. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  655. #if defined(QCA_SUPPORT_LATENCY_CAPTURE) || \
  656. defined(QCA_TX_CAPTURE_SUPPORT) || \
  657. defined(QCA_MCOPY_SUPPORT)
  658. #ifdef FEATURE_PERPKT_INFO
  659. QDF_STATUS
  660. dp_get_completion_indication_for_stack(struct dp_soc *soc,
  661. struct dp_pdev *pdev,
  662. struct dp_txrx_peer *peer,
  663. struct hal_tx_completion_status *ts,
  664. qdf_nbuf_t netbuf,
  665. uint64_t time_latency);
  666. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  667. uint16_t peer_id, uint32_t ppdu_id,
  668. qdf_nbuf_t netbuf);
  669. #endif
  670. #else
  671. static inline
  672. QDF_STATUS dp_get_completion_indication_for_stack(struct dp_soc *soc,
  673. struct dp_pdev *pdev,
  674. struct dp_txrx_peer *peer,
  675. struct hal_tx_completion_status *ts,
  676. qdf_nbuf_t netbuf,
  677. uint64_t time_latency)
  678. {
  679. return QDF_STATUS_E_NOSUPPORT;
  680. }
  681. static inline
  682. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  683. uint16_t peer_id, uint32_t ppdu_id,
  684. qdf_nbuf_t netbuf)
  685. {
  686. }
  687. #endif
  688. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  689. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  690. struct dp_tx_desc_s *desc,
  691. struct hal_tx_completion_status *ts);
  692. #else
  693. static inline void
  694. dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  695. struct dp_tx_desc_s *desc,
  696. struct hal_tx_completion_status *ts)
  697. {
  698. }
  699. #endif
  700. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  701. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  702. /**
  703. * dp_tx_update_stats() - Update soc level tx stats
  704. * @soc: DP soc handle
  705. * @tx_desc: TX descriptor reference
  706. * @ring_id: TCL ring id
  707. *
  708. * Returns: none
  709. */
  710. void dp_tx_update_stats(struct dp_soc *soc,
  711. struct dp_tx_desc_s *tx_desc,
  712. uint8_t ring_id);
  713. /**
  714. * dp_tx_attempt_coalescing() - Check and attempt TCL register write coalescing
  715. * @soc: Datapath soc handle
  716. * @tx_desc: tx packet descriptor
  717. * @tid: TID for pkt transmission
  718. * @msdu_info: MSDU info of tx packet
  719. * @ring_id: TCL ring id
  720. *
  721. * Returns: 1, if coalescing is to be done
  722. * 0, if coalescing is not to be done
  723. */
  724. int
  725. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  726. struct dp_tx_desc_s *tx_desc,
  727. uint8_t tid,
  728. struct dp_tx_msdu_info_s *msdu_info,
  729. uint8_t ring_id);
  730. /**
  731. * dp_tx_ring_access_end() - HAL ring access end for data transmission
  732. * @soc: Datapath soc handle
  733. * @hal_ring_hdl: HAL ring handle
  734. * @coalesce: Coalesce the current write or not
  735. *
  736. * Returns: none
  737. */
  738. void
  739. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  740. int coalesce);
  741. #else
  742. /**
  743. * dp_tx_update_stats() - Update soc level tx stats
  744. * @soc: DP soc handle
  745. * @tx_desc: TX descriptor reference
  746. * @ring_id: TCL ring id
  747. *
  748. * Returns: none
  749. */
  750. static inline void dp_tx_update_stats(struct dp_soc *soc,
  751. struct dp_tx_desc_s *tx_desc,
  752. uint8_t ring_id){ }
  753. static inline void
  754. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  755. int coalesce)
  756. {
  757. dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
  758. }
  759. static inline int
  760. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  761. struct dp_tx_desc_s *tx_desc,
  762. uint8_t tid,
  763. struct dp_tx_msdu_info_s *msdu_info,
  764. uint8_t ring_id)
  765. {
  766. return 0;
  767. }
  768. #endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */
  769. #ifdef FEATURE_RUNTIME_PM
  770. /**
  771. * dp_set_rtpm_tput_policy_requirement() - Update RTPM throughput policy
  772. * @soc_hdl: DP soc handle
  773. * @is_high_tput: flag to indicate whether throughput is high
  774. *
  775. * Returns: none
  776. */
  777. static inline
  778. void dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  779. bool is_high_tput)
  780. {
  781. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  782. qdf_atomic_set(&soc->rtpm_high_tput_flag, is_high_tput);
  783. }
  784. void
  785. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  786. hal_ring_handle_t hal_ring_hdl,
  787. int coalesce);
  788. #else
  789. #ifdef DP_POWER_SAVE
  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. static inline void
  796. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  797. hal_ring_handle_t hal_ring_hdl,
  798. int coalesce)
  799. {
  800. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  801. }
  802. #endif
  803. static inline void
  804. dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  805. bool is_high_tput)
  806. { }
  807. #endif
  808. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  809. #ifdef DP_TX_HW_DESC_HISTORY
  810. static inline void
  811. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  812. hal_ring_handle_t hal_ring_hdl,
  813. struct dp_soc *soc)
  814. {
  815. struct dp_tx_hw_desc_evt *evt;
  816. uint64_t idx = 0;
  817. if (!soc->tx_hw_desc_history)
  818. return;
  819. idx = ++soc->tx_hw_desc_history->index;
  820. if (idx == DP_TX_HW_DESC_HIST_MAX)
  821. soc->tx_hw_desc_history->index = 0;
  822. idx = qdf_do_div_rem(idx, DP_TX_HW_DESC_HIST_MAX);
  823. evt = &soc->tx_hw_desc_history->entry[idx];
  824. qdf_mem_copy(evt->tcl_desc, hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  825. evt->posted = qdf_get_log_timestamp();
  826. hal_get_sw_hptp(soc->hal_soc, hal_ring_hdl, &evt->tp, &evt->hp);
  827. }
  828. #else
  829. static inline void
  830. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  831. hal_ring_handle_t hal_ring_hdl,
  832. struct dp_soc *soc)
  833. {
  834. }
  835. #endif
  836. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(WLAN_CONFIG_TX_DELAY)
  837. /**
  838. * dp_tx_compute_hw_delay_us() - Compute hardware Tx completion delay
  839. * @ts: Tx completion status
  840. * @delta_tsf: Difference between TSF clock and qtimer
  841. * @delay_us: Delay in microseconds
  842. *
  843. * Return: QDF_STATUS_SUCCESS : Success
  844. * QDF_STATUS_E_INVAL : Tx completion status is invalid or
  845. * delay_us is NULL
  846. * QDF_STATUS_E_FAILURE : Error in delay calculation
  847. */
  848. QDF_STATUS
  849. dp_tx_compute_hw_delay_us(struct hal_tx_completion_status *ts,
  850. uint32_t delta_tsf,
  851. uint32_t *delay_us);
  852. /**
  853. * dp_set_delta_tsf() - Set delta_tsf to dp_soc structure
  854. * @soc_hdl: cdp soc pointer
  855. * @vdev_id: vdev id
  856. * @delta_tsf: difference between TSF clock and qtimer
  857. *
  858. * Return: None
  859. */
  860. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  861. uint32_t delta_tsf);
  862. #endif
  863. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  864. /**
  865. * dp_set_tsf_report_ul_delay() - Enable or disable reporting uplink delay
  866. * @soc_hdl: cdp soc pointer
  867. * @vdev_id: vdev id
  868. * @enable: true to enable and false to disable
  869. *
  870. * Return: QDF_STATUS
  871. */
  872. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  873. uint8_t vdev_id, bool enable);
  874. /**
  875. * dp_get_uplink_delay() - Get uplink delay value
  876. * @soc_hdl: cdp soc pointer
  877. * @vdev_id: vdev id
  878. * @val: pointer to save uplink delay value
  879. *
  880. * Return: QDF_STATUS
  881. */
  882. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  883. uint32_t *val);
  884. #endif /* WLAN_FEATURE_TSF_UPLINK_TSF */
  885. /**
  886. * dp_tx_pkt_tracepoints_enabled() - Get the state of tx pkt tracepoint
  887. *
  888. * Return: True if any tx pkt tracepoint is enabled else false
  889. */
  890. static inline
  891. bool dp_tx_pkt_tracepoints_enabled(void)
  892. {
  893. return (qdf_trace_dp_tx_comp_tcp_pkt_enabled() ||
  894. qdf_trace_dp_tx_comp_udp_pkt_enabled() ||
  895. qdf_trace_dp_tx_comp_pkt_enabled());
  896. }
  897. #ifdef DP_TX_TRACKING
  898. /**
  899. * dp_tx_desc_set_timestamp() - set timestamp in tx descriptor
  900. * @tx_desc - tx descriptor
  901. *
  902. * Return: None
  903. */
  904. static inline
  905. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  906. {
  907. tx_desc->timestamp_tick = qdf_system_ticks();
  908. }
  909. /**
  910. * dp_tx_desc_check_corruption() - Verify magic pattern in tx descriptor
  911. * @tx_desc: tx descriptor
  912. *
  913. * Check for corruption in tx descriptor, if magic pattern is not matching
  914. * trigger self recovery
  915. *
  916. * Return: none
  917. */
  918. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc);
  919. #else
  920. static inline
  921. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  922. {
  923. }
  924. static inline
  925. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  926. {
  927. }
  928. #endif
  929. #ifndef CONFIG_SAWF
  930. static inline bool dp_sawf_tag_valid_get(qdf_nbuf_t nbuf)
  931. {
  932. return false;
  933. }
  934. #endif
  935. #ifdef HW_TX_DELAY_STATS_ENABLE
  936. /**
  937. * dp_tx_desc_set_ktimestamp() - set kernel timestamp in tx descriptor
  938. * @vdev: DP vdev handle
  939. * @tx_desc: tx descriptor
  940. *
  941. * Return: true when descriptor is timestamped, false otherwise
  942. */
  943. static inline
  944. bool dp_tx_desc_set_ktimestamp(struct dp_vdev *vdev,
  945. struct dp_tx_desc_s *tx_desc)
  946. {
  947. if (qdf_unlikely(vdev->pdev->delay_stats_flag) ||
  948. qdf_unlikely(vdev->pdev->soc->wlan_cfg_ctx->pext_stats_enabled) ||
  949. qdf_unlikely(dp_tx_pkt_tracepoints_enabled()) ||
  950. qdf_unlikely(vdev->pdev->soc->peerstats_enabled) ||
  951. qdf_unlikely(dp_is_vdev_tx_delay_stats_enabled(vdev))) {
  952. tx_desc->timestamp = qdf_ktime_real_get();
  953. return true;
  954. }
  955. return false;
  956. }
  957. #else
  958. static inline
  959. bool dp_tx_desc_set_ktimestamp(struct dp_vdev *vdev,
  960. struct dp_tx_desc_s *tx_desc)
  961. {
  962. if (qdf_unlikely(vdev->pdev->delay_stats_flag) ||
  963. qdf_unlikely(vdev->pdev->soc->wlan_cfg_ctx->pext_stats_enabled) ||
  964. qdf_unlikely(dp_tx_pkt_tracepoints_enabled()) ||
  965. qdf_unlikely(vdev->pdev->soc->peerstats_enabled)) {
  966. tx_desc->timestamp = qdf_ktime_real_get();
  967. return true;
  968. }
  969. return false;
  970. }
  971. #endif
  972. #ifdef CONFIG_DP_PKT_ADD_TIMESTAMP
  973. /**
  974. * dp_pkt_add_timestamp() - add timestamp in data payload
  975. *
  976. * @vdev: dp vdev
  977. * @index: index to decide offset in payload
  978. * @time: timestamp to add in data payload
  979. * @nbuf: network buffer
  980. *
  981. * Return: none
  982. */
  983. void dp_pkt_add_timestamp(struct dp_vdev *vdev,
  984. enum qdf_pkt_timestamp_index index, uint64_t time,
  985. qdf_nbuf_t nbuf);
  986. /**
  987. * dp_pkt_get_timestamp() - get current system time
  988. *
  989. * @time: return current system time
  990. *
  991. * Return: none
  992. */
  993. void dp_pkt_get_timestamp(uint64_t *time);
  994. #else
  995. #define dp_pkt_add_timestamp(vdev, index, time, nbuf)
  996. static inline
  997. void dp_pkt_get_timestamp(uint64_t *time)
  998. {
  999. }
  1000. #endif
  1001. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  1002. /**
  1003. * dp_update_tx_desc_stats - Update the increase or decrease in
  1004. * outstanding tx desc count
  1005. * values on pdev and soc
  1006. * @vdev: DP pdev handle
  1007. *
  1008. * Return: void
  1009. */
  1010. static inline void
  1011. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  1012. {
  1013. int32_t tx_descs_cnt =
  1014. qdf_atomic_read(&pdev->num_tx_outstanding);
  1015. if (pdev->tx_descs_max < tx_descs_cnt)
  1016. pdev->tx_descs_max = tx_descs_cnt;
  1017. qdf_mem_tx_desc_cnt_update(pdev->num_tx_outstanding,
  1018. pdev->tx_descs_max);
  1019. }
  1020. #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
  1021. static inline void
  1022. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  1023. {
  1024. }
  1025. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  1026. #ifdef QCA_TX_LIMIT_CHECK
  1027. /**
  1028. * dp_tx_limit_check - Check if allocated tx descriptors reached
  1029. * soc max limit and pdev max limit
  1030. * @vdev: DP vdev handle
  1031. *
  1032. * Return: true if allocated tx descriptors reached max configured value, else
  1033. * false
  1034. */
  1035. static inline bool
  1036. dp_tx_limit_check(struct dp_vdev *vdev)
  1037. {
  1038. struct dp_pdev *pdev = vdev->pdev;
  1039. struct dp_soc *soc = pdev->soc;
  1040. if (qdf_atomic_read(&soc->num_tx_outstanding) >=
  1041. soc->num_tx_allowed) {
  1042. dp_tx_info("queued packets are more than max tx, drop the frame");
  1043. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1044. return true;
  1045. }
  1046. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  1047. pdev->num_tx_allowed) {
  1048. dp_tx_info("queued packets are more than max tx, drop the frame");
  1049. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1050. DP_STATS_INC(vdev, tx_i.dropped.desc_na_exc_outstand.num, 1);
  1051. return true;
  1052. }
  1053. return false;
  1054. }
  1055. /**
  1056. * dp_tx_exception_limit_check - Check if allocated tx exception descriptors
  1057. * reached soc max limit
  1058. * @vdev: DP vdev handle
  1059. *
  1060. * Return: true if allocated tx descriptors reached max configured value, else
  1061. * false
  1062. */
  1063. static inline bool
  1064. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  1065. {
  1066. struct dp_pdev *pdev = vdev->pdev;
  1067. struct dp_soc *soc = pdev->soc;
  1068. if (qdf_atomic_read(&soc->num_tx_exception) >=
  1069. soc->num_msdu_exception_desc) {
  1070. dp_info("exc packets are more than max drop the exc pkt");
  1071. DP_STATS_INC(vdev, tx_i.dropped.exc_desc_na.num, 1);
  1072. return true;
  1073. }
  1074. return false;
  1075. }
  1076. /**
  1077. * dp_tx_outstanding_inc - Increment outstanding tx desc values on pdev and soc
  1078. * @vdev: DP pdev handle
  1079. *
  1080. * Return: void
  1081. */
  1082. static inline void
  1083. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1084. {
  1085. struct dp_soc *soc = pdev->soc;
  1086. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1087. qdf_atomic_inc(&soc->num_tx_outstanding);
  1088. dp_update_tx_desc_stats(pdev);
  1089. }
  1090. /**
  1091. * dp_tx_outstanding__dec - Decrement outstanding tx desc values on pdev and soc
  1092. * @vdev: DP pdev handle
  1093. *
  1094. * Return: void
  1095. */
  1096. static inline void
  1097. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1098. {
  1099. struct dp_soc *soc = pdev->soc;
  1100. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1101. qdf_atomic_dec(&soc->num_tx_outstanding);
  1102. dp_update_tx_desc_stats(pdev);
  1103. }
  1104. #else //QCA_TX_LIMIT_CHECK
  1105. static inline bool
  1106. dp_tx_limit_check(struct dp_vdev *vdev)
  1107. {
  1108. return false;
  1109. }
  1110. static inline bool
  1111. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  1112. {
  1113. return false;
  1114. }
  1115. static inline void
  1116. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1117. {
  1118. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1119. dp_update_tx_desc_stats(pdev);
  1120. }
  1121. static inline void
  1122. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1123. {
  1124. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1125. dp_update_tx_desc_stats(pdev);
  1126. }
  1127. #endif //QCA_TX_LIMIT_CHECK
  1128. #endif