dp_tx.h 56 KB

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