dp_rx_err.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  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. rx_bufs_used++;
  213. nbuf = rx_desc->nbuf;
  214. qdf_nbuf_unmap_single(soc->osdev, nbuf,
  215. QDF_DMA_BIDIRECTIONAL);
  216. rx_desc->rx_buf_start = qdf_nbuf_data(nbuf);
  217. l2_hdr_offset =
  218. hal_rx_msdu_end_l3_hdr_padding_get(rx_desc->rx_buf_start);
  219. msdu_len = hal_rx_msdu_start_msdu_len_get(rx_desc->rx_buf_start);
  220. pkt_len = msdu_len + l2_hdr_offset + RX_PKT_TLVS_LEN;
  221. /* Set length in nbuf */
  222. qdf_nbuf_set_pktlen(nbuf, pkt_len);
  223. /*
  224. * Check if DMA completed -- msdu_done is the last bit
  225. * to be written
  226. */
  227. if (!hal_rx_attn_msdu_done_get(rx_desc->rx_buf_start)) {
  228. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  229. FL("MSDU DONE failure"));
  230. hal_rx_dump_pkt_tlvs(rx_desc->rx_buf_start,
  231. QDF_TRACE_LEVEL_INFO);
  232. qdf_assert(0);
  233. }
  234. peer_id = hal_rx_mpdu_start_sw_peer_id_get(rx_desc->rx_buf_start);
  235. peer = dp_peer_find_by_id(soc, peer_id);
  236. if (!peer) {
  237. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  238. FL("peer is NULL"));
  239. qdf_nbuf_pull_head(nbuf, RX_PKT_TLVS_LEN);
  240. dp_rx_process_invalid_peer(soc, nbuf);
  241. goto fail;
  242. }
  243. vdev = peer->vdev;
  244. if (!vdev) {
  245. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  246. FL("INVALID vdev %p OR osif_rx"), vdev);
  247. /* Drop & free packet */
  248. qdf_nbuf_free(nbuf);
  249. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  250. goto fail;
  251. }
  252. sgi = hal_rx_msdu_start_sgi_get(rx_desc->rx_buf_start);
  253. rate_mcs = hal_rx_msdu_start_rate_mcs_get(rx_desc->rx_buf_start);
  254. tid = hal_rx_mpdu_start_tid_get(rx_desc->rx_buf_start);
  255. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  256. "%s: %d, SGI: %d, rate_mcs: %d, tid: %d",
  257. __func__, __LINE__, sgi, rate_mcs, tid);
  258. /* WDS Source Port Learning */
  259. if (qdf_likely(vdev->rx_decap_type == htt_cmn_pkt_type_ethernet) &&
  260. (vdev->wds_enabled))
  261. dp_rx_wds_srcport_learn(soc, rx_desc->rx_buf_start, peer, nbuf);
  262. /*
  263. * Advance the packet start pointer by total size of
  264. * pre-header TLV's
  265. */
  266. qdf_nbuf_pull_head(nbuf, RX_PKT_TLVS_LEN);
  267. if (l2_hdr_offset)
  268. qdf_nbuf_pull_head(nbuf, l2_hdr_offset);
  269. if (hal_rx_mpdu_start_mpdu_qos_control_valid_get(
  270. rx_desc->rx_buf_start)) {
  271. /* TODO: Assuming that qos_control_valid also indicates
  272. * unicast. Should we check this?
  273. */
  274. if (peer &&
  275. peer->rx_tid[tid].hw_qdesc_vaddr_unaligned == NULL) {
  276. /* IEEE80211_SEQ_MAX indicates invalid start_seq */
  277. dp_rx_tid_setup_wifi3(peer, tid, 1, IEEE80211_SEQ_MAX);
  278. }
  279. }
  280. #ifdef QCA_WIFI_NAPIER_EMULATION /* Debug code, remove later */
  281. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  282. "%s: p_id %d msdu_len %d hdr_off %d",
  283. __func__, peer_id, msdu_len, l2_hdr_offset);
  284. print_hex_dump(KERN_ERR,
  285. "\t Pkt Data:", DUMP_PREFIX_NONE, 32, 4,
  286. qdf_nbuf_data(nbuf), 128, false);
  287. #endif /* NAPIER_EMULATION */
  288. if (qdf_unlikely(vdev->rx_decap_type == htt_cmn_pkt_type_raw)) {
  289. qdf_nbuf_set_next(nbuf, NULL);
  290. dp_rx_deliver_raw(vdev, nbuf);
  291. } else {
  292. if (qdf_unlikely(peer->bss_peer)) {
  293. QDF_TRACE(QDF_MODULE_ID_DP,
  294. QDF_TRACE_LEVEL_INFO,
  295. FL("received pkt with same src MAC"));
  296. /* Drop & free packet */
  297. qdf_nbuf_free(nbuf);
  298. goto fail;
  299. }
  300. if (vdev->osif_rx) {
  301. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  302. FL("vdev %p osif_rx %p"), vdev,
  303. vdev->osif_rx);
  304. qdf_nbuf_set_next(nbuf, NULL);
  305. vdev->osif_rx(vdev->osif_vdev, nbuf);
  306. DP_STATS_INC(vdev->pdev, rx.to_stack.num, 1);
  307. } else {
  308. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  309. FL("INVALID vdev %p OR osif_rx"), vdev);
  310. DP_STATS_INC(soc, rx.err.invalid_vdev, 1);
  311. }
  312. }
  313. fail:
  314. dp_rx_add_to_free_desc_list(head, tail, rx_desc);
  315. return rx_bufs_used;
  316. }
  317. /**
  318. * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW
  319. * (WBM), following error handling
  320. *
  321. * @soc: core DP main context
  322. * @ring_desc: opaque pointer to the REO error ring descriptor
  323. *
  324. * Return: QDF_STATUS
  325. */
  326. static QDF_STATUS
  327. dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc)
  328. {
  329. void *buf_addr_info = HAL_RX_REO_BUF_ADDR_INFO_GET(ring_desc);
  330. struct dp_srng *wbm_desc_rel_ring = &soc->wbm_desc_rel_ring;
  331. void *wbm_rel_srng = wbm_desc_rel_ring->hal_srng;
  332. void *hal_soc = soc->hal_soc;
  333. QDF_STATUS status = QDF_STATUS_E_FAILURE;
  334. void *src_srng_desc;
  335. if (!wbm_rel_srng) {
  336. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  337. "WBM RELEASE RING not initialized");
  338. return status;
  339. }
  340. if (qdf_unlikely(hal_srng_access_start(hal_soc, wbm_rel_srng))) {
  341. /* TODO */
  342. /*
  343. * Need API to convert from hal_ring pointer to
  344. * Ring Type / Ring Id combo
  345. */
  346. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  347. FL("HAL RING Access For WBM Release SRNG Failed - %p"),
  348. wbm_rel_srng);
  349. DP_STATS_INC(soc, rx.err.hal_ring_access_fail, 1);
  350. goto done;
  351. }
  352. src_srng_desc = hal_srng_src_get_next(hal_soc, wbm_rel_srng);
  353. if (qdf_likely(src_srng_desc)) {
  354. /* Return link descriptor through WBM ring (SW2WBM)*/
  355. hal_rx_msdu_link_desc_set(hal_soc,
  356. src_srng_desc, buf_addr_info);
  357. status = QDF_STATUS_SUCCESS;
  358. } else {
  359. struct hal_srng *srng = (struct hal_srng *)wbm_rel_srng;
  360. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  361. FL("WBM Release Ring (Id %d) Full"), srng->ring_id);
  362. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  363. "HP 0x%x Reap HP 0x%x TP 0x%x Cached TP 0x%x",
  364. *srng->u.src_ring.hp_addr, srng->u.src_ring.reap_hp,
  365. *srng->u.src_ring.tp_addr, srng->u.src_ring.cached_tp);
  366. }
  367. done:
  368. hal_srng_access_end(hal_soc, wbm_rel_srng);
  369. return status;
  370. }
  371. /**
  372. * dp_rx_err_process() - Processes error frames routed to REO error ring
  373. *
  374. * @soc: core txrx main context
  375. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  376. * @quota: No. of units (packets) that can be serviced in one shot.
  377. *
  378. * This function implements error processing and top level demultiplexer
  379. * for all the frames routed to REO error ring.
  380. *
  381. * Return: uint32_t: No. of elements processed
  382. */
  383. uint32_t
  384. dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota)
  385. {
  386. void *hal_soc;
  387. void *ring_desc;
  388. union dp_rx_desc_list_elem_t *head = NULL;
  389. union dp_rx_desc_list_elem_t *tail = NULL;
  390. uint32_t rx_bufs_used = 0;
  391. uint8_t buf_type;
  392. uint8_t error, rbm;
  393. struct hal_rx_mpdu_desc_info mpdu_desc_info;
  394. struct hal_buf_info hbi;
  395. struct dp_pdev *dp_pdev;
  396. struct dp_srng *dp_rxdma_srng;
  397. struct rx_desc_pool *rx_desc_pool;
  398. /* Debug -- Remove later */
  399. qdf_assert(soc && hal_ring);
  400. hal_soc = soc->hal_soc;
  401. /* Debug -- Remove later */
  402. qdf_assert(hal_soc);
  403. if (qdf_unlikely(hal_srng_access_start(hal_soc, hal_ring))) {
  404. /* TODO */
  405. /*
  406. * Need API to convert from hal_ring pointer to
  407. * Ring Type / Ring Id combo
  408. */
  409. DP_STATS_INC(soc, rx.err.hal_ring_access_fail, 1);
  410. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  411. FL("HAL RING Access Failed -- %p"), hal_ring);
  412. goto done;
  413. }
  414. while (qdf_likely((ring_desc =
  415. hal_srng_dst_get_next(hal_soc, hal_ring))
  416. && quota--)) {
  417. error = HAL_RX_ERROR_STATUS_GET(ring_desc);
  418. qdf_assert(error == HAL_REO_ERROR_DETECTED);
  419. /*
  420. * Check if the buffer is to be processed on this processor
  421. */
  422. rbm = hal_rx_ret_buf_manager_get(ring_desc);
  423. if (qdf_unlikely(rbm != HAL_RX_BUF_RBM_SW3_BM)) {
  424. /* TODO */
  425. /* Call appropriate handler */
  426. DP_STATS_INC(soc, rx.err.invalid_rbm, 1);
  427. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  428. FL("Invalid RBM %d"), rbm);
  429. continue;
  430. }
  431. buf_type = HAL_RX_REO_BUF_TYPE_GET(ring_desc);
  432. /*
  433. * For REO error ring, expect only MSDU LINK DESC
  434. */
  435. qdf_assert(buf_type == HAL_RX_REO_MSDU_LINK_DESC_TYPE);
  436. hal_rx_reo_buf_paddr_get(ring_desc, &hbi);
  437. /* Get the MPDU DESC info */
  438. hal_rx_mpdu_desc_info_get(ring_desc, &mpdu_desc_info);
  439. if (mpdu_desc_info.mpdu_flags & HAL_MPDU_F_FRAGMENT) {
  440. /* TODO */
  441. DP_STATS_INC(soc,
  442. rx.err.reo_error[HAL_MPDU_F_FRAGMENT], 1);
  443. rx_bufs_used += dp_rx_frag_handle(soc,
  444. ring_desc, &mpdu_desc_info,
  445. &head, &tail, quota);
  446. continue;
  447. }
  448. if (hal_rx_reo_is_pn_error(ring_desc)) {
  449. /* TOD0 */
  450. DP_STATS_INC(soc,
  451. rx.err.
  452. reo_error[HAL_REO_ERR_PN_CHECK_FAILED],
  453. 1);
  454. rx_bufs_used += dp_rx_pn_error_handle(soc,
  455. ring_desc, &mpdu_desc_info,
  456. &head, &tail, quota);
  457. continue;
  458. }
  459. if (hal_rx_reo_is_2k_jump(ring_desc)) {
  460. /* TOD0 */
  461. DP_STATS_INC(soc,
  462. rx.err.
  463. reo_error[HAL_REO_ERR_REGULAR_FRAME_2K_JUMP],
  464. 1);
  465. rx_bufs_used += dp_rx_2k_jump_handle(soc,
  466. ring_desc, &mpdu_desc_info,
  467. &head, &tail, quota);
  468. continue;
  469. }
  470. /* Return link descriptor through WBM ring (SW2WBM)*/
  471. dp_rx_link_desc_return(soc, ring_desc);
  472. }
  473. done:
  474. hal_srng_access_end(hal_soc, hal_ring);
  475. /* Assume MAC id = 0, owner = 0 */
  476. if (rx_bufs_used) {
  477. dp_pdev = soc->pdev_list[0];
  478. dp_rxdma_srng = &dp_pdev->rx_refill_buf_ring;
  479. rx_desc_pool = &soc->rx_desc_buf[0];
  480. dp_rx_buffers_replenish(soc, 0, dp_rxdma_srng, rx_desc_pool,
  481. rx_bufs_used, &head, &tail, HAL_RX_BUF_RBM_SW3_BM);
  482. }
  483. return rx_bufs_used; /* Assume no scale factor for now */
  484. }
  485. /**
  486. * dp_rx_wbm_err_process() - Processes error frames routed to WBM release ring
  487. *
  488. * @soc: core txrx main context
  489. * @hal_ring: opaque pointer to the HAL Rx Error Ring, which will be serviced
  490. * @quota: No. of units (packets) that can be serviced in one shot.
  491. *
  492. * This function implements error processing and top level demultiplexer
  493. * for all the frames routed to WBM2HOST sw release ring.
  494. *
  495. * Return: uint32_t: No. of elements processed
  496. */
  497. uint32_t
  498. dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota)
  499. {
  500. void *hal_soc;
  501. void *ring_desc;
  502. struct dp_rx_desc *rx_desc;
  503. union dp_rx_desc_list_elem_t *head[MAX_PDEV_CNT] = { NULL };
  504. union dp_rx_desc_list_elem_t *tail[MAX_PDEV_CNT] = { NULL };
  505. uint32_t rx_bufs_used[MAX_PDEV_CNT] = { 0 };
  506. uint32_t rx_bufs_reaped = 0;
  507. uint8_t buf_type, rbm;
  508. uint8_t wbm_err_src;
  509. uint32_t rx_buf_cookie;
  510. uint8_t mac_id;
  511. struct dp_pdev *dp_pdev;
  512. struct dp_srng *dp_rxdma_srng;
  513. struct rx_desc_pool *rx_desc_pool;
  514. /* Debug -- Remove later */
  515. qdf_assert(soc && hal_ring);
  516. hal_soc = soc->hal_soc;
  517. /* Debug -- Remove later */
  518. qdf_assert(hal_soc);
  519. if (qdf_unlikely(hal_srng_access_start(hal_soc, hal_ring))) {
  520. /* TODO */
  521. /*
  522. * Need API to convert from hal_ring pointer to
  523. * Ring Type / Ring Id combo
  524. */
  525. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  526. FL("HAL RING Access Failed -- %p"), hal_ring);
  527. goto done;
  528. }
  529. while (qdf_likely((ring_desc =
  530. hal_srng_dst_get_next(hal_soc, hal_ring))
  531. && quota--)) {
  532. /* XXX */
  533. wbm_err_src = HAL_RX_WBM_ERR_SRC_GET(ring_desc);
  534. qdf_assert((wbm_err_src == HAL_RX_WBM_ERR_SRC_RXDMA) ||
  535. (wbm_err_src == HAL_RX_WBM_ERR_SRC_REO));
  536. /*
  537. * Check if the buffer is to be processed on this processor
  538. */
  539. rbm = hal_rx_ret_buf_manager_get(ring_desc);
  540. if (qdf_unlikely(rbm != HAL_RX_BUF_RBM_SW3_BM)) {
  541. /* TODO */
  542. /* Call appropriate handler */
  543. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  544. FL("Invalid RBM %d"), rbm);
  545. continue;
  546. }
  547. rx_buf_cookie = HAL_RX_WBM_BUF_COOKIE_GET(ring_desc);
  548. rx_desc = dp_rx_cookie_2_va_rxdma_buf(soc, rx_buf_cookie);
  549. qdf_assert(rx_desc);
  550. /* XXX */
  551. buf_type = HAL_RX_WBM_BUF_TYPE_GET(ring_desc);
  552. /*
  553. * For WBM ring, expect only MSDU buffers
  554. */
  555. qdf_assert(buf_type == HAL_RX_WBM_BUF_TYPE_REL_BUF);
  556. if (wbm_err_src == HAL_RX_WBM_ERR_SRC_REO) {
  557. uint8_t push_reason =
  558. HAL_RX_WBM_REO_PUSH_REASON_GET(ring_desc);
  559. if (push_reason == HAL_RX_WBM_REO_PSH_RSN_ERROR) {
  560. uint8_t reo_error_code =
  561. HAL_RX_WBM_REO_ERROR_CODE_GET(ring_desc);
  562. DP_STATS_INC(soc, rx.err.reo_error[
  563. reo_error_code], 1);
  564. switch (reo_error_code) {
  565. /*
  566. * Handling for packets which have NULL REO
  567. * queue descriptor
  568. */
  569. case HAL_REO_ERR_QUEUE_DESC_ADDR_0:
  570. QDF_TRACE(QDF_MODULE_ID_DP,
  571. QDF_TRACE_LEVEL_WARN,
  572. "Got pkt with REO ERROR: %d",
  573. reo_error_code);
  574. rx_bufs_used[rx_desc->pool_id] +=
  575. dp_rx_null_q_desc_handle(soc,
  576. rx_desc,
  577. &head[rx_desc->pool_id],
  578. &tail[rx_desc->pool_id], quota);
  579. continue;
  580. /* TODO */
  581. /* Add per error code accounting */
  582. default:
  583. QDF_TRACE(QDF_MODULE_ID_DP,
  584. QDF_TRACE_LEVEL_ERROR,
  585. "REO error %d detected",
  586. reo_error_code);
  587. }
  588. }
  589. } else if (wbm_err_src == HAL_RX_WBM_ERR_SRC_RXDMA) {
  590. uint8_t push_reason =
  591. HAL_RX_WBM_RXDMA_PUSH_REASON_GET(ring_desc);
  592. if (push_reason == HAL_RX_WBM_RXDMA_PSH_RSN_ERROR) {
  593. uint8_t rxdma_error_code =
  594. HAL_RX_WBM_RXDMA_ERROR_CODE_GET(ring_desc);
  595. DP_STATS_INC(soc, rx.err.rxdma_error[
  596. rxdma_error_code], 1);
  597. switch (rxdma_error_code) {
  598. /* TODO */
  599. /* Add per error code accounting */
  600. default:
  601. QDF_TRACE(QDF_MODULE_ID_DP,
  602. QDF_TRACE_LEVEL_ERROR,
  603. "RXDMA error %d detected",
  604. rxdma_error_code);
  605. }
  606. }
  607. } else {
  608. /* Should not come here */
  609. rx_buf_cookie = HAL_RX_WBM_BUF_COOKIE_GET(ring_desc);
  610. rx_desc = dp_rx_cookie_2_va_rxdma_buf(soc, rx_buf_cookie);
  611. qdf_assert(rx_desc);
  612. qdf_nbuf_unmap_single(soc->osdev, rx_desc->nbuf,
  613. QDF_DMA_BIDIRECTIONAL);
  614. rx_desc->rx_buf_start = qdf_nbuf_data(rx_desc->nbuf);
  615. hal_rx_dump_pkt_tlvs(rx_desc->rx_buf_start,
  616. QDF_TRACE_LEVEL_INFO);
  617. qdf_assert(0);
  618. }
  619. rx_bufs_used[rx_desc->pool_id]++;
  620. qdf_nbuf_unmap_single(soc->osdev, rx_desc->nbuf,
  621. QDF_DMA_BIDIRECTIONAL);
  622. rx_desc->rx_buf_start = qdf_nbuf_data(rx_desc->nbuf);
  623. hal_rx_dump_pkt_tlvs(rx_desc->rx_buf_start,
  624. QDF_TRACE_LEVEL_INFO);
  625. qdf_nbuf_free(rx_desc->nbuf);
  626. dp_rx_add_to_free_desc_list(&head[rx_desc->pool_id],
  627. &tail[rx_desc->pool_id], rx_desc);
  628. }
  629. done:
  630. hal_srng_access_end(hal_soc, hal_ring);
  631. for (mac_id = 0; mac_id < MAX_PDEV_CNT; mac_id++) {
  632. if (rx_bufs_used[mac_id]) {
  633. dp_pdev = soc->pdev_list[mac_id];
  634. dp_rxdma_srng = &dp_pdev->rx_refill_buf_ring;
  635. rx_desc_pool = &soc->rx_desc_buf[mac_id];
  636. dp_rx_buffers_replenish(soc, mac_id, dp_rxdma_srng,
  637. rx_desc_pool, rx_bufs_used[mac_id],
  638. &head[mac_id], &tail[mac_id],
  639. HAL_RX_BUF_RBM_SW3_BM);
  640. rx_bufs_reaped += rx_bufs_used[mac_id];
  641. }
  642. }
  643. return rx_bufs_reaped; /* Assume no scale factor for now */
  644. }