blob: 719412d994cddcd7c50e7fb977a3aef8be7b1f64 [file] [log] [blame]
Kai Chen6eca1a62017-01-12 10:17:53 -08001/*
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"
Dustin Brown49a8f6e2017-08-17 15:47:48 -070026#include "linux/ieee80211.h"
Kai Chen6eca1a62017-01-12 10:17:53 -080027#include "dp_rx_mon.h"
Keyur Parekhfad6d082017-05-07 08:54:47 -070028#include "dp_internal.h"
29#include "qdf_mem.h" /* qdf_mem_malloc,free */
Kai Chen6eca1a62017-01-12 10:17:53 -080030
Kai Chen6eca1a62017-01-12 10:17:53 -080031/**
Anish Nataraj38a29562017-08-18 19:41:17 +053032* dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
33* @soc: core txrx main context
34* @ppdu_info: ppdu info structure from ppdu ring
35* @ppdu_nbuf: qdf nbuf abstraction for linux skb
36*
37* Return: none
38*/
39#ifdef FEATURE_PERPKT_INFO
40static inline void
41dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc,
42 struct hal_rx_ppdu_info *ppdu_info,
43 qdf_nbuf_t ppdu_nbuf)
44{
45 struct dp_peer *peer;
46 struct dp_ast_entry *ast_entry;
47 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
48 uint32_t ast_index;
49
50 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
51
52 ast_index = ppdu_info->rx_status.ast_index;
53 if (ast_index > (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
54 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
55 return;
56 }
57
58 ast_entry = soc->ast_table[ast_index];
59 if (!ast_entry) {
60 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
61 return;
62 }
63 peer = ast_entry->peer;
64 if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
65 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
66 return;
67 }
68
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053069 qdf_mem_copy(cdp_rx_ppdu->mac_addr,
70 peer->mac_addr.raw, DP_MAC_ADDR_LEN);
71 cdp_rx_ppdu->first_data_seq_ctrl =
72 ppdu_info->rx_status.first_data_seq_ctrl;
Anish Nataraj38a29562017-08-18 19:41:17 +053073 cdp_rx_ppdu->peer_id = peer->peer_ids[0];
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053074 cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
Anish Nataraj38a29562017-08-18 19:41:17 +053075 cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
76 cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
77 cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
78 cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
79 cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
80 cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
81 cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
82 cdp_rx_ppdu->timestamp = ppdu_info->com_info.ppdu_timestamp;
83 cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_freq;
Anish Nataraj38a29562017-08-18 19:41:17 +053084}
85#else
86static inline void
87dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc,
88 struct hal_rx_ppdu_info *ppdu_info,
89 qdf_nbuf_t ppdu_nbuf)
90{
91}
92#endif
93
94/**
95* dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
96* @soc: core txrx main context
97* @pdev: pdev strcuture
98* @ppdu_info: structure for rx ppdu ring
99*
100* Return: none
101*/
102#ifdef FEATURE_PERPKT_INFO
103static inline void
104dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
105 struct hal_rx_ppdu_info *ppdu_info)
106{
107 qdf_nbuf_t ppdu_nbuf;
108 struct dp_peer *peer;
109 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
110
111 ppdu_nbuf = qdf_nbuf_alloc(pdev->osif_pdev,
112 sizeof(struct hal_rx_ppdu_info), 0, 0, FALSE);
113 if (ppdu_nbuf) {
114 dp_rx_populate_cdp_indication_ppdu(soc, ppdu_info, ppdu_nbuf);
115 qdf_nbuf_put_tail(ppdu_nbuf,
116 sizeof(struct cdp_rx_indication_ppdu));
117 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
118
119 peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
120 if (peer && cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
121 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
122 ppdu_nbuf, cdp_rx_ppdu->peer_id,
123 WDI_NO_VAL, pdev->pdev_id);
124 } else
125 qdf_nbuf_free(ppdu_nbuf);
126 }
127}
128#else
129static inline void
130dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
131 struct hal_rx_ppdu_info *ppdu_info)
132{
133}
134#endif
135
136/**
Kai Chen6eca1a62017-01-12 10:17:53 -0800137* dp_rx_mon_status_process_tlv() - Process status TLV in status
138* buffer on Rx status Queue posted by status SRNG processing.
139* @soc: core txrx main context
140* @mac_id: mac_id which is one of 3 mac_ids _ring
141*
142* Return: none
143*/
144static inline void
Karunakar Dasineni40555682017-03-26 22:44:39 -0700145dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
146 uint32_t quota)
147{
Kai Chen6eca1a62017-01-12 10:17:53 -0800148 struct dp_pdev *pdev = soc->pdev_list[mac_id];
149 struct hal_rx_ppdu_info *ppdu_info;
150 qdf_nbuf_t status_nbuf;
151 uint8_t *rx_tlv;
152 uint8_t *rx_tlv_start;
Kai Chenad516ae2017-09-08 18:35:47 -0700153 uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
Kai Chen6eca1a62017-01-12 10:17:53 -0800154
Kai Chen6eca1a62017-01-12 10:17:53 -0800155 ppdu_info = &pdev->ppdu_info;
156
157 if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
158 return;
159
160 while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
161
162 status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
163 rx_tlv = qdf_nbuf_data(status_nbuf);
164 rx_tlv_start = rx_tlv;
165
Keyur Parekhfad6d082017-05-07 08:54:47 -0700166#if defined(CONFIG_WIN) && WDI_EVENT_ENABLE
167#ifndef REMOVE_PKT_LOG
168 dp_wdi_event_handler(WDI_EVENT_RX_DESC, soc,
Keyur Parekhdb0fa142017-07-13 19:40:22 -0700169 status_nbuf, HTT_INVALID_PEER, WDI_NO_VAL, mac_id);
Keyur Parekhfad6d082017-05-07 08:54:47 -0700170#endif
171#endif
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +0530172 if ((pdev->monitor_vdev != NULL) || (pdev->enhanced_stats_en)) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800173
Keyur Parekhfad6d082017-05-07 08:54:47 -0700174 do {
175 tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
176 ppdu_info);
177 rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
Kai Chen6eca1a62017-01-12 10:17:53 -0800178
Keyur Parekhfad6d082017-05-07 08:54:47 -0700179 if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
180 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800181
Keyur Parekhfad6d082017-05-07 08:54:47 -0700182 } while (tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE);
183 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800184 qdf_nbuf_free(status_nbuf);
185
186 if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
Anish Nataraj38a29562017-08-18 19:41:17 +0530187 if (pdev->enhanced_stats_en)
188 dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
Kai Chen6eca1a62017-01-12 10:17:53 -0800189 pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
Karunakar Dasineni40555682017-03-26 22:44:39 -0700190 dp_rx_mon_dest_process(soc, mac_id, quota);
Kai Chencbe4c342017-06-12 20:06:35 -0700191 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Kai Chen6eca1a62017-01-12 10:17:53 -0800192 }
193 }
194 return;
195}
196
197/*
198 * dp_rx_mon_status_srng_process() - Process monitor status ring
199 * post the status ring buffer to Rx status Queue for later
200 * processing when status ring is filled with status TLV.
201 * Allocate a new buffer to status ring if the filled buffer
202 * is posted.
203 *
204 * @soc: core txrx main context
205 * @mac_id: mac_id which is one of 3 mac_ids
206 * @quota: No. of ring entry that can be serviced in one shot.
207
208 * Return: uint32_t: No. of ring entry that is processed.
209 */
210static inline uint32_t
211dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
212 uint32_t quota)
213{
214 struct dp_pdev *pdev = soc->pdev_list[mac_id];
215 void *hal_soc;
216 void *mon_status_srng;
217 void *rxdma_mon_status_ring_entry;
218 QDF_STATUS status;
219 uint32_t work_done = 0;
220
Kai Chen6eca1a62017-01-12 10:17:53 -0800221 mon_status_srng = pdev->rxdma_mon_status_ring.hal_srng;
222
223 qdf_assert(mon_status_srng);
Houston Hoffman648a9182017-05-21 23:27:50 -0700224 if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
225
226 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700227 "%s %d : HAL Monitor Destination Ring Init Failed -- %pK\n",
Houston Hoffman648a9182017-05-21 23:27:50 -0700228 __func__, __LINE__, mon_status_srng);
229 return work_done;
230 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800231
232 hal_soc = soc->hal_soc;
233
234 qdf_assert(hal_soc);
235
236 if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
237 goto done;
238
239 /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
240 * BUFFER_ADDR_INFO STRUCT
241 */
242 while (qdf_likely((rxdma_mon_status_ring_entry =
243 hal_srng_src_peek(hal_soc, mon_status_srng))
244 && quota--)) {
245 uint32_t rx_buf_cookie;
246 qdf_nbuf_t status_nbuf;
247 struct dp_rx_desc *rx_desc;
248 uint8_t *status_buf;
249 qdf_dma_addr_t paddr;
250 uint64_t buf_addr;
251
252 buf_addr =
253 (HAL_RX_BUFFER_ADDR_31_0_GET(
254 rxdma_mon_status_ring_entry) |
255 ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
256 rxdma_mon_status_ring_entry)) << 32));
257
258 if (qdf_likely(buf_addr)) {
259
260 rx_buf_cookie =
261 HAL_RX_BUF_COOKIE_GET(
262 rxdma_mon_status_ring_entry);
263 rx_desc = dp_rx_cookie_2_va_mon_status(soc,
264 rx_buf_cookie);
265
266 qdf_assert(rx_desc);
267
268 status_nbuf = rx_desc->nbuf;
269
270 qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
271 QDF_DMA_FROM_DEVICE);
272
273 status_buf = qdf_nbuf_data(status_nbuf);
274
275 status = hal_get_rx_status_done(status_buf);
276
277 if (status != QDF_STATUS_SUCCESS) {
278 QDF_TRACE(QDF_MODULE_ID_DP,
279 QDF_TRACE_LEVEL_WARN,
280 "[%s][%d] status not done",
281 __func__, __LINE__);
282 break;
283 }
284 qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
285
286 qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
287 QDF_DMA_FROM_DEVICE);
288
289 /* Put the status_nbuf to queue */
290 qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
291
292 } else {
293 union dp_rx_desc_list_elem_t *desc_list = NULL;
294 union dp_rx_desc_list_elem_t *tail = NULL;
295 struct rx_desc_pool *rx_desc_pool;
296 uint32_t num_alloc_desc;
297
298 rx_desc_pool = &soc->rx_desc_status[mac_id];
299
300 num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
301 rx_desc_pool,
302 1,
303 &desc_list,
304 &tail);
305
306 rx_desc = &desc_list->rx_desc;
307 }
308
309 /* Allocate a new skb */
310 status_nbuf = qdf_nbuf_alloc(pdev->osif_pdev, RX_BUFFER_SIZE,
311 RX_BUFFER_RESERVATION, RX_BUFFER_ALIGNMENT, FALSE);
312
313 status_buf = qdf_nbuf_data(status_nbuf);
314
315 hal_clear_rx_status_done(status_buf);
316
317 qdf_nbuf_map_single(soc->osdev, status_nbuf,
318 QDF_DMA_BIDIRECTIONAL);
319 paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
320
321 rx_desc->nbuf = status_nbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700322 rx_desc->in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800323
324 hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
325 paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
326
327 rxdma_mon_status_ring_entry =
328 hal_srng_src_get_next(hal_soc, mon_status_srng);
329 work_done++;
330 }
331done:
332
333 hal_srng_access_end(hal_soc, mon_status_srng);
334
335 return work_done;
336
337}
338/*
339 * dp_rx_mon_status_process() - Process monitor status ring and
340 * TLV in status ring.
341 *
342 * @soc: core txrx main context
343 * @mac_id: mac_id which is one of 3 mac_ids
344 * @quota: No. of ring entry that can be serviced in one shot.
345
346 * Return: uint32_t: No. of ring entry that is processed.
347 */
348static inline uint32_t
349dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
350 uint32_t work_done;
351
352 work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
Karunakar Dasineni40555682017-03-26 22:44:39 -0700353 quota -= work_done;
354 dp_rx_mon_status_process_tlv(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800355
356 return work_done;
357}
358/**
359 * dp_mon_process() - Main monitor mode processing roution.
360 * This call monitor status ring process then monitor
361 * destination ring process.
362 * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
363 * @soc: core txrx main context
364 * @mac_id: mac_id which is one of 3 mac_ids
365 * @quota: No. of status ring entry that can be serviced in one shot.
366
367 * Return: uint32_t: No. of ring entry that is processed.
368 */
369uint32_t
370dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
Karunakar Dasineni40555682017-03-26 22:44:39 -0700371 return dp_rx_mon_status_process(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800372}
Karunakar Dasineni40555682017-03-26 22:44:39 -0700373
Kai Chen6eca1a62017-01-12 10:17:53 -0800374/**
375 * dp_rx_pdev_mon_detach() - detach dp rx for status ring
376 * @pdev: core txrx pdev context
377 *
378 * This function will detach DP RX status ring from
379 * main device context. will free DP Rx resources for
380 * status ring
381 *
382 * Return: QDF_STATUS_SUCCESS: success
383 * QDF_STATUS_E_RESOURCES: Error return
384 */
385QDF_STATUS
386dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev)
387{
388 uint8_t pdev_id = pdev->pdev_id;
389 struct dp_soc *soc = pdev->soc;
390 struct rx_desc_pool *rx_desc_pool;
391
392 rx_desc_pool = &soc->rx_desc_status[pdev_id];
psimhaeae1b412017-08-25 16:10:13 -0700393 if (rx_desc_pool->pool_size != 0) {
394 dp_rx_desc_pool_free(soc, pdev_id, rx_desc_pool);
395 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800396
397 return QDF_STATUS_SUCCESS;
398}
399
400/*
401 * dp_rx_buffers_replenish() - replenish monitor status ring with
402 * rx nbufs called during dp rx
403 * monitor status ring initialization
404 *
405 * @soc: core txrx main context
406 * @mac_id: mac_id which is one of 3 mac_ids
407 * @dp_rxdma_srng: dp monitor status circular ring
408 * @rx_desc_pool; Pointer to Rx descriptor pool
409 * @num_req_buffers: number of buffer to be replenished
410 * @desc_list: list of descs if called from dp rx monitor status
411 * process or NULL during dp rx initialization or
412 * out of buffer interrupt
413 * @tail: tail of descs list
414 * @owner: who owns the nbuf (host, NSS etc...)
415 * Return: return success or failure
416 */
417static inline
418QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
419 uint32_t mac_id,
420 struct dp_srng *dp_rxdma_srng,
421 struct rx_desc_pool *rx_desc_pool,
422 uint32_t num_req_buffers,
423 union dp_rx_desc_list_elem_t **desc_list,
424 union dp_rx_desc_list_elem_t **tail,
425 uint8_t owner)
426{
427 uint32_t num_alloc_desc;
428 uint16_t num_desc_to_free = 0;
429 uint32_t num_entries_avail;
430 uint32_t count;
431 int sync_hw_ptr = 1;
432 qdf_dma_addr_t paddr;
433 qdf_nbuf_t rx_netbuf;
434 void *rxdma_ring_entry;
435 union dp_rx_desc_list_elem_t *next;
436 void *rxdma_srng;
437 uint8_t *status_buf;
438
439 rxdma_srng = dp_rxdma_srng->hal_srng;
440
441 qdf_assert(rxdma_srng);
442
Houston Hoffmanae850c62017-08-11 16:47:50 -0700443 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800444 "[%s][%d] requested %d buffers for replenish\n",
445 __func__, __LINE__, num_req_buffers);
446
447 /*
448 * if desc_list is NULL, allocate the descs from freelist
449 */
450 if (!(*desc_list)) {
451
452 num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
453 rx_desc_pool,
454 num_req_buffers,
455 desc_list,
456 tail);
457
458 if (!num_alloc_desc) {
459 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
460 "[%s][%d] no free rx_descs in freelist\n",
461 __func__, __LINE__);
462 return QDF_STATUS_E_NOMEM;
463 }
464
Houston Hoffmanae850c62017-08-11 16:47:50 -0700465 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800466 "[%s][%d] %d rx desc allocated\n", __func__, __LINE__,
467 num_alloc_desc);
Houston Hoffmanae850c62017-08-11 16:47:50 -0700468
Kai Chen6eca1a62017-01-12 10:17:53 -0800469 num_req_buffers = num_alloc_desc;
470 }
471
472 hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
473 num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
474 rxdma_srng, sync_hw_ptr);
475
Houston Hoffmanae850c62017-08-11 16:47:50 -0700476 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800477 "[%s][%d] no of availble entries in rxdma ring: %d\n",
478 __func__, __LINE__, num_entries_avail);
479
480 if (num_entries_avail < num_req_buffers) {
481 num_desc_to_free = num_req_buffers - num_entries_avail;
482 num_req_buffers = num_entries_avail;
483 }
484
485 for (count = 0; count < num_req_buffers; count++) {
486 rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
487 rxdma_srng);
488
489 rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev,
490 RX_BUFFER_SIZE,
491 RX_BUFFER_RESERVATION,
492 RX_BUFFER_ALIGNMENT,
493 FALSE);
494
495 status_buf = qdf_nbuf_data(rx_netbuf);
496 hal_clear_rx_status_done(status_buf);
497
498 memset(status_buf, 0, RX_BUFFER_SIZE);
499
500 qdf_nbuf_map_single(dp_soc->osdev, rx_netbuf,
501 QDF_DMA_BIDIRECTIONAL);
502
503 paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
504
505 next = (*desc_list)->next;
506
507 (*desc_list)->rx_desc.nbuf = rx_netbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700508 (*desc_list)->rx_desc.in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800509 hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
510 (*desc_list)->rx_desc.cookie, owner);
511
Karunakar Dasineni40555682017-03-26 22:44:39 -0700512 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700513 "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
514 status_buf=%pK paddr=%pK\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800515 __func__, __LINE__, &(*desc_list)->rx_desc,
516 (*desc_list)->rx_desc.cookie, rx_netbuf,
517 status_buf, (void *)paddr);
518
519 *desc_list = next;
520 }
521
522 hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
523
Houston Hoffmanae850c62017-08-11 16:47:50 -0700524 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800525 "successfully replenished %d buffers\n", num_req_buffers);
526
Houston Hoffmanae850c62017-08-11 16:47:50 -0700527 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800528 "%d rx desc added back to free list\n", num_desc_to_free);
529
Houston Hoffmanae850c62017-08-11 16:47:50 -0700530 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700531 "[%s][%d] desc_list=%pK, tail=%pK rx_desc=%pK, cookie=%d\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800532 __func__, __LINE__, desc_list, tail, &(*desc_list)->rx_desc,
533 (*desc_list)->rx_desc.cookie);
534
535 /*
536 * add any available free desc back to the free list
537 */
538 if (*desc_list) {
539 dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
540 mac_id, rx_desc_pool);
541 }
542
543 return QDF_STATUS_SUCCESS;
544}
545/**
546 * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
547 * @pdev: core txrx pdev context
548 *
549 * This function will attach a DP RX monitor status ring into pDEV
550 * and replenish monitor status ring with buffer.
551 *
552 * Return: QDF_STATUS_SUCCESS: success
553 * QDF_STATUS_E_RESOURCES: Error return
554 */
555QDF_STATUS
556dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev) {
557 uint8_t pdev_id = pdev->pdev_id;
558 struct dp_soc *soc = pdev->soc;
559 union dp_rx_desc_list_elem_t *desc_list = NULL;
560 union dp_rx_desc_list_elem_t *tail = NULL;
561 struct dp_srng *rxdma_srng;
562 uint32_t rxdma_entries;
563 struct rx_desc_pool *rx_desc_pool;
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700564 QDF_STATUS status;
Kai Chen6eca1a62017-01-12 10:17:53 -0800565
566 rxdma_srng = &pdev->rxdma_mon_status_ring;
567
568 rxdma_entries = rxdma_srng->alloc_size/hal_srng_get_entrysize(
569 soc->hal_soc, RXDMA_MONITOR_STATUS);
570
571 rx_desc_pool = &soc->rx_desc_status[pdev_id];
572
573 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
574 "%s: Mon RX Status Pool[%d] allocation size=%d\n",
575 __func__, pdev_id, rxdma_entries);
576
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700577 status = dp_rx_desc_pool_alloc(soc, pdev_id, rxdma_entries+1,
578 rx_desc_pool);
Ravi Joshi73a05512017-07-10 13:53:32 -0700579 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700580 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
581 "%s: dp_rx_desc_pool_alloc() failed \n", __func__);
582 return status;
583 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800584
585 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
586 "%s: Mon RX Status Buffers Replenish pdev_id=%d\n",
587 __func__, pdev_id);
588
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700589 status = dp_rx_mon_status_buffers_replenish(soc, pdev_id, rxdma_srng,
590 rx_desc_pool, rxdma_entries, &desc_list, &tail,
591 HAL_RX_BUF_RBM_SW3_BM);
Ravi Joshi73a05512017-07-10 13:53:32 -0700592 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700593 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
594 "%s: dp_rx_buffers_replenish() failed \n", __func__);
595 return status;
596 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800597
598 qdf_nbuf_queue_init(&pdev->rx_status_q);
599
600 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni40555682017-03-26 22:44:39 -0700601 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
602 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -0800603
604 return QDF_STATUS_SUCCESS;
605}