dp_rx_err.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include "hal_hw_headers.h"
  19. #include "dp_types.h"
  20. #include "dp_rx.h"
  21. #include "dp_peer.h"
  22. #include "dp_internal.h"
  23. #include "hal_api.h"
  24. #include "qdf_trace.h"
  25. #include "qdf_nbuf.h"
  26. #ifdef CONFIG_MCL
  27. #include <cds_ieee80211_common.h>
  28. #else
  29. #include <linux/ieee80211.h>
  30. #endif
  31. #include "dp_rx_defrag.h"
  32. #include <enet.h> /* LLC_SNAP_HDR_LEN */
  33. #ifdef RX_DESC_DEBUG_CHECK
  34. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  35. {
  36. if (qdf_unlikely(rx_desc->magic != DP_RX_DESC_MAGIC)) {
  37. return false;
  38. }
  39. rx_desc->magic = 0;
  40. return true;
  41. }
  42. #else
  43. static inline bool dp_rx_desc_check_magic(struct dp_rx_desc *rx_desc)
  44. {
  45. return true;
  46. }
  47. #endif
  48. /**
  49. * dp_rx_mcast_echo_check() - check if the mcast pkt is a loop
  50. * back on same vap or a different vap.
  51. *
  52. * @soc: core DP main context
  53. * @peer: dp peer handler
  54. * @rx_tlv_hdr: start of the rx TLV header
  55. * @nbuf: pkt buffer
  56. *
  57. * Return: bool (true if it is a looped back pkt else false)
  58. *
  59. */
  60. static inline bool dp_rx_mcast_echo_check(struct dp_soc *soc,
  61. struct dp_peer *peer,
  62. uint8_t *rx_tlv_hdr,
  63. qdf_nbuf_t nbuf)
  64. {
  65. struct dp_vdev *vdev = peer->vdev;
  66. struct dp_ast_entry *ase;
  67. uint16_t sa_idx = 0;
  68. uint8_t *data;
  69. /*
  70. * Multicast Echo Check is required only if vdev is STA and
  71. * received pkt is a multicast/broadcast pkt. otherwise
  72. * skip the MEC check.
  73. */
  74. if (vdev->opmode != wlan_op_mode_sta)
  75. return false;
  76. if (!hal_rx_msdu_end_da_is_mcbc_get(rx_tlv_hdr))
  77. return false;
  78. data = qdf_nbuf_data(nbuf);
  79. /*
  80. * if the received pkts src mac addr matches with vdev
  81. * mac address then drop the pkt as it is looped back
  82. */
  83. if (!(qdf_mem_cmp(&data[DP_MAC_ADDR_LEN],
  84. vdev->mac_addr.raw,
  85. DP_MAC_ADDR_LEN)))
  86. return true;
  87. /*
  88. * In case of qwrap isolation mode, donot drop loopback packets.
  89. * In isolation mode, all packets from the wired stations need to go
  90. * to rootap and loop back to reach the wireless stations and
  91. * vice-versa.
  92. */
  93. if (qdf_unlikely(vdev->isolation_vdev))
  94. return false;
  95. /* if the received pkts src mac addr matches with the
  96. * wired PCs MAC addr which is behind the STA or with
  97. * wireless STAs MAC addr which are behind the Repeater,
  98. * then drop the pkt as it is looped back
  99. */
  100. qdf_spin_lock_bh(&soc->ast_lock);
  101. if (hal_rx_msdu_end_sa_is_valid_get(rx_tlv_hdr)) {
  102. sa_idx = hal_rx_msdu_end_sa_idx_get(rx_tlv_hdr);
  103. if ((sa_idx < 0) ||
  104. (sa_idx >= (WLAN_UMAC_PSOC_MAX_PEERS * 2))) {
  105. qdf_spin_unlock_bh(&soc->ast_lock);
  106. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  107. "invalid sa_idx: %d", sa_idx);
  108. qdf_assert_always(0);
  109. }
  110. ase = soc->ast_table[sa_idx];
  111. if (!ase) {
  112. /* We do not get a peer map event for STA and without
  113. * this event we don't know what is STA's sa_idx.
  114. * For this reason the AST is still not associated to
  115. * any index postion in ast_table.
  116. * In these kind of scenarios where sa is valid but
  117. * ast is not in ast_table, we use the below API to get
  118. * AST entry for STA's own mac_address.
  119. */
  120. ase = dp_peer_ast_list_find(soc, peer,
  121. &data[DP_MAC_ADDR_LEN]);
  122. if (ase) {
  123. ase->ast_idx = sa_idx;
  124. soc->ast_table[sa_idx] = ase;
  125. ase->is_mapped = TRUE;
  126. }
  127. }
  128. } else
  129. ase = dp_peer_ast_hash_find_soc(soc, &data[DP_MAC_ADDR_LEN]);
  130. if (ase) {
  131. if (ase->pdev_id != vdev->pdev->pdev_id) {
  132. qdf_spin_unlock_bh(&soc->ast_lock);
  133. QDF_TRACE(QDF_MODULE_ID_DP,
  134. QDF_TRACE_LEVEL_INFO,
  135. "Detected DBDC Root AP %pM, %d %d",
  136. &data[DP_MAC_ADDR_LEN], vdev->pdev->pdev_id,
  137. ase->pdev_id);
  138. return false;
  139. }
  140. if ((ase->type == CDP_TXRX_AST_TYPE_MEC) ||
  141. (ase->peer != peer)) {
  142. qdf_spin_unlock_bh(&soc->ast_lock);
  143. QDF_TRACE(QDF_MODULE_ID_DP,
  144. QDF_TRACE_LEVEL_INFO,
  145. "received pkt with same src mac %pM",
  146. &data[DP_MAC_ADDR_LEN]);
  147. return true;
  148. }
  149. }
  150. qdf_spin_unlock_bh(&soc->ast_lock);
  151. return false;
  152. }
  153. /**
  154. * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to
  155. * (WBM) by address
  156. *
  157. * @soc: core DP main context
  158. * @link_desc_addr: link descriptor addr
  159. *
  160. * Return: QDF_STATUS
  161. */
  162. QDF_STATUS
  163. dp_rx_link_desc_return_by_addr(struct dp_soc *soc, void *link_desc_addr,
  164. uint8_t bm_action)
  165. {
  166. struct dp_srng *wbm_desc_rel_ring = &soc->wbm_desc_rel_ring;
  167. void *wbm_rel_srng = wbm_desc_rel_ring->hal_srng;
  168. void *hal_soc = soc->hal_soc;
  169. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  170. void *src_srng_desc;
  171. if (!wbm_rel_srng) {
  172. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  173. "WBM RELEASE RING not initialized");
  174. return status;
  175. }
  176. if (qdf_unlikely(hal_srng_access_start(hal_soc, wbm_rel_srng))) {
  177. /* TODO */
  178. /*
  179. * Need API to convert from hal_ring pointer to
  180. * Ring Type / Ring Id combo
  181. */
  182. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  183. FL("HAL RING Access For WBM Release SRNG Failed - %pK"),
  184. wbm_rel_srng);
  185. DP_STATS_INC(soc, rx.err.hal_ring_access_fail, 1);
  186. goto done;
  187. }
  188. src_srng_desc = hal_srng_src_get_next(hal_soc, wbm_rel_srng);
  189. if (qdf_likely(src_srng_desc)) {
  190. /* Return link descriptor through WBM ring (SW2WBM)*/
  191. hal_rx_msdu_link_desc_set(hal_soc,
  192. src_srng_desc, link_desc_addr, bm_action);
  193. status = QDF_STATUS_SUCCESS;
  194. } else {
  195. struct hal_srng *srng = (struct hal_srng *)wbm_rel_srng;
  196. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  197. FL("WBM Release Ring (Id %d) Full"), srng->ring_id);
  198. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  199. "HP 0x%x Reap HP 0x%x TP 0x%x Cached TP 0x%x",
  200. *srng->u.src_ring.hp_addr, srng->u.src_ring.reap_hp,
  201. *srng->u.src_ring.tp_addr, srng->u.src_ring.cached_tp);
  202. }
  203. done:
  204. hal_srng_access_end(hal_soc, wbm_rel_srng);
  205. return status;
  206. }
  207. /**
  208. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  209. * (WBM), following error handling
  210. *
  211. * @soc: core DP main context
  212. * @ring_desc: opaque pointer to the REO error ring descriptor
  213. *
  214. * Return: QDF_STATUS
  215. */
  216. QDF_STATUS
  217. dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc, uint8_t bm_action)
  218. {
  219. void *buf_addr_info = HAL_RX_REO_BUF_ADDR_INFO_GET(ring_desc);
  220. return dp_rx_link_desc_return_by_addr(soc, buf_addr_info, bm_action);
  221. }
  222. /**
  223. * dp_rx_msdus_drop() - Drops all MSDU's per MPDU
  224. *
  225. * @soc: core txrx main context
  226. * @ring_desc: opaque pointer to the REO error ring descriptor
  227. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  228. * @head: head of the local descriptor free-list
  229. * @tail: tail of the local descriptor free-list
  230. * @quota: No. of units (packets) that can be serviced in one shot.
  231. *
  232. * This function is used to drop all MSDU in an MPDU
  233. *
  234. * Return: uint32_t: No. of elements processed
  235. */
  236. static uint32_t dp_rx_msdus_drop(struct dp_soc *soc, void *ring_desc,
  237. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  238. uint8_t *mac_id,
  239. uint32_t quota)
  240. {
  241. uint32_t rx_bufs_used = 0;
  242. void *link_desc_va;
  243. struct hal_buf_info buf_info;
  244. struct dp_pdev *pdev;
  245. struct hal_rx_msdu_list msdu_list; /* MSDU's per MPDU */
  246. int i;
  247. uint8_t *rx_tlv_hdr;
  248. uint32_t tid;
  249. hal_rx_reo_buf_paddr_get(ring_desc, &buf_info);
  250. link_desc_va = dp_rx_cookie_2_link_desc_va(soc, &buf_info);
  251. /* No UNMAP required -- this is "malloc_consistent" memory */
  252. hal_rx_msdu_list_get(soc->hal_soc, link_desc_va, &msdu_list,
  253. &mpdu_desc_info->msdu_count);
  254. for (i = 0; (i < mpdu_desc_info->msdu_count) && quota--; i++) {
  255. struct dp_rx_desc *rx_desc =
  256. dp_rx_cookie_2_va_rxdma_buf(soc,
  257. msdu_list.sw_cookie[i]);
  258. qdf_assert_always(rx_desc);
  259. /* all buffers from a MSDU link link belong to same pdev */
  260. *mac_id = rx_desc->pool_id;
  261. pdev = soc->pdev_list[rx_desc->pool_id];
  262. if (!dp_rx_desc_check_magic(rx_desc)) {
  263. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  264. FL("Invalid rx_desc cookie=%d"),
  265. msdu_list.sw_cookie[i]);
  266. return rx_bufs_used;
  267. }
  268. rx_bufs_used++;
  269. tid = hal_rx_mpdu_start_tid_get(soc->hal_soc,
  270. rx_desc->rx_buf_start);
  271. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  272. "Packet received with PN error for tid :%d", tid);
  273. rx_tlv_hdr = qdf_nbuf_data(rx_desc->nbuf);
  274. if (hal_rx_encryption_info_valid(rx_tlv_hdr))
  275. hal_rx_print_pn(rx_tlv_hdr);
  276. /* Just free the buffers */
  277. qdf_nbuf_free(rx_desc->nbuf);
  278. dp_rx_add_to_free_desc_list(&pdev->free_list_head,
  279. &pdev->free_list_tail, rx_desc);
  280. }
  281. /* Return link descriptor through WBM ring (SW2WBM)*/
  282. dp_rx_link_desc_return(soc, ring_desc, HAL_BM_ACTION_PUT_IN_IDLE_LIST);
  283. return rx_bufs_used;
  284. }
  285. /**
  286. * dp_rx_pn_error_handle() - Handles PN check errors
  287. *
  288. * @soc: core txrx main context
  289. * @ring_desc: opaque pointer to the REO error ring descriptor
  290. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  291. * @head: head of the local descriptor free-list
  292. * @tail: tail of the local descriptor free-list
  293. * @quota: No. of units (packets) that can be serviced in one shot.
  294. *
  295. * This function implements PN error handling
  296. * If the peer is configured to ignore the PN check errors
  297. * or if DP feels, that this frame is still OK, the frame can be
  298. * re-injected back to REO to use some of the other features
  299. * of REO e.g. duplicate detection/routing to other cores
  300. *
  301. * Return: uint32_t: No. of elements processed
  302. */
  303. static uint32_t
  304. dp_rx_pn_error_handle(struct dp_soc *soc, void *ring_desc,
  305. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  306. uint8_t *mac_id,
  307. uint32_t quota)
  308. {
  309. uint16_t peer_id;
  310. uint32_t rx_bufs_used = 0;
  311. struct dp_peer *peer;
  312. bool peer_pn_policy = false;
  313. peer_id = DP_PEER_METADATA_PEER_ID_GET(
  314. mpdu_desc_info->peer_meta_data);
  315. peer = dp_peer_find_by_id(soc, peer_id);
  316. if (qdf_likely(peer)) {
  317. /*
  318. * TODO: Check for peer specific policies & set peer_pn_policy
  319. */
  320. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  321. "discard rx due to PN error for peer %pK "
  322. "(%02x:%02x:%02x:%02x:%02x:%02x)",
  323. peer,
  324. peer->mac_addr.raw[0], peer->mac_addr.raw[1],
  325. peer->mac_addr.raw[2], peer->mac_addr.raw[3],
  326. peer->mac_addr.raw[4], peer->mac_addr.raw[5]);
  327. dp_peer_unref_del_find_by_id(peer);
  328. }
  329. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  330. "Packet received with PN error");
  331. /* No peer PN policy -- definitely drop */
  332. if (!peer_pn_policy)
  333. rx_bufs_used = dp_rx_msdus_drop(soc, ring_desc,
  334. mpdu_desc_info,
  335. mac_id, quota);
  336. return rx_bufs_used;
  337. }
  338. /**
  339. * dp_rx_2k_jump_handle() - Handles Sequence Number Jump by 2K
  340. *
  341. * @soc: core txrx main context
  342. * @ring_desc: opaque pointer to the REO error ring descriptor
  343. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  344. * @head: head of the local descriptor free-list
  345. * @tail: tail of the local descriptor free-list
  346. * @quota: No. of units (packets) that can be serviced in one shot.
  347. *
  348. * This function implements the error handling when sequence number
  349. * of the MPDU jumps suddenly by 2K.Today there are 2 cases that
  350. * need to be handled:
  351. * A) CSN (Current Sequence Number) = Last Valid SN (LSN) + 2K
  352. * B) CSN = LSN + 2K, but falls within a "BA sized window" of the SSN
  353. * For case A) the protocol stack is invoked to generate DELBA/DEAUTH frame
  354. * For case B), the frame is normally dropped, no more action is taken
  355. *
  356. * Return: uint32_t: No. of elements processed
  357. */
  358. static uint32_t
  359. dp_rx_2k_jump_handle(struct dp_soc *soc, void *ring_desc,
  360. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  361. uint8_t *mac_id, uint32_t quota)
  362. {
  363. return dp_rx_msdus_drop(soc, ring_desc, mpdu_desc_info,
  364. mac_id, quota);
  365. }
  366. #ifdef CONFIG_MCL
  367. #define DP_PDEV_INVALID_PEER_MSDU_CHECK(head, tail) \
  368. do { \
  369. qdf_assert_always(!(head)); \
  370. qdf_assert_always(!(tail)); \
  371. } while (0)
  372. #else
  373. #define DP_PDEV_INVALID_PEER_MSDU_CHECK(head, tail) /* no op */
  374. #endif
  375. /**
  376. * dp_rx_chain_msdus() - Function to chain all msdus of a mpdu
  377. * to pdev invalid peer list
  378. *
  379. * @soc: core DP main context
  380. * @nbuf: Buffer pointer
  381. * @rx_tlv_hdr: start of rx tlv header
  382. * @mac_id: mac id
  383. *
  384. * Return: bool: true for last msdu of mpdu
  385. */
  386. static bool
  387. dp_rx_chain_msdus(struct dp_soc *soc, qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr,
  388. uint8_t mac_id)
  389. {
  390. bool mpdu_done = false;
  391. qdf_nbuf_t curr_nbuf = NULL;
  392. qdf_nbuf_t tmp_nbuf = NULL;
  393. /* TODO: Currently only single radio is supported, hence
  394. * pdev hard coded to '0' index
  395. */
  396. struct dp_pdev *dp_pdev = soc->pdev_list[mac_id];
  397. if (!dp_pdev->first_nbuf) {
  398. qdf_nbuf_set_rx_chfrag_start(nbuf, 1);
  399. dp_pdev->ppdu_id = HAL_RX_HW_DESC_GET_PPDUID_GET(rx_tlv_hdr);
  400. dp_pdev->first_nbuf = true;
  401. /* If the new nbuf received is the first msdu of the
  402. * amsdu and there are msdus in the invalid peer msdu
  403. * list, then let us free all the msdus of the invalid
  404. * peer msdu list.
  405. * This scenario can happen when we start receiving
  406. * new a-msdu even before the previous a-msdu is completely
  407. * received.
  408. */
  409. curr_nbuf = dp_pdev->invalid_peer_head_msdu;
  410. while (curr_nbuf) {
  411. tmp_nbuf = curr_nbuf->next;
  412. qdf_nbuf_free(curr_nbuf);
  413. curr_nbuf = tmp_nbuf;
  414. }
  415. dp_pdev->invalid_peer_head_msdu = NULL;
  416. dp_pdev->invalid_peer_tail_msdu = NULL;
  417. hal_rx_mon_hw_desc_get_mpdu_status(soc->hal_soc, rx_tlv_hdr,
  418. &(dp_pdev->ppdu_info.rx_status));
  419. }
  420. if (dp_pdev->ppdu_id == hal_rx_attn_phy_ppdu_id_get(rx_tlv_hdr) &&
  421. hal_rx_attn_msdu_done_get(rx_tlv_hdr)) {
  422. qdf_nbuf_set_rx_chfrag_end(nbuf, 1);
  423. qdf_assert_always(dp_pdev->first_nbuf == true);
  424. dp_pdev->first_nbuf = false;
  425. mpdu_done = true;
  426. }
  427. /*
  428. * For MCL, invalid_peer_head_msdu and invalid_peer_tail_msdu
  429. * should be NULL here, add the checking for debugging purpose
  430. * in case some corner case.
  431. */
  432. DP_PDEV_INVALID_PEER_MSDU_CHECK(dp_pdev->invalid_peer_head_msdu,
  433. dp_pdev->invalid_peer_tail_msdu);
  434. DP_RX_LIST_APPEND(dp_pdev->invalid_peer_head_msdu,
  435. dp_pdev->invalid_peer_tail_msdu,
  436. nbuf);
  437. return mpdu_done;
  438. }
  439. /**
  440. * dp_2k_jump_handle() - Function to handle 2k jump exception
  441. * on WBM ring
  442. *
  443. * @soc: core DP main context
  444. * @nbuf: buffer pointer
  445. * @rx_tlv_hdr: start of rx tlv header
  446. * @peer_id: peer id of first msdu
  447. * @tid: Tid for which exception occurred
  448. *
  449. * This function handles 2k jump violations arising out
  450. * of receiving aggregates in non BA case. This typically
  451. * may happen if aggregates are received on a QOS enabled TID
  452. * while Rx window size is still initialized to value of 2. Or
  453. * it may also happen if negotiated window size is 1 but peer
  454. * sends aggregates.
  455. *
  456. */
  457. static void
  458. dp_2k_jump_handle(struct dp_soc *soc,
  459. qdf_nbuf_t nbuf,
  460. uint8_t *rx_tlv_hdr,
  461. uint16_t peer_id,
  462. uint8_t tid)
  463. {
  464. uint32_t ppdu_id;
  465. struct dp_peer *peer = NULL;
  466. struct dp_rx_tid *rx_tid = NULL;
  467. peer = dp_peer_find_by_id(soc, peer_id);
  468. if (!peer || peer->delete_in_progress) {
  469. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  470. "peer not found");
  471. goto free_nbuf;
  472. }
  473. rx_tid = &peer->rx_tid[tid];
  474. if (qdf_unlikely(rx_tid == NULL)) {
  475. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  476. "rx_tid is NULL!!");
  477. goto free_nbuf;
  478. }
  479. qdf_spin_lock_bh(&rx_tid->tid_lock);
  480. ppdu_id = hal_rx_attn_phy_ppdu_id_get(rx_tlv_hdr);
  481. if (rx_tid->ppdu_id_2k != ppdu_id) {
  482. rx_tid->ppdu_id_2k = ppdu_id;
  483. qdf_spin_unlock_bh(&rx_tid->tid_lock);
  484. goto free_nbuf;
  485. }
  486. if (!rx_tid->delba_tx_status) {
  487. rx_tid->delba_tx_retry++;
  488. rx_tid->delba_tx_status = 1;
  489. rx_tid->delba_rcode =
  490. IEEE80211_REASON_QOS_SETUP_REQUIRED;
  491. qdf_spin_unlock_bh(&rx_tid->tid_lock);
  492. soc->cdp_soc.ol_ops->send_delba(peer->vdev->pdev->ctrl_pdev,
  493. peer->ctrl_peer,
  494. peer->mac_addr.raw,
  495. tid,
  496. peer->vdev->ctrl_vdev,
  497. rx_tid->delba_rcode);
  498. } else {
  499. qdf_spin_unlock_bh(&rx_tid->tid_lock);
  500. }
  501. free_nbuf:
  502. qdf_nbuf_free(nbuf);
  503. return;
  504. }
  505. /**
  506. * dp_rx_null_q_desc_handle() - Function to handle NULL Queue
  507. * descriptor violation on either a
  508. * REO or WBM ring
  509. *
  510. * @soc: core DP main context
  511. * @nbuf: buffer pointer
  512. * @rx_tlv_hdr: start of rx tlv header
  513. * @pool_id: mac id
  514. * @peer: peer handle
  515. *
  516. * This function handles NULL queue descriptor violations arising out
  517. * a missing REO queue for a given peer or a given TID. This typically
  518. * may happen if a packet is received on a QOS enabled TID before the
  519. * ADDBA negotiation for that TID, when the TID queue is setup. Or
  520. * it may also happen for MC/BC frames if they are not routed to the
  521. * non-QOS TID queue, in the absence of any other default TID queue.
  522. * This error can show up both in a REO destination or WBM release ring.
  523. *
  524. */
  525. static void
  526. dp_rx_null_q_desc_handle(struct dp_soc *soc, qdf_nbuf_t nbuf,
  527. uint8_t *rx_tlv_hdr, uint8_t pool_id,
  528. struct dp_peer *peer)
  529. {
  530. uint32_t pkt_len, l2_hdr_offset;
  531. uint16_t msdu_len;
  532. struct dp_vdev *vdev;
  533. uint8_t tid;
  534. struct ether_header *eh;
  535. qdf_nbuf_set_rx_chfrag_start(nbuf,
  536. hal_rx_msdu_end_first_msdu_get(rx_tlv_hdr));
  537. qdf_nbuf_set_rx_chfrag_end(nbuf,
  538. hal_rx_msdu_end_last_msdu_get(rx_tlv_hdr));
  539. l2_hdr_offset = hal_rx_msdu_end_l3_hdr_padding_get(rx_tlv_hdr);
  540. msdu_len = hal_rx_msdu_start_msdu_len_get(rx_tlv_hdr);
  541. pkt_len = msdu_len + l2_hdr_offset + RX_PKT_TLVS_LEN;
  542. QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DP,
  543. "Len %d Extn list %pK ",
  544. (uint32_t)qdf_nbuf_len(nbuf),
  545. qdf_nbuf_get_ext_list(nbuf));
  546. /* Set length in nbuf */
  547. if (!qdf_nbuf_get_ext_list(nbuf))
  548. qdf_nbuf_set_pktlen(nbuf, pkt_len);
  549. /*
  550. * Check if DMA completed -- msdu_done is the last bit
  551. * to be written
  552. */
  553. if (!hal_rx_attn_msdu_done_get(rx_tlv_hdr)) {
  554. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  555. FL("MSDU DONE failure"));
  556. hal_rx_dump_pkt_tlvs(soc->hal_soc, rx_tlv_hdr,
  557. QDF_TRACE_LEVEL_INFO);
  558. qdf_assert(0);
  559. }
  560. if (!peer) {
  561. bool mpdu_done = false;
  562. struct dp_pdev *pdev = soc->pdev_list[pool_id];
  563. QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_DP, "peer is NULL");
  564. DP_STATS_INC_PKT(soc,
  565. rx.err.rx_invalid_peer,
  566. 1,
  567. qdf_nbuf_len(nbuf));
  568. mpdu_done = dp_rx_chain_msdus(soc, nbuf, rx_tlv_hdr, pool_id);
  569. /* Trigger invalid peer handler wrapper */
  570. dp_rx_process_invalid_peer_wrapper(soc, nbuf, mpdu_done);
  571. if (mpdu_done) {
  572. pdev->invalid_peer_head_msdu = NULL;
  573. pdev->invalid_peer_tail_msdu = NULL;
  574. }
  575. return;
  576. }
  577. vdev = peer->vdev;
  578. if (!vdev) {
  579. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  580. FL("INVALID vdev %pK OR osif_rx"), vdev);
  581. /* Drop & free packet */
  582. qdf_nbuf_free(nbuf);
  583. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  584. return;
  585. }
  586. /*
  587. * Advance the packet start pointer by total size of
  588. * pre-header TLV's
  589. */
  590. if (qdf_nbuf_get_ext_list(nbuf))
  591. qdf_nbuf_pull_head(nbuf, RX_PKT_TLVS_LEN);
  592. else
  593. qdf_nbuf_pull_head(nbuf, (l2_hdr_offset + RX_PKT_TLVS_LEN));
  594. if (dp_rx_mcast_echo_check(soc, peer, rx_tlv_hdr, nbuf)) {
  595. /* this is a looped back MCBC pkt, drop it */
  596. DP_STATS_INC_PKT(peer, rx.mec_drop, 1, qdf_nbuf_len(nbuf));
  597. qdf_nbuf_free(nbuf);
  598. return;
  599. }
  600. /*
  601. * In qwrap mode if the received packet matches with any of the vdev
  602. * mac addresses, drop it. Donot receive multicast packets originated
  603. * from any proxysta.
  604. */
  605. if (check_qwrap_multicast_loopback(vdev, nbuf)) {
  606. DP_STATS_INC_PKT(peer, rx.mec_drop, 1, qdf_nbuf_len(nbuf));
  607. qdf_nbuf_free(nbuf);
  608. return;
  609. }
  610. if (qdf_unlikely((peer->nawds_enabled == true) &&
  611. hal_rx_msdu_end_da_is_mcbc_get(rx_tlv_hdr))) {
  612. QDF_TRACE(QDF_MODULE_ID_DP,
  613. QDF_TRACE_LEVEL_DEBUG,
  614. "%s free buffer for multicast packet",
  615. __func__);
  616. DP_STATS_INC(peer, rx.nawds_mcast_drop, 1);
  617. qdf_nbuf_free(nbuf);
  618. return;
  619. }
  620. if (!dp_wds_rx_policy_check(rx_tlv_hdr, vdev, peer,
  621. hal_rx_msdu_end_da_is_mcbc_get(rx_tlv_hdr))) {
  622. QDF_TRACE(QDF_MODULE_ID_DP,
  623. QDF_TRACE_LEVEL_ERROR,
  624. FL("mcast Policy Check Drop pkt"));
  625. /* Drop & free packet */
  626. qdf_nbuf_free(nbuf);
  627. return;
  628. }
  629. /* WDS Source Port Learning */
  630. if (qdf_likely(vdev->rx_decap_type == htt_cmn_pkt_type_ethernet &&
  631. vdev->wds_enabled))
  632. dp_rx_wds_srcport_learn(soc, rx_tlv_hdr, peer, nbuf);
  633. if (hal_rx_mpdu_start_mpdu_qos_control_valid_get(rx_tlv_hdr)) {
  634. /* TODO: Assuming that qos_control_valid also indicates
  635. * unicast. Should we check this?
  636. */
  637. tid = hal_rx_mpdu_start_tid_get(soc->hal_soc, rx_tlv_hdr);
  638. if (peer && !peer->rx_tid[tid].hw_qdesc_vaddr_unaligned) {
  639. /* IEEE80211_SEQ_MAX indicates invalid start_seq */
  640. dp_rx_tid_setup_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
  641. }
  642. }
  643. #ifdef QCA_WIFI_NAPIER_EMULATION /* Debug code, remove later */
  644. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  645. "%s: mac_add:%pM msdu_len %d hdr_off %d",
  646. __func__, peer->mac_addr.raw, msdu_len,
  647. l2_hdr_offset);
  648. print_hex_dump(KERN_ERR, "\t Pkt Data:", DUMP_PREFIX_NONE, 32, 4,
  649. qdf_nbuf_data(nbuf), 128, false);
  650. #endif /* NAPIER_EMULATION */
  651. if (qdf_unlikely(vdev->rx_decap_type == htt_cmn_pkt_type_raw)) {
  652. qdf_nbuf_set_next(nbuf, NULL);
  653. dp_rx_deliver_raw(vdev, nbuf, peer);
  654. } else {
  655. if (qdf_unlikely(peer->bss_peer)) {
  656. QDF_TRACE(QDF_MODULE_ID_DP,
  657. QDF_TRACE_LEVEL_INFO,
  658. FL("received pkt with same src MAC"));
  659. DP_STATS_INC_PKT(peer, rx.mec_drop, 1,
  660. qdf_nbuf_len(nbuf));
  661. /* Drop & free packet */
  662. qdf_nbuf_free(nbuf);
  663. return;
  664. }
  665. if (vdev->osif_rx) {
  666. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  667. FL("vdev %pK osif_rx %pK"), vdev,
  668. vdev->osif_rx);
  669. qdf_nbuf_set_next(nbuf, NULL);
  670. DP_STATS_INC_PKT(peer, rx.to_stack, 1,
  671. qdf_nbuf_len(nbuf));
  672. vdev->osif_rx(vdev->osif_vdev, nbuf);
  673. if (qdf_unlikely(hal_rx_msdu_end_da_is_mcbc_get(
  674. rx_tlv_hdr) &&
  675. (vdev->rx_decap_type ==
  676. htt_cmn_pkt_type_ethernet))) {
  677. eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  678. DP_STATS_INC_PKT(peer, rx.multicast, 1,
  679. qdf_nbuf_len(nbuf));
  680. if (IEEE80211_IS_BROADCAST(eh->ether_dhost)) {
  681. DP_STATS_INC_PKT(peer, rx.bcast, 1,
  682. qdf_nbuf_len(nbuf));
  683. }
  684. }
  685. } else {
  686. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  687. FL("INVALID vdev %pK OR osif_rx"), vdev);
  688. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  689. }
  690. }
  691. return;
  692. }
  693. /**
  694. * dp_rx_process_err_unencrypted() - Function to deliver rxdma unencrypted_err
  695. * frames to OS
  696. * @soc: core DP main context
  697. * @nbuf: buffer pointer
  698. * @rx_tlv_hdr: start of rx tlv header
  699. * @peer: peer reference
  700. *
  701. * Return: None
  702. */
  703. static void
  704. dp_rx_process_err_unencrypted(struct dp_soc *soc, qdf_nbuf_t nbuf,
  705. uint8_t *rx_tlv_hdr, struct dp_peer *peer)
  706. {
  707. uint32_t pkt_len, l2_hdr_offset;
  708. uint16_t msdu_len;
  709. struct dp_vdev *vdev;
  710. struct ether_header *eh;
  711. bool isBroadcast;
  712. /*
  713. * Check if DMA completed -- msdu_done is the last bit
  714. * to be written
  715. */
  716. if (!hal_rx_attn_msdu_done_get(rx_tlv_hdr)) {
  717. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  718. FL("MSDU DONE failure"));
  719. hal_rx_dump_pkt_tlvs(soc->hal_soc, rx_tlv_hdr,
  720. QDF_TRACE_LEVEL_INFO);
  721. qdf_assert(0);
  722. }
  723. l2_hdr_offset = hal_rx_msdu_end_l3_hdr_padding_get(rx_tlv_hdr);
  724. msdu_len = hal_rx_msdu_start_msdu_len_get(rx_tlv_hdr);
  725. pkt_len = msdu_len + l2_hdr_offset + RX_PKT_TLVS_LEN;
  726. /* Set length in nbuf */
  727. qdf_nbuf_set_pktlen(nbuf, pkt_len);
  728. qdf_nbuf_set_next(nbuf, NULL);
  729. qdf_nbuf_set_rx_chfrag_start(nbuf, 1);
  730. qdf_nbuf_set_rx_chfrag_end(nbuf, 1);
  731. if (!peer) {
  732. QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DP, "peer is NULL");
  733. DP_STATS_INC_PKT(soc, rx.err.rx_invalid_peer, 1,
  734. qdf_nbuf_len(nbuf));
  735. /* Trigger invalid peer handler wrapper */
  736. dp_rx_process_invalid_peer_wrapper(soc, nbuf, true);
  737. return;
  738. }
  739. vdev = peer->vdev;
  740. if (!vdev) {
  741. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  742. FL("INVALID vdev %pK OR osif_rx"), vdev);
  743. /* Drop & free packet */
  744. qdf_nbuf_free(nbuf);
  745. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  746. return;
  747. }
  748. /*
  749. * Advance the packet start pointer by total size of
  750. * pre-header TLV's
  751. */
  752. qdf_nbuf_pull_head(nbuf, l2_hdr_offset + RX_PKT_TLVS_LEN);
  753. /*
  754. * WAPI cert AP sends rekey frames as unencrypted.
  755. * Thus RXDMA will report unencrypted frame error.
  756. * To pass WAPI cert case, SW needs to pass unencrypted
  757. * rekey frame to stack.
  758. */
  759. if (qdf_nbuf_is_ipv4_wapi_pkt(nbuf)) {
  760. qdf_nbuf_cb_update_peer_local_id(nbuf, peer->local_id);
  761. if (qdf_likely(vdev->osif_rx)) {
  762. DP_STATS_INC(peer, rx.to_stack.num, 1);
  763. vdev->osif_rx(vdev->osif_vdev, nbuf);
  764. } else {
  765. qdf_nbuf_free(nbuf);
  766. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  767. }
  768. return;
  769. }
  770. /* Drop & free packet if mesh mode not enabled */
  771. if (!vdev->mesh_vdev) {
  772. qdf_nbuf_free(nbuf);
  773. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  774. return;
  775. }
  776. if (dp_rx_filter_mesh_packets(vdev, nbuf, rx_tlv_hdr)
  777. == QDF_STATUS_SUCCESS) {
  778. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_MED,
  779. FL("mesh pkt filtered"));
  780. DP_STATS_INC(vdev->pdev, dropped.mesh_filter, 1);
  781. qdf_nbuf_free(nbuf);
  782. return;
  783. }
  784. dp_rx_fill_mesh_stats(vdev, nbuf, rx_tlv_hdr, peer);
  785. if (qdf_unlikely(hal_rx_msdu_end_da_is_mcbc_get(rx_tlv_hdr) &&
  786. (vdev->rx_decap_type ==
  787. htt_cmn_pkt_type_ethernet))) {
  788. eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  789. isBroadcast = (IEEE80211_IS_BROADCAST
  790. (eh->ether_dhost)) ? 1 : 0 ;
  791. DP_STATS_INC_PKT(peer, rx.multicast, 1, qdf_nbuf_len(nbuf));
  792. if (isBroadcast) {
  793. DP_STATS_INC_PKT(peer, rx.bcast, 1,
  794. qdf_nbuf_len(nbuf));
  795. }
  796. }
  797. if (qdf_unlikely(vdev->rx_decap_type == htt_cmn_pkt_type_raw)) {
  798. dp_rx_deliver_raw(vdev, nbuf, peer);
  799. } else {
  800. DP_STATS_INC(peer, rx.to_stack.num, 1);
  801. vdev->osif_rx(vdev->osif_vdev, nbuf);
  802. }
  803. return;
  804. }
  805. /**
  806. * dp_rx_process_mic_error(): Function to pass mic error indication to umac
  807. * @soc: core DP main context
  808. * @nbuf: buffer pointer
  809. * @rx_tlv_hdr: start of rx tlv header
  810. * @peer: peer handle
  811. *
  812. * return: void
  813. */
  814. void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf,
  815. uint8_t *rx_tlv_hdr, struct dp_peer *peer)
  816. {
  817. struct dp_vdev *vdev = NULL;
  818. struct dp_pdev *pdev = NULL;
  819. struct ol_if_ops *tops = NULL;
  820. struct ieee80211_frame *wh;
  821. uint8_t *rx_pkt_hdr;
  822. uint16_t rx_seq, fragno;
  823. unsigned int tid;
  824. QDF_STATUS status;
  825. if (!hal_rx_msdu_end_first_msdu_get(rx_tlv_hdr))
  826. return;
  827. rx_pkt_hdr = hal_rx_pkt_hdr_get(qdf_nbuf_data(nbuf));
  828. wh = (struct ieee80211_frame *)rx_pkt_hdr;
  829. if (!peer) {
  830. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  831. "peer not found");
  832. goto fail;
  833. }
  834. vdev = peer->vdev;
  835. if (!vdev) {
  836. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  837. "VDEV not found");
  838. goto fail;
  839. }
  840. pdev = vdev->pdev;
  841. if (!pdev) {
  842. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  843. "PDEV not found");
  844. goto fail;
  845. }
  846. tid = hal_rx_mpdu_start_tid_get(soc->hal_soc, qdf_nbuf_data(nbuf));
  847. rx_seq = (((*(uint16_t *)wh->i_seq) &
  848. IEEE80211_SEQ_SEQ_MASK) >>
  849. IEEE80211_SEQ_SEQ_SHIFT);
  850. fragno = dp_rx_frag_get_mpdu_frag_number(qdf_nbuf_data(nbuf));
  851. /* Can get only last fragment */
  852. if (fragno) {
  853. status = dp_rx_defrag_add_last_frag(soc, peer,
  854. tid, rx_seq, nbuf);
  855. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  856. "%s: Frag pkt seq# %d frag# %d consumed status %d !",
  857. __func__, rx_seq, fragno, status);
  858. return;
  859. }
  860. tops = pdev->soc->cdp_soc.ol_ops;
  861. if (tops->rx_mic_error)
  862. tops->rx_mic_error(pdev->ctrl_pdev, vdev->vdev_id, wh);
  863. fail:
  864. qdf_nbuf_free(nbuf);
  865. return;
  866. }
  867. /**
  868. * dp_rx_err_process() - Processes error frames routed to REO error ring
  869. *
  870. * @soc: core txrx main context
  871. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  872. * @quota: No. of units (packets) that can be serviced in one shot.
  873. *
  874. * This function implements error processing and top level demultiplexer
  875. * for all the frames routed to REO error ring.
  876. *
  877. * Return: uint32_t: No. of elements processed
  878. */
  879. uint32_t
  880. dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota)
  881. {
  882. void *hal_soc;
  883. void *ring_desc;
  884. uint32_t count = 0;
  885. uint32_t rx_bufs_used = 0;
  886. uint32_t rx_bufs_reaped[MAX_PDEV_CNT] = { 0 };
  887. uint8_t mac_id = 0;
  888. uint8_t buf_type;
  889. uint8_t error, rbm;
  890. struct hal_rx_mpdu_desc_info mpdu_desc_info;
  891. struct hal_buf_info hbi;
  892. struct dp_pdev *dp_pdev;
  893. struct dp_srng *dp_rxdma_srng;
  894. struct rx_desc_pool *rx_desc_pool;
  895. uint32_t cookie = 0;
  896. void *link_desc_va;
  897. struct hal_rx_msdu_list msdu_list; /* MSDU's per MPDU */
  898. uint16_t num_msdus;
  899. /* Debug -- Remove later */
  900. qdf_assert(soc && hal_ring);
  901. hal_soc = soc->hal_soc;
  902. /* Debug -- Remove later */
  903. qdf_assert(hal_soc);
  904. if (qdf_unlikely(hal_srng_access_start(hal_soc, hal_ring))) {
  905. /* TODO */
  906. /*
  907. * Need API to convert from hal_ring pointer to
  908. * Ring Type / Ring Id combo
  909. */
  910. DP_STATS_INC(soc, rx.err.hal_ring_access_fail, 1);
  911. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  912. FL("HAL RING Access Failed -- %pK"), hal_ring);
  913. goto done;
  914. }
  915. while (qdf_likely(quota-- && (ring_desc =
  916. hal_srng_dst_get_next(hal_soc, hal_ring)))) {
  917. DP_STATS_INC(soc, rx.err_ring_pkts, 1);
  918. error = HAL_RX_ERROR_STATUS_GET(ring_desc);
  919. qdf_assert(error == HAL_REO_ERROR_DETECTED);
  920. buf_type = HAL_RX_REO_BUF_TYPE_GET(ring_desc);
  921. /*
  922. * For REO error ring, expect only MSDU LINK DESC
  923. */
  924. qdf_assert_always(buf_type == HAL_RX_REO_MSDU_LINK_DESC_TYPE);
  925. cookie = HAL_RX_REO_BUF_COOKIE_GET(ring_desc);
  926. /*
  927. * check for the magic number in the sw cookie
  928. */
  929. qdf_assert_always((cookie >> LINK_DESC_ID_SHIFT) &
  930. LINK_DESC_ID_START);
  931. /*
  932. * Check if the buffer is to be processed on this processor
  933. */
  934. rbm = hal_rx_ret_buf_manager_get(ring_desc);
  935. hal_rx_reo_buf_paddr_get(ring_desc, &hbi);
  936. link_desc_va = dp_rx_cookie_2_link_desc_va(soc, &hbi);
  937. hal_rx_msdu_list_get(soc->hal_soc, link_desc_va, &msdu_list,
  938. &num_msdus);
  939. if (qdf_unlikely((msdu_list.rbm[0] != DP_WBM2SW_RBM) &&
  940. (msdu_list.rbm[0] !=
  941. HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST))) {
  942. /* TODO */
  943. /* Call appropriate handler */
  944. DP_STATS_INC(soc, rx.err.invalid_rbm, 1);
  945. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  946. FL("Invalid RBM %d"), msdu_list.rbm[0]);
  947. /* Return link descriptor through WBM ring (SW2WBM)*/
  948. dp_rx_link_desc_return(soc, ring_desc,
  949. HAL_BM_ACTION_RELEASE_MSDU_LIST);
  950. continue;
  951. }
  952. /* Get the MPDU DESC info */
  953. hal_rx_mpdu_desc_info_get(ring_desc, &mpdu_desc_info);
  954. if (mpdu_desc_info.mpdu_flags & HAL_MPDU_F_FRAGMENT) {
  955. /* TODO */
  956. count = dp_rx_frag_handle(soc,
  957. ring_desc, &mpdu_desc_info,
  958. &mac_id, quota);
  959. rx_bufs_reaped[mac_id] += count;
  960. DP_STATS_INC(soc, rx.rx_frags, 1);
  961. continue;
  962. }
  963. if (hal_rx_reo_is_pn_error(ring_desc)) {
  964. /* TOD0 */
  965. DP_STATS_INC(soc,
  966. rx.err.
  967. reo_error[HAL_REO_ERR_PN_CHECK_FAILED],
  968. 1);
  969. count = dp_rx_pn_error_handle(soc,
  970. ring_desc,
  971. &mpdu_desc_info, &mac_id,
  972. quota);
  973. rx_bufs_reaped[mac_id] += count;
  974. continue;
  975. }
  976. if (hal_rx_reo_is_2k_jump(ring_desc)) {
  977. /* TOD0 */
  978. DP_STATS_INC(soc,
  979. rx.err.
  980. reo_error[HAL_REO_ERR_REGULAR_FRAME_2K_JUMP],
  981. 1);
  982. count = dp_rx_2k_jump_handle(soc,
  983. ring_desc, &mpdu_desc_info,
  984. &mac_id, quota);
  985. rx_bufs_reaped[mac_id] += count;
  986. continue;
  987. }
  988. }
  989. done:
  990. hal_srng_access_end(hal_soc, hal_ring);
  991. if (soc->rx.flags.defrag_timeout_check)
  992. dp_rx_defrag_waitlist_flush(soc);
  993. for (mac_id = 0; mac_id < MAX_PDEV_CNT; mac_id++) {
  994. if (rx_bufs_reaped[mac_id]) {
  995. dp_pdev = soc->pdev_list[mac_id];
  996. dp_rxdma_srng = &dp_pdev->rx_refill_buf_ring;
  997. rx_desc_pool = &soc->rx_desc_buf[mac_id];
  998. dp_rx_buffers_replenish(soc, mac_id, dp_rxdma_srng,
  999. rx_desc_pool,
  1000. rx_bufs_reaped[mac_id],
  1001. &dp_pdev->free_list_head,
  1002. &dp_pdev->free_list_tail);
  1003. rx_bufs_used += rx_bufs_reaped[mac_id];
  1004. }
  1005. }
  1006. return rx_bufs_used; /* Assume no scale factor for now */
  1007. }
  1008. /**
  1009. * dp_rx_wbm_err_process() - Processes error frames routed to WBM release ring
  1010. *
  1011. * @soc: core txrx main context
  1012. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  1013. * @quota: No. of units (packets) that can be serviced in one shot.
  1014. *
  1015. * This function implements error processing and top level demultiplexer
  1016. * for all the frames routed to WBM2HOST sw release ring.
  1017. *
  1018. * Return: uint32_t: No. of elements processed
  1019. */
  1020. uint32_t
  1021. dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota)
  1022. {
  1023. void *hal_soc;
  1024. void *ring_desc;
  1025. struct dp_rx_desc *rx_desc;
  1026. union dp_rx_desc_list_elem_t *head[MAX_PDEV_CNT] = { NULL };
  1027. union dp_rx_desc_list_elem_t *tail[MAX_PDEV_CNT] = { NULL };
  1028. uint32_t rx_bufs_used = 0;
  1029. uint32_t rx_bufs_reaped[MAX_PDEV_CNT] = { 0 };
  1030. uint8_t buf_type, rbm;
  1031. uint32_t rx_buf_cookie;
  1032. uint8_t mac_id;
  1033. struct dp_pdev *dp_pdev;
  1034. struct dp_srng *dp_rxdma_srng;
  1035. struct rx_desc_pool *rx_desc_pool;
  1036. uint8_t *rx_tlv_hdr;
  1037. qdf_nbuf_t nbuf_head = NULL;
  1038. qdf_nbuf_t nbuf_tail = NULL;
  1039. qdf_nbuf_t nbuf, next;
  1040. struct hal_wbm_err_desc_info wbm_err_info = { 0 };
  1041. uint8_t pool_id;
  1042. uint8_t tid = 0;
  1043. /* Debug -- Remove later */
  1044. qdf_assert(soc && hal_ring);
  1045. hal_soc = soc->hal_soc;
  1046. /* Debug -- Remove later */
  1047. qdf_assert(hal_soc);
  1048. if (qdf_unlikely(hal_srng_access_start(hal_soc, hal_ring))) {
  1049. /* TODO */
  1050. /*
  1051. * Need API to convert from hal_ring pointer to
  1052. * Ring Type / Ring Id combo
  1053. */
  1054. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1055. FL("HAL RING Access Failed -- %pK"), hal_ring);
  1056. goto done;
  1057. }
  1058. while (qdf_likely(quota-- && (ring_desc =
  1059. hal_srng_dst_get_next(hal_soc, hal_ring)))) {
  1060. /* XXX */
  1061. buf_type = HAL_RX_WBM_BUF_TYPE_GET(ring_desc);
  1062. /*
  1063. * For WBM ring, expect only MSDU buffers
  1064. */
  1065. qdf_assert_always(buf_type == HAL_RX_WBM_BUF_TYPE_REL_BUF);
  1066. qdf_assert((HAL_RX_WBM_ERR_SRC_GET(ring_desc)
  1067. == HAL_RX_WBM_ERR_SRC_RXDMA) ||
  1068. (HAL_RX_WBM_ERR_SRC_GET(ring_desc)
  1069. == HAL_RX_WBM_ERR_SRC_REO));
  1070. /*
  1071. * Check if the buffer is to be processed on this processor
  1072. */
  1073. rbm = hal_rx_ret_buf_manager_get(ring_desc);
  1074. if (qdf_unlikely(rbm != HAL_RX_BUF_RBM_SW3_BM)) {
  1075. /* TODO */
  1076. /* Call appropriate handler */
  1077. DP_STATS_INC(soc, rx.err.invalid_rbm, 1);
  1078. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1079. FL("Invalid RBM %d"), rbm);
  1080. continue;
  1081. }
  1082. rx_buf_cookie = HAL_RX_WBM_BUF_COOKIE_GET(ring_desc);
  1083. rx_desc = dp_rx_cookie_2_va_rxdma_buf(soc, rx_buf_cookie);
  1084. qdf_assert_always(rx_desc);
  1085. if (!dp_rx_desc_check_magic(rx_desc)) {
  1086. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1087. FL("Invalid rx_desc cookie=%d"),
  1088. rx_buf_cookie);
  1089. continue;
  1090. }
  1091. nbuf = rx_desc->nbuf;
  1092. qdf_nbuf_unmap_single(soc->osdev, nbuf, QDF_DMA_BIDIRECTIONAL);
  1093. /*
  1094. * save the wbm desc info in nbuf TLV. We will need this
  1095. * info when we do the actual nbuf processing
  1096. */
  1097. hal_rx_wbm_err_info_get(ring_desc, &wbm_err_info, hal_soc);
  1098. wbm_err_info.pool_id = rx_desc->pool_id;
  1099. hal_rx_wbm_err_info_set_in_tlv(qdf_nbuf_data(nbuf),
  1100. &wbm_err_info);
  1101. rx_bufs_reaped[rx_desc->pool_id]++;
  1102. DP_RX_LIST_APPEND(nbuf_head, nbuf_tail, rx_desc->nbuf);
  1103. dp_rx_add_to_free_desc_list(&head[rx_desc->pool_id],
  1104. &tail[rx_desc->pool_id],
  1105. rx_desc);
  1106. }
  1107. done:
  1108. hal_srng_access_end(hal_soc, hal_ring);
  1109. for (mac_id = 0; mac_id < MAX_PDEV_CNT; mac_id++) {
  1110. if (rx_bufs_reaped[mac_id]) {
  1111. dp_pdev = soc->pdev_list[mac_id];
  1112. dp_rxdma_srng = &dp_pdev->rx_refill_buf_ring;
  1113. rx_desc_pool = &soc->rx_desc_buf[mac_id];
  1114. dp_rx_buffers_replenish(soc, mac_id, dp_rxdma_srng,
  1115. rx_desc_pool, rx_bufs_reaped[mac_id],
  1116. &head[mac_id], &tail[mac_id]);
  1117. rx_bufs_used += rx_bufs_reaped[mac_id];
  1118. }
  1119. }
  1120. nbuf = nbuf_head;
  1121. while (nbuf) {
  1122. struct dp_peer *peer;
  1123. uint16_t peer_id;
  1124. rx_tlv_hdr = qdf_nbuf_data(nbuf);
  1125. peer_id = hal_rx_mpdu_start_sw_peer_id_get(rx_tlv_hdr);
  1126. peer = dp_peer_find_by_id(soc, peer_id);
  1127. /*
  1128. * retrieve the wbm desc info from nbuf TLV, so we can
  1129. * handle error cases appropriately
  1130. */
  1131. hal_rx_wbm_err_info_get_from_tlv(rx_tlv_hdr, &wbm_err_info);
  1132. /* Set queue_mapping in nbuf to 0 */
  1133. dp_set_rx_queue(nbuf, 0);
  1134. next = nbuf->next;
  1135. if (wbm_err_info.wbm_err_src == HAL_RX_WBM_ERR_SRC_REO) {
  1136. if (wbm_err_info.reo_psh_rsn
  1137. == HAL_RX_WBM_REO_PSH_RSN_ERROR) {
  1138. DP_STATS_INC(soc,
  1139. rx.err.reo_error
  1140. [wbm_err_info.reo_err_code], 1);
  1141. switch (wbm_err_info.reo_err_code) {
  1142. /*
  1143. * Handling for packets which have NULL REO
  1144. * queue descriptor
  1145. */
  1146. case HAL_REO_ERR_QUEUE_DESC_ADDR_0:
  1147. pool_id = wbm_err_info.pool_id;
  1148. QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_DP,
  1149. "Got pkt with REO ERROR: %d",
  1150. wbm_err_info.reo_err_code);
  1151. dp_rx_null_q_desc_handle(soc, nbuf,
  1152. rx_tlv_hdr,
  1153. pool_id, peer);
  1154. nbuf = next;
  1155. if (peer)
  1156. dp_peer_unref_del_find_by_id(
  1157. peer);
  1158. continue;
  1159. /* TODO */
  1160. /* Add per error code accounting */
  1161. case HAL_REO_ERR_REGULAR_FRAME_2K_JUMP:
  1162. pool_id = wbm_err_info.pool_id;
  1163. QDF_TRACE(QDF_MODULE_ID_DP,
  1164. QDF_TRACE_LEVEL_ERROR,
  1165. "Got pkt with REO ERROR: %d",
  1166. wbm_err_info.reo_err_code);
  1167. if (hal_rx_msdu_end_first_msdu_get(rx_tlv_hdr)) {
  1168. peer_id =
  1169. hal_rx_mpdu_start_sw_peer_id_get(rx_tlv_hdr);
  1170. tid =
  1171. hal_rx_mpdu_start_tid_get(hal_soc, rx_tlv_hdr);
  1172. }
  1173. dp_2k_jump_handle(soc, nbuf, rx_tlv_hdr,
  1174. peer_id, tid);
  1175. nbuf = next;
  1176. if (peer)
  1177. dp_peer_unref_del_find_by_id(
  1178. peer);
  1179. continue;
  1180. default:
  1181. QDF_TRACE(QDF_MODULE_ID_DP,
  1182. QDF_TRACE_LEVEL_ERROR,
  1183. "REO error %d detected",
  1184. wbm_err_info.reo_err_code);
  1185. }
  1186. }
  1187. } else if (wbm_err_info.wbm_err_src ==
  1188. HAL_RX_WBM_ERR_SRC_RXDMA) {
  1189. if (wbm_err_info.rxdma_psh_rsn
  1190. == HAL_RX_WBM_RXDMA_PSH_RSN_ERROR) {
  1191. DP_STATS_INC(soc,
  1192. rx.err.rxdma_error
  1193. [wbm_err_info.rxdma_err_code], 1);
  1194. switch (wbm_err_info.rxdma_err_code) {
  1195. case HAL_RXDMA_ERR_UNENCRYPTED:
  1196. dp_rx_process_err_unencrypted(
  1197. soc, nbuf,
  1198. rx_tlv_hdr, peer);
  1199. nbuf = next;
  1200. if (peer)
  1201. dp_peer_unref_del_find_by_id(
  1202. peer);
  1203. continue;
  1204. case HAL_RXDMA_ERR_TKIP_MIC:
  1205. dp_rx_process_mic_error(soc, nbuf,
  1206. rx_tlv_hdr,
  1207. peer);
  1208. nbuf = next;
  1209. if (peer) {
  1210. DP_STATS_INC(peer, rx.err.mic_err, 1);
  1211. dp_peer_unref_del_find_by_id(
  1212. peer);
  1213. }
  1214. continue;
  1215. case HAL_RXDMA_ERR_DECRYPT:
  1216. if (peer)
  1217. DP_STATS_INC(peer, rx.err.decrypt_err, 1);
  1218. QDF_TRACE(QDF_MODULE_ID_DP,
  1219. QDF_TRACE_LEVEL_DEBUG,
  1220. "Packet received with Decrypt error");
  1221. break;
  1222. default:
  1223. QDF_TRACE(QDF_MODULE_ID_DP,
  1224. QDF_TRACE_LEVEL_DEBUG,
  1225. "RXDMA error %d",
  1226. wbm_err_info.
  1227. rxdma_err_code);
  1228. }
  1229. }
  1230. } else {
  1231. /* Should not come here */
  1232. qdf_assert(0);
  1233. }
  1234. if (peer)
  1235. dp_peer_unref_del_find_by_id(peer);
  1236. hal_rx_dump_pkt_tlvs(hal_soc, rx_tlv_hdr,
  1237. QDF_TRACE_LEVEL_DEBUG);
  1238. qdf_nbuf_free(nbuf);
  1239. nbuf = next;
  1240. }
  1241. return rx_bufs_used; /* Assume no scale factor for now */
  1242. }
  1243. /**
  1244. * dp_rx_err_mpdu_pop() - extract the MSDU's from link descs
  1245. *
  1246. * @soc: core DP main context
  1247. * @mac_id: mac id which is one of 3 mac_ids
  1248. * @rxdma_dst_ring_desc: void pointer to monitor link descriptor buf addr info
  1249. * @head: head of descs list to be freed
  1250. * @tail: tail of decs list to be freed
  1251. * Return: number of msdu in MPDU to be popped
  1252. */
  1253. static inline uint32_t
  1254. dp_rx_err_mpdu_pop(struct dp_soc *soc, uint32_t mac_id,
  1255. void *rxdma_dst_ring_desc,
  1256. union dp_rx_desc_list_elem_t **head,
  1257. union dp_rx_desc_list_elem_t **tail)
  1258. {
  1259. void *rx_msdu_link_desc;
  1260. qdf_nbuf_t msdu;
  1261. qdf_nbuf_t last;
  1262. struct hal_rx_msdu_list msdu_list;
  1263. uint16_t num_msdus;
  1264. struct hal_buf_info buf_info;
  1265. void *p_buf_addr_info;
  1266. void *p_last_buf_addr_info;
  1267. uint32_t rx_bufs_used = 0;
  1268. uint32_t msdu_cnt;
  1269. uint32_t i;
  1270. uint8_t push_reason;
  1271. uint8_t rxdma_error_code = 0;
  1272. uint8_t bm_action = HAL_BM_ACTION_PUT_IN_IDLE_LIST;
  1273. struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
  1274. msdu = 0;
  1275. last = NULL;
  1276. hal_rx_reo_ent_buf_paddr_get(rxdma_dst_ring_desc, &buf_info,
  1277. &p_last_buf_addr_info, &msdu_cnt);
  1278. push_reason =
  1279. hal_rx_reo_ent_rxdma_push_reason_get(rxdma_dst_ring_desc);
  1280. if (push_reason == HAL_RX_WBM_RXDMA_PSH_RSN_ERROR) {
  1281. rxdma_error_code =
  1282. hal_rx_reo_ent_rxdma_error_code_get(rxdma_dst_ring_desc);
  1283. }
  1284. do {
  1285. rx_msdu_link_desc =
  1286. dp_rx_cookie_2_link_desc_va(soc, &buf_info);
  1287. qdf_assert(rx_msdu_link_desc);
  1288. hal_rx_msdu_list_get(soc->hal_soc, rx_msdu_link_desc,
  1289. &msdu_list, &num_msdus);
  1290. if (msdu_list.sw_cookie[0] != HAL_RX_COOKIE_SPECIAL) {
  1291. /* if the msdus belongs to NSS offloaded radio &&
  1292. * the rbm is not SW1_BM then return the msdu_link
  1293. * descriptor without freeing the msdus (nbufs). let
  1294. * these buffers be given to NSS completion ring for
  1295. * NSS to free them.
  1296. * else iterate through the msdu link desc list and
  1297. * free each msdu in the list.
  1298. */
  1299. if (msdu_list.rbm[0] != HAL_RX_BUF_RBM_SW3_BM &&
  1300. wlan_cfg_get_dp_pdev_nss_enabled(
  1301. pdev->wlan_cfg_ctx))
  1302. bm_action = HAL_BM_ACTION_RELEASE_MSDU_LIST;
  1303. else {
  1304. for (i = 0; i < num_msdus; i++) {
  1305. struct dp_rx_desc *rx_desc =
  1306. dp_rx_cookie_2_va_rxdma_buf(soc,
  1307. msdu_list.sw_cookie[i]);
  1308. qdf_assert_always(rx_desc);
  1309. msdu = rx_desc->nbuf;
  1310. qdf_nbuf_unmap_single(soc->osdev, msdu,
  1311. QDF_DMA_FROM_DEVICE);
  1312. QDF_TRACE(QDF_MODULE_ID_DP,
  1313. QDF_TRACE_LEVEL_DEBUG,
  1314. "[%s][%d] msdu_nbuf=%pK ",
  1315. __func__, __LINE__, msdu);
  1316. qdf_nbuf_free(msdu);
  1317. rx_bufs_used++;
  1318. dp_rx_add_to_free_desc_list(head,
  1319. tail, rx_desc);
  1320. }
  1321. }
  1322. } else {
  1323. rxdma_error_code = HAL_RXDMA_ERR_WAR;
  1324. }
  1325. hal_rx_mon_next_link_desc_get(rx_msdu_link_desc, &buf_info,
  1326. &p_buf_addr_info);
  1327. dp_rx_link_desc_return(soc, p_last_buf_addr_info, bm_action);
  1328. p_last_buf_addr_info = p_buf_addr_info;
  1329. } while (buf_info.paddr);
  1330. DP_STATS_INC(soc, rx.err.rxdma_error[rxdma_error_code], 1);
  1331. if (rxdma_error_code == HAL_RXDMA_ERR_DECRYPT) {
  1332. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1333. "Packet received with Decrypt error");
  1334. }
  1335. return rx_bufs_used;
  1336. }
  1337. /**
  1338. * dp_rxdma_err_process() - RxDMA error processing functionality
  1339. *
  1340. * @soc: core txrx main contex
  1341. * @mac_id: mac id which is one of 3 mac_ids
  1342. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  1343. * @quota: No. of units (packets) that can be serviced in one shot.
  1344. * Return: num of buffers processed
  1345. */
  1346. uint32_t
  1347. dp_rxdma_err_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota)
  1348. {
  1349. struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
  1350. int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
  1351. void *hal_soc;
  1352. void *rxdma_dst_ring_desc;
  1353. void *err_dst_srng;
  1354. union dp_rx_desc_list_elem_t *head = NULL;
  1355. union dp_rx_desc_list_elem_t *tail = NULL;
  1356. struct dp_srng *dp_rxdma_srng;
  1357. struct rx_desc_pool *rx_desc_pool;
  1358. uint32_t work_done = 0;
  1359. uint32_t rx_bufs_used = 0;
  1360. if (!pdev)
  1361. return 0;
  1362. err_dst_srng = pdev->rxdma_err_dst_ring[mac_for_pdev].hal_srng;
  1363. if (!err_dst_srng) {
  1364. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1365. "%s %d : HAL Monitor Destination Ring Init \
  1366. Failed -- %pK",
  1367. __func__, __LINE__, err_dst_srng);
  1368. return 0;
  1369. }
  1370. hal_soc = soc->hal_soc;
  1371. qdf_assert(hal_soc);
  1372. if (qdf_unlikely(hal_srng_access_start(hal_soc, err_dst_srng))) {
  1373. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1374. "%s %d : HAL Monitor Destination Ring Init \
  1375. Failed -- %pK",
  1376. __func__, __LINE__, err_dst_srng);
  1377. return 0;
  1378. }
  1379. while (qdf_likely(quota-- && (rxdma_dst_ring_desc =
  1380. hal_srng_dst_get_next(hal_soc, err_dst_srng)))) {
  1381. rx_bufs_used += dp_rx_err_mpdu_pop(soc, mac_id,
  1382. rxdma_dst_ring_desc,
  1383. &head, &tail);
  1384. }
  1385. hal_srng_access_end(hal_soc, err_dst_srng);
  1386. if (rx_bufs_used) {
  1387. dp_rxdma_srng = &pdev->rx_refill_buf_ring;
  1388. rx_desc_pool = &soc->rx_desc_buf[mac_id];
  1389. dp_rx_buffers_replenish(soc, mac_id, dp_rxdma_srng,
  1390. rx_desc_pool, rx_bufs_used, &head, &tail);
  1391. work_done += rx_bufs_used;
  1392. }
  1393. return work_done;
  1394. }