dp_rx_err.c 21 KB

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