dp_tx.h 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 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. #include "dp_ipa.h"
  39. #define DP_INVALID_VDEV_ID 0xFF
  40. #define DP_TX_MAX_NUM_FRAGS 6
  41. /* invalid peer id for reinject*/
  42. #define DP_INVALID_PEER 0XFFFE
  43. void dp_tx_nawds_handler(struct dp_soc *soc, struct dp_vdev *vdev,
  44. struct dp_tx_msdu_info_s *msdu_info,
  45. qdf_nbuf_t nbuf, uint16_t sa_peer_id);
  46. /*
  47. * DP_TX_DESC_FLAG_FRAG flags should always be defined to 0x1
  48. * please do not change this flag's definition
  49. */
  50. #define DP_TX_DESC_FLAG_FRAG 0x1
  51. #define DP_TX_DESC_FLAG_TO_FW 0x2
  52. #define DP_TX_DESC_FLAG_SIMPLE 0x4
  53. #define DP_TX_DESC_FLAG_RAW 0x8
  54. #define DP_TX_DESC_FLAG_MESH 0x10
  55. #define DP_TX_DESC_FLAG_QUEUED_TX 0x20
  56. #define DP_TX_DESC_FLAG_COMPLETED_TX 0x40
  57. #define DP_TX_DESC_FLAG_ME 0x80
  58. #define DP_TX_DESC_FLAG_TDLS_FRAME 0x100
  59. #define DP_TX_DESC_FLAG_ALLOCATED 0x200
  60. #define DP_TX_DESC_FLAG_MESH_MODE 0x400
  61. #define DP_TX_DESC_FLAG_UNMAP_DONE 0x800
  62. #define DP_TX_DESC_FLAG_TX_COMP_ERR 0x1000
  63. #define DP_TX_DESC_FLAG_FLUSH 0x2000
  64. #define DP_TX_DESC_FLAG_TRAFFIC_END_IND 0x4000
  65. #define DP_TX_DESC_FLAG_RMNET 0x8000
  66. /*
  67. * Since the Tx descriptor flag is of only 16-bit and no more bit is free for
  68. * any new flag, therefore for time being overloading PPEDS flag with that of
  69. * FLUSH flag and FLAG_FAST with TDLS which is not enabled for WIN.
  70. */
  71. #define DP_TX_DESC_FLAG_PPEDS 0x2000
  72. #define DP_TX_DESC_FLAG_FAST 0x100
  73. #define DP_TX_EXT_DESC_FLAG_METADATA_VALID 0x1
  74. #define DP_TX_FREE_SINGLE_BUF(soc, buf) \
  75. do { \
  76. qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_TO_DEVICE); \
  77. qdf_nbuf_free(buf); \
  78. } while (0)
  79. #define OCB_HEADER_VERSION 1
  80. #ifdef TX_PER_PDEV_DESC_POOL
  81. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  82. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
  83. #else /* QCA_LL_TX_FLOW_CONTROL_V2 */
  84. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->pdev->pdev_id)
  85. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  86. #define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
  87. #else
  88. #ifdef TX_PER_VDEV_DESC_POOL
  89. #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
  90. #define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
  91. #endif /* TX_PER_VDEV_DESC_POOL */
  92. #endif /* TX_PER_PDEV_DESC_POOL */
  93. #define DP_TX_QUEUE_MASK 0x3
  94. #define MAX_CDP_SEC_TYPE 12
  95. /* number of dwords for htt_tx_msdu_desc_ext2_t */
  96. #define DP_TX_MSDU_INFO_META_DATA_DWORDS 7
  97. #define dp_tx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX, params)
  98. #define dp_tx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX, params)
  99. #define dp_tx_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DP_TX, params)
  100. #define dp_tx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX, params)
  101. #define dp_tx_info(params...) \
  102. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX, ## params)
  103. #define dp_tx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX, params)
  104. #define dp_tx_comp_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX_COMP, params)
  105. #define dp_tx_comp_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX_COMP, params)
  106. #define dp_tx_comp_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX_COMP, params)
  107. #define dp_tx_comp_info(params...) \
  108. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
  109. #define dp_tx_comp_info_rl(params...) \
  110. __QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
  111. #define dp_tx_comp_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX_COMP, params)
  112. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  113. /**
  114. * struct dp_tx_frag_info_s
  115. * @vaddr: hlos virtual address for buffer
  116. * @paddr_lo: physical address lower 32bits
  117. * @paddr_hi: physical address higher bits
  118. * @len: length of the buffer
  119. */
  120. struct dp_tx_frag_info_s {
  121. uint8_t *vaddr;
  122. uint32_t paddr_lo;
  123. uint16_t paddr_hi;
  124. uint16_t len;
  125. };
  126. /**
  127. * struct dp_tx_seg_info_s - Segmentation Descriptor
  128. * @nbuf: NBUF pointer if segment corresponds to separate nbuf
  129. * @frag_cnt: Fragment count in this segment
  130. * @total_len: Total length of segment
  131. * @frags: per-Fragment information
  132. * @next: pointer to next MSDU segment
  133. */
  134. struct dp_tx_seg_info_s {
  135. qdf_nbuf_t nbuf;
  136. uint16_t frag_cnt;
  137. uint16_t total_len;
  138. struct dp_tx_frag_info_s frags[DP_TX_MAX_NUM_FRAGS];
  139. struct dp_tx_seg_info_s *next;
  140. };
  141. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  142. /**
  143. * struct dp_tx_sg_info_s - Scatter Gather Descriptor
  144. * @num_segs: Number of segments (TSO/ME) in the frame
  145. * @total_len: Total length of the frame
  146. * @curr_seg: Points to current segment descriptor to be processed. Chain of
  147. * descriptors for SG frames/multicast-unicast converted packets.
  148. *
  149. * Used for SG (802.3 or Raw) frames and Multicast-Unicast converted frames to
  150. * carry fragmentation information
  151. * Raw Frames will be handed over to driver as an SKB chain with MPDU boundaries
  152. * indicated through flags in SKB CB (first_msdu and last_msdu). This will be
  153. * converted into set of skb sg (nr_frags) structures.
  154. */
  155. struct dp_tx_sg_info_s {
  156. uint32_t num_segs;
  157. uint32_t total_len;
  158. struct dp_tx_seg_info_s *curr_seg;
  159. };
  160. /**
  161. * struct dp_tx_queue - Tx queue
  162. * @desc_pool_id: Descriptor Pool to be used for the tx queue
  163. * @ring_id: TCL descriptor ring ID corresponding to the tx queue
  164. *
  165. * Tx queue contains information of the software (Descriptor pool)
  166. * and hardware resources (TCL ring id) to be used for a particular
  167. * transmit queue (obtained from skb_queue_mapping in case of linux)
  168. */
  169. struct dp_tx_queue {
  170. uint8_t desc_pool_id;
  171. uint8_t ring_id;
  172. };
  173. /**
  174. * struct dp_tx_msdu_info_s - MSDU Descriptor
  175. * @frm_type: Frame type - Regular/TSO/SG/Multicast enhancement
  176. * @tx_queue: Tx queue on which this MSDU should be transmitted
  177. * @num_seg: Number of segments (TSO)
  178. * @tid: TID (override) that is sent from HLOS
  179. * @exception_fw: Duplicate frame to be sent to firmware
  180. * @is_tx_sniffer: Indicates if the packet has to be sniffed
  181. * @u: union of frame information structs
  182. * @u.tso_info: TSO information for TSO frame types
  183. * (chain of the TSO segments, number of segments)
  184. * @u.sg_info: Scatter Gather information for non-TSO SG frames
  185. * @meta_data: Mesh meta header information
  186. * @ppdu_cookie: 16-bit ppdu_cookie that has to be replayed back in completions
  187. * @gsn: global sequence for reinjected mcast packets
  188. * @vdev_id : vdev_id for reinjected mcast packets
  189. * @skip_hp_update : Skip HP update for TSO segments and update in last segment
  190. * @buf_len:
  191. * @payload_addr:
  192. *
  193. * This structure holds the complete MSDU information needed to program the
  194. * Hardware TCL and MSDU extension descriptors for different frame types
  195. *
  196. */
  197. struct dp_tx_msdu_info_s {
  198. enum dp_tx_frm_type frm_type;
  199. struct dp_tx_queue tx_queue;
  200. uint32_t num_seg;
  201. uint8_t tid;
  202. uint8_t exception_fw;
  203. uint8_t is_tx_sniffer;
  204. union {
  205. struct qdf_tso_info_t tso_info;
  206. struct dp_tx_sg_info_s sg_info;
  207. } u;
  208. uint32_t meta_data[DP_TX_MSDU_INFO_META_DATA_DWORDS];
  209. uint16_t ppdu_cookie;
  210. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  211. #ifdef WLAN_MCAST_MLO
  212. uint16_t gsn;
  213. uint8_t vdev_id;
  214. #endif
  215. #endif
  216. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  217. uint8_t skip_hp_update;
  218. #endif
  219. #ifdef QCA_DP_TX_RMNET_OPTIMIZATION
  220. uint16_t buf_len;
  221. uint8_t *payload_addr;
  222. #endif
  223. };
  224. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  225. /**
  226. * dp_tx_deinit_pair_by_index() - Deinit TX rings based on index
  227. * @soc: core txrx context
  228. * @index: index of ring to deinit
  229. *
  230. * Deinit 1 TCL and 1 WBM2SW release ring on as needed basis using
  231. * index of the respective TCL/WBM2SW release in soc structure.
  232. * For example, if the index is 2 then &soc->tcl_data_ring[2]
  233. * and &soc->tx_comp_ring[2] will be deinitialized.
  234. *
  235. * Return: none
  236. */
  237. void dp_tx_deinit_pair_by_index(struct dp_soc *soc, int index);
  238. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  239. /**
  240. * dp_tx_comp_process_desc_list() - Tx complete software descriptor handler
  241. * @soc: core txrx main context
  242. * @comp_head: software descriptor head pointer
  243. * @ring_id: ring number
  244. *
  245. * This function will process batch of descriptors reaped by dp_tx_comp_handler
  246. * and release the software descriptors after processing is complete
  247. *
  248. * Return: none
  249. */
  250. void
  251. dp_tx_comp_process_desc_list(struct dp_soc *soc,
  252. struct dp_tx_desc_s *comp_head, uint8_t ring_id);
  253. /**
  254. * dp_tx_comp_free_buf() - Free nbuf associated with the Tx Descriptor
  255. * @soc: Soc handle
  256. * @desc: software Tx descriptor to be processed
  257. * @delayed_free: defer freeing of nbuf
  258. *
  259. * Return: nbuf to be freed later
  260. */
  261. qdf_nbuf_t dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc,
  262. bool delayed_free);
  263. /**
  264. * dp_tx_desc_release() - Release Tx Descriptor
  265. * @tx_desc: Tx Descriptor
  266. * @desc_pool_id: Descriptor Pool ID
  267. *
  268. * Deallocate all resources attached to Tx descriptor and free the Tx
  269. * descriptor.
  270. *
  271. * Return:
  272. */
  273. void dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id);
  274. /**
  275. * dp_tx_compute_delay() - Compute and fill in all timestamps
  276. * to pass in correct fields
  277. * @vdev: pdev handle
  278. * @tx_desc: tx descriptor
  279. * @tid: tid value
  280. * @ring_id: TCL or WBM ring number for transmit path
  281. *
  282. * Return: none
  283. */
  284. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  285. uint8_t tid, uint8_t ring_id);
  286. /**
  287. * dp_tx_comp_process_tx_status() - Parse and Dump Tx completion status info
  288. * @soc: DP soc handle
  289. * @tx_desc: software descriptor head pointer
  290. * @ts: Tx completion status
  291. * @txrx_peer: txrx peer handle
  292. * @ring_id: ring number
  293. *
  294. * Return: none
  295. */
  296. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  297. struct dp_tx_desc_s *tx_desc,
  298. struct hal_tx_completion_status *ts,
  299. struct dp_txrx_peer *txrx_peer,
  300. uint8_t ring_id);
  301. /**
  302. * dp_tx_comp_process_desc() - Process tx descriptor and free associated nbuf
  303. * @soc: DP Soc handle
  304. * @desc: software Tx descriptor
  305. * @ts: Tx completion status from HAL/HTT descriptor
  306. * @txrx_peer: DP peer context
  307. *
  308. * Return: none
  309. */
  310. void dp_tx_comp_process_desc(struct dp_soc *soc,
  311. struct dp_tx_desc_s *desc,
  312. struct hal_tx_completion_status *ts,
  313. struct dp_txrx_peer *txrx_peer);
  314. /**
  315. * dp_tx_reinject_handler() - Tx Reinject Handler
  316. * @soc: datapath soc handle
  317. * @vdev: datapath vdev handle
  318. * @tx_desc: software descriptor head pointer
  319. * @status: Tx completion status from HTT descriptor
  320. * @reinject_reason: reinject reason from HTT descriptor
  321. *
  322. * This function reinjects frames back to Target.
  323. * Todo - Host queue needs to be added
  324. *
  325. * Return: none
  326. */
  327. void dp_tx_reinject_handler(struct dp_soc *soc,
  328. struct dp_vdev *vdev,
  329. struct dp_tx_desc_s *tx_desc,
  330. uint8_t *status,
  331. uint8_t reinject_reason);
  332. /**
  333. * dp_tx_inspect_handler() - Tx Inspect Handler
  334. * @soc: datapath soc handle
  335. * @vdev: datapath vdev handle
  336. * @tx_desc: software descriptor head pointer
  337. * @status: Tx completion status from HTT descriptor
  338. *
  339. * Handles Tx frames sent back to Host for inspection
  340. * (ProxyARP)
  341. *
  342. * Return: none
  343. */
  344. void dp_tx_inspect_handler(struct dp_soc *soc,
  345. struct dp_vdev *vdev,
  346. struct dp_tx_desc_s *tx_desc,
  347. uint8_t *status);
  348. /**
  349. * dp_tx_update_peer_basic_stats() - Update peer basic stats
  350. * @txrx_peer: Datapath txrx_peer handle
  351. * @length: Length of the packet
  352. * @tx_status: Tx status from TQM/FW
  353. * @update: enhanced flag value present in dp_pdev
  354. *
  355. * Return: none
  356. */
  357. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  358. uint32_t length, uint8_t tx_status,
  359. bool update);
  360. #ifdef DP_UMAC_HW_RESET_SUPPORT
  361. /**
  362. * dp_tx_drop() - Drop the frame on a given VAP
  363. * @soc: DP soc handle
  364. * @vdev_id: id of DP vdev handle
  365. * @nbuf: skb
  366. *
  367. * Drop all the incoming packets
  368. *
  369. * Return: nbuf
  370. */
  371. qdf_nbuf_t dp_tx_drop(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
  372. /**
  373. * dp_tx_exc_drop() - Drop the frame on a given VAP
  374. * @soc_hdl: DP soc handle
  375. * @vdev_id: id of DP vdev handle
  376. * @nbuf: skb
  377. * @tx_exc_metadata: Handle that holds exception path meta data
  378. *
  379. * Drop all the incoming packets
  380. *
  381. * Return: nbuf
  382. */
  383. qdf_nbuf_t dp_tx_exc_drop(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  384. qdf_nbuf_t nbuf,
  385. struct cdp_tx_exception_metadata *tx_exc_metadata);
  386. #endif
  387. #ifdef WLAN_SUPPORT_PPEDS
  388. qdf_nbuf_t
  389. dp_ppeds_tx_desc_free(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc);
  390. #else
  391. static inline qdf_nbuf_t
  392. dp_ppeds_tx_desc_free(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  393. {
  394. return NULL;
  395. }
  396. #endif
  397. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  398. /**
  399. * dp_tso_soc_attach() - TSO Attach handler
  400. * @txrx_soc: Opaque Dp handle
  401. *
  402. * Reserve TSO descriptor buffers
  403. *
  404. * Return: QDF_STATUS_E_FAILURE on failure or
  405. * QDF_STATUS_SUCCESS on success
  406. */
  407. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc);
  408. /**
  409. * dp_tso_soc_detach() - TSO Detach handler
  410. * @txrx_soc: Opaque Dp handle
  411. *
  412. * Deallocate TSO descriptor buffers
  413. *
  414. * Return: QDF_STATUS_E_FAILURE on failure or
  415. * QDF_STATUS_SUCCESS on success
  416. */
  417. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc);
  418. /**
  419. * dp_tx_send() - Transmit a frame on a given VAP
  420. * @soc_hdl: DP soc handle
  421. * @vdev_id: id of DP vdev handle
  422. * @nbuf: skb
  423. *
  424. * Entry point for Core Tx layer (DP_TX) invoked from
  425. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  426. * cases
  427. *
  428. * Return: NULL on success,
  429. * nbuf when it fails to send
  430. */
  431. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  432. qdf_nbuf_t nbuf);
  433. /**
  434. * dp_tx_send_vdev_id_check() - Transmit a frame on a given VAP in special
  435. * case to avoid check in per-packet path.
  436. * @soc_hdl: DP soc handle
  437. * @vdev_id: id of DP vdev handle
  438. * @nbuf: skb
  439. *
  440. * Entry point for Core Tx layer (DP_TX) invoked from
  441. * hard_start_xmit in OSIF/HDD to transmit packet through dp_tx_send
  442. * with special condition to avoid per pkt check in dp_tx_send
  443. *
  444. * Return: NULL on success,
  445. * nbuf when it fails to send
  446. */
  447. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc_hdl,
  448. uint8_t vdev_id, qdf_nbuf_t nbuf);
  449. /**
  450. * dp_tx_send_exception() - Transmit a frame on a given VAP in exception path
  451. * @soc_hdl: DP soc handle
  452. * @vdev_id: id of DP vdev handle
  453. * @nbuf: skb
  454. * @tx_exc_metadata: Handle that holds exception path meta data
  455. *
  456. * Entry point for Core Tx layer (DP_TX) invoked from
  457. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  458. *
  459. * Return: NULL on success,
  460. * nbuf when it fails to send
  461. */
  462. qdf_nbuf_t
  463. dp_tx_send_exception(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  464. qdf_nbuf_t nbuf,
  465. struct cdp_tx_exception_metadata *tx_exc_metadata);
  466. /**
  467. * dp_tx_send_exception_vdev_id_check() - Transmit a frame on a given VAP
  468. * in exception path in special case to avoid regular exception path chk.
  469. * @soc_hdl: DP soc handle
  470. * @vdev_id: id of DP vdev handle
  471. * @nbuf: skb
  472. * @tx_exc_metadata: Handle that holds exception path meta data
  473. *
  474. * Entry point for Core Tx layer (DP_TX) invoked from
  475. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  476. *
  477. * Return: NULL on success,
  478. * nbuf when it fails to send
  479. */
  480. qdf_nbuf_t
  481. dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc_hdl,
  482. uint8_t vdev_id, qdf_nbuf_t nbuf,
  483. struct cdp_tx_exception_metadata *tx_exc_metadata);
  484. /**
  485. * dp_tx_send_mesh() - Transmit mesh frame on a given VAP
  486. * @soc_hdl: DP soc handle
  487. * @vdev_id: DP vdev handle
  488. * @nbuf: skb
  489. *
  490. * Entry point for Core Tx layer (DP_TX) invoked from
  491. * hard_start_xmit in OSIF/HDD
  492. *
  493. * Return: NULL on success,
  494. * nbuf when it fails to send
  495. */
  496. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  497. qdf_nbuf_t nbuf);
  498. /**
  499. * dp_tx_send_msdu_single() - Setup descriptor and enqueue single MSDU to TCL
  500. * @vdev: DP vdev handle
  501. * @nbuf: skb
  502. * @msdu_info: MSDU information
  503. * @peer_id: peer_id of the peer in case of NAWDS frames
  504. * @tx_exc_metadata: Handle that holds exception path metadata
  505. *
  506. * Return: NULL on success,
  507. * nbuf when it fails to send
  508. */
  509. qdf_nbuf_t
  510. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  511. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  512. struct cdp_tx_exception_metadata *tx_exc_metadata);
  513. /**
  514. * dp_tx_mcast_enhance() - Multicast enhancement on TX
  515. * @vdev: DP vdev handle
  516. * @nbuf: network buffer to be transmitted
  517. *
  518. * Return: true on success
  519. * false on failure
  520. */
  521. bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  522. /**
  523. * dp_tx_send_msdu_multiple() - Enqueue multiple MSDUs
  524. * @vdev: DP vdev handle
  525. * @nbuf: skb
  526. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  527. *
  528. * Prepare descriptors for multiple MSDUs (TSO segments) and enqueue to TCL
  529. *
  530. * Return: NULL on success,
  531. * nbuf when it fails to send
  532. */
  533. #if QDF_LOCK_STATS
  534. noinline qdf_nbuf_t
  535. dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  536. struct dp_tx_msdu_info_s *msdu_info);
  537. #else
  538. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  539. struct dp_tx_msdu_info_s *msdu_info);
  540. #endif
  541. #ifdef FEATURE_WLAN_TDLS
  542. /**
  543. * dp_tx_non_std() - Allow the control-path SW to send data frames
  544. * @soc_hdl: Datapath soc handle
  545. * @vdev_id: id of vdev
  546. * @tx_spec: what non-standard handling to apply to the tx data frames
  547. * @msdu_list: NULL-terminated list of tx MSDUs
  548. *
  549. * Return: NULL on success,
  550. * nbuf when it fails to send
  551. */
  552. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  553. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
  554. #endif
  555. /**
  556. * dp_tx_frame_is_drop() - checks if the packet is loopback
  557. * @vdev: DP vdev handle
  558. * @srcmac: source MAC address
  559. * @dstmac: destination MAC address
  560. *
  561. * Return: 1 if frame needs to be dropped else 0
  562. */
  563. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac);
  564. #ifndef WLAN_SOFTUMAC_SUPPORT
  565. /**
  566. * dp_tx_comp_handler() - Tx completion handler
  567. * @int_ctx: pointer to DP interrupt context
  568. * @soc: core txrx main context
  569. * @hal_srng: Opaque HAL SRNG pointer
  570. * @ring_id: completion ring id
  571. * @quota: No. of packets/descriptors that can be serviced in one loop
  572. *
  573. * This function will collect hardware release ring element contents and
  574. * handle descriptor contents. Based on contents, free packet or handle error
  575. * conditions
  576. *
  577. * Return: Number of TX completions processed
  578. */
  579. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  580. hal_ring_handle_t hal_srng, uint8_t ring_id,
  581. uint32_t quota);
  582. #endif
  583. void
  584. dp_tx_comp_process_desc_list(struct dp_soc *soc,
  585. struct dp_tx_desc_s *comp_head, uint8_t ring_id);
  586. QDF_STATUS
  587. dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  588. QDF_STATUS
  589. dp_tx_prepare_send_igmp_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  590. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  591. #if defined(QCA_HOST_MODE_WIFI_DISABLED) || !defined(ATH_SUPPORT_IQUE)
  592. static inline void dp_tx_me_exit(struct dp_pdev *pdev)
  593. {
  594. return;
  595. }
  596. #endif
  597. /**
  598. * dp_tx_pdev_init() - dp tx pdev init
  599. * @pdev: physical device instance
  600. *
  601. * Return: QDF_STATUS_SUCCESS: success
  602. * QDF_STATUS_E_RESOURCES: Error return
  603. */
  604. static inline QDF_STATUS dp_tx_pdev_init(struct dp_pdev *pdev)
  605. {
  606. struct dp_soc *soc = pdev->soc;
  607. /* Initialize Flow control counters */
  608. qdf_atomic_init(&pdev->num_tx_outstanding);
  609. pdev->tx_descs_max = 0;
  610. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  611. /* Initialize descriptors in TCL Ring */
  612. hal_tx_init_data_ring(soc->hal_soc,
  613. soc->tcl_data_ring[pdev->pdev_id].hal_srng);
  614. }
  615. return QDF_STATUS_SUCCESS;
  616. }
  617. /**
  618. * dp_tx_prefetch_hw_sw_nbuf_desc() - function to prefetch HW and SW desc
  619. * @soc: Handle to HAL Soc structure
  620. * @hal_soc: HAL SOC handle
  621. * @num_avail_for_reap: descriptors available for reap
  622. * @hal_ring_hdl: ring pointer
  623. * @last_prefetched_hw_desc: pointer to the last prefetched HW descriptor
  624. * @last_prefetched_sw_desc: pointer to last prefetch SW desc
  625. *
  626. * Return: None
  627. */
  628. #ifdef QCA_DP_TX_HW_SW_NBUF_DESC_PREFETCH
  629. static inline
  630. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  631. hal_soc_handle_t hal_soc,
  632. uint32_t num_avail_for_reap,
  633. hal_ring_handle_t hal_ring_hdl,
  634. void **last_prefetched_hw_desc,
  635. struct dp_tx_desc_s
  636. **last_prefetched_sw_desc)
  637. {
  638. if (*last_prefetched_sw_desc) {
  639. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf);
  640. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf + 64);
  641. }
  642. if (num_avail_for_reap && *last_prefetched_hw_desc) {
  643. soc->arch_ops.tx_comp_get_params_from_hal_desc(soc,
  644. *last_prefetched_hw_desc,
  645. last_prefetched_sw_desc);
  646. if ((uintptr_t)*last_prefetched_hw_desc & 0x3f)
  647. *last_prefetched_hw_desc =
  648. hal_srng_dst_prefetch_next_cached_desc(
  649. hal_soc,
  650. hal_ring_hdl,
  651. (uint8_t *)*last_prefetched_hw_desc);
  652. else
  653. *last_prefetched_hw_desc =
  654. hal_srng_dst_get_next_32_byte_desc(hal_soc,
  655. hal_ring_hdl,
  656. (uint8_t *)*last_prefetched_hw_desc);
  657. }
  658. }
  659. #else
  660. static inline
  661. void dp_tx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  662. hal_soc_handle_t hal_soc,
  663. uint32_t num_avail_for_reap,
  664. hal_ring_handle_t hal_ring_hdl,
  665. void **last_prefetched_hw_desc,
  666. struct dp_tx_desc_s
  667. **last_prefetched_sw_desc)
  668. {
  669. }
  670. #endif
  671. #ifndef FEATURE_WDS
  672. static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
  673. {
  674. return;
  675. }
  676. #endif
  677. #ifndef QCA_MULTIPASS_SUPPORT
  678. static inline
  679. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  680. qdf_nbuf_t nbuf,
  681. struct dp_tx_msdu_info_s *msdu_info)
  682. {
  683. return true;
  684. }
  685. static inline
  686. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev)
  687. {
  688. }
  689. #else
  690. /**
  691. * dp_tx_multipass_process() - Process vlan frames in tx path
  692. * @soc: dp soc handle
  693. * @vdev: DP vdev handle
  694. * @nbuf: skb
  695. * @msdu_info: msdu descriptor
  696. *
  697. * Return: status whether frame needs to be dropped or transmitted
  698. */
  699. bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
  700. qdf_nbuf_t nbuf,
  701. struct dp_tx_msdu_info_s *msdu_info);
  702. /**
  703. * dp_tx_vdev_multipass_deinit() - set vlan map for vdev
  704. * @vdev: pointer to vdev
  705. *
  706. * return: void
  707. */
  708. void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev);
  709. /**
  710. * dp_tx_remove_vlan_tag() - Remove 4 bytes of vlan tag
  711. * @vdev: DP vdev handle
  712. * @nbuf: network buffer
  713. *
  714. * Return: void
  715. */
  716. void dp_tx_remove_vlan_tag(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  717. /**
  718. * dp_tx_add_groupkey_metadata() - Add group key in metadata
  719. * @vdev: DP vdev handle
  720. * @msdu_info: MSDU info to be setup in MSDU descriptor
  721. * @group_key: Group key index programmed in metadata
  722. *
  723. * Return: void
  724. */
  725. void dp_tx_add_groupkey_metadata(struct dp_vdev *vdev,
  726. struct dp_tx_msdu_info_s *msdu_info,
  727. uint16_t group_key);
  728. #endif
  729. /**
  730. * dp_tx_hw_to_qdf()- convert hw status to qdf status
  731. * @status: hw status
  732. *
  733. * Return: qdf tx rx status
  734. */
  735. static inline enum qdf_dp_tx_rx_status dp_tx_hw_to_qdf(uint16_t status)
  736. {
  737. switch (status) {
  738. case HAL_TX_TQM_RR_FRAME_ACKED:
  739. return QDF_TX_RX_STATUS_OK;
  740. case HAL_TX_TQM_RR_REM_CMD_TX:
  741. return QDF_TX_RX_STATUS_NO_ACK;
  742. case HAL_TX_TQM_RR_REM_CMD_REM:
  743. case HAL_TX_TQM_RR_REM_CMD_NOTX:
  744. case HAL_TX_TQM_RR_REM_CMD_AGED:
  745. return QDF_TX_RX_STATUS_FW_DISCARD;
  746. default:
  747. return QDF_TX_RX_STATUS_DEFAULT;
  748. }
  749. }
  750. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  751. /**
  752. * dp_tx_get_queue() - Returns Tx queue IDs to be used for this Tx frame
  753. * @vdev: DP Virtual device handle
  754. * @nbuf: Buffer pointer
  755. * @queue: queue ids container for nbuf
  756. *
  757. * TX packet queue has 2 instances, software descriptors id and dma ring id
  758. * Based on tx feature and hardware configuration queue id combination could be
  759. * different.
  760. * For example -
  761. * With XPS enabled,all TX descriptor pools and dma ring are assigned per cpu id
  762. * With no XPS,lock based resource protection, Descriptor pool ids are different
  763. * for each vdev, dma ring id will be same as single pdev id
  764. *
  765. * Return: None
  766. */
  767. #ifdef QCA_OL_TX_MULTIQ_SUPPORT
  768. #if defined(IPA_OFFLOAD) && defined(QCA_IPA_LL_TX_FLOW_CONTROL)
  769. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  770. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  771. {
  772. queue->ring_id = qdf_get_cpu();
  773. if (vdev->pdev->soc->wlan_cfg_ctx->ipa_enabled)
  774. if (queue->ring_id == IPA_TCL_DATA_RING_IDX)
  775. queue->ring_id = 0;
  776. queue->desc_pool_id = queue->ring_id;
  777. }
  778. #else
  779. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  780. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  781. {
  782. queue->ring_id = qdf_get_cpu();
  783. queue->desc_pool_id = queue->ring_id;
  784. }
  785. #endif
  786. /**
  787. * dp_tx_get_hal_ring_hdl() - Get the hal_tx_ring_hdl for data transmission
  788. * @soc: DP soc structure pointer
  789. * @ring_id: Transmit Queue/ring_id to be used when XPS is enabled
  790. *
  791. * Return: HAL ring handle
  792. */
  793. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  794. uint8_t ring_id)
  795. {
  796. if (ring_id == soc->num_tcl_data_rings)
  797. return soc->tcl_cmd_credit_ring.hal_srng;
  798. return soc->tcl_data_ring[ring_id].hal_srng;
  799. }
  800. #else /* QCA_OL_TX_MULTIQ_SUPPORT */
  801. #ifdef TX_MULTI_TCL
  802. #ifdef IPA_OFFLOAD
  803. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  804. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  805. {
  806. /* get flow id */
  807. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  808. if (vdev->pdev->soc->wlan_cfg_ctx->ipa_enabled)
  809. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  810. else
  811. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  812. vdev->pdev->soc->num_tcl_data_rings);
  813. }
  814. #else
  815. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  816. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  817. {
  818. /* get flow id */
  819. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  820. queue->ring_id = (qdf_nbuf_get_queue_mapping(nbuf) %
  821. vdev->pdev->soc->num_tcl_data_rings);
  822. }
  823. #endif
  824. #else
  825. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  826. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  827. {
  828. /* get flow id */
  829. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  830. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  831. }
  832. #endif
  833. static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
  834. uint8_t ring_id)
  835. {
  836. return soc->tcl_data_ring[ring_id].hal_srng;
  837. }
  838. #endif
  839. #ifdef QCA_OL_TX_LOCK_LESS_ACCESS
  840. /**
  841. * dp_tx_hal_ring_access_start() - hal_tx_ring access for data transmission
  842. * @soc: DP soc structure pointer
  843. * @hal_ring_hdl: HAL ring handle
  844. *
  845. * Return: None
  846. */
  847. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  848. hal_ring_handle_t hal_ring_hdl)
  849. {
  850. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  851. }
  852. /**
  853. * dp_tx_hal_ring_access_end() - hal_tx_ring access for data transmission
  854. * @soc: DP soc structure pointer
  855. * @hal_ring_hdl: HAL ring handle
  856. *
  857. * Return: None
  858. */
  859. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  860. hal_ring_handle_t hal_ring_hdl)
  861. {
  862. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  863. }
  864. /**
  865. * dp_tx_hal_ring_access_end_reap() - hal_tx_ring access for data transmission
  866. * @soc: DP soc structure pointer
  867. * @hal_ring_hdl: HAL ring handle
  868. *
  869. * Return: None
  870. */
  871. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  872. hal_ring_handle_t
  873. hal_ring_hdl)
  874. {
  875. }
  876. #else
  877. static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
  878. hal_ring_handle_t hal_ring_hdl)
  879. {
  880. return hal_srng_access_start(soc->hal_soc, hal_ring_hdl);
  881. }
  882. static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
  883. hal_ring_handle_t hal_ring_hdl)
  884. {
  885. hal_srng_access_end(soc->hal_soc, hal_ring_hdl);
  886. }
  887. static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
  888. hal_ring_handle_t
  889. hal_ring_hdl)
  890. {
  891. hal_srng_access_end_reap(soc->hal_soc, hal_ring_hdl);
  892. }
  893. #endif
  894. #ifdef ATH_TX_PRI_OVERRIDE
  895. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
  896. ((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
  897. #else
  898. #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
  899. #endif
  900. /* TODO TX_FEATURE_NOT_YET */
  901. static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
  902. {
  903. return;
  904. }
  905. /* TODO TX_FEATURE_NOT_YET */
  906. /**
  907. * dp_tx_desc_flush() - release resources associated
  908. * to TX Desc
  909. *
  910. * @pdev: Handle to DP pdev structure
  911. * @vdev: virtual device instance
  912. * NULL: no specific Vdev is required and check all allcated TX desc
  913. * on this pdev.
  914. * Non-NULL: only check the allocated TX Desc associated to this Vdev.
  915. *
  916. * @force_free:
  917. * true: flush the TX desc.
  918. * false: only reset the Vdev in each allocated TX desc
  919. * that associated to current Vdev.
  920. *
  921. * This function will go through the TX desc pool to flush
  922. * the outstanding TX data or reset Vdev to NULL in associated TX
  923. * Desc.
  924. */
  925. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  926. bool force_free);
  927. /**
  928. * dp_tx_vdev_attach() - attach vdev to dp tx
  929. * @vdev: virtual device instance
  930. *
  931. * Return: QDF_STATUS_SUCCESS: success
  932. * QDF_STATUS_E_RESOURCES: Error return
  933. */
  934. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
  935. /**
  936. * dp_tx_vdev_detach() - detach vdev from dp tx
  937. * @vdev: virtual device instance
  938. *
  939. * Return: QDF_STATUS_SUCCESS: success
  940. * QDF_STATUS_E_RESOURCES: Error return
  941. */
  942. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
  943. /**
  944. * dp_tx_vdev_update_search_flags() - Update vdev flags as per opmode
  945. * @vdev: virtual device instance
  946. *
  947. * Return: void
  948. *
  949. */
  950. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
  951. /**
  952. * dp_soc_tx_desc_sw_pools_alloc() - Allocate tx descriptor pool memory
  953. * @soc: core txrx main context
  954. *
  955. * This function allocates memory for following descriptor pools
  956. * 1. regular sw tx descriptor pools (static pools)
  957. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  958. * 3. TSO descriptor pools
  959. *
  960. * Return: QDF_STATUS_SUCCESS: success
  961. * QDF_STATUS_E_RESOURCES: Error return
  962. */
  963. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc);
  964. /**
  965. * dp_soc_tx_desc_sw_pools_init() - Initialise TX descriptor pools
  966. * @soc: core txrx main context
  967. *
  968. * This function initializes the following TX descriptor pools
  969. * 1. regular sw tx descriptor pools (static pools)
  970. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  971. * 3. TSO descriptor pools
  972. *
  973. * Return: QDF_STATUS_SUCCESS: success
  974. * QDF_STATUS_E_RESOURCES: Error return
  975. */
  976. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc);
  977. /**
  978. * dp_soc_tx_desc_sw_pools_free() - free all TX descriptors
  979. * @soc: core txrx main context
  980. *
  981. * This function frees all tx related descriptors as below
  982. * 1. Regular TX descriptors (static pools)
  983. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  984. * 3. TSO descriptors
  985. *
  986. */
  987. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc);
  988. /**
  989. * dp_soc_tx_desc_sw_pools_deinit() - de-initialize all TX descriptors
  990. * @soc: core txrx main context
  991. *
  992. * This function de-initializes all tx related descriptors as below
  993. * 1. Regular TX descriptors (static pools)
  994. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  995. * 3. TSO descriptors
  996. *
  997. */
  998. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc);
  999. #ifndef WLAN_SOFTUMAC_SUPPORT
  1000. /**
  1001. * dp_handle_wbm_internal_error() - handles wbm_internal_error case
  1002. * @soc: core DP main context
  1003. * @hal_desc: hal descriptor
  1004. * @buf_type: indicates if the buffer is of type link disc or msdu
  1005. *
  1006. * wbm_internal_error is seen in following scenarios :
  1007. *
  1008. * 1. Null pointers detected in WBM_RELEASE_RING descriptors
  1009. * 2. Null pointers detected during delinking process
  1010. *
  1011. * Some null pointer cases:
  1012. *
  1013. * a. MSDU buffer pointer is NULL
  1014. * b. Next_MSDU_Link_Desc pointer is NULL, with no last msdu flag
  1015. * c. MSDU buffer pointer is NULL or Next_Link_Desc pointer is NULL
  1016. *
  1017. * Return: None
  1018. */
  1019. void
  1020. dp_handle_wbm_internal_error(struct dp_soc *soc, void *hal_desc,
  1021. uint32_t buf_type);
  1022. #endif
  1023. #else /* QCA_HOST_MODE_WIFI_DISABLED */
  1024. static inline
  1025. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  1026. {
  1027. return QDF_STATUS_SUCCESS;
  1028. }
  1029. static inline
  1030. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  1031. {
  1032. return QDF_STATUS_SUCCESS;
  1033. }
  1034. static inline void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  1035. {
  1036. }
  1037. static inline void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  1038. {
  1039. }
  1040. static inline
  1041. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  1042. bool force_free)
  1043. {
  1044. }
  1045. static inline QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  1046. {
  1047. return QDF_STATUS_SUCCESS;
  1048. }
  1049. static inline QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  1050. {
  1051. return QDF_STATUS_SUCCESS;
  1052. }
  1053. static inline void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  1054. {
  1055. }
  1056. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1057. #if defined(QCA_SUPPORT_LATENCY_CAPTURE) || \
  1058. defined(QCA_TX_CAPTURE_SUPPORT) || \
  1059. defined(QCA_MCOPY_SUPPORT)
  1060. #ifdef FEATURE_PERPKT_INFO
  1061. /**
  1062. * dp_get_completion_indication_for_stack() - send completion to stack
  1063. * @soc : dp_soc handle
  1064. * @pdev: dp_pdev handle
  1065. * @txrx_peer: dp peer handle
  1066. * @ts: transmit completion status structure
  1067. * @netbuf: Buffer pointer for free
  1068. * @time_latency:
  1069. *
  1070. * This function is used for indication whether buffer needs to be
  1071. * sent to stack for freeing or not
  1072. *
  1073. * Return: QDF_STATUS
  1074. */
  1075. QDF_STATUS
  1076. dp_get_completion_indication_for_stack(struct dp_soc *soc,
  1077. struct dp_pdev *pdev,
  1078. struct dp_txrx_peer *txrx_peer,
  1079. struct hal_tx_completion_status *ts,
  1080. qdf_nbuf_t netbuf,
  1081. uint64_t time_latency);
  1082. /**
  1083. * dp_send_completion_to_stack() - send completion to stack
  1084. * @soc : dp_soc handle
  1085. * @pdev: dp_pdev handle
  1086. * @peer_id: peer_id of the peer for which completion came
  1087. * @ppdu_id: ppdu_id
  1088. * @netbuf: Buffer pointer for free
  1089. *
  1090. * This function is used to send completion to stack
  1091. * to free buffer
  1092. *
  1093. * Return: QDF_STATUS
  1094. */
  1095. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  1096. uint16_t peer_id, uint32_t ppdu_id,
  1097. qdf_nbuf_t netbuf);
  1098. #endif
  1099. #else
  1100. static inline
  1101. QDF_STATUS dp_get_completion_indication_for_stack(struct dp_soc *soc,
  1102. struct dp_pdev *pdev,
  1103. struct dp_txrx_peer *peer,
  1104. struct hal_tx_completion_status *ts,
  1105. qdf_nbuf_t netbuf,
  1106. uint64_t time_latency)
  1107. {
  1108. return QDF_STATUS_E_NOSUPPORT;
  1109. }
  1110. static inline
  1111. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  1112. uint16_t peer_id, uint32_t ppdu_id,
  1113. qdf_nbuf_t netbuf)
  1114. {
  1115. }
  1116. #endif
  1117. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  1118. /**
  1119. * dp_send_completion_to_pkt_capture() - send tx completion to packet capture
  1120. * @soc: dp_soc handle
  1121. * @desc: Tx Descriptor
  1122. * @ts: HAL Tx completion descriptor contents
  1123. *
  1124. * This function is used to send tx completion to packet capture
  1125. */
  1126. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  1127. struct dp_tx_desc_s *desc,
  1128. struct hal_tx_completion_status *ts);
  1129. #else
  1130. static inline void
  1131. dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  1132. struct dp_tx_desc_s *desc,
  1133. struct hal_tx_completion_status *ts)
  1134. {
  1135. }
  1136. #endif
  1137. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1138. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  1139. /**
  1140. * dp_tx_update_stats() - Update soc level tx stats
  1141. * @soc: DP soc handle
  1142. * @tx_desc: TX descriptor reference
  1143. * @ring_id: TCL ring id
  1144. *
  1145. * Return: none
  1146. */
  1147. void dp_tx_update_stats(struct dp_soc *soc,
  1148. struct dp_tx_desc_s *tx_desc,
  1149. uint8_t ring_id);
  1150. /**
  1151. * dp_tx_attempt_coalescing() - Check and attempt TCL register write coalescing
  1152. * @soc: Datapath soc handle
  1153. * @vdev: DP vdev handle
  1154. * @tx_desc: tx packet descriptor
  1155. * @tid: TID for pkt transmission
  1156. * @msdu_info: MSDU info of tx packet
  1157. * @ring_id: TCL ring id
  1158. *
  1159. * Return: 1, if coalescing is to be done
  1160. * 0, if coalescing is not to be done
  1161. */
  1162. int
  1163. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  1164. struct dp_tx_desc_s *tx_desc,
  1165. uint8_t tid,
  1166. struct dp_tx_msdu_info_s *msdu_info,
  1167. uint8_t ring_id);
  1168. /**
  1169. * dp_tx_ring_access_end() - HAL ring access end for data transmission
  1170. * @soc: Datapath soc handle
  1171. * @hal_ring_hdl: HAL ring handle
  1172. * @coalesce: Coalesce the current write or not
  1173. *
  1174. * Return: none
  1175. */
  1176. void
  1177. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  1178. int coalesce);
  1179. #else
  1180. /**
  1181. * dp_tx_update_stats() - Update soc level tx stats
  1182. * @soc: DP soc handle
  1183. * @tx_desc: TX descriptor reference
  1184. * @ring_id: TCL ring id
  1185. *
  1186. * Return: none
  1187. */
  1188. static inline void dp_tx_update_stats(struct dp_soc *soc,
  1189. struct dp_tx_desc_s *tx_desc,
  1190. uint8_t ring_id){ }
  1191. static inline void
  1192. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  1193. int coalesce)
  1194. {
  1195. dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
  1196. }
  1197. static inline int
  1198. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  1199. struct dp_tx_desc_s *tx_desc,
  1200. uint8_t tid,
  1201. struct dp_tx_msdu_info_s *msdu_info,
  1202. uint8_t ring_id)
  1203. {
  1204. return 0;
  1205. }
  1206. #endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */
  1207. #ifdef FEATURE_RUNTIME_PM
  1208. /**
  1209. * dp_set_rtpm_tput_policy_requirement() - Update RTPM throughput policy
  1210. * @soc_hdl: DP soc handle
  1211. * @is_high_tput: flag to indicate whether throughput is high
  1212. *
  1213. * Return: none
  1214. */
  1215. static inline
  1216. void dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  1217. bool is_high_tput)
  1218. {
  1219. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  1220. qdf_atomic_set(&soc->rtpm_high_tput_flag, is_high_tput);
  1221. }
  1222. /**
  1223. * dp_tx_ring_access_end_wrapper() - Wrapper for ring access end
  1224. * @soc: Datapath soc handle
  1225. * @hal_ring_hdl: HAL ring handle
  1226. * @coalesce: Coalesce the current write or not
  1227. *
  1228. * Feature-specific wrapper for HAL ring access end for data
  1229. * transmission
  1230. *
  1231. * Return: none
  1232. */
  1233. void
  1234. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1235. hal_ring_handle_t hal_ring_hdl,
  1236. int coalesce);
  1237. #else
  1238. #ifdef DP_POWER_SAVE
  1239. void
  1240. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1241. hal_ring_handle_t hal_ring_hdl,
  1242. int coalesce);
  1243. #else
  1244. static inline void
  1245. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1246. hal_ring_handle_t hal_ring_hdl,
  1247. int coalesce)
  1248. {
  1249. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1250. }
  1251. #endif
  1252. static inline void
  1253. dp_set_rtpm_tput_policy_requirement(struct cdp_soc_t *soc_hdl,
  1254. bool is_high_tput)
  1255. { }
  1256. #endif
  1257. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1258. #ifdef DP_TX_HW_DESC_HISTORY
  1259. static inline void
  1260. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  1261. hal_ring_handle_t hal_ring_hdl,
  1262. struct dp_soc *soc, uint8_t ring_id)
  1263. {
  1264. struct dp_tx_hw_desc_history *tx_hw_desc_history =
  1265. &soc->tx_hw_desc_history;
  1266. struct dp_tx_hw_desc_evt *evt;
  1267. uint32_t idx = 0;
  1268. uint16_t slot = 0;
  1269. if (!tx_hw_desc_history->allocated)
  1270. return;
  1271. dp_get_frag_hist_next_atomic_idx(&tx_hw_desc_history->index, &idx,
  1272. &slot,
  1273. DP_TX_HW_DESC_HIST_SLOT_SHIFT,
  1274. DP_TX_HW_DESC_HIST_PER_SLOT_MAX,
  1275. DP_TX_HW_DESC_HIST_MAX);
  1276. evt = &tx_hw_desc_history->entry[slot][idx];
  1277. qdf_mem_copy(evt->tcl_desc, hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  1278. evt->posted = qdf_get_log_timestamp();
  1279. evt->tcl_ring_id = ring_id;
  1280. hal_get_sw_hptp(soc->hal_soc, hal_ring_hdl, &evt->tp, &evt->hp);
  1281. }
  1282. #else
  1283. static inline void
  1284. dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
  1285. hal_ring_handle_t hal_ring_hdl,
  1286. struct dp_soc *soc, uint8_t ring_id)
  1287. {
  1288. }
  1289. #endif
  1290. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(WLAN_CONFIG_TX_DELAY)
  1291. /**
  1292. * dp_tx_compute_hw_delay_us() - Compute hardware Tx completion delay
  1293. * @ts: Tx completion status
  1294. * @delta_tsf: Difference between TSF clock and qtimer
  1295. * @delay_us: Delay in microseconds
  1296. *
  1297. * Return: QDF_STATUS_SUCCESS : Success
  1298. * QDF_STATUS_E_INVAL : Tx completion status is invalid or
  1299. * delay_us is NULL
  1300. * QDF_STATUS_E_FAILURE : Error in delay calculation
  1301. */
  1302. QDF_STATUS
  1303. dp_tx_compute_hw_delay_us(struct hal_tx_completion_status *ts,
  1304. uint32_t delta_tsf,
  1305. uint32_t *delay_us);
  1306. /**
  1307. * dp_set_delta_tsf() - Set delta_tsf to dp_soc structure
  1308. * @soc_hdl: cdp soc pointer
  1309. * @vdev_id: vdev id
  1310. * @delta_tsf: difference between TSF clock and qtimer
  1311. *
  1312. * Return: None
  1313. */
  1314. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  1315. uint32_t delta_tsf);
  1316. #endif
  1317. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  1318. /**
  1319. * dp_set_tsf_ul_delay_report() - Enable or disable reporting uplink delay
  1320. * @soc_hdl: cdp soc pointer
  1321. * @vdev_id: vdev id
  1322. * @enable: true to enable and false to disable
  1323. *
  1324. * Return: QDF_STATUS
  1325. */
  1326. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  1327. uint8_t vdev_id, bool enable);
  1328. /**
  1329. * dp_get_uplink_delay() - Get uplink delay value
  1330. * @soc_hdl: cdp soc pointer
  1331. * @vdev_id: vdev id
  1332. * @val: pointer to save uplink delay value
  1333. *
  1334. * Return: QDF_STATUS
  1335. */
  1336. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  1337. uint32_t *val);
  1338. #endif /* WLAN_FEATURE_TSF_UPLINK_TSF */
  1339. /**
  1340. * dp_tx_pkt_tracepoints_enabled() - Get the state of tx pkt tracepoint
  1341. *
  1342. * Return: True if any tx pkt tracepoint is enabled else false
  1343. */
  1344. static inline
  1345. bool dp_tx_pkt_tracepoints_enabled(void)
  1346. {
  1347. return (qdf_trace_dp_tx_comp_tcp_pkt_enabled() ||
  1348. qdf_trace_dp_tx_comp_udp_pkt_enabled() ||
  1349. qdf_trace_dp_tx_comp_pkt_enabled());
  1350. }
  1351. #ifdef DP_TX_TRACKING
  1352. /**
  1353. * dp_tx_desc_set_timestamp() - set timestamp in tx descriptor
  1354. * @tx_desc: tx descriptor
  1355. *
  1356. * Return: None
  1357. */
  1358. static inline
  1359. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  1360. {
  1361. tx_desc->timestamp_tick = qdf_system_ticks();
  1362. }
  1363. /**
  1364. * dp_tx_desc_check_corruption() - Verify magic pattern in tx descriptor
  1365. * @tx_desc: tx descriptor
  1366. *
  1367. * Check for corruption in tx descriptor, if magic pattern is not matching
  1368. * trigger self recovery
  1369. *
  1370. * Return: none
  1371. */
  1372. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc);
  1373. #else
  1374. static inline
  1375. void dp_tx_desc_set_timestamp(struct dp_tx_desc_s *tx_desc)
  1376. {
  1377. }
  1378. static inline
  1379. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  1380. {
  1381. }
  1382. #endif
  1383. #ifndef CONFIG_SAWF
  1384. static inline bool dp_sawf_tag_valid_get(qdf_nbuf_t nbuf)
  1385. {
  1386. return false;
  1387. }
  1388. #endif
  1389. #ifdef HW_TX_DELAY_STATS_ENABLE
  1390. /**
  1391. * dp_tx_desc_set_ktimestamp() - set kernel timestamp in tx descriptor
  1392. * @vdev: DP vdev handle
  1393. * @tx_desc: tx descriptor
  1394. *
  1395. * Return: true when descriptor is timestamped, false otherwise
  1396. */
  1397. static inline
  1398. bool dp_tx_desc_set_ktimestamp(struct dp_vdev *vdev,
  1399. struct dp_tx_desc_s *tx_desc)
  1400. {
  1401. if (qdf_unlikely(vdev->pdev->delay_stats_flag) ||
  1402. qdf_unlikely(vdev->pdev->soc->wlan_cfg_ctx->pext_stats_enabled) ||
  1403. qdf_unlikely(dp_tx_pkt_tracepoints_enabled()) ||
  1404. qdf_unlikely(vdev->pdev->soc->peerstats_enabled) ||
  1405. qdf_unlikely(dp_is_vdev_tx_delay_stats_enabled(vdev))) {
  1406. tx_desc->timestamp = qdf_ktime_real_get();
  1407. return true;
  1408. }
  1409. return false;
  1410. }
  1411. #else
  1412. static inline
  1413. bool dp_tx_desc_set_ktimestamp(struct dp_vdev *vdev,
  1414. struct dp_tx_desc_s *tx_desc)
  1415. {
  1416. if (qdf_unlikely(vdev->pdev->delay_stats_flag) ||
  1417. qdf_unlikely(vdev->pdev->soc->wlan_cfg_ctx->pext_stats_enabled) ||
  1418. qdf_unlikely(dp_tx_pkt_tracepoints_enabled()) ||
  1419. qdf_unlikely(vdev->pdev->soc->peerstats_enabled)) {
  1420. tx_desc->timestamp = qdf_ktime_real_get();
  1421. return true;
  1422. }
  1423. return false;
  1424. }
  1425. #endif
  1426. #ifdef CONFIG_DP_PKT_ADD_TIMESTAMP
  1427. /**
  1428. * dp_pkt_add_timestamp() - add timestamp in data payload
  1429. *
  1430. * @vdev: dp vdev
  1431. * @index: index to decide offset in payload
  1432. * @time: timestamp to add in data payload
  1433. * @nbuf: network buffer
  1434. *
  1435. * Return: none
  1436. */
  1437. void dp_pkt_add_timestamp(struct dp_vdev *vdev,
  1438. enum qdf_pkt_timestamp_index index, uint64_t time,
  1439. qdf_nbuf_t nbuf);
  1440. /**
  1441. * dp_pkt_get_timestamp() - get current system time
  1442. *
  1443. * @time: return current system time
  1444. *
  1445. * Return: none
  1446. */
  1447. void dp_pkt_get_timestamp(uint64_t *time);
  1448. #else
  1449. #define dp_pkt_add_timestamp(vdev, index, time, nbuf)
  1450. static inline
  1451. void dp_pkt_get_timestamp(uint64_t *time)
  1452. {
  1453. }
  1454. #endif
  1455. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  1456. /**
  1457. * dp_update_tx_desc_stats - Update the increase or decrease in
  1458. * outstanding tx desc count
  1459. * values on pdev and soc
  1460. * @pdev: DP pdev handle
  1461. *
  1462. * Return: void
  1463. */
  1464. static inline void
  1465. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  1466. {
  1467. int32_t tx_descs_cnt =
  1468. qdf_atomic_read(&pdev->num_tx_outstanding);
  1469. if (pdev->tx_descs_max < tx_descs_cnt)
  1470. pdev->tx_descs_max = tx_descs_cnt;
  1471. qdf_mem_tx_desc_cnt_update(pdev->num_tx_outstanding,
  1472. pdev->tx_descs_max);
  1473. }
  1474. #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
  1475. static inline void
  1476. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  1477. {
  1478. }
  1479. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  1480. #ifdef QCA_SUPPORT_DP_GLOBAL_CTX
  1481. /**
  1482. * dp_tx_get_global_desc_in_use() - read global descriptors in usage
  1483. * @dp_global: Datapath global context
  1484. *
  1485. * Return: global descriptors in use
  1486. */
  1487. static inline int32_t
  1488. dp_tx_get_global_desc_in_use(struct dp_global_context *dp_global)
  1489. {
  1490. return qdf_atomic_read(&dp_global->global_descriptor_in_use);
  1491. }
  1492. #endif
  1493. #ifdef QCA_TX_LIMIT_CHECK
  1494. static inline bool is_spl_packet(qdf_nbuf_t nbuf)
  1495. {
  1496. if (qdf_nbuf_is_ipv4_eapol_pkt(nbuf))
  1497. return true;
  1498. return false;
  1499. }
  1500. #ifdef QCA_SUPPORT_DP_GLOBAL_CTX
  1501. /**
  1502. * is_dp_spl_tx_limit_reached - Check if the packet is a special packet to allow
  1503. * allocation if allocated tx descriptors are within the global max limit
  1504. * and pdev max limit.
  1505. * @vdev: DP vdev handle
  1506. * @nbuf: network buffer
  1507. *
  1508. * Return: true if allocated tx descriptors reached max configured value, else
  1509. * false
  1510. */
  1511. static inline bool
  1512. is_dp_spl_tx_limit_reached(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  1513. {
  1514. struct dp_pdev *pdev = vdev->pdev;
  1515. struct dp_soc *soc = pdev->soc;
  1516. struct dp_global_context *dp_global;
  1517. uint32_t global_tx_desc_allowed;
  1518. dp_global = wlan_objmgr_get_global_ctx();
  1519. global_tx_desc_allowed =
  1520. wlan_cfg_get_num_global_tx_desc(soc->wlan_cfg_ctx);
  1521. if (is_spl_packet(nbuf)) {
  1522. if (dp_tx_get_global_desc_in_use(dp_global) >=
  1523. global_tx_desc_allowed)
  1524. return true;
  1525. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  1526. pdev->num_tx_allowed)
  1527. return true;
  1528. return false;
  1529. }
  1530. return true;
  1531. }
  1532. /**
  1533. * dp_tx_limit_check - Check if allocated tx descriptors reached
  1534. * global max reg limit and pdev max reg limit for regular packets. Also check
  1535. * if the limit is reached for special packets.
  1536. * @vdev: DP vdev handle
  1537. * @nbuf: network buffer
  1538. *
  1539. * Return: true if allocated tx descriptors reached max limit for regular
  1540. * packets and in case of special packets, if the limit is reached max
  1541. * configured vale for the soc/pdev, else false
  1542. */
  1543. static inline bool
  1544. dp_tx_limit_check(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  1545. {
  1546. struct dp_pdev *pdev = vdev->pdev;
  1547. struct dp_soc *soc = pdev->soc;
  1548. struct dp_global_context *dp_global;
  1549. uint32_t global_tx_desc_allowed;
  1550. uint32_t global_tx_desc_reg_allowed;
  1551. uint32_t global_tx_desc_spcl_allowed;
  1552. dp_global = wlan_objmgr_get_global_ctx();
  1553. global_tx_desc_allowed =
  1554. wlan_cfg_get_num_global_tx_desc(soc->wlan_cfg_ctx);
  1555. global_tx_desc_spcl_allowed =
  1556. wlan_cfg_get_num_global_spcl_tx_desc(soc->wlan_cfg_ctx);
  1557. global_tx_desc_reg_allowed = global_tx_desc_allowed -
  1558. global_tx_desc_spcl_allowed;
  1559. if (dp_tx_get_global_desc_in_use(dp_global) >= global_tx_desc_reg_allowed) {
  1560. if (is_dp_spl_tx_limit_reached(vdev, nbuf)) {
  1561. dp_tx_info("queued packets are more than max tx, drop the frame");
  1562. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1563. return true;
  1564. }
  1565. }
  1566. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  1567. pdev->num_reg_tx_allowed) {
  1568. if (is_dp_spl_tx_limit_reached(vdev, nbuf)) {
  1569. dp_tx_info("queued packets are more than max tx, drop the frame");
  1570. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1571. DP_STATS_INC(vdev,
  1572. tx_i.dropped.desc_na_exc_outstand.num, 1);
  1573. return true;
  1574. }
  1575. }
  1576. return false;
  1577. }
  1578. #else
  1579. /**
  1580. * is_dp_spl_tx_limit_reached - Check if the packet is a special packet to allow
  1581. * allocation if allocated tx descriptors are within the soc max limit
  1582. * and pdev max limit.
  1583. * @vdev: DP vdev handle
  1584. * @nbuf: network buffer
  1585. *
  1586. * Return: true if allocated tx descriptors reached max configured value, else
  1587. * false
  1588. */
  1589. static inline bool
  1590. is_dp_spl_tx_limit_reached(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  1591. {
  1592. struct dp_pdev *pdev = vdev->pdev;
  1593. struct dp_soc *soc = pdev->soc;
  1594. if (is_spl_packet(nbuf)) {
  1595. if (qdf_atomic_read(&soc->num_tx_outstanding) >=
  1596. soc->num_tx_allowed)
  1597. return true;
  1598. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  1599. pdev->num_tx_allowed)
  1600. return true;
  1601. return false;
  1602. }
  1603. return true;
  1604. }
  1605. /**
  1606. * dp_tx_limit_check - Check if allocated tx descriptors reached
  1607. * soc max reg limit and pdev max reg limit for regular packets. Also check if
  1608. * the limit is reached for special packets.
  1609. * @vdev: DP vdev handle
  1610. * @nbuf: network buffer
  1611. *
  1612. * Return: true if allocated tx descriptors reached max limit for regular
  1613. * packets and in case of special packets, if the limit is reached max
  1614. * configured vale for the soc/pdev, else false
  1615. */
  1616. static inline bool
  1617. dp_tx_limit_check(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  1618. {
  1619. struct dp_pdev *pdev = vdev->pdev;
  1620. struct dp_soc *soc = pdev->soc;
  1621. if (qdf_atomic_read(&soc->num_tx_outstanding) >=
  1622. soc->num_reg_tx_allowed) {
  1623. if (is_dp_spl_tx_limit_reached(vdev, nbuf)) {
  1624. dp_tx_info("queued packets are more than max tx, drop the frame");
  1625. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1626. return true;
  1627. }
  1628. }
  1629. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  1630. pdev->num_reg_tx_allowed) {
  1631. if (is_dp_spl_tx_limit_reached(vdev, nbuf)) {
  1632. dp_tx_info("queued packets are more than max tx, drop the frame");
  1633. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1634. DP_STATS_INC(vdev,
  1635. tx_i.dropped.desc_na_exc_outstand.num, 1);
  1636. return true;
  1637. }
  1638. }
  1639. return false;
  1640. }
  1641. #endif
  1642. /**
  1643. * dp_tx_exception_limit_check - Check if allocated tx exception descriptors
  1644. * reached soc max limit
  1645. * @vdev: DP vdev handle
  1646. *
  1647. * Return: true if allocated tx descriptors reached max configured value, else
  1648. * false
  1649. */
  1650. static inline bool
  1651. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  1652. {
  1653. struct dp_pdev *pdev = vdev->pdev;
  1654. struct dp_soc *soc = pdev->soc;
  1655. if (qdf_atomic_read(&soc->num_tx_exception) >=
  1656. soc->num_msdu_exception_desc) {
  1657. dp_info("exc packets are more than max drop the exc pkt");
  1658. DP_STATS_INC(vdev, tx_i.dropped.exc_desc_na.num, 1);
  1659. return true;
  1660. }
  1661. return false;
  1662. }
  1663. #ifdef QCA_SUPPORT_DP_GLOBAL_CTX
  1664. /**
  1665. * dp_tx_outstanding_inc - Inc outstanding tx desc values on global and pdev
  1666. * @pdev: DP pdev handle
  1667. *
  1668. * Return: void
  1669. */
  1670. static inline void
  1671. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1672. {
  1673. struct dp_global_context *dp_global;
  1674. dp_global = wlan_objmgr_get_global_ctx();
  1675. qdf_atomic_inc(&dp_global->global_descriptor_in_use);
  1676. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1677. dp_update_tx_desc_stats(pdev);
  1678. }
  1679. /**
  1680. * dp_tx_outstanding_dec - Dec outstanding tx desc values on global and pdev
  1681. * @pdev: DP pdev handle
  1682. *
  1683. * Return: void
  1684. */
  1685. static inline void
  1686. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1687. {
  1688. struct dp_global_context *dp_global;
  1689. dp_global = wlan_objmgr_get_global_ctx();
  1690. qdf_atomic_dec(&dp_global->global_descriptor_in_use);
  1691. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1692. dp_update_tx_desc_stats(pdev);
  1693. }
  1694. #else
  1695. /**
  1696. * dp_tx_outstanding_inc - Increment outstanding tx desc values on pdev and soc
  1697. * @pdev: DP pdev handle
  1698. *
  1699. * Return: void
  1700. */
  1701. static inline void
  1702. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1703. {
  1704. struct dp_soc *soc = pdev->soc;
  1705. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1706. qdf_atomic_inc(&soc->num_tx_outstanding);
  1707. dp_update_tx_desc_stats(pdev);
  1708. }
  1709. /**
  1710. * dp_tx_outstanding_dec - Decrement outstanding tx desc values on pdev and soc
  1711. * @pdev: DP pdev handle
  1712. *
  1713. * Return: void
  1714. */
  1715. static inline void
  1716. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1717. {
  1718. struct dp_soc *soc = pdev->soc;
  1719. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1720. qdf_atomic_dec(&soc->num_tx_outstanding);
  1721. dp_update_tx_desc_stats(pdev);
  1722. }
  1723. #endif /* QCA_SUPPORT_DP_GLOBAL_CTX */
  1724. #else //QCA_TX_LIMIT_CHECK
  1725. static inline bool
  1726. dp_tx_limit_check(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  1727. {
  1728. return false;
  1729. }
  1730. static inline bool
  1731. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  1732. {
  1733. return false;
  1734. }
  1735. static inline void
  1736. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  1737. {
  1738. qdf_atomic_inc(&pdev->num_tx_outstanding);
  1739. dp_update_tx_desc_stats(pdev);
  1740. }
  1741. static inline void
  1742. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  1743. {
  1744. qdf_atomic_dec(&pdev->num_tx_outstanding);
  1745. dp_update_tx_desc_stats(pdev);
  1746. }
  1747. #endif //QCA_TX_LIMIT_CHECK
  1748. /**
  1749. * dp_tx_get_pkt_len() - Get the packet length of a msdu
  1750. * @tx_desc: tx descriptor
  1751. *
  1752. * Return: Packet length of a msdu. If the packet is fragmented,
  1753. * it will return the single fragment length.
  1754. *
  1755. * In TSO mode, the msdu from stack will be fragmented into small
  1756. * fragments and each of these new fragments will be transmitted
  1757. * as an individual msdu.
  1758. *
  1759. * Please note that the length of a msdu from stack may be smaller
  1760. * than the length of the total length of the fragments it has been
  1761. * fragmentted because each of the fragments has a nbuf header.
  1762. */
  1763. static inline uint32_t dp_tx_get_pkt_len(struct dp_tx_desc_s *tx_desc)
  1764. {
  1765. return tx_desc->frm_type == dp_tx_frm_tso ?
  1766. tx_desc->msdu_ext_desc->tso_desc->seg.total_len :
  1767. qdf_nbuf_len(tx_desc->nbuf);
  1768. }
  1769. #ifdef FEATURE_RUNTIME_PM
  1770. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1771. {
  1772. return qdf_atomic_read(&soc->rtpm_high_tput_flag) &&
  1773. (hif_rtpm_get_state() <= HIF_RTPM_STATE_ON);
  1774. }
  1775. #else
  1776. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1777. {
  1778. return 0;
  1779. }
  1780. #endif
  1781. #endif