dp_rx.h 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _DP_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. /* Max buffer in invalid peer SG list*/
  43. #define DP_MAX_INVALID_BUFFERS 10
  44. #ifdef DP_INVALID_PEER_ASSERT
  45. #define DP_PDEV_INVALID_PEER_MSDU_CHECK(head, tail) \
  46. do { \
  47. qdf_assert_always(!(head)); \
  48. qdf_assert_always(!(tail)); \
  49. } while (0)
  50. #else
  51. #define DP_PDEV_INVALID_PEER_MSDU_CHECK(head, tail) /* no op */
  52. #endif
  53. #define RX_BUFFER_RESERVATION 0
  54. #ifdef BE_PKTLOG_SUPPORT
  55. #define BUFFER_RESIDUE 1
  56. #define RX_MON_MIN_HEAD_ROOM 64
  57. #endif
  58. #define DP_DEFAULT_NOISEFLOOR (-96)
  59. #define DP_RX_DESC_MAGIC 0xdec0de
  60. #define dp_rx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_RX, params)
  61. #define dp_rx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_RX, params)
  62. #define dp_rx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_RX, params)
  63. #define dp_rx_info(params...) \
  64. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX, ## params)
  65. #define dp_rx_info_rl(params...) \
  66. __QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX, ## params)
  67. #define dp_rx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_RX, params)
  68. #define dp_rx_err_err(params...) \
  69. QDF_TRACE_ERROR(QDF_MODULE_ID_DP_RX_ERROR, params)
  70. /**
  71. * enum dp_rx_desc_state
  72. *
  73. * @RX_DESC_REPLENISHED: rx desc replenished
  74. * @RX_DESC_IN_FREELIST: rx desc in freelist
  75. */
  76. enum dp_rx_desc_state {
  77. RX_DESC_REPLENISHED,
  78. RX_DESC_IN_FREELIST,
  79. };
  80. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  81. /**
  82. * struct dp_rx_desc_dbg_info
  83. *
  84. * @freelist_caller: name of the function that put the
  85. * the rx desc in freelist
  86. * @freelist_ts: timestamp when the rx desc is put in
  87. * a freelist
  88. * @replenish_caller: name of the function that last
  89. * replenished the rx desc
  90. * @replenish_ts: last replenish timestamp
  91. * @prev_nbuf: previous nbuf info
  92. * @prev_nbuf_data_addr: previous nbuf data address
  93. */
  94. struct dp_rx_desc_dbg_info {
  95. char freelist_caller[QDF_MEM_FUNC_NAME_SIZE];
  96. uint64_t freelist_ts;
  97. char replenish_caller[QDF_MEM_FUNC_NAME_SIZE];
  98. uint64_t replenish_ts;
  99. qdf_nbuf_t prev_nbuf;
  100. uint8_t *prev_nbuf_data_addr;
  101. };
  102. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  103. /**
  104. * struct dp_rx_desc
  105. *
  106. * @nbuf: VA of the "skb" posted
  107. * @rx_buf_start: VA of the original Rx buffer, before
  108. * movement of any skb->data pointer
  109. * @paddr_buf_start: PA of the original Rx buffer, before
  110. * movement of any frag pointer
  111. * @cookie: index into the sw array which holds
  112. * the sw Rx descriptors
  113. * Cookie space is 21 bits:
  114. * lower 18 bits -- index
  115. * upper 3 bits -- pool_id
  116. * @pool_id: pool Id for which this allocated.
  117. * Can only be used if there is no flow
  118. * steering
  119. * @chip_id: chip_id indicating MLO chip_id
  120. * valid or used only in case of multi-chip MLO
  121. * @reuse_nbuf: VA of the "skb" which is being reused
  122. * @magic:
  123. * @nbuf_data_addr: VA of nbuf data posted
  124. * @dbg_info:
  125. * @in_use: rx_desc is in use
  126. * @unmapped: used to mark rx_desc an unmapped if the corresponding
  127. * nbuf is already unmapped
  128. * @in_err_state: Nbuf sanity failed for this descriptor.
  129. * @has_reuse_nbuf: the nbuf associated with this desc is also saved in
  130. * reuse_nbuf field
  131. */
  132. struct dp_rx_desc {
  133. qdf_nbuf_t nbuf;
  134. #ifdef WLAN_SUPPORT_PPEDS
  135. qdf_nbuf_t reuse_nbuf;
  136. #endif
  137. uint8_t *rx_buf_start;
  138. qdf_dma_addr_t paddr_buf_start;
  139. uint32_t cookie;
  140. uint8_t pool_id;
  141. uint8_t chip_id;
  142. #ifdef RX_DESC_DEBUG_CHECK
  143. uint32_t magic;
  144. uint8_t *nbuf_data_addr;
  145. struct dp_rx_desc_dbg_info *dbg_info;
  146. #endif
  147. uint8_t in_use:1,
  148. unmapped:1,
  149. in_err_state:1,
  150. has_reuse_nbuf:1;
  151. };
  152. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  153. #ifdef ATH_RX_PRI_SAVE
  154. #define DP_RX_TID_SAVE(_nbuf, _tid) \
  155. (qdf_nbuf_set_priority(_nbuf, _tid))
  156. #else
  157. #define DP_RX_TID_SAVE(_nbuf, _tid)
  158. #endif
  159. /* RX Descriptor Multi Page memory alloc related */
  160. #define DP_RX_DESC_OFFSET_NUM_BITS 8
  161. #define DP_RX_DESC_PAGE_ID_NUM_BITS 8
  162. #define DP_RX_DESC_POOL_ID_NUM_BITS 4
  163. #define DP_RX_DESC_PAGE_ID_SHIFT DP_RX_DESC_OFFSET_NUM_BITS
  164. #define DP_RX_DESC_POOL_ID_SHIFT \
  165. (DP_RX_DESC_OFFSET_NUM_BITS + DP_RX_DESC_PAGE_ID_NUM_BITS)
  166. #define RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK \
  167. (((1 << DP_RX_DESC_POOL_ID_NUM_BITS) - 1) << DP_RX_DESC_POOL_ID_SHIFT)
  168. #define RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK \
  169. (((1 << DP_RX_DESC_PAGE_ID_NUM_BITS) - 1) << \
  170. DP_RX_DESC_PAGE_ID_SHIFT)
  171. #define RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK \
  172. ((1 << DP_RX_DESC_OFFSET_NUM_BITS) - 1)
  173. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(_cookie) \
  174. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_POOL_ID_MASK) >> \
  175. DP_RX_DESC_POOL_ID_SHIFT)
  176. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(_cookie) \
  177. (((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_PAGE_ID_MASK) >> \
  178. DP_RX_DESC_PAGE_ID_SHIFT)
  179. #define DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(_cookie) \
  180. ((_cookie) & RX_DESC_MULTI_PAGE_COOKIE_OFFSET_MASK)
  181. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  182. #define RX_DESC_COOKIE_INDEX_SHIFT 0
  183. #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */
  184. #define RX_DESC_COOKIE_POOL_ID_SHIFT 18
  185. #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000
  186. #define DP_RX_DESC_COOKIE_MAX \
  187. (RX_DESC_COOKIE_INDEX_MASK | RX_DESC_COOKIE_POOL_ID_MASK)
  188. #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \
  189. (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \
  190. RX_DESC_COOKIE_POOL_ID_SHIFT)
  191. #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \
  192. (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \
  193. RX_DESC_COOKIE_INDEX_SHIFT)
  194. #define dp_rx_add_to_free_desc_list(head, tail, new) \
  195. __dp_rx_add_to_free_desc_list(head, tail, new, __func__)
  196. #define dp_rx_add_to_free_desc_list_reuse(head, tail, new) \
  197. __dp_rx_add_to_free_desc_list_reuse(head, tail, new, __func__)
  198. #define dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool, \
  199. num_buffers, desc_list, tail, req_only) \
  200. __dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool, \
  201. num_buffers, desc_list, tail, req_only, \
  202. __func__)
  203. #ifdef WLAN_SUPPORT_RX_FISA
  204. /**
  205. * dp_rx_set_hdr_pad() - set l3 padding in nbuf cb
  206. * @nbuf: pkt skb pointer
  207. * @l3_padding: l3 padding
  208. *
  209. * Return: None
  210. */
  211. static inline
  212. void dp_rx_set_hdr_pad(qdf_nbuf_t nbuf, uint32_t l3_padding)
  213. {
  214. QDF_NBUF_CB_RX_PACKET_L3_HDR_PAD(nbuf) = l3_padding;
  215. }
  216. #else
  217. static inline
  218. void dp_rx_set_hdr_pad(qdf_nbuf_t nbuf, uint32_t l3_padding)
  219. {
  220. }
  221. #endif
  222. #ifdef DP_RX_SPECIAL_FRAME_NEED
  223. /**
  224. * dp_rx_is_special_frame() - check is RX frame special needed
  225. *
  226. * @nbuf: RX skb pointer
  227. * @frame_mask: the mask for special frame needed
  228. *
  229. * Check is RX frame wanted matched with mask
  230. *
  231. * Return: true - special frame needed, false - no
  232. */
  233. static inline
  234. bool dp_rx_is_special_frame(qdf_nbuf_t nbuf, uint32_t frame_mask)
  235. {
  236. if (((frame_mask & FRAME_MASK_IPV4_ARP) &&
  237. qdf_nbuf_is_ipv4_arp_pkt(nbuf)) ||
  238. ((frame_mask & FRAME_MASK_IPV4_DHCP) &&
  239. qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) ||
  240. ((frame_mask & FRAME_MASK_IPV4_EAPOL) &&
  241. qdf_nbuf_is_ipv4_eapol_pkt(nbuf)) ||
  242. ((frame_mask & FRAME_MASK_IPV6_DHCP) &&
  243. qdf_nbuf_is_ipv6_dhcp_pkt(nbuf)))
  244. return true;
  245. return false;
  246. }
  247. /**
  248. * dp_rx_deliver_special_frame() - Deliver the RX special frame to stack
  249. * if matches mask
  250. *
  251. * @soc: Datapath soc handler
  252. * @peer: pointer to DP peer
  253. * @nbuf: pointer to the skb of RX frame
  254. * @frame_mask: the mask for special frame needed
  255. * @rx_tlv_hdr: start of rx tlv header
  256. *
  257. * note: Msdu_len must have been stored in QDF_NBUF_CB_RX_PKT_LEN(nbuf) and
  258. * single nbuf is expected.
  259. *
  260. * Return: true - nbuf has been delivered to stack, false - not.
  261. */
  262. bool dp_rx_deliver_special_frame(struct dp_soc *soc, struct dp_txrx_peer *peer,
  263. qdf_nbuf_t nbuf, uint32_t frame_mask,
  264. uint8_t *rx_tlv_hdr);
  265. #else
  266. static inline
  267. bool dp_rx_is_special_frame(qdf_nbuf_t nbuf, uint32_t frame_mask)
  268. {
  269. return false;
  270. }
  271. static inline
  272. bool dp_rx_deliver_special_frame(struct dp_soc *soc, struct dp_txrx_peer *peer,
  273. qdf_nbuf_t nbuf, uint32_t frame_mask,
  274. uint8_t *rx_tlv_hdr)
  275. {
  276. return false;
  277. }
  278. #endif
  279. #ifdef FEATURE_RX_LINKSPEED_ROAM_TRIGGER
  280. /**
  281. * dp_rx_data_is_specific() - Used to exclude specific frames
  282. * not practical for getting rx
  283. * stats like rate, mcs, nss, etc.
  284. *
  285. * @hal_soc_hdl: soc handler
  286. * @rx_tlv_hdr: rx tlv header
  287. * @nbuf: RX skb pointer
  288. *
  289. * Return: true - a specific frame not suitable
  290. * for getting rx stats from it.
  291. * false - a common frame suitable for
  292. * getting rx stats from it.
  293. */
  294. static inline
  295. bool dp_rx_data_is_specific(hal_soc_handle_t hal_soc_hdl,
  296. uint8_t *rx_tlv_hdr,
  297. qdf_nbuf_t nbuf)
  298. {
  299. if (qdf_unlikely(qdf_nbuf_is_da_mcbc(nbuf)))
  300. return true;
  301. if (!hal_rx_tlv_first_mpdu_get(hal_soc_hdl, rx_tlv_hdr))
  302. return true;
  303. if (!hal_rx_msdu_end_first_msdu_get(hal_soc_hdl, rx_tlv_hdr))
  304. return true;
  305. /* ARP, EAPOL is neither IPV6 ETH nor IPV4 ETH from L3 level */
  306. if (qdf_likely(hal_rx_tlv_l3_type_get(hal_soc_hdl, rx_tlv_hdr) ==
  307. QDF_NBUF_TRAC_IPV4_ETH_TYPE)) {
  308. if (qdf_nbuf_is_ipv4_dhcp_pkt(nbuf))
  309. return true;
  310. } else if (qdf_likely(hal_rx_tlv_l3_type_get(hal_soc_hdl, rx_tlv_hdr) ==
  311. QDF_NBUF_TRAC_IPV6_ETH_TYPE)) {
  312. if (qdf_nbuf_is_ipv6_dhcp_pkt(nbuf))
  313. return true;
  314. } else {
  315. return true;
  316. }
  317. return false;
  318. }
  319. #else
  320. static inline
  321. bool dp_rx_data_is_specific(hal_soc_handle_t hal_soc_hdl,
  322. uint8_t *rx_tlv_hdr,
  323. qdf_nbuf_t nbuf)
  324. {
  325. /*
  326. * default return is true to make sure that rx stats
  327. * will not be handled when this feature is disabled
  328. */
  329. return true;
  330. }
  331. #endif /* FEATURE_RX_LINKSPEED_ROAM_TRIGGER */
  332. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  333. #ifdef DP_RX_DISABLE_NDI_MDNS_FORWARDING
  334. static inline
  335. bool dp_rx_check_ndi_mdns_fwding(struct dp_txrx_peer *ta_txrx_peer,
  336. qdf_nbuf_t nbuf, uint8_t link_id)
  337. {
  338. if (ta_txrx_peer->vdev->opmode == wlan_op_mode_ndi &&
  339. qdf_nbuf_is_ipv6_mdns_pkt(nbuf)) {
  340. DP_PEER_PER_PKT_STATS_INC(ta_txrx_peer,
  341. rx.intra_bss.mdns_no_fwd,
  342. 1, link_id);
  343. return false;
  344. }
  345. return true;
  346. }
  347. #else
  348. static inline
  349. bool dp_rx_check_ndi_mdns_fwding(struct dp_txrx_peer *ta_txrx_peer,
  350. qdf_nbuf_t nbuf, uint8_t link_id)
  351. {
  352. return true;
  353. }
  354. #endif
  355. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  356. /* DOC: Offset to obtain LLC hdr
  357. *
  358. * In the case of Wifi parse error
  359. * to reach LLC header from beginning
  360. * of VLAN tag we need to skip 8 bytes.
  361. * Vlan_tag(4)+length(2)+length added
  362. * by HW(2) = 8 bytes.
  363. */
  364. #define DP_SKIP_VLAN 8
  365. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  366. /**
  367. * struct dp_rx_cached_buf - rx cached buffer
  368. * @node: linked list node
  369. * @buf: skb buffer
  370. */
  371. struct dp_rx_cached_buf {
  372. qdf_list_node_t node;
  373. qdf_nbuf_t buf;
  374. };
  375. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  376. /**
  377. * dp_rx_xor_block() - xor block of data
  378. * @b: destination data block
  379. * @a: source data block
  380. * @len: length of the data to process
  381. *
  382. * Return: None
  383. */
  384. static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len)
  385. {
  386. qdf_size_t i;
  387. for (i = 0; i < len; i++)
  388. b[i] ^= a[i];
  389. }
  390. /**
  391. * dp_rx_rotl() - rotate the bits left
  392. * @val: unsigned integer input value
  393. * @bits: number of bits
  394. *
  395. * Return: Integer with left rotated by number of 'bits'
  396. */
  397. static inline uint32_t dp_rx_rotl(uint32_t val, int bits)
  398. {
  399. return (val << bits) | (val >> (32 - bits));
  400. }
  401. /**
  402. * dp_rx_rotr() - rotate the bits right
  403. * @val: unsigned integer input value
  404. * @bits: number of bits
  405. *
  406. * Return: Integer with right rotated by number of 'bits'
  407. */
  408. static inline uint32_t dp_rx_rotr(uint32_t val, int bits)
  409. {
  410. return (val >> bits) | (val << (32 - bits));
  411. }
  412. /**
  413. * dp_set_rx_queue() - set queue_mapping in skb
  414. * @nbuf: skb
  415. * @queue_id: rx queue_id
  416. *
  417. * Return: void
  418. */
  419. #ifdef QCA_OL_RX_MULTIQ_SUPPORT
  420. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  421. {
  422. qdf_nbuf_record_rx_queue(nbuf, queue_id);
  423. return;
  424. }
  425. #else
  426. static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id)
  427. {
  428. }
  429. #endif
  430. /**
  431. * dp_rx_xswap() - swap the bits left
  432. * @val: unsigned integer input value
  433. *
  434. * Return: Integer with bits swapped
  435. */
  436. static inline uint32_t dp_rx_xswap(uint32_t val)
  437. {
  438. return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
  439. }
  440. /**
  441. * dp_rx_get_le32_split() - get little endian 32 bits split
  442. * @b0: byte 0
  443. * @b1: byte 1
  444. * @b2: byte 2
  445. * @b3: byte 3
  446. *
  447. * Return: Integer with split little endian 32 bits
  448. */
  449. static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2,
  450. uint8_t b3)
  451. {
  452. return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
  453. }
  454. /**
  455. * dp_rx_get_le32() - get little endian 32 bits
  456. * @p: source 32-bit value
  457. *
  458. * Return: Integer with little endian 32 bits
  459. */
  460. static inline uint32_t dp_rx_get_le32(const uint8_t *p)
  461. {
  462. return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]);
  463. }
  464. /**
  465. * dp_rx_put_le32() - put little endian 32 bits
  466. * @p: destination char array
  467. * @v: source 32-bit integer
  468. *
  469. * Return: None
  470. */
  471. static inline void dp_rx_put_le32(uint8_t *p, uint32_t v)
  472. {
  473. p[0] = (v) & 0xff;
  474. p[1] = (v >> 8) & 0xff;
  475. p[2] = (v >> 16) & 0xff;
  476. p[3] = (v >> 24) & 0xff;
  477. }
  478. /* Extract michal mic block of data */
  479. #define dp_rx_michael_block(l, r) \
  480. do { \
  481. r ^= dp_rx_rotl(l, 17); \
  482. l += r; \
  483. r ^= dp_rx_xswap(l); \
  484. l += r; \
  485. r ^= dp_rx_rotl(l, 3); \
  486. l += r; \
  487. r ^= dp_rx_rotr(l, 2); \
  488. l += r; \
  489. } while (0)
  490. /**
  491. * struct dp_rx_desc_list_elem_t
  492. *
  493. * @next: Next pointer to form free list
  494. * @rx_desc: DP Rx descriptor
  495. */
  496. union dp_rx_desc_list_elem_t {
  497. union dp_rx_desc_list_elem_t *next;
  498. struct dp_rx_desc rx_desc;
  499. };
  500. #ifdef RX_DESC_MULTI_PAGE_ALLOC
  501. /**
  502. * dp_rx_desc_find() - find dp rx descriptor from page ID and offset
  503. * @page_id: Page ID
  504. * @offset: Offset of the descriptor element
  505. * @rx_pool: RX pool
  506. *
  507. * Return: RX descriptor element
  508. */
  509. union dp_rx_desc_list_elem_t *dp_rx_desc_find(uint16_t page_id, uint16_t offset,
  510. struct rx_desc_pool *rx_pool);
  511. static inline
  512. struct dp_rx_desc *dp_get_rx_desc_from_cookie(struct dp_soc *soc,
  513. struct rx_desc_pool *pool,
  514. uint32_t cookie)
  515. {
  516. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  517. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  518. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  519. struct rx_desc_pool *rx_desc_pool;
  520. union dp_rx_desc_list_elem_t *rx_desc_elem;
  521. if (qdf_unlikely(pool_id >= MAX_PDEV_CNT))
  522. return NULL;
  523. rx_desc_pool = &pool[pool_id];
  524. rx_desc_elem = (union dp_rx_desc_list_elem_t *)
  525. (rx_desc_pool->desc_pages.cacheable_pages[page_id] +
  526. rx_desc_pool->elem_size * offset);
  527. return &rx_desc_elem->rx_desc;
  528. }
  529. static inline
  530. struct dp_rx_desc *dp_get_rx_mon_status_desc_from_cookie(struct dp_soc *soc,
  531. struct rx_desc_pool *pool,
  532. uint32_t cookie)
  533. {
  534. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  535. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  536. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  537. struct rx_desc_pool *rx_desc_pool;
  538. union dp_rx_desc_list_elem_t *rx_desc_elem;
  539. if (qdf_unlikely(pool_id >= NUM_RXDMA_RINGS_PER_PDEV))
  540. return NULL;
  541. rx_desc_pool = &pool[pool_id];
  542. rx_desc_elem = (union dp_rx_desc_list_elem_t *)
  543. (rx_desc_pool->desc_pages.cacheable_pages[page_id] +
  544. rx_desc_pool->elem_size * offset);
  545. return &rx_desc_elem->rx_desc;
  546. }
  547. /**
  548. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  549. * the Rx descriptor on Rx DMA source ring buffer
  550. * @soc: core txrx main context
  551. * @cookie: cookie used to lookup virtual address
  552. *
  553. * Return: Pointer to the Rx descriptor
  554. */
  555. static inline
  556. struct dp_rx_desc *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc,
  557. uint32_t cookie)
  558. {
  559. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_buf[0], cookie);
  560. }
  561. /**
  562. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  563. * the Rx descriptor on monitor ring buffer
  564. * @soc: core txrx main context
  565. * @cookie: cookie used to lookup virtual address
  566. *
  567. * Return: Pointer to the Rx descriptor
  568. */
  569. static inline
  570. struct dp_rx_desc *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc,
  571. uint32_t cookie)
  572. {
  573. return dp_get_rx_desc_from_cookie(soc, &soc->rx_desc_mon[0], cookie);
  574. }
  575. /**
  576. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  577. * the Rx descriptor on monitor status ring buffer
  578. * @soc: core txrx main context
  579. * @cookie: cookie used to lookup virtual address
  580. *
  581. * Return: Pointer to the Rx descriptor
  582. */
  583. static inline
  584. struct dp_rx_desc *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc,
  585. uint32_t cookie)
  586. {
  587. return dp_get_rx_mon_status_desc_from_cookie(soc,
  588. &soc->rx_desc_status[0],
  589. cookie);
  590. }
  591. #else
  592. void dp_rx_desc_pool_init(struct dp_soc *soc, uint32_t pool_id,
  593. uint32_t pool_size,
  594. struct rx_desc_pool *rx_desc_pool);
  595. /**
  596. * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of
  597. * the Rx descriptor on Rx DMA source ring buffer
  598. * @soc: core txrx main context
  599. * @cookie: cookie used to lookup virtual address
  600. *
  601. * Return: void *: Virtual Address of the Rx descriptor
  602. */
  603. static inline
  604. void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie)
  605. {
  606. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  607. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  608. struct rx_desc_pool *rx_desc_pool;
  609. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  610. return NULL;
  611. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  612. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  613. return NULL;
  614. return &rx_desc_pool->array[index].rx_desc;
  615. }
  616. /**
  617. * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of
  618. * the Rx descriptor on monitor ring buffer
  619. * @soc: core txrx main context
  620. * @cookie: cookie used to lookup virtual address
  621. *
  622. * Return: void *: Virtual Address of the Rx descriptor
  623. */
  624. static inline
  625. void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie)
  626. {
  627. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  628. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  629. /* TODO */
  630. /* Add sanity for pool_id & index */
  631. return &(soc->rx_desc_mon[pool_id].array[index].rx_desc);
  632. }
  633. /**
  634. * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of
  635. * the Rx descriptor on monitor status ring buffer
  636. * @soc: core txrx main context
  637. * @cookie: cookie used to lookup virtual address
  638. *
  639. * Return: void *: Virtual Address of the Rx descriptor
  640. */
  641. static inline
  642. void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie)
  643. {
  644. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  645. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  646. /* TODO */
  647. /* Add sanity for pool_id & index */
  648. return &(soc->rx_desc_status[pool_id].array[index].rx_desc);
  649. }
  650. #endif /* RX_DESC_MULTI_PAGE_ALLOC */
  651. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  652. static inline bool dp_rx_check_ap_bridge(struct dp_vdev *vdev)
  653. {
  654. return vdev->ap_bridge_enabled;
  655. }
  656. #ifdef DP_RX_DESC_COOKIE_INVALIDATE
  657. static inline QDF_STATUS
  658. dp_rx_cookie_check_and_invalidate(hal_ring_desc_t ring_desc)
  659. {
  660. if (qdf_unlikely(HAL_RX_REO_BUF_COOKIE_INVALID_GET(ring_desc)))
  661. return QDF_STATUS_E_FAILURE;
  662. HAL_RX_REO_BUF_COOKIE_INVALID_SET(ring_desc);
  663. return QDF_STATUS_SUCCESS;
  664. }
  665. /**
  666. * dp_rx_cookie_reset_invalid_bit() - Reset the invalid bit of the cookie
  667. * field in ring descriptor
  668. * @ring_desc: ring descriptor
  669. *
  670. * Return: None
  671. */
  672. static inline void
  673. dp_rx_cookie_reset_invalid_bit(hal_ring_desc_t ring_desc)
  674. {
  675. HAL_RX_REO_BUF_COOKIE_INVALID_RESET(ring_desc);
  676. }
  677. #else
  678. static inline QDF_STATUS
  679. dp_rx_cookie_check_and_invalidate(hal_ring_desc_t ring_desc)
  680. {
  681. return QDF_STATUS_SUCCESS;
  682. }
  683. static inline void
  684. dp_rx_cookie_reset_invalid_bit(hal_ring_desc_t ring_desc)
  685. {
  686. }
  687. #endif
  688. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  689. #if defined(RX_DESC_MULTI_PAGE_ALLOC) && \
  690. defined(DP_WAR_VALIDATE_RX_ERR_MSDU_COOKIE)
  691. /**
  692. * dp_rx_is_sw_cookie_valid() - check whether SW cookie valid
  693. * @soc: dp soc ref
  694. * @cookie: Rx buf SW cookie value
  695. *
  696. * Return: true if cookie is valid else false
  697. */
  698. static inline bool dp_rx_is_sw_cookie_valid(struct dp_soc *soc,
  699. uint32_t cookie)
  700. {
  701. uint8_t pool_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_POOL_ID(cookie);
  702. uint16_t page_id = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_PAGE_ID(cookie);
  703. uint8_t offset = DP_RX_DESC_MULTI_PAGE_COOKIE_GET_OFFSET(cookie);
  704. struct rx_desc_pool *rx_desc_pool;
  705. if (qdf_unlikely(pool_id >= MAX_PDEV_CNT))
  706. goto fail;
  707. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  708. if (page_id >= rx_desc_pool->desc_pages.num_pages ||
  709. offset >= rx_desc_pool->desc_pages.num_element_per_page)
  710. goto fail;
  711. return true;
  712. fail:
  713. DP_STATS_INC(soc, rx.err.invalid_cookie, 1);
  714. return false;
  715. }
  716. #else
  717. /**
  718. * dp_rx_is_sw_cookie_valid() - check whether SW cookie valid
  719. * @soc: dp soc ref
  720. * @cookie: Rx buf SW cookie value
  721. *
  722. * When multi page alloc is disabled SW cookie validness is
  723. * checked while fetching Rx descriptor, so no need to check here
  724. *
  725. * Return: true if cookie is valid else false
  726. */
  727. static inline bool dp_rx_is_sw_cookie_valid(struct dp_soc *soc,
  728. uint32_t cookie)
  729. {
  730. return true;
  731. }
  732. #endif
  733. /**
  734. * dp_rx_desc_pool_is_allocated() - check if memory is allocated for the
  735. * rx descriptor pool
  736. * @rx_desc_pool: rx descriptor pool pointer
  737. *
  738. * Return: QDF_STATUS QDF_STATUS_SUCCESS
  739. * QDF_STATUS_E_NOMEM
  740. */
  741. QDF_STATUS dp_rx_desc_pool_is_allocated(struct rx_desc_pool *rx_desc_pool);
  742. /**
  743. * dp_rx_desc_pool_alloc() - Allocate a memory pool for software rx
  744. * descriptors
  745. * @soc: core txrx main context
  746. * @pool_size: number of rx descriptors (size of the pool)
  747. * @rx_desc_pool: rx descriptor pool pointer
  748. *
  749. * Return: QDF_STATUS QDF_STATUS_SUCCESS
  750. * QDF_STATUS_E_NOMEM
  751. * QDF_STATUS_E_FAULT
  752. */
  753. QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc,
  754. uint32_t pool_size,
  755. struct rx_desc_pool *rx_desc_pool);
  756. /**
  757. * dp_rx_desc_pool_init() - Initialize the software RX descriptor pool
  758. * @soc: core txrx main context
  759. * @pool_id: pool_id which is one of 3 mac_ids
  760. * @pool_size: size of the rx descriptor pool
  761. * @rx_desc_pool: rx descriptor pool pointer
  762. *
  763. * Convert the pool of memory into a list of rx descriptors and create
  764. * locks to access this list of rx descriptors.
  765. *
  766. */
  767. void dp_rx_desc_pool_init(struct dp_soc *soc, uint32_t pool_id,
  768. uint32_t pool_size,
  769. struct rx_desc_pool *rx_desc_pool);
  770. /**
  771. * dp_rx_add_desc_list_to_free_list() - append unused desc_list back to
  772. * freelist.
  773. * @soc: core txrx main context
  774. * @local_desc_list: local desc list provided by the caller
  775. * @tail: attach the point to last desc of local desc list
  776. * @pool_id: pool_id which is one of 3 mac_ids
  777. * @rx_desc_pool: rx descriptor pool pointer
  778. */
  779. void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc,
  780. union dp_rx_desc_list_elem_t **local_desc_list,
  781. union dp_rx_desc_list_elem_t **tail,
  782. uint16_t pool_id,
  783. struct rx_desc_pool *rx_desc_pool);
  784. /**
  785. * dp_rx_get_free_desc_list() - provide a list of descriptors from
  786. * the free rx desc pool.
  787. * @soc: core txrx main context
  788. * @pool_id: pool_id which is one of 3 mac_ids
  789. * @rx_desc_pool: rx descriptor pool pointer
  790. * @num_descs: number of descs requested from freelist
  791. * @desc_list: attach the descs to this list (output parameter)
  792. * @tail: attach the point to last desc of free list (output parameter)
  793. *
  794. * Return: number of descs allocated from free list.
  795. */
  796. uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id,
  797. struct rx_desc_pool *rx_desc_pool,
  798. uint16_t num_descs,
  799. union dp_rx_desc_list_elem_t **desc_list,
  800. union dp_rx_desc_list_elem_t **tail);
  801. /**
  802. * dp_rx_pdev_desc_pool_alloc() - allocate memory for software rx descriptor
  803. * pool
  804. * @pdev: core txrx pdev context
  805. *
  806. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  807. * QDF_STATUS_E_NOMEM
  808. */
  809. QDF_STATUS dp_rx_pdev_desc_pool_alloc(struct dp_pdev *pdev);
  810. /**
  811. * dp_rx_pdev_desc_pool_free() - free software rx descriptor pool
  812. * @pdev: core txrx pdev context
  813. */
  814. void dp_rx_pdev_desc_pool_free(struct dp_pdev *pdev);
  815. /**
  816. * dp_rx_pdev_desc_pool_init() - initialize software rx descriptors
  817. * @pdev: core txrx pdev context
  818. *
  819. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  820. * QDF_STATUS_E_NOMEM
  821. */
  822. QDF_STATUS dp_rx_pdev_desc_pool_init(struct dp_pdev *pdev);
  823. /**
  824. * dp_rx_pdev_desc_pool_deinit() - de-initialize software rx descriptor pools
  825. * @pdev: core txrx pdev context
  826. *
  827. * This function resets the freelist of rx descriptors and destroys locks
  828. * associated with this list of descriptors.
  829. */
  830. void dp_rx_pdev_desc_pool_deinit(struct dp_pdev *pdev);
  831. void dp_rx_desc_pool_deinit(struct dp_soc *soc,
  832. struct rx_desc_pool *rx_desc_pool,
  833. uint32_t pool_id);
  834. QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev);
  835. /**
  836. * dp_rx_pdev_buffers_alloc() - Allocate nbufs (skbs) and replenish RxDMA ring
  837. * @pdev: core txrx pdev context
  838. *
  839. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  840. * QDF_STATUS_E_NOMEM
  841. */
  842. QDF_STATUS dp_rx_pdev_buffers_alloc(struct dp_pdev *pdev);
  843. /**
  844. * dp_rx_pdev_buffers_free() - Free nbufs (skbs)
  845. * @pdev: core txrx pdev context
  846. */
  847. void dp_rx_pdev_buffers_free(struct dp_pdev *pdev);
  848. void dp_rx_pdev_detach(struct dp_pdev *pdev);
  849. /**
  850. * dp_print_napi_stats() - NAPI stats
  851. * @soc: soc handle
  852. */
  853. void dp_print_napi_stats(struct dp_soc *soc);
  854. /**
  855. * dp_rx_vdev_detach() - detach vdev from dp rx
  856. * @vdev: virtual device instance
  857. *
  858. * Return: QDF_STATUS_SUCCESS: success
  859. * QDF_STATUS_E_RESOURCES: Error return
  860. */
  861. QDF_STATUS dp_rx_vdev_detach(struct dp_vdev *vdev);
  862. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  863. uint32_t
  864. dp_rx_process(struct dp_intr *int_ctx, hal_ring_handle_t hal_ring_hdl,
  865. uint8_t reo_ring_num,
  866. uint32_t quota);
  867. /**
  868. * dp_rx_sg_create() - create a frag_list for MSDUs which are spread across
  869. * multiple nbufs.
  870. * @soc: core txrx main context
  871. * @nbuf: pointer to the first msdu of an amsdu.
  872. *
  873. * This function implements the creation of RX frag_list for cases
  874. * where an MSDU is spread across multiple nbufs.
  875. *
  876. * Return: returns the head nbuf which contains complete frag_list.
  877. */
  878. qdf_nbuf_t dp_rx_sg_create(struct dp_soc *soc, qdf_nbuf_t nbuf);
  879. /**
  880. * dp_rx_is_sg_supported() - SG packets processing supported or not.
  881. *
  882. * Return: returns true when processing is supported else false.
  883. */
  884. bool dp_rx_is_sg_supported(void);
  885. /**
  886. * dp_rx_desc_nbuf_and_pool_free() - free the sw rx desc pool called during
  887. * de-initialization of wifi module.
  888. *
  889. * @soc: core txrx main context
  890. * @pool_id: pool_id which is one of 3 mac_ids
  891. * @rx_desc_pool: rx descriptor pool pointer
  892. *
  893. * Return: None
  894. */
  895. void dp_rx_desc_nbuf_and_pool_free(struct dp_soc *soc, uint32_t pool_id,
  896. struct rx_desc_pool *rx_desc_pool);
  897. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  898. /**
  899. * dp_rx_desc_nbuf_free() - free the sw rx desc nbufs called during
  900. * de-initialization of wifi module.
  901. *
  902. * @soc: core txrx main context
  903. * @rx_desc_pool: rx descriptor pool pointer
  904. * @is_mon_pool: true if this is a monitor pool
  905. *
  906. * Return: None
  907. */
  908. void dp_rx_desc_nbuf_free(struct dp_soc *soc,
  909. struct rx_desc_pool *rx_desc_pool,
  910. bool is_mon_pool);
  911. #ifdef DP_RX_MON_MEM_FRAG
  912. /**
  913. * dp_rx_desc_frag_free() - free the sw rx desc frag called during
  914. * de-initialization of wifi module.
  915. *
  916. * @soc: core txrx main context
  917. * @rx_desc_pool: rx descriptor pool pointer
  918. *
  919. * Return: None
  920. */
  921. void dp_rx_desc_frag_free(struct dp_soc *soc,
  922. struct rx_desc_pool *rx_desc_pool);
  923. #else
  924. static inline
  925. void dp_rx_desc_frag_free(struct dp_soc *soc,
  926. struct rx_desc_pool *rx_desc_pool)
  927. {
  928. }
  929. #endif
  930. /**
  931. * dp_rx_desc_pool_free() - free the sw rx desc array called during
  932. * de-initialization of wifi module.
  933. *
  934. * @soc: core txrx main context
  935. * @rx_desc_pool: rx descriptor pool pointer
  936. *
  937. * Return: None
  938. */
  939. void dp_rx_desc_pool_free(struct dp_soc *soc,
  940. struct rx_desc_pool *rx_desc_pool);
  941. /**
  942. * dp_rx_deliver_raw() - process RAW mode pkts and hand over the
  943. * pkts to RAW mode simulation to
  944. * decapsulate the pkt.
  945. * @vdev: vdev on which RAW mode is enabled
  946. * @nbuf_list: list of RAW pkts to process
  947. * @peer: peer object from which the pkt is rx
  948. * @link_id: link Id on which the packet is received
  949. *
  950. * Return: void
  951. */
  952. void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list,
  953. struct dp_txrx_peer *peer, uint8_t link_id);
  954. #ifdef RX_DESC_LOGGING
  955. /**
  956. * dp_rx_desc_alloc_dbg_info() - Alloc memory for rx descriptor debug
  957. * structure
  958. * @rx_desc: rx descriptor pointer
  959. *
  960. * Return: None
  961. */
  962. static inline
  963. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  964. {
  965. rx_desc->dbg_info = qdf_mem_malloc(sizeof(struct dp_rx_desc_dbg_info));
  966. }
  967. /**
  968. * dp_rx_desc_free_dbg_info() - Free rx descriptor debug
  969. * structure memory
  970. * @rx_desc: rx descriptor pointer
  971. *
  972. * Return: None
  973. */
  974. static inline
  975. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  976. {
  977. qdf_mem_free(rx_desc->dbg_info);
  978. }
  979. /**
  980. * dp_rx_desc_update_dbg_info() - Update rx descriptor debug info
  981. * structure memory
  982. * @rx_desc: rx descriptor pointer
  983. * @func_name: name of calling function
  984. * @flag:
  985. *
  986. * Return: None
  987. */
  988. static
  989. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  990. const char *func_name, uint8_t flag)
  991. {
  992. struct dp_rx_desc_dbg_info *info = rx_desc->dbg_info;
  993. if (!info)
  994. return;
  995. if (flag == RX_DESC_REPLENISHED) {
  996. qdf_str_lcopy(info->replenish_caller, func_name,
  997. QDF_MEM_FUNC_NAME_SIZE);
  998. info->replenish_ts = qdf_get_log_timestamp();
  999. } else {
  1000. qdf_str_lcopy(info->freelist_caller, func_name,
  1001. QDF_MEM_FUNC_NAME_SIZE);
  1002. info->freelist_ts = qdf_get_log_timestamp();
  1003. info->prev_nbuf = rx_desc->nbuf;
  1004. info->prev_nbuf_data_addr = rx_desc->nbuf_data_addr;
  1005. rx_desc->nbuf_data_addr = NULL;
  1006. }
  1007. }
  1008. #else
  1009. static inline
  1010. void dp_rx_desc_alloc_dbg_info(struct dp_rx_desc *rx_desc)
  1011. {
  1012. }
  1013. static inline
  1014. void dp_rx_desc_free_dbg_info(struct dp_rx_desc *rx_desc)
  1015. {
  1016. }
  1017. static inline
  1018. void dp_rx_desc_update_dbg_info(struct dp_rx_desc *rx_desc,
  1019. const char *func_name, uint8_t flag)
  1020. {
  1021. }
  1022. #endif /* RX_DESC_LOGGING */
  1023. /**
  1024. * __dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list
  1025. *
  1026. * @head: pointer to the head of local free list
  1027. * @tail: pointer to the tail of local free list
  1028. * @new: new descriptor that is added to the free list
  1029. * @func_name: caller func name
  1030. *
  1031. * Return: void:
  1032. */
  1033. static inline
  1034. void __dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head,
  1035. union dp_rx_desc_list_elem_t **tail,
  1036. struct dp_rx_desc *new, const char *func_name)
  1037. {
  1038. qdf_assert(head && new);
  1039. dp_rx_desc_update_dbg_info(new, func_name, RX_DESC_IN_FREELIST);
  1040. new->nbuf = NULL;
  1041. new->in_use = 0;
  1042. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  1043. *head = (union dp_rx_desc_list_elem_t *)new;
  1044. /* reset tail if head->next is NULL */
  1045. if (!*tail || !(*head)->next)
  1046. *tail = *head;
  1047. }
  1048. /**
  1049. * dp_rx_process_invalid_peer(): Function to pass invalid peer list to umac
  1050. * @soc: DP SOC handle
  1051. * @nbuf: network buffer
  1052. * @mac_id: mac_id which is one of 3 mac_ids(Assuming mac_id and
  1053. * pool_id has same mapping)
  1054. *
  1055. * Return: integer type
  1056. */
  1057. uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1058. uint8_t mac_id);
  1059. /**
  1060. * dp_rx_process_invalid_peer_wrapper(): Function to wrap invalid peer handler
  1061. * @soc: DP SOC handle
  1062. * @mpdu: mpdu for which peer is invalid
  1063. * @mpdu_done: if an mpdu is completed
  1064. * @mac_id: mac_id which is one of 3 mac_ids(Assuming mac_id and
  1065. * pool_id has same mapping)
  1066. *
  1067. * Return: integer type
  1068. */
  1069. void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
  1070. qdf_nbuf_t mpdu, bool mpdu_done, uint8_t mac_id);
  1071. #define DP_RX_HEAD_APPEND(head, elem) \
  1072. do { \
  1073. qdf_nbuf_set_next((elem), (head)); \
  1074. (head) = (elem); \
  1075. } while (0)
  1076. #define DP_RX_LIST_APPEND(head, tail, elem) \
  1077. do { \
  1078. if (!(head)) { \
  1079. (head) = (elem); \
  1080. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\
  1081. } else { \
  1082. qdf_nbuf_set_next((tail), (elem)); \
  1083. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \
  1084. } \
  1085. (tail) = (elem); \
  1086. qdf_nbuf_set_next((tail), NULL); \
  1087. } while (0)
  1088. #define DP_RX_MERGE_TWO_LIST(phead, ptail, chead, ctail) \
  1089. do { \
  1090. if (!(phead)) { \
  1091. (phead) = (chead); \
  1092. } else { \
  1093. qdf_nbuf_set_next((ptail), (chead)); \
  1094. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(phead) += \
  1095. QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(chead); \
  1096. } \
  1097. (ptail) = (ctail); \
  1098. qdf_nbuf_set_next((ptail), NULL); \
  1099. } while (0)
  1100. #if defined(QCA_PADDR_CHECK_ON_3TH_PLATFORM)
  1101. /*
  1102. * on some third-party platform, the memory below 0x2000
  1103. * is reserved for target use, so any memory allocated in this
  1104. * region should not be used by host
  1105. */
  1106. #define MAX_RETRY 50
  1107. #define DP_PHY_ADDR_RESERVED 0x2000
  1108. #elif defined(BUILD_X86)
  1109. /*
  1110. * in M2M emulation platforms (x86) the memory below 0x50000000
  1111. * is reserved for target use, so any memory allocated in this
  1112. * region should not be used by host
  1113. */
  1114. #define MAX_RETRY 100
  1115. #define DP_PHY_ADDR_RESERVED 0x50000000
  1116. #endif
  1117. #if defined(QCA_PADDR_CHECK_ON_3TH_PLATFORM) || defined(BUILD_X86)
  1118. /**
  1119. * dp_check_paddr() - check if current phy address is valid or not
  1120. * @dp_soc: core txrx main context
  1121. * @rx_netbuf: skb buffer
  1122. * @paddr: physical address
  1123. * @rx_desc_pool: struct of rx descriptor pool
  1124. * check if the physical address of the nbuf->data is less
  1125. * than DP_PHY_ADDR_RESERVED then free the nbuf and try
  1126. * allocating new nbuf. We can try for 100 times.
  1127. *
  1128. * This is a temp WAR till we fix it properly.
  1129. *
  1130. * Return: success or failure.
  1131. */
  1132. static inline
  1133. int dp_check_paddr(struct dp_soc *dp_soc,
  1134. qdf_nbuf_t *rx_netbuf,
  1135. qdf_dma_addr_t *paddr,
  1136. struct rx_desc_pool *rx_desc_pool)
  1137. {
  1138. uint32_t nbuf_retry = 0;
  1139. int32_t ret;
  1140. if (qdf_likely(*paddr > DP_PHY_ADDR_RESERVED))
  1141. return QDF_STATUS_SUCCESS;
  1142. do {
  1143. dp_debug("invalid phy addr 0x%llx, trying again",
  1144. (uint64_t)(*paddr));
  1145. nbuf_retry++;
  1146. if ((*rx_netbuf)) {
  1147. /* Not freeing buffer intentionally.
  1148. * Observed that same buffer is getting
  1149. * re-allocated resulting in longer load time
  1150. * WMI init timeout.
  1151. * This buffer is anyway not useful so skip it.
  1152. *.Add such buffer to invalid list and free
  1153. *.them when driver unload.
  1154. **/
  1155. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev,
  1156. *rx_netbuf,
  1157. QDF_DMA_FROM_DEVICE,
  1158. rx_desc_pool->buf_size);
  1159. qdf_nbuf_queue_add(&dp_soc->invalid_buf_queue,
  1160. *rx_netbuf);
  1161. }
  1162. *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  1163. rx_desc_pool->buf_size,
  1164. RX_BUFFER_RESERVATION,
  1165. rx_desc_pool->buf_alignment,
  1166. FALSE);
  1167. if (qdf_unlikely(!(*rx_netbuf)))
  1168. return QDF_STATUS_E_FAILURE;
  1169. ret = qdf_nbuf_map_nbytes_single(dp_soc->osdev,
  1170. *rx_netbuf,
  1171. QDF_DMA_FROM_DEVICE,
  1172. rx_desc_pool->buf_size);
  1173. if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) {
  1174. qdf_nbuf_free(*rx_netbuf);
  1175. *rx_netbuf = NULL;
  1176. continue;
  1177. }
  1178. *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0);
  1179. if (qdf_likely(*paddr > DP_PHY_ADDR_RESERVED))
  1180. return QDF_STATUS_SUCCESS;
  1181. } while (nbuf_retry < MAX_RETRY);
  1182. if ((*rx_netbuf)) {
  1183. qdf_nbuf_unmap_nbytes_single(dp_soc->osdev,
  1184. *rx_netbuf,
  1185. QDF_DMA_FROM_DEVICE,
  1186. rx_desc_pool->buf_size);
  1187. qdf_nbuf_queue_add(&dp_soc->invalid_buf_queue,
  1188. *rx_netbuf);
  1189. }
  1190. return QDF_STATUS_E_FAILURE;
  1191. }
  1192. #else
  1193. static inline
  1194. int dp_check_paddr(struct dp_soc *dp_soc,
  1195. qdf_nbuf_t *rx_netbuf,
  1196. qdf_dma_addr_t *paddr,
  1197. struct rx_desc_pool *rx_desc_pool)
  1198. {
  1199. return QDF_STATUS_SUCCESS;
  1200. }
  1201. #endif
  1202. /**
  1203. * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of
  1204. * the MSDU Link Descriptor
  1205. * @soc: core txrx main context
  1206. * @buf_info: buf_info includes cookie that is used to lookup
  1207. * virtual address of link descriptor after deriving the page id
  1208. * and the offset or index of the desc on the associatde page.
  1209. *
  1210. * This is the VA of the link descriptor, that HAL layer later uses to
  1211. * retrieve the list of MSDU's for a given MPDU.
  1212. *
  1213. * Return: void *: Virtual Address of the Rx descriptor
  1214. */
  1215. static inline
  1216. void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc,
  1217. struct hal_buf_info *buf_info)
  1218. {
  1219. void *link_desc_va;
  1220. struct qdf_mem_multi_page_t *pages;
  1221. uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
  1222. pages = &soc->link_desc_pages;
  1223. if (!pages)
  1224. return NULL;
  1225. if (qdf_unlikely(page_id >= pages->num_pages))
  1226. return NULL;
  1227. link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
  1228. (buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
  1229. return link_desc_va;
  1230. }
  1231. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1232. #ifdef DISABLE_EAPOL_INTRABSS_FWD
  1233. #ifdef WLAN_FEATURE_11BE_MLO
  1234. static inline bool dp_nbuf_dst_addr_is_mld_addr(struct dp_vdev *vdev,
  1235. qdf_nbuf_t nbuf)
  1236. {
  1237. struct qdf_mac_addr *self_mld_mac_addr =
  1238. (struct qdf_mac_addr *)vdev->mld_mac_addr.raw;
  1239. return qdf_is_macaddr_equal(self_mld_mac_addr,
  1240. (struct qdf_mac_addr *)qdf_nbuf_data(nbuf) +
  1241. QDF_NBUF_DEST_MAC_OFFSET);
  1242. }
  1243. #else
  1244. static inline bool dp_nbuf_dst_addr_is_mld_addr(struct dp_vdev *vdev,
  1245. qdf_nbuf_t nbuf)
  1246. {
  1247. return false;
  1248. }
  1249. #endif
  1250. static inline bool dp_nbuf_dst_addr_is_self_addr(struct dp_vdev *vdev,
  1251. qdf_nbuf_t nbuf)
  1252. {
  1253. return qdf_is_macaddr_equal((struct qdf_mac_addr *)vdev->mac_addr.raw,
  1254. (struct qdf_mac_addr *)qdf_nbuf_data(nbuf) +
  1255. QDF_NBUF_DEST_MAC_OFFSET);
  1256. }
  1257. /**
  1258. * dp_rx_intrabss_eapol_drop_check() - API For EAPOL
  1259. * pkt with DA not equal to vdev mac addr, fwd is not allowed.
  1260. * @soc: core txrx main context
  1261. * @ta_txrx_peer: source peer entry
  1262. * @rx_tlv_hdr: start address of rx tlvs
  1263. * @nbuf: nbuf that has to be intrabss forwarded
  1264. *
  1265. * Return: true if it is forwarded else false
  1266. */
  1267. static inline
  1268. bool dp_rx_intrabss_eapol_drop_check(struct dp_soc *soc,
  1269. struct dp_txrx_peer *ta_txrx_peer,
  1270. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf)
  1271. {
  1272. if (qdf_unlikely(qdf_nbuf_is_ipv4_eapol_pkt(nbuf) &&
  1273. !(dp_nbuf_dst_addr_is_self_addr(ta_txrx_peer->vdev,
  1274. nbuf) ||
  1275. dp_nbuf_dst_addr_is_mld_addr(ta_txrx_peer->vdev,
  1276. nbuf)))) {
  1277. qdf_nbuf_free(nbuf);
  1278. DP_STATS_INC(soc, rx.err.intrabss_eapol_drop, 1);
  1279. return true;
  1280. }
  1281. return false;
  1282. }
  1283. #else /* DISABLE_EAPOL_INTRABSS_FWD */
  1284. static inline
  1285. bool dp_rx_intrabss_eapol_drop_check(struct dp_soc *soc,
  1286. struct dp_txrx_peer *ta_txrx_peer,
  1287. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf)
  1288. {
  1289. return false;
  1290. }
  1291. #endif /* DISABLE_EAPOL_INTRABSS_FWD */
  1292. /**
  1293. * dp_rx_intrabss_mcbc_fwd() - Does intrabss forward for mcast packets
  1294. * @soc: core txrx main context
  1295. * @ta_peer: source peer entry
  1296. * @rx_tlv_hdr: start address of rx tlvs
  1297. * @nbuf: nbuf that has to be intrabss forwarded
  1298. * @tid_stats: tid stats pointer
  1299. * @link_id: link Id on which packet is received
  1300. *
  1301. * Return: bool: true if it is forwarded else false
  1302. */
  1303. bool dp_rx_intrabss_mcbc_fwd(struct dp_soc *soc,
  1304. struct dp_txrx_peer *ta_peer,
  1305. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf,
  1306. struct cdp_tid_rx_stats *tid_stats,
  1307. uint8_t link_id);
  1308. /**
  1309. * dp_rx_intrabss_ucast_fwd() - Does intrabss forward for unicast packets
  1310. * @soc: core txrx main context
  1311. * @ta_peer: source peer entry
  1312. * @tx_vdev_id: VDEV ID for Intra-BSS TX
  1313. * @rx_tlv_hdr: start address of rx tlvs
  1314. * @nbuf: nbuf that has to be intrabss forwarded
  1315. * @tid_stats: tid stats pointer
  1316. * @link_id: link Id on which packet is received
  1317. *
  1318. * Return: bool: true if it is forwarded else false
  1319. */
  1320. bool dp_rx_intrabss_ucast_fwd(struct dp_soc *soc,
  1321. struct dp_txrx_peer *ta_peer,
  1322. uint8_t tx_vdev_id,
  1323. uint8_t *rx_tlv_hdr, qdf_nbuf_t nbuf,
  1324. struct cdp_tid_rx_stats *tid_stats,
  1325. uint8_t link_id);
  1326. /**
  1327. * dp_rx_defrag_concat() - Concatenate the fragments
  1328. *
  1329. * @dst: destination pointer to the buffer
  1330. * @src: source pointer from where the fragment payload is to be copied
  1331. *
  1332. * Return: QDF_STATUS
  1333. */
  1334. static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
  1335. {
  1336. /*
  1337. * Inside qdf_nbuf_cat, if it is necessary to reallocate dst
  1338. * to provide space for src, the headroom portion is copied from
  1339. * the original dst buffer to the larger new dst buffer.
  1340. * (This is needed, because the headroom of the dst buffer
  1341. * contains the rx desc.)
  1342. */
  1343. if (!qdf_nbuf_cat(dst, src)) {
  1344. /*
  1345. * qdf_nbuf_cat does not free the src memory.
  1346. * Free src nbuf before returning
  1347. * For failure case the caller takes of freeing the nbuf
  1348. */
  1349. qdf_nbuf_free(src);
  1350. return QDF_STATUS_SUCCESS;
  1351. }
  1352. return QDF_STATUS_E_DEFRAG_ERROR;
  1353. }
  1354. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1355. #ifndef FEATURE_WDS
  1356. void dp_rx_da_learn(struct dp_soc *soc, uint8_t *rx_tlv_hdr,
  1357. struct dp_txrx_peer *ta_txrx_peer, qdf_nbuf_t nbuf);
  1358. static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
  1359. {
  1360. return QDF_STATUS_SUCCESS;
  1361. }
  1362. static inline void
  1363. dp_rx_wds_srcport_learn(struct dp_soc *soc,
  1364. uint8_t *rx_tlv_hdr,
  1365. struct dp_txrx_peer *txrx_peer,
  1366. qdf_nbuf_t nbuf,
  1367. struct hal_rx_msdu_metadata msdu_metadata)
  1368. {
  1369. }
  1370. static inline void
  1371. dp_rx_ipa_wds_srcport_learn(struct dp_soc *soc,
  1372. struct dp_peer *ta_peer, qdf_nbuf_t nbuf,
  1373. struct hal_rx_msdu_metadata msdu_end_info,
  1374. bool ad4_valid, bool chfrag_start)
  1375. {
  1376. }
  1377. #endif
  1378. /**
  1379. * dp_rx_desc_dump() - dump the sw rx descriptor
  1380. *
  1381. * @rx_desc: sw rx descriptor
  1382. */
  1383. static inline void dp_rx_desc_dump(struct dp_rx_desc *rx_desc)
  1384. {
  1385. dp_info("rx_desc->nbuf: %pK, rx_desc->cookie: %d, rx_desc->pool_id: %d, rx_desc->in_use: %d, rx_desc->unmapped: %d",
  1386. rx_desc->nbuf, rx_desc->cookie, rx_desc->pool_id,
  1387. rx_desc->in_use, rx_desc->unmapped);
  1388. }
  1389. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1390. /**
  1391. * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet.
  1392. * In qwrap mode, packets originated from
  1393. * any vdev should not loopback and
  1394. * should be dropped.
  1395. * @vdev: vdev on which rx packet is received
  1396. * @nbuf: rx pkt
  1397. *
  1398. */
  1399. #if ATH_SUPPORT_WRAP
  1400. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1401. qdf_nbuf_t nbuf)
  1402. {
  1403. struct dp_vdev *psta_vdev;
  1404. struct dp_pdev *pdev = vdev->pdev;
  1405. uint8_t *data = qdf_nbuf_data(nbuf);
  1406. if (qdf_unlikely(vdev->proxysta_vdev)) {
  1407. /* In qwrap isolation mode, allow loopback packets as all
  1408. * packets go to RootAP and Loopback on the mpsta.
  1409. */
  1410. if (vdev->isolation_vdev)
  1411. return false;
  1412. TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) {
  1413. if (qdf_unlikely(psta_vdev->proxysta_vdev &&
  1414. !qdf_mem_cmp(psta_vdev->mac_addr.raw,
  1415. &data[QDF_MAC_ADDR_SIZE],
  1416. QDF_MAC_ADDR_SIZE))) {
  1417. /* Drop packet if source address is equal to
  1418. * any of the vdev addresses.
  1419. */
  1420. return true;
  1421. }
  1422. }
  1423. }
  1424. return false;
  1425. }
  1426. #else
  1427. static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev,
  1428. qdf_nbuf_t nbuf)
  1429. {
  1430. return false;
  1431. }
  1432. #endif
  1433. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1434. #if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
  1435. defined(WLAN_SUPPORT_RX_TAG_STATISTICS) ||\
  1436. defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1437. #include "dp_rx_tag.h"
  1438. #endif
  1439. #if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\
  1440. !defined(WLAN_SUPPORT_RX_FLOW_TAG)
  1441. /**
  1442. * dp_rx_update_protocol_tag() - Reads CCE metadata from the RX MSDU end TLV
  1443. * and set the corresponding tag in QDF packet
  1444. * @soc: core txrx main context
  1445. * @vdev: vdev on which the packet is received
  1446. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1447. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  1448. * @ring_index: REO ring number, not used for error & monitor ring
  1449. * @is_reo_exception: flag to indicate if rx from REO ring or exception ring
  1450. * @is_update_stats: flag to indicate whether to update stats or not
  1451. *
  1452. * Return: void
  1453. */
  1454. static inline void
  1455. dp_rx_update_protocol_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1456. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  1457. uint16_t ring_index,
  1458. bool is_reo_exception, bool is_update_stats)
  1459. {
  1460. }
  1461. #endif
  1462. #ifndef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
  1463. /**
  1464. * dp_rx_err_cce_drop() - Reads CCE metadata from the RX MSDU end TLV
  1465. * and returns whether cce metadata matches
  1466. * @soc: core txrx main context
  1467. * @vdev: vdev on which the packet is received
  1468. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1469. * @rx_tlv_hdr: rBbase address where the RX TLVs starts
  1470. *
  1471. * Return: bool
  1472. */
  1473. static inline bool
  1474. dp_rx_err_cce_drop(struct dp_soc *soc, struct dp_vdev *vdev,
  1475. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr)
  1476. {
  1477. return false;
  1478. }
  1479. #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
  1480. #ifndef WLAN_SUPPORT_RX_FLOW_TAG
  1481. /**
  1482. * dp_rx_update_flow_tag() - Reads FSE metadata from the RX MSDU end TLV
  1483. * and set the corresponding tag in QDF packet
  1484. * @soc: core txrx main context
  1485. * @vdev: vdev on which the packet is received
  1486. * @nbuf: QDF pkt buffer on which the protocol tag should be set
  1487. * @rx_tlv_hdr: base address where the RX TLVs starts
  1488. * @update_stats: flag to indicate whether to update stats or not
  1489. *
  1490. * Return: void
  1491. */
  1492. static inline void
  1493. dp_rx_update_flow_tag(struct dp_soc *soc, struct dp_vdev *vdev,
  1494. qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr, bool update_stats)
  1495. {
  1496. }
  1497. #endif /* WLAN_SUPPORT_RX_FLOW_TAG */
  1498. #define CRITICAL_BUFFER_THRESHOLD 64
  1499. /**
  1500. * __dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs
  1501. * called during dp rx initialization
  1502. * and at the end of dp_rx_process.
  1503. *
  1504. * @dp_soc: core txrx main context
  1505. * @mac_id: mac_id which is one of 3 mac_ids
  1506. * @dp_rxdma_srng: dp rxdma circular ring
  1507. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1508. * @num_req_buffers: number of buffer to be replenished
  1509. * @desc_list: list of descs if called from dp_rx_process
  1510. * or NULL during dp rx initialization or out of buffer
  1511. * interrupt.
  1512. * @tail: tail of descs list
  1513. * @req_only: If true don't replenish more than req buffers
  1514. * @func_name: name of the caller function
  1515. *
  1516. * Return: return success or failure
  1517. */
  1518. QDF_STATUS __dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1519. struct dp_srng *dp_rxdma_srng,
  1520. struct rx_desc_pool *rx_desc_pool,
  1521. uint32_t num_req_buffers,
  1522. union dp_rx_desc_list_elem_t **desc_list,
  1523. union dp_rx_desc_list_elem_t **tail,
  1524. bool req_only,
  1525. const char *func_name);
  1526. /**
  1527. * __dp_rx_buffers_no_map_replenish() - replenish rxdma ring with rx nbufs
  1528. * use direct APIs to get invalidate
  1529. * and get the physical address of the
  1530. * nbuf instead of map api,called during
  1531. * dp rx initialization and at the end
  1532. * of dp_rx_process.
  1533. *
  1534. * @dp_soc: core txrx main context
  1535. * @mac_id: mac_id which is one of 3 mac_ids
  1536. * @dp_rxdma_srng: dp rxdma circular ring
  1537. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1538. * @num_req_buffers: number of buffer to be replenished
  1539. * @desc_list: list of descs if called from dp_rx_process
  1540. * or NULL during dp rx initialization or out of buffer
  1541. * interrupt.
  1542. * @tail: tail of descs list
  1543. *
  1544. * Return: return success or failure
  1545. */
  1546. QDF_STATUS
  1547. __dp_rx_buffers_no_map_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1548. struct dp_srng *dp_rxdma_srng,
  1549. struct rx_desc_pool *rx_desc_pool,
  1550. uint32_t num_req_buffers,
  1551. union dp_rx_desc_list_elem_t **desc_list,
  1552. union dp_rx_desc_list_elem_t **tail);
  1553. /**
  1554. * __dp_rx_comp2refill_replenish() - replenish rxdma ring with rx nbufs
  1555. * use direct APIs to get invalidate
  1556. * and get the physical address of the
  1557. * nbuf instead of map api,called during
  1558. * dp rx initialization and at the end
  1559. * of dp_rx_process.
  1560. *
  1561. * @dp_soc: core txrx main context
  1562. * @mac_id: mac_id which is one of 3 mac_ids
  1563. * @dp_rxdma_srng: dp rxdma circular ring
  1564. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1565. * @num_req_buffers: number of buffer to be replenished
  1566. * @desc_list: list of descs if called from dp_rx_process
  1567. * or NULL during dp rx initialization or out of buffer
  1568. * interrupt.
  1569. * @tail: tail of descs list
  1570. * Return: return success or failure
  1571. */
  1572. QDF_STATUS
  1573. __dp_rx_comp2refill_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1574. struct dp_srng *dp_rxdma_srng,
  1575. struct rx_desc_pool *rx_desc_pool,
  1576. uint32_t num_req_buffers,
  1577. union dp_rx_desc_list_elem_t **desc_list,
  1578. union dp_rx_desc_list_elem_t **tail);
  1579. /**
  1580. * __dp_rx_buffers_no_map_lt_replenish() - replenish rxdma ring with rx nbufs
  1581. * use direct APIs to get invalidate
  1582. * and get the physical address of the
  1583. * nbuf instead of map api,called when
  1584. * low threshold interrupt is triggered
  1585. *
  1586. * @dp_soc: core txrx main context
  1587. * @mac_id: mac_id which is one of 3 mac_ids
  1588. * @dp_rxdma_srng: dp rxdma circular ring
  1589. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1590. *
  1591. * Return: return success or failure
  1592. */
  1593. QDF_STATUS
  1594. __dp_rx_buffers_no_map_lt_replenish(struct dp_soc *dp_soc, uint32_t mac_id,
  1595. struct dp_srng *dp_rxdma_srng,
  1596. struct rx_desc_pool *rx_desc_pool);
  1597. /**
  1598. * __dp_pdev_rx_buffers_no_map_attach() - replenish rxdma ring with rx nbufs
  1599. * use direct APIs to get invalidate
  1600. * and get the physical address of the
  1601. * nbuf instead of map api,called during
  1602. * dp rx initialization.
  1603. *
  1604. * @dp_soc: core txrx main context
  1605. * @mac_id: mac_id which is one of 3 mac_ids
  1606. * @dp_rxdma_srng: dp rxdma circular ring
  1607. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1608. * @num_req_buffers: number of buffer to be replenished
  1609. *
  1610. * Return: return success or failure
  1611. */
  1612. QDF_STATUS __dp_pdev_rx_buffers_no_map_attach(struct dp_soc *dp_soc,
  1613. uint32_t mac_id,
  1614. struct dp_srng *dp_rxdma_srng,
  1615. struct rx_desc_pool *rx_desc_pool,
  1616. uint32_t num_req_buffers);
  1617. /**
  1618. * dp_pdev_rx_buffers_attach() - replenish rxdma ring with rx nbufs
  1619. * called during dp rx initialization
  1620. *
  1621. * @dp_soc: core txrx main context
  1622. * @mac_id: mac_id which is one of 3 mac_ids
  1623. * @dp_rxdma_srng: dp rxdma circular ring
  1624. * @rx_desc_pool: Pointer to free Rx descriptor pool
  1625. * @num_req_buffers: number of buffer to be replenished
  1626. *
  1627. * Return: return success or failure
  1628. */
  1629. QDF_STATUS
  1630. dp_pdev_rx_buffers_attach(struct dp_soc *dp_soc, uint32_t mac_id,
  1631. struct dp_srng *dp_rxdma_srng,
  1632. struct rx_desc_pool *rx_desc_pool,
  1633. uint32_t num_req_buffers);
  1634. /**
  1635. * dp_rx_fill_mesh_stats() - Fills the mesh per packet receive stats
  1636. * @vdev: DP Virtual device handle
  1637. * @nbuf: Buffer pointer
  1638. * @rx_tlv_hdr: start of rx tlv header
  1639. * @txrx_peer: pointer to peer
  1640. *
  1641. * This function allocated memory for mesh receive stats and fill the
  1642. * required stats. Stores the memory address in skb cb.
  1643. *
  1644. * Return: void
  1645. */
  1646. void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1647. uint8_t *rx_tlv_hdr,
  1648. struct dp_txrx_peer *txrx_peer);
  1649. /**
  1650. * dp_rx_filter_mesh_packets() - Filters mesh unwanted packets
  1651. * @vdev: DP Virtual device handle
  1652. * @nbuf: Buffer pointer
  1653. * @rx_tlv_hdr: start of rx tlv header
  1654. *
  1655. * This checks if the received packet is matching any filter out
  1656. * catogery and and drop the packet if it matches.
  1657. *
  1658. * Return: QDF_STATUS_SUCCESS indicates drop,
  1659. * QDF_STATUS_E_FAILURE indicate to not drop
  1660. */
  1661. QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1662. uint8_t *rx_tlv_hdr);
  1663. int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev,
  1664. struct dp_txrx_peer *peer);
  1665. /**
  1666. * dp_rx_compute_delay() - Compute and fill in all timestamps
  1667. * to pass in correct fields
  1668. * @vdev: pdev handle
  1669. * @nbuf: network buffer
  1670. *
  1671. * Return: none
  1672. */
  1673. void dp_rx_compute_delay(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
  1674. #ifdef QCA_PEER_EXT_STATS
  1675. /**
  1676. * dp_rx_compute_tid_delay - Compute per TID delay stats
  1677. * @stats: TID delay stats to update
  1678. * @nbuf: NBuffer
  1679. *
  1680. * Return: Void
  1681. */
  1682. void dp_rx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  1683. qdf_nbuf_t nbuf);
  1684. #endif /* QCA_PEER_EXT_STATS */
  1685. #ifdef WLAN_SUPPORT_PPEDS
  1686. static inline
  1687. void dp_rx_set_reuse_nbuf(struct dp_rx_desc *rx_desc, qdf_nbuf_t nbuf)
  1688. {
  1689. rx_desc->reuse_nbuf = nbuf;
  1690. rx_desc->has_reuse_nbuf = true;
  1691. }
  1692. /**
  1693. * __dp_rx_add_to_free_desc_list_reuse() - Adds to a local free descriptor list
  1694. * this list will reused
  1695. *
  1696. * @head: pointer to the head of local free list
  1697. * @tail: pointer to the tail of local free list
  1698. * @new: new descriptor that is added to the free list
  1699. * @func_name: caller func name
  1700. *
  1701. * Return: void:
  1702. */
  1703. static inline
  1704. void __dp_rx_add_to_free_desc_list_reuse(union dp_rx_desc_list_elem_t **head,
  1705. union dp_rx_desc_list_elem_t **tail,
  1706. struct dp_rx_desc *new,
  1707. const char *func_name)
  1708. {
  1709. qdf_assert(head && new);
  1710. dp_rx_desc_update_dbg_info(new, func_name, RX_DESC_IN_FREELIST);
  1711. new->nbuf = NULL;
  1712. ((union dp_rx_desc_list_elem_t *)new)->next = *head;
  1713. *head = (union dp_rx_desc_list_elem_t *)new;
  1714. /* reset tail if head->next is NULL */
  1715. if (!*tail || !(*head)->next)
  1716. *tail = *head;
  1717. }
  1718. #else
  1719. static inline
  1720. void dp_rx_set_reuse_nbuf(struct dp_rx_desc *rx_desc, qdf_nbuf_t nbuf)
  1721. {
  1722. }
  1723. static inline
  1724. void __dp_rx_add_to_free_desc_list_reuse(union dp_rx_desc_list_elem_t **head,
  1725. union dp_rx_desc_list_elem_t **tail,
  1726. struct dp_rx_desc *new,
  1727. const char *func_name)
  1728. {
  1729. }
  1730. #endif
  1731. #ifdef RX_DESC_DEBUG_CHECK
  1732. /**
  1733. * dp_rx_desc_check_magic() - check the magic value in dp_rx_desc
  1734. * @rx_desc: rx descriptor pointer
  1735. *
  1736. * Return: true, if magic is correct, else false.
  1737. */
  1738. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1739. {
  1740. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC))
  1741. return false;
  1742. rx_desc->magic = 0;
  1743. return true;
  1744. }
  1745. /**
  1746. * dp_rx_desc_prep() - prepare rx desc
  1747. * @rx_desc: rx descriptor pointer to be prepared
  1748. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1749. *
  1750. * Note: assumption is that we are associating a nbuf which is mapped
  1751. *
  1752. * Return: none
  1753. */
  1754. static inline
  1755. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1756. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1757. {
  1758. rx_desc->magic = DP_RX_DESC_MAGIC;
  1759. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1760. rx_desc->unmapped = 0;
  1761. rx_desc->nbuf_data_addr = (uint8_t *)qdf_nbuf_data(rx_desc->nbuf);
  1762. dp_rx_set_reuse_nbuf(rx_desc, rx_desc->nbuf);
  1763. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1764. }
  1765. /**
  1766. * dp_rx_desc_frag_prep() - prepare rx desc
  1767. * @rx_desc: rx descriptor pointer to be prepared
  1768. * @nbuf_frag_info_t: struct dp_rx_nbuf_frag_info *
  1769. *
  1770. * Note: assumption is that we frag address is mapped
  1771. *
  1772. * Return: none
  1773. */
  1774. #ifdef DP_RX_MON_MEM_FRAG
  1775. static inline
  1776. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1777. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1778. {
  1779. rx_desc->magic = DP_RX_DESC_MAGIC;
  1780. rx_desc->rx_buf_start =
  1781. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1782. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1783. rx_desc->unmapped = 0;
  1784. }
  1785. #else
  1786. static inline
  1787. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1788. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1789. {
  1790. }
  1791. #endif /* DP_RX_MON_MEM_FRAG */
  1792. /**
  1793. * dp_rx_desc_paddr_sanity_check() - paddr sanity for ring desc vs rx_desc
  1794. * @rx_desc: rx descriptor
  1795. * @ring_paddr: paddr obatined from the ring
  1796. *
  1797. * Return: QDF_STATUS
  1798. */
  1799. static inline
  1800. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  1801. uint64_t ring_paddr)
  1802. {
  1803. return (ring_paddr == qdf_nbuf_get_frag_paddr(rx_desc->nbuf, 0));
  1804. }
  1805. #else
  1806. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  1807. {
  1808. return true;
  1809. }
  1810. static inline
  1811. void dp_rx_desc_prep(struct dp_rx_desc *rx_desc,
  1812. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1813. {
  1814. rx_desc->nbuf = (nbuf_frag_info_t->virt_addr).nbuf;
  1815. dp_rx_set_reuse_nbuf(rx_desc, rx_desc->nbuf);
  1816. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1817. rx_desc->unmapped = 0;
  1818. }
  1819. #ifdef DP_RX_MON_MEM_FRAG
  1820. static inline
  1821. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1822. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1823. {
  1824. rx_desc->rx_buf_start =
  1825. (uint8_t *)((nbuf_frag_info_t->virt_addr).vaddr);
  1826. rx_desc->paddr_buf_start = nbuf_frag_info_t->paddr;
  1827. rx_desc->unmapped = 0;
  1828. }
  1829. #else
  1830. static inline
  1831. void dp_rx_desc_frag_prep(struct dp_rx_desc *rx_desc,
  1832. struct dp_rx_nbuf_frag_info *nbuf_frag_info_t)
  1833. {
  1834. }
  1835. #endif /* DP_RX_MON_MEM_FRAG */
  1836. static inline
  1837. bool dp_rx_desc_paddr_sanity_check(struct dp_rx_desc *rx_desc,
  1838. uint64_t ring_paddr)
  1839. {
  1840. return true;
  1841. }
  1842. #endif /* RX_DESC_DEBUG_CHECK */
  1843. /**
  1844. * dp_rx_enable_mon_dest_frag() - Enable frag processing for
  1845. * monitor destination ring via frag.
  1846. * @rx_desc_pool: Rx desc pool
  1847. * @is_mon_dest_desc: Is it for monitor dest buffer
  1848. *
  1849. * Enable this flag only for monitor destination buffer processing
  1850. * if DP_RX_MON_MEM_FRAG feature is enabled.
  1851. * If flag is set then frag based function will be called for alloc,
  1852. * map, prep desc and free ops for desc buffer else normal nbuf based
  1853. * function will be called.
  1854. *
  1855. * Return: None
  1856. */
  1857. void dp_rx_enable_mon_dest_frag(struct rx_desc_pool *rx_desc_pool,
  1858. bool is_mon_dest_desc);
  1859. #ifndef QCA_MULTIPASS_SUPPORT
  1860. static inline
  1861. bool dp_rx_multipass_process(struct dp_txrx_peer *peer, qdf_nbuf_t nbuf,
  1862. uint8_t tid)
  1863. {
  1864. return false;
  1865. }
  1866. #else
  1867. /**
  1868. * dp_rx_multipass_process - insert vlan tag on frames for traffic separation
  1869. * @txrx_peer: DP txrx peer handle
  1870. * @nbuf: skb
  1871. * @tid: traffic priority
  1872. *
  1873. * Return: bool: true in case of success else false
  1874. * Success is considered if:
  1875. * i. If frame has vlan header
  1876. * ii. If the frame comes from different peer and dont need multipass processing
  1877. * Failure is considered if:
  1878. * i. Frame comes from multipass peer but doesn't contain vlan header.
  1879. * In failure case, drop such frames.
  1880. */
  1881. bool dp_rx_multipass_process(struct dp_txrx_peer *txrx_peer, qdf_nbuf_t nbuf,
  1882. uint8_t tid);
  1883. #endif
  1884. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1885. #ifndef WLAN_RX_PKT_CAPTURE_ENH
  1886. static inline
  1887. QDF_STATUS dp_peer_set_rx_capture_enabled(struct dp_pdev *pdev,
  1888. struct dp_peer *peer_handle,
  1889. bool value, uint8_t *mac_addr)
  1890. {
  1891. return QDF_STATUS_SUCCESS;
  1892. }
  1893. #endif
  1894. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1895. /**
  1896. * dp_rx_deliver_to_stack() - deliver pkts to network stack
  1897. * Caller to hold peer refcount and check for valid peer
  1898. * @soc: soc
  1899. * @vdev: vdev
  1900. * @peer: txrx peer
  1901. * @nbuf_head: skb list head
  1902. * @nbuf_tail: skb list tail
  1903. *
  1904. * Return: QDF_STATUS
  1905. */
  1906. QDF_STATUS dp_rx_deliver_to_stack(struct dp_soc *soc,
  1907. struct dp_vdev *vdev,
  1908. struct dp_txrx_peer *peer,
  1909. qdf_nbuf_t nbuf_head,
  1910. qdf_nbuf_t nbuf_tail);
  1911. #ifdef QCA_SUPPORT_EAPOL_OVER_CONTROL_PORT
  1912. /**
  1913. * dp_rx_eapol_deliver_to_stack() - deliver pkts to network stack
  1914. * caller to hold peer refcount and check for valid peer
  1915. * @soc: soc
  1916. * @vdev: vdev
  1917. * @peer: peer
  1918. * @nbuf_head: skb list head
  1919. * @nbuf_tail: skb list tail
  1920. *
  1921. * Return: QDF_STATUS
  1922. */
  1923. QDF_STATUS dp_rx_eapol_deliver_to_stack(struct dp_soc *soc,
  1924. struct dp_vdev *vdev,
  1925. struct dp_txrx_peer *peer,
  1926. qdf_nbuf_t nbuf_head,
  1927. qdf_nbuf_t nbuf_tail);
  1928. #endif
  1929. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1930. #ifdef WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL
  1931. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1932. do { \
  1933. if (!soc->rx_buff_pool[rx_desc->pool_id].is_initialized) { \
  1934. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf); \
  1935. break; \
  1936. } \
  1937. DP_RX_LIST_APPEND(ebuf_head, ebuf_tail, rx_desc->nbuf); \
  1938. if (!qdf_nbuf_is_rx_chfrag_cont(rx_desc->nbuf)) { \
  1939. if (!dp_rx_buffer_pool_refill(soc, ebuf_head, \
  1940. rx_desc->pool_id)) \
  1941. DP_RX_MERGE_TWO_LIST(head, tail, \
  1942. ebuf_head, ebuf_tail);\
  1943. ebuf_head = NULL; \
  1944. ebuf_tail = NULL; \
  1945. } \
  1946. } while (0)
  1947. #else
  1948. #define DP_RX_PROCESS_NBUF(soc, head, tail, ebuf_head, ebuf_tail, rx_desc) \
  1949. DP_RX_LIST_APPEND(head, tail, rx_desc->nbuf)
  1950. #endif /* WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL */
  1951. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1952. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  1953. /**
  1954. * dp_rx_deliver_to_pkt_capture() - deliver rx packet to packet capture
  1955. * @soc : dp_soc handle
  1956. * @pdev: dp_pdev handle
  1957. * @peer_id: peer_id of the peer for which completion came
  1958. * @is_offload:
  1959. * @netbuf: Buffer pointer
  1960. *
  1961. * This function is used to deliver rx packet to packet capture
  1962. */
  1963. void dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1964. uint16_t peer_id, uint32_t is_offload,
  1965. qdf_nbuf_t netbuf);
  1966. void dp_rx_deliver_to_pkt_capture_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1967. uint32_t is_offload);
  1968. #else
  1969. static inline void
  1970. dp_rx_deliver_to_pkt_capture(struct dp_soc *soc, struct dp_pdev *pdev,
  1971. uint16_t peer_id, uint32_t is_offload,
  1972. qdf_nbuf_t netbuf)
  1973. {
  1974. }
  1975. static inline void
  1976. dp_rx_deliver_to_pkt_capture_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf,
  1977. uint32_t is_offload)
  1978. {
  1979. }
  1980. #endif
  1981. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1982. #ifdef FEATURE_MEC
  1983. /**
  1984. * dp_rx_mcast_echo_check() - check if the mcast pkt is a loop
  1985. * back on same vap or a different vap.
  1986. * @soc: core DP main context
  1987. * @peer: dp peer handler
  1988. * @rx_tlv_hdr: start of the rx TLV header
  1989. * @nbuf: pkt buffer
  1990. *
  1991. * Return: bool (true if it is a looped back pkt else false)
  1992. *
  1993. */
  1994. bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  1995. struct dp_txrx_peer *peer,
  1996. uint8_t *rx_tlv_hdr,
  1997. qdf_nbuf_t nbuf);
  1998. #else
  1999. static inline bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  2000. struct dp_txrx_peer *peer,
  2001. uint8_t *rx_tlv_hdr,
  2002. qdf_nbuf_t nbuf)
  2003. {
  2004. return false;
  2005. }
  2006. #endif /* FEATURE_MEC */
  2007. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  2008. #ifdef RECEIVE_OFFLOAD
  2009. /**
  2010. * dp_rx_fill_gro_info() - Fill GRO info from RX TLV into skb->cb
  2011. * @soc: DP SOC handle
  2012. * @rx_tlv: RX TLV received for the msdu
  2013. * @msdu: msdu for which GRO info needs to be filled
  2014. * @rx_ol_pkt_cnt: counter to be incremented for GRO eligible packets
  2015. *
  2016. * Return: None
  2017. */
  2018. void dp_rx_fill_gro_info(struct dp_soc *soc, uint8_t *rx_tlv,
  2019. qdf_nbuf_t msdu, uint32_t *rx_ol_pkt_cnt);
  2020. #else
  2021. static inline
  2022. void dp_rx_fill_gro_info(struct dp_soc *soc, uint8_t *rx_tlv,
  2023. qdf_nbuf_t msdu, uint32_t *rx_ol_pkt_cnt)
  2024. {
  2025. }
  2026. #endif
  2027. /**
  2028. * dp_rx_msdu_stats_update() - update per msdu stats.
  2029. * @soc: core txrx main context
  2030. * @nbuf: pointer to the first msdu of an amsdu.
  2031. * @rx_tlv_hdr: pointer to the start of RX TLV headers.
  2032. * @txrx_peer: pointer to the txrx peer object.
  2033. * @ring_id: reo dest ring number on which pkt is reaped.
  2034. * @tid_stats: per tid rx stats.
  2035. * @link_id: link Id on which packet is received
  2036. *
  2037. * update all the per msdu stats for that nbuf.
  2038. *
  2039. * Return: void
  2040. */
  2041. void dp_rx_msdu_stats_update(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2042. uint8_t *rx_tlv_hdr,
  2043. struct dp_txrx_peer *txrx_peer,
  2044. uint8_t ring_id,
  2045. struct cdp_tid_rx_stats *tid_stats,
  2046. uint8_t link_id);
  2047. /**
  2048. * dp_rx_deliver_to_stack_no_peer() - try deliver rx data even if
  2049. * no corresbonding peer found
  2050. * @soc: core txrx main context
  2051. * @nbuf: pkt skb pointer
  2052. *
  2053. * This function will try to deliver some RX special frames to stack
  2054. * even there is no peer matched found. for instance, LFR case, some
  2055. * eapol data will be sent to host before peer_map done.
  2056. *
  2057. * Return: None
  2058. */
  2059. void dp_rx_deliver_to_stack_no_peer(struct dp_soc *soc, qdf_nbuf_t nbuf);
  2060. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  2061. #ifdef DP_RX_DROP_RAW_FRM
  2062. /**
  2063. * dp_rx_is_raw_frame_dropped() - if raw frame nbuf, free and drop
  2064. * @nbuf: pkt skb pointer
  2065. *
  2066. * Return: true - raw frame, dropped
  2067. * false - not raw frame, do nothing
  2068. */
  2069. bool dp_rx_is_raw_frame_dropped(qdf_nbuf_t nbuf);
  2070. #else
  2071. static inline
  2072. bool dp_rx_is_raw_frame_dropped(qdf_nbuf_t nbuf)
  2073. {
  2074. return false;
  2075. }
  2076. #endif
  2077. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  2078. /**
  2079. * dp_rx_update_stats() - Update soc level rx packet count
  2080. * @soc: DP soc handle
  2081. * @nbuf: nbuf received
  2082. *
  2083. * Return: none
  2084. */
  2085. void dp_rx_update_stats(struct dp_soc *soc, qdf_nbuf_t nbuf);
  2086. #else
  2087. static inline
  2088. void dp_rx_update_stats(struct dp_soc *soc, qdf_nbuf_t nbuf)
  2089. {
  2090. }
  2091. #endif
  2092. /**
  2093. * dp_rx_cksum_offload() - set the nbuf checksum as defined by hardware.
  2094. * @pdev: dp_pdev handle
  2095. * @nbuf: pointer to the first msdu of an amsdu.
  2096. * @rx_tlv_hdr: pointer to the start of RX TLV headers.
  2097. *
  2098. * The ipsumed field of the skb is set based on whether HW validated the
  2099. * IP/TCP/UDP checksum.
  2100. *
  2101. * Return: void
  2102. */
  2103. #if defined(MAX_PDEV_CNT) && (MAX_PDEV_CNT == 1)
  2104. static inline
  2105. void dp_rx_cksum_offload(struct dp_pdev *pdev,
  2106. qdf_nbuf_t nbuf,
  2107. uint8_t *rx_tlv_hdr)
  2108. {
  2109. qdf_nbuf_rx_cksum_t cksum = {0};
  2110. //TODO - Move this to ring desc api
  2111. //HAL_RX_MSDU_DESC_IP_CHKSUM_FAIL_GET
  2112. //HAL_RX_MSDU_DESC_TCP_UDP_CHKSUM_FAIL_GET
  2113. uint32_t ip_csum_err, tcp_udp_csum_er;
  2114. hal_rx_tlv_csum_err_get(pdev->soc->hal_soc, rx_tlv_hdr, &ip_csum_err,
  2115. &tcp_udp_csum_er);
  2116. if (qdf_nbuf_is_ipv4_pkt(nbuf)) {
  2117. if (qdf_likely(!ip_csum_err)) {
  2118. cksum.l4_result = QDF_NBUF_RX_CKSUM_TCP_UDP_UNNECESSARY;
  2119. if (qdf_nbuf_is_ipv4_udp_pkt(nbuf) ||
  2120. qdf_nbuf_is_ipv4_tcp_pkt(nbuf)) {
  2121. if (qdf_likely(!tcp_udp_csum_er))
  2122. cksum.csum_level = 1;
  2123. else
  2124. DP_STATS_INCC(pdev,
  2125. err.tcp_udp_csum_err, 1,
  2126. tcp_udp_csum_er);
  2127. }
  2128. } else {
  2129. DP_STATS_INCC(pdev, err.ip_csum_err, 1, ip_csum_err);
  2130. }
  2131. } else if (qdf_nbuf_is_ipv6_udp_pkt(nbuf) ||
  2132. qdf_nbuf_is_ipv6_tcp_pkt(nbuf)) {
  2133. if (qdf_likely(!tcp_udp_csum_er))
  2134. cksum.l4_result = QDF_NBUF_RX_CKSUM_TCP_UDP_UNNECESSARY;
  2135. else
  2136. DP_STATS_INCC(pdev, err.tcp_udp_csum_err, 1,
  2137. tcp_udp_csum_er);
  2138. } else {
  2139. cksum.l4_result = QDF_NBUF_RX_CKSUM_NONE;
  2140. }
  2141. qdf_nbuf_set_rx_cksum(nbuf, &cksum);
  2142. }
  2143. #else
  2144. static inline
  2145. void dp_rx_cksum_offload(struct dp_pdev *pdev,
  2146. qdf_nbuf_t nbuf,
  2147. uint8_t *rx_tlv_hdr)
  2148. {
  2149. }
  2150. #endif
  2151. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  2152. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  2153. static inline
  2154. bool dp_rx_reap_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  2155. int max_reap_limit)
  2156. {
  2157. bool limit_hit = false;
  2158. limit_hit =
  2159. (num_reaped >= max_reap_limit) ? true : false;
  2160. if (limit_hit)
  2161. DP_STATS_INC(soc, rx.reap_loop_pkt_limit_hit, 1)
  2162. return limit_hit;
  2163. }
  2164. static inline
  2165. bool dp_rx_enable_eol_data_check(struct dp_soc *soc)
  2166. {
  2167. return soc->wlan_cfg_ctx->rx_enable_eol_data_check;
  2168. }
  2169. static inline int dp_rx_get_loop_pkt_limit(struct dp_soc *soc)
  2170. {
  2171. struct wlan_cfg_dp_soc_ctxt *cfg = soc->wlan_cfg_ctx;
  2172. return cfg->rx_reap_loop_pkt_limit;
  2173. }
  2174. #else
  2175. static inline
  2176. bool dp_rx_reap_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  2177. int max_reap_limit)
  2178. {
  2179. return false;
  2180. }
  2181. static inline
  2182. bool dp_rx_enable_eol_data_check(struct dp_soc *soc)
  2183. {
  2184. return false;
  2185. }
  2186. static inline int dp_rx_get_loop_pkt_limit(struct dp_soc *soc)
  2187. {
  2188. return 0;
  2189. }
  2190. #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */
  2191. void dp_rx_update_stats(struct dp_soc *soc, qdf_nbuf_t nbuf);
  2192. static inline uint16_t
  2193. dp_rx_peer_metadata_peer_id_get(struct dp_soc *soc, uint32_t peer_metadata)
  2194. {
  2195. return soc->arch_ops.dp_rx_peer_metadata_peer_id_get(soc,
  2196. peer_metadata);
  2197. }
  2198. static inline uint8_t
  2199. dp_rx_peer_mdata_link_id_get(struct dp_soc *soc, uint32_t peer_metadata)
  2200. {
  2201. return soc->arch_ops.dp_rx_peer_mdata_link_id_get(peer_metadata);
  2202. }
  2203. /**
  2204. * dp_rx_desc_pool_init_generic() - Generic Rx descriptors initialization
  2205. * @soc: SOC handle
  2206. * @rx_desc_pool: pointer to RX descriptor pool
  2207. * @pool_id: pool ID
  2208. *
  2209. * Return: None
  2210. */
  2211. QDF_STATUS dp_rx_desc_pool_init_generic(struct dp_soc *soc,
  2212. struct rx_desc_pool *rx_desc_pool,
  2213. uint32_t pool_id);
  2214. void dp_rx_desc_pool_deinit_generic(struct dp_soc *soc,
  2215. struct rx_desc_pool *rx_desc_pool,
  2216. uint32_t pool_id);
  2217. /**
  2218. * dp_rx_pkt_tracepoints_enabled() - Get the state of rx pkt tracepoint
  2219. *
  2220. * Return: True if any rx pkt tracepoint is enabled else false
  2221. */
  2222. static inline
  2223. bool dp_rx_pkt_tracepoints_enabled(void)
  2224. {
  2225. return (qdf_trace_dp_rx_tcp_pkt_enabled() ||
  2226. qdf_trace_dp_rx_udp_pkt_enabled() ||
  2227. qdf_trace_dp_rx_pkt_enabled());
  2228. }
  2229. #ifdef FEATURE_DIRECT_LINK
  2230. /**
  2231. * dp_audio_smmu_map()- Map memory region into Audio SMMU CB
  2232. * @qdf_dev: pointer to QDF device structure
  2233. * @paddr: physical address
  2234. * @iova: DMA address
  2235. * @size: memory region size
  2236. *
  2237. * Return: 0 on success else failure code
  2238. */
  2239. static inline
  2240. int dp_audio_smmu_map(qdf_device_t qdf_dev, qdf_dma_addr_t paddr,
  2241. qdf_dma_addr_t iova, qdf_size_t size)
  2242. {
  2243. return pld_audio_smmu_map(qdf_dev->dev, paddr, iova, size);
  2244. }
  2245. /**
  2246. * dp_audio_smmu_unmap()- Remove memory region mapping from Audio SMMU CB
  2247. * @qdf_dev: pointer to QDF device structure
  2248. * @iova: DMA address
  2249. * @size: memory region size
  2250. *
  2251. * Return: None
  2252. */
  2253. static inline
  2254. void dp_audio_smmu_unmap(qdf_device_t qdf_dev, qdf_dma_addr_t iova,
  2255. qdf_size_t size)
  2256. {
  2257. pld_audio_smmu_unmap(qdf_dev->dev, iova, size);
  2258. }
  2259. #else
  2260. static inline
  2261. int dp_audio_smmu_map(qdf_device_t qdf_dev, qdf_dma_addr_t paddr,
  2262. qdf_dma_addr_t iova, qdf_size_t size)
  2263. {
  2264. return 0;
  2265. }
  2266. static inline
  2267. void dp_audio_smmu_unmap(qdf_device_t qdf_dev, qdf_dma_addr_t iova,
  2268. qdf_size_t size)
  2269. {
  2270. }
  2271. #endif
  2272. #if defined(QCA_DP_RX_NBUF_NO_MAP_UNMAP) && !defined(BUILD_X86)
  2273. static inline
  2274. void dp_rx_set_err_info(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2275. struct hal_wbm_err_desc_info wbm_err_info)
  2276. {
  2277. QDF_NBUF_CB_RX_ERR_CODES(nbuf) = *((uint32_t *)&wbm_err_info);
  2278. }
  2279. static inline
  2280. struct hal_wbm_err_desc_info dp_rx_get_err_info(struct dp_soc *soc,
  2281. qdf_nbuf_t nbuf)
  2282. {
  2283. return *(struct hal_wbm_err_desc_info *)&QDF_NBUF_CB_RX_ERR_CODES(nbuf);
  2284. }
  2285. static inline
  2286. QDF_STATUS dp_pdev_rx_buffers_attach_simple(struct dp_soc *soc, uint32_t mac_id,
  2287. struct dp_srng *rxdma_srng,
  2288. struct rx_desc_pool *rx_desc_pool,
  2289. uint32_t num_req_buffers)
  2290. {
  2291. return __dp_pdev_rx_buffers_no_map_attach(soc, mac_id,
  2292. rxdma_srng,
  2293. rx_desc_pool,
  2294. num_req_buffers);
  2295. }
  2296. static inline
  2297. void dp_rx_buffers_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2298. struct dp_srng *rxdma_srng,
  2299. struct rx_desc_pool *rx_desc_pool,
  2300. uint32_t num_req_buffers,
  2301. union dp_rx_desc_list_elem_t **desc_list,
  2302. union dp_rx_desc_list_elem_t **tail)
  2303. {
  2304. __dp_rx_buffers_no_map_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2305. num_req_buffers, desc_list, tail);
  2306. }
  2307. static inline
  2308. void dp_rx_comp2refill_replenish(struct dp_soc *soc, uint32_t mac_id,
  2309. struct dp_srng *rxdma_srng,
  2310. struct rx_desc_pool *rx_desc_pool,
  2311. uint32_t num_req_buffers,
  2312. union dp_rx_desc_list_elem_t **desc_list,
  2313. union dp_rx_desc_list_elem_t **tail)
  2314. {
  2315. __dp_rx_comp2refill_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2316. num_req_buffers, desc_list, tail);
  2317. }
  2318. static inline
  2319. void dp_rx_buffers_lt_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2320. struct dp_srng *rxdma_srng,
  2321. struct rx_desc_pool *rx_desc_pool,
  2322. uint32_t num_req_buffers,
  2323. union dp_rx_desc_list_elem_t **desc_list,
  2324. union dp_rx_desc_list_elem_t **tail)
  2325. {
  2326. __dp_rx_buffers_no_map_lt_replenish(soc, mac_id, rxdma_srng,
  2327. rx_desc_pool);
  2328. }
  2329. #ifndef QCA_DP_NBUF_FAST_RECYCLE_CHECK
  2330. static inline
  2331. qdf_dma_addr_t dp_rx_nbuf_sync_no_dsb(struct dp_soc *dp_soc,
  2332. qdf_nbuf_t nbuf,
  2333. uint32_t buf_size)
  2334. {
  2335. qdf_nbuf_dma_inv_range_no_dsb((void *)nbuf->data,
  2336. (void *)(nbuf->data + buf_size));
  2337. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  2338. }
  2339. #else
  2340. #define L3_HEADER_PAD 2
  2341. static inline
  2342. qdf_dma_addr_t dp_rx_nbuf_sync_no_dsb(struct dp_soc *dp_soc,
  2343. qdf_nbuf_t nbuf,
  2344. uint32_t buf_size)
  2345. {
  2346. if (nbuf->recycled_for_ds)
  2347. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  2348. if (unlikely(!nbuf->fast_recycled)) {
  2349. qdf_nbuf_dma_inv_range_no_dsb((void *)nbuf->data,
  2350. (void *)(nbuf->data + buf_size));
  2351. }
  2352. DP_STATS_INC(dp_soc, rx.fast_recycled, 1);
  2353. nbuf->fast_recycled = 0;
  2354. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  2355. }
  2356. #endif
  2357. static inline
  2358. qdf_dma_addr_t dp_rx_nbuf_sync(struct dp_soc *dp_soc,
  2359. qdf_nbuf_t nbuf,
  2360. uint32_t buf_size)
  2361. {
  2362. qdf_nbuf_dma_inv_range((void *)nbuf->data,
  2363. (void *)(nbuf->data + buf_size));
  2364. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  2365. }
  2366. #if !defined(SPECULATIVE_READ_DISABLED)
  2367. static inline
  2368. void dp_rx_nbuf_unmap(struct dp_soc *soc,
  2369. struct dp_rx_desc *rx_desc,
  2370. uint8_t reo_ring_num)
  2371. {
  2372. struct rx_desc_pool *rx_desc_pool;
  2373. qdf_nbuf_t nbuf;
  2374. rx_desc_pool = &soc->rx_desc_buf[rx_desc->pool_id];
  2375. nbuf = rx_desc->nbuf;
  2376. qdf_nbuf_dma_inv_range_no_dsb((void *)nbuf->data,
  2377. (void *)(nbuf->data + rx_desc_pool->buf_size));
  2378. }
  2379. static inline
  2380. void dp_rx_nbuf_unmap_pool(struct dp_soc *soc,
  2381. struct rx_desc_pool *rx_desc_pool,
  2382. qdf_nbuf_t nbuf)
  2383. {
  2384. qdf_nbuf_dma_inv_range((void *)nbuf->data,
  2385. (void *)(nbuf->data + rx_desc_pool->buf_size));
  2386. }
  2387. #else
  2388. static inline
  2389. void dp_rx_nbuf_unmap(struct dp_soc *soc,
  2390. struct dp_rx_desc *rx_desc,
  2391. uint8_t reo_ring_num)
  2392. {
  2393. }
  2394. static inline
  2395. void dp_rx_nbuf_unmap_pool(struct dp_soc *soc,
  2396. struct rx_desc_pool *rx_desc_pool,
  2397. qdf_nbuf_t nbuf)
  2398. {
  2399. }
  2400. #endif
  2401. static inline
  2402. void dp_rx_per_core_stats_update(struct dp_soc *soc, uint8_t ring_id,
  2403. uint32_t bufs_reaped)
  2404. {
  2405. }
  2406. static inline
  2407. qdf_nbuf_t dp_rx_nbuf_alloc(struct dp_soc *soc,
  2408. struct rx_desc_pool *rx_desc_pool)
  2409. {
  2410. return qdf_nbuf_alloc_simple(soc->osdev, rx_desc_pool->buf_size,
  2411. RX_BUFFER_RESERVATION,
  2412. rx_desc_pool->buf_alignment, FALSE);
  2413. }
  2414. static inline
  2415. void dp_rx_nbuf_free(qdf_nbuf_t nbuf)
  2416. {
  2417. qdf_nbuf_free_simple(nbuf);
  2418. }
  2419. #else
  2420. static inline
  2421. void dp_rx_set_err_info(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2422. struct hal_wbm_err_desc_info wbm_err_info)
  2423. {
  2424. hal_rx_priv_info_set_in_tlv(soc->hal_soc,
  2425. qdf_nbuf_data(nbuf),
  2426. (uint8_t *)&wbm_err_info,
  2427. sizeof(wbm_err_info));
  2428. }
  2429. static inline
  2430. struct hal_wbm_err_desc_info dp_rx_get_err_info(struct dp_soc *soc,
  2431. qdf_nbuf_t nbuf)
  2432. {
  2433. struct hal_wbm_err_desc_info wbm_err_info = { 0 };
  2434. hal_rx_priv_info_get_from_tlv(soc->hal_soc, qdf_nbuf_data(nbuf),
  2435. (uint8_t *)&wbm_err_info,
  2436. sizeof(struct hal_wbm_err_desc_info));
  2437. return wbm_err_info;
  2438. }
  2439. static inline
  2440. QDF_STATUS dp_pdev_rx_buffers_attach_simple(struct dp_soc *soc, uint32_t mac_id,
  2441. struct dp_srng *rxdma_srng,
  2442. struct rx_desc_pool *rx_desc_pool,
  2443. uint32_t num_req_buffers)
  2444. {
  2445. return dp_pdev_rx_buffers_attach(soc, mac_id,
  2446. rxdma_srng,
  2447. rx_desc_pool,
  2448. num_req_buffers);
  2449. }
  2450. static inline
  2451. void dp_rx_buffers_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2452. struct dp_srng *rxdma_srng,
  2453. struct rx_desc_pool *rx_desc_pool,
  2454. uint32_t num_req_buffers,
  2455. union dp_rx_desc_list_elem_t **desc_list,
  2456. union dp_rx_desc_list_elem_t **tail)
  2457. {
  2458. dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2459. num_req_buffers, desc_list, tail, false);
  2460. }
  2461. static inline
  2462. void dp_rx_buffers_lt_replenish_simple(struct dp_soc *soc, uint32_t mac_id,
  2463. struct dp_srng *rxdma_srng,
  2464. struct rx_desc_pool *rx_desc_pool,
  2465. uint32_t num_req_buffers,
  2466. union dp_rx_desc_list_elem_t **desc_list,
  2467. union dp_rx_desc_list_elem_t **tail)
  2468. {
  2469. dp_rx_buffers_replenish(soc, mac_id, rxdma_srng, rx_desc_pool,
  2470. num_req_buffers, desc_list, tail, false);
  2471. }
  2472. static inline
  2473. qdf_dma_addr_t dp_rx_nbuf_sync_no_dsb(struct dp_soc *dp_soc,
  2474. qdf_nbuf_t nbuf,
  2475. uint32_t buf_size)
  2476. {
  2477. return (qdf_dma_addr_t)NULL;
  2478. }
  2479. static inline
  2480. qdf_dma_addr_t dp_rx_nbuf_sync(struct dp_soc *dp_soc,
  2481. qdf_nbuf_t nbuf,
  2482. uint32_t buf_size)
  2483. {
  2484. return (qdf_dma_addr_t)NULL;
  2485. }
  2486. static inline
  2487. void dp_rx_nbuf_unmap(struct dp_soc *soc,
  2488. struct dp_rx_desc *rx_desc,
  2489. uint8_t reo_ring_num)
  2490. {
  2491. struct rx_desc_pool *rx_desc_pool;
  2492. rx_desc_pool = &soc->rx_desc_buf[rx_desc->pool_id];
  2493. dp_ipa_reo_ctx_buf_mapping_lock(soc, reo_ring_num);
  2494. dp_audio_smmu_unmap(soc->osdev,
  2495. QDF_NBUF_CB_PADDR(rx_desc->nbuf),
  2496. rx_desc_pool->buf_size);
  2497. dp_ipa_handle_rx_buf_smmu_mapping(soc, rx_desc->nbuf,
  2498. rx_desc_pool->buf_size,
  2499. false, __func__, __LINE__);
  2500. qdf_nbuf_unmap_nbytes_single(soc->osdev, rx_desc->nbuf,
  2501. QDF_DMA_FROM_DEVICE,
  2502. rx_desc_pool->buf_size);
  2503. dp_ipa_reo_ctx_buf_mapping_unlock(soc, reo_ring_num);
  2504. }
  2505. static inline
  2506. void dp_rx_nbuf_unmap_pool(struct dp_soc *soc,
  2507. struct rx_desc_pool *rx_desc_pool,
  2508. qdf_nbuf_t nbuf)
  2509. {
  2510. dp_audio_smmu_unmap(soc->osdev, QDF_NBUF_CB_PADDR(nbuf),
  2511. rx_desc_pool->buf_size);
  2512. dp_ipa_handle_rx_buf_smmu_mapping(soc, nbuf, rx_desc_pool->buf_size,
  2513. false, __func__, __LINE__);
  2514. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf, QDF_DMA_FROM_DEVICE,
  2515. rx_desc_pool->buf_size);
  2516. }
  2517. static inline
  2518. void dp_rx_per_core_stats_update(struct dp_soc *soc, uint8_t ring_id,
  2519. uint32_t bufs_reaped)
  2520. {
  2521. int cpu_id = qdf_get_cpu();
  2522. DP_STATS_INC(soc, rx.ring_packets[cpu_id][ring_id], bufs_reaped);
  2523. }
  2524. static inline
  2525. qdf_nbuf_t dp_rx_nbuf_alloc(struct dp_soc *soc,
  2526. struct rx_desc_pool *rx_desc_pool)
  2527. {
  2528. return qdf_nbuf_alloc(soc->osdev, rx_desc_pool->buf_size,
  2529. RX_BUFFER_RESERVATION,
  2530. rx_desc_pool->buf_alignment, FALSE);
  2531. }
  2532. static inline
  2533. void dp_rx_nbuf_free(qdf_nbuf_t nbuf)
  2534. {
  2535. qdf_nbuf_free(nbuf);
  2536. }
  2537. #endif
  2538. #ifdef DP_UMAC_HW_RESET_SUPPORT
  2539. /**
  2540. * dp_rx_desc_reuse() - Reuse the rx descriptors to fill the rx buf ring
  2541. * @soc: core txrx main context
  2542. * @nbuf_list: nbuf list for delayed free
  2543. *
  2544. * Return: void
  2545. */
  2546. void dp_rx_desc_reuse(struct dp_soc *soc, qdf_nbuf_t *nbuf_list);
  2547. /**
  2548. * dp_rx_desc_delayed_free() - Delayed free of the rx descs
  2549. *
  2550. * @soc: core txrx main context
  2551. *
  2552. * Return: void
  2553. */
  2554. void dp_rx_desc_delayed_free(struct dp_soc *soc);
  2555. #endif
  2556. /**
  2557. * dp_rx_get_txrx_peer_and_vdev() - Get txrx peer and vdev from peer id
  2558. * @soc: core txrx main context
  2559. * @nbuf : pointer to the first msdu of an amsdu.
  2560. * @peer_id : Peer id of the peer
  2561. * @txrx_ref_handle : Buffer to save the handle for txrx peer's reference
  2562. * @pkt_capture_offload : Flag indicating if pkt capture offload is needed
  2563. * @vdev : Buffer to hold pointer to vdev
  2564. * @rx_pdev : Buffer to hold pointer to rx pdev
  2565. * @dsf : delay stats flag
  2566. * @old_tid : Old tid
  2567. *
  2568. * Get txrx peer and vdev from peer id
  2569. *
  2570. * Return: Pointer to txrx peer
  2571. */
  2572. static inline struct dp_txrx_peer *
  2573. dp_rx_get_txrx_peer_and_vdev(struct dp_soc *soc,
  2574. qdf_nbuf_t nbuf,
  2575. uint16_t peer_id,
  2576. dp_txrx_ref_handle *txrx_ref_handle,
  2577. bool pkt_capture_offload,
  2578. struct dp_vdev **vdev,
  2579. struct dp_pdev **rx_pdev,
  2580. uint32_t *dsf,
  2581. uint32_t *old_tid)
  2582. {
  2583. struct dp_txrx_peer *txrx_peer = NULL;
  2584. txrx_peer = dp_txrx_peer_get_ref_by_id(soc, peer_id, txrx_ref_handle,
  2585. DP_MOD_ID_RX);
  2586. if (qdf_likely(txrx_peer)) {
  2587. *vdev = txrx_peer->vdev;
  2588. } else {
  2589. nbuf->next = NULL;
  2590. dp_rx_deliver_to_pkt_capture_no_peer(soc, nbuf,
  2591. pkt_capture_offload);
  2592. if (!pkt_capture_offload)
  2593. dp_rx_deliver_to_stack_no_peer(soc, nbuf);
  2594. goto end;
  2595. }
  2596. if (qdf_unlikely(!(*vdev))) {
  2597. qdf_nbuf_free(nbuf);
  2598. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  2599. goto end;
  2600. }
  2601. *rx_pdev = (*vdev)->pdev;
  2602. *dsf = (*rx_pdev)->delay_stats_flag;
  2603. *old_tid = 0xff;
  2604. end:
  2605. return txrx_peer;
  2606. }
  2607. static inline QDF_STATUS
  2608. dp_peer_rx_reorder_queue_setup(struct dp_soc *soc, struct dp_peer *peer,
  2609. int tid, uint32_t ba_window_size)
  2610. {
  2611. return soc->arch_ops.dp_peer_rx_reorder_queue_setup(soc,
  2612. peer, tid,
  2613. ba_window_size);
  2614. }
  2615. static inline
  2616. void dp_rx_nbuf_list_deliver(struct dp_soc *soc,
  2617. struct dp_vdev *vdev,
  2618. struct dp_txrx_peer *txrx_peer,
  2619. uint16_t peer_id,
  2620. uint8_t pkt_capture_offload,
  2621. qdf_nbuf_t deliver_list_head,
  2622. qdf_nbuf_t deliver_list_tail)
  2623. {
  2624. qdf_nbuf_t nbuf, next;
  2625. if (qdf_likely(deliver_list_head)) {
  2626. if (qdf_likely(txrx_peer)) {
  2627. dp_rx_deliver_to_pkt_capture(soc, vdev->pdev, peer_id,
  2628. pkt_capture_offload,
  2629. deliver_list_head);
  2630. if (!pkt_capture_offload)
  2631. dp_rx_deliver_to_stack(soc, vdev, txrx_peer,
  2632. deliver_list_head,
  2633. deliver_list_tail);
  2634. } else {
  2635. nbuf = deliver_list_head;
  2636. while (nbuf) {
  2637. next = nbuf->next;
  2638. nbuf->next = NULL;
  2639. dp_rx_deliver_to_stack_no_peer(soc, nbuf);
  2640. nbuf = next;
  2641. }
  2642. }
  2643. }
  2644. }
  2645. #ifdef DP_TX_RX_TPUT_SIMULATE
  2646. /*
  2647. * Change this macro value to simulate different RX T-put,
  2648. * if OTA is 100 Mbps, to simulate 200 Mbps, then multiplication factor
  2649. * is 2, set macro value as 1 (multiplication factor - 1).
  2650. */
  2651. #define DP_RX_PKTS_DUPLICATE_CNT 0
  2652. static inline
  2653. void dp_rx_nbuf_list_dup_deliver(struct dp_soc *soc,
  2654. struct dp_vdev *vdev,
  2655. struct dp_txrx_peer *txrx_peer,
  2656. uint16_t peer_id,
  2657. uint8_t pkt_capture_offload,
  2658. qdf_nbuf_t ori_list_head,
  2659. qdf_nbuf_t ori_list_tail)
  2660. {
  2661. qdf_nbuf_t new_skb = NULL;
  2662. qdf_nbuf_t new_list_head = NULL;
  2663. qdf_nbuf_t new_list_tail = NULL;
  2664. qdf_nbuf_t nbuf = NULL;
  2665. int i;
  2666. for (i = 0; i < DP_RX_PKTS_DUPLICATE_CNT; i++) {
  2667. nbuf = ori_list_head;
  2668. new_list_head = NULL;
  2669. new_list_tail = NULL;
  2670. while (nbuf) {
  2671. new_skb = qdf_nbuf_copy(nbuf);
  2672. if (qdf_likely(new_skb))
  2673. DP_RX_LIST_APPEND(new_list_head,
  2674. new_list_tail,
  2675. new_skb);
  2676. else
  2677. dp_err("copy skb failed");
  2678. nbuf = qdf_nbuf_next(nbuf);
  2679. }
  2680. /* deliver the copied nbuf list */
  2681. dp_rx_nbuf_list_deliver(soc, vdev, txrx_peer, peer_id,
  2682. pkt_capture_offload,
  2683. new_list_head,
  2684. new_list_tail);
  2685. }
  2686. /* deliver the original skb_list */
  2687. dp_rx_nbuf_list_deliver(soc, vdev, txrx_peer, peer_id,
  2688. pkt_capture_offload,
  2689. ori_list_head,
  2690. ori_list_tail);
  2691. }
  2692. #define DP_RX_DELIVER_TO_STACK dp_rx_nbuf_list_dup_deliver
  2693. #else /* !DP_TX_RX_TPUT_SIMULATE */
  2694. #define DP_RX_DELIVER_TO_STACK dp_rx_nbuf_list_deliver
  2695. #endif /* DP_TX_RX_TPUT_SIMULATE */
  2696. /**
  2697. * dp_rx_wbm_desc_nbuf_sanity_check() - Add sanity check to for WBM rx_desc
  2698. * paddr corruption
  2699. * @soc: core txrx main context
  2700. * @hal_ring_hdl: opaque pointer to the HAL Rx Error Ring
  2701. * @ring_desc: REO ring descriptor
  2702. * @rx_desc: Rx descriptor
  2703. *
  2704. * Return: NONE
  2705. */
  2706. QDF_STATUS dp_rx_wbm_desc_nbuf_sanity_check(struct dp_soc *soc,
  2707. hal_ring_handle_t hal_ring_hdl,
  2708. hal_ring_desc_t ring_desc,
  2709. struct dp_rx_desc *rx_desc);
  2710. /**
  2711. * dp_rx_is_sg_formation_required() - Check if sg formation is required
  2712. * @info: WBM desc info
  2713. *
  2714. * Return: True if sg is required else false
  2715. */
  2716. bool dp_rx_is_sg_formation_required(struct hal_wbm_err_desc_info *info);
  2717. /**
  2718. * dp_rx_err_tlv_invalidate() - Invalidate network buffer
  2719. * @soc: core txrx main context
  2720. * @nbuf: Network buffer to invalidate
  2721. *
  2722. * Return: NONE
  2723. */
  2724. void dp_rx_err_tlv_invalidate(struct dp_soc *soc,
  2725. qdf_nbuf_t nbuf);
  2726. /**
  2727. * dp_rx_wbm_sg_list_last_msdu_war() - war for HW issue
  2728. * @soc: DP SOC handle
  2729. *
  2730. * This is a war for HW issue where length is only valid in last msdu
  2731. *
  2732. * Return: NONE
  2733. */
  2734. void dp_rx_wbm_sg_list_last_msdu_war(struct dp_soc *soc);
  2735. /**
  2736. * dp_rx_check_pkt_len() - Check for pktlen validity
  2737. * @soc: DP SOC context
  2738. * @pkt_len: computed length of the pkt from caller in bytes
  2739. *
  2740. * Return: true if pktlen > RX_BUFFER_SIZE, else return false
  2741. *
  2742. */
  2743. bool dp_rx_check_pkt_len(struct dp_soc *soc, uint32_t pkt_len);
  2744. /**
  2745. * dp_rx_null_q_handle_invalid_peer_id_exception() - to find exception
  2746. * @soc: pointer to dp_soc struct
  2747. * @pool_id: Pool id to find dp_pdev
  2748. * @rx_tlv_hdr: TLV header of received packet
  2749. * @nbuf: SKB
  2750. *
  2751. * In certain types of packets if peer_id is not correct then
  2752. * driver may not be able find. Try finding peer by addr_2 of
  2753. * received MPDU. If you find the peer then most likely sw_peer_id &
  2754. * ast_idx is corrupted.
  2755. *
  2756. * Return: True if you find the peer by addr_2 of received MPDU else false
  2757. */
  2758. bool dp_rx_null_q_handle_invalid_peer_id_exception(struct dp_soc *soc,
  2759. uint8_t pool_id,
  2760. uint8_t *rx_tlv_hdr,
  2761. qdf_nbuf_t nbuf);
  2762. /**
  2763. * dp_rx_err_drop_3addr_mcast() - Check if feature drop_3ddr_mcast is enabled
  2764. * If so, drop the multicast frame.
  2765. * @vdev: datapath vdev
  2766. * @rx_tlv_hdr: TLV header
  2767. *
  2768. * Return: true if packet is to be dropped,
  2769. * false, if packet is not dropped.
  2770. */
  2771. bool dp_rx_err_drop_3addr_mcast(struct dp_vdev *vdev, uint8_t *rx_tlv_hdr);
  2772. /**
  2773. * dp_rx_deliver_to_osif_stack() - function to deliver rx pkts to stack
  2774. * @soc: DP soc
  2775. * @vdev: DP vdev handle
  2776. * @txrx_peer: pointer to the txrx_peer object
  2777. * @nbuf: skb list head
  2778. * @tail: skb list tail
  2779. * @is_eapol: eapol pkt check
  2780. *
  2781. * Return: None
  2782. */
  2783. void
  2784. dp_rx_deliver_to_osif_stack(struct dp_soc *soc,
  2785. struct dp_vdev *vdev,
  2786. struct dp_txrx_peer *txrx_peer,
  2787. qdf_nbuf_t nbuf,
  2788. qdf_nbuf_t tail,
  2789. bool is_eapol);
  2790. #ifndef WLAN_SOFTUMAC_SUPPORT /* WLAN_SOFTUMAC_SUPPORT */
  2791. /**
  2792. * dp_rx_dump_info_and_assert() - dump RX Ring info and Rx Desc info
  2793. *
  2794. * @soc: core txrx main context
  2795. * @hal_ring_hdl: opaque pointer to the HAL Rx Ring, which will be serviced
  2796. * @ring_desc: opaque pointer to the RX ring descriptor
  2797. * @rx_desc: host rx descriptor
  2798. *
  2799. * Return: void
  2800. */
  2801. void dp_rx_dump_info_and_assert(struct dp_soc *soc,
  2802. hal_ring_handle_t hal_ring_hdl,
  2803. hal_ring_desc_t ring_desc,
  2804. struct dp_rx_desc *rx_desc);
  2805. /**
  2806. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  2807. * (WBM), following error handling
  2808. *
  2809. * @soc: core DP main context
  2810. * @ring_desc: opaque pointer to the REO error ring descriptor
  2811. * @bm_action: put to idle_list or release to msdu_list
  2812. *
  2813. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  2814. */
  2815. QDF_STATUS
  2816. dp_rx_link_desc_return(struct dp_soc *soc, hal_ring_desc_t ring_desc,
  2817. uint8_t bm_action);
  2818. /**
  2819. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  2820. * (WBM) by address
  2821. *
  2822. * @soc: core DP main context
  2823. * @link_desc_addr: link descriptor addr
  2824. * @bm_action: put to idle_list or release to msdu_list
  2825. *
  2826. * Return: QDF_STATUS_E_FAILURE for failure else QDF_STATUS_SUCCESS
  2827. */
  2828. QDF_STATUS
  2829. dp_rx_link_desc_return_by_addr(struct dp_soc *soc,
  2830. hal_buff_addrinfo_t link_desc_addr,
  2831. uint8_t bm_action);
  2832. /**
  2833. * dp_rxdma_err_process() - RxDMA error processing functionality
  2834. * @int_ctx: pointer to DP interrupt context
  2835. * @soc: core txrx main context
  2836. * @mac_id: mac id which is one of 3 mac_ids
  2837. * @quota: No. of units (packets) that can be serviced in one shot.
  2838. *
  2839. * Return: num of buffers processed
  2840. */
  2841. uint32_t
  2842. dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  2843. uint32_t mac_id, uint32_t quota);
  2844. /**
  2845. * dp_rx_process_rxdma_err() - Function to deliver rxdma unencrypted_err
  2846. * frames to OS or wifi parse errors.
  2847. * @soc: core DP main context
  2848. * @nbuf: buffer pointer
  2849. * @rx_tlv_hdr: start of rx tlv header
  2850. * @txrx_peer: peer reference
  2851. * @err_code: rxdma err code
  2852. * @mac_id: mac_id which is one of 3 mac_ids(Assuming mac_id and
  2853. * pool_id has same mapping)
  2854. * @link_id: link Id on which the packet is received
  2855. *
  2856. * Return: None
  2857. */
  2858. void
  2859. dp_rx_process_rxdma_err(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2860. uint8_t *rx_tlv_hdr, struct dp_txrx_peer *txrx_peer,
  2861. uint8_t err_code, uint8_t mac_id, uint8_t link_id);
  2862. /**
  2863. * dp_rx_process_mic_error(): Function to pass mic error indication to umac
  2864. * @soc: core DP main context
  2865. * @nbuf: buffer pointer
  2866. * @rx_tlv_hdr: start of rx tlv header
  2867. * @txrx_peer: txrx peer handle
  2868. *
  2869. * Return: void
  2870. */
  2871. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2872. uint8_t *rx_tlv_hdr,
  2873. struct dp_txrx_peer *txrx_peer);
  2874. /**
  2875. * dp_2k_jump_handle() - Function to handle 2k jump exception
  2876. * on WBM ring
  2877. * @soc: core DP main context
  2878. * @nbuf: buffer pointer
  2879. * @rx_tlv_hdr: start of rx tlv header
  2880. * @peer_id: peer id of first msdu
  2881. * @tid: Tid for which exception occurred
  2882. *
  2883. * This function handles 2k jump violations arising out
  2884. * of receiving aggregates in non BA case. This typically
  2885. * may happen if aggregates are received on a QOS enabled TID
  2886. * while Rx window size is still initialized to value of 2. Or
  2887. * it may also happen if negotiated window size is 1 but peer
  2888. * sends aggregates.
  2889. */
  2890. void dp_2k_jump_handle(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  2891. uint16_t peer_id, uint8_t tid);
  2892. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  2893. /**
  2894. * dp_rx_err_process() - Processes error frames routed to REO error ring
  2895. * @int_ctx: pointer to DP interrupt context
  2896. * @soc: core txrx main context
  2897. * @hal_ring_hdl: opaque pointer to the HAL Rx Error Ring, which will be serviced
  2898. * @quota: No. of units (packets) that can be serviced in one shot.
  2899. *
  2900. * This function implements error processing and top level demultiplexer
  2901. * for all the frames routed to REO error ring.
  2902. *
  2903. * Return: uint32_t: No. of elements processed
  2904. */
  2905. uint32_t dp_rx_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  2906. hal_ring_handle_t hal_ring_hdl, uint32_t quota);
  2907. /**
  2908. * dp_rx_wbm_err_process() - Processes error frames routed to WBM release ring
  2909. * @int_ctx: pointer to DP interrupt context
  2910. * @soc: core txrx main context
  2911. * @hal_ring_hdl: opaque pointer to the HAL Rx Error Ring, which will be
  2912. * serviced
  2913. * @quota: No. of units (packets) that can be serviced in one shot.
  2914. *
  2915. * This function implements error processing and top level demultiplexer
  2916. * for all the frames routed to WBM2HOST sw release ring.
  2917. *
  2918. * Return: uint32_t: No. of elements processed
  2919. */
  2920. uint32_t
  2921. dp_rx_wbm_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  2922. hal_ring_handle_t hal_ring_hdl, uint32_t quota);
  2923. #ifdef QCA_OL_RX_LOCK_LESS_ACCESS
  2924. /**
  2925. * dp_rx_srng_access_start()- Wrapper function to log access start of a hal ring
  2926. * @int_ctx: pointer to DP interrupt context
  2927. * @soc: DP soc structure pointer
  2928. * @hal_ring_hdl: HAL ring handle
  2929. *
  2930. * Return: 0 on success; error on failure
  2931. */
  2932. static inline int
  2933. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  2934. hal_ring_handle_t hal_ring_hdl)
  2935. {
  2936. return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
  2937. }
  2938. /**
  2939. * dp_rx_srng_access_end()- Wrapper function to log access end of a hal ring
  2940. * @int_ctx: pointer to DP interrupt context
  2941. * @soc: DP soc structure pointer
  2942. * @hal_ring_hdl: HAL ring handle
  2943. *
  2944. * Return: None
  2945. */
  2946. static inline void
  2947. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  2948. hal_ring_handle_t hal_ring_hdl)
  2949. {
  2950. hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
  2951. }
  2952. #else
  2953. static inline int
  2954. dp_rx_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *soc,
  2955. hal_ring_handle_t hal_ring_hdl)
  2956. {
  2957. return dp_srng_access_start(int_ctx, soc, hal_ring_hdl);
  2958. }
  2959. static inline void
  2960. dp_rx_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *soc,
  2961. hal_ring_handle_t hal_ring_hdl)
  2962. {
  2963. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  2964. }
  2965. #endif
  2966. #ifdef RX_DESC_SANITY_WAR
  2967. QDF_STATUS dp_rx_desc_sanity(struct dp_soc *soc, hal_soc_handle_t hal_soc,
  2968. hal_ring_handle_t hal_ring_hdl,
  2969. hal_ring_desc_t ring_desc,
  2970. struct dp_rx_desc *rx_desc);
  2971. #else
  2972. static inline
  2973. QDF_STATUS dp_rx_desc_sanity(struct dp_soc *soc, hal_soc_handle_t hal_soc,
  2974. hal_ring_handle_t hal_ring_hdl,
  2975. hal_ring_desc_t ring_desc,
  2976. struct dp_rx_desc *rx_desc)
  2977. {
  2978. return QDF_STATUS_SUCCESS;
  2979. }
  2980. #endif
  2981. #ifdef RX_DESC_DEBUG_CHECK
  2982. /**
  2983. * dp_rx_desc_nbuf_sanity_check - Add sanity check to catch REO rx_desc paddr
  2984. * corruption
  2985. * @soc: DP SoC context
  2986. * @ring_desc: REO ring descriptor
  2987. * @rx_desc: Rx descriptor
  2988. *
  2989. * Return: NONE
  2990. */
  2991. QDF_STATUS dp_rx_desc_nbuf_sanity_check(struct dp_soc *soc,
  2992. hal_ring_desc_t ring_desc,
  2993. struct dp_rx_desc *rx_desc);
  2994. #else
  2995. static inline
  2996. QDF_STATUS dp_rx_desc_nbuf_sanity_check(struct dp_soc *soc,
  2997. hal_ring_desc_t ring_desc,
  2998. struct dp_rx_desc *rx_desc)
  2999. {
  3000. return QDF_STATUS_SUCCESS;
  3001. }
  3002. #endif
  3003. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  3004. /**
  3005. * dp_rx_wbm_sg_list_reset() - Initialize sg list
  3006. *
  3007. * This api should be called at soc init and afterevery sg processing.
  3008. *@soc: DP SOC handle
  3009. */
  3010. static inline void dp_rx_wbm_sg_list_reset(struct dp_soc *soc)
  3011. {
  3012. if (soc) {
  3013. soc->wbm_sg_param.wbm_is_first_msdu_in_sg = false;
  3014. soc->wbm_sg_param.wbm_sg_nbuf_head = NULL;
  3015. soc->wbm_sg_param.wbm_sg_nbuf_tail = NULL;
  3016. soc->wbm_sg_param.wbm_sg_desc_msdu_len = 0;
  3017. }
  3018. }
  3019. /**
  3020. * dp_rx_wbm_sg_list_deinit() - De-initialize sg list
  3021. *
  3022. * This api should be called in down path, to avoid any leak.
  3023. *@soc: DP SOC handle
  3024. */
  3025. static inline void dp_rx_wbm_sg_list_deinit(struct dp_soc *soc)
  3026. {
  3027. if (soc) {
  3028. if (soc->wbm_sg_param.wbm_sg_nbuf_head)
  3029. qdf_nbuf_list_free(soc->wbm_sg_param.wbm_sg_nbuf_head);
  3030. dp_rx_wbm_sg_list_reset(soc);
  3031. }
  3032. }
  3033. /**
  3034. * dp_rx_link_desc_refill_duplicate_check() - check if link desc duplicate
  3035. * to refill
  3036. * @soc: DP SOC handle
  3037. * @buf_info: the last link desc buf info
  3038. * @ring_buf_info: current buf address pointor including link desc
  3039. *
  3040. * Return: none.
  3041. */
  3042. void dp_rx_link_desc_refill_duplicate_check(
  3043. struct dp_soc *soc,
  3044. struct hal_buf_info *buf_info,
  3045. hal_buff_addrinfo_t ring_buf_info);
  3046. /**
  3047. * dp_rx_srng_get_num_pending() - get number of pending entries
  3048. * @hal_soc: hal soc opaque pointer
  3049. * @hal_ring_hdl: opaque pointer to the HAL Rx Ring
  3050. * @num_entries: number of entries in the hal_ring.
  3051. * @near_full: pointer to a boolean. This is set if ring is near full.
  3052. *
  3053. * The function returns the number of entries in a destination ring which are
  3054. * yet to be reaped. The function also checks if the ring is near full.
  3055. * If more than half of the ring needs to be reaped, the ring is considered
  3056. * approaching full.
  3057. * The function uses hal_srng_dst_num_valid_locked to get the number of valid
  3058. * entries. It should not be called within a SRNG lock. HW pointer value is
  3059. * synced into cached_hp.
  3060. *
  3061. * Return: Number of pending entries if any
  3062. */
  3063. uint32_t dp_rx_srng_get_num_pending(hal_soc_handle_t hal_soc,
  3064. hal_ring_handle_t hal_ring_hdl,
  3065. uint32_t num_entries,
  3066. bool *near_full);
  3067. #ifdef WLAN_FEATURE_DP_RX_RING_HISTORY
  3068. /**
  3069. * dp_rx_ring_record_entry() - Record an entry into the rx ring history.
  3070. * @soc: Datapath soc structure
  3071. * @ring_num: REO ring number
  3072. * @ring_desc: REO ring descriptor
  3073. *
  3074. * Return: None
  3075. */
  3076. void dp_rx_ring_record_entry(struct dp_soc *soc, uint8_t ring_num,
  3077. hal_ring_desc_t ring_desc);
  3078. #else
  3079. static inline void
  3080. dp_rx_ring_record_entry(struct dp_soc *soc, uint8_t ring_num,
  3081. hal_ring_desc_t ring_desc)
  3082. {
  3083. }
  3084. #endif
  3085. #ifdef QCA_SUPPORT_WDS_EXTENDED
  3086. /**
  3087. * dp_rx_is_list_ready() - Make different lists for 4-address
  3088. * and 3-address frames
  3089. * @nbuf_head: skb list head
  3090. * @vdev: vdev
  3091. * @txrx_peer : txrx_peer
  3092. * @peer_id: peer id of new received frame
  3093. * @vdev_id: vdev_id of new received frame
  3094. *
  3095. * Return: true if peer_ids are different.
  3096. */
  3097. static inline bool
  3098. dp_rx_is_list_ready(qdf_nbuf_t nbuf_head,
  3099. struct dp_vdev *vdev,
  3100. struct dp_txrx_peer *txrx_peer,
  3101. uint16_t peer_id,
  3102. uint8_t vdev_id)
  3103. {
  3104. if (nbuf_head && txrx_peer && txrx_peer->peer_id != peer_id)
  3105. return true;
  3106. return false;
  3107. }
  3108. #else
  3109. static inline bool
  3110. dp_rx_is_list_ready(qdf_nbuf_t nbuf_head,
  3111. struct dp_vdev *vdev,
  3112. struct dp_txrx_peer *txrx_peer,
  3113. uint16_t peer_id,
  3114. uint8_t vdev_id)
  3115. {
  3116. if (nbuf_head && vdev && (vdev->vdev_id != vdev_id))
  3117. return true;
  3118. return false;
  3119. }
  3120. #endif
  3121. #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
  3122. /**
  3123. * dp_rx_mark_first_packet_after_wow_wakeup - get first packet after wow wakeup
  3124. * @pdev: pointer to dp_pdev structure
  3125. * @rx_tlv: pointer to rx_pkt_tlvs structure
  3126. * @nbuf: pointer to skb buffer
  3127. *
  3128. * Return: None
  3129. */
  3130. void dp_rx_mark_first_packet_after_wow_wakeup(struct dp_pdev *pdev,
  3131. uint8_t *rx_tlv,
  3132. qdf_nbuf_t nbuf);
  3133. #else
  3134. static inline void
  3135. dp_rx_mark_first_packet_after_wow_wakeup(struct dp_pdev *pdev,
  3136. uint8_t *rx_tlv,
  3137. qdf_nbuf_t nbuf)
  3138. {
  3139. }
  3140. #endif
  3141. #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
  3142. static inline uint8_t
  3143. dp_rx_get_defrag_bm_id(struct dp_soc *soc)
  3144. {
  3145. return DP_DEFRAG_RBM(soc->wbm_sw0_bm_id);
  3146. }
  3147. static inline uint8_t
  3148. dp_rx_get_rx_bm_id(struct dp_soc *soc)
  3149. {
  3150. return DP_WBM2SW_RBM(soc->wbm_sw0_bm_id);
  3151. }
  3152. #else
  3153. static inline uint8_t
  3154. dp_rx_get_rx_bm_id(struct dp_soc *soc)
  3155. {
  3156. struct wlan_cfg_dp_soc_ctxt *cfg_ctx = soc->wlan_cfg_ctx;
  3157. uint8_t wbm2_sw_rx_rel_ring_id;
  3158. wbm2_sw_rx_rel_ring_id = wlan_cfg_get_rx_rel_ring_id(cfg_ctx);
  3159. return HAL_RX_BUF_RBM_SW_BM(soc->wbm_sw0_bm_id,
  3160. wbm2_sw_rx_rel_ring_id);
  3161. }
  3162. static inline uint8_t
  3163. dp_rx_get_defrag_bm_id(struct dp_soc *soc)
  3164. {
  3165. return dp_rx_get_rx_bm_id(soc);
  3166. }
  3167. #endif
  3168. #else
  3169. static inline QDF_STATUS
  3170. dp_rx_link_desc_return_by_addr(struct dp_soc *soc,
  3171. hal_buff_addrinfo_t link_desc_addr,
  3172. uint8_t bm_action)
  3173. {
  3174. return QDF_STATUS_SUCCESS;
  3175. }
  3176. static inline void dp_rx_wbm_sg_list_reset(struct dp_soc *soc)
  3177. {
  3178. }
  3179. static inline void dp_rx_wbm_sg_list_deinit(struct dp_soc *soc)
  3180. {
  3181. }
  3182. static inline uint8_t
  3183. dp_rx_get_defrag_bm_id(struct dp_soc *soc)
  3184. {
  3185. return 0;
  3186. }
  3187. static inline uint8_t
  3188. dp_rx_get_rx_bm_id(struct dp_soc *soc)
  3189. {
  3190. return 0;
  3191. }
  3192. #endif /* WLAN_SOFTUMAC_SUPPORT */
  3193. #endif /* _DP_RX_H */