dp_tx.h 53 KB

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