dp_rx.h 77 KB

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