dp_rx.h 97 KB

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