dp_full_mon.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "dp_types.h"
  17. #include "hal_rx.h"
  18. #include "hal_api.h"
  19. #include "qdf_trace.h"
  20. #include "qdf_nbuf.h"
  21. #include "hal_api_mon.h"
  22. #include "dp_rx.h"
  23. #include "dp_rx_mon.h"
  24. #include "dp_internal.h"
  25. #include "dp_htt.h"
  26. #include "dp_full_mon.h"
  27. #include "qdf_mem.h"
  28. #ifdef QCA_SUPPORT_FULL_MON
  29. uint32_t
  30. dp_rx_mon_status_process(struct dp_soc *soc,
  31. uint32_t mac_id,
  32. uint32_t quota);
  33. /*
  34. * dp_rx_mon_prepare_mon_mpdu () - API to prepare dp_mon_mpdu object
  35. *
  36. * @pdev: DP pdev object
  37. * @head_msdu: Head msdu
  38. * @tail_msdu: Tail msdu
  39. *
  40. */
  41. static inline struct dp_mon_mpdu *
  42. dp_rx_mon_prepare_mon_mpdu(struct dp_pdev *pdev,
  43. qdf_nbuf_t head_msdu,
  44. qdf_nbuf_t tail_msdu)
  45. {
  46. struct dp_mon_mpdu *mon_mpdu = NULL;
  47. mon_mpdu = qdf_mem_malloc(sizeof(struct dp_mon_mpdu));
  48. if (!mon_mpdu) {
  49. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  50. FL("Monitor MPDU object allocation failed -- %pK"),
  51. pdev);
  52. qdf_assert_always(0);
  53. }
  54. mon_mpdu->head = head_msdu;
  55. mon_mpdu->tail = tail_msdu;
  56. mon_mpdu->rs_flags = pdev->ppdu_info.rx_status.rs_flags;
  57. mon_mpdu->ant_signal_db = pdev->ppdu_info.rx_status.ant_signal_db;
  58. mon_mpdu->is_stbc = pdev->ppdu_info.rx_status.is_stbc;
  59. mon_mpdu->sgi = pdev->ppdu_info.rx_status.sgi;
  60. mon_mpdu->beamformed = pdev->ppdu_info.rx_status.beamformed;
  61. return mon_mpdu;
  62. }
  63. /*
  64. * dp_rx_monitor_deliver_ppdu () - API to deliver all MPDU for a MPDU
  65. * to upper layer stack
  66. *
  67. * @soc: DP soc handle
  68. * @mac_id: lmac id
  69. */
  70. static inline QDF_STATUS
  71. dp_rx_monitor_deliver_ppdu(struct dp_soc *soc, uint32_t mac_id)
  72. {
  73. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  74. struct dp_mon_mpdu *mpdu = NULL;
  75. struct dp_mon_mpdu *temp_mpdu = NULL;
  76. if (!TAILQ_EMPTY(&pdev->mon_mpdu_q)) {
  77. TAILQ_FOREACH_SAFE(mpdu,
  78. &pdev->mon_mpdu_q,
  79. mpdu_list_elem,
  80. temp_mpdu) {
  81. TAILQ_REMOVE(&pdev->mon_mpdu_q,
  82. mpdu, mpdu_list_elem);
  83. pdev->ppdu_info.rx_status.rs_flags = mpdu->rs_flags;
  84. pdev->ppdu_info.rx_status.ant_signal_db =
  85. mpdu->ant_signal_db;
  86. pdev->ppdu_info.rx_status.is_stbc = mpdu->is_stbc;
  87. pdev->ppdu_info.rx_status.sgi = mpdu->sgi;
  88. pdev->ppdu_info.rx_status.beamformed = mpdu->beamformed;
  89. dp_rx_mon_deliver(soc, mac_id,
  90. mpdu->head, mpdu->tail);
  91. qdf_mem_free(mpdu);
  92. }
  93. }
  94. return QDF_STATUS_SUCCESS;
  95. }
  96. /**
  97. * dp_rx_mon_reap_status_ring () - Reap status_buf_count of status buffers for
  98. * status ring.
  99. *
  100. * @soc: DP soc handle
  101. * @mac_id: mac id on which interrupt is received
  102. * @quota: number of status ring entries to be reaped
  103. * @desc_info: Rx ppdu desc info
  104. */
  105. static inline uint32_t
  106. dp_rx_mon_reap_status_ring(struct dp_soc *soc,
  107. uint32_t mac_id,
  108. uint32_t quota,
  109. struct hal_rx_mon_desc_info *desc_info)
  110. {
  111. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  112. uint8_t status_buf_count;
  113. uint32_t work_done;
  114. status_buf_count = desc_info->status_buf_count;
  115. qdf_mem_copy(&pdev->mon_desc, desc_info,
  116. sizeof(struct hal_rx_mon_desc_info));
  117. work_done = dp_rx_mon_status_process(soc, mac_id, status_buf_count);
  118. if (desc_info->ppdu_id != pdev->ppdu_info.com_info.ppdu_id) {
  119. qdf_err("DEBUG: count: %d quota: %d", status_buf_count, quota);
  120. dp_print_ring_stats(pdev);
  121. qdf_assert_always(0);
  122. }
  123. /* DEBUG */
  124. if (work_done != status_buf_count) {
  125. qdf_err("Reaped status ring buffers are not equal to "
  126. "status buf count from destination ring work_done:"
  127. " %d status_buf_count: %d",
  128. work_done, status_buf_count);
  129. dp_print_ring_stats(pdev);
  130. qdf_assert_always(0);
  131. }
  132. return work_done;
  133. }
  134. /**
  135. * dp_rx_mon_mpdu_reap () - This API reaps a mpdu from mon dest ring descriptor
  136. * and returns link descriptor to HW (WBM)
  137. *
  138. * @soc: DP soc handle
  139. * @mac_id: lmac id
  140. * @ring_desc: SW monitor ring desc
  141. * @head_msdu: nbuf pointing to first msdu in a chain
  142. * @tail_msdu: nbuf pointing to last msdu in a chain
  143. * @head_desc: head pointer to free desc list
  144. * @tail_desc: tail pointer to free desc list
  145. *
  146. * Return: number of reaped buffers
  147. */
  148. static inline uint32_t
  149. dp_rx_mon_mpdu_reap(struct dp_soc *soc, uint32_t mac_id, void *ring_desc,
  150. qdf_nbuf_t *head_msdu, qdf_nbuf_t *tail_msdu,
  151. union dp_rx_desc_list_elem_t **head_desc,
  152. union dp_rx_desc_list_elem_t **tail_desc)
  153. {
  154. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  155. struct dp_rx_desc *rx_desc = NULL;
  156. struct hal_rx_msdu_list msdu_list;
  157. uint32_t rx_buf_reaped = 0;
  158. uint16_t num_msdus = 0, msdu_index, rx_hdr_tlv_len, l3_hdr_pad;
  159. uint32_t total_frag_len = 0, frag_len = 0;
  160. bool drop_mpdu = false;
  161. bool msdu_frag = false;
  162. void *link_desc_va;
  163. uint8_t *rx_tlv_hdr;
  164. qdf_nbuf_t msdu = NULL, last_msdu = NULL;
  165. uint32_t rx_link_buf_info[HAL_RX_BUFFINFO_NUM_DWORDS];
  166. struct hal_rx_mon_desc_info *desc_info;
  167. desc_info = pdev->mon_desc;
  168. qdf_mem_zero(desc_info, sizeof(struct hal_rx_mon_desc_info));
  169. /* Read SW Mon ring descriptor */
  170. hal_rx_sw_mon_desc_info_get((struct hal_soc *)soc->hal_soc,
  171. ring_desc,
  172. (void *)desc_info);
  173. /* If end_of_ppdu is 1, return*/
  174. if (desc_info->end_of_ppdu)
  175. return rx_buf_reaped;
  176. /* If there is rxdma error, drop mpdu */
  177. if (qdf_unlikely(dp_rx_mon_is_rxdma_error(desc_info)
  178. == QDF_STATUS_SUCCESS)) {
  179. drop_mpdu = true;
  180. pdev->rx_mon_stats.dest_mpdu_drop++;
  181. }
  182. /*
  183. * while loop iterates through all link descriptors and
  184. * reaps msdu_count number of msdus for one SW_MONITOR_RING descriptor
  185. * and forms nbuf queue.
  186. */
  187. while (desc_info->msdu_count && desc_info->link_desc.paddr) {
  188. link_desc_va = dp_rx_cookie_2_mon_link_desc(pdev,
  189. desc_info->link_desc,
  190. mac_id);
  191. qdf_assert_always(link_desc_va);
  192. hal_rx_msdu_list_get(soc->hal_soc,
  193. link_desc_va,
  194. &msdu_list,
  195. &num_msdus);
  196. for (msdu_index = 0; msdu_index < num_msdus; msdu_index++) {
  197. rx_desc = dp_rx_get_mon_desc(soc,
  198. msdu_list.sw_cookie[msdu_index]);
  199. qdf_assert_always(rx_desc);
  200. msdu = rx_desc->nbuf;
  201. if (rx_desc->unmapped == 0) {
  202. qdf_nbuf_unmap_single(soc->osdev,
  203. msdu,
  204. QDF_DMA_FROM_DEVICE);
  205. rx_desc->unmapped = 1;
  206. }
  207. if (drop_mpdu) {
  208. qdf_nbuf_free(msdu);
  209. msdu = NULL;
  210. desc_info->msdu_count--;
  211. goto next_msdu;
  212. }
  213. rx_tlv_hdr = qdf_nbuf_data(msdu);
  214. if (hal_rx_desc_is_first_msdu(soc->hal_soc,
  215. rx_tlv_hdr))
  216. hal_rx_mon_hw_desc_get_mpdu_status(soc->hal_soc,
  217. rx_tlv_hdr,
  218. &pdev->ppdu_info.rx_status);
  219. /** If msdu is fragmented, spread across multiple
  220. * buffers
  221. * a. calculate len of each fragmented buffer
  222. * b. calculate the number of fragmented buffers for
  223. * a msdu and decrement one msdu_count
  224. */
  225. if (msdu_list.msdu_info[msdu_index].msdu_flags
  226. & HAL_MSDU_F_MSDU_CONTINUATION) {
  227. if (!msdu_frag) {
  228. total_frag_len = msdu_list.msdu_info[msdu_index].msdu_len;
  229. msdu_frag = true;
  230. }
  231. dp_mon_adjust_frag_len(&total_frag_len,
  232. &frag_len);
  233. } else {
  234. if (msdu_frag)
  235. dp_mon_adjust_frag_len(&total_frag_len,
  236. &frag_len);
  237. else
  238. frag_len = msdu_list.msdu_info[msdu_index].msdu_len;
  239. msdu_frag = false;
  240. desc_info->msdu_count--;
  241. }
  242. rx_hdr_tlv_len = SIZE_OF_MONITOR_TLV;
  243. /*
  244. * HW structures call this L3 header padding.
  245. * this is actually the offset
  246. * from the buffer beginning where the L2
  247. * header begins.
  248. */
  249. l3_hdr_pad = hal_rx_msdu_end_l3_hdr_padding_get(
  250. soc->hal_soc,
  251. rx_tlv_hdr);
  252. /*******************************************************
  253. * RX_PACKET *
  254. * ----------------------------------------------------*
  255. | RX_PKT_TLVS | L3 Padding header | msdu data| |
  256. * ----------------------------------------------------*
  257. ******************************************************/
  258. qdf_nbuf_set_pktlen(msdu,
  259. rx_hdr_tlv_len +
  260. l3_hdr_pad +
  261. frag_len);
  262. if (head_msdu && !*head_msdu)
  263. *head_msdu = msdu;
  264. else if (last_msdu)
  265. qdf_nbuf_set_next(last_msdu, msdu);
  266. last_msdu = msdu;
  267. next_msdu:
  268. rx_buf_reaped++;
  269. dp_rx_add_to_free_desc_list(head_desc,
  270. tail_desc,
  271. rx_desc);
  272. QDF_TRACE(QDF_MODULE_ID_DP,
  273. QDF_TRACE_LEVEL_DEBUG,
  274. FL("%s total_len %u frag_len %u flags %u"),
  275. total_frag_len, frag_len,
  276. msdu_list.msdu_info[msdu_index].msdu_flags);
  277. }
  278. hal_rxdma_buff_addr_info_set(rx_link_buf_info,
  279. desc_info->link_desc.paddr,
  280. desc_info->link_desc.sw_cookie,
  281. desc_info->link_desc.rbm);
  282. /* Get next link desc VA from current link desc */
  283. hal_rx_mon_next_link_desc_get(link_desc_va,
  284. &desc_info->link_desc);
  285. /* return msdu link descriptor to WBM */
  286. if (dp_rx_monitor_link_desc_return(pdev,
  287. (hal_buff_addrinfo_t)rx_link_buf_info,
  288. mac_id,
  289. HAL_BM_ACTION_PUT_IN_IDLE_LIST)
  290. != QDF_STATUS_SUCCESS) {
  291. dp_print_ring_stats(pdev);
  292. qdf_assert_always(0);
  293. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  294. "dp_rx_monitor_link_desc_return failed");
  295. }
  296. }
  297. if (last_msdu)
  298. qdf_nbuf_set_next(last_msdu, NULL);
  299. *tail_msdu = msdu;
  300. return rx_buf_reaped;
  301. }
  302. /**
  303. * dp_rx_mon_process () - Core brain processing for monitor mode
  304. *
  305. * This API processes monitor destination ring followed by monitor status ring
  306. * Called from bottom half (tasklet/NET_RX_SOFTIRQ)
  307. *
  308. * @soc: datapath soc context
  309. * @mac_id: mac_id on which interrupt is received
  310. * @quota: Number of status ring entry that can be serviced in one shot.
  311. *
  312. * @Return: Number of reaped status ring entries
  313. */
  314. uint32_t dp_rx_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota)
  315. {
  316. struct dp_pdev *pdev = dp_get_pdev_for_lmac_id(soc, mac_id);
  317. union dp_rx_desc_list_elem_t *head_desc = NULL;
  318. union dp_rx_desc_list_elem_t *tail_desc = NULL;
  319. uint32_t rx_bufs_reaped = 0;
  320. struct dp_mon_mpdu *mon_mpdu;
  321. struct cdp_pdev_mon_stats *rx_mon_stats = &pdev->rx_mon_stats;
  322. hal_rxdma_desc_t ring_desc;
  323. hal_soc_handle_t hal_soc;
  324. hal_ring_handle_t mon_dest_srng;
  325. qdf_nbuf_t head_msdu = NULL;
  326. qdf_nbuf_t tail_msdu = NULL;
  327. struct hal_rx_mon_desc_info *desc_info;
  328. int mac_for_pdev = mac_id;
  329. QDF_STATUS status;
  330. if (qdf_unlikely(!dp_soc_is_full_mon_enable(pdev)))
  331. return quota;
  332. mon_dest_srng = dp_rxdma_get_mon_dst_ring(pdev, mac_for_pdev);
  333. if (qdf_unlikely(!mon_dest_srng ||
  334. !hal_srng_initialized(mon_dest_srng))) {
  335. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  336. FL("HAL Monitor Destination Ring Init Failed -- %pK"),
  337. mon_dest_srng);
  338. goto done;
  339. }
  340. hal_soc = soc->hal_soc;
  341. qdf_assert_always(hal_soc && pdev);
  342. qdf_spin_lock_bh(&pdev->mon_lock);
  343. desc_info = pdev->mon_desc;
  344. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_dest_srng))) {
  345. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  346. FL("HAL Monitor Destination Ring access Failed -- %pK"),
  347. mon_dest_srng);
  348. goto done1;
  349. }
  350. /* Each entry in mon dest ring carries mpdu data
  351. * reap all msdus for a mpdu and form skb chain
  352. */
  353. while (qdf_likely(ring_desc =
  354. hal_srng_dst_peek(hal_soc, mon_dest_srng))) {
  355. head_msdu = NULL;
  356. tail_msdu = NULL;
  357. rx_bufs_reaped = dp_rx_mon_mpdu_reap(soc, mac_id,
  358. ring_desc, &head_msdu,
  359. &tail_msdu, &head_desc,
  360. &tail_desc);
  361. /* Assert if end_of_ppdu is zero and number of reaped buffers
  362. * are zero.
  363. */
  364. if (qdf_unlikely(!desc_info->end_of_ppdu && !rx_bufs_reaped)) {
  365. dp_print_ring_stats(pdev);
  366. qdf_assert_always(0);
  367. }
  368. rx_mon_stats->mon_rx_bufs_reaped_dest += rx_bufs_reaped;
  369. /* replenish rx_bufs_reaped buffers back to
  370. * RxDMA Monitor buffer ring
  371. */
  372. if (rx_bufs_reaped) {
  373. status = dp_rx_buffers_replenish(soc, mac_id,
  374. dp_rxdma_get_mon_buf_ring(pdev,
  375. mac_for_pdev),
  376. dp_rx_get_mon_desc_pool(soc, mac_id,
  377. pdev->pdev_id),
  378. rx_bufs_reaped,
  379. &head_desc, &tail_desc);
  380. if (status != QDF_STATUS_SUCCESS)
  381. qdf_assert_always(0);
  382. rx_mon_stats->mon_rx_bufs_replenished_dest += rx_bufs_reaped;
  383. }
  384. head_desc = NULL;
  385. tail_desc = NULL;
  386. /* If end_of_ppdu is zero, it is a valid data mpdu
  387. * a. Add head_msdu and tail_msdu to mpdu list
  388. * b. continue reaping next SW_MONITOR_RING descriptor
  389. */
  390. if (!desc_info->end_of_ppdu) {
  391. /*
  392. * In case of rxdma error, MPDU is dropped
  393. * from sw_monitor_ring descriptor.
  394. * in this case, head_msdu remains NULL.
  395. * move srng to next and continue reaping next entry
  396. */
  397. if (!head_msdu) {
  398. ring_desc = hal_srng_dst_get_next(hal_soc,
  399. mon_dest_srng);
  400. continue;
  401. }
  402. /*
  403. * Prepare a MPDU object which holds chain of msdus
  404. * and MPDU specific status and add this is to
  405. * monitor mpdu queue
  406. */
  407. mon_mpdu = dp_rx_mon_prepare_mon_mpdu(pdev,
  408. head_msdu,
  409. tail_msdu);
  410. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  411. FL("Dest_srng: %pK MPDU_OBJ: %pK "
  412. "head_msdu: %pK tail_msdu: %pK -- "),
  413. mon_dest_srng,
  414. mon_mpdu,
  415. head_msdu,
  416. tail_msdu);
  417. TAILQ_INSERT_TAIL(&pdev->mon_mpdu_q,
  418. mon_mpdu,
  419. mpdu_list_elem);
  420. head_msdu = NULL;
  421. tail_msdu = NULL;
  422. ring_desc = hal_srng_dst_get_next(hal_soc,
  423. mon_dest_srng);
  424. continue;
  425. }
  426. /*
  427. * end_of_ppdu is one,
  428. * a. update ppdu_done stattistics
  429. * b. Replenish buffers back to mon buffer ring
  430. * c. reap status ring for a PPDU and deliver all mpdus
  431. * to upper layer
  432. */
  433. rx_mon_stats->dest_ppdu_done++;
  434. if (pdev->ppdu_info.com_info.ppdu_id !=
  435. pdev->mon_desc->ppdu_id) {
  436. pdev->rx_mon_stats.ppdu_id_mismatch++;
  437. qdf_err("PPDU id mismatch, status_ppdu_id: %d"
  438. "dest_ppdu_id: %d status_ppdu_done: %d "
  439. "dest_ppdu_done: %d ppdu_id_mismatch_cnt: %u"
  440. "dest_mpdu_drop: %u",
  441. pdev->ppdu_info.com_info.ppdu_id,
  442. pdev->mon_desc->ppdu_id,
  443. pdev->rx_mon_stats.status_ppdu_done,
  444. pdev->rx_mon_stats.dest_ppdu_done,
  445. pdev->rx_mon_stats.ppdu_id_mismatch,
  446. pdev->rx_mon_stats.dest_mpdu_drop);
  447. /* WAR: It is observed that in some cases, status ring ppdu_id
  448. * and destination ring ppdu_id doesn't match.
  449. * Following WAR is added to fix it.
  450. * a. If status ppdu_id is less than destination ppdu_id,
  451. * hold onto destination ring until ppdu_id matches
  452. * b. If status ppdu_id is greater than destination ring
  453. * ppdu_Id, move tp in destination ring.
  454. */
  455. if (pdev->ppdu_info.com_info.ppdu_id <
  456. pdev->mon_desc->ppdu_id) {
  457. break;
  458. } else {
  459. ring_desc = hal_srng_dst_get_next(hal_soc,
  460. mon_dest_srng);
  461. continue;
  462. }
  463. }
  464. /*
  465. * At this point, end_of_ppdu is one here,
  466. * When 'end_of_ppdu' is one, status buffer_count and
  467. * status_buf_addr must be valid.
  468. *
  469. * Assert if
  470. * a. status_buf_count is zero
  471. * b. status_buf.paddr is NULL
  472. */
  473. if (!pdev->mon_desc->status_buf_count ||
  474. !pdev->mon_desc->status_buf.paddr) {
  475. qdf_assert_always(0);
  476. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  477. FL("Status buffer info is NULL"
  478. "status_buf_count: %d"
  479. "status_buf_addr: %pK"
  480. "ring_desc: %pK-- "),
  481. pdev->mon_desc->status_buf_count,
  482. pdev->mon_desc->status_buf.paddr,
  483. ring_desc);
  484. goto done2;
  485. }
  486. /* Deliver all MPDUs for a PPDU */
  487. dp_rx_monitor_deliver_ppdu(soc, mac_id);
  488. hal_srng_dst_get_next(hal_soc, mon_dest_srng);
  489. break;
  490. }
  491. done2:
  492. hal_srng_access_end(hal_soc, mon_dest_srng);
  493. done1:
  494. qdf_spin_unlock_bh(&pdev->mon_lock);
  495. done:
  496. return quota;
  497. }
  498. /**
  499. * dp_full_mon_attach() - attach full monitor mode
  500. * resources
  501. * @pdev: Datapath PDEV handle
  502. *
  503. * Return: void
  504. */
  505. void dp_full_mon_attach(struct dp_pdev *pdev)
  506. {
  507. struct dp_soc *soc = pdev->soc;
  508. if (!soc->full_mon_mode) {
  509. qdf_debug("Full monitor is not enabled");
  510. return;
  511. }
  512. pdev->mon_desc = qdf_mem_malloc(sizeof(struct hal_rx_mon_desc_info));
  513. if (!pdev->mon_desc) {
  514. qdf_err("Memory allocation failed for hal_rx_mon_desc_info ");
  515. return;
  516. }
  517. TAILQ_INIT(&pdev->mon_mpdu_q);
  518. }
  519. /**
  520. * dp_full_mon_detach() - detach full monitor mode
  521. * resources
  522. * @pdev: Datapath PDEV handle
  523. *
  524. * Return: void
  525. *
  526. */
  527. void dp_full_mon_detach(struct dp_pdev *pdev)
  528. {
  529. struct dp_soc *soc = pdev->soc;
  530. struct dp_mon_mpdu *mpdu = NULL;
  531. struct dp_mon_mpdu *temp_mpdu = NULL;
  532. if (!soc->full_mon_mode) {
  533. qdf_debug("Full monitor is not enabled");
  534. return;
  535. }
  536. if (pdev->mon_desc)
  537. qdf_mem_free(pdev->mon_desc);
  538. if (!TAILQ_EMPTY(&pdev->mon_mpdu_q)) {
  539. TAILQ_FOREACH_SAFE(mpdu,
  540. &pdev->mon_mpdu_q,
  541. mpdu_list_elem,
  542. temp_mpdu) {
  543. qdf_mem_free(mpdu);
  544. }
  545. }
  546. }
  547. #endif