dp_rx.h 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 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_RX_H
  20. #define _DP_RX_H
  21. #include "hal_rx.h"
  22. #include "dp_peer.h"
  23. #include "dp_internal.h"
  24. #include <qdf_tracepoint.h>
  25. #include "dp_ipa.h"
  26. #ifdef RXDMA_OPTIMIZATION
  27. #ifndef RX_DATA_BUFFER_ALIGNMENT
  28. #define RX_DATA_BUFFER_ALIGNMENT 128
  29. #endif
  30. #ifndef RX_MONITOR_BUFFER_ALIGNMENT
  31. #define RX_MONITOR_BUFFER_ALIGNMENT 128
  32. #endif
  33. #else /* RXDMA_OPTIMIZATION */
  34. #define RX_DATA_BUFFER_ALIGNMENT 4
  35. #define RX_MONITOR_BUFFER_ALIGNMENT 4
  36. #endif /* RXDMA_OPTIMIZATION */
  37. #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
  38. #define DP_WBM2SW_RBM(sw0_bm_id) HAL_RX_BUF_RBM_SW1_BM(sw0_bm_id)
  39. /* RBM value used for re-injecting defragmented packets into REO */
  40. #define DP_DEFRAG_RBM(sw0_bm_id) HAL_RX_BUF_RBM_SW3_BM(sw0_bm_id)
  41. #endif
  42. #define RX_BUFFER_RESERVATION 0
  43. #ifdef BE_PKTLOG_SUPPORT
  44. #define BUFFER_RESIDUE 1
  45. #define RX_MON_MIN_HEAD_ROOM 64
  46. #endif
  47. #define DP_DEFAULT_NOISEFLOOR (-96)
  48. #define DP_RX_DESC_MAGIC 0xdec0de
  49. #define dp_rx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_RX, params)
  50. #define dp_rx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_RX, params)
  51. #define dp_rx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_RX, params)
  52. #define dp_rx_info(params...) \
  53. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX, ## params)
  54. #define dp_rx_info_rl(params...) \
  55. __QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX, ## params)
  56. #define dp_rx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_RX, params)
  57. /**
  58. * enum dp_rx_desc_state
  59. *
  60. * @RX_DESC_REPLENISH: rx desc replenished
  61. * @RX_DESC_FREELIST: rx desc in freelist
  62. */
  63. enum dp_rx_desc_state {
  64. RX_DESC_REPLENISHED,
  65. RX_DESC_IN_FREELIST,
  66. };
  67. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  68. /**
  69. * struct dp_rx_desc_dbg_info
  70. *
  71. * @freelist_caller: name of the function that put the
  72. * the rx desc in freelist
  73. * @freelist_ts: timestamp when the rx desc is put in
  74. * a freelist
  75. * @replenish_caller: name of the function that last
  76. * replenished the rx desc
  77. * @replenish_ts: last replenish timestamp
  78. * @prev_nbuf: previous nbuf info
  79. * @prev_nbuf_data_addr: previous nbuf data address
  80. */
  81. struct dp_rx_desc_dbg_info {
  82. char freelist_caller[QDF_MEM_FUNC_NAME_SIZE];
  83. uint64_t freelist_ts;
  84. char replenish_caller[QDF_MEM_FUNC_NAME_SIZE];
  85. uint64_t replenish_ts;
  86. qdf_nbuf_t prev_nbuf;
  87. uint8_t *prev_nbuf_data_addr;
  88. };
  89. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  90. /**
  91. * struct dp_rx_desc
  92. *
  93. * @nbuf : VA of the "skb" posted
  94. * @rx_buf_start : VA of the original Rx buffer, before
  95. * movement of any skb->data pointer
  96. * @paddr_buf_start : PA of the original Rx buffer, before
  97. * movement of any frag pointer
  98. * @cookie : index into the sw array which holds
  99. * the sw Rx descriptors
  100. * Cookie space is 21 bits:
  101. * lower 18 bits -- index
  102. * upper 3 bits -- pool_id
  103. * @pool_id : pool Id for which this allocated.
  104. * Can only be used if there is no flow
  105. * steering
  106. * @chip_id : chip_id indicating MLO chip_id
  107. * valid or used only in case of multi-chip MLO
  108. * @in_use rx_desc is in use
  109. * @unmapped used to mark rx_desc an unmapped if the corresponding
  110. * nbuf is already unmapped
  111. * @in_err_state : Nbuf sanity failed for this descriptor.
  112. * @nbuf_data_addr : VA of nbuf data posted
  113. */
  114. struct dp_rx_desc {
  115. qdf_nbuf_t nbuf;
  116. uint8_t *rx_buf_start;
  117. qdf_dma_addr_t paddr_buf_start;
  118. uint32_t cookie;
  119. uint8_t pool_id;
  120. uint8_t chip_id;
  121. #ifdef RX_DESC_DEBUG_CHECK
  122. uint32_t magic;
  123. uint8_t *nbuf_data_addr;
  124. struct dp_rx_desc_dbg_info *dbg_info;
  125. #endif
  126. uint8_t in_use:1,
  127. unmapped:1,
  128. in_err_state:1;
  129. };
  130. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  131. #ifdef ATH_RX_PRI_SAVE
  132. #define DP_RX_TID_SAVE(_nbuf, _tid) \
  133. (qdf_nbuf_set_priority(_nbuf, _tid))
  134. #else
  135. #define DP_RX_TID_SAVE(_nbuf, _tid)
  136. #endif
  137. /* RX Descriptor Multi Page memory alloc related */
  138. #define DP_RX_DESC_OFFSET_NUM_BITS 8
  139. #define DP_RX_DESC_PAGE_ID_NUM_BITS 8
  140. #define DP_RX_DESC_POOL_ID_NUM_BITS 4
  141. #define DP_RX_DESC_PAGE_ID_SHIFT DP_RX_DESC_OFFSET_NUM_BITS
  142. #define DP_RX_DESC_POOL_ID_SHIFT \
  143. (DP_RX_DESC_OFFSET_NUM_BITS + DP_RX_DESC_PAGE_ID_NUM_BITS)
  144. #define RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK \
  145. (((1 << DP_RX_DESC_POOL_ID_NUM_BITS) - 1) << DP_RX_DESC_POOL_ID_SHIFT)
  146. #define RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK \
  147. (((1 << DP_RX_DESC_PAGE_ID_NUM_BITS) - 1) << \
  148. DP_RX_DESC_PAGE_ID_SHIFT)
  149. #define RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK \
  150. ((1 << DP_RX_DESC_OFFSET_NUM_BITS) - 1)
  151. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(_cookie) \
  152. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK) >> \
  153. DP_RX_DESC_POOL_ID_SHIFT)
  154. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(_cookie) \
  155. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK) >> \
  156. DP_RX_DESC_PAGE_ID_SHIFT)
  157. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(_cookie) \
  158. ((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK)
  159. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  160. #define RX_DESC_COOKIE_INDEX_SHIFT 0
  161. #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */
  162. #define RX_DESC_COOKIE_POOL_ID_SHIFT 18
  163. #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000
  164. #define DP_RX_DESC_COOKIE_MAX \
  165. (RX_DESC_COOKIE_INDEX_MASK | RX_DESC_COOKIE_POOL_ID_MASK)
  166. #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \
  167. (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \
  168. RX_DESC_COOKIE_POOL_ID_SHIFT)
  169. #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \
  170. (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \
  171. RX_DESC_COOKIE_INDEX_SHIFT)
  172. #define dp_rx_add_to_free_desc_list(head, tail, new) \
  173. __dp_rx_add_to_free_desc_list(head, tail, new, __func__)
  174. #define dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool, \
  175. num_buffers, desc_list, tail) \
  176. __dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool, \
  177. num_buffers, desc_list, tail, __func__)
  178. #ifdef WLAN_SUPPORT_RX_FISA
  179. /**
  180. * dp_rx_set_hdr_pad() - set l3 padding in nbuf cb
  181. * @nbuf: pkt skb pointer
  182. * @l3_padding: l3 padding
  183. *
  184. * Return: None
  185. */
  186. static inline
  187. void dp_rx_set_hdr_pad(qdf_nbuf_t nbuf, uint32_t l3_padding)
  188. {
  189. QDF_NBUF_CB_RX_PACKET_L3_HDR_PAD(nbuf) = l3_padding;
  190. }
  191. #else
  192. static inline
  193. void dp_rx_set_hdr_pad(qdf_nbuf_t nbuf, uint32_t l3_padding)
  194. {
  195. }
  196. #endif
  197. #ifdef DP_RX_SPECIAL_FRAME_NEED
  198. /**
  199. * dp_rx_is_special_frame() - check is RX frame special needed
  200. *
  201. * @nbuf: RX skb pointer
  202. * @frame_mask: the mask for speical frame needed
  203. *
  204. * Check is RX frame wanted matched with mask
  205. *
  206. * Return: true - special frame needed, false - no
  207. */
  208. static inline
  209. bool dp_rx_is_special_frame(qdf_nbuf_t nbuf, uint32_t frame_mask)
  210. {
  211. if (((frame_mask & FRAME_MASK_IPV4_ARP) &&
  212. qdf_nbuf_is_ipv4_arp_pkt(nbuf)) ||
  213. ((frame_mask & FRAME_MASK_IPV4_DHCP) &&
  214. qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) ||
  215. ((frame_mask & FRAME_MASK_IPV4_EAPOL) &&
  216. qdf_nbuf_is_ipv4_eapol_pkt(nbuf)) ||
  217. ((frame_mask & FRAME_MASK_IPV6_DHCP) &&
  218. qdf_nbuf_is_ipv6_dhcp_pkt(nbuf)))
  219. return true;
  220. return false;
  221. }
  222. /**
  223. * dp_rx_deliver_special_frame() - Deliver the RX special frame to stack
  224. * if matches mask
  225. *
  226. * @soc: Datapath soc handler
  227. * @peer: pointer to DP peer
  228. * @nbuf: pointer to the skb of RX frame
  229. * @frame_mask: the mask for speical frame needed
  230. * @rx_tlv_hdr: start of rx tlv header
  231. *
  232. * note: Msdu_len must have been stored in QDF_NBUF_CB_RX_PKT_LEN(nbuf) and
  233. * single nbuf is expected.
  234. *
  235. * return: true - nbuf has been delivered to stack, false - not.
  236. */
  237. bool dp_rx_deliver_special_frame(struct dp_soc *soc, struct dp_txrx_peer *peer,
  238. qdf_nbuf_t nbuf, uint32_t frame_mask,
  239. uint8_t *rx_tlv_hdr);
  240. #else
  241. static inline
  242. bool dp_rx_is_special_frame(qdf_nbuf_t nbuf, uint32_t frame_mask)
  243. {
  244. return false;
  245. }
  246. static inline
  247. bool dp_rx_deliver_special_frame(struct dp_soc *soc, struct dp_txrx_peer *peer,
  248. qdf_nbuf_t nbuf, uint32_t frame_mask,
  249. uint8_t *rx_tlv_hdr)
  250. {
  251. return false;
  252. }
  253. #endif
  254. #ifdef FEATURE_RX_LINKSPEED_ROAM_TRIGGER
  255. /**
  256. * dp_rx_data_is_specific() - Used to exclude specific frames
  257. * not practical for getting rx
  258. * stats like rate, mcs, nss, etc.
  259. *
  260. * @hal-soc_hdl: soc handler
  261. * @rx_tlv_hdr: rx tlv header
  262. * @nbuf: RX skb pointer
  263. *
  264. * Return: true - a specific frame not suitable
  265. * for getting rx stats from it.
  266. * false - a common frame suitable for
  267. * getting rx stats from it.
  268. */
  269. static inline
  270. bool dp_rx_data_is_specific(hal_soc_handle_t hal_soc_hdl,
  271. uint8_t *rx_tlv_hdr,
  272. qdf_nbuf_t nbuf)
  273. {
  274. if (qdf_unlikely(qdf_nbuf_is_da_mcbc(nbuf)))
  275. return true;
  276. if (!hal_rx_tlv_first_mpdu_get(hal_soc_hdl, rx_tlv_hdr))
  277. return true;
  278. if (!hal_rx_msdu_end_first_msdu_get(hal_soc_hdl, rx_tlv_hdr))
  279. return true;
  280. /* ARP, EAPOL is neither IPV6 ETH nor IPV4 ETH from L3 level */
  281. if (qdf_likely(hal_rx_tlv_l3_type_get(hal_soc_hdl, rx_tlv_hdr) ==
  282. QDF_NBUF_TRAC_IPV4_ETH_TYPE)) {
  283. if (qdf_nbuf_is_ipv4_dhcp_pkt(nbuf))
  284. return true;
  285. } else if (qdf_likely(hal_rx_tlv_l3_type_get(hal_soc_hdl, rx_tlv_hdr) ==
  286. QDF_NBUF_TRAC_IPV6_ETH_TYPE)) {
  287. if (qdf_nbuf_is_ipv6_dhcp_pkt(nbuf))
  288. return true;
  289. } else {
  290. return true;
  291. }
  292. return false;
  293. }
  294. #else
  295. static inline
  296. bool dp_rx_data_is_specific(hal_soc_handle_t hal_soc_hdl,
  297. uint8_t *rx_tlv_hdr,
  298. qdf_nbuf_t nbuf)
  299. {
  300. /*
  301. * default return is true to make sure that rx stats
  302. * will not be handled when this feature is disabled
  303. */
  304. return true;
  305. }
  306. #endif /* FEATURE_RX_LINKSPEED_ROAM_TRIGGER */
  307. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  308. #ifdef DP_RX_DISABLE_NDI_MDNS_FORWARDING
  309. static inline
  310. bool dp_rx_check_ndi_mdns_fwding(struct dp_txrx_peer *ta_txrx_peer,
  311. qdf_nbuf_t nbuf)
  312. {
  313. if (ta_txrx_peer->vdev->opmode == wlan_op_mode_ndi &&
  314. qdf_nbuf_is_ipv6_mdns_pkt(nbuf)) {
  315. DP_PEER_PER_PKT_STATS_INC(ta_txrx_peer,
  316. rx.intra_bss.mdns_no_fwd, 1);
  317. return false;
  318. }
  319. return true;
  320. }
  321. #else
  322. static inline
  323. bool dp_rx_check_ndi_mdns_fwding(struct dp_txrx_peer *ta_txrx_peer,
  324. qdf_nbuf_t nbuf)
  325. {
  326. return true;
  327. }
  328. #endif
  329. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  330. /* DOC: Offset to obtain LLC hdr
  331. *
  332. * In the case of Wifi parse error
  333. * to reach LLC header from beginning
  334. * of VLAN tag we need to skip 8 bytes.
  335. * Vlan_tag(4)+length(2)+length added
  336. * by HW(2) = 8 bytes.
  337. */
  338. #define DP_SKIP_VLAN 8
  339. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  340. /**
  341. * struct dp_rx_cached_buf - rx cached buffer
  342. * @list: linked list node
  343. * @buf: skb buffer
  344. */
  345. struct dp_rx_cached_buf {
  346. qdf_list_node_t node;
  347. qdf_nbuf_t buf;
  348. };
  349. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  350. /*
  351. *dp_rx_xor_block() - xor block of data
  352. *@b: destination data block
  353. *@a: source data block
  354. *@len: length of the data to process
  355. *
  356. *Returns: None
  357. */
  358. static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len)
  359. {
  360. qdf_size_t i;
  361. for (i = 0; i < len; i++)
  362. b[i] ^= a[i];
  363. }
  364. /*
  365. *dp_rx_rotl() - rotate the bits left
  366. *@val: unsigned integer input value
  367. *@bits: number of bits
  368. *
  369. *Returns: Integer with left rotated by number of 'bits'
  370. */
  371. static inline uint32_t dp_rx_rotl(uint32_t val, int bits)
  372. {
  373. return (val << bits) | (val >> (32 - bits));
  374. }
  375. /*
  376. *dp_rx_rotr() - rotate the bits right
  377. *@val: unsigned integer input value
  378. *@bits: number of bits
  379. *
  380. *Returns: Integer with right rotated by number of 'bits'
  381. */
  382. static inline uint32_t dp_rx_rotr(uint32_t val, int bits)
  383. {
  384. return (val >> bits) | (val << (32 - bits));
  385. }
  386. /*
  387. * dp_set_rx_queue() - set queue_mapping in skb
  388. * @nbuf: skb
  389. * @queue_id: rx queue_id
  390. *
  391. * Return: void
  392. */
  393. #ifdef QCA_OL_RX_MULTIQ_SUPPORT
  394. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  395. {
  396. qdf_nbuf_record_rx_queue(nbuf, queue_id);
  397. return;
  398. }
  399. #else
  400. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  401. {
  402. }
  403. #endif
  404. /*
  405. *dp_rx_xswap() - swap the bits left
  406. *@val: unsigned integer input value
  407. *
  408. *Returns: Integer with bits swapped
  409. */
  410. static inline uint32_t dp_rx_xswap(uint32_t val)
  411. {
  412. return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
  413. }
  414. /*
  415. *dp_rx_get_le32_split() - get little endian 32 bits split
  416. *@b0: byte 0
  417. *@b1: byte 1
  418. *@b2: byte 2
  419. *@b3: byte 3
  420. *
  421. *Returns: Integer with split little endian 32 bits
  422. */
  423. static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2,
  424. uint8_t b3)
  425. {
  426. return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
  427. }
  428. /*
  429. *dp_rx_get_le32() - get little endian 32 bits
  430. *@b0: byte 0
  431. *@b1: byte 1
  432. *@b2: byte 2
  433. *@b3: byte 3
  434. *
  435. *Returns: Integer with little endian 32 bits
  436. */
  437. static inline uint32_t dp_rx_get_le32(const uint8_t *p)
  438. {
  439. return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]);
  440. }
  441. /*
  442. * dp_rx_put_le32() - put little endian 32 bits
  443. * @p: destination char array
  444. * @v: source 32-bit integer
  445. *
  446. * Returns: None
  447. */
  448. static inline void dp_rx_put_le32(uint8_t *p, uint32_t v)
  449. {
  450. p[0] = (v) & 0xff;
  451. p[1] = (v >> 8) & 0xff;
  452. p[2] = (v >> 16) & 0xff;
  453. p[3] = (v >> 24) & 0xff;
  454. }
  455. /* Extract michal mic block of data */
  456. #define dp_rx_michael_block(l, r) \
  457. do { \
  458. r ^= dp_rx_rotl(l, 17); \
  459. l += r; \
  460. r ^= dp_rx_xswap(l); \
  461. l += r; \
  462. r ^= dp_rx_rotl(l, 3); \
  463. l += r; \
  464. r ^= dp_rx_rotr(l, 2); \
  465. l += r; \
  466. } while (0)
  467. /**
  468. * struct dp_rx_desc_list_elem_t
  469. *
  470. * @next : Next pointer to form free list
  471. * @rx_desc : DP Rx descriptor
  472. */
  473. union dp_rx_desc_list_elem_t {
  474. union dp_rx_desc_list_elem_t *next;
  475. struct dp_rx_desc rx_desc;
  476. };
  477. #ifdef RX_DESC_MULTI_PAGE_ALLOC
  478. /**
  479. * dp_rx_desc_find() - find dp rx descriptor from page ID and offset
  480. * @page_id: Page ID
  481. * @offset: Offset of the descriptor element
  482. *
  483. * Return: RX descriptor element
  484. */
  485. union dp_rx_desc_list_elem_t *dp_rx_desc_find(uint16_t page_id, uint16_t offset,
  486. struct rx_desc_pool *rx_pool);
  487. static inline
  488. struct dp_rx_desc *dp_get_rx_desc_from_cookie(struct dp_soc *soc,
  489. struct rx_desc_pool *pool,
  490. uint32_t cookie)
  491. {
  492. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  493. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  494. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  495. struct rx_desc_pool *rx_desc_pool;
  496. union dp_rx_desc_list_elem_t *rx_desc_elem;
  497. if (qdf_unlikely(pool_id >= MAX_PDEV_CNT))
  498. return NULL;
  499. rx_desc_pool = &pool[pool_id];
  500. rx_desc_elem = (union dp_rx_desc_list_elem_t *)
  501. (rx_desc_pool->desc_pages.cacheable_pages[page_id] +
  502. rx_desc_pool->elem_size * offset);
  503. return &rx_desc_elem->rx_desc;
  504. }
  505. /**
  506. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  507. * the Rx descriptor on Rx DMA source ring buffer
  508. * @soc: core txrx main context
  509. * @cookie: cookie used to lookup virtual address
  510. *
  511. * Return: Pointer to the Rx descriptor
  512. */
  513. static inline
  514. struct dp_rx_desc *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc,
  515. uint32_t cookie)
  516. {
  517. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_buf[0], cookie);
  518. }
  519. /**
  520. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  521. * the Rx descriptor on monitor ring buffer
  522. * @soc: core txrx main context
  523. * @cookie: cookie used to lookup virtual address
  524. *
  525. * Return: Pointer to the Rx descriptor
  526. */
  527. static inline
  528. struct dp_rx_desc *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc,
  529. uint32_t cookie)
  530. {
  531. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_mon[0], cookie);
  532. }
  533. /**
  534. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  535. * the Rx descriptor on monitor status ring buffer
  536. * @soc: core txrx main context
  537. * @cookie: cookie used to lookup virtual address
  538. *
  539. * Return: Pointer to the Rx descriptor
  540. */
  541. static inline
  542. struct dp_rx_desc *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc,
  543. uint32_t cookie)
  544. {
  545. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_status[0], cookie);
  546. }
  547. #else
  548. void dp_rx_desc_pool_init(struct dp_soc *soc, uint32_t pool_id,
  549. uint32_t pool_size,
  550. struct rx_desc_pool *rx_desc_pool);
  551. /**
  552. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  553. * the Rx descriptor on Rx DMA source ring buffer
  554. * @soc: core txrx main context
  555. * @cookie: cookie used to lookup virtual address
  556. *
  557. * Return: void *: Virtual Address of the Rx descriptor
  558. */
  559. static inline
  560. void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie)
  561. {
  562. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  563. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  564. struct rx_desc_pool *rx_desc_pool;
  565. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  566. return NULL;
  567. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  568. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  569. return NULL;
  570. return &rx_desc_pool->array[index].rx_desc;
  571. }
  572. /**
  573. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  574. * the Rx descriptor on monitor ring buffer
  575. * @soc: core txrx main context
  576. * @cookie: cookie used to lookup virtual address
  577. *
  578. * Return: void *: Virtual Address of the Rx descriptor
  579. */
  580. static inline
  581. void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie)
  582. {
  583. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  584. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  585. /* TODO */
  586. /* Add sanity for pool_id & index */
  587. return &(soc->rx_desc_mon[pool_id].array[index].rx_desc);
  588. }
  589. /**
  590. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  591. * the Rx descriptor on monitor status ring buffer
  592. * @soc: core txrx main context
  593. * @cookie: cookie used to lookup virtual address
  594. *
  595. * Return: void *: Virtual Address of the Rx descriptor
  596. */
  597. static inline
  598. void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie)
  599. {
  600. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  601. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  602. /* TODO */
  603. /* Add sanity for pool_id & index */
  604. return &(soc->rx_desc_status[pool_id].array[index].rx_desc);
  605. }
  606. #endif /* RX_DESC_MULTI_PAGE_ALLOC */
  607. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  608. static inline bool dp_rx_check_ap_bridge(struct dp_vdev *vdev)
  609. {
  610. return vdev->ap_bridge_enabled;
  611. }
  612. #ifdef DP_RX_DESC_COOKIE_INVALIDATE
  613. static inline QDF_STATUS
  614. dp_rx_cookie_check_and_invalidate(hal_ring_desc_t ring_desc)
  615. {
  616. if (qdf_unlikely(HAL_RX_REO_BUF_COOKIE_INVALID_GET(ring_desc)))
  617. return QDF_STATUS_E_FAILURE;
  618. HAL_RX_REO_BUF_COOKIE_INVALID_SET(ring_desc);
  619. return QDF_STATUS_SUCCESS;
  620. }
  621. /**
  622. * dp_rx_cookie_reset_invalid_bit() - Reset the invalid bit of the cookie
  623. * field in ring descriptor
  624. * @ring_desc: ring descriptor
  625. *
  626. * Return: None
  627. */
  628. static inline void
  629. dp_rx_cookie_reset_invalid_bit(hal_ring_desc_t ring_desc)
  630. {
  631. HAL_RX_REO_BUF_COOKIE_INVALID_RESET(ring_desc);
  632. }
  633. #else
  634. static inline QDF_STATUS
  635. dp_rx_cookie_check_and_invalidate(hal_ring_desc_t ring_desc)
  636. {
  637. return QDF_STATUS_SUCCESS;
  638. }
  639. static inline void
  640. dp_rx_cookie_reset_invalid_bit(hal_ring_desc_t ring_desc)
  641. {
  642. }
  643. #endif
  644. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  645. #if defined(RX_DESC_MULTI_PAGE_ALLOC) && \
  646. defined(DP_WAR_VALIDATE_RX_ERR_MSDU_COOKIE)
  647. /**
  648. * dp_rx_is_sw_cookie_valid() - check whether SW cookie valid
  649. * @soc: dp soc ref
  650. * @cookie: Rx buf SW cookie value
  651. *
  652. * Return: true if cookie is valid else false
  653. */
  654. static inline bool dp_rx_is_sw_cookie_valid(struct dp_soc *soc,
  655. uint32_t cookie)
  656. {
  657. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  658. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  659. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  660. struct rx_desc_pool *rx_desc_pool;
  661. if (qdf_unlikely(pool_id >= MAX_PDEV_CNT))
  662. goto fail;
  663. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  664. if (page_id >= rx_desc_pool->desc_pages.num_pages ||
  665. offset >= rx_desc_pool->desc_pages.num_element_per_page)
  666. goto fail;
  667. return true;
  668. fail:
  669. DP_STATS_INC(soc, rx.err.invalid_cookie, 1);
  670. return false;
  671. }
  672. #else
  673. /**
  674. * dp_rx_is_sw_cookie_valid() - check whether SW cookie valid
  675. * @soc: dp soc ref
  676. * @cookie: Rx buf SW cookie value
  677. *
  678. * When multi page alloc is disabled SW cookie validness is
  679. * checked while fetching Rx descriptor, so no need to check here
  680. * Return: true if cookie is valid else false
  681. */
  682. static inline bool dp_rx_is_sw_cookie_valid(struct dp_soc *soc,
  683. uint32_t cookie)
  684. {
  685. return true;
  686. }
  687. #endif
  688. QDF_STATUS dp_rx_desc_pool_is_allocated(struct rx_desc_pool *rx_desc_pool);
  689. QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc,
  690. uint32_t pool_size,
  691. struct rx_desc_pool *rx_desc_pool);
  692. void dp_rx_desc_pool_init(struct dp_soc *soc, uint32_t pool_id,
  693. uint32_t pool_size,
  694. struct rx_desc_pool *rx_desc_pool);
  695. void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc,
  696. union dp_rx_desc_list_elem_t **local_desc_list,
  697. union dp_rx_desc_list_elem_t **tail,
  698. uint16_t pool_id,
  699. struct rx_desc_pool *rx_desc_pool);
  700. uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id,
  701. struct rx_desc_pool *rx_desc_pool,
  702. uint16_t num_descs,
  703. union dp_rx_desc_list_elem_t **desc_list,
  704. union dp_rx_desc_list_elem_t **tail);
  705. QDF_STATUS dp_rx_pdev_desc_pool_alloc(struct dp_pdev *pdev);
  706. void dp_rx_pdev_desc_pool_free(struct dp_pdev *pdev);
  707. QDF_STATUS dp_rx_pdev_desc_pool_init(struct dp_pdev *pdev);
  708. void dp_rx_pdev_desc_pool_deinit(struct dp_pdev *pdev);
  709. void dp_rx_desc_pool_deinit(struct dp_soc *soc,
  710. struct rx_desc_pool *rx_desc_pool,
  711. uint32_t pool_id);
  712. QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev);
  713. QDF_STATUS dp_rx_pdev_buffers_alloc(struct dp_pdev *pdev);
  714. void dp_rx_pdev_buffers_free(struct dp_pdev *pdev);
  715. void dp_rx_pdev_detach(struct dp_pdev *pdev);
  716. void dp_print_napi_stats(struct dp_soc *soc);
  717. /**
  718. * dp_rx_vdev_detach() - detach vdev from dp rx
  719. * @vdev: virtual device instance
  720. *
  721. * Return: QDF_STATUS_SUCCESS: success
  722. * QDF_STATUS_E_RESOURCES: Error return
  723. */
  724. QDF_STATUS dp_rx_vdev_detach(struct dp_vdev *vdev);
  725. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  726. uint32_t
  727. dp_rx_process(struct dp_intr *int_ctx, hal_ring_handle_t hal_ring_hdl,
  728. uint8_t reo_ring_num,
  729. uint32_t quota);
  730. /**
  731. * dp_rx_err_process() - Processes error frames routed to REO error ring
  732. * @int_ctx: pointer to DP interrupt context
  733. * @soc: core txrx main context
  734. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  735. * @quota: No. of units (packets) that can be serviced in one shot.
  736. *
  737. * This function implements error processing and top level demultiplexer
  738. * for all the frames routed to REO error ring.
  739. *
  740. * Return: uint32_t: No. of elements processed
  741. */
  742. uint32_t dp_rx_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  743. hal_ring_handle_t hal_ring_hdl, uint32_t quota);
  744. /**
  745. * dp_rx_wbm_err_process() - Processes error frames routed to WBM release ring
  746. * @int_ctx: pointer to DP interrupt context
  747. * @soc: core txrx main context
  748. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  749. * @quota: No. of units (packets) that can be serviced in one shot.
  750. *
  751. * This function implements error processing and top level demultiplexer
  752. * for all the frames routed to WBM2HOST sw release ring.
  753. *
  754. * Return: uint32_t: No. of elements processed
  755. */
  756. uint32_t
  757. dp_rx_wbm_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  758. hal_ring_handle_t hal_ring_hdl, uint32_t quota);
  759. /**
  760. * dp_rx_sg_create() - create a frag_list for MSDUs which are spread across
  761. * multiple nbufs.
  762. * @soc: core txrx main context
  763. * @nbuf: pointer to the first msdu of an amsdu.
  764. *
  765. * This function implements the creation of RX frag_list for cases
  766. * where an MSDU is spread across multiple nbufs.
  767. *
  768. * Return: returns the head nbuf which contains complete frag_list.
  769. */
  770. qdf_nbuf_t dp_rx_sg_create(struct dp_soc *soc, qdf_nbuf_t nbuf);
  771. /*
  772. * dp_rx_desc_nbuf_and_pool_free() - free the sw rx desc pool called during
  773. * de-initialization of wifi module.
  774. *
  775. * @soc: core txrx main context
  776. * @pool_id: pool_id which is one of 3 mac_ids
  777. * @rx_desc_pool: rx descriptor pool pointer
  778. *
  779. * Return: None
  780. */
  781. void dp_rx_desc_nbuf_and_pool_free(struct dp_soc *soc, uint32_t pool_id,
  782. struct rx_desc_pool *rx_desc_pool);
  783. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  784. /*
  785. * dp_rx_desc_nbuf_free() - free the sw rx desc nbufs called during
  786. * de-initialization of wifi module.
  787. *
  788. * @soc: core txrx main context
  789. * @pool_id: pool_id which is one of 3 mac_ids
  790. * @rx_desc_pool: rx descriptor pool pointer
  791. *
  792. * Return: None
  793. */
  794. void dp_rx_desc_nbuf_free(struct dp_soc *soc,
  795. struct rx_desc_pool *rx_desc_pool);
  796. #ifdef DP_RX_MON_MEM_FRAG
  797. /*
  798. * dp_rx_desc_frag_free() - free the sw rx desc frag called during
  799. * de-initialization of wifi module.
  800. *
  801. * @soc: core txrx main context
  802. * @rx_desc_pool: rx descriptor pool pointer
  803. *
  804. * Return: None
  805. */
  806. void dp_rx_desc_frag_free(struct dp_soc *soc,
  807. struct rx_desc_pool *rx_desc_pool);
  808. #else
  809. static inline
  810. void dp_rx_desc_frag_free(struct dp_soc *soc,
  811. struct rx_desc_pool *rx_desc_pool)
  812. {
  813. }
  814. #endif
  815. /*
  816. * dp_rx_desc_pool_free() - free the sw rx desc array called during
  817. * de-initialization of wifi module.
  818. *
  819. * @soc: core txrx main context
  820. * @rx_desc_pool: rx descriptor pool pointer
  821. *
  822. * Return: None
  823. */
  824. void dp_rx_desc_pool_free(struct dp_soc *soc,
  825. struct rx_desc_pool *rx_desc_pool);
  826. void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list,
  827. struct dp_txrx_peer *peer);
  828. #ifdef RX_DESC_LOGGING
  829. /*
  830. * dp_rx_desc_alloc_dbg_info() - Alloc memory for rx descriptor debug
  831. * structure
  832. * @rx_desc: rx descriptor pointer
  833. *
  834. * Return: None
  835. */
  836. static inline
  837. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  838. {
  839. rx_desc->dbg_info = qdf_mem_malloc(sizeof(struct dp_rx_desc_dbg_info));
  840. }
  841. /*
  842. * dp_rx_desc_free_dbg_info() - Free rx descriptor debug
  843. * structure memory
  844. * @rx_desc: rx descriptor pointer
  845. *
  846. * Return: None
  847. */
  848. static inline
  849. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  850. {
  851. qdf_mem_free(rx_desc->dbg_info);
  852. }
  853. /*
  854. * dp_rx_desc_update_dbg_info() - Update rx descriptor debug info
  855. * structure memory
  856. * @rx_desc: rx descriptor pointer
  857. *
  858. * Return: None
  859. */
  860. static
  861. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  862. const char *func_name, uint8_t flag)
  863. {
  864. struct dp_rx_desc_dbg_info *info = rx_desc->dbg_info;
  865. if (!info)
  866. return;
  867. if (flag == RX_DESC_REPLENISHED) {
  868. qdf_str_lcopy(info->replenish_caller, func_name,
  869. QDF_MEM_FUNC_NAME_SIZE);
  870. info->replenish_ts = qdf_get_log_timestamp();
  871. } else {
  872. qdf_str_lcopy(info->freelist_caller, func_name,
  873. QDF_MEM_FUNC_NAME_SIZE);
  874. info->freelist_ts = qdf_get_log_timestamp();
  875. info->prev_nbuf = rx_desc->nbuf;
  876. info->prev_nbuf_data_addr = rx_desc->nbuf_data_addr;
  877. rx_desc->nbuf_data_addr = NULL;
  878. }
  879. }
  880. #else
  881. static inline
  882. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  883. {
  884. }
  885. static inline
  886. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  887. {
  888. }
  889. static inline
  890. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  891. const char *func_name, uint8_t flag)
  892. {
  893. }
  894. #endif /* RX_DESC_LOGGING */
  895. /**
  896. * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  897. *
  898. * @head: pointer to the head of local free list
  899. * @tail: pointer to the tail of local free list
  900. * @new: new descriptor that is added to the free list
  901. * @func_name: caller func name
  902. *
  903. * Return: void:
  904. */
  905. static inline
  906. void __dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  907. union dp_rx_desc_list_elem_t **tail,
  908. struct dp_rx_desc *new, const char *func_name)
  909. {
  910. qdf_assert(head && new);
  911. dp_rx_desc_update_dbg_info(new, func_name, RX_DESC_IN_FREELIST);
  912. new->nbuf = NULL;
  913. new->in_use = 0;
  914. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  915. *head = (union dp_rx_desc_list_elem_t *)new;
  916. /* reset tail if head->next is NULL */
  917. if (!*tail || !(*head)->next)
  918. *tail = *head;
  919. }
  920. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  921. uint8_t mac_id);
  922. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  923. qdf_nbuf_t mpdu, bool mpdu_done, uint8_t mac_id);
  924. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  925. uint8_t *rx_tlv_hdr, struct dp_txrx_peer *peer);
  926. void dp_2k_jump_handle(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  927. uint16_t peer_id, uint8_t tid);
  928. #define DP_RX_HEAD_APPEND(head, elem) \
  929. do { \
  930. qdf_nbuf_set_next((elem), (head)); \
  931. (head) = (elem); \
  932. } while (0)
  933. #define DP_RX_LIST_APPEND(head, tail, elem) \
  934. do { \
  935. if (!(head)) { \
  936. (head) = (elem); \
  937. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\
  938. } else { \
  939. qdf_nbuf_set_next((tail), (elem)); \
  940. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \
  941. } \
  942. (tail) = (elem); \
  943. qdf_nbuf_set_next((tail), NULL); \
  944. } while (0)
  945. #define DP_RX_MERGE_TWO_LIST(phead, ptail, chead, ctail) \
  946. do { \
  947. if (!(phead)) { \
  948. (phead) = (chead); \
  949. } else { \
  950. qdf_nbuf_set_next((ptail), (chead)); \
  951. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(phead) += \
  952. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(chead); \
  953. } \
  954. (ptail) = (ctail); \
  955. qdf_nbuf_set_next((ptail), NULL); \
  956. } while (0)
  957. #if defined(QCA_PADDR_CHECK_ON_3TH_PLATFORM)
  958. /*
  959. * on some third-party platform, the memory below 0x2000
  960. * is reserved for target use, so any memory allocated in this
  961. * region should not be used by host
  962. */
  963. #define MAX_RETRY 50
  964. #define DP_PHY_ADDR_RESERVED 0x2000
  965. #elif defined(BUILD_X86)
  966. /*
  967. * in M2M emulation platforms (x86) the memory below 0x50000000
  968. * is reserved for target use, so any memory allocated in this
  969. * region should not be used by host
  970. */
  971. #define MAX_RETRY 100
  972. #define DP_PHY_ADDR_RESERVED 0x50000000
  973. #endif
  974. #if defined(QCA_PADDR_CHECK_ON_3TH_PLATFORM) || defined(BUILD_X86)
  975. /**
  976. * dp_check_paddr() - check if current phy address is valid or not
  977. * @dp_soc: core txrx main context
  978. * @rx_netbuf: skb buffer
  979. * @paddr: physical address
  980. * @rx_desc_pool: struct of rx descriptor pool
  981. * check if the physical address of the nbuf->data is less
  982. * than DP_PHY_ADDR_RESERVED then free the nbuf and try
  983. * allocating new nbuf. We can try for 100 times.
  984. *
  985. * This is a temp WAR till we fix it properly.
  986. *
  987. * Return: success or failure.
  988. */
  989. static inline
  990. int dp_check_paddr(struct dp_soc *dp_soc,
  991. qdf_nbuf_t *rx_netbuf,
  992. qdf_dma_addr_t *paddr,
  993. struct rx_desc_pool *rx_desc_pool)
  994. {
  995. uint32_t nbuf_retry = 0;
  996. int32_t ret;
  997. if (qdf_likely(*paddr > DP_PHY_ADDR_RESERVED))
  998. return QDF_STATUS_SUCCESS;
  999. do {
  1000. dp_debug("invalid phy addr 0x%llx, trying again",
  1001. (uint64_t)(*paddr));
  1002. nbuf_retry++;
  1003. if ((*rx_netbuf)) {
  1004. /* Not freeing buffer intentionally.
  1005. * Observed that same buffer is getting
  1006. * re-allocated resulting in longer load time
  1007. * WMI init timeout.
  1008. * This buffer is anyway not useful so skip it.
  1009. *.Add such buffer to invalid list and free
  1010. *.them when driver unload.
  1011. **/
  1012. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev,
  1013. *rx_netbuf,
  1014. QDF_DMA_FROM_DEVICE,
  1015. rx_desc_pool->buf_size);
  1016. qdf_nbuf_queue_add(&dp_soc->invalid_buf_queue,
  1017. *rx_netbuf);
  1018. }
  1019. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  1020. rx_desc_pool->buf_size,
  1021. RX_BUFFER_RESERVATION,
  1022. rx_desc_pool->buf_alignment,
  1023. FALSE);
  1024. if (qdf_unlikely(!(*rx_netbuf)))
  1025. return QDF_STATUS_E_FAILURE;
  1026. ret = qdf_nbuf_map_nbytes_single(dp_soc->osdev,
  1027. *rx_netbuf,
  1028. QDF_DMA_FROM_DEVICE,
  1029. rx_desc_pool->buf_size);
  1030. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  1031. qdf_nbuf_free(*rx_netbuf);
  1032. *rx_netbuf = NULL;
  1033. continue;
  1034. }
  1035. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  1036. if (qdf_likely(*paddr > DP_PHY_ADDR_RESERVED))
  1037. return QDF_STATUS_SUCCESS;
  1038. } while (nbuf_retry < MAX_RETRY);
  1039. if ((*rx_netbuf)) {
  1040. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev,
  1041. *rx_netbuf,
  1042. QDF_DMA_FROM_DEVICE,
  1043. rx_desc_pool->buf_size);
  1044. qdf_nbuf_queue_add(&dp_soc->invalid_buf_queue,
  1045. *rx_netbuf);
  1046. }
  1047. return QDF_STATUS_E_FAILURE;
  1048. }
  1049. #else
  1050. static inline
  1051. int dp_check_paddr(struct dp_soc *dp_soc,
  1052. qdf_nbuf_t *rx_netbuf,
  1053. qdf_dma_addr_t *paddr,
  1054. struct rx_desc_pool *rx_desc_pool)
  1055. {
  1056. return QDF_STATUS_SUCCESS;
  1057. }
  1058. #endif
  1059. /**
  1060. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  1061. * the MSDU Link Descriptor
  1062. * @soc: core txrx main context
  1063. * @buf_info: buf_info includes cookie that is used to lookup
  1064. * virtual address of link descriptor after deriving the page id
  1065. * and the offset or index of the desc on the associatde page.
  1066. *
  1067. * This is the VA of the link descriptor, that HAL layer later uses to
  1068. * retrieve the list of MSDU's for a given MPDU.
  1069. *
  1070. * Return: void *: Virtual Address of the Rx descriptor
  1071. */
  1072. static inline
  1073. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  1074. struct hal_buf_info *buf_info)
  1075. {
  1076. void *link_desc_va;
  1077. struct qdf_mem_multi_page_t *pages;
  1078. uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
  1079. pages = &soc->link_desc_pages;
  1080. if (!pages)
  1081. return NULL;
  1082. if (qdf_unlikely(page_id >= pages->num_pages))
  1083. return NULL;
  1084. link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
  1085. (buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
  1086. return link_desc_va;
  1087. }
  1088. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1089. #ifdef DISABLE_EAPOL_INTRABSS_FWD
  1090. #ifdef WLAN_FEATURE_11BE_MLO
  1091. static inline bool dp_nbuf_dst_addr_is_mld_addr(struct dp_vdev *vdev,
  1092. qdf_nbuf_t nbuf)
  1093. {
  1094. struct qdf_mac_addr *self_mld_mac_addr =
  1095. (struct qdf_mac_addr *)vdev->mld_mac_addr.raw;
  1096. return qdf_is_macaddr_equal(self_mld_mac_addr,
  1097. (struct qdf_mac_addr *)qdf_nbuf_data(nbuf) +
  1098. QDF_NBUF_DEST_MAC_OFFSET);
  1099. }
  1100. #else
  1101. static inline bool dp_nbuf_dst_addr_is_mld_addr(struct dp_vdev *vdev,
  1102. qdf_nbuf_t nbuf)
  1103. {
  1104. return false;
  1105. }
  1106. #endif
  1107. static inline bool dp_nbuf_dst_addr_is_self_addr(struct dp_vdev *vdev,
  1108. qdf_nbuf_t nbuf)
  1109. {
  1110. return qdf_is_macaddr_equal((struct qdf_mac_addr *)vdev->mac_addr.raw,
  1111. (struct qdf_mac_addr *)qdf_nbuf_data(nbuf) +
  1112. QDF_NBUF_DEST_MAC_OFFSET);
  1113. }
  1114. /*
  1115. * dp_rx_intrabss_eapol_drop_check() - API For EAPOL
  1116. * pkt with DA not equal to vdev mac addr, fwd is not allowed.
  1117. * @soc: core txrx main context
  1118. * @ta_txrx_peer: source peer entry
  1119. * @rx_tlv_hdr: start address of rx tlvs
  1120. * @nbuf: nbuf that has to be intrabss forwarded
  1121. *
  1122. * Return: true if it is forwarded else false
  1123. */
  1124. static inline
  1125. bool dp_rx_intrabss_eapol_drop_check(struct dp_soc *soc,
  1126. struct dp_txrx_peer *ta_txrx_peer,
  1127. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf)
  1128. {
  1129. if (qdf_unlikely(qdf_nbuf_is_ipv4_eapol_pkt(nbuf) &&
  1130. !(dp_nbuf_dst_addr_is_self_addr(ta_txrx_peer->vdev,
  1131. nbuf) ||
  1132. dp_nbuf_dst_addr_is_mld_addr(ta_txrx_peer->vdev,
  1133. nbuf)))) {
  1134. qdf_nbuf_free(nbuf);
  1135. DP_STATS_INC(soc, rx.err.intrabss_eapol_drop, 1);
  1136. return true;
  1137. }
  1138. return false;
  1139. }
  1140. #else /* DISABLE_EAPOL_INTRABSS_FWD */
  1141. static inline
  1142. bool dp_rx_intrabss_eapol_drop_check(struct dp_soc *soc,
  1143. struct dp_txrx_peer *ta_txrx_peer,
  1144. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf)
  1145. {
  1146. return false;
  1147. }
  1148. #endif /* DISABLE_EAPOL_INTRABSS_FWD */
  1149. bool dp_rx_intrabss_mcbc_fwd(struct dp_soc *soc,
  1150. struct dp_txrx_peer *ta_txrx_peer,
  1151. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf,
  1152. struct cdp_tid_rx_stats *tid_stats);
  1153. bool dp_rx_intrabss_ucast_fwd(struct dp_soc *soc,
  1154. struct dp_txrx_peer *ta_txrx_peer,
  1155. uint8_t tx_vdev_id,
  1156. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf,
  1157. struct cdp_tid_rx_stats *tid_stats);
  1158. /**
  1159. * dp_rx_defrag_concat() - Concatenate the fragments
  1160. *
  1161. * @dst: destination pointer to the buffer
  1162. * @src: source pointer from where the fragment payload is to be copied
  1163. *
  1164. * Return: QDF_STATUS
  1165. */
  1166. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  1167. {
  1168. /*
  1169. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  1170. * to provide space for src, the headroom portion is copied from
  1171. * the original dst buffer to the larger new dst buffer.
  1172. * (This is needed, because the headroom of the dst buffer
  1173. * contains the rx desc.)
  1174. */
  1175. if (!qdf_nbuf_cat(dst, src)) {
  1176. /*
  1177. * qdf_nbuf_cat does not free the src memory.
  1178. * Free src nbuf before returning
  1179. * For failure case the caller takes of freeing the nbuf
  1180. */
  1181. qdf_nbuf_free(src);
  1182. return QDF_STATUS_SUCCESS;
  1183. }
  1184. return QDF_STATUS_E_DEFRAG_ERROR;
  1185. }
  1186. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1187. #ifndef FEATURE_WDS
  1188. void dp_rx_da_learn(struct dp_soc *soc, uint8_t *rx_tlv_hdr,
  1189. struct dp_txrx_peer *ta_txrx_peer, qdf_nbuf_t nbuf);
  1190. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  1191. {
  1192. return QDF_STATUS_SUCCESS;
  1193. }
  1194. static inline void
  1195. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  1196. uint8_t *rx_tlv_hdr,
  1197. struct dp_txrx_peer *txrx_peer,
  1198. qdf_nbuf_t nbuf,
  1199. struct hal_rx_msdu_metadata msdu_metadata)
  1200. {
  1201. }
  1202. static inline void
  1203. dp_rx_ipa_wds_srcport_learn(struct dp_soc *soc,
  1204. struct dp_peer *ta_peer, qdf_nbuf_t nbuf,
  1205. struct hal_rx_msdu_metadata msdu_end_info,
  1206. bool ad4_valid, bool chfrag_start)
  1207. {
  1208. }
  1209. #endif
  1210. /*
  1211. * dp_rx_desc_dump() - dump the sw rx descriptor
  1212. *
  1213. * @rx_desc: sw rx descriptor
  1214. */
  1215. static inline void dp_rx_desc_dump(struct dp_rx_desc *rx_desc)
  1216. {
  1217. dp_info("rx_desc->nbuf: %pK, rx_desc->cookie: %d, rx_desc->pool_id: %d, rx_desc->in_use: %d, rx_desc->unmapped: %d",
  1218. rx_desc->nbuf, rx_desc->cookie, rx_desc->pool_id,
  1219. rx_desc->in_use, rx_desc->unmapped);
  1220. }
  1221. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1222. /*
  1223. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  1224. * In qwrap mode, packets originated from
  1225. * any vdev should not loopback and
  1226. * should be dropped.
  1227. * @vdev: vdev on which rx packet is received
  1228. * @nbuf: rx pkt
  1229. *
  1230. */
  1231. #if ATH_SUPPORT_WRAP
  1232. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1233. qdf_nbuf_t nbuf)
  1234. {
  1235. struct dp_vdev *psta_vdev;
  1236. struct dp_pdev *pdev = vdev->pdev;
  1237. uint8_t *data = qdf_nbuf_data(nbuf);
  1238. if (qdf_unlikely(vdev->proxysta_vdev)) {
  1239. /* In qwrap isolation mode, allow loopback packets as all
  1240. * packets go to RootAP and Loopback on the mpsta.
  1241. */
  1242. if (vdev->isolation_vdev)
  1243. return false;
  1244. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  1245. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  1246. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  1247. &data[QDF_MAC_ADDR_SIZE],
  1248. QDF_MAC_ADDR_SIZE))) {
  1249. /* Drop packet if source address is equal to
  1250. * any of the vdev addresses.
  1251. */
  1252. return true;
  1253. }
  1254. }
  1255. }
  1256. return false;
  1257. }
  1258. #else
  1259. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1260. qdf_nbuf_t nbuf)
  1261. {
  1262. return false;
  1263. }
  1264. #endif
  1265. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1266. #if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
  1267. defined(WLAN_SUPPORT_RX_TAG_STATISTICS) ||\
  1268. defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1269. #include "dp_rx_tag.h"
  1270. #endif
  1271. #if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\
  1272. !defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1273. /**
  1274. * dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
  1275. * and set the corresponding tag in QDF packet
  1276. * @soc: core txrx main context
  1277. * @vdev: vdev on which the packet is received
  1278. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1279. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  1280. * @ring_index: REO ring number, not used for error & monitor ring
  1281. * @is_reo_exception: flag to indicate if rx from REO ring or exception ring
  1282. * @is_update_stats: flag to indicate whether to update stats or not
  1283. * Return: void
  1284. */
  1285. static inline void
  1286. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1287. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  1288. uint16_t ring_index,
  1289. bool is_reo_exception, bool is_update_stats)
  1290. {
  1291. }
  1292. #endif
  1293. #ifndef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  1294. /**
  1295. * dp_rx_err_cce_drop() - Reads CCE metadata from the RX MSDU end TLV
  1296. * and returns whether cce metadata matches
  1297. * @soc: core txrx main context
  1298. * @vdev: vdev on which the packet is received
  1299. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1300. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  1301. * Return: bool
  1302. */
  1303. static inline bool
  1304. dp_rx_err_cce_drop(struct dp_soc *soc, struct dp_vdev *vdev,
  1305. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr)
  1306. {
  1307. return false;
  1308. }
  1309. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  1310. #ifndef WLAN_SUPPORT_RX_FLOW_TAG
  1311. /**
  1312. * dp_rx_update_flow_tag() - Reads FSE metadata from the RX MSDU end TLV
  1313. * and set the corresponding tag in QDF packet
  1314. * @soc: core txrx main context
  1315. * @vdev: vdev on which the packet is received
  1316. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1317. * @rx_tlv_hdr: base address where the RX TLVs starts
  1318. * @is_update_stats: flag to indicate whether to update stats or not
  1319. *
  1320. * Return: void
  1321. */
  1322. static inline void
  1323. dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1324. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr, bool update_stats)
  1325. {
  1326. }
  1327. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  1328. #define CRITICAL_BUFFER_THRESHOLD 64
  1329. /*
  1330. * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  1331. * called during dp rx initialization
  1332. * and at the end of dp_rx_process.
  1333. *
  1334. * @soc: core txrx main context
  1335. * @mac_id: mac_id which is one of 3 mac_ids
  1336. * @dp_rxdma_srng: dp rxdma circular ring
  1337. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1338. * @num_req_buffers: number of buffer to be replenished
  1339. * @desc_list: list of descs if called from dp_rx_process
  1340. * or NULL during dp rx initialization or out of buffer
  1341. * interrupt.
  1342. * @tail: tail of descs list
  1343. * @func_name: name of the caller function
  1344. * Return: return success or failure
  1345. */
  1346. QDF_STATUS __dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1347. struct dp_srng *dp_rxdma_srng,
  1348. struct rx_desc_pool *rx_desc_pool,
  1349. uint32_t num_req_buffers,
  1350. union dp_rx_desc_list_elem_t **desc_list,
  1351. union dp_rx_desc_list_elem_t **tail,
  1352. const char *func_name);
  1353. /*
  1354. * __dp_rx_buffers_no_map_replenish() - replenish rxdma ring with rx nbufs
  1355. * use direct APIs to get invalidate
  1356. * and get the physical address of the
  1357. * nbuf instead of map api,called during
  1358. * dp rx initialization and at the end
  1359. * of dp_rx_process.
  1360. *
  1361. * @soc: core txrx main context
  1362. * @mac_id: mac_id which is one of 3 mac_ids
  1363. * @dp_rxdma_srng: dp rxdma circular ring
  1364. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1365. * @num_req_buffers: number of buffer to be replenished
  1366. * @desc_list: list of descs if called from dp_rx_process
  1367. * or NULL during dp rx initialization or out of buffer
  1368. * interrupt.
  1369. * @tail: tail of descs list
  1370. * Return: return success or failure
  1371. */
  1372. QDF_STATUS
  1373. __dp_rx_buffers_no_map_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1374. struct dp_srng *dp_rxdma_srng,
  1375. struct rx_desc_pool *rx_desc_pool,
  1376. uint32_t num_req_buffers,
  1377. union dp_rx_desc_list_elem_t **desc_list,
  1378. union dp_rx_desc_list_elem_t **tail);
  1379. /*
  1380. * __dp_rx_buffers_no_map__lt_replenish() - replenish rxdma ring with rx nbufs
  1381. * use direct APIs to get invalidate
  1382. * and get the physical address of the
  1383. * nbuf instead of map api,called when
  1384. * low threshold interrupt is triggered
  1385. *
  1386. * @soc: core txrx main context
  1387. * @mac_id: mac_id which is one of 3 mac_ids
  1388. * @dp_rxdma_srng: dp rxdma circular ring
  1389. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1390. * Return: return success or failure
  1391. */
  1392. QDF_STATUS
  1393. __dp_rx_buffers_no_map_lt_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1394. struct dp_srng *dp_rxdma_srng,
  1395. struct rx_desc_pool *rx_desc_pool);
  1396. /*
  1397. * __dp_pdev_rx_buffers_no_map_attach() - replenish rxdma ring with rx nbufs
  1398. * use direct APIs to get invalidate
  1399. * and get the physical address of the
  1400. * nbuf instead of map api,called during
  1401. * dp rx initialization.
  1402. *
  1403. * @soc: core txrx main context
  1404. * @mac_id: mac_id which is one of 3 mac_ids
  1405. * @dp_rxdma_srng: dp rxdma circular ring
  1406. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1407. * @num_req_buffers: number of buffer to be replenished
  1408. * Return: return success or failure
  1409. */
  1410. QDF_STATUS __dp_pdev_rx_buffers_no_map_attach(struct dp_soc *dp_soc,
  1411. uint32_t mac_id,
  1412. struct dp_srng *dp_rxdma_srng,
  1413. struct rx_desc_pool *rx_desc_pool,
  1414. uint32_t num_req_buffers);
  1415. /*
  1416. * dp_pdev_rx_buffers_attach() - replenish rxdma ring with rx nbufs
  1417. * called during dp rx initialization
  1418. *
  1419. * @soc: core txrx main context
  1420. * @mac_id: mac_id which is one of 3 mac_ids
  1421. * @dp_rxdma_srng: dp rxdma circular ring
  1422. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1423. * @num_req_buffers: number of buffer to be replenished
  1424. *
  1425. * Return: return success or failure
  1426. */
  1427. QDF_STATUS
  1428. dp_pdev_rx_buffers_attach(struct dp_soc *dp_soc, uint32_t mac_id,
  1429. struct dp_srng *dp_rxdma_srng,
  1430. struct rx_desc_pool *rx_desc_pool,
  1431. uint32_t num_req_buffers);
  1432. /**
  1433. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  1434. * (WBM), following error handling
  1435. *
  1436. * @soc: core DP main context
  1437. * @buf_addr_info: opaque pointer to the REO error ring descriptor
  1438. * @buf_addr_info: void pointer to the buffer_addr_info
  1439. * @bm_action: put to idle_list or release to msdu_list
  1440. *
  1441. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  1442. */
  1443. QDF_STATUS
  1444. dp_rx_link_desc_return(struct dp_soc *soc, hal_ring_desc_t ring_desc,
  1445. uint8_t bm_action);
  1446. /**
  1447. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  1448. * (WBM) by address
  1449. *
  1450. * @soc: core DP main context
  1451. * @link_desc_addr: link descriptor addr
  1452. *
  1453. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  1454. */
  1455. QDF_STATUS
  1456. dp_rx_link_desc_return_by_addr(struct dp_soc *soc,
  1457. hal_buff_addrinfo_t link_desc_addr,
  1458. uint8_t bm_action);
  1459. /**
  1460. * dp_rxdma_err_process() - RxDMA error processing functionality
  1461. * @soc: core txrx main contex
  1462. * @mac_id: mac id which is one of 3 mac_ids
  1463. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1464. * @quota: No. of units (packets) that can be serviced in one shot.
  1465. *
  1466. * Return: num of buffers processed
  1467. */
  1468. uint32_t
  1469. dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  1470. uint32_t mac_id, uint32_t quota);
  1471. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1472. uint8_t *rx_tlv_hdr, struct dp_txrx_peer *peer);
  1473. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1474. uint8_t *rx_tlv_hdr);
  1475. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  1476. struct dp_txrx_peer *peer);
  1477. /*
  1478. * dp_rx_dump_info_and_assert() - dump RX Ring info and Rx Desc info
  1479. *
  1480. * @soc: core txrx main context
  1481. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1482. * @ring_desc: opaque pointer to the RX ring descriptor
  1483. * @rx_desc: host rx descriptor
  1484. *
  1485. * Return: void
  1486. */
  1487. void dp_rx_dump_info_and_assert(struct dp_soc *soc,
  1488. hal_ring_handle_t hal_ring_hdl,
  1489. hal_ring_desc_t ring_desc,
  1490. struct dp_rx_desc *rx_desc);
  1491. void dp_rx_compute_delay(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  1492. #ifdef QCA_PEER_EXT_STATS
  1493. void dp_rx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  1494. qdf_nbuf_t nbuf);
  1495. #endif /* QCA_PEER_EXT_STATS */
  1496. #ifdef RX_DESC_DEBUG_CHECK
  1497. /**
  1498. * dp_rx_desc_check_magic() - check the magic value in dp_rx_desc
  1499. * @rx_desc: rx descriptor pointer
  1500. *
  1501. * Return: true, if magic is correct, else false.
  1502. */
  1503. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1504. {
  1505. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC))
  1506. return false;
  1507. rx_desc->magic = 0;
  1508. return true;
  1509. }
  1510. /**
  1511. * dp_rx_desc_prep() - prepare rx desc
  1512. * @rx_desc: rx descriptor pointer to be prepared
  1513. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1514. *
  1515. * Note: assumption is that we are associating a nbuf which is mapped
  1516. *
  1517. * Return: none
  1518. */
  1519. static inline
  1520. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1521. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1522. {
  1523. rx_desc->magic = DP_RX_DESC_MAGIC;
  1524. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1525. rx_desc->unmapped = 0;
  1526. rx_desc->nbuf_data_addr = (uint8_t *)qdf_nbuf_data(rx_desc->nbuf);
  1527. }
  1528. /**
  1529. * dp_rx_desc_frag_prep() - prepare rx desc
  1530. * @rx_desc: rx descriptor pointer to be prepared
  1531. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1532. *
  1533. * Note: assumption is that we frag address is mapped
  1534. *
  1535. * Return: none
  1536. */
  1537. #ifdef DP_RX_MON_MEM_FRAG
  1538. static inline
  1539. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1540. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1541. {
  1542. rx_desc->magic = DP_RX_DESC_MAGIC;
  1543. rx_desc->rx_buf_start =
  1544. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1545. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1546. rx_desc->unmapped = 0;
  1547. }
  1548. #else
  1549. static inline
  1550. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1551. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1552. {
  1553. }
  1554. #endif /* DP_RX_MON_MEM_FRAG */
  1555. /**
  1556. * dp_rx_desc_paddr_sanity_check() - paddr sanity for ring desc vs rx_desc
  1557. * @rx_desc: rx descriptor
  1558. * @ring_paddr: paddr obatined from the ring
  1559. *
  1560. * Returns: QDF_STATUS
  1561. */
  1562. static inline
  1563. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  1564. uint64_t ring_paddr)
  1565. {
  1566. return (ring_paddr == qdf_nbuf_get_frag_paddr(rx_desc->nbuf, 0));
  1567. }
  1568. #else
  1569. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1570. {
  1571. return true;
  1572. }
  1573. static inline
  1574. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1575. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1576. {
  1577. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1578. rx_desc->unmapped = 0;
  1579. }
  1580. #ifdef DP_RX_MON_MEM_FRAG
  1581. static inline
  1582. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1583. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1584. {
  1585. rx_desc->rx_buf_start =
  1586. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1587. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1588. rx_desc->unmapped = 0;
  1589. }
  1590. #else
  1591. static inline
  1592. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1593. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1594. {
  1595. }
  1596. #endif /* DP_RX_MON_MEM_FRAG */
  1597. static inline
  1598. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  1599. uint64_t ring_paddr)
  1600. {
  1601. return true;
  1602. }
  1603. #endif /* RX_DESC_DEBUG_CHECK */
  1604. void dp_rx_enable_mon_dest_frag(struct rx_desc_pool *rx_desc_pool,
  1605. bool is_mon_dest_desc);
  1606. void dp_rx_process_rxdma_err(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1607. uint8_t *rx_tlv_hdr, struct dp_txrx_peer *peer,
  1608. uint8_t err_code, uint8_t mac_id);
  1609. #ifndef QCA_MULTIPASS_SUPPORT
  1610. static inline
  1611. bool dp_rx_multipass_process(struct dp_txrx_peer *peer, qdf_nbuf_t nbuf,
  1612. uint8_t tid)
  1613. {
  1614. return false;
  1615. }
  1616. #else
  1617. bool dp_rx_multipass_process(struct dp_txrx_peer *peer, qdf_nbuf_t nbuf,
  1618. uint8_t tid);
  1619. #endif
  1620. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1621. #ifndef WLAN_RX_PKT_CAPTURE_ENH
  1622. static inline
  1623. QDF_STATUS dp_peer_set_rx_capture_enabled(struct dp_pdev *pdev,
  1624. struct dp_peer *peer_handle,
  1625. bool value, uint8_t *mac_addr)
  1626. {
  1627. return QDF_STATUS_SUCCESS;
  1628. }
  1629. #endif
  1630. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1631. /**
  1632. * dp_rx_deliver_to_stack() - deliver pkts to network stack
  1633. * Caller to hold peer refcount and check for valid peer
  1634. * @soc: soc
  1635. * @vdev: vdev
  1636. * @txrx_peer: txrx peer
  1637. * @nbuf_head: skb list head
  1638. * @nbuf_tail: skb list tail
  1639. *
  1640. * Return: QDF_STATUS
  1641. */
  1642. QDF_STATUS dp_rx_deliver_to_stack(struct dp_soc *soc,
  1643. struct dp_vdev *vdev,
  1644. struct dp_txrx_peer *peer,
  1645. qdf_nbuf_t nbuf_head,
  1646. qdf_nbuf_t nbuf_tail);
  1647. #ifdef QCA_SUPPORT_EAPOL_OVER_CONTROL_PORT
  1648. /**
  1649. * dp_rx_eapol_deliver_to_stack() - deliver pkts to network stack
  1650. * caller to hold peer refcount and check for valid peer
  1651. * @soc: soc
  1652. * @vdev: vdev
  1653. * @peer: peer
  1654. * @nbuf_head: skb list head
  1655. * @nbuf_tail: skb list tail
  1656. *
  1657. * return: QDF_STATUS
  1658. */
  1659. QDF_STATUS dp_rx_eapol_deliver_to_stack(struct dp_soc *soc,
  1660. struct dp_vdev *vdev,
  1661. struct dp_txrx_peer *peer,
  1662. qdf_nbuf_t nbuf_head,
  1663. qdf_nbuf_t nbuf_tail);
  1664. #endif
  1665. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1666. #ifdef QCA_OL_RX_LOCK_LESS_ACCESS
  1667. /*
  1668. * dp_rx_ring_access_start()- Wrapper function to log access start of a hal ring
  1669. * @int_ctx: pointer to DP interrupt context
  1670. * @dp_soc - DP soc structure pointer
  1671. * @hal_ring_hdl - HAL ring handle
  1672. *
  1673. * Return: 0 on success; error on failure
  1674. */
  1675. static inline int
  1676. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  1677. hal_ring_handle_t hal_ring_hdl)
  1678. {
  1679. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  1680. }
  1681. /*
  1682. * dp_rx_ring_access_end()- Wrapper function to log access end of a hal ring
  1683. * @int_ctx: pointer to DP interrupt context
  1684. * @dp_soc - DP soc structure pointer
  1685. * @hal_ring_hdl - HAL ring handle
  1686. *
  1687. * Return - None
  1688. */
  1689. static inline void
  1690. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  1691. hal_ring_handle_t hal_ring_hdl)
  1692. {
  1693. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  1694. }
  1695. #else
  1696. static inline int
  1697. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  1698. hal_ring_handle_t hal_ring_hdl)
  1699. {
  1700. return dp_srng_access_start(int_ctx, soc, hal_ring_hdl);
  1701. }
  1702. static inline void
  1703. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  1704. hal_ring_handle_t hal_ring_hdl)
  1705. {
  1706. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  1707. }
  1708. #endif
  1709. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1710. /*
  1711. * dp_rx_wbm_sg_list_reset() - Initialize sg list
  1712. *
  1713. * This api should be called at soc init and afterevery sg processing.
  1714. *@soc: DP SOC handle
  1715. */
  1716. static inline void dp_rx_wbm_sg_list_reset(struct dp_soc *soc)
  1717. {
  1718. if (soc) {
  1719. soc->wbm_sg_param.wbm_is_first_msdu_in_sg = false;
  1720. soc->wbm_sg_param.wbm_sg_nbuf_head = NULL;
  1721. soc->wbm_sg_param.wbm_sg_nbuf_tail = NULL;
  1722. soc->wbm_sg_param.wbm_sg_desc_msdu_len = 0;
  1723. }
  1724. }
  1725. /*
  1726. * dp_rx_wbm_sg_list_deinit() - De-initialize sg list
  1727. *
  1728. * This api should be called in down path, to avoid any leak.
  1729. *@soc: DP SOC handle
  1730. */
  1731. static inline void dp_rx_wbm_sg_list_deinit(struct dp_soc *soc)
  1732. {
  1733. if (soc) {
  1734. if (soc->wbm_sg_param.wbm_sg_nbuf_head)
  1735. qdf_nbuf_list_free(soc->wbm_sg_param.wbm_sg_nbuf_head);
  1736. dp_rx_wbm_sg_list_reset(soc);
  1737. }
  1738. }
  1739. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1740. #ifdef WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL
  1741. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1742. do { \
  1743. if (!soc->rx_buff_pool[rx_desc->pool_id].is_initialized) { \
  1744. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf); \
  1745. break; \
  1746. } \
  1747. DP_RX_LIST_APPEND(ebuf_head, ebuf_tail, rx_desc->nbuf); \
  1748. if (!qdf_nbuf_is_rx_chfrag_cont(rx_desc->nbuf)) { \
  1749. if (!dp_rx_buffer_pool_refill(soc, ebuf_head, \
  1750. rx_desc->pool_id)) \
  1751. DP_RX_MERGE_TWO_LIST(head, tail, \
  1752. ebuf_head, ebuf_tail);\
  1753. ebuf_head = NULL; \
  1754. ebuf_tail = NULL; \
  1755. } \
  1756. } while (0)
  1757. #else
  1758. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1759. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf)
  1760. #endif /* WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL */
  1761. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1762. /*
  1763. * dp_rx_link_desc_refill_duplicate_check() - check if link desc duplicate
  1764. to refill
  1765. * @soc: DP SOC handle
  1766. * @buf_info: the last link desc buf info
  1767. * @ring_buf_info: current buf address pointor including link desc
  1768. *
  1769. * return: none.
  1770. */
  1771. void dp_rx_link_desc_refill_duplicate_check(
  1772. struct dp_soc *soc,
  1773. struct hal_buf_info *buf_info,
  1774. hal_buff_addrinfo_t ring_buf_info);
  1775. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  1776. /**
  1777. * dp_rx_deliver_to_pkt_capture() - deliver rx packet to packet capture
  1778. * @soc : dp_soc handle
  1779. * @pdev: dp_pdev handle
  1780. * @peer_id: peer_id of the peer for which completion came
  1781. * @ppdu_id: ppdu_id
  1782. * @netbuf: Buffer pointer
  1783. *
  1784. * This function is used to deliver rx packet to packet capture
  1785. */
  1786. void dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1787. uint16_t peer_id, uint32_t is_offload,
  1788. qdf_nbuf_t netbuf);
  1789. void dp_rx_deliver_to_pkt_capture_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1790. uint32_t is_offload);
  1791. #else
  1792. static inline void
  1793. dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1794. uint16_t peer_id, uint32_t is_offload,
  1795. qdf_nbuf_t netbuf)
  1796. {
  1797. }
  1798. static inline void
  1799. dp_rx_deliver_to_pkt_capture_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1800. uint32_t is_offload)
  1801. {
  1802. }
  1803. #endif
  1804. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1805. #ifdef FEATURE_MEC
  1806. /**
  1807. * dp_rx_mcast_echo_check() - check if the mcast pkt is a loop
  1808. * back on same vap or a different vap.
  1809. * @soc: core DP main context
  1810. * @peer: dp peer handler
  1811. * @rx_tlv_hdr: start of the rx TLV header
  1812. * @nbuf: pkt buffer
  1813. *
  1814. * Return: bool (true if it is a looped back pkt else false)
  1815. *
  1816. */
  1817. bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  1818. struct dp_txrx_peer *peer,
  1819. uint8_t *rx_tlv_hdr,
  1820. qdf_nbuf_t nbuf);
  1821. #else
  1822. static inline bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  1823. struct dp_txrx_peer *peer,
  1824. uint8_t *rx_tlv_hdr,
  1825. qdf_nbuf_t nbuf)
  1826. {
  1827. return false;
  1828. }
  1829. #endif /* FEATURE_MEC */
  1830. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1831. #ifdef RECEIVE_OFFLOAD
  1832. void dp_rx_fill_gro_info(struct dp_soc *soc, uint8_t *rx_tlv,
  1833. qdf_nbuf_t msdu, uint32_t *rx_ol_pkt_cnt);
  1834. #else
  1835. static inline
  1836. void dp_rx_fill_gro_info(struct dp_soc *soc, uint8_t *rx_tlv,
  1837. qdf_nbuf_t msdu, uint32_t *rx_ol_pkt_cnt)
  1838. {
  1839. }
  1840. #endif
  1841. void dp_rx_msdu_stats_update(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1842. uint8_t *rx_tlv_hdr, struct dp_txrx_peer *peer,
  1843. uint8_t ring_id,
  1844. struct cdp_tid_rx_stats *tid_stats);
  1845. void dp_rx_deliver_to_stack_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf);
  1846. uint32_t dp_rx_srng_get_num_pending(hal_soc_handle_t hal_soc,
  1847. hal_ring_handle_t hal_ring_hdl,
  1848. uint32_t num_entries,
  1849. bool *near_full);
  1850. #ifdef WLAN_FEATURE_DP_RX_RING_HISTORY
  1851. void dp_rx_ring_record_entry(struct dp_soc *soc, uint8_t ring_num,
  1852. hal_ring_desc_t ring_desc);
  1853. #else
  1854. static inline void
  1855. dp_rx_ring_record_entry(struct dp_soc *soc, uint8_t ring_num,
  1856. hal_ring_desc_t ring_desc)
  1857. {
  1858. }
  1859. #endif
  1860. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1861. #ifdef RX_DESC_SANITY_WAR
  1862. QDF_STATUS dp_rx_desc_sanity(struct dp_soc *soc, hal_soc_handle_t hal_soc,
  1863. hal_ring_handle_t hal_ring_hdl,
  1864. hal_ring_desc_t ring_desc,
  1865. struct dp_rx_desc *rx_desc);
  1866. #else
  1867. static inline
  1868. QDF_STATUS dp_rx_desc_sanity(struct dp_soc *soc, hal_soc_handle_t hal_soc,
  1869. hal_ring_handle_t hal_ring_hdl,
  1870. hal_ring_desc_t ring_desc,
  1871. struct dp_rx_desc *rx_desc)
  1872. {
  1873. return QDF_STATUS_SUCCESS;
  1874. }
  1875. #endif
  1876. #ifdef DP_RX_DROP_RAW_FRM
  1877. bool dp_rx_is_raw_frame_dropped(qdf_nbuf_t nbuf);
  1878. #else
  1879. static inline
  1880. bool dp_rx_is_raw_frame_dropped(qdf_nbuf_t nbuf)
  1881. {
  1882. return false;
  1883. }
  1884. #endif
  1885. #ifdef RX_DESC_DEBUG_CHECK
  1886. QDF_STATUS dp_rx_desc_nbuf_sanity_check(struct dp_soc *soc,
  1887. hal_ring_desc_t ring_desc,
  1888. struct dp_rx_desc *rx_desc);
  1889. #else
  1890. static inline
  1891. QDF_STATUS dp_rx_desc_nbuf_sanity_check(struct dp_soc *soc,
  1892. hal_ring_desc_t ring_desc,
  1893. struct dp_rx_desc *rx_desc)
  1894. {
  1895. return QDF_STATUS_SUCCESS;
  1896. }
  1897. #endif
  1898. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  1899. void dp_rx_update_stats(struct dp_soc *soc, qdf_nbuf_t nbuf);
  1900. #else
  1901. static inline
  1902. void dp_rx_update_stats(struct dp_soc *soc, qdf_nbuf_t nbuf)
  1903. {
  1904. }
  1905. #endif
  1906. /**
  1907. * dp_rx_cksum_offload() - set the nbuf checksum as defined by hardware.
  1908. * @nbuf: pointer to the first msdu of an amsdu.
  1909. * @rx_tlv_hdr: pointer to the start of RX TLV headers.
  1910. *
  1911. * The ipsumed field of the skb is set based on whether HW validated the
  1912. * IP/TCP/UDP checksum.
  1913. *
  1914. * Return: void
  1915. */
  1916. static inline
  1917. void dp_rx_cksum_offload(struct dp_pdev *pdev,
  1918. qdf_nbuf_t nbuf,
  1919. uint8_t *rx_tlv_hdr)
  1920. {
  1921. qdf_nbuf_rx_cksum_t cksum = {0};
  1922. //TODO - Move this to ring desc api
  1923. //HAL_RX_MSDU_DESC_IP_CHKSUM_FAIL_GET
  1924. //HAL_RX_MSDU_DESC_TCP_UDP_CHKSUM_FAIL_GET
  1925. uint32_t ip_csum_err, tcp_udp_csum_er;
  1926. hal_rx_tlv_csum_err_get(pdev->soc->hal_soc, rx_tlv_hdr, &ip_csum_err,
  1927. &tcp_udp_csum_er);
  1928. if (qdf_likely(!ip_csum_err && !tcp_udp_csum_er)) {
  1929. cksum.l4_result = QDF_NBUF_RX_CKSUM_TCP_UDP_UNNECESSARY;
  1930. qdf_nbuf_set_rx_cksum(nbuf, &cksum);
  1931. } else {
  1932. DP_STATS_INCC(pdev, err.ip_csum_err, 1, ip_csum_err);
  1933. DP_STATS_INCC(pdev, err.tcp_udp_csum_err, 1, tcp_udp_csum_er);
  1934. }
  1935. }
  1936. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1937. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  1938. static inline
  1939. bool dp_rx_reap_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  1940. int max_reap_limit)
  1941. {
  1942. bool limit_hit = false;
  1943. limit_hit =
  1944. (num_reaped >= max_reap_limit) ? true : false;
  1945. if (limit_hit)
  1946. DP_STATS_INC(soc, rx.reap_loop_pkt_limit_hit, 1)
  1947. return limit_hit;
  1948. }
  1949. static inline
  1950. bool dp_rx_enable_eol_data_check(struct dp_soc *soc)
  1951. {
  1952. return soc->wlan_cfg_ctx->rx_enable_eol_data_check;
  1953. }
  1954. static inline int dp_rx_get_loop_pkt_limit(struct dp_soc *soc)
  1955. {
  1956. struct wlan_cfg_dp_soc_ctxt *cfg = soc->wlan_cfg_ctx;
  1957. return cfg->rx_reap_loop_pkt_limit;
  1958. }
  1959. #else
  1960. static inline
  1961. bool dp_rx_reap_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  1962. int max_reap_limit)
  1963. {
  1964. return false;
  1965. }
  1966. static inline
  1967. bool dp_rx_enable_eol_data_check(struct dp_soc *soc)
  1968. {
  1969. return false;
  1970. }
  1971. static inline int dp_rx_get_loop_pkt_limit(struct dp_soc *soc)
  1972. {
  1973. return 0;
  1974. }
  1975. #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */
  1976. void dp_rx_update_stats(struct dp_soc *soc, qdf_nbuf_t nbuf);
  1977. #ifdef QCA_SUPPORT_WDS_EXTENDED
  1978. /**
  1979. * dp_rx_is_list_ready() - Make different lists for 4-address
  1980. and 3-address frames
  1981. * @nbuf_head: skb list head
  1982. * @vdev: vdev
  1983. * @txrx_peer : txrx_peer
  1984. * @peer_id: peer id of new received frame
  1985. * @vdev_id: vdev_id of new received frame
  1986. *
  1987. * Return: true if peer_ids are different.
  1988. */
  1989. static inline bool
  1990. dp_rx_is_list_ready(qdf_nbuf_t nbuf_head,
  1991. struct dp_vdev *vdev,
  1992. struct dp_txrx_peer *txrx_peer,
  1993. uint16_t peer_id,
  1994. uint8_t vdev_id)
  1995. {
  1996. if (nbuf_head && txrx_peer && txrx_peer->peer_id != peer_id)
  1997. return true;
  1998. return false;
  1999. }
  2000. #else
  2001. static inline bool
  2002. dp_rx_is_list_ready(qdf_nbuf_t nbuf_head,
  2003. struct dp_vdev *vdev,
  2004. struct dp_txrx_peer *txrx_peer,
  2005. uint16_t peer_id,
  2006. uint8_t vdev_id)
  2007. {
  2008. if (nbuf_head && vdev && (vdev->vdev_id != vdev_id))
  2009. return true;
  2010. return false;
  2011. }
  2012. #endif
  2013. #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
  2014. /**
  2015. * dp_rx_mark_first_packet_after_wow_wakeup - get first packet after wow wakeup
  2016. * @pdev: pointer to dp_pdev structure
  2017. * @rx_tlv: pointer to rx_pkt_tlvs structure
  2018. * @nbuf: pointer to skb buffer
  2019. *
  2020. * Return: None
  2021. */
  2022. void dp_rx_mark_first_packet_after_wow_wakeup(struct dp_pdev *pdev,
  2023. uint8_t *rx_tlv,
  2024. qdf_nbuf_t nbuf);
  2025. #else
  2026. static inline void
  2027. dp_rx_mark_first_packet_after_wow_wakeup(struct dp_pdev *pdev,
  2028. uint8_t *rx_tlv,
  2029. qdf_nbuf_t nbuf)
  2030. {
  2031. }
  2032. #endif
  2033. #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
  2034. static inline uint8_t
  2035. dp_rx_get_defrag_bm_id(struct dp_soc *soc)
  2036. {
  2037. return DP_DEFRAG_RBM(soc->wbm_sw0_bm_id);
  2038. }
  2039. static inline uint8_t
  2040. dp_rx_get_rx_bm_id(struct dp_soc *soc)
  2041. {
  2042. return DP_WBM2SW_RBM(soc->wbm_sw0_bm_id);
  2043. }
  2044. #else
  2045. static inline uint8_t
  2046. dp_rx_get_rx_bm_id(struct dp_soc *soc)
  2047. {
  2048. struct wlan_cfg_dp_soc_ctxt *cfg_ctx = soc->wlan_cfg_ctx;
  2049. uint8_t wbm2_sw_rx_rel_ring_id;
  2050. wbm2_sw_rx_rel_ring_id = wlan_cfg_get_rx_rel_ring_id(cfg_ctx);
  2051. return HAL_RX_BUF_RBM_SW_BM(soc->wbm_sw0_bm_id,
  2052. wbm2_sw_rx_rel_ring_id);
  2053. }
  2054. static inline uint8_t
  2055. dp_rx_get_defrag_bm_id(struct dp_soc *soc)
  2056. {
  2057. return dp_rx_get_rx_bm_id(soc);
  2058. }
  2059. #endif
  2060. static inline uint16_t
  2061. dp_rx_peer_metadata_peer_id_get(struct dp_soc *soc, uint32_t peer_metadata)
  2062. {
  2063. return soc->arch_ops.dp_rx_peer_metadata_peer_id_get(soc,
  2064. peer_metadata);
  2065. }
  2066. /**
  2067. * dp_rx_desc_pool_init_generic() - Generic Rx descriptors initialization
  2068. * @soc: SOC handle
  2069. * @rx_desc_pool: pointer to RX descriptor pool
  2070. * @pool_id: pool ID
  2071. *
  2072. * Return: None
  2073. */
  2074. QDF_STATUS dp_rx_desc_pool_init_generic(struct dp_soc *soc,
  2075. struct rx_desc_pool *rx_desc_pool,
  2076. uint32_t pool_id);
  2077. void dp_rx_desc_pool_deinit_generic(struct dp_soc *soc,
  2078. struct rx_desc_pool *rx_desc_pool,
  2079. uint32_t pool_id);
  2080. /**
  2081. * dp_rx_pkt_tracepoints_enabled() - Get the state of rx pkt tracepoint
  2082. *
  2083. * Return: True if any rx pkt tracepoint is enabled else false
  2084. */
  2085. static inline
  2086. bool dp_rx_pkt_tracepoints_enabled(void)
  2087. {
  2088. return (qdf_trace_dp_rx_tcp_pkt_enabled() ||
  2089. qdf_trace_dp_rx_udp_pkt_enabled() ||
  2090. qdf_trace_dp_rx_pkt_enabled());
  2091. }
  2092. #if defined(QCA_DP_RX_NBUF_NO_MAP_UNMAP) && !defined(BUILD_X86)
  2093. static inline
  2094. QDF_STATUS dp_pdev_rx_buffers_attach_simple(struct dp_soc *soc, uint32_t mac_id,
  2095. struct dp_srng *rxdma_srng,
  2096. struct rx_desc_pool *rx_desc_pool,
  2097. uint32_t num_req_buffers)
  2098. {
  2099. return __dp_pdev_rx_buffers_no_map_attach(soc, mac_id,
  2100. rxdma_srng,
  2101. rx_desc_pool,
  2102. num_req_buffers);
  2103. }
  2104. static inline
  2105. void dp_rx_buffers_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2106. struct dp_srng *rxdma_srng,
  2107. struct rx_desc_pool *rx_desc_pool,
  2108. uint32_t num_req_buffers,
  2109. union dp_rx_desc_list_elem_t **desc_list,
  2110. union dp_rx_desc_list_elem_t **tail)
  2111. {
  2112. __dp_rx_buffers_no_map_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2113. num_req_buffers, desc_list, tail);
  2114. }
  2115. static inline
  2116. void dp_rx_buffers_lt_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2117. struct dp_srng *rxdma_srng,
  2118. struct rx_desc_pool *rx_desc_pool,
  2119. uint32_t num_req_buffers,
  2120. union dp_rx_desc_list_elem_t **desc_list,
  2121. union dp_rx_desc_list_elem_t **tail)
  2122. {
  2123. __dp_rx_buffers_no_map_lt_replenish(soc, mac_id, rxdma_srng,
  2124. rx_desc_pool);
  2125. }
  2126. static inline
  2127. qdf_dma_addr_t dp_rx_nbuf_sync_no_dsb(struct dp_soc *dp_soc,
  2128. qdf_nbuf_t nbuf,
  2129. uint32_t buf_size)
  2130. {
  2131. qdf_nbuf_dma_inv_range_no_dsb((void *)nbuf->data,
  2132. (void *)(nbuf->data + buf_size));
  2133. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  2134. }
  2135. static inline
  2136. qdf_dma_addr_t dp_rx_nbuf_sync(struct dp_soc *dp_soc,
  2137. qdf_nbuf_t nbuf,
  2138. uint32_t buf_size)
  2139. {
  2140. qdf_nbuf_dma_inv_range((void *)nbuf->data,
  2141. (void *)(nbuf->data + buf_size));
  2142. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  2143. }
  2144. #if !defined(SPECULATIVE_READ_DISABLED)
  2145. static inline
  2146. void dp_rx_nbuf_unmap(struct dp_soc *soc,
  2147. struct dp_rx_desc *rx_desc,
  2148. uint8_t reo_ring_num)
  2149. {
  2150. struct rx_desc_pool *rx_desc_pool;
  2151. qdf_nbuf_t nbuf;
  2152. rx_desc_pool = &soc->rx_desc_buf[rx_desc->pool_id];
  2153. nbuf = rx_desc->nbuf;
  2154. qdf_nbuf_dma_inv_range_no_dsb((void *)nbuf->data,
  2155. (void *)(nbuf->data + rx_desc_pool->buf_size));
  2156. }
  2157. static inline
  2158. void dp_rx_nbuf_unmap_pool(struct dp_soc *soc,
  2159. struct rx_desc_pool *rx_desc_pool,
  2160. qdf_nbuf_t nbuf)
  2161. {
  2162. qdf_nbuf_dma_inv_range((void *)nbuf->data,
  2163. (void *)(nbuf->data + rx_desc_pool->buf_size));
  2164. }
  2165. #else
  2166. static inline
  2167. void dp_rx_nbuf_unmap(struct dp_soc *soc,
  2168. struct dp_rx_desc *rx_desc,
  2169. uint8_t reo_ring_num)
  2170. {
  2171. }
  2172. static inline
  2173. void dp_rx_nbuf_unmap_pool(struct dp_soc *soc,
  2174. struct rx_desc_pool *rx_desc_pool,
  2175. qdf_nbuf_t nbuf)
  2176. {
  2177. }
  2178. #endif
  2179. static inline
  2180. void dp_rx_per_core_stats_update(struct dp_soc *soc, uint8_t ring_id,
  2181. uint32_t bufs_reaped)
  2182. {
  2183. }
  2184. static inline
  2185. qdf_nbuf_t dp_rx_nbuf_alloc(struct dp_soc *soc,
  2186. struct rx_desc_pool *rx_desc_pool)
  2187. {
  2188. return qdf_nbuf_alloc_simple(soc->osdev, rx_desc_pool->buf_size,
  2189. RX_BUFFER_RESERVATION,
  2190. rx_desc_pool->buf_alignment, FALSE);
  2191. }
  2192. static inline
  2193. void dp_rx_nbuf_free(qdf_nbuf_t nbuf)
  2194. {
  2195. qdf_nbuf_free_simple(nbuf);
  2196. }
  2197. #else
  2198. static inline
  2199. QDF_STATUS dp_pdev_rx_buffers_attach_simple(struct dp_soc *soc, uint32_t mac_id,
  2200. struct dp_srng *rxdma_srng,
  2201. struct rx_desc_pool *rx_desc_pool,
  2202. uint32_t num_req_buffers)
  2203. {
  2204. return dp_pdev_rx_buffers_attach(soc, mac_id,
  2205. rxdma_srng,
  2206. rx_desc_pool,
  2207. num_req_buffers);
  2208. }
  2209. static inline
  2210. void dp_rx_buffers_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2211. struct dp_srng *rxdma_srng,
  2212. struct rx_desc_pool *rx_desc_pool,
  2213. uint32_t num_req_buffers,
  2214. union dp_rx_desc_list_elem_t **desc_list,
  2215. union dp_rx_desc_list_elem_t **tail)
  2216. {
  2217. dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2218. num_req_buffers, desc_list, tail);
  2219. }
  2220. static inline
  2221. void dp_rx_buffers_lt_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2222. struct dp_srng *rxdma_srng,
  2223. struct rx_desc_pool *rx_desc_pool,
  2224. uint32_t num_req_buffers,
  2225. union dp_rx_desc_list_elem_t **desc_list,
  2226. union dp_rx_desc_list_elem_t **tail)
  2227. {
  2228. dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2229. num_req_buffers, desc_list, tail);
  2230. }
  2231. static inline
  2232. qdf_dma_addr_t dp_rx_nbuf_sync_no_dsb(struct dp_soc *dp_soc,
  2233. qdf_nbuf_t nbuf,
  2234. uint32_t buf_size)
  2235. {
  2236. return (qdf_dma_addr_t)NULL;
  2237. }
  2238. static inline
  2239. qdf_dma_addr_t dp_rx_nbuf_sync(struct dp_soc *dp_soc,
  2240. qdf_nbuf_t nbuf,
  2241. uint32_t buf_size)
  2242. {
  2243. return (qdf_dma_addr_t)NULL;
  2244. }
  2245. static inline
  2246. void dp_rx_nbuf_unmap(struct dp_soc *soc,
  2247. struct dp_rx_desc *rx_desc,
  2248. uint8_t reo_ring_num)
  2249. {
  2250. struct rx_desc_pool *rx_desc_pool;
  2251. rx_desc_pool = &soc->rx_desc_buf[rx_desc->pool_id];
  2252. dp_ipa_reo_ctx_buf_mapping_lock(soc, reo_ring_num);
  2253. dp_ipa_handle_rx_buf_smmu_mapping(soc, rx_desc->nbuf,
  2254. rx_desc_pool->buf_size,
  2255. false);
  2256. qdf_nbuf_unmap_nbytes_single(soc->osdev, rx_desc->nbuf,
  2257. QDF_DMA_FROM_DEVICE,
  2258. rx_desc_pool->buf_size);
  2259. dp_ipa_reo_ctx_buf_mapping_unlock(soc, reo_ring_num);
  2260. }
  2261. static inline
  2262. void dp_rx_nbuf_unmap_pool(struct dp_soc *soc,
  2263. struct rx_desc_pool *rx_desc_pool,
  2264. qdf_nbuf_t nbuf)
  2265. {
  2266. dp_ipa_handle_rx_buf_smmu_mapping(soc, nbuf, rx_desc_pool->buf_size,
  2267. false);
  2268. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf, QDF_DMA_FROM_DEVICE,
  2269. rx_desc_pool->buf_size);
  2270. }
  2271. static inline
  2272. void dp_rx_per_core_stats_update(struct dp_soc *soc, uint8_t ring_id,
  2273. uint32_t bufs_reaped)
  2274. {
  2275. int cpu_id = qdf_get_cpu();
  2276. DP_STATS_INC(soc, rx.ring_packets[cpu_id][ring_id], bufs_reaped);
  2277. }
  2278. static inline
  2279. qdf_nbuf_t dp_rx_nbuf_alloc(struct dp_soc *soc,
  2280. struct rx_desc_pool *rx_desc_pool)
  2281. {
  2282. return qdf_nbuf_alloc(soc->osdev, rx_desc_pool->buf_size,
  2283. RX_BUFFER_RESERVATION,
  2284. rx_desc_pool->buf_alignment, FALSE);
  2285. }
  2286. static inline
  2287. void dp_rx_nbuf_free(qdf_nbuf_t nbuf)
  2288. {
  2289. qdf_nbuf_free(nbuf);
  2290. }
  2291. #endif
  2292. /**
  2293. * dp_rx_get_txrx_peer_and_vdev() - Get txrx peer and vdev from peer id
  2294. * @nbuf : pointer to the first msdu of an amsdu.
  2295. * @peer_id : Peer id of the peer
  2296. * @txrx_ref_handle : Buffer to save the handle for txrx peer's reference
  2297. * @pkt_capture_offload : Flag indicating if pkt capture offload is needed
  2298. * @vdev : Buffer to hold pointer to vdev
  2299. * @rx_pdev : Buffer to hold pointer to rx pdev
  2300. * @dsf : delay stats flag
  2301. * @old_tid : Old tid
  2302. *
  2303. * Get txrx peer and vdev from peer id
  2304. *
  2305. * Return: Pointer to txrx peer
  2306. */
  2307. static inline struct dp_txrx_peer *
  2308. dp_rx_get_txrx_peer_and_vdev(struct dp_soc *soc,
  2309. qdf_nbuf_t nbuf,
  2310. uint16_t peer_id,
  2311. dp_txrx_ref_handle *txrx_ref_handle,
  2312. bool pkt_capture_offload,
  2313. struct dp_vdev **vdev,
  2314. struct dp_pdev **rx_pdev,
  2315. uint32_t *dsf,
  2316. uint32_t *old_tid)
  2317. {
  2318. struct dp_txrx_peer *txrx_peer = NULL;
  2319. txrx_peer = dp_txrx_peer_get_ref_by_id(soc, peer_id, txrx_ref_handle,
  2320. DP_MOD_ID_RX);
  2321. if (qdf_likely(txrx_peer)) {
  2322. *vdev = txrx_peer->vdev;
  2323. } else {
  2324. nbuf->next = NULL;
  2325. dp_rx_deliver_to_pkt_capture_no_peer(soc, nbuf,
  2326. pkt_capture_offload);
  2327. if (!pkt_capture_offload)
  2328. dp_rx_deliver_to_stack_no_peer(soc, nbuf);
  2329. goto end;
  2330. }
  2331. if (qdf_unlikely(!(*vdev))) {
  2332. qdf_nbuf_free(nbuf);
  2333. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  2334. goto end;
  2335. }
  2336. *rx_pdev = (*vdev)->pdev;
  2337. *dsf = (*rx_pdev)->delay_stats_flag;
  2338. *old_tid = 0xff;
  2339. end:
  2340. return txrx_peer;
  2341. }
  2342. static inline QDF_STATUS
  2343. dp_peer_rx_reorder_queue_setup(struct dp_soc *soc, struct dp_peer *peer,
  2344. int tid, uint32_t ba_window_size)
  2345. {
  2346. return soc->arch_ops.dp_peer_rx_reorder_queue_setup(soc,
  2347. peer, tid,
  2348. ba_window_size);
  2349. }
  2350. static inline
  2351. void dp_rx_nbuf_list_deliver(struct dp_soc *soc,
  2352. struct dp_vdev *vdev,
  2353. struct dp_txrx_peer *txrx_peer,
  2354. uint16_t peer_id,
  2355. uint8_t pkt_capture_offload,
  2356. qdf_nbuf_t deliver_list_head,
  2357. qdf_nbuf_t deliver_list_tail)
  2358. {
  2359. qdf_nbuf_t nbuf, next;
  2360. if (qdf_likely(deliver_list_head)) {
  2361. if (qdf_likely(txrx_peer)) {
  2362. dp_rx_deliver_to_pkt_capture(soc, vdev->pdev, peer_id,
  2363. pkt_capture_offload,
  2364. deliver_list_head);
  2365. if (!pkt_capture_offload)
  2366. dp_rx_deliver_to_stack(soc, vdev, txrx_peer,
  2367. deliver_list_head,
  2368. deliver_list_tail);
  2369. } else {
  2370. nbuf = deliver_list_head;
  2371. while (nbuf) {
  2372. next = nbuf->next;
  2373. nbuf->next = NULL;
  2374. dp_rx_deliver_to_stack_no_peer(soc, nbuf);
  2375. nbuf = next;
  2376. }
  2377. }
  2378. }
  2379. }
  2380. #ifdef DP_TX_RX_TPUT_SIMULATE
  2381. /*
  2382. * Change this macro value to simulate different RX T-put,
  2383. * if OTA is 100 Mbps, to simulate 200 Mbps, then multiplication factor
  2384. * is 2, set macro value as 1 (multiplication factor - 1).
  2385. */
  2386. #define DP_RX_PKTS_DUPLICATE_CNT 0
  2387. static inline
  2388. void dp_rx_nbuf_list_dup_deliver(struct dp_soc *soc,
  2389. struct dp_vdev *vdev,
  2390. struct dp_txrx_peer *txrx_peer,
  2391. uint16_t peer_id,
  2392. uint8_t pkt_capture_offload,
  2393. qdf_nbuf_t ori_list_head,
  2394. qdf_nbuf_t ori_list_tail)
  2395. {
  2396. qdf_nbuf_t new_skb = NULL;
  2397. qdf_nbuf_t new_list_head = NULL;
  2398. qdf_nbuf_t new_list_tail = NULL;
  2399. qdf_nbuf_t nbuf = NULL;
  2400. int i;
  2401. for (i = 0; i < DP_RX_PKTS_DUPLICATE_CNT; i++) {
  2402. nbuf = ori_list_head;
  2403. new_list_head = NULL;
  2404. new_list_tail = NULL;
  2405. while (nbuf) {
  2406. new_skb = qdf_nbuf_copy(nbuf);
  2407. if (qdf_likely(new_skb))
  2408. DP_RX_LIST_APPEND(new_list_head,
  2409. new_list_tail,
  2410. new_skb);
  2411. else
  2412. dp_err("copy skb failed");
  2413. nbuf = qdf_nbuf_next(nbuf);
  2414. }
  2415. /* deliver the copied nbuf list */
  2416. dp_rx_nbuf_list_deliver(soc, vdev, txrx_peer, peer_id,
  2417. pkt_capture_offload,
  2418. new_list_head,
  2419. new_list_tail);
  2420. }
  2421. /* deliver the original skb_list */
  2422. dp_rx_nbuf_list_deliver(soc, vdev, txrx_peer, peer_id,
  2423. pkt_capture_offload,
  2424. ori_list_head,
  2425. ori_list_tail);
  2426. }
  2427. #define DP_RX_DELIVER_TO_STACK dp_rx_nbuf_list_dup_deliver
  2428. #else /* !DP_TX_RX_TPUT_SIMULATE */
  2429. #define DP_RX_DELIVER_TO_STACK dp_rx_nbuf_list_deliver
  2430. #endif /* DP_TX_RX_TPUT_SIMULATE */
  2431. #endif /* _DP_RX_H */