dp_rx.h 92 KB

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