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