dp_rx.h 75 KB

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