dp_rx.h 93 KB

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