dp_rx_mon_status.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. * Copyright (c) 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 "hal_rx.h"
  22. #include "hal_api.h"
  23. #include "qdf_trace.h"
  24. #include "qdf_nbuf.h"
  25. #include "hal_api_mon.h"
  26. #include "linux/ieee80211.h"
  27. #include "dp_rx_mon.h"
  28. #include "dp_internal.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. /**
  31. * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
  32. * @soc: core txrx main context
  33. * @ppdu_info: ppdu info structure from ppdu ring
  34. * @ppdu_nbuf: qdf nbuf abstraction for linux skb
  35. *
  36. * Return: none
  37. */
  38. #ifdef FEATURE_PERPKT_INFO
  39. static inline void
  40. dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc,
  41. struct hal_rx_ppdu_info *ppdu_info,
  42. qdf_nbuf_t ppdu_nbuf)
  43. {
  44. struct dp_peer *peer;
  45. struct dp_ast_entry *ast_entry;
  46. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  47. uint32_t ast_index;
  48. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  49. ast_index = ppdu_info->rx_status.ast_index;
  50. if (ast_index > (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
  51. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  52. return;
  53. }
  54. ast_entry = soc->ast_table[ast_index];
  55. if (!ast_entry) {
  56. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  57. return;
  58. }
  59. peer = ast_entry->peer;
  60. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  61. cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
  62. return;
  63. }
  64. qdf_mem_copy(cdp_rx_ppdu->mac_addr,
  65. peer->mac_addr.raw, DP_MAC_ADDR_LEN);
  66. cdp_rx_ppdu->first_data_seq_ctrl =
  67. ppdu_info->rx_status.first_data_seq_ctrl;
  68. cdp_rx_ppdu->peer_id = peer->peer_ids[0];
  69. cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
  70. cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
  71. cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
  72. cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
  73. cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
  74. cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
  75. cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
  76. cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
  77. cdp_rx_ppdu->timestamp = ppdu_info->com_info.ppdu_timestamp;
  78. cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_freq;
  79. }
  80. #else
  81. static inline void
  82. dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc,
  83. struct hal_rx_ppdu_info *ppdu_info,
  84. qdf_nbuf_t ppdu_nbuf)
  85. {
  86. }
  87. #endif
  88. /**
  89. * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
  90. * @soc: core txrx main context
  91. * @pdev: pdev strcuture
  92. * @ppdu_info: structure for rx ppdu ring
  93. *
  94. * Return: none
  95. */
  96. #ifdef FEATURE_PERPKT_INFO
  97. static inline void
  98. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  99. struct hal_rx_ppdu_info *ppdu_info)
  100. {
  101. qdf_nbuf_t ppdu_nbuf;
  102. struct dp_peer *peer;
  103. struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
  104. ppdu_nbuf = qdf_nbuf_alloc(pdev->osif_pdev,
  105. sizeof(struct hal_rx_ppdu_info), 0, 0, FALSE);
  106. if (ppdu_nbuf) {
  107. dp_rx_populate_cdp_indication_ppdu(soc, ppdu_info, ppdu_nbuf);
  108. qdf_nbuf_put_tail(ppdu_nbuf,
  109. sizeof(struct cdp_rx_indication_ppdu));
  110. cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
  111. peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
  112. if (peer && cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
  113. dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
  114. ppdu_nbuf, cdp_rx_ppdu->peer_id,
  115. WDI_NO_VAL, pdev->pdev_id);
  116. } else
  117. qdf_nbuf_free(ppdu_nbuf);
  118. }
  119. }
  120. #else
  121. static inline void
  122. dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
  123. struct hal_rx_ppdu_info *ppdu_info)
  124. {
  125. }
  126. #endif
  127. /**
  128. * dp_rx_mon_status_process_tlv() - Process status TLV in status
  129. * buffer on Rx status Queue posted by status SRNG processing.
  130. * @soc: core txrx main context
  131. * @mac_id: mac_id which is one of 3 mac_ids _ring
  132. *
  133. * Return: none
  134. */
  135. static inline void
  136. dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
  137. uint32_t quota)
  138. {
  139. struct dp_pdev *pdev = soc->pdev_list[mac_id];
  140. struct hal_rx_ppdu_info *ppdu_info;
  141. qdf_nbuf_t status_nbuf;
  142. uint8_t *rx_tlv;
  143. uint8_t *rx_tlv_start;
  144. uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
  145. ppdu_info = &pdev->ppdu_info;
  146. if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
  147. return;
  148. while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
  149. status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
  150. rx_tlv = qdf_nbuf_data(status_nbuf);
  151. rx_tlv_start = rx_tlv;
  152. #if defined(CONFIG_WIN) && WDI_EVENT_ENABLE
  153. #ifndef REMOVE_PKT_LOG
  154. dp_wdi_event_handler(WDI_EVENT_RX_DESC, soc,
  155. status_nbuf, HTT_INVALID_PEER, WDI_NO_VAL, mac_id);
  156. #endif
  157. #endif
  158. if ((pdev->monitor_vdev != NULL) || (pdev->enhanced_stats_en)) {
  159. do {
  160. tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
  161. ppdu_info);
  162. rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
  163. if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
  164. break;
  165. } while (tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE);
  166. }
  167. qdf_nbuf_free(status_nbuf);
  168. if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
  169. if (pdev->enhanced_stats_en)
  170. dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
  171. pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
  172. dp_rx_mon_dest_process(soc, mac_id, quota);
  173. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  174. }
  175. }
  176. return;
  177. }
  178. /*
  179. * dp_rx_mon_status_srng_process() - Process monitor status ring
  180. * post the status ring buffer to Rx status Queue for later
  181. * processing when status ring is filled with status TLV.
  182. * Allocate a new buffer to status ring if the filled buffer
  183. * is posted.
  184. *
  185. * @soc: core txrx main context
  186. * @mac_id: mac_id which is one of 3 mac_ids
  187. * @quota: No. of ring entry that can be serviced in one shot.
  188. * Return: uint32_t: No. of ring entry that is processed.
  189. */
  190. static inline uint32_t
  191. dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
  192. uint32_t quota)
  193. {
  194. struct dp_pdev *pdev = soc->pdev_list[mac_id];
  195. void *hal_soc;
  196. void *mon_status_srng;
  197. void *rxdma_mon_status_ring_entry;
  198. QDF_STATUS status;
  199. uint32_t work_done = 0;
  200. mon_status_srng = pdev->rxdma_mon_status_ring.hal_srng;
  201. qdf_assert(mon_status_srng);
  202. if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
  203. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  204. "%s %d : HAL Monitor Destination Ring Init Failed -- %pK\n",
  205. __func__, __LINE__, mon_status_srng);
  206. return work_done;
  207. }
  208. hal_soc = soc->hal_soc;
  209. qdf_assert(hal_soc);
  210. if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
  211. goto done;
  212. /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
  213. * BUFFER_ADDR_INFO STRUCT
  214. */
  215. while (qdf_likely((rxdma_mon_status_ring_entry =
  216. hal_srng_src_peek(hal_soc, mon_status_srng))
  217. && quota--)) {
  218. uint32_t rx_buf_cookie;
  219. qdf_nbuf_t status_nbuf;
  220. struct dp_rx_desc *rx_desc;
  221. uint8_t *status_buf;
  222. qdf_dma_addr_t paddr;
  223. uint64_t buf_addr;
  224. buf_addr =
  225. (HAL_RX_BUFFER_ADDR_31_0_GET(
  226. rxdma_mon_status_ring_entry) |
  227. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
  228. rxdma_mon_status_ring_entry)) << 32));
  229. if (qdf_likely(buf_addr)) {
  230. rx_buf_cookie =
  231. HAL_RX_BUF_COOKIE_GET(
  232. rxdma_mon_status_ring_entry);
  233. rx_desc = dp_rx_cookie_2_va_mon_status(soc,
  234. rx_buf_cookie);
  235. qdf_assert(rx_desc);
  236. status_nbuf = rx_desc->nbuf;
  237. qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
  238. QDF_DMA_FROM_DEVICE);
  239. status_buf = qdf_nbuf_data(status_nbuf);
  240. status = hal_get_rx_status_done(status_buf);
  241. if (status != QDF_STATUS_SUCCESS) {
  242. QDF_TRACE(QDF_MODULE_ID_DP,
  243. QDF_TRACE_LEVEL_WARN,
  244. "[%s][%d] status not done",
  245. __func__, __LINE__);
  246. break;
  247. }
  248. qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
  249. qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
  250. QDF_DMA_FROM_DEVICE);
  251. /* Put the status_nbuf to queue */
  252. qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
  253. } else {
  254. union dp_rx_desc_list_elem_t *desc_list = NULL;
  255. union dp_rx_desc_list_elem_t *tail = NULL;
  256. struct rx_desc_pool *rx_desc_pool;
  257. uint32_t num_alloc_desc;
  258. rx_desc_pool = &soc->rx_desc_status[mac_id];
  259. num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
  260. rx_desc_pool,
  261. 1,
  262. &desc_list,
  263. &tail);
  264. rx_desc = &desc_list->rx_desc;
  265. }
  266. /* Allocate a new skb */
  267. status_nbuf = qdf_nbuf_alloc(pdev->osif_pdev, RX_BUFFER_SIZE,
  268. RX_BUFFER_RESERVATION, RX_BUFFER_ALIGNMENT, FALSE);
  269. status_buf = qdf_nbuf_data(status_nbuf);
  270. hal_clear_rx_status_done(status_buf);
  271. qdf_nbuf_map_single(soc->osdev, status_nbuf,
  272. QDF_DMA_BIDIRECTIONAL);
  273. paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
  274. rx_desc->nbuf = status_nbuf;
  275. rx_desc->in_use = 1;
  276. hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
  277. paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
  278. rxdma_mon_status_ring_entry =
  279. hal_srng_src_get_next(hal_soc, mon_status_srng);
  280. work_done++;
  281. }
  282. done:
  283. hal_srng_access_end(hal_soc, mon_status_srng);
  284. return work_done;
  285. }
  286. /*
  287. * dp_rx_mon_status_process() - Process monitor status ring and
  288. * TLV in status ring.
  289. *
  290. * @soc: core txrx main context
  291. * @mac_id: mac_id which is one of 3 mac_ids
  292. * @quota: No. of ring entry that can be serviced in one shot.
  293. * Return: uint32_t: No. of ring entry that is processed.
  294. */
  295. static inline uint32_t
  296. dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  297. uint32_t work_done;
  298. work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
  299. quota -= work_done;
  300. dp_rx_mon_status_process_tlv(soc, mac_id, quota);
  301. return work_done;
  302. }
  303. /**
  304. * dp_mon_process() - Main monitor mode processing roution.
  305. * This call monitor status ring process then monitor
  306. * destination ring process.
  307. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  308. * @soc: core txrx main context
  309. * @mac_id: mac_id which is one of 3 mac_ids
  310. * @quota: No. of status ring entry that can be serviced in one shot.
  311. * Return: uint32_t: No. of ring entry that is processed.
  312. */
  313. uint32_t
  314. dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
  315. return dp_rx_mon_status_process(soc, mac_id, quota);
  316. }
  317. /**
  318. * dp_rx_pdev_mon_detach() - detach dp rx for status ring
  319. * @pdev: core txrx pdev context
  320. *
  321. * This function will detach DP RX status ring from
  322. * main device context. will free DP Rx resources for
  323. * status ring
  324. *
  325. * Return: QDF_STATUS_SUCCESS: success
  326. * QDF_STATUS_E_RESOURCES: Error return
  327. */
  328. QDF_STATUS
  329. dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev)
  330. {
  331. uint8_t pdev_id = pdev->pdev_id;
  332. struct dp_soc *soc = pdev->soc;
  333. struct rx_desc_pool *rx_desc_pool;
  334. rx_desc_pool = &soc->rx_desc_status[pdev_id];
  335. if (rx_desc_pool->pool_size != 0) {
  336. dp_rx_desc_pool_free(soc, pdev_id, rx_desc_pool);
  337. }
  338. return QDF_STATUS_SUCCESS;
  339. }
  340. /*
  341. * dp_rx_buffers_replenish() - replenish monitor status ring with
  342. * rx nbufs called during dp rx
  343. * monitor status ring initialization
  344. *
  345. * @soc: core txrx main context
  346. * @mac_id: mac_id which is one of 3 mac_ids
  347. * @dp_rxdma_srng: dp monitor status circular ring
  348. * @rx_desc_pool; Pointer to Rx descriptor pool
  349. * @num_req_buffers: number of buffer to be replenished
  350. * @desc_list: list of descs if called from dp rx monitor status
  351. * process or NULL during dp rx initialization or
  352. * out of buffer interrupt
  353. * @tail: tail of descs list
  354. * @owner: who owns the nbuf (host, NSS etc...)
  355. * Return: return success or failure
  356. */
  357. static inline
  358. QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
  359. uint32_t mac_id,
  360. struct dp_srng *dp_rxdma_srng,
  361. struct rx_desc_pool *rx_desc_pool,
  362. uint32_t num_req_buffers,
  363. union dp_rx_desc_list_elem_t **desc_list,
  364. union dp_rx_desc_list_elem_t **tail,
  365. uint8_t owner)
  366. {
  367. uint32_t num_alloc_desc;
  368. uint16_t num_desc_to_free = 0;
  369. uint32_t num_entries_avail;
  370. uint32_t count;
  371. int sync_hw_ptr = 1;
  372. qdf_dma_addr_t paddr;
  373. qdf_nbuf_t rx_netbuf;
  374. void *rxdma_ring_entry;
  375. union dp_rx_desc_list_elem_t *next;
  376. void *rxdma_srng;
  377. uint8_t *status_buf;
  378. rxdma_srng = dp_rxdma_srng->hal_srng;
  379. qdf_assert(rxdma_srng);
  380. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  381. "[%s][%d] requested %d buffers for replenish\n",
  382. __func__, __LINE__, num_req_buffers);
  383. /*
  384. * if desc_list is NULL, allocate the descs from freelist
  385. */
  386. if (!(*desc_list)) {
  387. num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
  388. rx_desc_pool,
  389. num_req_buffers,
  390. desc_list,
  391. tail);
  392. if (!num_alloc_desc) {
  393. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  394. "[%s][%d] no free rx_descs in freelist\n",
  395. __func__, __LINE__);
  396. return QDF_STATUS_E_NOMEM;
  397. }
  398. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  399. "[%s][%d] %d rx desc allocated\n", __func__, __LINE__,
  400. num_alloc_desc);
  401. num_req_buffers = num_alloc_desc;
  402. }
  403. hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
  404. num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
  405. rxdma_srng, sync_hw_ptr);
  406. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  407. "[%s][%d] no of availble entries in rxdma ring: %d\n",
  408. __func__, __LINE__, num_entries_avail);
  409. if (num_entries_avail < num_req_buffers) {
  410. num_desc_to_free = num_req_buffers - num_entries_avail;
  411. num_req_buffers = num_entries_avail;
  412. }
  413. for (count = 0; count < num_req_buffers; count++) {
  414. rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
  415. rxdma_srng);
  416. rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
  417. RX_BUFFER_SIZE,
  418. RX_BUFFER_RESERVATION,
  419. RX_BUFFER_ALIGNMENT,
  420. FALSE);
  421. status_buf = qdf_nbuf_data(rx_netbuf);
  422. hal_clear_rx_status_done(status_buf);
  423. memset(status_buf, 0, RX_BUFFER_SIZE);
  424. qdf_nbuf_map_single(dp_soc->osdev, rx_netbuf,
  425. QDF_DMA_BIDIRECTIONAL);
  426. paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
  427. next = (*desc_list)->next;
  428. (*desc_list)->rx_desc.nbuf = rx_netbuf;
  429. (*desc_list)->rx_desc.in_use = 1;
  430. hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
  431. (*desc_list)->rx_desc.cookie, owner);
  432. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  433. "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
  434. status_buf=%pK paddr=%pK\n",
  435. __func__, __LINE__, &(*desc_list)->rx_desc,
  436. (*desc_list)->rx_desc.cookie, rx_netbuf,
  437. status_buf, (void *)paddr);
  438. *desc_list = next;
  439. }
  440. hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
  441. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  442. "successfully replenished %d buffers\n", num_req_buffers);
  443. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  444. "%d rx desc added back to free list\n", num_desc_to_free);
  445. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  446. "[%s][%d] desc_list=%pK, tail=%pK rx_desc=%pK, cookie=%d\n",
  447. __func__, __LINE__, desc_list, tail, &(*desc_list)->rx_desc,
  448. (*desc_list)->rx_desc.cookie);
  449. /*
  450. * add any available free desc back to the free list
  451. */
  452. if (*desc_list) {
  453. dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
  454. mac_id, rx_desc_pool);
  455. }
  456. return QDF_STATUS_SUCCESS;
  457. }
  458. /**
  459. * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
  460. * @pdev: core txrx pdev context
  461. *
  462. * This function will attach a DP RX monitor status ring into pDEV
  463. * and replenish monitor status ring with buffer.
  464. *
  465. * Return: QDF_STATUS_SUCCESS: success
  466. * QDF_STATUS_E_RESOURCES: Error return
  467. */
  468. QDF_STATUS
  469. dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev) {
  470. uint8_t pdev_id = pdev->pdev_id;
  471. struct dp_soc *soc = pdev->soc;
  472. union dp_rx_desc_list_elem_t *desc_list = NULL;
  473. union dp_rx_desc_list_elem_t *tail = NULL;
  474. struct dp_srng *rxdma_srng;
  475. uint32_t rxdma_entries;
  476. struct rx_desc_pool *rx_desc_pool;
  477. QDF_STATUS status;
  478. rxdma_srng = &pdev->rxdma_mon_status_ring;
  479. rxdma_entries = rxdma_srng->alloc_size/hal_srng_get_entrysize(
  480. soc->hal_soc, RXDMA_MONITOR_STATUS);
  481. rx_desc_pool = &soc->rx_desc_status[pdev_id];
  482. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
  483. "%s: Mon RX Status Pool[%d] allocation size=%d\n",
  484. __func__, pdev_id, rxdma_entries);
  485. status = dp_rx_desc_pool_alloc(soc, pdev_id, rxdma_entries+1,
  486. rx_desc_pool);
  487. if (!QDF_IS_STATUS_SUCCESS(status)) {
  488. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  489. "%s: dp_rx_desc_pool_alloc() failed \n", __func__);
  490. return status;
  491. }
  492. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
  493. "%s: Mon RX Status Buffers Replenish pdev_id=%d\n",
  494. __func__, pdev_id);
  495. status = dp_rx_mon_status_buffers_replenish(soc, pdev_id, rxdma_srng,
  496. rx_desc_pool, rxdma_entries, &desc_list, &tail,
  497. HAL_RX_BUF_RBM_SW3_BM);
  498. if (!QDF_IS_STATUS_SUCCESS(status)) {
  499. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  500. "%s: dp_rx_buffers_replenish() failed \n", __func__);
  501. return status;
  502. }
  503. qdf_nbuf_queue_init(&pdev->rx_status_q);
  504. pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
  505. qdf_mem_zero(&(pdev->ppdu_info.rx_status),
  506. sizeof(pdev->ppdu_info.rx_status));
  507. return QDF_STATUS_SUCCESS;
  508. }