dp_rx_err.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. * Copyright (c) 2016-2017 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 "dp_types.h"
  19. #include "dp_rx.h"
  20. #include "dp_peer.h"
  21. #include "dp_internal.h"
  22. #include "hal_api.h"
  23. #include "qdf_trace.h"
  24. #include "qdf_nbuf.h"
  25. #ifdef CONFIG_MCL
  26. #include <cds_ieee80211_common.h>
  27. #else
  28. #include <ieee80211.h>
  29. #endif
  30. /**
  31. * dp_rx_frag_handle() - Handles fragmented Rx frames
  32. *
  33. * @soc: core txrx main context
  34. * @ring_desc: opaque pointer to the REO error ring descriptor
  35. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  36. * @head: head of the local descriptor free-list
  37. * @tail: tail of the local descriptor free-list
  38. * @quota: No. of units (packets) that can be serviced in one shot.
  39. *
  40. * This function implements RX 802.11 fragmentation handling
  41. * The handling is mostly same as legacy fragmentation handling.
  42. * If required, this function can re-inject the frames back to
  43. * REO ring (with proper setting to by-pass fragmentation check
  44. * but use duplicate detection / re-ordering and routing these frames
  45. * to a different core.
  46. *
  47. * Return: uint32_t: No. of elements processed
  48. */
  49. static uint32_t
  50. dp_rx_frag_handle(struct dp_soc *soc, void *ring_desc,
  51. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  52. union dp_rx_desc_list_elem_t **head,
  53. union dp_rx_desc_list_elem_t **tail,
  54. uint32_t quota)
  55. {
  56. uint32_t rx_bufs_used = 0;
  57. return rx_bufs_used;
  58. }
  59. /**
  60. * dp_rx_msdus_drop() - Drops all MSDU's per MPDU
  61. *
  62. * @soc: core txrx main context
  63. * @ring_desc: opaque pointer to the REO error ring descriptor
  64. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  65. * @head: head of the local descriptor free-list
  66. * @tail: tail of the local descriptor free-list
  67. * @quota: No. of units (packets) that can be serviced in one shot.
  68. *
  69. * This function is used to drop all MSDU in an MPDU
  70. *
  71. * Return: uint32_t: No. of elements processed
  72. */
  73. static uint32_t
  74. dp_rx_msdus_drop(struct dp_soc *soc, void *ring_desc,
  75. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  76. union dp_rx_desc_list_elem_t **head,
  77. union dp_rx_desc_list_elem_t **tail,
  78. uint32_t quota)
  79. {
  80. uint8_t num_msdus;
  81. uint32_t rx_bufs_used = 0;
  82. void *link_desc_va;
  83. struct hal_buf_info buf_info;
  84. struct hal_rx_msdu_list msdu_list; /* MSDU's per MPDU */
  85. int i;
  86. hal_rx_reo_buf_paddr_get(ring_desc, &buf_info);
  87. link_desc_va = dp_rx_cookie_2_link_desc_va(soc, &buf_info);
  88. qdf_assert(rx_msdu_link_desc);
  89. /* No UNMAP required -- this is "malloc_consistent" memory */
  90. hal_rx_msdu_list_get(link_desc_va, &msdu_list, &num_msdus);
  91. for (i = 0; (i < HAL_RX_NUM_MSDU_DESC) && quota--; i++) {
  92. struct dp_rx_desc *rx_desc =
  93. dp_rx_cookie_2_va_rxdma_buf(soc,
  94. msdu_list.sw_cookie[i]);
  95. qdf_assert(rx_desc);
  96. rx_bufs_used++;
  97. /* Just free the buffers */
  98. qdf_nbuf_free(rx_desc->nbuf);
  99. dp_rx_add_to_free_desc_list(head, tail, rx_desc);
  100. }
  101. return rx_bufs_used;
  102. }
  103. /**
  104. * dp_rx_pn_error_handle() - Handles PN check errors
  105. *
  106. * @soc: core txrx main context
  107. * @ring_desc: opaque pointer to the REO error ring descriptor
  108. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  109. * @head: head of the local descriptor free-list
  110. * @tail: tail of the local descriptor free-list
  111. * @quota: No. of units (packets) that can be serviced in one shot.
  112. *
  113. * This function implements PN error handling
  114. * If the peer is configured to ignore the PN check errors
  115. * or if DP feels, that this frame is still OK, the frame can be
  116. * re-injected back to REO to use some of the other features
  117. * of REO e.g. duplicate detection/routing to other cores
  118. *
  119. * Return: uint32_t: No. of elements processed
  120. */
  121. static uint32_t
  122. dp_rx_pn_error_handle(struct dp_soc *soc, void *ring_desc,
  123. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  124. union dp_rx_desc_list_elem_t **head,
  125. union dp_rx_desc_list_elem_t **tail,
  126. uint32_t quota)
  127. {
  128. uint16_t peer_id;
  129. uint32_t rx_bufs_used = 0;
  130. struct dp_peer *peer;
  131. bool peer_pn_policy = false;
  132. peer_id = DP_PEER_METADATA_PEER_ID_GET(
  133. mpdu_desc_info->peer_meta_data);
  134. peer = dp_peer_find_by_id(soc, peer_id);
  135. if (qdf_likely(peer)) {
  136. /*
  137. * TODO: Check for peer specific policies & set peer_pn_policy
  138. */
  139. }
  140. /* No peer PN policy -- definitely drop */
  141. if (!peer_pn_policy)
  142. rx_bufs_used = dp_rx_msdus_drop(soc, ring_desc,
  143. mpdu_desc_info,
  144. head, tail, quota);
  145. return rx_bufs_used;
  146. }
  147. /**
  148. * dp_rx_2k_jump_handle() - Handles Sequence Number Jump by 2K
  149. *
  150. * @soc: core txrx main context
  151. * @ring_desc: opaque pointer to the REO error ring descriptor
  152. * @mpdu_desc_info: MPDU descriptor information from ring descriptor
  153. * @head: head of the local descriptor free-list
  154. * @tail: tail of the local descriptor free-list
  155. * @quota: No. of units (packets) that can be serviced in one shot.
  156. *
  157. * This function implements the error handling when sequence number
  158. * of the MPDU jumps suddenly by 2K.Today there are 2 cases that
  159. * need to be handled:
  160. * A) CSN (Current Sequence Number) = Last Valid SN (LSN) + 2K
  161. * B) CSN = LSN + 2K, but falls within a "BA sized window" of the SSN
  162. * For case A) the protocol stack is invoked to generate DELBA/DEAUTH frame
  163. * For case B), the frame is normally dropped, no more action is taken
  164. *
  165. * Return: uint32_t: No. of elements processed
  166. */
  167. static uint32_t
  168. dp_rx_2k_jump_handle(struct dp_soc *soc, void *ring_desc,
  169. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  170. union dp_rx_desc_list_elem_t **head,
  171. union dp_rx_desc_list_elem_t **tail,
  172. uint32_t quota)
  173. {
  174. return dp_rx_msdus_drop(soc, ring_desc, mpdu_desc_info,
  175. head, tail, quota);
  176. }
  177. /**
  178. * dp_rx_null_q_desc_handle() - Function to handle NULL Queue
  179. * descriptor violation on either a
  180. * REO or WBM ring
  181. *
  182. * @soc: core DP main context
  183. * @rx_desc : pointer to the sw rx descriptor
  184. * @head: pointer to head of rx descriptors to be added to free list
  185. * @tail: pointer to tail of rx descriptors to be added to free list
  186. * quota: upper limit of descriptors that can be reaped
  187. *
  188. * This function handles NULL queue descriptor violations arising out
  189. * a missing REO queue for a given peer or a given TID. This typically
  190. * may happen if a packet is received on a QOS enabled TID before the
  191. * ADDBA negotiation for that TID, when the TID queue is setup. Or
  192. * it may also happen for MC/BC frames if they are not routed to the
  193. * non-QOS TID queue, in the absence of any other default TID queue.
  194. * This error can show up both in a REO destination or WBM release ring.
  195. *
  196. * Return: uint32_t: No. of Rx buffers reaped
  197. */
  198. static uint32_t
  199. dp_rx_null_q_desc_handle(struct dp_soc *soc, struct dp_rx_desc *rx_desc,
  200. union dp_rx_desc_list_elem_t **head,
  201. union dp_rx_desc_list_elem_t **tail,
  202. uint32_t quota)
  203. {
  204. uint32_t rx_bufs_used = 0;
  205. uint32_t pkt_len, l2_hdr_offset;
  206. uint16_t msdu_len;
  207. qdf_nbuf_t nbuf;
  208. struct dp_vdev *vdev;
  209. uint16_t peer_id = 0xFFFF;
  210. struct dp_peer *peer = NULL;
  211. uint32_t sgi, rate_mcs, tid;
  212. uint32_t peer_mdata;
  213. rx_bufs_used++;
  214. nbuf = rx_desc->nbuf;
  215. qdf_nbuf_unmap_single(soc->osdev, nbuf,
  216. QDF_DMA_BIDIRECTIONAL);
  217. rx_desc->rx_buf_start = qdf_nbuf_data(nbuf);
  218. l2_hdr_offset =
  219. hal_rx_msdu_end_l3_hdr_padding_get(rx_desc->rx_buf_start);
  220. msdu_len = hal_rx_msdu_start_msdu_len_get(rx_desc->rx_buf_start);
  221. pkt_len = msdu_len + l2_hdr_offset + RX_PKT_TLVS_LEN;
  222. /* Set length in nbuf */
  223. qdf_nbuf_set_pktlen(nbuf, pkt_len);
  224. /*
  225. * Check if DMA completed -- msdu_done is the last bit
  226. * to be written
  227. */
  228. if (!hal_rx_attn_msdu_done_get(rx_desc->rx_buf_start)) {
  229. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  230. FL("MSDU DONE failure"));
  231. hal_rx_dump_pkt_tlvs(rx_desc->rx_buf_start,
  232. QDF_TRACE_LEVEL_INFO);
  233. qdf_assert(0);
  234. }
  235. peer_id = hal_rx_mpdu_start_sw_peer_id_get(rx_desc->rx_buf_start);
  236. peer = dp_peer_find_by_id(soc, peer_id);
  237. if (!peer) {
  238. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  239. FL("peer is NULL"));
  240. qdf_nbuf_pull_head(nbuf, RX_PKT_TLVS_LEN);
  241. dp_rx_process_invalid_peer(soc, nbuf);
  242. goto fail;
  243. }
  244. sgi = hal_rx_msdu_start_sgi_get(rx_desc->rx_buf_start);
  245. rate_mcs = hal_rx_msdu_start_rate_mcs_get(rx_desc->rx_buf_start);
  246. tid = hal_rx_mpdu_start_tid_get(rx_desc->rx_buf_start);
  247. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  248. "%s: %d, SGI: %d, rate_mcs: %d, tid: %d",
  249. __func__, __LINE__, sgi, rate_mcs, tid);
  250. peer_mdata = hal_rx_mpdu_peer_meta_data_get(rx_desc->rx_buf_start);
  251. peer_id = DP_PEER_METADATA_PEER_ID_GET(peer_mdata);
  252. peer = dp_peer_find_by_id(soc, peer_id);
  253. if (!peer) {
  254. qdf_nbuf_free(nbuf);
  255. goto fail;
  256. }
  257. /*
  258. * Advance the packet start pointer by total size of
  259. * pre-header TLV's
  260. */
  261. qdf_nbuf_pull_head(nbuf, RX_PKT_TLVS_LEN);
  262. if (l2_hdr_offset)
  263. qdf_nbuf_pull_head(nbuf, l2_hdr_offset);
  264. /* WDS Source Port Learning */
  265. dp_rx_wds_srcport_learn(soc, rx_desc->rx_buf_start, peer, nbuf);
  266. if (hal_rx_mpdu_start_mpdu_qos_control_valid_get(
  267. rx_desc->rx_buf_start)) {
  268. /* TODO: Assuming that qos_control_valid also indicates
  269. * unicast. Should we check this?
  270. */
  271. if (peer &&
  272. peer->rx_tid[tid].hw_qdesc_vaddr_unaligned == NULL) {
  273. /* IEEE80211_SEQ_MAX indicates invalid start_seq */
  274. dp_rx_tid_setup_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
  275. }
  276. }
  277. #ifdef QCA_WIFI_NAPIER_EMULATION /* Debug code, remove later */
  278. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  279. "%s: p_id %d msdu_len %d hdr_off %d",
  280. __func__, peer_id, msdu_len, l2_hdr_offset);
  281. print_hex_dump(KERN_ERR,
  282. "\t Pkt Data:", DUMP_PREFIX_NONE, 32, 4,
  283. qdf_nbuf_data(nbuf), 128, false);
  284. #endif /* NAPIER_EMULATION */
  285. if (qdf_unlikely(peer->bss_peer)) {
  286. QDF_TRACE(QDF_MODULE_ID_DP,
  287. QDF_TRACE_LEVEL_INFO,
  288. FL("received pkt with same src MAC"));
  289. /* Drop & free packet */
  290. qdf_nbuf_free(nbuf);
  291. /* Statistics */
  292. goto fail;
  293. }
  294. vdev = peer->vdev;
  295. if (vdev && vdev->osif_rx) {
  296. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  297. FL("vdev %p osif_rx %p"), vdev,
  298. vdev->osif_rx);
  299. qdf_nbuf_set_next(nbuf, NULL);
  300. vdev->osif_rx(vdev->osif_vdev, nbuf);
  301. DP_STATS_INC(vdev->pdev, rx.to_stack.num, 1);
  302. } else {
  303. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  304. FL("INVALID vdev %p OR osif_rx"), vdev);
  305. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  306. }
  307. fail:
  308. dp_rx_add_to_free_desc_list(head, tail, rx_desc);
  309. return rx_bufs_used;
  310. }
  311. /**
  312. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  313. * (WBM), following error handling
  314. *
  315. * @soc: core DP main context
  316. * @ring_desc: opaque pointer to the REO error ring descriptor
  317. *
  318. * Return: QDF_STATUS
  319. */
  320. static QDF_STATUS
  321. dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc)
  322. {
  323. void *buf_addr_info = HAL_RX_REO_BUF_ADDR_INFO_GET(ring_desc);
  324. struct dp_srng *wbm_desc_rel_ring = &soc->wbm_desc_rel_ring;
  325. void *wbm_rel_srng = wbm_desc_rel_ring->hal_srng;
  326. void *hal_soc = soc->hal_soc;
  327. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  328. void *src_srng_desc;
  329. if (!wbm_rel_srng) {
  330. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  331. "WBM RELEASE RING not initialized");
  332. return status;
  333. }
  334. if (qdf_unlikely(hal_srng_access_start(hal_soc, wbm_rel_srng))) {
  335. /* TODO */
  336. /*
  337. * Need API to convert from hal_ring pointer to
  338. * Ring Type / Ring Id combo
  339. */
  340. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  341. FL("HAL RING Access For WBM Release SRNG Failed - %p"),
  342. wbm_rel_srng);
  343. DP_STATS_INC(soc, rx.err.hal_ring_access_fail, 1);
  344. goto done;
  345. }
  346. src_srng_desc = hal_srng_src_get_next(hal_soc, wbm_rel_srng);
  347. if (qdf_likely(src_srng_desc)) {
  348. /* Return link descriptor through WBM ring (SW2WBM)*/
  349. hal_rx_msdu_link_desc_set(hal_soc,
  350. src_srng_desc, buf_addr_info);
  351. status = QDF_STATUS_SUCCESS;
  352. } else {
  353. struct hal_srng *srng = (struct hal_srng *)wbm_rel_srng;
  354. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  355. FL("WBM Release Ring (Id %d) Full"), srng->ring_id);
  356. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  357. "HP 0x%x Reap HP 0x%x TP 0x%x Cached TP 0x%x",
  358. *srng->u.src_ring.hp_addr, srng->u.src_ring.reap_hp,
  359. *srng->u.src_ring.tp_addr, srng->u.src_ring.cached_tp);
  360. }
  361. done:
  362. hal_srng_access_end(hal_soc, wbm_rel_srng);
  363. return status;
  364. }
  365. /**
  366. * dp_rx_err_process() - Processes error frames routed to REO error ring
  367. *
  368. * @soc: core txrx main context
  369. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  370. * @quota: No. of units (packets) that can be serviced in one shot.
  371. *
  372. * This function implements error processing and top level demultiplexer
  373. * for all the frames routed to REO error ring.
  374. *
  375. * Return: uint32_t: No. of elements processed
  376. */
  377. uint32_t
  378. dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota)
  379. {
  380. void *hal_soc;
  381. void *ring_desc;
  382. union dp_rx_desc_list_elem_t *head = NULL;
  383. union dp_rx_desc_list_elem_t *tail = NULL;
  384. uint32_t rx_bufs_used = 0;
  385. uint8_t buf_type;
  386. uint8_t error, rbm;
  387. struct hal_rx_mpdu_desc_info mpdu_desc_info;
  388. struct hal_buf_info hbi;
  389. struct dp_pdev *dp_pdev;
  390. struct dp_srng *dp_rxdma_srng;
  391. struct rx_desc_pool *rx_desc_pool;
  392. /* Debug -- Remove later */
  393. qdf_assert(soc && hal_ring);
  394. hal_soc = soc->hal_soc;
  395. /* Debug -- Remove later */
  396. qdf_assert(hal_soc);
  397. if (qdf_unlikely(hal_srng_access_start(hal_soc, hal_ring))) {
  398. /* TODO */
  399. /*
  400. * Need API to convert from hal_ring pointer to
  401. * Ring Type / Ring Id combo
  402. */
  403. DP_STATS_INC(soc, rx.err.hal_ring_access_fail, 1);
  404. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  405. FL("HAL RING Access Failed -- %p"), hal_ring);
  406. goto done;
  407. }
  408. while (qdf_likely((ring_desc =
  409. hal_srng_dst_get_next(hal_soc, hal_ring))
  410. && quota--)) {
  411. error = HAL_RX_ERROR_STATUS_GET(ring_desc);
  412. qdf_assert(error == HAL_REO_ERROR_DETECTED);
  413. /*
  414. * Check if the buffer is to be processed on this processor
  415. */
  416. rbm = hal_rx_ret_buf_manager_get(ring_desc);
  417. if (qdf_unlikely(rbm != HAL_RX_BUF_RBM_SW3_BM)) {
  418. /* TODO */
  419. /* Call appropriate handler */
  420. DP_STATS_INC(soc, rx.err.invalid_rbm, 1);
  421. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  422. FL("Invalid RBM %d"), rbm);
  423. continue;
  424. }
  425. buf_type = HAL_RX_REO_BUF_TYPE_GET(ring_desc);
  426. /*
  427. * For REO error ring, expect only MSDU LINK DESC
  428. */
  429. qdf_assert(buf_type == HAL_RX_REO_MSDU_LINK_DESC_TYPE);
  430. hal_rx_reo_buf_paddr_get(ring_desc, &hbi);
  431. /* Get the MPDU DESC info */
  432. hal_rx_mpdu_desc_info_get(ring_desc, &mpdu_desc_info);
  433. if (mpdu_desc_info.mpdu_flags & HAL_MPDU_F_FRAGMENT) {
  434. /* TODO */
  435. DP_STATS_INC(soc,
  436. rx.err.reo_error[HAL_MPDU_F_FRAGMENT], 1);
  437. rx_bufs_used += dp_rx_frag_handle(soc,
  438. ring_desc, &mpdu_desc_info,
  439. &head, &tail, quota);
  440. continue;
  441. }
  442. if (hal_rx_reo_is_pn_error(ring_desc)) {
  443. /* TOD0 */
  444. DP_STATS_INC(soc,
  445. rx.err.
  446. reo_error[HAL_REO_ERR_PN_CHECK_FAILED],
  447. 1);
  448. rx_bufs_used += dp_rx_pn_error_handle(soc,
  449. ring_desc, &mpdu_desc_info,
  450. &head, &tail, quota);
  451. continue;
  452. }
  453. if (hal_rx_reo_is_2k_jump(ring_desc)) {
  454. /* TOD0 */
  455. DP_STATS_INC(soc,
  456. rx.err.
  457. reo_error[HAL_REO_ERR_REGULAR_FRAME_2K_JUMP],
  458. 1);
  459. rx_bufs_used += dp_rx_2k_jump_handle(soc,
  460. ring_desc, &mpdu_desc_info,
  461. &head, &tail, quota);
  462. continue;
  463. }
  464. /* Return link descriptor through WBM ring (SW2WBM)*/
  465. dp_rx_link_desc_return(soc, ring_desc);
  466. }
  467. done:
  468. hal_srng_access_end(hal_soc, hal_ring);
  469. /* Assume MAC id = 0, owner = 0 */
  470. if (rx_bufs_used) {
  471. dp_pdev = soc->pdev_list[0];
  472. dp_rxdma_srng = &dp_pdev->rx_refill_buf_ring;
  473. rx_desc_pool = &soc->rx_desc_buf[0];
  474. dp_rx_buffers_replenish(soc, 0, dp_rxdma_srng, rx_desc_pool,
  475. rx_bufs_used, &head, &tail, HAL_RX_BUF_RBM_SW3_BM);
  476. }
  477. return rx_bufs_used; /* Assume no scale factor for now */
  478. }
  479. /**
  480. * dp_rx_wbm_err_process() - Processes error frames routed to WBM release ring
  481. *
  482. * @soc: core txrx main context
  483. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  484. * @quota: No. of units (packets) that can be serviced in one shot.
  485. *
  486. * This function implements error processing and top level demultiplexer
  487. * for all the frames routed to WBM2HOST sw release ring.
  488. *
  489. * Return: uint32_t: No. of elements processed
  490. */
  491. uint32_t
  492. dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota)
  493. {
  494. void *hal_soc;
  495. void *ring_desc;
  496. struct dp_rx_desc *rx_desc;
  497. union dp_rx_desc_list_elem_t *head[MAX_PDEV_CNT] = { NULL };
  498. union dp_rx_desc_list_elem_t *tail[MAX_PDEV_CNT] = { NULL };
  499. uint32_t rx_bufs_used[MAX_PDEV_CNT] = { 0 };
  500. uint32_t rx_bufs_reaped = 0;
  501. uint8_t buf_type, rbm;
  502. uint8_t wbm_err_src;
  503. uint32_t rx_buf_cookie;
  504. uint8_t mac_id;
  505. struct dp_pdev *dp_pdev;
  506. struct dp_srng *dp_rxdma_srng;
  507. struct rx_desc_pool *rx_desc_pool;
  508. /* Debug -- Remove later */
  509. qdf_assert(soc && hal_ring);
  510. hal_soc = soc->hal_soc;
  511. /* Debug -- Remove later */
  512. qdf_assert(hal_soc);
  513. if (qdf_unlikely(hal_srng_access_start(hal_soc, hal_ring))) {
  514. /* TODO */
  515. /*
  516. * Need API to convert from hal_ring pointer to
  517. * Ring Type / Ring Id combo
  518. */
  519. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  520. FL("HAL RING Access Failed -- %p"), hal_ring);
  521. goto done;
  522. }
  523. while (qdf_likely((ring_desc =
  524. hal_srng_dst_get_next(hal_soc, hal_ring))
  525. && quota--)) {
  526. /* XXX */
  527. wbm_err_src = HAL_RX_WBM_ERR_SRC_GET(ring_desc);
  528. qdf_assert((wbm_err_src == HAL_RX_WBM_ERR_SRC_RXDMA) ||
  529. (wbm_err_src == HAL_RX_WBM_ERR_SRC_REO));
  530. /*
  531. * Check if the buffer is to be processed on this processor
  532. */
  533. rbm = hal_rx_ret_buf_manager_get(ring_desc);
  534. if (qdf_unlikely(rbm != HAL_RX_BUF_RBM_SW3_BM)) {
  535. /* TODO */
  536. /* Call appropriate handler */
  537. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  538. FL("Invalid RBM %d"), rbm);
  539. continue;
  540. }
  541. rx_buf_cookie = HAL_RX_WBM_BUF_COOKIE_GET(ring_desc);
  542. rx_desc = dp_rx_cookie_2_va_rxdma_buf(soc, rx_buf_cookie);
  543. qdf_assert(rx_desc);
  544. /* XXX */
  545. buf_type = HAL_RX_WBM_BUF_TYPE_GET(ring_desc);
  546. /*
  547. * For WBM ring, expect only MSDU buffers
  548. */
  549. qdf_assert(buf_type == HAL_RX_WBM_BUF_TYPE_REL_BUF);
  550. if (wbm_err_src == HAL_RX_WBM_ERR_SRC_REO) {
  551. uint8_t push_reason =
  552. HAL_RX_WBM_REO_PUSH_REASON_GET(ring_desc);
  553. if (push_reason == HAL_RX_WBM_REO_PSH_RSN_ERROR) {
  554. uint8_t reo_error_code =
  555. HAL_RX_WBM_REO_ERROR_CODE_GET(ring_desc);
  556. DP_STATS_INC(soc, rx.err.reo_error[
  557. reo_error_code], 1);
  558. switch (reo_error_code) {
  559. /*
  560. * Handling for packets which have NULL REO
  561. * queue descriptor
  562. */
  563. case HAL_REO_ERR_QUEUE_DESC_ADDR_0:
  564. QDF_TRACE(QDF_MODULE_ID_DP,
  565. QDF_TRACE_LEVEL_WARN,
  566. "Got pkt with REO ERROR: %d",
  567. reo_error_code);
  568. rx_bufs_used[rx_desc->pool_id] +=
  569. dp_rx_null_q_desc_handle(soc,
  570. rx_desc,
  571. &head[rx_desc->pool_id],
  572. &tail[rx_desc->pool_id], quota);
  573. continue;
  574. /* TODO */
  575. /* Add per error code accounting */
  576. default:
  577. QDF_TRACE(QDF_MODULE_ID_DP,
  578. QDF_TRACE_LEVEL_ERROR,
  579. "REO error %d detected",
  580. reo_error_code);
  581. }
  582. }
  583. } else if (wbm_err_src == HAL_RX_WBM_ERR_SRC_RXDMA) {
  584. uint8_t push_reason =
  585. HAL_RX_WBM_RXDMA_PUSH_REASON_GET(ring_desc);
  586. if (push_reason == HAL_RX_WBM_RXDMA_PSH_RSN_ERROR) {
  587. uint8_t rxdma_error_code =
  588. HAL_RX_WBM_RXDMA_ERROR_CODE_GET(ring_desc);
  589. DP_STATS_INC(soc, rx.err.rxdma_error[
  590. rxdma_error_code], 1);
  591. switch (rxdma_error_code) {
  592. /* TODO */
  593. /* Add per error code accounting */
  594. default:
  595. QDF_TRACE(QDF_MODULE_ID_DP,
  596. QDF_TRACE_LEVEL_ERROR,
  597. "RXDMA error %d detected",
  598. rxdma_error_code);
  599. }
  600. }
  601. } else {
  602. /* Should not come here */
  603. rx_buf_cookie = HAL_RX_WBM_BUF_COOKIE_GET(ring_desc);
  604. rx_desc = dp_rx_cookie_2_va_rxdma_buf(soc, rx_buf_cookie);
  605. qdf_assert(rx_desc);
  606. qdf_nbuf_unmap_single(soc->osdev, rx_desc->nbuf,
  607. QDF_DMA_BIDIRECTIONAL);
  608. rx_desc->rx_buf_start = qdf_nbuf_data(rx_desc->nbuf);
  609. hal_rx_dump_pkt_tlvs(rx_desc->rx_buf_start,
  610. QDF_TRACE_LEVEL_INFO);
  611. qdf_assert(0);
  612. }
  613. rx_bufs_used[rx_desc->pool_id]++;
  614. qdf_nbuf_unmap_single(soc->osdev, rx_desc->nbuf,
  615. QDF_DMA_BIDIRECTIONAL);
  616. rx_desc->rx_buf_start = qdf_nbuf_data(rx_desc->nbuf);
  617. hal_rx_dump_pkt_tlvs(rx_desc->rx_buf_start,
  618. QDF_TRACE_LEVEL_INFO);
  619. qdf_nbuf_free(rx_desc->nbuf);
  620. dp_rx_add_to_free_desc_list(&head[rx_desc->pool_id],
  621. &tail[rx_desc->pool_id], rx_desc);
  622. }
  623. done:
  624. hal_srng_access_end(hal_soc, hal_ring);
  625. for (mac_id = 0; mac_id < MAX_PDEV_CNT; mac_id++) {
  626. if (rx_bufs_used[mac_id]) {
  627. dp_pdev = soc->pdev_list[mac_id];
  628. dp_rxdma_srng = &dp_pdev->rx_refill_buf_ring;
  629. rx_desc_pool = &soc->rx_desc_buf[mac_id];
  630. dp_rx_buffers_replenish(soc, mac_id, dp_rxdma_srng,
  631. rx_desc_pool, rx_bufs_used[mac_id],
  632. &head[mac_id], &tail[mac_id],
  633. HAL_RX_BUF_RBM_SW3_BM);
  634. rx_bufs_reaped += rx_bufs_used[mac_id];
  635. }
  636. }
  637. return rx_bufs_reaped; /* Assume no scale factor for now */
  638. }