Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 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 | |
| 19 | #include <qdf_types.h> |
| 20 | #include <qdf_lock.h> |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 21 | #include <qdf_net_types.h> |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 22 | #include <hal_api.h> |
| 23 | #include <hif.h> |
| 24 | #include <htt.h> |
| 25 | #include <wdi_event.h> |
| 26 | #include <queue.h> |
| 27 | #include "dp_htt.h" |
| 28 | #include "dp_types.h" |
| 29 | #include "dp_internal.h" |
Vijay Pamidipati | d41d6d6 | 2016-10-19 21:19:00 +0530 | [diff] [blame] | 30 | #include "dp_tx.h" |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 31 | #include "dp_rx.h" |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 32 | #include <cdp_txrx_handle.h> |
Ravi Joshi | af9ace8 | 2017-02-17 12:41:48 -0800 | [diff] [blame] | 33 | #include <wlan_cfg.h> |
Ishank Jain | bc2d91f | 2017-01-03 18:14:54 +0530 | [diff] [blame] | 34 | #include "cdp_txrx_cmn_struct.h" |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 35 | #include <qdf_util.h> |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 36 | #include "dp_peer.h" |
Ravi Joshi | af9ace8 | 2017-02-17 12:41:48 -0800 | [diff] [blame] | 37 | |
Ravi Joshi | 05d9e67 | 2016-11-22 17:31:46 -0800 | [diff] [blame] | 38 | #define DP_INTR_POLL_TIMER_MS 100 |
Ishank Jain | bc2d91f | 2017-01-03 18:14:54 +0530 | [diff] [blame] | 39 | #define DP_MCS_LENGTH (6*MAX_MCS) |
| 40 | #define DP_NSS_LENGTH (6*SS_COUNT) |
| 41 | #define DP_RXDMA_ERR_LENGTH (6*MAX_RXDMA_ERRORS) |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 42 | #define DP_REO_ERR_LENGTH (6*REO_ERROR_TYPE_MAX) |
Ishank Jain | 949674c | 2017-02-27 17:09:29 +0530 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * default_dscp_tid_map - Default DSCP-TID mapping |
| 46 | * |
| 47 | * DSCP TID AC |
| 48 | * 000000 0 WME_AC_BE |
| 49 | * 001000 1 WME_AC_BK |
| 50 | * 010000 1 WME_AC_BK |
| 51 | * 011000 0 WME_AC_BE |
| 52 | * 100000 5 WME_AC_VI |
| 53 | * 101000 5 WME_AC_VI |
| 54 | * 110000 6 WME_AC_VO |
| 55 | * 111000 6 WME_AC_VO |
| 56 | */ |
| 57 | static uint8_t default_dscp_tid_map[DSCP_TID_MAP_MAX] = { |
| 58 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 59 | 1, 1, 1, 1, 1, 1, 1, 1, |
| 60 | 1, 1, 1, 1, 1, 1, 1, 1, |
| 61 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 62 | 5, 5, 5, 5, 5, 5, 5, 5, |
| 63 | 5, 5, 5, 5, 5, 5, 5, 5, |
| 64 | 6, 6, 6, 6, 6, 6, 6, 6, |
| 65 | 6, 6, 6, 6, 6, 6, 6, 6, |
| 66 | }; |
| 67 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 68 | /** |
Venkata Sharath Chandra Manchala | a77da0d | 2017-02-27 22:44:37 -0800 | [diff] [blame^] | 69 | * @brief Select the type of statistics |
| 70 | */ |
| 71 | enum dp_stats_type { |
| 72 | STATS_FW = 0, |
| 73 | STATS_HOST = 1, |
| 74 | STATS_TYPE_MAX = 2, |
| 75 | }; |
| 76 | |
| 77 | /** |
| 78 | * @brief General Firmware statistics options |
| 79 | * |
| 80 | */ |
| 81 | enum dp_fw_stats { |
| 82 | TXRX_FW_STATS_INVALID = -1, |
| 83 | }; |
| 84 | |
| 85 | /** |
| 86 | * @brief Firmware and Host statistics |
| 87 | * currently supported |
| 88 | */ |
| 89 | const int dp_stats_mapping_table[][STATS_TYPE_MAX] = { |
| 90 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 91 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 92 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 93 | {TXRX_FW_STATS_INVALID, TXRX_RX_RATE_STATS}, |
| 94 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 95 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 96 | {TXRX_FW_STATS_INVALID, TXRX_TX_RATE_STATS}, |
| 97 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 98 | {TXRX_FW_STATS_INVALID, TXRX_TX_HOST_STATS}, |
| 99 | {TXRX_FW_STATS_INVALID, TXRX_CLEAR_STATS}, |
| 100 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 101 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 102 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 103 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 104 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 105 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 106 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 107 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 108 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 109 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 110 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 111 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 112 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 113 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 114 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 115 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 116 | {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID}, |
| 117 | {TXRX_FW_STATS_INVALID, TXRX_RX_HOST_STATS}, |
| 118 | }; |
| 119 | |
| 120 | /** |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 121 | * dp_setup_srng - Internal function to setup SRNG rings used by data path |
| 122 | */ |
| 123 | static int dp_srng_setup(struct dp_soc *soc, struct dp_srng *srng, |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 124 | int ring_type, int ring_num, int mac_id, uint32_t num_entries) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 125 | { |
| 126 | void *hal_soc = soc->hal_soc; |
| 127 | uint32_t entry_size = hal_srng_get_entrysize(hal_soc, ring_type); |
| 128 | /* TODO: See if we should get align size from hal */ |
| 129 | uint32_t ring_base_align = 8; |
| 130 | struct hal_srng_params ring_params; |
Karunakar Dasineni | d0ea21f | 2017-01-31 22:58:15 -0800 | [diff] [blame] | 131 | uint32_t max_entries = hal_srng_max_entries(hal_soc, ring_type); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 132 | |
Karunakar Dasineni | d0ea21f | 2017-01-31 22:58:15 -0800 | [diff] [blame] | 133 | num_entries = (num_entries > max_entries) ? max_entries : num_entries; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 134 | srng->hal_srng = NULL; |
| 135 | srng->alloc_size = (num_entries * entry_size) + ring_base_align - 1; |
| 136 | srng->base_vaddr_unaligned = qdf_mem_alloc_consistent( |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 137 | soc->osdev, soc->osdev->dev, srng->alloc_size, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 138 | &(srng->base_paddr_unaligned)); |
| 139 | |
| 140 | if (!srng->base_vaddr_unaligned) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 141 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 142 | FL("alloc failed - ring_type: %d, ring_num %d"), |
| 143 | ring_type, ring_num); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 144 | return QDF_STATUS_E_NOMEM; |
| 145 | } |
| 146 | |
| 147 | ring_params.ring_base_vaddr = srng->base_vaddr_unaligned + |
| 148 | ((unsigned long)srng->base_vaddr_unaligned % ring_base_align); |
| 149 | ring_params.ring_base_paddr = srng->base_paddr_unaligned + |
| 150 | ((unsigned long)(ring_params.ring_base_vaddr) - |
| 151 | (unsigned long)srng->base_vaddr_unaligned); |
| 152 | ring_params.num_entries = num_entries; |
| 153 | |
| 154 | /* TODO: Check MSI support and get MSI settings from HIF layer */ |
| 155 | ring_params.msi_data = 0; |
| 156 | ring_params.msi_addr = 0; |
| 157 | |
| 158 | /* TODO: Setup interrupt timer and batch counter thresholds for |
| 159 | * interrupt mitigation based on ring type |
| 160 | */ |
| 161 | ring_params.intr_timer_thres_us = 8; |
| 162 | ring_params.intr_batch_cntr_thres_entries = 1; |
| 163 | |
| 164 | /* TODO: Currently hal layer takes care of endianness related settings. |
| 165 | * See if these settings need to passed from DP layer |
| 166 | */ |
| 167 | ring_params.flags = 0; |
| 168 | |
| 169 | /* Enable low threshold interrupts for rx buffer rings (regular and |
| 170 | * monitor buffer rings. |
| 171 | * TODO: See if this is required for any other ring |
| 172 | */ |
| 173 | if ((ring_type == RXDMA_BUF) || (ring_type == RXDMA_MONITOR_BUF)) { |
| 174 | /* TODO: Setting low threshold to 1/8th of ring size |
| 175 | * see if this needs to be configurable |
| 176 | */ |
| 177 | ring_params.low_threshold = num_entries >> 3; |
| 178 | ring_params.flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE; |
| 179 | } |
| 180 | |
| 181 | srng->hal_srng = hal_srng_setup(hal_soc, ring_type, ring_num, |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 182 | mac_id, &ring_params); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * dp_srng_cleanup - Internal function to cleanup SRNG rings used by data path |
| 188 | * Any buffers allocated and attached to ring entries are expected to be freed |
| 189 | * before calling this function. |
| 190 | */ |
| 191 | static void dp_srng_cleanup(struct dp_soc *soc, struct dp_srng *srng, |
| 192 | int ring_type, int ring_num) |
| 193 | { |
| 194 | if (!srng->hal_srng) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 195 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 196 | FL("Ring type: %d, num:%d not setup"), |
| 197 | ring_type, ring_num); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 198 | return; |
| 199 | } |
| 200 | |
| 201 | hal_srng_cleanup(soc->hal_soc, srng->hal_srng); |
| 202 | |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 203 | qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 204 | srng->alloc_size, |
| 205 | srng->base_vaddr_unaligned, |
| 206 | srng->base_paddr_unaligned, 0); |
| 207 | } |
| 208 | |
| 209 | /* TODO: Need this interface from HIF */ |
| 210 | void *hif_get_hal_handle(void *hif_handle); |
| 211 | |
| 212 | /* |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 213 | * dp_service_srngs() - Top level interrupt handler for DP Ring interrupts |
| 214 | * @dp_ctx: DP SOC handle |
| 215 | * @budget: Number of frames/descriptors that can be processed in one shot |
| 216 | * |
| 217 | * Return: remaining budget/quota for the soc device |
| 218 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 219 | static uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget) |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 220 | { |
| 221 | struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx; |
| 222 | struct dp_soc *soc = int_ctx->soc; |
| 223 | int ring = 0; |
| 224 | uint32_t work_done = 0; |
| 225 | uint32_t budget = dp_budget; |
| 226 | uint8_t tx_mask = int_ctx->tx_ring_mask; |
| 227 | uint8_t rx_mask = int_ctx->rx_ring_mask; |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 228 | uint8_t rx_err_mask = int_ctx->rx_err_ring_mask; |
| 229 | uint8_t rx_wbm_rel_mask = int_ctx->rx_wbm_rel_ring_mask; |
Karunakar Dasineni | a0f09ea | 2016-11-21 17:41:31 -0800 | [diff] [blame] | 230 | uint8_t reo_status_mask = int_ctx->reo_status_ring_mask; |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 231 | |
| 232 | /* Process Tx completion interrupts first to return back buffers */ |
| 233 | if (tx_mask) { |
| 234 | for (ring = 0; ring < soc->num_tcl_data_rings; ring++) { |
| 235 | if (tx_mask & (1 << ring)) { |
| 236 | work_done = |
| 237 | dp_tx_comp_handler(soc, ring, budget); |
| 238 | budget -= work_done; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 239 | if (work_done) |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 240 | QDF_TRACE(QDF_MODULE_ID_DP, |
| 241 | QDF_TRACE_LEVEL_INFO, |
| 242 | "tx mask 0x%x ring %d," |
| 243 | "budget %d", |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 244 | tx_mask, ring, budget); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 245 | if (budget <= 0) |
| 246 | goto budget_done; |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 251 | /* Process REO Exception ring interrupt */ |
| 252 | if (rx_err_mask) { |
| 253 | work_done = dp_rx_err_process(soc, |
| 254 | soc->reo_exception_ring.hal_srng, budget); |
| 255 | budget -= work_done; |
| 256 | |
| 257 | if (work_done) |
| 258 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, |
| 259 | "REO Exception Ring: work_done %d budget %d", |
| 260 | work_done, budget); |
| 261 | if (budget <= 0) { |
| 262 | goto budget_done; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | /* Process Rx WBM release ring interrupt */ |
| 267 | if (rx_wbm_rel_mask) { |
| 268 | work_done = dp_rx_wbm_err_process(soc, |
| 269 | soc->rx_rel_ring.hal_srng, budget); |
| 270 | budget -= work_done; |
| 271 | |
| 272 | if (work_done) |
| 273 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, |
| 274 | "WBM Release Ring: work_done %d budget %d", |
| 275 | work_done, budget); |
| 276 | if (budget <= 0) { |
| 277 | goto budget_done; |
| 278 | } |
| 279 | } |
| 280 | |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 281 | /* Process Rx interrupts */ |
| 282 | if (rx_mask) { |
| 283 | for (ring = 0; ring < soc->num_reo_dest_rings; ring++) { |
| 284 | if (rx_mask & (1 << ring)) { |
| 285 | work_done = |
| 286 | dp_rx_process(soc, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 287 | soc->reo_dest_ring[ring].hal_srng, |
| 288 | budget); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 289 | budget -= work_done; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 290 | if (work_done) |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 291 | QDF_TRACE(QDF_MODULE_ID_DP, |
| 292 | QDF_TRACE_LEVEL_INFO, |
| 293 | "rx mask 0x%x ring %d," |
| 294 | "budget %d", |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 295 | tx_mask, ring, budget); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 296 | if (budget <= 0) |
| 297 | goto budget_done; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
Karunakar Dasineni | a0f09ea | 2016-11-21 17:41:31 -0800 | [diff] [blame] | 302 | if (reo_status_mask) |
| 303 | dp_reo_status_ring_handler(soc); |
| 304 | |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 305 | budget_done: |
| 306 | return dp_budget - budget; |
| 307 | } |
| 308 | |
| 309 | /* dp_interrupt_timer()- timer poll for interrupts |
| 310 | * |
| 311 | * @arg: SoC Handle |
| 312 | * |
| 313 | * Return: |
| 314 | * |
| 315 | */ |
| 316 | #ifdef DP_INTR_POLL_BASED |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 317 | static void dp_interrupt_timer(void *arg) |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 318 | { |
| 319 | struct dp_soc *soc = (struct dp_soc *) arg; |
| 320 | int i; |
| 321 | |
Ravi Joshi | 86e9826 | 2017-03-01 13:47:03 -0800 | [diff] [blame] | 322 | if (qdf_atomic_read(&soc->cmn_init_done)) { |
| 323 | for (i = 0; |
| 324 | i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) |
| 325 | dp_service_srngs(&soc->intr_ctx[i], 0xffff); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 326 | |
Ravi Joshi | 86e9826 | 2017-03-01 13:47:03 -0800 | [diff] [blame] | 327 | qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS); |
| 328 | } |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | /* |
| 332 | * dp_soc_interrupt_attach() - Register handlers for DP interrupts |
| 333 | * @txrx_soc: DP SOC handle |
| 334 | * |
| 335 | * Host driver will register for “DP_NUM_INTERRUPT_CONTEXTS” number of NAPI |
| 336 | * contexts. Each NAPI context will have a tx_ring_mask , rx_ring_mask ,and |
| 337 | * rx_monitor_ring mask to indicate the rings that are processed by the handler. |
| 338 | * |
| 339 | * Return: 0 for success. nonzero for failure. |
| 340 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 341 | static QDF_STATUS dp_soc_interrupt_attach(void *txrx_soc) |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 342 | { |
| 343 | struct dp_soc *soc = (struct dp_soc *)txrx_soc; |
| 344 | int i; |
| 345 | |
| 346 | for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) { |
| 347 | soc->intr_ctx[i].tx_ring_mask = 0xF; |
| 348 | soc->intr_ctx[i].rx_ring_mask = 0xF; |
| 349 | soc->intr_ctx[i].rx_mon_ring_mask = 0xF; |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 350 | soc->intr_ctx[i].rx_err_ring_mask = 0x1; |
| 351 | soc->intr_ctx[i].rx_wbm_rel_ring_mask = 0x1; |
Karunakar Dasineni | a0f09ea | 2016-11-21 17:41:31 -0800 | [diff] [blame] | 352 | soc->intr_ctx[i].reo_status_ring_mask = 0x1; |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 353 | soc->intr_ctx[i].soc = soc; |
| 354 | } |
| 355 | |
| 356 | qdf_timer_init(soc->osdev, &soc->int_timer, |
| 357 | dp_interrupt_timer, (void *)soc, |
| 358 | QDF_TIMER_TYPE_WAKE_APPS); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 359 | |
| 360 | return QDF_STATUS_SUCCESS; |
| 361 | } |
| 362 | |
| 363 | /* |
| 364 | * dp_soc_interrupt_detach() - Deregister any allocations done for interrupts |
| 365 | * @txrx_soc: DP SOC handle |
| 366 | * |
| 367 | * Return: void |
| 368 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 369 | static void dp_soc_interrupt_detach(void *txrx_soc) |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 370 | { |
| 371 | struct dp_soc *soc = (struct dp_soc *)txrx_soc; |
| 372 | |
| 373 | qdf_timer_stop(&soc->int_timer); |
Ravi Joshi | 05d9e67 | 2016-11-22 17:31:46 -0800 | [diff] [blame] | 374 | |
Vijay Pamidipati | 88c40ff | 2016-11-17 21:27:02 +0530 | [diff] [blame] | 375 | qdf_timer_free(&soc->int_timer); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 376 | } |
| 377 | #else |
| 378 | /* |
| 379 | * dp_soc_interrupt_attach() - Register handlers for DP interrupts |
| 380 | * @txrx_soc: DP SOC handle |
| 381 | * |
| 382 | * Host driver will register for “DP_NUM_INTERRUPT_CONTEXTS” number of NAPI |
| 383 | * contexts. Each NAPI context will have a tx_ring_mask , rx_ring_mask ,and |
| 384 | * rx_monitor_ring mask to indicate the rings that are processed by the handler. |
| 385 | * |
| 386 | * Return: 0 for success. nonzero for failure. |
| 387 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 388 | static QDF_STATUS dp_soc_interrupt_attach(void *txrx_soc) |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 389 | { |
| 390 | struct dp_soc *soc = (struct dp_soc *)txrx_soc; |
| 391 | |
| 392 | int i = 0; |
| 393 | int num_irq = 0; |
| 394 | |
| 395 | |
| 396 | for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) { |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 397 | int j = 0; |
| 398 | int ret = 0; |
| 399 | |
| 400 | /* Map of IRQ ids registered with one interrupt context */ |
| 401 | int irq_id_map[HIF_MAX_GRP_IRQ]; |
| 402 | |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 403 | int tx_mask = |
| 404 | wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i); |
| 405 | int rx_mask = |
| 406 | wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i); |
| 407 | int rx_mon_mask = |
| 408 | wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i); |
| 409 | |
| 410 | soc->intr_ctx[i].tx_ring_mask = tx_mask; |
| 411 | soc->intr_ctx[i].rx_ring_mask = rx_mask; |
| 412 | soc->intr_ctx[i].rx_mon_ring_mask = rx_mon_mask; |
| 413 | soc->intr_ctx[i].soc = soc; |
| 414 | |
| 415 | num_irq = 0; |
| 416 | |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 417 | for (j = 0; j < HIF_MAX_GRP_IRQ; j++) { |
| 418 | |
| 419 | if (tx_mask & (1 << j)) { |
| 420 | irq_id_map[num_irq++] = |
| 421 | (wbm2host_tx_completions_ring1 - j); |
| 422 | } |
| 423 | |
| 424 | if (rx_mask & (1 << j)) { |
| 425 | irq_id_map[num_irq++] = |
| 426 | (reo2host_destination_ring1 - j); |
| 427 | } |
| 428 | |
| 429 | if (rx_mon_mask & (1 << j)) { |
| 430 | irq_id_map[num_irq++] = |
| 431 | (rxdma2host_monitor_destination_mac1 |
| 432 | - j); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | |
| 437 | ret = hif_register_ext_group_int_handler(soc->hif_handle, |
| 438 | num_irq, irq_id_map, |
| 439 | dp_service_srngs, |
| 440 | &soc->intr_ctx[i]); |
| 441 | |
| 442 | if (ret) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 443 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 444 | FL("failed, ret = %d"), ret); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 445 | |
| 446 | return QDF_STATUS_E_FAILURE; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | return QDF_STATUS_SUCCESS; |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * dp_soc_interrupt_detach() - Deregister any allocations done for interrupts |
| 455 | * @txrx_soc: DP SOC handle |
| 456 | * |
| 457 | * Return: void |
| 458 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 459 | static void dp_soc_interrupt_detach(void *txrx_soc) |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 460 | { |
| 461 | struct dp_soc *soc = (struct dp_soc *)txrx_soc; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 462 | int i; |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 463 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 464 | for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) { |
| 465 | soc->intr_ctx[i].tx_ring_mask = 0; |
| 466 | soc->intr_ctx[i].rx_ring_mask = 0; |
| 467 | soc->intr_ctx[i].rx_mon_ring_mask = 0; |
| 468 | } |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 469 | } |
| 470 | #endif |
| 471 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 472 | #define AVG_MAX_MPDUS_PER_TID 128 |
| 473 | #define AVG_TIDS_PER_CLIENT 2 |
| 474 | #define AVG_FLOWS_PER_TID 2 |
| 475 | #define AVG_MSDUS_PER_FLOW 128 |
| 476 | #define AVG_MSDUS_PER_MPDU 4 |
| 477 | |
| 478 | /* |
| 479 | * Allocate and setup link descriptor pool that will be used by HW for |
| 480 | * various link and queue descriptors and managed by WBM |
| 481 | */ |
| 482 | static int dp_hw_link_desc_pool_setup(struct dp_soc *soc) |
| 483 | { |
| 484 | int link_desc_size = hal_get_link_desc_size(soc->hal_soc); |
| 485 | int link_desc_align = hal_get_link_desc_align(soc->hal_soc); |
| 486 | uint32_t max_clients = wlan_cfg_get_max_clients(soc->wlan_cfg_ctx); |
| 487 | uint32_t num_mpdus_per_link_desc = |
| 488 | hal_num_mpdus_per_link_desc(soc->hal_soc); |
| 489 | uint32_t num_msdus_per_link_desc = |
| 490 | hal_num_msdus_per_link_desc(soc->hal_soc); |
| 491 | uint32_t num_mpdu_links_per_queue_desc = |
| 492 | hal_num_mpdu_links_per_queue_desc(soc->hal_soc); |
| 493 | uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx); |
| 494 | uint32_t total_link_descs, total_mem_size; |
| 495 | uint32_t num_mpdu_link_descs, num_mpdu_queue_descs; |
| 496 | uint32_t num_tx_msdu_link_descs, num_rx_msdu_link_descs; |
| 497 | uint32_t num_link_desc_banks; |
| 498 | uint32_t last_bank_size = 0; |
| 499 | uint32_t entry_size, num_entries; |
| 500 | int i; |
| 501 | |
| 502 | /* Only Tx queue descriptors are allocated from common link descriptor |
| 503 | * pool Rx queue descriptors are not included in this because (REO queue |
| 504 | * extension descriptors) they are expected to be allocated contiguously |
| 505 | * with REO queue descriptors |
| 506 | */ |
| 507 | num_mpdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT * |
| 508 | AVG_MAX_MPDUS_PER_TID) / num_mpdus_per_link_desc; |
| 509 | |
| 510 | num_mpdu_queue_descs = num_mpdu_link_descs / |
| 511 | num_mpdu_links_per_queue_desc; |
| 512 | |
| 513 | num_tx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT * |
| 514 | AVG_FLOWS_PER_TID * AVG_MSDUS_PER_FLOW) / |
| 515 | num_msdus_per_link_desc; |
| 516 | |
| 517 | num_rx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT * |
| 518 | AVG_MAX_MPDUS_PER_TID * AVG_MSDUS_PER_MPDU) / 6; |
| 519 | |
| 520 | num_entries = num_mpdu_link_descs + num_mpdu_queue_descs + |
| 521 | num_tx_msdu_link_descs + num_rx_msdu_link_descs; |
| 522 | |
| 523 | /* Round up to power of 2 */ |
| 524 | total_link_descs = 1; |
| 525 | while (total_link_descs < num_entries) |
| 526 | total_link_descs <<= 1; |
| 527 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 528 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
| 529 | FL("total_link_descs: %u, link_desc_size: %d"), |
| 530 | total_link_descs, link_desc_size); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 531 | total_mem_size = total_link_descs * link_desc_size; |
| 532 | |
| 533 | total_mem_size += link_desc_align; |
| 534 | |
| 535 | if (total_mem_size <= max_alloc_size) { |
| 536 | num_link_desc_banks = 0; |
| 537 | last_bank_size = total_mem_size; |
| 538 | } else { |
| 539 | num_link_desc_banks = (total_mem_size) / |
| 540 | (max_alloc_size - link_desc_align); |
| 541 | last_bank_size = total_mem_size % |
| 542 | (max_alloc_size - link_desc_align); |
| 543 | } |
| 544 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 545 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
| 546 | FL("total_mem_size: %d, num_link_desc_banks: %u"), |
| 547 | total_mem_size, num_link_desc_banks); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 548 | |
| 549 | for (i = 0; i < num_link_desc_banks; i++) { |
| 550 | soc->link_desc_banks[i].base_vaddr_unaligned = |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 551 | qdf_mem_alloc_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 552 | max_alloc_size, |
| 553 | &(soc->link_desc_banks[i].base_paddr_unaligned)); |
| 554 | soc->link_desc_banks[i].size = max_alloc_size; |
| 555 | |
| 556 | soc->link_desc_banks[i].base_vaddr = (void *)((unsigned long)( |
| 557 | soc->link_desc_banks[i].base_vaddr_unaligned) + |
| 558 | ((unsigned long)( |
| 559 | soc->link_desc_banks[i].base_vaddr_unaligned) % |
| 560 | link_desc_align)); |
| 561 | |
| 562 | soc->link_desc_banks[i].base_paddr = (unsigned long)( |
| 563 | soc->link_desc_banks[i].base_paddr_unaligned) + |
| 564 | ((unsigned long)(soc->link_desc_banks[i].base_vaddr) - |
| 565 | (unsigned long)( |
| 566 | soc->link_desc_banks[i].base_vaddr_unaligned)); |
| 567 | |
| 568 | if (!soc->link_desc_banks[i].base_vaddr_unaligned) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 569 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 570 | FL("Link descriptor memory alloc failed")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 571 | goto fail; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | if (last_bank_size) { |
| 576 | /* Allocate last bank in case total memory required is not exact |
| 577 | * multiple of max_alloc_size |
| 578 | */ |
| 579 | soc->link_desc_banks[i].base_vaddr_unaligned = |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 580 | qdf_mem_alloc_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 581 | last_bank_size, |
| 582 | &(soc->link_desc_banks[i].base_paddr_unaligned)); |
| 583 | soc->link_desc_banks[i].size = last_bank_size; |
| 584 | |
| 585 | soc->link_desc_banks[i].base_vaddr = (void *)((unsigned long) |
| 586 | (soc->link_desc_banks[i].base_vaddr_unaligned) + |
| 587 | ((unsigned long)( |
| 588 | soc->link_desc_banks[i].base_vaddr_unaligned) % |
| 589 | link_desc_align)); |
| 590 | |
| 591 | soc->link_desc_banks[i].base_paddr = |
| 592 | (unsigned long)( |
| 593 | soc->link_desc_banks[i].base_paddr_unaligned) + |
| 594 | ((unsigned long)(soc->link_desc_banks[i].base_vaddr) - |
| 595 | (unsigned long)( |
| 596 | soc->link_desc_banks[i].base_vaddr_unaligned)); |
| 597 | } |
| 598 | |
| 599 | |
| 600 | /* Allocate and setup link descriptor idle list for HW internal use */ |
| 601 | entry_size = hal_srng_get_entrysize(soc->hal_soc, WBM_IDLE_LINK); |
| 602 | total_mem_size = entry_size * total_link_descs; |
| 603 | |
| 604 | if (total_mem_size <= max_alloc_size) { |
| 605 | void *desc; |
| 606 | |
| 607 | if (dp_srng_setup(soc, &soc->wbm_idle_link_ring, |
| 608 | WBM_IDLE_LINK, 0, 0, total_link_descs)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 609 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 610 | FL("Link desc idle ring setup failed")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 611 | goto fail; |
| 612 | } |
| 613 | |
| 614 | hal_srng_access_start_unlocked(soc->hal_soc, |
| 615 | soc->wbm_idle_link_ring.hal_srng); |
| 616 | |
| 617 | for (i = 0; i < MAX_LINK_DESC_BANKS && |
| 618 | soc->link_desc_banks[i].base_paddr; i++) { |
| 619 | uint32_t num_entries = (soc->link_desc_banks[i].size - |
| 620 | (unsigned long)( |
| 621 | soc->link_desc_banks[i].base_vaddr) - |
| 622 | (unsigned long)( |
| 623 | soc->link_desc_banks[i].base_vaddr_unaligned)) |
| 624 | / link_desc_size; |
| 625 | unsigned long paddr = (unsigned long)( |
| 626 | soc->link_desc_banks[i].base_paddr); |
| 627 | |
| 628 | while (num_entries && (desc = hal_srng_src_get_next( |
| 629 | soc->hal_soc, |
| 630 | soc->wbm_idle_link_ring.hal_srng))) { |
| 631 | hal_set_link_desc_addr(desc, i, paddr); |
| 632 | num_entries--; |
| 633 | paddr += link_desc_size; |
| 634 | } |
| 635 | } |
| 636 | hal_srng_access_end_unlocked(soc->hal_soc, |
| 637 | soc->wbm_idle_link_ring.hal_srng); |
| 638 | } else { |
| 639 | uint32_t num_scatter_bufs; |
| 640 | uint32_t num_entries_per_buf; |
| 641 | uint32_t rem_entries; |
| 642 | uint8_t *scatter_buf_ptr; |
| 643 | uint16_t scatter_buf_num; |
| 644 | |
| 645 | soc->wbm_idle_scatter_buf_size = |
| 646 | hal_idle_list_scatter_buf_size(soc->hal_soc); |
| 647 | num_entries_per_buf = hal_idle_scatter_buf_num_entries( |
| 648 | soc->hal_soc, soc->wbm_idle_scatter_buf_size); |
| 649 | num_scatter_bufs = (total_mem_size / |
| 650 | soc->wbm_idle_scatter_buf_size) + (total_mem_size % |
| 651 | soc->wbm_idle_scatter_buf_size) ? 1 : 0; |
| 652 | |
| 653 | for (i = 0; i < num_scatter_bufs; i++) { |
| 654 | soc->wbm_idle_scatter_buf_base_vaddr[i] = |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 655 | qdf_mem_alloc_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 656 | soc->wbm_idle_scatter_buf_size, |
| 657 | &(soc->wbm_idle_scatter_buf_base_paddr[i])); |
| 658 | if (soc->wbm_idle_scatter_buf_base_vaddr[i] == NULL) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 659 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 660 | QDF_TRACE_LEVEL_ERROR, |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 661 | FL("Scatter list memory alloc failed")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 662 | goto fail; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | /* Populate idle list scatter buffers with link descriptor |
| 667 | * pointers |
| 668 | */ |
| 669 | scatter_buf_num = 0; |
| 670 | scatter_buf_ptr = (uint8_t *)( |
| 671 | soc->wbm_idle_scatter_buf_base_vaddr[scatter_buf_num]); |
| 672 | rem_entries = num_entries_per_buf; |
| 673 | |
| 674 | for (i = 0; i < MAX_LINK_DESC_BANKS && |
| 675 | soc->link_desc_banks[i].base_paddr; i++) { |
| 676 | uint32_t num_link_descs = |
| 677 | (soc->link_desc_banks[i].size - |
| 678 | (unsigned long)( |
| 679 | soc->link_desc_banks[i].base_vaddr) - |
| 680 | (unsigned long)( |
| 681 | soc->link_desc_banks[i].base_vaddr_unaligned)) / |
| 682 | link_desc_size; |
| 683 | unsigned long paddr = (unsigned long)( |
| 684 | soc->link_desc_banks[i].base_paddr); |
| 685 | void *desc = NULL; |
| 686 | |
| 687 | while (num_link_descs && (desc = |
| 688 | hal_srng_src_get_next(soc->hal_soc, |
| 689 | soc->wbm_idle_link_ring.hal_srng))) { |
| 690 | hal_set_link_desc_addr((void *)scatter_buf_ptr, |
| 691 | i, paddr); |
| 692 | num_link_descs--; |
| 693 | paddr += link_desc_size; |
| 694 | if (rem_entries) { |
| 695 | rem_entries--; |
| 696 | scatter_buf_ptr += link_desc_size; |
| 697 | } else { |
| 698 | rem_entries = num_entries_per_buf; |
| 699 | scatter_buf_num++; |
| 700 | scatter_buf_ptr = (uint8_t *)( |
| 701 | soc->wbm_idle_scatter_buf_base_vaddr[ |
| 702 | scatter_buf_num]); |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | /* Setup link descriptor idle list in HW */ |
| 707 | hal_setup_link_idle_list(soc->hal_soc, |
| 708 | soc->wbm_idle_scatter_buf_base_paddr, |
| 709 | soc->wbm_idle_scatter_buf_base_vaddr, |
| 710 | num_scatter_bufs, soc->wbm_idle_scatter_buf_size, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 711 | (uint32_t)(scatter_buf_ptr - |
| 712 | (uint8_t *)(soc->wbm_idle_scatter_buf_base_vaddr[ |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 713 | scatter_buf_num]))); |
| 714 | } |
| 715 | return 0; |
| 716 | |
| 717 | fail: |
| 718 | if (soc->wbm_idle_link_ring.hal_srng) { |
| 719 | dp_srng_cleanup(soc->hal_soc, &soc->wbm_idle_link_ring, |
| 720 | WBM_IDLE_LINK, 0); |
| 721 | } |
| 722 | |
| 723 | for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) { |
| 724 | if (soc->wbm_idle_scatter_buf_base_vaddr[i]) { |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 725 | qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 726 | soc->wbm_idle_scatter_buf_size, |
| 727 | soc->wbm_idle_scatter_buf_base_vaddr[i], |
| 728 | soc->wbm_idle_scatter_buf_base_paddr[i], 0); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | for (i = 0; i < MAX_LINK_DESC_BANKS; i++) { |
| 733 | if (soc->link_desc_banks[i].base_vaddr_unaligned) { |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 734 | qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 735 | soc->link_desc_banks[i].size, |
| 736 | soc->link_desc_banks[i].base_vaddr_unaligned, |
| 737 | soc->link_desc_banks[i].base_paddr_unaligned, |
| 738 | 0); |
| 739 | } |
| 740 | } |
| 741 | return QDF_STATUS_E_FAILURE; |
| 742 | } |
| 743 | |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 744 | #ifdef notused |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 745 | /* |
| 746 | * Free link descriptor pool that was setup HW |
| 747 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 748 | static void dp_hw_link_desc_pool_cleanup(struct dp_soc *soc) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 749 | { |
| 750 | int i; |
| 751 | |
| 752 | if (soc->wbm_idle_link_ring.hal_srng) { |
| 753 | dp_srng_cleanup(soc->hal_soc, &soc->wbm_idle_link_ring, |
| 754 | WBM_IDLE_LINK, 0); |
| 755 | } |
| 756 | |
| 757 | for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) { |
| 758 | if (soc->wbm_idle_scatter_buf_base_vaddr[i]) { |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 759 | qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 760 | soc->wbm_idle_scatter_buf_size, |
| 761 | soc->wbm_idle_scatter_buf_base_vaddr[i], |
| 762 | soc->wbm_idle_scatter_buf_base_paddr[i], 0); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | for (i = 0; i < MAX_LINK_DESC_BANKS; i++) { |
| 767 | if (soc->link_desc_banks[i].base_vaddr_unaligned) { |
Dhanashri Atre | 57e420d | 2016-10-25 21:13:54 -0700 | [diff] [blame] | 768 | qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 769 | soc->link_desc_banks[i].size, |
| 770 | soc->link_desc_banks[i].base_vaddr_unaligned, |
| 771 | soc->link_desc_banks[i].base_paddr_unaligned, |
| 772 | 0); |
| 773 | } |
| 774 | } |
| 775 | } |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 776 | #endif /* notused */ |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 777 | |
| 778 | /* TODO: Following should be configurable */ |
| 779 | #define WBM_RELEASE_RING_SIZE 64 |
| 780 | #define TCL_DATA_RING_SIZE 512 |
Karunakar Dasineni | d0ea21f | 2017-01-31 22:58:15 -0800 | [diff] [blame] | 781 | #define TX_COMP_RING_SIZE 1024 |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 782 | #define TCL_CMD_RING_SIZE 32 |
| 783 | #define TCL_STATUS_RING_SIZE 32 |
| 784 | #define REO_DST_RING_SIZE 2048 |
| 785 | #define REO_REINJECT_RING_SIZE 32 |
Karunakar Dasineni | d0ea21f | 2017-01-31 22:58:15 -0800 | [diff] [blame] | 786 | #define RX_RELEASE_RING_SIZE 1024 |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 787 | #define REO_EXCEPTION_RING_SIZE 128 |
| 788 | #define REO_CMD_RING_SIZE 32 |
| 789 | #define REO_STATUS_RING_SIZE 32 |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 790 | #define RXDMA_BUF_RING_SIZE 1024 |
| 791 | #define RXDMA_REFILL_RING_SIZE 2048 |
Ishank Jain | 2fab33d | 2017-01-06 19:32:30 +0530 | [diff] [blame] | 792 | #define RXDMA_MONITOR_BUF_RING_SIZE 2048 |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 793 | #define RXDMA_MONITOR_DST_RING_SIZE 2048 |
| 794 | #define RXDMA_MONITOR_STATUS_RING_SIZE 2048 |
| 795 | |
| 796 | /* |
| 797 | * dp_soc_cmn_setup() - Common SoC level initializion |
| 798 | * @soc: Datapath SOC handle |
| 799 | * |
| 800 | * This is an internal function used to setup common SOC data structures, |
| 801 | * to be called from PDEV attach after receiving HW mode capabilities from FW |
| 802 | */ |
| 803 | static int dp_soc_cmn_setup(struct dp_soc *soc) |
| 804 | { |
| 805 | int i; |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 806 | struct hal_reo_params reo_params; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 807 | |
Ravi Joshi | 86e9826 | 2017-03-01 13:47:03 -0800 | [diff] [blame] | 808 | if (qdf_atomic_read(&soc->cmn_init_done)) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 809 | return 0; |
| 810 | |
| 811 | if (dp_peer_find_attach(soc)) |
| 812 | goto fail0; |
| 813 | |
| 814 | if (dp_hw_link_desc_pool_setup(soc)) |
| 815 | goto fail1; |
| 816 | |
| 817 | /* Setup SRNG rings */ |
| 818 | /* Common rings */ |
| 819 | if (dp_srng_setup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0, 0, |
| 820 | WBM_RELEASE_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 821 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 822 | FL("dp_srng_setup failed for wbm_desc_rel_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 823 | goto fail1; |
| 824 | } |
| 825 | |
| 826 | |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 827 | soc->num_tcl_data_rings = 0; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 828 | /* Tx data rings */ |
| 829 | if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) { |
| 830 | soc->num_tcl_data_rings = |
| 831 | wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx); |
| 832 | for (i = 0; i < soc->num_tcl_data_rings; i++) { |
| 833 | if (dp_srng_setup(soc, &soc->tcl_data_ring[i], |
| 834 | TCL_DATA, i, 0, TCL_DATA_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 835 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 836 | QDF_TRACE_LEVEL_ERROR, |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 837 | FL("dp_srng_setup failed for tcl_data_ring[%d]"), i); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 838 | goto fail1; |
| 839 | } |
| 840 | if (dp_srng_setup(soc, &soc->tx_comp_ring[i], |
Karunakar Dasineni | d0ea21f | 2017-01-31 22:58:15 -0800 | [diff] [blame] | 841 | WBM2SW_RELEASE, i, 0, TX_COMP_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 842 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 843 | QDF_TRACE_LEVEL_ERROR, |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 844 | FL("dp_srng_setup failed for tx_comp_ring[%d]"), i); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 845 | goto fail1; |
| 846 | } |
| 847 | } |
| 848 | } else { |
| 849 | /* This will be incremented during per pdev ring setup */ |
| 850 | soc->num_tcl_data_rings = 0; |
| 851 | } |
| 852 | |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 853 | if (dp_tx_soc_attach(soc)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 854 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 855 | FL("dp_tx_soc_attach failed")); |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 856 | goto fail1; |
| 857 | } |
| 858 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 859 | /* TCL command and status rings */ |
| 860 | if (dp_srng_setup(soc, &soc->tcl_cmd_ring, TCL_CMD, 0, 0, |
| 861 | TCL_CMD_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 862 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 863 | FL("dp_srng_setup failed for tcl_cmd_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 864 | goto fail1; |
| 865 | } |
| 866 | |
| 867 | if (dp_srng_setup(soc, &soc->tcl_status_ring, TCL_STATUS, 0, 0, |
| 868 | TCL_STATUS_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 869 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 870 | FL("dp_srng_setup failed for tcl_status_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 871 | goto fail1; |
| 872 | } |
| 873 | |
| 874 | |
| 875 | /* TBD: call dp_tx_init to setup Tx SW descriptors and MSDU extension |
| 876 | * descriptors |
| 877 | */ |
| 878 | |
| 879 | /* Rx data rings */ |
| 880 | if (!wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) { |
| 881 | soc->num_reo_dest_rings = |
| 882 | wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx); |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 883 | QDF_TRACE(QDF_MODULE_ID_DP, |
| 884 | QDF_TRACE_LEVEL_ERROR, |
| 885 | FL("num_reo_dest_rings %d\n"), soc->num_reo_dest_rings); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 886 | for (i = 0; i < soc->num_reo_dest_rings; i++) { |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 887 | if (dp_srng_setup(soc, &soc->reo_dest_ring[i], REO_DST, |
| 888 | i, 0, REO_DST_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 889 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 890 | QDF_TRACE_LEVEL_ERROR, |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 891 | FL("dp_srng_setup failed for reo_dest_ring[%d]"), i); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 892 | goto fail1; |
| 893 | } |
| 894 | } |
| 895 | } else { |
| 896 | /* This will be incremented during per pdev ring setup */ |
| 897 | soc->num_reo_dest_rings = 0; |
| 898 | } |
| 899 | |
| 900 | /* TBD: call dp_rx_init to setup Rx SW descriptors */ |
| 901 | |
| 902 | /* REO reinjection ring */ |
| 903 | if (dp_srng_setup(soc, &soc->reo_reinject_ring, REO_REINJECT, 0, 0, |
| 904 | REO_REINJECT_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 905 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 906 | FL("dp_srng_setup failed for reo_reinject_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 907 | goto fail1; |
| 908 | } |
| 909 | |
| 910 | |
| 911 | /* Rx release ring */ |
| 912 | if (dp_srng_setup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 3, 0, |
| 913 | RX_RELEASE_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 914 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 915 | FL("dp_srng_setup failed for rx_rel_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 916 | goto fail1; |
| 917 | } |
| 918 | |
| 919 | |
| 920 | /* Rx exception ring */ |
| 921 | if (dp_srng_setup(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0, |
| 922 | MAX_REO_DEST_RINGS, REO_EXCEPTION_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 923 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 924 | FL("dp_srng_setup failed for reo_exception_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 925 | goto fail1; |
| 926 | } |
| 927 | |
| 928 | |
| 929 | /* REO command and status rings */ |
| 930 | if (dp_srng_setup(soc, &soc->reo_cmd_ring, REO_CMD, 0, 0, |
| 931 | REO_CMD_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 932 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 933 | FL("dp_srng_setup failed for reo_cmd_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 934 | goto fail1; |
| 935 | } |
| 936 | |
Manoj Ekbote | 4f0c6b1 | 2016-10-30 16:01:38 -0700 | [diff] [blame] | 937 | hal_reo_init_cmd_ring(soc->hal_soc, soc->reo_cmd_ring.hal_srng); |
| 938 | TAILQ_INIT(&soc->rx.reo_cmd_list); |
| 939 | qdf_spinlock_create(&soc->rx.reo_cmd_lock); |
| 940 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 941 | if (dp_srng_setup(soc, &soc->reo_status_ring, REO_STATUS, 0, 0, |
| 942 | REO_STATUS_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 943 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 944 | FL("dp_srng_setup failed for reo_status_ring")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 945 | goto fail1; |
| 946 | } |
| 947 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 948 | dp_soc_interrupt_attach(soc); |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 949 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 950 | /* Setup HW REO */ |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 951 | qdf_mem_zero(&reo_params, sizeof(reo_params)); |
| 952 | |
| 953 | if (wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx)) |
| 954 | reo_params.rx_hash_enabled = true; |
| 955 | |
| 956 | hal_reo_setup(soc->hal_soc, &reo_params); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 957 | |
Ravi Joshi | 86e9826 | 2017-03-01 13:47:03 -0800 | [diff] [blame] | 958 | qdf_atomic_set(&soc->cmn_init_done, 1); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 959 | return 0; |
| 960 | fail1: |
| 961 | /* |
| 962 | * Cleanup will be done as part of soc_detach, which will |
| 963 | * be called on pdev attach failure |
| 964 | */ |
| 965 | fail0: |
| 966 | return QDF_STATUS_E_FAILURE; |
| 967 | } |
| 968 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 969 | static void dp_pdev_detach_wifi3(struct cdp_pdev *txrx_pdev, int force); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 970 | |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 971 | static void dp_lro_hash_setup(struct dp_soc *soc) |
| 972 | { |
| 973 | struct cdp_lro_hash_config lro_hash; |
| 974 | |
| 975 | if (!wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx) && |
| 976 | !wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx)) { |
| 977 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 978 | FL("LRO disabled RX hash disabled")); |
| 979 | return; |
| 980 | } |
| 981 | |
| 982 | qdf_mem_zero(&lro_hash, sizeof(lro_hash)); |
| 983 | |
| 984 | if (wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx)) { |
| 985 | lro_hash.lro_enable = 1; |
| 986 | lro_hash.tcp_flag = QDF_TCPHDR_ACK; |
| 987 | lro_hash.tcp_flag_mask = QDF_TCPHDR_FIN | QDF_TCPHDR_SYN | |
| 988 | QDF_TCPHDR_RST | QDF_TCPHDR_ACK | QDF_TCPHDR_URG | |
| 989 | QDF_TCPHDR_ECE | QDF_TCPHDR_CWR; |
| 990 | } |
| 991 | |
| 992 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, FL("enabled")); |
| 993 | qdf_get_random_bytes(lro_hash.toeplitz_hash_ipv4, |
| 994 | (sizeof(lro_hash.toeplitz_hash_ipv4[0]) * |
| 995 | LRO_IPV4_SEED_ARR_SZ)); |
| 996 | |
| 997 | qdf_get_random_bytes(lro_hash.toeplitz_hash_ipv6, |
| 998 | (sizeof(lro_hash.toeplitz_hash_ipv6[0]) * |
| 999 | LRO_IPV6_SEED_ARR_SZ)); |
| 1000 | |
| 1001 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1002 | "lro_hash: lro_enable: 0x%x" |
| 1003 | "lro_hash: tcp_flag 0x%x tcp_flag_mask 0x%x", |
| 1004 | lro_hash.lro_enable, lro_hash.tcp_flag, |
| 1005 | lro_hash.tcp_flag_mask); |
| 1006 | |
| 1007 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1008 | FL("lro_hash: toeplitz_hash_ipv4:")); |
| 1009 | qdf_trace_hex_dump(QDF_MODULE_ID_DP, |
| 1010 | QDF_TRACE_LEVEL_ERROR, |
| 1011 | (void *)lro_hash.toeplitz_hash_ipv4, |
| 1012 | (sizeof(lro_hash.toeplitz_hash_ipv4[0]) * |
| 1013 | LRO_IPV4_SEED_ARR_SZ)); |
| 1014 | |
| 1015 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1016 | FL("lro_hash: toeplitz_hash_ipv6:")); |
| 1017 | qdf_trace_hex_dump(QDF_MODULE_ID_DP, |
| 1018 | QDF_TRACE_LEVEL_ERROR, |
| 1019 | (void *)lro_hash.toeplitz_hash_ipv6, |
| 1020 | (sizeof(lro_hash.toeplitz_hash_ipv6[0]) * |
| 1021 | LRO_IPV6_SEED_ARR_SZ)); |
| 1022 | |
| 1023 | qdf_assert(soc->cdp_soc.ol_ops->lro_hash_config); |
| 1024 | |
| 1025 | if (soc->cdp_soc.ol_ops->lro_hash_config) |
| 1026 | (void)soc->cdp_soc.ol_ops->lro_hash_config |
| 1027 | (soc->osif_soc, &lro_hash); |
| 1028 | } |
| 1029 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1030 | /* |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1031 | * dp_rxdma_ring_setup() - configure the RX DMA rings |
| 1032 | * @soc: data path SoC handle |
| 1033 | * @pdev: Physical device handle |
| 1034 | * |
| 1035 | * Return: 0 - success, > 0 - failure |
| 1036 | */ |
| 1037 | #ifdef QCA_HOST2FW_RXBUF_RING |
| 1038 | static int dp_rxdma_ring_setup(struct dp_soc *soc, |
| 1039 | struct dp_pdev *pdev) |
| 1040 | { |
| 1041 | int max_mac_rings = |
| 1042 | wlan_cfg_get_num_mac_rings |
| 1043 | (pdev->wlan_cfg_ctx); |
| 1044 | int i; |
| 1045 | |
| 1046 | for (i = 0; i < max_mac_rings; i++) { |
| 1047 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 1048 | "%s: pdev_id %d mac_id %d\n", |
| 1049 | __func__, pdev->pdev_id, i); |
| 1050 | if (dp_srng_setup(soc, &pdev->rx_mac_buf_ring[i], |
| 1051 | RXDMA_BUF, 1, i, RXDMA_BUF_RING_SIZE)) { |
| 1052 | QDF_TRACE(QDF_MODULE_ID_DP, |
| 1053 | QDF_TRACE_LEVEL_ERROR, |
| 1054 | FL("failed rx mac ring setup")); |
| 1055 | return QDF_STATUS_E_FAILURE; |
| 1056 | } |
| 1057 | } |
| 1058 | return QDF_STATUS_SUCCESS; |
| 1059 | } |
| 1060 | #else |
| 1061 | static int dp_rxdma_ring_setup(struct dp_soc *soc, |
| 1062 | struct dp_pdev *pdev) |
| 1063 | { |
| 1064 | return QDF_STATUS_SUCCESS; |
| 1065 | } |
| 1066 | #endif |
Ishank Jain | 949674c | 2017-02-27 17:09:29 +0530 | [diff] [blame] | 1067 | |
| 1068 | /** |
| 1069 | * dp_dscp_tid_map_setup(): Initialize the dscp-tid maps |
| 1070 | * @pdev - DP_PDEV handle |
| 1071 | * |
| 1072 | * Return: void |
| 1073 | */ |
| 1074 | static inline void |
| 1075 | dp_dscp_tid_map_setup(struct dp_pdev *pdev) |
| 1076 | { |
| 1077 | uint8_t map_id; |
| 1078 | for (map_id = 0; map_id < DP_MAX_TID_MAPS; map_id++) { |
| 1079 | qdf_mem_copy(pdev->dscp_tid_map[map_id], default_dscp_tid_map, |
| 1080 | sizeof(default_dscp_tid_map)); |
| 1081 | } |
| 1082 | for (map_id = 0; map_id < HAL_MAX_HW_DSCP_TID_MAPS; map_id++) { |
| 1083 | hal_tx_set_dscp_tid_map(pdev->soc->hal_soc, |
| 1084 | pdev->dscp_tid_map[map_id], |
| 1085 | map_id); |
| 1086 | } |
| 1087 | } |
| 1088 | |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1089 | /* |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1090 | * dp_pdev_attach_wifi3() - attach txrx pdev |
| 1091 | * @osif_pdev: Opaque PDEV handle from OSIF/HDD |
| 1092 | * @txrx_soc: Datapath SOC handle |
| 1093 | * @htc_handle: HTC handle for host-target interface |
| 1094 | * @qdf_osdev: QDF OS device |
| 1095 | * @pdev_id: PDEV ID |
| 1096 | * |
| 1097 | * Return: DP PDEV handle on success, NULL on failure |
| 1098 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1099 | static struct cdp_pdev *dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc, |
| 1100 | struct cdp_cfg *ctrl_pdev, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1101 | HTC_HANDLE htc_handle, qdf_device_t qdf_osdev, uint8_t pdev_id) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1102 | { |
| 1103 | struct dp_soc *soc = (struct dp_soc *)txrx_soc; |
| 1104 | struct dp_pdev *pdev = qdf_mem_malloc(sizeof(*pdev)); |
| 1105 | |
| 1106 | if (!pdev) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1107 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1108 | FL("DP PDEV memory allocation failed")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1109 | goto fail0; |
| 1110 | } |
| 1111 | |
Vijay Pamidipati | d41d6d6 | 2016-10-19 21:19:00 +0530 | [diff] [blame] | 1112 | pdev->wlan_cfg_ctx = wlan_cfg_pdev_attach(); |
| 1113 | |
| 1114 | if (!pdev->wlan_cfg_ctx) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1115 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1116 | FL("pdev cfg_attach failed")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1117 | |
| 1118 | qdf_mem_free(pdev); |
Vijay Pamidipati | d41d6d6 | 2016-10-19 21:19:00 +0530 | [diff] [blame] | 1119 | goto fail0; |
| 1120 | } |
| 1121 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1122 | pdev->soc = soc; |
| 1123 | pdev->osif_pdev = ctrl_pdev; |
| 1124 | pdev->pdev_id = pdev_id; |
| 1125 | soc->pdev_list[pdev_id] = pdev; |
| 1126 | |
| 1127 | TAILQ_INIT(&pdev->vdev_list); |
| 1128 | pdev->vdev_count = 0; |
| 1129 | |
| 1130 | if (dp_soc_cmn_setup(soc)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1131 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1132 | FL("dp_soc_cmn_setup failed")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1133 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | /* Setup per PDEV TCL rings if configured */ |
| 1137 | if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) { |
| 1138 | if (dp_srng_setup(soc, &soc->tcl_data_ring[pdev_id], TCL_DATA, |
| 1139 | pdev_id, pdev_id, TCL_DATA_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1140 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1141 | FL("dp_srng_setup failed for tcl_data_ring")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1142 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1143 | } |
| 1144 | if (dp_srng_setup(soc, &soc->tx_comp_ring[pdev_id], |
| 1145 | WBM2SW_RELEASE, pdev_id, pdev_id, TCL_DATA_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1146 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1147 | FL("dp_srng_setup failed for tx_comp_ring")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1148 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1149 | } |
| 1150 | soc->num_tcl_data_rings++; |
| 1151 | } |
| 1152 | |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 1153 | /* Tx specific init */ |
| 1154 | if (dp_tx_pdev_attach(pdev)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1155 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1156 | FL("dp_tx_pdev_attach failed")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1157 | goto fail1; |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 1158 | } |
| 1159 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1160 | /* Setup per PDEV REO rings if configured */ |
| 1161 | if (wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) { |
| 1162 | if (dp_srng_setup(soc, &soc->reo_dest_ring[pdev_id], REO_DST, |
| 1163 | pdev_id, pdev_id, REO_DST_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1164 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1165 | FL("dp_srng_setup failed for reo_dest_ringn")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1166 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1167 | } |
| 1168 | soc->num_reo_dest_rings++; |
| 1169 | |
| 1170 | } |
| 1171 | |
Dhanashri Atre | 7351d17 | 2016-10-12 13:08:09 -0700 | [diff] [blame] | 1172 | if (dp_srng_setup(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0, pdev_id, |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1173 | RXDMA_REFILL_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1174 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1175 | FL("dp_srng_setup failed rx refill ring")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1176 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1177 | } |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1178 | |
| 1179 | if (dp_rxdma_ring_setup(soc, pdev)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1180 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1181 | FL("RXDMA ring config failed")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1182 | goto fail1; |
Dhanashri Atre | 7351d17 | 2016-10-12 13:08:09 -0700 | [diff] [blame] | 1183 | } |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1184 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1185 | if (dp_srng_setup(soc, &pdev->rxdma_mon_buf_ring, RXDMA_MONITOR_BUF, 0, |
| 1186 | pdev_id, RXDMA_MONITOR_BUF_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1187 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1188 | FL("dp_srng_setup failed for rxdma_mon_buf_ring")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1189 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | if (dp_srng_setup(soc, &pdev->rxdma_mon_dst_ring, RXDMA_MONITOR_DST, 0, |
| 1193 | pdev_id, RXDMA_MONITOR_DST_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1194 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1195 | FL("dp_srng_setup failed for rxdma_mon_dst_ring")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1196 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | if (dp_srng_setup(soc, &pdev->rxdma_mon_status_ring, |
| 1201 | RXDMA_MONITOR_STATUS, 0, pdev_id, |
| 1202 | RXDMA_MONITOR_STATUS_RING_SIZE)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1203 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1204 | FL("dp_srng_setup failed for rxdma_mon_status_ring")); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1205 | goto fail1; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1208 | /* Rx specific init */ |
| 1209 | if (dp_rx_pdev_attach(pdev)) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1210 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1211 | FL("dp_rx_pdev_attach failed ")); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1212 | goto fail0; |
| 1213 | } |
Ishank Jain | bc2d91f | 2017-01-03 18:14:54 +0530 | [diff] [blame] | 1214 | DP_STATS_INIT(pdev); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1215 | |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 1216 | #ifndef CONFIG_WIN |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1217 | /* MCL */ |
| 1218 | dp_local_peer_id_pool_init(pdev); |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 1219 | #endif |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 1220 | dp_lro_hash_setup(soc); |
Ishank Jain | 949674c | 2017-02-27 17:09:29 +0530 | [diff] [blame] | 1221 | dp_dscp_tid_map_setup(pdev); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1222 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1223 | return (struct cdp_pdev *)pdev; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1224 | |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1225 | fail1: |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1226 | dp_pdev_detach_wifi3((struct cdp_pdev *)pdev, 0); |
Vijay Pamidipati | b775e13 | 2016-10-19 21:19:52 +0530 | [diff] [blame] | 1227 | |
| 1228 | fail0: |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1229 | return NULL; |
| 1230 | } |
| 1231 | |
| 1232 | /* |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1233 | * dp_rxdma_ring_cleanup() - configure the RX DMA rings |
| 1234 | * @soc: data path SoC handle |
| 1235 | * @pdev: Physical device handle |
| 1236 | * |
| 1237 | * Return: void |
| 1238 | */ |
| 1239 | #ifdef QCA_HOST2FW_RXBUF_RING |
| 1240 | static void dp_rxdma_ring_cleanup(struct dp_soc *soc, |
| 1241 | struct dp_pdev *pdev) |
| 1242 | { |
| 1243 | int max_mac_rings = |
| 1244 | wlan_cfg_get_num_mac_rings(pdev->wlan_cfg_ctx); |
| 1245 | int i; |
| 1246 | |
| 1247 | max_mac_rings = max_mac_rings < MAX_RX_MAC_RINGS ? |
| 1248 | max_mac_rings : MAX_RX_MAC_RINGS; |
| 1249 | for (i = 0; i < MAX_RX_MAC_RINGS; i++) |
| 1250 | dp_srng_cleanup(soc, &pdev->rx_mac_buf_ring[i], |
| 1251 | RXDMA_BUF, 1); |
| 1252 | } |
| 1253 | #else |
| 1254 | static void dp_rxdma_ring_cleanup(struct dp_soc *soc, |
| 1255 | struct dp_pdev *pdev) |
| 1256 | { |
| 1257 | } |
| 1258 | #endif |
| 1259 | /* |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1260 | * dp_pdev_detach_wifi3() - detach txrx pdev |
| 1261 | * @txrx_pdev: Datapath PDEV handle |
| 1262 | * @force: Force detach |
| 1263 | * |
| 1264 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1265 | static void dp_pdev_detach_wifi3(struct cdp_pdev *txrx_pdev, int force) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1266 | { |
| 1267 | struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev; |
| 1268 | struct dp_soc *soc = pdev->soc; |
| 1269 | |
Vijay Pamidipati | d41d6d6 | 2016-10-19 21:19:00 +0530 | [diff] [blame] | 1270 | dp_tx_pdev_detach(pdev); |
| 1271 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1272 | if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) { |
| 1273 | dp_srng_cleanup(soc, &soc->tcl_data_ring[pdev->pdev_id], |
| 1274 | TCL_DATA, pdev->pdev_id); |
| 1275 | dp_srng_cleanup(soc, &soc->tx_comp_ring[pdev->pdev_id], |
| 1276 | WBM2SW_RELEASE, pdev->pdev_id); |
| 1277 | } |
| 1278 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1279 | dp_rx_pdev_detach(pdev); |
| 1280 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1281 | /* Setup per PDEV REO rings if configured */ |
| 1282 | if (wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) { |
| 1283 | dp_srng_cleanup(soc, &soc->reo_dest_ring[pdev->pdev_id], |
| 1284 | REO_DST, pdev->pdev_id); |
| 1285 | } |
| 1286 | |
Dhanashri Atre | 7351d17 | 2016-10-12 13:08:09 -0700 | [diff] [blame] | 1287 | dp_srng_cleanup(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1288 | |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1289 | dp_rxdma_ring_cleanup(soc, pdev); |
| 1290 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1291 | dp_srng_cleanup(soc, &pdev->rxdma_mon_buf_ring, RXDMA_MONITOR_BUF, 0); |
| 1292 | |
| 1293 | dp_srng_cleanup(soc, &pdev->rxdma_mon_dst_ring, RXDMA_MONITOR_DST, 0); |
| 1294 | |
| 1295 | dp_srng_cleanup(soc, &pdev->rxdma_mon_status_ring, |
| 1296 | RXDMA_MONITOR_STATUS, 0); |
| 1297 | |
| 1298 | soc->pdev_list[pdev->pdev_id] = NULL; |
| 1299 | |
| 1300 | qdf_mem_free(pdev); |
| 1301 | } |
| 1302 | |
| 1303 | /* |
Karunakar Dasineni | 8bebb00 | 2017-02-09 22:15:23 -0800 | [diff] [blame] | 1304 | * dp_reo_desc_freelist_destroy() - Flush REO descriptors from deferred freelist |
| 1305 | * @soc: DP SOC handle |
| 1306 | */ |
| 1307 | static inline void dp_reo_desc_freelist_destroy(struct dp_soc *soc) |
| 1308 | { |
| 1309 | struct reo_desc_list_node *desc; |
| 1310 | struct dp_rx_tid *rx_tid; |
| 1311 | |
| 1312 | qdf_spin_lock_bh(&soc->reo_desc_freelist_lock); |
| 1313 | while (qdf_list_remove_front(&soc->reo_desc_freelist, |
| 1314 | (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) { |
| 1315 | rx_tid = &desc->rx_tid; |
| 1316 | qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, |
| 1317 | rx_tid->hw_qdesc_alloc_size, |
| 1318 | rx_tid->hw_qdesc_vaddr_unaligned, |
| 1319 | rx_tid->hw_qdesc_paddr_unaligned, 0); |
| 1320 | qdf_mem_free(desc); |
| 1321 | } |
| 1322 | qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock); |
| 1323 | qdf_list_destroy(&soc->reo_desc_freelist); |
| 1324 | qdf_spinlock_destroy(&soc->reo_desc_freelist_lock); |
| 1325 | } |
| 1326 | |
| 1327 | /* |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1328 | * dp_soc_detach_wifi3() - Detach txrx SOC |
| 1329 | * @txrx_soc: DP SOC handle |
| 1330 | * |
| 1331 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 1332 | static void dp_soc_detach_wifi3(void *txrx_soc) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1333 | { |
| 1334 | struct dp_soc *soc = (struct dp_soc *)txrx_soc; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1335 | int i; |
| 1336 | |
Ravi Joshi | 86e9826 | 2017-03-01 13:47:03 -0800 | [diff] [blame] | 1337 | qdf_atomic_set(&soc->cmn_init_done, 0); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1338 | |
Pamidipati, Vijay | 692f00c | 2016-11-11 20:31:33 +0530 | [diff] [blame] | 1339 | dp_soc_interrupt_detach(soc); |
| 1340 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1341 | for (i = 0; i < MAX_PDEV_CNT; i++) { |
| 1342 | if (soc->pdev_list[i]) |
Kiran Venkatappa | 5dba3a3 | 2017-03-01 16:00:22 +0530 | [diff] [blame] | 1343 | dp_pdev_detach_wifi3( |
| 1344 | (struct cdp_pdev *)soc->pdev_list[i], 1); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | dp_peer_find_detach(soc); |
| 1348 | |
| 1349 | /* TBD: Call Tx and Rx cleanup functions to free buffers and |
| 1350 | * SW descriptors |
| 1351 | */ |
| 1352 | |
| 1353 | /* Free the ring memories */ |
| 1354 | /* Common rings */ |
| 1355 | dp_srng_cleanup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0); |
| 1356 | |
| 1357 | /* Tx data rings */ |
| 1358 | if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) { |
Vijay Pamidipati | d41d6d6 | 2016-10-19 21:19:00 +0530 | [diff] [blame] | 1359 | dp_tx_soc_detach(soc); |
| 1360 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1361 | for (i = 0; i < soc->num_tcl_data_rings; i++) { |
| 1362 | dp_srng_cleanup(soc, &soc->tcl_data_ring[i], |
| 1363 | TCL_DATA, i); |
| 1364 | dp_srng_cleanup(soc, &soc->tx_comp_ring[i], |
| 1365 | WBM2SW_RELEASE, i); |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | /* TCL command and status rings */ |
| 1370 | dp_srng_cleanup(soc, &soc->tcl_cmd_ring, TCL_CMD, 0); |
| 1371 | dp_srng_cleanup(soc, &soc->tcl_status_ring, TCL_STATUS, 0); |
| 1372 | |
| 1373 | /* Rx data rings */ |
| 1374 | if (!wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) { |
| 1375 | soc->num_reo_dest_rings = |
| 1376 | wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx); |
| 1377 | for (i = 0; i < soc->num_reo_dest_rings; i++) { |
| 1378 | /* TODO: Get number of rings and ring sizes |
| 1379 | * from wlan_cfg |
| 1380 | */ |
| 1381 | dp_srng_cleanup(soc, &soc->reo_dest_ring[i], |
| 1382 | REO_DST, i); |
| 1383 | } |
| 1384 | } |
| 1385 | /* REO reinjection ring */ |
| 1386 | dp_srng_cleanup(soc, &soc->reo_reinject_ring, REO_REINJECT, 0); |
| 1387 | |
| 1388 | /* Rx release ring */ |
| 1389 | dp_srng_cleanup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 0); |
| 1390 | |
| 1391 | /* Rx exception ring */ |
| 1392 | /* TODO: Better to store ring_type and ring_num in |
| 1393 | * dp_srng during setup |
| 1394 | */ |
| 1395 | dp_srng_cleanup(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0); |
| 1396 | |
| 1397 | /* REO command and status rings */ |
| 1398 | dp_srng_cleanup(soc, &soc->reo_cmd_ring, REO_CMD, 0); |
| 1399 | dp_srng_cleanup(soc, &soc->reo_status_ring, REO_STATUS, 0); |
Karunakar Dasineni | 8bebb00 | 2017-02-09 22:15:23 -0800 | [diff] [blame] | 1400 | |
Manoj Ekbote | 4f0c6b1 | 2016-10-30 16:01:38 -0700 | [diff] [blame] | 1401 | qdf_spinlock_destroy(&soc->rx.reo_cmd_lock); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1402 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1403 | qdf_spinlock_destroy(&soc->peer_ref_mutex); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1404 | htt_soc_detach(soc->htt_handle); |
Karunakar Dasineni | 8bebb00 | 2017-02-09 22:15:23 -0800 | [diff] [blame] | 1405 | |
| 1406 | dp_reo_desc_freelist_destroy(soc); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1407 | } |
| 1408 | |
| 1409 | /* |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1410 | * dp_rxdma_ring_config() - configure the RX DMA rings |
| 1411 | * |
| 1412 | * This function is used to configure the MAC rings. |
| 1413 | * On MCL host provides buffers in Host2FW ring |
| 1414 | * FW refills (copies) buffers to the ring and updates |
| 1415 | * ring_idx in register |
| 1416 | * |
| 1417 | * @soc: data path SoC handle |
| 1418 | * @pdev: Physical device handle |
| 1419 | * |
| 1420 | * Return: void |
| 1421 | */ |
| 1422 | #ifdef QCA_HOST2FW_RXBUF_RING |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1423 | static void dp_rxdma_ring_config(struct dp_soc *soc) |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1424 | { |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1425 | int i; |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1426 | |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1427 | for (i = 0; i < MAX_PDEV_CNT; i++) { |
| 1428 | struct dp_pdev *pdev = soc->pdev_list[i]; |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1429 | |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1430 | if (pdev) { |
| 1431 | int mac_id = 0; |
| 1432 | int j; |
| 1433 | int max_mac_rings = |
| 1434 | wlan_cfg_get_num_mac_rings |
| 1435 | (pdev->wlan_cfg_ctx); |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1436 | |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1437 | htt_srng_setup(soc->htt_handle, 0, |
| 1438 | pdev->rx_refill_buf_ring.hal_srng, |
| 1439 | RXDMA_BUF); |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1440 | |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1441 | if (!soc->cdp_soc.ol_ops-> |
| 1442 | is_hw_dbs_2x2_capable()) { |
| 1443 | max_mac_rings = 1; |
| 1444 | QDF_TRACE(QDF_MODULE_ID_TXRX, |
| 1445 | QDF_TRACE_LEVEL_ERROR, |
| 1446 | FL("DBS enabled, max_mac_rings %d\n"), |
| 1447 | max_mac_rings); |
| 1448 | } else { |
| 1449 | QDF_TRACE(QDF_MODULE_ID_TXRX, |
| 1450 | QDF_TRACE_LEVEL_ERROR, |
| 1451 | FL("DBS disabled max_mac_rings %d\n"), |
| 1452 | max_mac_rings); |
| 1453 | } |
| 1454 | |
| 1455 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 1456 | FL("pdev_id %d max_mac_rings %d\n"), |
| 1457 | pdev->pdev_id, max_mac_rings); |
| 1458 | |
| 1459 | for (j = 0; j < max_mac_rings; j++) { |
| 1460 | QDF_TRACE(QDF_MODULE_ID_TXRX, |
| 1461 | QDF_TRACE_LEVEL_ERROR, |
| 1462 | FL("mac_id %d\n"), mac_id); |
| 1463 | htt_srng_setup(soc->htt_handle, mac_id, |
| 1464 | pdev->rx_mac_buf_ring[j] |
| 1465 | .hal_srng, |
| 1466 | RXDMA_BUF); |
| 1467 | mac_id++; |
| 1468 | } |
| 1469 | } |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1470 | } |
| 1471 | } |
| 1472 | #else |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1473 | static void dp_rxdma_ring_config(struct dp_soc *soc) |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1474 | { |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1475 | int i; |
| 1476 | |
| 1477 | for (i = 0; i < MAX_PDEV_CNT; i++) { |
| 1478 | struct dp_pdev *pdev = soc->pdev_list[i]; |
| 1479 | |
| 1480 | if (pdev) { |
| 1481 | htt_srng_setup(soc->htt_handle, i, |
| 1482 | pdev->rx_refill_buf_ring.hal_srng, RXDMA_BUF); |
| 1483 | } |
| 1484 | } |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1485 | } |
| 1486 | #endif |
| 1487 | |
| 1488 | /* |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1489 | * dp_soc_attach_target_wifi3() - SOC initialization in the target |
| 1490 | * @txrx_soc: Datapath SOC handle |
| 1491 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 1492 | static int dp_soc_attach_target_wifi3(struct cdp_soc_t *cdp_soc) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1493 | { |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1494 | struct dp_soc *soc = (struct dp_soc *)cdp_soc; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1495 | |
| 1496 | htt_soc_attach_target(soc->htt_handle); |
| 1497 | |
Dhanashri Atre | 2ea8c0f | 2017-02-08 11:09:56 -0800 | [diff] [blame] | 1498 | dp_rxdma_ring_config(soc); |
Dhanashri Atre | d4032ab | 2017-01-17 15:05:41 -0800 | [diff] [blame] | 1499 | |
Ishank Jain | bc2d91f | 2017-01-03 18:14:54 +0530 | [diff] [blame] | 1500 | DP_STATS_INIT(soc); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1501 | return 0; |
| 1502 | } |
| 1503 | |
| 1504 | /* |
| 1505 | * dp_vdev_attach_wifi3() - attach txrx vdev |
| 1506 | * @txrx_pdev: Datapath PDEV handle |
| 1507 | * @vdev_mac_addr: MAC address of the virtual interface |
| 1508 | * @vdev_id: VDEV Id |
| 1509 | * @wlan_op_mode: VDEV operating mode |
| 1510 | * |
| 1511 | * Return: DP VDEV handle on success, NULL on failure |
| 1512 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1513 | static struct cdp_vdev *dp_vdev_attach_wifi3(struct cdp_pdev *txrx_pdev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1514 | uint8_t *vdev_mac_addr, uint8_t vdev_id, enum wlan_op_mode op_mode) |
| 1515 | { |
| 1516 | struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev; |
| 1517 | struct dp_soc *soc = pdev->soc; |
| 1518 | struct dp_vdev *vdev = qdf_mem_malloc(sizeof(*vdev)); |
| 1519 | |
| 1520 | if (!vdev) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1521 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1522 | FL("DP VDEV memory allocation failed")); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1523 | goto fail0; |
| 1524 | } |
| 1525 | |
| 1526 | vdev->pdev = pdev; |
| 1527 | vdev->vdev_id = vdev_id; |
| 1528 | vdev->opmode = op_mode; |
Vijay Pamidipati | d41d6d6 | 2016-10-19 21:19:00 +0530 | [diff] [blame] | 1529 | vdev->osdev = soc->osdev; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1530 | |
| 1531 | vdev->osif_rx = NULL; |
Venkateswara Swamy Bandaru | bfbef4f | 2016-12-16 19:12:31 +0530 | [diff] [blame] | 1532 | vdev->osif_rsim_rx_decap = NULL; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1533 | vdev->osif_rx_mon = NULL; |
Venkateswara Swamy Bandaru | 9748234 | 2017-02-16 12:04:50 +0530 | [diff] [blame] | 1534 | vdev->osif_tx_free_ext = NULL; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1535 | vdev->osif_vdev = NULL; |
| 1536 | |
| 1537 | vdev->delete.pending = 0; |
| 1538 | vdev->safemode = 0; |
| 1539 | vdev->drop_unenc = 1; |
| 1540 | #ifdef notyet |
| 1541 | vdev->filters_num = 0; |
| 1542 | #endif |
| 1543 | |
| 1544 | qdf_mem_copy( |
| 1545 | &vdev->mac_addr.raw[0], vdev_mac_addr, OL_TXRX_MAC_ADDR_LEN); |
| 1546 | |
| 1547 | vdev->tx_encap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx); |
| 1548 | vdev->rx_decap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx); |
Ishank Jain | 949674c | 2017-02-27 17:09:29 +0530 | [diff] [blame] | 1549 | vdev->dscp_tid_map_id = 0; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1550 | |
| 1551 | /* TODO: Initialize default HTT meta data that will be used in |
| 1552 | * TCL descriptors for packets transmitted from this VDEV |
| 1553 | */ |
| 1554 | |
| 1555 | TAILQ_INIT(&vdev->peer_list); |
| 1556 | |
| 1557 | /* add this vdev into the pdev's list */ |
| 1558 | TAILQ_INSERT_TAIL(&pdev->vdev_list, vdev, vdev_list_elem); |
| 1559 | pdev->vdev_count++; |
| 1560 | |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 1561 | dp_tx_vdev_attach(vdev); |
| 1562 | |
Vijay Pamidipati | 88c40ff | 2016-11-17 21:27:02 +0530 | [diff] [blame] | 1563 | #ifdef DP_INTR_POLL_BASED |
| 1564 | if (pdev->vdev_count == 1) |
| 1565 | qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS); |
| 1566 | #endif |
| 1567 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1568 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1569 | "Created vdev %p (%pM)", vdev, vdev->mac_addr.raw); |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 1570 | DP_STATS_INIT(vdev); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1571 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1572 | return (struct cdp_vdev *)vdev; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1573 | |
| 1574 | fail0: |
| 1575 | return NULL; |
| 1576 | } |
| 1577 | |
| 1578 | /** |
| 1579 | * dp_vdev_register_wifi3() - Register VDEV operations from osif layer |
| 1580 | * @vdev: Datapath VDEV handle |
| 1581 | * @osif_vdev: OSIF vdev handle |
| 1582 | * @txrx_ops: Tx and Rx operations |
| 1583 | * |
| 1584 | * Return: DP VDEV handle on success, NULL on failure |
| 1585 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1586 | static void dp_vdev_register_wifi3(struct cdp_vdev *vdev_handle, |
| 1587 | void *osif_vdev, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1588 | struct ol_txrx_ops *txrx_ops) |
| 1589 | { |
| 1590 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 1591 | vdev->osif_vdev = osif_vdev; |
| 1592 | vdev->osif_rx = txrx_ops->rx.rx; |
Venkateswara Swamy Bandaru | bfbef4f | 2016-12-16 19:12:31 +0530 | [diff] [blame] | 1593 | vdev->osif_rsim_rx_decap = txrx_ops->rx.rsim_rx_decap; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1594 | vdev->osif_rx_mon = txrx_ops->rx.mon; |
Venkateswara Swamy Bandaru | 9748234 | 2017-02-16 12:04:50 +0530 | [diff] [blame] | 1595 | vdev->osif_tx_free_ext = txrx_ops->tx.tx_free_ext; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1596 | #ifdef notyet |
| 1597 | #if ATH_SUPPORT_WAPI |
| 1598 | vdev->osif_check_wai = txrx_ops->rx.wai_check; |
| 1599 | #endif |
| 1600 | #if UMAC_SUPPORT_PROXY_ARP |
| 1601 | vdev->osif_proxy_arp = txrx_ops->proxy_arp; |
| 1602 | #endif |
| 1603 | #endif |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1604 | /* TODO: Enable the following once Tx code is integrated */ |
| 1605 | txrx_ops->tx.tx = dp_tx_send; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1606 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1607 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, |
| 1608 | "DP Vdev Register success"); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | /* |
| 1612 | * dp_vdev_detach_wifi3() - Detach txrx vdev |
| 1613 | * @txrx_vdev: Datapath VDEV handle |
| 1614 | * @callback: Callback OL_IF on completion of detach |
| 1615 | * @cb_context: Callback context |
| 1616 | * |
| 1617 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1618 | static void dp_vdev_detach_wifi3(struct cdp_vdev *vdev_handle, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1619 | ol_txrx_vdev_delete_cb callback, void *cb_context) |
| 1620 | { |
| 1621 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 1622 | struct dp_pdev *pdev = vdev->pdev; |
| 1623 | struct dp_soc *soc = pdev->soc; |
| 1624 | |
| 1625 | /* preconditions */ |
| 1626 | qdf_assert(vdev); |
| 1627 | |
| 1628 | /* remove the vdev from its parent pdev's list */ |
| 1629 | TAILQ_REMOVE(&pdev->vdev_list, vdev, vdev_list_elem); |
| 1630 | |
| 1631 | /* |
| 1632 | * Use peer_ref_mutex while accessing peer_list, in case |
| 1633 | * a peer is in the process of being removed from the list. |
| 1634 | */ |
| 1635 | qdf_spin_lock_bh(&soc->peer_ref_mutex); |
| 1636 | /* check that the vdev has no peers allocated */ |
| 1637 | if (!TAILQ_EMPTY(&vdev->peer_list)) { |
| 1638 | /* debug print - will be removed later */ |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1639 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN, |
| 1640 | FL("not deleting vdev object %p (%pM)" |
| 1641 | "until deletion finishes for all its peers"), |
| 1642 | vdev, vdev->mac_addr.raw); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1643 | /* indicate that the vdev needs to be deleted */ |
| 1644 | vdev->delete.pending = 1; |
| 1645 | vdev->delete.callback = callback; |
| 1646 | vdev->delete.context = cb_context; |
| 1647 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1648 | return; |
| 1649 | } |
| 1650 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1651 | |
Pamidipati, Vijay | 576bd15 | 2016-09-27 20:58:18 +0530 | [diff] [blame] | 1652 | dp_tx_vdev_detach(vdev); |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1653 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
| 1654 | FL("deleting vdev object %p (%pM)"), vdev, vdev->mac_addr.raw); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1655 | |
| 1656 | qdf_mem_free(vdev); |
| 1657 | |
| 1658 | if (callback) |
| 1659 | callback(cb_context); |
| 1660 | } |
| 1661 | |
| 1662 | /* |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 1663 | * dp_peer_create_wifi3() - attach txrx peer |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1664 | * @txrx_vdev: Datapath VDEV handle |
| 1665 | * @peer_mac_addr: Peer MAC address |
| 1666 | * |
| 1667 | * Return: DP peeer handle on success, NULL on failure |
| 1668 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1669 | static void *dp_peer_create_wifi3(struct cdp_vdev *vdev_handle, |
| 1670 | uint8_t *peer_mac_addr) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1671 | { |
| 1672 | struct dp_peer *peer; |
| 1673 | int i; |
| 1674 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 1675 | struct dp_pdev *pdev; |
| 1676 | struct dp_soc *soc; |
| 1677 | |
| 1678 | /* preconditions */ |
| 1679 | qdf_assert(vdev); |
| 1680 | qdf_assert(peer_mac_addr); |
| 1681 | |
| 1682 | pdev = vdev->pdev; |
| 1683 | soc = pdev->soc; |
| 1684 | #ifdef notyet |
| 1685 | peer = (struct dp_peer *)qdf_mempool_alloc(soc->osdev, |
| 1686 | soc->mempool_ol_ath_peer); |
| 1687 | #else |
| 1688 | peer = (struct dp_peer *)qdf_mem_malloc(sizeof(*peer)); |
| 1689 | #endif |
| 1690 | |
| 1691 | if (!peer) |
| 1692 | return NULL; /* failure */ |
| 1693 | |
| 1694 | qdf_mem_zero(peer, sizeof(struct dp_peer)); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1695 | qdf_spinlock_create(&peer->peer_info_lock); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1696 | |
| 1697 | /* store provided params */ |
| 1698 | peer->vdev = vdev; |
| 1699 | qdf_mem_copy( |
| 1700 | &peer->mac_addr.raw[0], peer_mac_addr, OL_TXRX_MAC_ADDR_LEN); |
| 1701 | |
| 1702 | /* TODO: See of rx_opt_proc is really required */ |
| 1703 | peer->rx_opt_proc = soc->rx_opt_proc; |
| 1704 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1705 | /* initialize the peer_id */ |
| 1706 | for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++) |
| 1707 | peer->peer_ids[i] = HTT_INVALID_PEER; |
| 1708 | |
| 1709 | qdf_spin_lock_bh(&soc->peer_ref_mutex); |
| 1710 | |
| 1711 | qdf_atomic_init(&peer->ref_cnt); |
| 1712 | |
| 1713 | /* keep one reference for attach */ |
| 1714 | qdf_atomic_inc(&peer->ref_cnt); |
| 1715 | |
| 1716 | /* add this peer into the vdev's list */ |
| 1717 | TAILQ_INSERT_TAIL(&vdev->peer_list, peer, peer_list_elem); |
| 1718 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1719 | |
| 1720 | /* TODO: See if hash based search is required */ |
| 1721 | dp_peer_find_hash_add(soc, peer); |
| 1722 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1723 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
Krishna Kumaar Natarajan | 71e5b83 | 2017-01-26 08:04:13 -0800 | [diff] [blame] | 1724 | "vdev %p created peer %p (%pM) ref_cnt: %d", |
| 1725 | vdev, peer, peer->mac_addr.raw, |
| 1726 | qdf_atomic_read(&peer->ref_cnt)); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1727 | /* |
| 1728 | * For every peer MAp message search and set if bss_peer |
| 1729 | */ |
| 1730 | if (memcmp(peer->mac_addr.raw, vdev->mac_addr.raw, 6) == 0) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1731 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
| 1732 | "vdev bss_peer!!!!"); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1733 | peer->bss_peer = 1; |
| 1734 | vdev->vap_bss_peer = peer; |
| 1735 | } |
| 1736 | |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 1737 | #ifndef CONFIG_WIN |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1738 | dp_local_peer_id_alloc(pdev, peer); |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 1739 | #endif |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 1740 | DP_STATS_INIT(peer); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1741 | return (void *)peer; |
| 1742 | } |
| 1743 | |
| 1744 | /* |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 1745 | * dp_peer_setup_wifi3() - initialize the peer |
| 1746 | * @vdev_hdl: virtual device object |
| 1747 | * @peer: Peer object |
| 1748 | * |
| 1749 | * Return: void |
| 1750 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1751 | static void dp_peer_setup_wifi3(struct cdp_vdev *vdev_hdl, void *peer_hdl) |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 1752 | { |
| 1753 | struct dp_peer *peer = (struct dp_peer *)peer_hdl; |
| 1754 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl; |
| 1755 | struct dp_pdev *pdev; |
| 1756 | struct dp_soc *soc; |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 1757 | bool hash_based = 0; |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 1758 | |
| 1759 | /* preconditions */ |
| 1760 | qdf_assert(vdev); |
| 1761 | qdf_assert(peer); |
| 1762 | |
| 1763 | pdev = vdev->pdev; |
| 1764 | soc = pdev->soc; |
| 1765 | |
| 1766 | dp_peer_rx_init(pdev, peer); |
| 1767 | |
Krishna Kumaar Natarajan | d684ba2 | 2017-01-25 15:48:43 -0800 | [diff] [blame] | 1768 | peer->last_assoc_rcvd = 0; |
| 1769 | peer->last_disassoc_rcvd = 0; |
| 1770 | peer->last_deauth_rcvd = 0; |
| 1771 | |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 1772 | hash_based = wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx); |
| 1773 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1774 | FL("hash based steering %d\n"), hash_based); |
| 1775 | |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 1776 | if (soc->cdp_soc.ol_ops->peer_set_default_routing) { |
| 1777 | /* TODO: Check the destination ring number to be passed to FW */ |
Dhanashri Atre | 1404917 | 2016-11-11 18:32:36 -0800 | [diff] [blame] | 1778 | soc->cdp_soc.ol_ops->peer_set_default_routing( |
| 1779 | pdev->osif_pdev, peer->mac_addr.raw, |
| 1780 | peer->vdev->vdev_id, hash_based, 1); |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 1781 | } |
| 1782 | return; |
| 1783 | } |
| 1784 | |
| 1785 | /* |
Kalyan Tallapragada | 277f45e | 2017-01-30 14:25:27 +0530 | [diff] [blame] | 1786 | * dp_set_vdev_tx_encap_type() - set the encap type of the vdev |
| 1787 | * @vdev_handle: virtual device object |
| 1788 | * @htt_pkt_type: type of pkt |
| 1789 | * |
| 1790 | * Return: void |
| 1791 | */ |
| 1792 | static void dp_set_vdev_tx_encap_type(struct cdp_vdev *vdev_handle, |
| 1793 | enum htt_cmn_pkt_type val) |
| 1794 | { |
| 1795 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 1796 | vdev->tx_encap_type = val; |
| 1797 | } |
| 1798 | |
| 1799 | /* |
| 1800 | * dp_set_vdev_rx_decap_type() - set the decap type of the vdev |
| 1801 | * @vdev_handle: virtual device object |
| 1802 | * @htt_pkt_type: type of pkt |
| 1803 | * |
| 1804 | * Return: void |
| 1805 | */ |
| 1806 | static void dp_set_vdev_rx_decap_type(struct cdp_vdev *vdev_handle, |
| 1807 | enum htt_cmn_pkt_type val) |
| 1808 | { |
| 1809 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 1810 | vdev->rx_decap_type = val; |
| 1811 | } |
| 1812 | |
| 1813 | /* |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1814 | * dp_peer_authorize() - authorize txrx peer |
| 1815 | * @peer_handle: Datapath peer handle |
| 1816 | * @authorize |
| 1817 | * |
| 1818 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 1819 | static void dp_peer_authorize(void *peer_handle, uint32_t authorize) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1820 | { |
| 1821 | struct dp_peer *peer = (struct dp_peer *)peer_handle; |
| 1822 | struct dp_soc *soc; |
| 1823 | |
| 1824 | if (peer != NULL) { |
| 1825 | soc = peer->vdev->pdev->soc; |
| 1826 | |
| 1827 | qdf_spin_lock_bh(&soc->peer_ref_mutex); |
| 1828 | peer->authorize = authorize ? 1 : 0; |
| 1829 | #ifdef notyet /* ATH_BAND_STEERING */ |
| 1830 | peer->peer_bs_inact_flag = 0; |
| 1831 | peer->peer_bs_inact = soc->pdev_bs_inact_reload; |
| 1832 | #endif |
| 1833 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1834 | } |
| 1835 | } |
| 1836 | |
| 1837 | /* |
| 1838 | * dp_peer_unref_delete() - unref and delete peer |
| 1839 | * @peer_handle: Datapath peer handle |
| 1840 | * |
| 1841 | */ |
| 1842 | void dp_peer_unref_delete(void *peer_handle) |
| 1843 | { |
| 1844 | struct dp_peer *peer = (struct dp_peer *)peer_handle; |
| 1845 | struct dp_vdev *vdev = peer->vdev; |
Kiran Venkatappa | 9edb961 | 2017-03-16 11:37:35 +0530 | [diff] [blame] | 1846 | struct dp_pdev *pdev = vdev->pdev; |
| 1847 | struct dp_soc *soc = pdev->soc; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1848 | struct dp_peer *tmppeer; |
| 1849 | int found = 0; |
| 1850 | uint16_t peer_id; |
| 1851 | |
| 1852 | /* |
| 1853 | * Hold the lock all the way from checking if the peer ref count |
| 1854 | * is zero until the peer references are removed from the hash |
| 1855 | * table and vdev list (if the peer ref count is zero). |
| 1856 | * This protects against a new HL tx operation starting to use the |
| 1857 | * peer object just after this function concludes it's done being used. |
| 1858 | * Furthermore, the lock needs to be held while checking whether the |
| 1859 | * vdev's list of peers is empty, to make sure that list is not modified |
| 1860 | * concurrently with the empty check. |
| 1861 | */ |
| 1862 | qdf_spin_lock_bh(&soc->peer_ref_mutex); |
Krishna Kumaar Natarajan | 71e5b83 | 2017-01-26 08:04:13 -0800 | [diff] [blame] | 1863 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 1864 | "%s: peer %p ref_cnt(before decrement): %d\n", __func__, |
| 1865 | peer, qdf_atomic_read(&peer->ref_cnt)); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1866 | if (qdf_atomic_dec_and_test(&peer->ref_cnt)) { |
| 1867 | peer_id = peer->peer_ids[0]; |
| 1868 | |
| 1869 | /* |
| 1870 | * Make sure that the reference to the peer in |
| 1871 | * peer object map is removed |
| 1872 | */ |
| 1873 | if (peer_id != HTT_INVALID_PEER) |
| 1874 | soc->peer_id_to_obj_map[peer_id] = NULL; |
| 1875 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1876 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
| 1877 | "Deleting peer %p (%pM)", peer, peer->mac_addr.raw); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1878 | |
| 1879 | /* remove the reference to the peer from the hash table */ |
| 1880 | dp_peer_find_hash_remove(soc, peer); |
| 1881 | |
| 1882 | TAILQ_FOREACH(tmppeer, &peer->vdev->peer_list, peer_list_elem) { |
| 1883 | if (tmppeer == peer) { |
| 1884 | found = 1; |
| 1885 | break; |
| 1886 | } |
| 1887 | } |
| 1888 | if (found) { |
| 1889 | TAILQ_REMOVE(&peer->vdev->peer_list, peer, |
| 1890 | peer_list_elem); |
| 1891 | } else { |
| 1892 | /*Ignoring the remove operation as peer not found*/ |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1893 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN, |
| 1894 | "peer %p not found in vdev (%p)->peer_list:%p", |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1895 | peer, vdev, &peer->vdev->peer_list); |
| 1896 | } |
| 1897 | |
Krishna Kumaar Natarajan | d684ba2 | 2017-01-25 15:48:43 -0800 | [diff] [blame] | 1898 | /* cleanup the peer data */ |
| 1899 | dp_peer_cleanup(vdev, peer); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1900 | |
| 1901 | /* check whether the parent vdev has no peers left */ |
| 1902 | if (TAILQ_EMPTY(&vdev->peer_list)) { |
| 1903 | /* |
| 1904 | * Now that there are no references to the peer, we can |
| 1905 | * release the peer reference lock. |
| 1906 | */ |
| 1907 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1908 | /* |
| 1909 | * Check if the parent vdev was waiting for its peers |
| 1910 | * to be deleted, in order for it to be deleted too. |
| 1911 | */ |
| 1912 | if (vdev->delete.pending) { |
| 1913 | ol_txrx_vdev_delete_cb vdev_delete_cb = |
| 1914 | vdev->delete.callback; |
| 1915 | void *vdev_delete_context = |
| 1916 | vdev->delete.context; |
| 1917 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1918 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1919 | QDF_TRACE_LEVEL_INFO_HIGH, |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1920 | FL("deleting vdev object %p (%pM)" |
| 1921 | " - its last peer is done"), |
| 1922 | vdev, vdev->mac_addr.raw); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1923 | /* all peers are gone, go ahead and delete it */ |
| 1924 | qdf_mem_free(vdev); |
| 1925 | if (vdev_delete_cb) |
| 1926 | vdev_delete_cb(vdev_delete_context); |
| 1927 | } |
| 1928 | } else { |
| 1929 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1930 | } |
| 1931 | #ifdef notyet |
| 1932 | qdf_mempool_free(soc->osdev, soc->mempool_ol_ath_peer, peer); |
| 1933 | #else |
| 1934 | qdf_mem_free(peer); |
| 1935 | #endif |
Pamidipati, Vijay | b31b6b1 | 2016-11-11 16:46:13 +0530 | [diff] [blame] | 1936 | if (soc->cdp_soc.ol_ops->peer_unref_delete) { |
Kiran Venkatappa | 9edb961 | 2017-03-16 11:37:35 +0530 | [diff] [blame] | 1937 | soc->cdp_soc.ol_ops->peer_unref_delete(pdev->osif_pdev, |
Vijay Pamidipati | da06116 | 2017-01-17 12:53:05 +0530 | [diff] [blame] | 1938 | vdev->vdev_id, peer->mac_addr.raw); |
Pamidipati, Vijay | b31b6b1 | 2016-11-11 16:46:13 +0530 | [diff] [blame] | 1939 | } |
Vijay Pamidipati | da06116 | 2017-01-17 12:53:05 +0530 | [diff] [blame] | 1940 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1941 | } else { |
| 1942 | qdf_spin_unlock_bh(&soc->peer_ref_mutex); |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | /* |
| 1947 | * dp_peer_detach_wifi3() – Detach txrx peer |
| 1948 | * @peer_handle: Datapath peer handle |
| 1949 | * |
| 1950 | */ |
Jeff Johnson | f135257 | 2017-01-10 14:24:10 -0800 | [diff] [blame] | 1951 | static void dp_peer_delete_wifi3(void *peer_handle) |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1952 | { |
| 1953 | struct dp_peer *peer = (struct dp_peer *)peer_handle; |
| 1954 | |
| 1955 | /* redirect the peer's rx delivery function to point to a |
| 1956 | * discard func |
| 1957 | */ |
| 1958 | peer->rx_opt_proc = dp_rx_discard; |
| 1959 | |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 1960 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, |
| 1961 | FL("peer %p (%pM)"), peer, peer->mac_addr.raw); |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1962 | |
Krishna Kumaar Natarajan | 604fe16 | 2017-01-28 18:37:01 -0800 | [diff] [blame] | 1963 | #ifndef CONFIG_WIN |
| 1964 | dp_local_peer_id_free(peer->vdev->pdev, peer); |
| 1965 | #endif |
| 1966 | qdf_spinlock_destroy(&peer->peer_info_lock); |
| 1967 | |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 1968 | /* |
| 1969 | * Remove the reference added during peer_attach. |
| 1970 | * The peer will still be left allocated until the |
| 1971 | * PEER_UNMAP message arrives to remove the other |
| 1972 | * reference, added by the PEER_MAP message. |
| 1973 | */ |
| 1974 | dp_peer_unref_delete(peer_handle); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1975 | } |
| 1976 | |
| 1977 | /* |
| 1978 | * dp_get_vdev_mac_addr_wifi3() – Detach txrx peer |
| 1979 | * @peer_handle: Datapath peer handle |
| 1980 | * |
| 1981 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1982 | static uint8 *dp_get_vdev_mac_addr_wifi3(struct cdp_vdev *pvdev) |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1983 | { |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1984 | struct dp_vdev *vdev = (struct dp_vdev *)pvdev; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1985 | |
| 1986 | return vdev->mac_addr.raw; |
| 1987 | } |
| 1988 | |
| 1989 | /* |
| 1990 | * dp_get_vdev_from_vdev_id_wifi3() – Detach txrx peer |
| 1991 | * @peer_handle: Datapath peer handle |
| 1992 | * |
| 1993 | */ |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1994 | static struct cdp_vdev *dp_get_vdev_from_vdev_id_wifi3(struct cdp_pdev *dev, |
| 1995 | uint8_t vdev_id) |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1996 | { |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 1997 | struct dp_pdev *pdev = (struct dp_pdev *)dev; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 1998 | struct dp_vdev *vdev = NULL; |
| 1999 | |
| 2000 | if (qdf_unlikely(!pdev)) |
| 2001 | return NULL; |
| 2002 | |
| 2003 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
| 2004 | if (vdev->vdev_id == vdev_id) |
| 2005 | break; |
| 2006 | } |
| 2007 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 2008 | return (struct cdp_vdev *)vdev; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2009 | } |
| 2010 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 2011 | static int dp_get_opmode(struct cdp_vdev *vdev_handle) |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2012 | { |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 2013 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2014 | |
| 2015 | return vdev->opmode; |
| 2016 | } |
| 2017 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 2018 | static struct cdp_cfg *dp_get_ctrl_pdev_from_vdev_wifi3(struct cdp_vdev *pvdev) |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2019 | { |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 2020 | struct dp_vdev *vdev = (struct dp_vdev *)pvdev; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2021 | struct dp_pdev *pdev = vdev->pdev; |
| 2022 | |
Venkata Sharath Chandra Manchala | f2a125a | 2016-11-28 18:10:11 -0800 | [diff] [blame] | 2023 | return (struct cdp_cfg *)pdev->wlan_cfg_ctx; |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2024 | } |
| 2025 | |
Venkateswara Swamy Bandaru | 3f62370 | 2017-02-25 00:12:59 +0530 | [diff] [blame] | 2026 | #ifdef MESH_MODE_SUPPORT |
Venkateswara Swamy Bandaru | ec4f8e6 | 2017-03-07 11:04:28 +0530 | [diff] [blame] | 2027 | void dp_peer_set_mesh_mode(struct cdp_vdev *vdev_hdl, uint32_t val) |
Venkateswara Swamy Bandaru | 3f62370 | 2017-02-25 00:12:59 +0530 | [diff] [blame] | 2028 | { |
| 2029 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl; |
| 2030 | |
| 2031 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, |
Venkateswara Swamy Bandaru | 5caa83a | 2017-03-06 11:33:15 +0530 | [diff] [blame] | 2032 | FL("val %d"), val); |
Venkateswara Swamy Bandaru | 3f62370 | 2017-02-25 00:12:59 +0530 | [diff] [blame] | 2033 | vdev->mesh_vdev = val; |
| 2034 | } |
Venkateswara Swamy Bandaru | ec4f8e6 | 2017-03-07 11:04:28 +0530 | [diff] [blame] | 2035 | |
| 2036 | /* |
| 2037 | * dp_peer_set_mesh_rx_filter() - to set the mesh rx filter |
| 2038 | * @vdev_hdl: virtual device object |
| 2039 | * @val: value to be set |
| 2040 | * |
| 2041 | * Return: void |
| 2042 | */ |
| 2043 | void dp_peer_set_mesh_rx_filter(struct cdp_vdev *vdev_hdl, uint32_t val) |
| 2044 | { |
| 2045 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl; |
| 2046 | |
| 2047 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, |
| 2048 | FL("val %d"), val); |
| 2049 | vdev->mesh_rx_filter = val; |
| 2050 | } |
Venkateswara Swamy Bandaru | 3f62370 | 2017-02-25 00:12:59 +0530 | [diff] [blame] | 2051 | #endif |
| 2052 | |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 2053 | /** |
| 2054 | * dp_aggregate_vdev_stats(): Consolidate stats at VDEV level |
| 2055 | * @vdev: DP VDEV handle |
| 2056 | * |
| 2057 | * return: void |
| 2058 | */ |
| 2059 | void dp_aggregate_vdev_stats(struct dp_vdev *vdev) |
| 2060 | { |
| 2061 | struct dp_peer *peer = NULL; |
| 2062 | int i; |
| 2063 | |
| 2064 | qdf_mem_set(&(vdev->stats.tx), sizeof(vdev->stats.tx), 0x0); |
| 2065 | qdf_mem_set(&(vdev->stats.rx), sizeof(vdev->stats.rx), 0x0); |
| 2066 | |
| 2067 | TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) { |
| 2068 | if (!peer) |
| 2069 | return; |
| 2070 | |
| 2071 | for (i = 0; i <= MAX_MCS; i++) { |
| 2072 | DP_STATS_AGGR(vdev, peer, tx.pkt_type[0].mcs_count[i]); |
| 2073 | DP_STATS_AGGR(vdev, peer, tx.pkt_type[1].mcs_count[i]); |
| 2074 | DP_STATS_AGGR(vdev, peer, tx.pkt_type[2].mcs_count[i]); |
| 2075 | DP_STATS_AGGR(vdev, peer, tx.pkt_type[3].mcs_count[i]); |
| 2076 | DP_STATS_AGGR(vdev, peer, tx.pkt_type[4].mcs_count[i]); |
| 2077 | DP_STATS_AGGR(vdev, peer, rx.mcs_count[i]); |
| 2078 | } |
| 2079 | |
| 2080 | for (i = 0; i < SUPPORTED_BW; i++) { |
| 2081 | DP_STATS_AGGR(vdev, peer, tx.bw[i]); |
| 2082 | DP_STATS_AGGR(vdev, peer, rx.bw[i]); |
| 2083 | } |
| 2084 | |
| 2085 | for (i = 0; i < SS_COUNT; i++) |
| 2086 | DP_STATS_AGGR(vdev, peer, rx.nss[i]); |
| 2087 | |
| 2088 | for (i = 0; i < WME_AC_MAX; i++) { |
| 2089 | DP_STATS_AGGR(vdev, peer, tx.wme_ac_type[i]); |
| 2090 | DP_STATS_AGGR(vdev, peer, rx.wme_ac_type[i]); |
| 2091 | DP_STATS_AGGR(vdev, peer, tx.excess_retries_ac[i]); |
| 2092 | |
| 2093 | } |
| 2094 | |
| 2095 | for (i = 0; i < MAX_MCS + 1; i++) { |
| 2096 | DP_STATS_AGGR(vdev, peer, tx.sgi_count[i]); |
| 2097 | DP_STATS_AGGR(vdev, peer, rx.sgi_count[i]); |
| 2098 | } |
| 2099 | |
| 2100 | DP_STATS_AGGR_PKT(vdev, peer, tx.comp_pkt); |
| 2101 | DP_STATS_AGGR_PKT(vdev, peer, tx.ucast); |
| 2102 | DP_STATS_AGGR_PKT(vdev, peer, tx.mcast); |
| 2103 | DP_STATS_AGGR_PKT(vdev, peer, tx.tx_success); |
| 2104 | DP_STATS_AGGR(vdev, peer, tx.tx_failed); |
| 2105 | DP_STATS_AGGR(vdev, peer, tx.ofdma); |
| 2106 | DP_STATS_AGGR(vdev, peer, tx.stbc); |
| 2107 | DP_STATS_AGGR(vdev, peer, tx.ldpc); |
| 2108 | DP_STATS_AGGR(vdev, peer, tx.retries); |
| 2109 | DP_STATS_AGGR(vdev, peer, tx.non_amsdu_cnt); |
| 2110 | DP_STATS_AGGR(vdev, peer, tx.amsdu_cnt); |
| 2111 | DP_STATS_AGGR(vdev, peer, tx.dropped.dma_map_error); |
| 2112 | DP_STATS_AGGR(vdev, peer, tx.dropped.ring_full); |
| 2113 | DP_STATS_AGGR(vdev, peer, tx.dropped.fw_discard); |
| 2114 | DP_STATS_AGGR(vdev, peer, tx.dropped.fw_discard_retired); |
| 2115 | DP_STATS_AGGR(vdev, peer, tx.dropped.mpdu_age_out); |
| 2116 | DP_STATS_AGGR(vdev, peer, tx.dropped.fw_discard_reason1); |
| 2117 | DP_STATS_AGGR(vdev, peer, tx.dropped.fw_discard_reason2); |
| 2118 | DP_STATS_AGGR(vdev, peer, tx.dropped.fw_discard_reason3); |
| 2119 | DP_STATS_AGGR(vdev, peer, rx.err.mic_err); |
| 2120 | DP_STATS_AGGR(vdev, peer, rx.err.decrypt_err); |
| 2121 | DP_STATS_AGGR(vdev, peer, rx.non_ampdu_cnt); |
| 2122 | DP_STATS_AGGR(vdev, peer, rx.non_amsdu_cnt); |
| 2123 | DP_STATS_AGGR(vdev, peer, rx.amsdu_cnt); |
| 2124 | DP_STATS_AGGR_PKT(vdev, peer, rx.to_stack); |
| 2125 | DP_STATS_AGGR_PKT(vdev, peer, rx.rcvd_reo); |
| 2126 | DP_STATS_AGGR_PKT(vdev, peer, rx.unicast); |
| 2127 | DP_STATS_AGGR_PKT(vdev, peer, rx.multicast); |
| 2128 | DP_STATS_AGGR_PKT(vdev, peer, rx.wds); |
| 2129 | DP_STATS_AGGR_PKT(vdev, peer, rx.raw); |
| 2130 | DP_STATS_AGGR_PKT(vdev, peer, rx.intra_bss); |
| 2131 | |
| 2132 | vdev->stats.tx.last_ack_rssi = |
| 2133 | peer->stats.tx.last_ack_rssi; |
| 2134 | } |
| 2135 | } |
| 2136 | |
| 2137 | /** |
| 2138 | * dp_aggregate_pdev_stats(): Consolidate stats at PDEV level |
| 2139 | * @pdev: DP PDEV handle |
| 2140 | * |
| 2141 | * return: void |
| 2142 | */ |
| 2143 | static inline void dp_aggregate_pdev_stats(struct dp_pdev *pdev) |
| 2144 | { |
| 2145 | struct dp_vdev *vdev = NULL; |
| 2146 | uint8_t i; |
| 2147 | |
| 2148 | qdf_mem_set(&(pdev->stats.tx), sizeof(pdev->stats.tx), 0x0); |
| 2149 | qdf_mem_set(&(pdev->stats.rx), sizeof(pdev->stats.rx), 0x0); |
| 2150 | qdf_mem_set(&(pdev->stats.tx_i), sizeof(pdev->stats.tx_i), 0x0); |
| 2151 | |
| 2152 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
| 2153 | if (!vdev) |
| 2154 | return; |
| 2155 | dp_aggregate_vdev_stats(vdev); |
| 2156 | |
| 2157 | for (i = 0; i <= MAX_MCS; i++) { |
| 2158 | DP_STATS_AGGR(pdev, vdev, tx.pkt_type[0].mcs_count[i]); |
| 2159 | DP_STATS_AGGR(pdev, vdev, tx.pkt_type[1].mcs_count[i]); |
| 2160 | DP_STATS_AGGR(pdev, vdev, tx.pkt_type[2].mcs_count[i]); |
| 2161 | DP_STATS_AGGR(pdev, vdev, tx.pkt_type[3].mcs_count[i]); |
| 2162 | DP_STATS_AGGR(pdev, vdev, tx.pkt_type[4].mcs_count[i]); |
| 2163 | DP_STATS_AGGR(pdev, vdev, rx.mcs_count[i]); |
| 2164 | } |
| 2165 | |
| 2166 | for (i = 0; i < SUPPORTED_BW; i++) { |
| 2167 | DP_STATS_AGGR(pdev, vdev, tx.bw[i]); |
| 2168 | DP_STATS_AGGR(pdev, vdev, rx.bw[i]); |
| 2169 | } |
| 2170 | |
| 2171 | for (i = 0; i < SS_COUNT; i++) |
| 2172 | DP_STATS_AGGR(pdev, vdev, rx.nss[i]); |
| 2173 | |
| 2174 | for (i = 0; i < WME_AC_MAX; i++) { |
| 2175 | DP_STATS_AGGR(pdev, vdev, tx.wme_ac_type[i]); |
| 2176 | DP_STATS_AGGR(pdev, vdev, rx.wme_ac_type[i]); |
| 2177 | DP_STATS_AGGR(pdev, vdev, |
| 2178 | tx.excess_retries_ac[i]); |
| 2179 | |
| 2180 | } |
| 2181 | |
| 2182 | for (i = 0; i < MAX_MCS + 1; i++) { |
| 2183 | DP_STATS_AGGR(pdev, vdev, tx.sgi_count[i]); |
| 2184 | DP_STATS_AGGR(pdev, vdev, rx.sgi_count[i]); |
| 2185 | } |
| 2186 | |
| 2187 | DP_STATS_AGGR_PKT(pdev, vdev, tx.comp_pkt); |
| 2188 | DP_STATS_AGGR_PKT(pdev, vdev, tx.ucast); |
| 2189 | DP_STATS_AGGR_PKT(pdev, vdev, tx.mcast); |
| 2190 | DP_STATS_AGGR_PKT(pdev, vdev, tx.tx_success); |
| 2191 | DP_STATS_AGGR(pdev, vdev, tx.tx_failed); |
| 2192 | DP_STATS_AGGR(pdev, vdev, tx.ofdma); |
| 2193 | DP_STATS_AGGR(pdev, vdev, tx.stbc); |
| 2194 | DP_STATS_AGGR(pdev, vdev, tx.ldpc); |
| 2195 | DP_STATS_AGGR(pdev, vdev, tx.retries); |
| 2196 | DP_STATS_AGGR(pdev, vdev, tx.non_amsdu_cnt); |
| 2197 | DP_STATS_AGGR(pdev, vdev, tx.amsdu_cnt); |
| 2198 | DP_STATS_AGGR(pdev, vdev, tx.dropped.dma_map_error); |
| 2199 | DP_STATS_AGGR(pdev, vdev, tx.dropped.ring_full); |
| 2200 | DP_STATS_AGGR(pdev, vdev, tx.dropped.fw_discard); |
| 2201 | DP_STATS_AGGR(pdev, vdev, |
| 2202 | tx.dropped.fw_discard_retired); |
| 2203 | DP_STATS_AGGR(pdev, vdev, tx.dropped.mpdu_age_out); |
| 2204 | DP_STATS_AGGR(pdev, vdev, |
| 2205 | tx.dropped.fw_discard_reason1); |
| 2206 | DP_STATS_AGGR(pdev, vdev, |
| 2207 | tx.dropped.fw_discard_reason2); |
| 2208 | DP_STATS_AGGR(pdev, vdev, |
| 2209 | tx.dropped.fw_discard_reason3); |
| 2210 | DP_STATS_AGGR(pdev, vdev, rx.err.mic_err); |
| 2211 | DP_STATS_AGGR(pdev, vdev, rx.err.decrypt_err); |
| 2212 | DP_STATS_AGGR(pdev, vdev, rx.non_ampdu_cnt); |
| 2213 | DP_STATS_AGGR(pdev, vdev, rx.ampdu_cnt); |
| 2214 | DP_STATS_AGGR(pdev, vdev, rx.non_amsdu_cnt); |
| 2215 | DP_STATS_AGGR(pdev, vdev, rx.amsdu_cnt); |
| 2216 | DP_STATS_AGGR_PKT(pdev, vdev, rx.to_stack); |
| 2217 | DP_STATS_AGGR_PKT(pdev, vdev, rx.rcvd_reo); |
| 2218 | DP_STATS_AGGR_PKT(pdev, vdev, rx.unicast); |
| 2219 | DP_STATS_AGGR_PKT(pdev, vdev, rx.multicast); |
| 2220 | DP_STATS_AGGR_PKT(pdev, vdev, rx.wds); |
| 2221 | DP_STATS_AGGR_PKT(pdev, vdev, rx.intra_bss); |
| 2222 | DP_STATS_AGGR_PKT(pdev, vdev, rx.raw); |
| 2223 | |
| 2224 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.rcvd); |
| 2225 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.freed); |
| 2226 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.processed); |
| 2227 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.reinject_pkts); |
| 2228 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.inspect_pkts); |
| 2229 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.raw_pkt); |
| 2230 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.tso.tso_pkt); |
| 2231 | DP_STATS_AGGR(pdev, vdev, tx_i.tso.dropped_host); |
| 2232 | DP_STATS_AGGR(pdev, vdev, tx_i.tso.dropped_target); |
| 2233 | DP_STATS_AGGR(pdev, vdev, tx_i.sg.dropped_host); |
| 2234 | DP_STATS_AGGR(pdev, vdev, tx_i.sg.dropped_target); |
| 2235 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.sg.sg_pkt); |
| 2236 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.mcast_en.mcast_pkt); |
| 2237 | DP_STATS_AGGR(pdev, vdev, |
| 2238 | tx_i.mcast_en.dropped_map_error); |
| 2239 | DP_STATS_AGGR(pdev, vdev, |
| 2240 | tx_i.mcast_en.dropped_self_mac); |
| 2241 | DP_STATS_AGGR(pdev, vdev, |
| 2242 | tx_i.mcast_en.dropped_send_fail); |
| 2243 | DP_STATS_AGGR(pdev, vdev, tx_i.mcast_en.ucast); |
| 2244 | DP_STATS_AGGR_PKT(pdev, vdev, tx_i.dropped.dropped_pkt); |
| 2245 | |
| 2246 | pdev->stats.tx.last_ack_rssi = |
| 2247 | vdev->stats.tx.last_ack_rssi; |
| 2248 | pdev->stats.tx_i.tso.num_seg = |
| 2249 | vdev->stats.tx_i.tso.num_seg; |
| 2250 | } |
| 2251 | } |
| 2252 | |
| 2253 | /** |
| 2254 | * dp_print_pdev_tx_stats(): Print Pdev level TX stats |
| 2255 | * @pdev: DP_PDEV Handle |
| 2256 | * |
| 2257 | * Return:void |
| 2258 | */ |
| 2259 | static inline void |
| 2260 | dp_print_pdev_tx_stats(struct dp_pdev *pdev) |
| 2261 | { |
| 2262 | DP_TRACE(NONE, "WLAN Tx Stats:\n"); |
| 2263 | DP_TRACE(NONE, "Received From Stack:\n"); |
| 2264 | DP_TRACE(NONE, "Total Packets Received = %d", |
| 2265 | pdev->stats.tx_i.rcvd.num); |
| 2266 | DP_TRACE(NONE, "Bytes Sent = %d", |
| 2267 | pdev->stats.tx_i.rcvd.bytes); |
| 2268 | DP_TRACE(NONE, "Processed:\n"); |
| 2269 | DP_TRACE(NONE, "Msdu Processed = %d", |
| 2270 | pdev->stats.tx_i.processed.num); |
| 2271 | DP_TRACE(NONE, "Bytes Processed = %d", |
| 2272 | pdev->stats.tx_i.processed.bytes); |
| 2273 | DP_TRACE(NONE, "Completions:\n"); |
| 2274 | DP_TRACE(NONE, "Msdu Sent = %d", |
| 2275 | pdev->stats.tx.comp_pkt.num); |
| 2276 | DP_TRACE(NONE, "Bytes Sent = %d", |
| 2277 | pdev->stats.tx.comp_pkt.bytes); |
| 2278 | DP_TRACE(NONE, "Freed:\n"); |
| 2279 | DP_TRACE(NONE, "Msdus Freed = %d", |
| 2280 | pdev->stats.tx_i.freed.num); |
| 2281 | DP_TRACE(NONE, "Bytes Freed = %d", |
| 2282 | pdev->stats.tx_i.freed.bytes); |
| 2283 | DP_TRACE(NONE, "Dropped:\n"); |
| 2284 | DP_TRACE(NONE, "Total Packets Dropped = %d", |
| 2285 | pdev->stats.tx_i.dropped.dropped_pkt.num); |
| 2286 | DP_TRACE(NONE, "Bytes Dropped = %d", |
| 2287 | pdev->stats.tx_i.dropped.dropped_pkt.bytes); |
| 2288 | DP_TRACE(NONE, "Dma_map_error = %d", |
| 2289 | pdev->stats.tx.dropped.dma_map_error); |
| 2290 | DP_TRACE(NONE, "Ring Full = %d", pdev->stats.tx.dropped.ring_full); |
| 2291 | DP_TRACE(NONE, "Fw Discard = %d", |
| 2292 | pdev->stats.tx.dropped.fw_discard); |
| 2293 | DP_TRACE(NONE, "Fw Discard Retired = %d", |
| 2294 | pdev->stats.tx.dropped.fw_discard_retired); |
| 2295 | DP_TRACE(NONE, "Firmware Discard Untransmitted = %d", |
| 2296 | pdev->stats.tx.dropped.fw_discard_untransmitted); |
| 2297 | DP_TRACE(NONE, "Mpdu Age Out = %d", |
| 2298 | pdev->stats.tx.dropped.mpdu_age_out); |
| 2299 | DP_TRACE(NONE, "Firmware Discard Reason1 = %d", |
| 2300 | pdev->stats.tx.dropped.fw_discard_reason1); |
| 2301 | DP_TRACE(NONE, "Firmware Discard Reason2 = %d", |
| 2302 | pdev->stats.tx.dropped.fw_discard_reason2); |
| 2303 | DP_TRACE(NONE, "Firmware Discard Reason3 = %d", |
| 2304 | pdev->stats.tx.dropped.fw_discard_reason3); |
| 2305 | DP_TRACE(NONE, "Scatter Gather:\n"); |
| 2306 | DP_TRACE(NONE, "Total Packets = %d", |
| 2307 | pdev->stats.tx_i.sg.sg_pkt.num); |
| 2308 | DP_TRACE(NONE, "Total Bytes = %d", |
| 2309 | pdev->stats.tx_i.sg.sg_pkt.bytes); |
| 2310 | DP_TRACE(NONE, "Dropped By Host = %d", |
| 2311 | pdev->stats.tx_i.sg.dropped_host); |
| 2312 | DP_TRACE(NONE, "Dropped By Target = %d", |
| 2313 | pdev->stats.tx_i.sg.dropped_target); |
| 2314 | DP_TRACE(NONE, "Tso:\n"); |
| 2315 | DP_TRACE(NONE, "Number of Segments = %d", |
| 2316 | pdev->stats.tx_i.tso.num_seg); |
| 2317 | DP_TRACE(NONE, "Number Packets = %d", |
| 2318 | pdev->stats.tx_i.tso.tso_pkt.num); |
| 2319 | DP_TRACE(NONE, "Total Bytes = %d", |
| 2320 | pdev->stats.tx_i.tso.tso_pkt.bytes); |
| 2321 | DP_TRACE(NONE, "Dropped By Host = %d", |
| 2322 | pdev->stats.tx_i.tso.dropped_host); |
| 2323 | DP_TRACE(NONE, "Mcast Enhancement:\n"); |
| 2324 | DP_TRACE(NONE, "Dropped: Map Errors = %d", |
| 2325 | pdev->stats.tx_i.mcast_en.dropped_map_error); |
| 2326 | DP_TRACE(NONE, "Dropped: Self Mac = %d", |
| 2327 | pdev->stats.tx_i.mcast_en.dropped_self_mac); |
| 2328 | DP_TRACE(NONE, "Dropped: Send Fail = %d", |
| 2329 | pdev->stats.tx_i.mcast_en.dropped_send_fail); |
| 2330 | DP_TRACE(NONE, "Total Unicast sent = %d", |
| 2331 | pdev->stats.tx_i.mcast_en.ucast); |
| 2332 | } |
| 2333 | |
| 2334 | /** |
| 2335 | * dp_print_pdev_rx_stats(): Print Pdev level RX stats |
| 2336 | * @pdev: DP_PDEV Handle |
| 2337 | * |
| 2338 | * Return: void |
| 2339 | */ |
| 2340 | static inline void |
| 2341 | dp_print_pdev_rx_stats(struct dp_pdev *pdev) |
| 2342 | { |
| 2343 | DP_TRACE(NONE, "WLAN Rx Stats:\n"); |
| 2344 | DP_TRACE(NONE, "Received From HW (Reo Dest Ring):\n"); |
| 2345 | DP_TRACE(NONE, "Total Packets Received = %d", |
| 2346 | pdev->stats.rx.rcvd_reo.num); |
| 2347 | DP_TRACE(NONE, "Bytes Sent = %d", |
| 2348 | pdev->stats.rx.rcvd_reo.bytes); |
| 2349 | DP_TRACE(NONE, "Replenished:\n"); |
| 2350 | DP_TRACE(NONE, "Total Packets Replenished = %d", |
| 2351 | pdev->stats.replenished.num); |
| 2352 | DP_TRACE(NONE, "Bytes Sent = %d", |
| 2353 | pdev->stats.replenished.bytes); |
| 2354 | DP_TRACE(NONE, "Buffers Added To Freelist = %d", |
| 2355 | pdev->stats.buf_freelist); |
| 2356 | DP_TRACE(NONE, "Dropped:\n"); |
| 2357 | DP_TRACE(NONE, "Total Packets With No Peer = %d", |
| 2358 | pdev->stats.dropped.no_peer.num); |
| 2359 | DP_TRACE(NONE, "Bytes Sent With No Peer = %d", |
| 2360 | pdev->stats.dropped.no_peer.bytes); |
| 2361 | DP_TRACE(NONE, "Total Packets With Msdu Not Done = %d", |
| 2362 | pdev->stats.dropped.msdu_not_done.num); |
| 2363 | DP_TRACE(NONE, "Bytes Sent With Msdu Not Done = %d", |
| 2364 | pdev->stats.dropped.msdu_not_done.bytes); |
| 2365 | DP_TRACE(NONE, "Sent To Stack:\n"); |
| 2366 | DP_TRACE(NONE, "Packets Sent To Stack = %d", |
| 2367 | pdev->stats.rx.to_stack.num); |
| 2368 | DP_TRACE(NONE, "Bytes Sent To Stack = %d", |
| 2369 | pdev->stats.rx.to_stack.bytes); |
| 2370 | DP_TRACE(NONE, "Errors:\n"); |
| 2371 | DP_TRACE(NONE, "Rxdma Ring Unititalized: %d", |
| 2372 | pdev->stats.err.rxdma_unitialized); |
| 2373 | DP_TRACE(NONE, "Desc Alloc Failed: %d", |
| 2374 | pdev->stats.err.desc_alloc_fail); |
| 2375 | } |
| 2376 | |
| 2377 | /** |
| 2378 | * dp_print_soc_tx_stats(): Print SOC level stats |
| 2379 | * @soc DP_SOC Handle |
| 2380 | * |
| 2381 | * Return: void |
| 2382 | */ |
| 2383 | static inline void |
| 2384 | dp_print_soc_tx_stats(struct dp_soc *soc) |
| 2385 | { |
| 2386 | DP_TRACE(NONE, "SOC Tx Stats:\n"); |
| 2387 | DP_TRACE(NONE, "Tx Descriptors In Use = %d", |
| 2388 | soc->stats.tx.desc_in_use); |
| 2389 | } |
| 2390 | |
| 2391 | |
| 2392 | /** |
| 2393 | * dp_print_soc_rx_stats: Print SOC level Rx stats |
| 2394 | * @soc: DP_SOC Handle |
| 2395 | * |
| 2396 | * Return:void |
| 2397 | */ |
| 2398 | static inline void |
| 2399 | dp_print_soc_rx_stats(struct dp_soc *soc) |
| 2400 | { |
| 2401 | uint32_t i; |
| 2402 | char reo_error[DP_REO_ERR_LENGTH]; |
| 2403 | char rxdma_error[DP_RXDMA_ERR_LENGTH]; |
| 2404 | uint8_t index = 0; |
| 2405 | |
| 2406 | DP_TRACE(NONE, "SOC Rx Stats:\n"); |
| 2407 | DP_TRACE(NONE, "Errors:\n"); |
| 2408 | DP_TRACE(NONE, "Invalid RBM = %d", |
| 2409 | soc->stats.rx.err.invalid_rbm); |
| 2410 | DP_TRACE(NONE, "Invalid Vdev = %d", |
| 2411 | soc->stats.rx.err.invalid_vdev); |
| 2412 | DP_TRACE(NONE, "Invalid Pdev = %d", |
| 2413 | soc->stats.rx.err.invalid_pdev); |
| 2414 | DP_TRACE(NONE, "HAL Ring Access Fail = %d", |
| 2415 | soc->stats.rx.err.hal_ring_access_fail); |
| 2416 | for (i = 0; i < MAX_RXDMA_ERRORS; i++) { |
| 2417 | index += qdf_snprint(&rxdma_error[index], |
| 2418 | DP_RXDMA_ERR_LENGTH - index, |
| 2419 | " %d,", soc->stats.rx.err.rxdma_error[i]); |
| 2420 | } |
| 2421 | DP_TRACE(NONE, "RXDMA Error (0-31):%s", |
| 2422 | rxdma_error); |
| 2423 | |
| 2424 | index = 0; |
| 2425 | for (i = 0; i < REO_ERROR_TYPE_MAX; i++) { |
| 2426 | index += qdf_snprint(&reo_error[index], |
| 2427 | DP_REO_ERR_LENGTH - index, |
| 2428 | " %d,", soc->stats.rx.err.reo_error[i]); |
| 2429 | } |
| 2430 | DP_TRACE(NONE, "REO Error(0-14):%s", |
| 2431 | reo_error); |
| 2432 | } |
| 2433 | |
| 2434 | /** |
| 2435 | * dp_txrx_host_stats_clr(): Reinitialize the txrx stats |
| 2436 | * @vdev: DP_VDEV handle |
| 2437 | * |
| 2438 | * Return:void |
| 2439 | */ |
| 2440 | static inline void |
| 2441 | dp_txrx_host_stats_clr(struct dp_vdev *vdev) |
| 2442 | { |
| 2443 | struct dp_peer *peer = NULL; |
| 2444 | DP_STATS_CLR(vdev->pdev); |
| 2445 | DP_STATS_CLR(vdev->pdev->soc); |
| 2446 | DP_STATS_CLR(vdev); |
| 2447 | TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) { |
| 2448 | if (!peer) |
| 2449 | return; |
| 2450 | DP_STATS_CLR(peer); |
| 2451 | } |
| 2452 | |
| 2453 | } |
| 2454 | |
| 2455 | /** |
| 2456 | * dp_print_rx_rates(): Print Rx rate stats |
| 2457 | * @vdev: DP_VDEV handle |
| 2458 | * |
| 2459 | * Return:void |
| 2460 | */ |
| 2461 | static inline void |
| 2462 | dp_print_rx_rates(struct dp_vdev *vdev) |
| 2463 | { |
| 2464 | struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev; |
| 2465 | uint8_t i; |
| 2466 | uint8_t index = 0; |
| 2467 | char mcs[DP_MCS_LENGTH]; |
| 2468 | char nss[DP_NSS_LENGTH]; |
| 2469 | |
| 2470 | DP_TRACE(NONE, "Rx Rate Info:\n"); |
| 2471 | for (i = 0; i < MAX_MCS; i++) { |
| 2472 | index += qdf_snprint(&mcs[index], DP_MCS_LENGTH - index, |
| 2473 | " %d,", pdev->stats.rx.mcs_count[i]); |
| 2474 | } |
| 2475 | DP_TRACE(NONE, "MCS(0-11):%s", |
| 2476 | mcs); |
| 2477 | |
| 2478 | index = 0; |
| 2479 | for (i = 0; i < SS_COUNT; i++) { |
| 2480 | index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index, |
| 2481 | " %d,", pdev->stats.rx.nss[i]); |
| 2482 | } |
| 2483 | DP_TRACE(NONE, "NSS(0-7):%s", |
| 2484 | nss); |
| 2485 | |
| 2486 | DP_TRACE(NONE, "SGI:" |
| 2487 | " 0.8us %d," |
| 2488 | " 0.4us %d," |
| 2489 | " 1.6us %d," |
| 2490 | " 3.2us %d,", |
| 2491 | pdev->stats.rx.sgi_count[0], |
| 2492 | pdev->stats.rx.sgi_count[1], |
| 2493 | pdev->stats.rx.sgi_count[2], |
| 2494 | pdev->stats.rx.sgi_count[3]); |
| 2495 | DP_TRACE(NONE, "BW Counts: 20MHZ %d, 40MHZ %d, 80MHZ %d, 160MHZ %d", |
| 2496 | pdev->stats.rx.bw[0], pdev->stats.rx.bw[1], |
| 2497 | pdev->stats.rx.bw[2], pdev->stats.rx.bw[3]); |
| 2498 | DP_TRACE(NONE, "Reception Type:" |
| 2499 | " SU: %d," |
| 2500 | " MU_MIMO:%d," |
| 2501 | " MU_OFDMA:%d," |
| 2502 | " MU_OFDMA_MIMO:%d", |
| 2503 | pdev->stats.rx.reception_type[0], |
| 2504 | pdev->stats.rx.reception_type[1], |
| 2505 | pdev->stats.rx.reception_type[2], |
| 2506 | pdev->stats.rx.reception_type[3]); |
| 2507 | DP_TRACE(NONE, "Aggregation:\n"); |
| 2508 | DP_TRACE(NONE, "Number of Msdu's Part of Ampdu = %d", |
| 2509 | pdev->stats.rx.ampdu_cnt); |
| 2510 | DP_TRACE(NONE, "Number of Msdu's With No Mpdu Level Aggregation : %d", |
| 2511 | pdev->stats.rx.non_ampdu_cnt); |
| 2512 | DP_TRACE(NONE, "Number of Msdu's Part of Amsdu: %d", |
| 2513 | pdev->stats.rx.amsdu_cnt); |
| 2514 | DP_TRACE(NONE, "Number of Msdu's With No Msdu Level Aggregation: %d", |
| 2515 | pdev->stats.rx.non_amsdu_cnt); |
| 2516 | } |
| 2517 | |
| 2518 | /** |
| 2519 | * dp_print_tx_rates(): Print tx rates |
| 2520 | * @vdev: DP_VDEV handle |
| 2521 | * |
| 2522 | * Return:void |
| 2523 | */ |
| 2524 | static inline void |
| 2525 | dp_print_tx_rates(struct dp_vdev *vdev) |
| 2526 | { |
| 2527 | struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev; |
| 2528 | uint8_t i, pkt_type; |
| 2529 | char mcs[DOT11_MAX][DP_MCS_LENGTH]; |
| 2530 | uint32_t index; |
| 2531 | |
| 2532 | DP_TRACE(NONE, "Tx Rate Info:\n"); |
| 2533 | |
| 2534 | for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) { |
| 2535 | index = 0; |
| 2536 | for (i = 0; i < MAX_MCS; i++) { |
| 2537 | index += qdf_snprint(&mcs[pkt_type][index], |
| 2538 | DP_MCS_LENGTH - index, |
| 2539 | " %d ", |
| 2540 | pdev->stats.tx.pkt_type[pkt_type]. |
| 2541 | mcs_count[i]); |
| 2542 | } |
| 2543 | } |
| 2544 | |
| 2545 | DP_TRACE(NONE, "Packet Type 11A MCS(0-7):%s", |
| 2546 | mcs[0]); |
| 2547 | DP_TRACE(NONE, "Packet Type 11A MCS Invalid = %d", |
| 2548 | pdev->stats.tx.pkt_type[DOT11_A].mcs_count[MAX_MCS]); |
| 2549 | DP_TRACE(NONE, "Packet Type 11B MCS(0-6):%s", |
| 2550 | mcs[1]); |
| 2551 | DP_TRACE(NONE, "Packet Type 11B MCS Invalid = %d", |
| 2552 | pdev->stats.tx.pkt_type[DOT11_B].mcs_count[MAX_MCS]); |
| 2553 | DP_TRACE(NONE, "Packet Type 11N MCS(0-7):%s", |
| 2554 | mcs[2]); |
| 2555 | DP_TRACE(NONE, "Packet Type 11N MCS Invalid = %d", |
| 2556 | pdev->stats.tx.pkt_type[DOT11_N].mcs_count[MAX_MCS]); |
| 2557 | DP_TRACE(NONE, "Packet Type 11AC MCS(0-9):%s", |
| 2558 | mcs[3]); |
| 2559 | DP_TRACE(NONE, "Packet Type 11AC MCS Invalid = %d", |
| 2560 | pdev->stats.tx.pkt_type[DOT11_AC].mcs_count[MAX_MCS]); |
| 2561 | DP_TRACE(NONE, "Packet Type 11AX MCS(0-11):%s", |
| 2562 | mcs[4]); |
| 2563 | DP_TRACE(NONE, "Packet Type 11AX MCS Invalid = %d", |
| 2564 | pdev->stats.tx.pkt_type[DOT11_AX].mcs_count[MAX_MCS]); |
| 2565 | } |
| 2566 | |
| 2567 | /** |
| 2568 | * dp_print_peer_stats():print peer stats |
| 2569 | * @peer: DP_PEER handle |
| 2570 | * |
| 2571 | * return void |
| 2572 | */ |
| 2573 | static inline void dp_print_peer_stats(struct dp_peer *peer) |
| 2574 | { |
| 2575 | uint8_t i, pkt_type; |
| 2576 | char mcs[DOT11_MAX][DP_MCS_LENGTH]; |
| 2577 | uint32_t index; |
| 2578 | char nss[DP_NSS_LENGTH]; |
| 2579 | char mcs_rx[DP_MCS_LENGTH]; |
| 2580 | DP_TRACE(NONE, "Node Tx Stats:\n"); |
| 2581 | DP_TRACE(NONE, "Total Packet Completions %d", |
| 2582 | peer->stats.tx.comp_pkt.num); |
| 2583 | DP_TRACE(NONE, "Total Bytes Completions %d", |
| 2584 | peer->stats.tx.comp_pkt.bytes); |
| 2585 | DP_TRACE(NONE, "Success Packets %d", |
| 2586 | peer->stats.tx.tx_success.num); |
| 2587 | DP_TRACE(NONE, "Success Bytes %d", |
| 2588 | peer->stats.tx.tx_success.bytes); |
| 2589 | DP_TRACE(NONE, "Packets Failed %d", |
| 2590 | peer->stats.tx.tx_failed); |
| 2591 | DP_TRACE(NONE, "Packets In OFDMA %d", |
| 2592 | peer->stats.tx.ofdma); |
| 2593 | DP_TRACE(NONE, "Packets In STBC %d", |
| 2594 | peer->stats.tx.stbc); |
| 2595 | DP_TRACE(NONE, "Packets In LDPC %d", |
| 2596 | peer->stats.tx.ldpc); |
| 2597 | DP_TRACE(NONE, "Packet Retries %d", |
| 2598 | peer->stats.tx.retries); |
| 2599 | DP_TRACE(NONE, "Msdu's Not Part of Ampdu %d", |
| 2600 | peer->stats.tx.non_amsdu_cnt); |
| 2601 | DP_TRACE(NONE, "Mpdu's Part of Ampdu %d", |
| 2602 | peer->stats.tx.amsdu_cnt); |
| 2603 | DP_TRACE(NONE, "Last Packet RSSI %d", |
| 2604 | peer->stats.tx.last_ack_rssi); |
| 2605 | DP_TRACE(NONE, "Dropped At Host: Due To DMA Map Error %d", |
| 2606 | peer->stats.tx.dropped.dma_map_error); |
| 2607 | DP_TRACE(NONE, "Dropped At Host: Due To Ring Full %d", |
| 2608 | peer->stats.tx.dropped.ring_full); |
| 2609 | DP_TRACE(NONE, "Dropped At FW: FW Discard %d", |
| 2610 | peer->stats.tx.dropped.fw_discard); |
| 2611 | DP_TRACE(NONE, "Dropped At FW: FW Discard Retired %d", |
| 2612 | peer->stats.tx.dropped.fw_discard_retired); |
| 2613 | DP_TRACE(NONE, "Dropped At FW: FW Discard Untransmitted %d", |
| 2614 | peer->stats.tx.dropped.fw_discard_untransmitted); |
| 2615 | DP_TRACE(NONE, "Dropped : Mpdu Age Out %d", |
| 2616 | peer->stats.tx.dropped.mpdu_age_out); |
| 2617 | DP_TRACE(NONE, "Dropped : FW Discard Reason1 %d", |
| 2618 | peer->stats.tx.dropped.fw_discard_reason1); |
| 2619 | DP_TRACE(NONE, "Dropped : FW Discard Reason2 %d", |
| 2620 | peer->stats.tx.dropped.fw_discard_reason2); |
| 2621 | DP_TRACE(NONE, "Dropped : FW Discard Reason3 %d", |
| 2622 | peer->stats.tx.dropped.fw_discard_reason3); |
| 2623 | |
| 2624 | for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) { |
| 2625 | index = 0; |
| 2626 | for (i = 0; i < MAX_MCS; i++) { |
| 2627 | index += qdf_snprint(&mcs[pkt_type][index], |
| 2628 | DP_MCS_LENGTH - index, |
| 2629 | " %d ", |
| 2630 | peer->stats.tx.pkt_type[pkt_type]. |
| 2631 | mcs_count[i]); |
| 2632 | } |
| 2633 | } |
| 2634 | |
| 2635 | DP_TRACE(NONE, "Packet Type 11A MCS(0-7):%s", |
| 2636 | mcs[0]); |
| 2637 | DP_TRACE(NONE, "Packet Type 11A MCS Invalid = %d", |
| 2638 | peer->stats.tx.pkt_type[DOT11_A].mcs_count[MAX_MCS]); |
| 2639 | DP_TRACE(NONE, "Packet Type 11B MCS(0-6):%s", |
| 2640 | mcs[1]); |
| 2641 | DP_TRACE(NONE, "Packet Type 11B MCS Invalid = %d", |
| 2642 | peer->stats.tx.pkt_type[DOT11_B].mcs_count[MAX_MCS]); |
| 2643 | DP_TRACE(NONE, "Packet Type 11N MCS(0-7):%s", |
| 2644 | mcs[2]); |
| 2645 | DP_TRACE(NONE, "Packet Type 11N MCS Invalid = %d", |
| 2646 | peer->stats.tx.pkt_type[DOT11_N].mcs_count[MAX_MCS]); |
| 2647 | DP_TRACE(NONE, "Packet Type 11AC MCS(0-9):%s", |
| 2648 | mcs[3]); |
| 2649 | DP_TRACE(NONE, "Packet Type 11AC MCS Invalid = %d", |
| 2650 | peer->stats.tx.pkt_type[DOT11_AC].mcs_count[MAX_MCS]); |
| 2651 | DP_TRACE(NONE, "Packet Type 11AX MCS(0-11):%s", |
| 2652 | mcs[4]); |
| 2653 | DP_TRACE(NONE, "Packet Type 11AX MCS Invalid = %d", |
| 2654 | peer->stats.tx.pkt_type[DOT11_AX].mcs_count[MAX_MCS]); |
| 2655 | DP_TRACE(NONE, "SGI:" |
| 2656 | " 0.8us %d," |
| 2657 | " 0.4us %d," |
| 2658 | " 1.6us %d," |
| 2659 | " 3.2us %d,", |
| 2660 | peer->stats.tx.sgi_count[0], |
| 2661 | peer->stats.tx.sgi_count[1], |
| 2662 | peer->stats.tx.sgi_count[2], |
| 2663 | peer->stats.tx.sgi_count[3]); |
| 2664 | DP_TRACE(NONE, "BW Counts: 20MHZ %d, 40MHZ %d, 80MHZ %d, 160MHZ %d", |
| 2665 | peer->stats.tx.bw[0], peer->stats.tx.bw[1], |
| 2666 | peer->stats.tx.bw[2], peer->stats.tx.bw[3]); |
| 2667 | |
| 2668 | DP_TRACE(NONE, "Node Rx Stats:\n"); |
| 2669 | DP_TRACE(NONE, "Packets Sent To Stack %d", |
| 2670 | peer->stats.rx.to_stack.num); |
| 2671 | DP_TRACE(NONE, "Bytes Sent To Stack %d", |
| 2672 | peer->stats.rx.to_stack.bytes); |
| 2673 | DP_TRACE(NONE, "Packets Received %d", peer->stats.rx.rcvd_reo.num); |
| 2674 | DP_TRACE(NONE, "Bytes Received %d", peer->stats.rx.rcvd_reo.bytes); |
| 2675 | DP_TRACE(NONE, "Unicast Packets Received %d", |
| 2676 | peer->stats.rx.unicast.num); |
| 2677 | DP_TRACE(NONE, "Unicast Bytes Received %d", |
| 2678 | peer->stats.rx.unicast.bytes); |
| 2679 | DP_TRACE(NONE, "Multicast Packets Received %d", |
| 2680 | peer->stats.rx.multicast.num); |
| 2681 | DP_TRACE(NONE, "Multicast Bytes Received %d", |
| 2682 | peer->stats.rx.multicast.bytes); |
| 2683 | DP_TRACE(NONE, "WDS Packets Received %d", |
| 2684 | peer->stats.rx.wds.num); |
| 2685 | DP_TRACE(NONE, "WDS Bytes Received %d", |
| 2686 | peer->stats.rx.wds.bytes); |
| 2687 | DP_TRACE(NONE, "Intra BSS Packets Received %d", |
| 2688 | peer->stats.rx.intra_bss.num); |
| 2689 | DP_TRACE(NONE, "Intra BSS Bytes Received %d", |
| 2690 | peer->stats.rx.intra_bss.bytes); |
| 2691 | DP_TRACE(NONE, "Raw Packets Received %d", |
| 2692 | peer->stats.rx.raw.num); |
| 2693 | DP_TRACE(NONE, "Raw Bytes Received %d", |
| 2694 | peer->stats.rx.raw.bytes); |
| 2695 | DP_TRACE(NONE, "Errors: MIC Errors %d", |
| 2696 | peer->stats.rx.err.mic_err); |
| 2697 | DP_TRACE(NONE, "Erros: Decryption Errors %d", |
| 2698 | peer->stats.rx.err.decrypt_err); |
| 2699 | DP_TRACE(NONE, "Msdu's Received As Part of Ampdu %d", |
| 2700 | peer->stats.rx.non_ampdu_cnt); |
| 2701 | DP_TRACE(NONE, "Msdu's Recived As Ampdu %d", peer->stats.rx.ampdu_cnt); |
| 2702 | DP_TRACE(NONE, "Msdu's Received Not Part of Amsdu's %d", |
| 2703 | peer->stats.rx.non_amsdu_cnt); |
| 2704 | DP_TRACE(NONE, "MSDUs Received As Part of Amsdu %d", |
| 2705 | peer->stats.rx.amsdu_cnt); |
| 2706 | DP_TRACE(NONE, "SGI:" |
| 2707 | " 0.8us %d," |
| 2708 | " 0.4us %d," |
| 2709 | " 1.6us %d," |
| 2710 | " 3.2us %d,", |
| 2711 | peer->stats.rx.sgi_count[0], |
| 2712 | peer->stats.rx.sgi_count[1], |
| 2713 | peer->stats.rx.sgi_count[2], |
| 2714 | peer->stats.rx.sgi_count[3]); |
| 2715 | DP_TRACE(NONE, "BW Counts: 20MHZ %d, 40MHZ %d, 80MHZ %d, 160MHZ %d", |
| 2716 | peer->stats.rx.bw[0], peer->stats.rx.bw[1], |
| 2717 | peer->stats.rx.bw[2], peer->stats.rx.bw[3]); |
| 2718 | DP_TRACE(NONE, "Reception Type:" |
| 2719 | " SU %d," |
| 2720 | " MU_MIMO %d," |
| 2721 | " MU_OFDMA %d," |
| 2722 | " MU_OFDMA_MIMO %d", |
| 2723 | peer->stats.rx.reception_type[0], |
| 2724 | peer->stats.rx.reception_type[1], |
| 2725 | peer->stats.rx.reception_type[2], |
| 2726 | peer->stats.rx.reception_type[3]); |
| 2727 | |
| 2728 | index = 0; |
| 2729 | for (i = 0; i < MAX_MCS; i++) { |
| 2730 | index += qdf_snprint(&mcs_rx[index], DP_MCS_LENGTH - index, |
| 2731 | " %d,", peer->stats.rx.mcs_count[i]); |
| 2732 | } |
| 2733 | DP_TRACE(NONE, "MCS(0-11):%s", |
| 2734 | mcs_rx); |
| 2735 | |
| 2736 | index = 0; |
| 2737 | for (i = 0; i < SS_COUNT; i++) { |
| 2738 | index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index, |
| 2739 | " %d,", peer->stats.rx.nss[i]); |
| 2740 | } |
| 2741 | DP_TRACE(NONE, "NSS(0-7):%s", |
| 2742 | nss); |
| 2743 | } |
| 2744 | |
| 2745 | /** |
| 2746 | * dp_print_host_stats()- Function to print the stats aggregated at host |
| 2747 | * @vdev_handle: DP_VDEV handle |
| 2748 | * @req: ol_txrx_stats_req |
| 2749 | * @type: host stats type |
| 2750 | * |
| 2751 | * Available Stat types |
| 2752 | * TXRX_RX_RATE_STATS: Print Rx Rate Info |
| 2753 | * TXRX_TX_RATE_STATS: Print Tx Rate Info |
| 2754 | * TXRX_TX_HOST_STATS: Print Tx Stats |
| 2755 | * TXRX_RX_HOST_STATS: Print Rx Stats |
| 2756 | * TXRX_CLEAR_STATS : Clear the stats |
| 2757 | * |
| 2758 | * Return: 0 on success, print error message in case of failure |
| 2759 | */ |
| 2760 | static int |
| 2761 | dp_print_host_stats(struct cdp_vdev *vdev_handle, struct ol_txrx_stats_req *req, |
| 2762 | enum cdp_host_txrx_stats type) |
| 2763 | { |
| 2764 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 2765 | struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev; |
| 2766 | |
| 2767 | dp_aggregate_pdev_stats(pdev); |
| 2768 | switch (type) { |
| 2769 | case TXRX_RX_RATE_STATS: |
| 2770 | dp_print_rx_rates(vdev); |
| 2771 | break; |
| 2772 | case TXRX_TX_RATE_STATS: |
| 2773 | dp_print_tx_rates(vdev); |
| 2774 | break; |
| 2775 | case TXRX_TX_HOST_STATS: |
| 2776 | dp_print_pdev_tx_stats(pdev); |
| 2777 | dp_print_soc_tx_stats(pdev->soc); |
| 2778 | break; |
| 2779 | case TXRX_RX_HOST_STATS: |
| 2780 | dp_print_pdev_rx_stats(pdev); |
| 2781 | dp_print_soc_rx_stats(pdev->soc); |
| 2782 | break; |
| 2783 | case TXRX_CLEAR_STATS: |
| 2784 | dp_txrx_host_stats_clr(vdev); |
| 2785 | break; |
| 2786 | default: |
| 2787 | DP_TRACE(NONE, "Wrong Input For TxRx Host Stats"); |
| 2788 | break; |
| 2789 | } |
| 2790 | return 0; |
| 2791 | } |
| 2792 | |
| 2793 | /* |
| 2794 | * dp_get_peer_stats()- function to print peer stats |
| 2795 | * @pdev_handle: DP_PDEV handle |
| 2796 | * @mac_addr: mac address of the peer |
| 2797 | * |
| 2798 | * Return: void |
| 2799 | */ |
| 2800 | static void |
| 2801 | dp_get_peer_stats(struct cdp_pdev *pdev_handle, char *mac_addr) |
| 2802 | { |
| 2803 | struct dp_peer *peer; |
| 2804 | uint8_t local_id; |
| 2805 | peer = (struct dp_peer *)dp_find_peer_by_addr(pdev_handle, mac_addr, |
| 2806 | &local_id); |
| 2807 | |
| 2808 | dp_print_peer_stats(peer); |
| 2809 | return; |
| 2810 | } |
| 2811 | |
Ishank Jain | 949674c | 2017-02-27 17:09:29 +0530 | [diff] [blame] | 2812 | /* |
| 2813 | * dp_set_vdev_dscp_tid_map_wifi3(): Update Map ID selected for particular vdev |
| 2814 | * @vdev_handle: DP_VDEV handle |
| 2815 | * @map_id:ID of map that needs to be updated |
| 2816 | * |
| 2817 | * Return: void |
| 2818 | */ |
| 2819 | static void dp_set_vdev_dscp_tid_map_wifi3(struct cdp_vdev *vdev_handle, |
| 2820 | uint8_t map_id) |
| 2821 | { |
| 2822 | struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle; |
| 2823 | vdev->dscp_tid_map_id = map_id; |
| 2824 | return; |
| 2825 | } |
| 2826 | |
| 2827 | /** |
| 2828 | * dp_set_pdev_dscp_tid_map_wifi3(): update dscp tid map in pdev |
| 2829 | * @pdev: DP_PDEV handle |
| 2830 | * @map_id: ID of map that needs to be updated |
| 2831 | * @tos: index value in map |
| 2832 | * @tid: tid value passed by the user |
| 2833 | * |
| 2834 | * Return: void |
| 2835 | */ |
| 2836 | static void dp_set_pdev_dscp_tid_map_wifi3(struct cdp_pdev *pdev_handle, |
| 2837 | uint8_t map_id, uint8_t tos, uint8_t tid) |
| 2838 | { |
| 2839 | uint8_t dscp; |
| 2840 | struct dp_pdev *pdev = (struct dp_pdev *) pdev_handle; |
| 2841 | dscp = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK; |
| 2842 | pdev->dscp_tid_map[map_id][dscp] = tid; |
| 2843 | hal_tx_update_dscp_tid(pdev->soc->hal_soc, tid, |
| 2844 | map_id, dscp); |
| 2845 | return; |
| 2846 | } |
| 2847 | |
Venkata Sharath Chandra Manchala | a77da0d | 2017-02-27 22:44:37 -0800 | [diff] [blame^] | 2848 | /* |
| 2849 | * dp_txrx_stats() - function to map to firmware and host stats |
| 2850 | * @vdev: virtual handle |
| 2851 | * @req: statistics request handle |
| 2852 | * @stats: type of statistics requested |
| 2853 | * |
| 2854 | * Return: integer |
| 2855 | */ |
| 2856 | static int dp_txrx_stats(struct cdp_vdev *vdev, |
| 2857 | struct ol_txrx_stats_req *req, enum cdp_stats stats) |
| 2858 | { |
| 2859 | int host_stats; |
| 2860 | int fw_stats; |
| 2861 | |
| 2862 | if (stats >= CDP_TXRX_MAX_STATS) |
| 2863 | return 0; |
| 2864 | |
| 2865 | fw_stats = dp_stats_mapping_table[stats][STATS_FW]; |
| 2866 | host_stats = dp_stats_mapping_table[stats][STATS_HOST]; |
| 2867 | |
| 2868 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, |
| 2869 | "stats: %u fw_stats_type: %d host_stats_type: %d", |
| 2870 | stats, fw_stats, host_stats); |
| 2871 | |
| 2872 | /* TODO: Firmware Mapping not implemented */ |
| 2873 | |
| 2874 | if (host_stats != TXRX_HOST_STATS_INVALID) |
| 2875 | return dp_print_host_stats(vdev, req, host_stats); |
| 2876 | |
| 2877 | return 0; |
| 2878 | } |
| 2879 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2880 | static struct cdp_cmn_ops dp_ops_cmn = { |
| 2881 | .txrx_soc_attach_target = dp_soc_attach_target_wifi3, |
| 2882 | .txrx_vdev_attach = dp_vdev_attach_wifi3, |
| 2883 | .txrx_vdev_detach = dp_vdev_detach_wifi3, |
| 2884 | .txrx_pdev_attach = dp_pdev_attach_wifi3, |
| 2885 | .txrx_pdev_detach = dp_pdev_detach_wifi3, |
Dhanashri Atre | 6d90ef3 | 2016-11-10 16:27:38 -0800 | [diff] [blame] | 2886 | .txrx_peer_create = dp_peer_create_wifi3, |
| 2887 | .txrx_peer_setup = dp_peer_setup_wifi3, |
| 2888 | .txrx_peer_teardown = NULL, |
| 2889 | .txrx_peer_delete = dp_peer_delete_wifi3, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2890 | .txrx_vdev_register = dp_vdev_register_wifi3, |
| 2891 | .txrx_soc_detach = dp_soc_detach_wifi3, |
| 2892 | .txrx_get_vdev_mac_addr = dp_get_vdev_mac_addr_wifi3, |
| 2893 | .txrx_get_vdev_from_vdev_id = dp_get_vdev_from_vdev_id_wifi3, |
| 2894 | .txrx_get_ctrl_pdev_from_vdev = dp_get_ctrl_pdev_from_vdev_wifi3, |
Karunakar Dasineni | ed1de12 | 2016-08-02 11:57:59 -0700 | [diff] [blame] | 2895 | .addba_requestprocess = dp_addba_requestprocess_wifi3, |
| 2896 | .addba_responsesetup = dp_addba_responsesetup_wifi3, |
| 2897 | .delba_process = dp_delba_process_wifi3, |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 2898 | .get_peer_mac_addr_frm_id = dp_get_peer_mac_addr_frm_id, |
Ishank Jain | 949674c | 2017-02-27 17:09:29 +0530 | [diff] [blame] | 2899 | /* TODO: get API's for dscp-tid need to be added*/ |
| 2900 | .set_vdev_dscp_tid_map = dp_set_vdev_dscp_tid_map_wifi3, |
| 2901 | .set_pdev_dscp_tid_map = dp_set_pdev_dscp_tid_map_wifi3, |
Venkata Sharath Chandra Manchala | a77da0d | 2017-02-27 22:44:37 -0800 | [diff] [blame^] | 2902 | .txrx_stats = dp_txrx_stats, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2903 | /* TODO: Add other functions */ |
| 2904 | }; |
| 2905 | |
| 2906 | static struct cdp_ctrl_ops dp_ops_ctrl = { |
| 2907 | .txrx_peer_authorize = dp_peer_authorize, |
Kalyan Tallapragada | 277f45e | 2017-01-30 14:25:27 +0530 | [diff] [blame] | 2908 | .txrx_set_vdev_rx_decap_type = dp_set_vdev_rx_decap_type, |
| 2909 | .txrx_set_tx_encap_type = dp_set_vdev_tx_encap_type, |
Venkateswara Swamy Bandaru | 3f62370 | 2017-02-25 00:12:59 +0530 | [diff] [blame] | 2910 | #ifdef MESH_MODE_SUPPORT |
| 2911 | .txrx_set_mesh_mode = dp_peer_set_mesh_mode, |
Venkateswara Swamy Bandaru | ec4f8e6 | 2017-03-07 11:04:28 +0530 | [diff] [blame] | 2912 | .txrx_set_mesh_rx_filter = dp_peer_set_mesh_rx_filter, |
Venkateswara Swamy Bandaru | 3f62370 | 2017-02-25 00:12:59 +0530 | [diff] [blame] | 2913 | #endif |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2914 | /* TODO: Add other functions */ |
| 2915 | }; |
| 2916 | |
| 2917 | static struct cdp_me_ops dp_ops_me = { |
| 2918 | /* TODO */ |
| 2919 | }; |
| 2920 | |
| 2921 | static struct cdp_mon_ops dp_ops_mon = { |
| 2922 | /* TODO */ |
| 2923 | }; |
| 2924 | |
| 2925 | static struct cdp_host_stats_ops dp_ops_host_stats = { |
Ishank Jain | bc2d91f | 2017-01-03 18:14:54 +0530 | [diff] [blame] | 2926 | .txrx_host_stats_get = dp_print_host_stats, |
Ishank Jain | 1e7401c | 2017-02-17 15:38:39 +0530 | [diff] [blame] | 2927 | .txrx_per_peer_stats = dp_get_peer_stats, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2928 | /* TODO */ |
| 2929 | }; |
| 2930 | |
| 2931 | static struct cdp_wds_ops dp_ops_wds = { |
| 2932 | /* TODO */ |
| 2933 | }; |
| 2934 | |
| 2935 | static struct cdp_raw_ops dp_ops_raw = { |
| 2936 | /* TODO */ |
| 2937 | }; |
| 2938 | |
| 2939 | #ifdef CONFIG_WIN |
| 2940 | static struct cdp_pflow_ops dp_ops_pflow = { |
| 2941 | /* TODO */ |
| 2942 | }; |
| 2943 | #endif /* CONFIG_WIN */ |
| 2944 | |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 2945 | #ifndef CONFIG_WIN |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2946 | static struct cdp_misc_ops dp_ops_misc = { |
| 2947 | .get_opmode = dp_get_opmode, |
| 2948 | }; |
| 2949 | |
| 2950 | static struct cdp_flowctl_ops dp_ops_flowctl = { |
| 2951 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 2952 | }; |
| 2953 | |
| 2954 | static struct cdp_lflowctl_ops dp_ops_l_flowctl = { |
| 2955 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 2956 | }; |
| 2957 | |
| 2958 | static struct cdp_ipa_ops dp_ops_ipa = { |
| 2959 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 2960 | }; |
| 2961 | |
| 2962 | static struct cdp_lro_ops dp_ops_lro = { |
| 2963 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 2964 | }; |
| 2965 | |
Dustin Brown | e2e8dc2 | 2016-12-21 12:01:03 -0800 | [diff] [blame] | 2966 | /** |
| 2967 | * dp_dummy_bus_suspend() - dummy bus suspend op |
| 2968 | * |
| 2969 | * FIXME - This is a placeholder for the actual logic! |
| 2970 | * |
| 2971 | * Return: QDF_STATUS_SUCCESS |
| 2972 | */ |
| 2973 | inline QDF_STATUS dp_dummy_bus_suspend(void) |
| 2974 | { |
| 2975 | return QDF_STATUS_SUCCESS; |
| 2976 | } |
| 2977 | |
| 2978 | /** |
| 2979 | * dp_dummy_bus_resume() - dummy bus resume |
| 2980 | * |
| 2981 | * FIXME - This is a placeholder for the actual logic! |
| 2982 | * |
| 2983 | * Return: QDF_STATUS_SUCCESS |
| 2984 | */ |
| 2985 | inline QDF_STATUS dp_dummy_bus_resume(void) |
| 2986 | { |
| 2987 | return QDF_STATUS_SUCCESS; |
| 2988 | } |
| 2989 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2990 | static struct cdp_bus_ops dp_ops_bus = { |
| 2991 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
Dustin Brown | e2e8dc2 | 2016-12-21 12:01:03 -0800 | [diff] [blame] | 2992 | .bus_suspend = dp_dummy_bus_suspend, |
| 2993 | .bus_resume = dp_dummy_bus_resume |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 2994 | }; |
| 2995 | |
| 2996 | static struct cdp_ocb_ops dp_ops_ocb = { |
| 2997 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 2998 | }; |
| 2999 | |
| 3000 | |
| 3001 | static struct cdp_throttle_ops dp_ops_throttle = { |
| 3002 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 3003 | }; |
| 3004 | |
| 3005 | static struct cdp_mob_stats_ops dp_ops_mob_stats = { |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3006 | }; |
| 3007 | |
| 3008 | static struct cdp_cfg_ops dp_ops_cfg = { |
| 3009 | /* WIFI 3.0 DP NOT IMPLEMENTED YET */ |
| 3010 | }; |
| 3011 | |
| 3012 | static struct cdp_peer_ops dp_ops_peer = { |
| 3013 | .register_peer = dp_register_peer, |
| 3014 | .clear_peer = dp_clear_peer, |
| 3015 | .find_peer_by_addr = dp_find_peer_by_addr, |
| 3016 | .find_peer_by_addr_and_vdev = dp_find_peer_by_addr_and_vdev, |
| 3017 | .local_peer_id = dp_local_peer_id, |
| 3018 | .peer_find_by_local_id = dp_peer_find_by_local_id, |
| 3019 | .peer_state_update = dp_peer_state_update, |
| 3020 | .get_vdevid = dp_get_vdevid, |
| 3021 | .peer_get_peer_mac_addr = dp_peer_get_peer_mac_addr, |
| 3022 | .get_vdev_for_peer = dp_get_vdev_for_peer, |
| 3023 | .get_peer_state = dp_get_peer_state, |
Krishna Kumaar Natarajan | d684ba2 | 2017-01-25 15:48:43 -0800 | [diff] [blame] | 3024 | .last_assoc_received = dp_get_last_assoc_received, |
| 3025 | .last_disassoc_received = dp_get_last_disassoc_received, |
| 3026 | .last_deauth_received = dp_get_last_deauth_received, |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3027 | }; |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 3028 | #endif |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3029 | |
| 3030 | static struct cdp_ops dp_txrx_ops = { |
| 3031 | .cmn_drv_ops = &dp_ops_cmn, |
| 3032 | .ctrl_ops = &dp_ops_ctrl, |
| 3033 | .me_ops = &dp_ops_me, |
| 3034 | .mon_ops = &dp_ops_mon, |
| 3035 | .host_stats_ops = &dp_ops_host_stats, |
| 3036 | .wds_ops = &dp_ops_wds, |
| 3037 | .raw_ops = &dp_ops_raw, |
| 3038 | #ifdef CONFIG_WIN |
| 3039 | .pflow_ops = &dp_ops_pflow, |
| 3040 | #endif /* CONFIG_WIN */ |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 3041 | #ifndef CONFIG_WIN |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3042 | .misc_ops = &dp_ops_misc, |
| 3043 | .cfg_ops = &dp_ops_cfg, |
| 3044 | .flowctl_ops = &dp_ops_flowctl, |
| 3045 | .l_flowctl_ops = &dp_ops_l_flowctl, |
| 3046 | .ipa_ops = &dp_ops_ipa, |
| 3047 | .lro_ops = &dp_ops_lro, |
| 3048 | .bus_ops = &dp_ops_bus, |
| 3049 | .ocb_ops = &dp_ops_ocb, |
| 3050 | .peer_ops = &dp_ops_peer, |
| 3051 | .throttle_ops = &dp_ops_throttle, |
| 3052 | .mob_stats_ops = &dp_ops_mob_stats, |
Nandha Kishore Easwaran | fd7832e | 2016-11-20 18:22:48 +0530 | [diff] [blame] | 3053 | #endif |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3054 | }; |
| 3055 | |
| 3056 | /* |
| 3057 | * dp_soc_attach_wifi3() - Attach txrx SOC |
| 3058 | * @osif_soc: Opaque SOC handle from OSIF/HDD |
| 3059 | * @htc_handle: Opaque HTC handle |
| 3060 | * @hif_handle: Opaque HIF handle |
| 3061 | * @qdf_osdev: QDF device |
| 3062 | * |
| 3063 | * Return: DP SOC handle on success, NULL on failure |
| 3064 | */ |
Jeff Johnson | 0771857 | 2017-01-10 13:57:15 -0800 | [diff] [blame] | 3065 | /* |
| 3066 | * Local prototype added to temporarily address warning caused by |
| 3067 | * -Wmissing-prototypes. A more correct solution, namely to expose |
| 3068 | * a prototype in an appropriate header file, will come later. |
| 3069 | */ |
| 3070 | void *dp_soc_attach_wifi3(void *osif_soc, void *hif_handle, |
| 3071 | HTC_HANDLE htc_handle, qdf_device_t qdf_osdev, |
| 3072 | struct ol_if_ops *ol_ops); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3073 | void *dp_soc_attach_wifi3(void *osif_soc, void *hif_handle, |
| 3074 | HTC_HANDLE htc_handle, qdf_device_t qdf_osdev, |
| 3075 | struct ol_if_ops *ol_ops) |
| 3076 | { |
| 3077 | struct dp_soc *soc = qdf_mem_malloc(sizeof(*soc)); |
| 3078 | |
| 3079 | if (!soc) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 3080 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 3081 | FL("DP SOC memory allocation failed")); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3082 | goto fail0; |
| 3083 | } |
| 3084 | |
| 3085 | soc->cdp_soc.ops = &dp_txrx_ops; |
| 3086 | soc->cdp_soc.ol_ops = ol_ops; |
| 3087 | soc->osif_soc = osif_soc; |
| 3088 | soc->osdev = qdf_osdev; |
| 3089 | soc->hif_handle = hif_handle; |
| 3090 | |
| 3091 | soc->hal_soc = hif_get_hal_handle(hif_handle); |
| 3092 | soc->htt_handle = htt_soc_attach(soc, osif_soc, htc_handle, |
| 3093 | soc->hal_soc, qdf_osdev); |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 3094 | if (!soc->htt_handle) { |
| 3095 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 3096 | FL("HTT attach failed")); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3097 | goto fail1; |
| 3098 | } |
| 3099 | |
| 3100 | soc->wlan_cfg_ctx = wlan_cfg_soc_attach(); |
| 3101 | if (!soc->wlan_cfg_ctx) { |
Tallapragada Kalyan | 1ef5480 | 2016-11-30 12:54:55 +0530 | [diff] [blame] | 3102 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 3103 | FL("wlan_cfg_soc_attach failed")); |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3104 | goto fail2; |
| 3105 | } |
| 3106 | qdf_spinlock_create(&soc->peer_ref_mutex); |
| 3107 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3108 | if (dp_soc_interrupt_attach(soc) != QDF_STATUS_SUCCESS) { |
| 3109 | goto fail2; |
| 3110 | } |
| 3111 | |
Karunakar Dasineni | 8bebb00 | 2017-02-09 22:15:23 -0800 | [diff] [blame] | 3112 | qdf_spinlock_create(&soc->reo_desc_freelist_lock); |
| 3113 | qdf_list_create(&soc->reo_desc_freelist, REO_DESC_FREELIST_SIZE); |
| 3114 | |
Leo Chang | 5ea93a4 | 2016-11-03 12:39:49 -0700 | [diff] [blame] | 3115 | return (void *)soc; |
| 3116 | |
| 3117 | fail2: |
| 3118 | htt_soc_detach(soc->htt_handle); |
| 3119 | fail1: |
| 3120 | qdf_mem_free(soc); |
| 3121 | fail0: |
| 3122 | return NULL; |
Karunakar Dasineni | 9b814ce | 2016-09-01 15:00:09 -0700 | [diff] [blame] | 3123 | } |