dp_rx.h 99 KB

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