dp_rx.h 76 KB

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