dp_tx.h 54 KB

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