dp_tx.h 57 KB

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