dp_rx_err.c 21 KB

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