dp_rx.h 93 KB

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