dp_rx.h 97 KB

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