dp_rx.h 74 KB

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