dp_rx.h 98 KB

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