Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /* Include Files */ |
| 29 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 30 | /* denote that this file does not allow legacy hddLog */ |
| 31 | #define HDD_DISALLOW_LEGACY_HDDLOG 1 |
| 32 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | #include <wlan_hdd_includes.h> |
| 34 | #include <wlan_hdd_wowl.h> |
| 35 | #include "wlan_hdd_trace.h" |
| 36 | #include "wlan_hdd_ioctl.h" |
| 37 | #include "wlan_hdd_power.h" |
| 38 | #include "wlan_hdd_driver_ops.h" |
| 39 | #include "cds_concurrency.h" |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 40 | #include "wlan_hdd_hostapd.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | |
| 42 | #include "wlan_hdd_p2p.h" |
| 43 | #include <linux/ctype.h> |
| 44 | #include "wma.h" |
| 45 | #include "wlan_hdd_napi.h" |
| 46 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 47 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 48 | #include <sme_api.h> |
| 49 | #include <sir_api.h> |
| 50 | #endif |
| 51 | #include "hif.h" |
| 52 | |
| 53 | #if defined(LINUX_QCMBR) |
| 54 | #define SIOCIOCTLTX99 (SIOCDEVPRIVATE+13) |
| 55 | #endif |
| 56 | |
| 57 | /* |
| 58 | * Size of Driver command strings from upper layer |
| 59 | */ |
| 60 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 61 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
| 62 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 63 | /* |
| 64 | * Ibss prop IE from command will be of size: |
| 65 | * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) |
| 66 | * OUI_DATA should be at least 3 bytes long |
| 67 | */ |
| 68 | #define WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH (3) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 69 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 70 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 71 | #define TID_MIN_VALUE 0 |
| 72 | #define TID_MAX_VALUE 15 |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 73 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 74 | |
| 75 | /* |
| 76 | * Maximum buffer size used for returning the data back to user space |
| 77 | */ |
| 78 | #define WLAN_MAX_BUF_SIZE 1024 |
| 79 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
| 80 | |
| 81 | /* |
| 82 | * Driver miracast parameters 0-Disabled |
| 83 | * 1-Source, 2-Sink |
| 84 | */ |
| 85 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0 |
| 86 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2 |
| 87 | |
| 88 | /* |
| 89 | * When ever we need to print IBSSPEERINFOALL for more than 16 STA |
| 90 | * we will split the printing. |
| 91 | */ |
| 92 | #define NUM_OF_STA_DATA_TO_PRINT 16 |
| 93 | |
| 94 | /* |
| 95 | * Android DRIVER command structures |
| 96 | */ |
| 97 | struct android_wifi_reassoc_params { |
| 98 | unsigned char bssid[18]; |
| 99 | int channel; |
| 100 | }; |
| 101 | |
| 102 | #define ANDROID_WIFI_ACTION_FRAME_SIZE 1040 |
| 103 | struct android_wifi_af_params { |
| 104 | unsigned char bssid[18]; |
| 105 | int channel; |
| 106 | int dwell_time; |
| 107 | int len; |
| 108 | unsigned char data[ANDROID_WIFI_ACTION_FRAME_SIZE]; |
| 109 | }; |
| 110 | |
| 111 | /* |
| 112 | * Define HDD driver command handling entry, each contains a command |
| 113 | * string and the handler. |
| 114 | */ |
| 115 | typedef int (*hdd_drv_cmd_handler_t)(hdd_adapter_t *adapter, |
| 116 | hdd_context_t *hdd_ctx, |
| 117 | uint8_t *cmd, |
| 118 | uint8_t cmd_name_len, |
| 119 | hdd_priv_data_t *priv_data); |
| 120 | |
| 121 | typedef struct { |
| 122 | const char *cmd; |
| 123 | hdd_drv_cmd_handler_t handler; |
| 124 | } hdd_drv_cmd_t; |
| 125 | |
| 126 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 127 | #define WLAN_WAIT_TIME_READY_TO_EXTWOW 2000 |
| 128 | #define WLAN_HDD_MAX_TCP_PORT 65535 |
| 129 | #endif |
| 130 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 131 | static uint16_t cesium_pid; |
| 132 | extern struct sock *cesium_nl_srv_sock; |
| 133 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 134 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 135 | static void hdd_get_tsm_stats_cb(tAniTrafStrmMetrics tsm_metrics, |
| 136 | const uint32_t staId, void *context) |
| 137 | { |
| 138 | struct statsContext *stats_context = NULL; |
| 139 | hdd_adapter_t *adapter = NULL; |
| 140 | |
| 141 | if (NULL == context) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 142 | hdd_err("Bad param, context [%p]", context); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 143 | return; |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | * there is a race condition that exists between this callback |
| 148 | * function and the caller since the caller could time out either |
| 149 | * before or while this code is executing. we use a spinlock to |
| 150 | * serialize these actions |
| 151 | */ |
| 152 | spin_lock(&hdd_context_lock); |
| 153 | |
| 154 | stats_context = context; |
| 155 | adapter = stats_context->pAdapter; |
| 156 | if ((NULL == adapter) || |
| 157 | (STATS_CONTEXT_MAGIC != stats_context->magic)) { |
| 158 | /* |
| 159 | * the caller presumably timed out so there is |
| 160 | * nothing we can do |
| 161 | */ |
| 162 | spin_unlock(&hdd_context_lock); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 163 | hdd_warn("Invalid context, adapter [%p] magic [%08x]", |
| 164 | adapter, stats_context->magic); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 165 | return; |
| 166 | } |
| 167 | |
| 168 | /* context is valid so caller is still waiting */ |
| 169 | |
| 170 | /* paranoia: invalidate the magic */ |
| 171 | stats_context->magic = 0; |
| 172 | |
| 173 | /* copy over the tsm stats */ |
| 174 | adapter->tsmStats.UplinkPktQueueDly = tsm_metrics.UplinkPktQueueDly; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 175 | qdf_mem_copy(adapter->tsmStats.UplinkPktQueueDlyHist, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 176 | tsm_metrics.UplinkPktQueueDlyHist, |
| 177 | sizeof(adapter->tsmStats.UplinkPktQueueDlyHist) / |
| 178 | sizeof(adapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 179 | adapter->tsmStats.UplinkPktTxDly = tsm_metrics.UplinkPktTxDly; |
| 180 | adapter->tsmStats.UplinkPktLoss = tsm_metrics.UplinkPktLoss; |
| 181 | adapter->tsmStats.UplinkPktCount = tsm_metrics.UplinkPktCount; |
| 182 | adapter->tsmStats.RoamingCount = tsm_metrics.RoamingCount; |
| 183 | adapter->tsmStats.RoamingDly = tsm_metrics.RoamingDly; |
| 184 | |
| 185 | /* notify the caller */ |
| 186 | complete(&stats_context->completion); |
| 187 | |
| 188 | /* serialization is complete */ |
| 189 | spin_unlock(&hdd_context_lock); |
| 190 | } |
| 191 | |
| 192 | static |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 193 | QDF_STATUS hdd_get_tsm_stats(hdd_adapter_t *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 194 | const uint8_t tid, |
| 195 | tAniTrafStrmMetrics *tsm_metrics) |
| 196 | { |
| 197 | hdd_station_ctx_t *hdd_sta_ctx = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 198 | QDF_STATUS hstatus; |
| 199 | QDF_STATUS vstatus = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 200 | unsigned long rc; |
| 201 | struct statsContext context; |
| 202 | hdd_context_t *hdd_ctx = NULL; |
| 203 | |
| 204 | if (NULL == adapter) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 205 | hdd_err("adapter is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 206 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 210 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 211 | |
| 212 | /* we are connected prepare our callback context */ |
| 213 | init_completion(&context.completion); |
| 214 | context.pAdapter = adapter; |
| 215 | context.magic = STATS_CONTEXT_MAGIC; |
| 216 | |
| 217 | /* query tsm stats */ |
| 218 | hstatus = sme_get_tsm_stats(hdd_ctx->hHal, hdd_get_tsm_stats_cb, |
| 219 | hdd_sta_ctx->conn_info.staId[0], |
| 220 | hdd_sta_ctx->conn_info.bssId, |
| 221 | &context, hdd_ctx->pcds_context, tid); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 222 | if (QDF_STATUS_SUCCESS != hstatus) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 223 | hdd_err("Unable to retrieve statistics"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 224 | vstatus = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | } else { |
| 226 | /* request was sent -- wait for the response */ |
| 227 | rc = wait_for_completion_timeout(&context.completion, |
| 228 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
| 229 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 230 | hdd_err("SME timed out while retrieving statistics"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 231 | vstatus = QDF_STATUS_E_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | |
| 235 | /* |
| 236 | * either we never sent a request, we sent a request and received a |
| 237 | * response or we sent a request and timed out. if we never sent a |
| 238 | * request or if we sent a request and got a response, we want to |
| 239 | * clear the magic out of paranoia. if we timed out there is a |
| 240 | * race condition such that the callback function could be |
| 241 | * executing at the same time we are. of primary concern is if the |
| 242 | * callback function had already verified the "magic" but had not |
| 243 | * yet set the completion variable when a timeout occurred. we |
| 244 | * serialize these activities by invalidating the magic while |
| 245 | * holding a shared spinlock which will cause us to block if the |
| 246 | * callback is currently executing |
| 247 | */ |
| 248 | spin_lock(&hdd_context_lock); |
| 249 | context.magic = 0; |
| 250 | spin_unlock(&hdd_context_lock); |
| 251 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 252 | if (QDF_STATUS_SUCCESS == vstatus) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 253 | tsm_metrics->UplinkPktQueueDly = |
| 254 | adapter->tsmStats.UplinkPktQueueDly; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 255 | qdf_mem_copy(tsm_metrics->UplinkPktQueueDlyHist, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 256 | adapter->tsmStats.UplinkPktQueueDlyHist, |
| 257 | sizeof(adapter->tsmStats.UplinkPktQueueDlyHist) / |
| 258 | sizeof(adapter->tsmStats. |
| 259 | UplinkPktQueueDlyHist[0])); |
| 260 | tsm_metrics->UplinkPktTxDly = adapter->tsmStats.UplinkPktTxDly; |
| 261 | tsm_metrics->UplinkPktLoss = adapter->tsmStats.UplinkPktLoss; |
| 262 | tsm_metrics->UplinkPktCount = adapter->tsmStats.UplinkPktCount; |
| 263 | tsm_metrics->RoamingCount = adapter->tsmStats.RoamingCount; |
| 264 | tsm_metrics->RoamingDly = adapter->tsmStats.RoamingDly; |
| 265 | } |
| 266 | return vstatus; |
| 267 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 268 | #endif /*FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 269 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 270 | /* Function header is left blank intentionally */ |
| 271 | static int hdd_parse_setrmcenable_command(uint8_t *pValue, |
| 272 | uint8_t *pRmcEnable) |
| 273 | { |
| 274 | uint8_t *inPtr = pValue; |
| 275 | int tempInt; |
| 276 | int v = 0; |
| 277 | char buf[32]; |
| 278 | *pRmcEnable = 0; |
| 279 | |
| 280 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 281 | |
| 282 | if (NULL == inPtr) { |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 291 | inPtr++; |
| 292 | |
| 293 | if ('\0' == *inPtr) { |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | sscanf(inPtr, "%32s ", buf); |
| 298 | v = kstrtos32(buf, 10, &tempInt); |
| 299 | if (v < 0) { |
| 300 | return -EINVAL; |
| 301 | } |
| 302 | |
| 303 | *pRmcEnable = tempInt; |
| 304 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 305 | hdd_info("ucRmcEnable: %d", *pRmcEnable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | /* Function header is left blank intentionally */ |
| 311 | static int hdd_parse_setrmcactionperiod_command(uint8_t *pValue, |
| 312 | uint32_t *pActionPeriod) |
| 313 | { |
| 314 | uint8_t *inPtr = pValue; |
| 315 | int tempInt; |
| 316 | int v = 0; |
| 317 | char buf[32]; |
| 318 | *pActionPeriod = 0; |
| 319 | |
| 320 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 321 | |
| 322 | if (NULL == inPtr) { |
| 323 | return -EINVAL; |
| 324 | } |
| 325 | |
| 326 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 327 | return -EINVAL; |
| 328 | } |
| 329 | |
| 330 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 331 | inPtr++; |
| 332 | |
| 333 | if ('\0' == *inPtr) { |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | sscanf(inPtr, "%32s ", buf); |
| 338 | v = kstrtos32(buf, 10, &tempInt); |
| 339 | if (v < 0) { |
| 340 | return -EINVAL; |
| 341 | } |
| 342 | |
| 343 | if ((tempInt < WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMIN) || |
| 344 | (tempInt > WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMAX)) { |
| 345 | return -EINVAL; |
| 346 | } |
| 347 | |
| 348 | *pActionPeriod = tempInt; |
| 349 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 350 | hdd_info("uActionPeriod: %d", *pActionPeriod); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | /* Function header is left blank intentionally */ |
| 356 | static int hdd_parse_setrmcrate_command(uint8_t *pValue, |
| 357 | uint32_t *pRate, |
| 358 | tTxrateinfoflags *pTxFlags) |
| 359 | { |
| 360 | uint8_t *inPtr = pValue; |
| 361 | int tempInt; |
| 362 | int v = 0; |
| 363 | char buf[32]; |
| 364 | *pRate = 0; |
| 365 | *pTxFlags = 0; |
| 366 | |
| 367 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 368 | |
| 369 | if (NULL == inPtr) { |
| 370 | return -EINVAL; |
| 371 | } |
| 372 | |
| 373 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 374 | return -EINVAL; |
| 375 | } |
| 376 | |
| 377 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 378 | inPtr++; |
| 379 | |
| 380 | if ('\0' == *inPtr) { |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | sscanf(inPtr, "%32s ", buf); |
| 385 | v = kstrtos32(buf, 10, &tempInt); |
| 386 | if (v < 0) { |
| 387 | return -EINVAL; |
| 388 | } |
| 389 | |
| 390 | switch (tempInt) { |
| 391 | default: |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 392 | hdd_warn("Unsupported rate: %d", tempInt); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 393 | return -EINVAL; |
| 394 | case 0: |
| 395 | case 6: |
| 396 | case 9: |
| 397 | case 12: |
| 398 | case 18: |
| 399 | case 24: |
| 400 | case 36: |
| 401 | case 48: |
| 402 | case 54: |
| 403 | *pTxFlags = eHAL_TX_RATE_LEGACY; |
| 404 | *pRate = tempInt * 10; |
| 405 | break; |
| 406 | case 65: |
| 407 | *pTxFlags = eHAL_TX_RATE_HT20; |
| 408 | *pRate = tempInt * 10; |
| 409 | break; |
| 410 | case 72: |
| 411 | *pTxFlags = eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI; |
| 412 | *pRate = 722; |
| 413 | break; |
| 414 | } |
| 415 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 416 | hdd_info("Rate: %d", *pRate); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 417 | |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | /** |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 422 | * hdd_get_ibss_peer_info_cb() - IBSS peer Info request callback |
| 423 | * @UserData: Adapter private data |
| 424 | * @pPeerInfoRsp: Peer info response |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 425 | * |
| 426 | * This is an asynchronous callback function from SME when the peer info |
| 427 | * is received |
| 428 | * |
| 429 | * Return: 0 for success non-zero for failure |
| 430 | */ |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 431 | void |
| 432 | hdd_get_ibss_peer_info_cb(void *pUserData, |
| 433 | tSirPeerInfoRspParams *pPeerInfo) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 434 | { |
| 435 | hdd_adapter_t *adapter = (hdd_adapter_t *) pUserData; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 436 | hdd_station_ctx_t *pStaCtx; |
| 437 | uint8_t i; |
| 438 | |
| 439 | /* Sanity check */ |
| 440 | if ((NULL == adapter) || |
| 441 | (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 442 | hdd_alert("invalid adapter or adapter has invalid magic"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 443 | return; |
| 444 | } |
| 445 | |
| 446 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 447 | if (NULL != pPeerInfo && QDF_STATUS_SUCCESS == pPeerInfo->status) { |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 448 | /* validate number of peers */ |
| 449 | if (pPeerInfo->numPeers < SIR_MAX_NUM_STA_IN_IBSS) { |
| 450 | pStaCtx->ibss_peer_info.status = pPeerInfo->status; |
| 451 | pStaCtx->ibss_peer_info.numPeers = pPeerInfo->numPeers; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 452 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 453 | for (i = 0; i < pPeerInfo->numPeers; i++) { |
| 454 | pStaCtx->ibss_peer_info.peerInfoParams[i] = |
| 455 | pPeerInfo->peerInfoParams[i]; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 456 | } |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 457 | hdd_info("Peer Info copied in HDD"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 458 | } else { |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 459 | hdd_info("Number of peers %d returned is more than limit %d", |
| 460 | pPeerInfo->numPeers, SIR_MAX_NUM_STA_IN_IBSS); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 461 | } |
| 462 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 463 | hdd_info("peerInfo returned is NULL"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | complete(&adapter->ibss_peer_info_comp); |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * hdd_cfg80211_get_ibss_peer_info_all() - get ibss peers' info |
| 471 | * @adapter: Adapter context |
| 472 | * |
| 473 | * Request function to get IBSS peer info from lower layers |
| 474 | * |
| 475 | * Return: 0 for success non-zero for failure |
| 476 | */ |
| 477 | static |
| 478 | QDF_STATUS hdd_cfg80211_get_ibss_peer_info_all(hdd_adapter_t *adapter) |
| 479 | { |
| 480 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 481 | QDF_STATUS retStatus = QDF_STATUS_E_FAILURE; |
| 482 | unsigned long rc; |
| 483 | |
| 484 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 485 | |
| 486 | retStatus = sme_request_ibss_peer_info(hHal, adapter, |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 487 | hdd_get_ibss_peer_info_cb, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 488 | true, 0xFF); |
| 489 | |
| 490 | if (QDF_STATUS_SUCCESS == retStatus) { |
| 491 | rc = wait_for_completion_timeout |
| 492 | (&adapter->ibss_peer_info_comp, |
| 493 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 494 | |
| 495 | /* status will be 0 if timed out */ |
| 496 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 497 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 498 | retStatus = QDF_STATUS_E_FAILURE; |
| 499 | return retStatus; |
| 500 | } |
| 501 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 502 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | return retStatus; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * hdd_cfg80211_get_ibss_peer_info() - get ibss peer info |
| 510 | * @adapter: Adapter context |
| 511 | * @staIdx: Sta index for which the peer info is requested |
| 512 | * |
| 513 | * Request function to get IBSS peer info from lower layers |
| 514 | * |
| 515 | * Return: 0 for success non-zero for failure |
| 516 | */ |
| 517 | static QDF_STATUS |
| 518 | hdd_cfg80211_get_ibss_peer_info(hdd_adapter_t *adapter, uint8_t staIdx) |
| 519 | { |
| 520 | unsigned long rc; |
| 521 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 522 | QDF_STATUS retStatus = QDF_STATUS_E_FAILURE; |
| 523 | |
| 524 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 525 | |
| 526 | retStatus = sme_request_ibss_peer_info(hHal, adapter, |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 527 | hdd_get_ibss_peer_info_cb, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 528 | false, staIdx); |
| 529 | |
| 530 | if (QDF_STATUS_SUCCESS == retStatus) { |
| 531 | rc = wait_for_completion_timeout( |
| 532 | &adapter->ibss_peer_info_comp, |
| 533 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 534 | |
| 535 | /* status = 0 on timeout */ |
| 536 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 537 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 538 | retStatus = QDF_STATUS_E_FAILURE; |
| 539 | return retStatus; |
| 540 | } |
| 541 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 542 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | return retStatus; |
| 546 | } |
| 547 | |
| 548 | /* Function header is left blank intentionally */ |
| 549 | QDF_STATUS |
| 550 | hdd_parse_get_ibss_peer_info(uint8_t *pValue, struct qdf_mac_addr *pPeerMacAddr) |
| 551 | { |
| 552 | uint8_t *inPtr = pValue; |
| 553 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 554 | |
| 555 | if (NULL == inPtr) { |
| 556 | return QDF_STATUS_E_FAILURE;; |
| 557 | } |
| 558 | |
| 559 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 560 | return QDF_STATUS_E_FAILURE;; |
| 561 | } |
| 562 | |
| 563 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 564 | inPtr++; |
| 565 | |
| 566 | if ('\0' == *inPtr) { |
| 567 | return QDF_STATUS_E_FAILURE;; |
| 568 | } |
| 569 | |
| 570 | if (inPtr[2] != ':' || inPtr[5] != ':' || inPtr[8] != ':' || |
| 571 | inPtr[11] != ':' || inPtr[14] != ':') { |
| 572 | return QDF_STATUS_E_FAILURE;; |
| 573 | } |
| 574 | sscanf(inPtr, "%2x:%2x:%2x:%2x:%2x:%2x", |
| 575 | (unsigned int *)&pPeerMacAddr->bytes[0], |
| 576 | (unsigned int *)&pPeerMacAddr->bytes[1], |
| 577 | (unsigned int *)&pPeerMacAddr->bytes[2], |
| 578 | (unsigned int *)&pPeerMacAddr->bytes[3], |
| 579 | (unsigned int *)&pPeerMacAddr->bytes[4], |
| 580 | (unsigned int *)&pPeerMacAddr->bytes[5]); |
| 581 | |
| 582 | return QDF_STATUS_SUCCESS; |
| 583 | } |
| 584 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 585 | static void hdd_get_band_helper(hdd_context_t *hdd_ctx, int *pBand) |
| 586 | { |
| 587 | eCsrBand band = -1; |
| 588 | sme_get_freq_band((tHalHandle) (hdd_ctx->hHal), &band); |
| 589 | switch (band) { |
| 590 | case eCSR_BAND_ALL: |
| 591 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 592 | break; |
| 593 | |
| 594 | case eCSR_BAND_24: |
| 595 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 596 | break; |
| 597 | |
| 598 | case eCSR_BAND_5G: |
| 599 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 600 | break; |
| 601 | |
| 602 | default: |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 603 | hdd_warn("Invalid Band %d", band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | *pBand = -1; |
| 605 | break; |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * _hdd_parse_bssid_and_chan() - helper function to parse bssid and channel |
| 611 | * @data: input data |
| 612 | * @target_ap_bssid: pointer to bssid (output parameter) |
| 613 | * @channel: pointer to channel (output parameter) |
| 614 | * |
| 615 | * Return: 0 if parsing is successful; -EINVAL otherwise |
| 616 | */ |
| 617 | static int _hdd_parse_bssid_and_chan(const uint8_t **data, |
| 618 | uint8_t *bssid, |
| 619 | uint8_t *channel) |
| 620 | { |
| 621 | const uint8_t *in_ptr; |
| 622 | int v = 0; |
| 623 | int temp_int; |
| 624 | uint8_t temp_buf[32]; |
| 625 | |
| 626 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 627 | uint8_t mac_addr[18]; |
| 628 | |
| 629 | if (!data || !*data) |
| 630 | return -EINVAL; |
| 631 | |
| 632 | in_ptr = *data; |
| 633 | |
| 634 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 635 | /* no argument after the command */ |
| 636 | if (NULL == in_ptr) |
| 637 | goto error; |
| 638 | /* no space after the command */ |
| 639 | else if (SPACE_ASCII_VALUE != *in_ptr) |
| 640 | goto error; |
| 641 | |
| 642 | /* remove empty spaces */ |
| 643 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 644 | in_ptr++; |
| 645 | |
| 646 | /* no argument followed by spaces */ |
| 647 | if ('\0' == *in_ptr) |
| 648 | goto error; |
| 649 | |
| 650 | v = sscanf(in_ptr, "%17s", mac_addr); |
| 651 | if (!((1 == v) && hdd_is_valid_mac_address(mac_addr))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 652 | hdd_err("Invalid MAC address or All hex inputs are not read (%d)", |
| 653 | v); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 654 | goto error; |
| 655 | } |
| 656 | |
| 657 | bssid[0] = hex_to_bin(mac_addr[0]) << 4 | |
| 658 | hex_to_bin(mac_addr[1]); |
| 659 | bssid[1] = hex_to_bin(mac_addr[3]) << 4 | |
| 660 | hex_to_bin(mac_addr[4]); |
| 661 | bssid[2] = hex_to_bin(mac_addr[6]) << 4 | |
| 662 | hex_to_bin(mac_addr[7]); |
| 663 | bssid[3] = hex_to_bin(mac_addr[9]) << 4 | |
| 664 | hex_to_bin(mac_addr[10]); |
| 665 | bssid[4] = hex_to_bin(mac_addr[12]) << 4 | |
| 666 | hex_to_bin(mac_addr[13]); |
| 667 | bssid[5] = hex_to_bin(mac_addr[15]) << 4 | |
| 668 | hex_to_bin(mac_addr[16]); |
| 669 | |
| 670 | /* point to the next argument */ |
| 671 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 672 | /* no argument after the command */ |
| 673 | if (NULL == in_ptr) |
| 674 | goto error; |
| 675 | |
| 676 | /* remove empty spaces */ |
| 677 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 678 | in_ptr++; |
| 679 | |
| 680 | /* no argument followed by spaces */ |
| 681 | if ('\0' == *in_ptr) |
| 682 | goto error; |
| 683 | |
| 684 | /* get the next argument ie the channel number */ |
| 685 | v = sscanf(in_ptr, "%31s ", temp_buf); |
| 686 | if (1 != v) |
| 687 | goto error; |
| 688 | |
| 689 | v = kstrtos32(temp_buf, 10, &temp_int); |
| 690 | if ((v < 0) || (temp_int < 0) || |
| 691 | (temp_int > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 692 | return -EINVAL; |
| 693 | |
| 694 | *channel = temp_int; |
| 695 | *data = in_ptr; |
| 696 | return 0; |
| 697 | error: |
| 698 | *data = in_ptr; |
| 699 | return -EINVAL; |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 704 | * @pValue: Pointer to input data |
| 705 | * @pTargetApBssid: Pointer to target Ap bssid |
| 706 | * @pChannel: Pointer to the Target AP channel |
| 707 | * @pDwellTime: Pointer to the time to stay off-channel |
| 708 | * after transmitting action frame |
| 709 | * @pBuf: Pointer to data |
| 710 | * @pBufLen: Pointer to data length |
| 711 | * |
| 712 | * This function parses the send action frame data passed in the format |
| 713 | * SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 714 | * |
| 715 | * Return: 0 for success non-zero for failure |
| 716 | */ |
| 717 | static int |
| 718 | hdd_parse_send_action_frame_v1_data(const uint8_t *pValue, |
| 719 | uint8_t *pTargetApBssid, |
| 720 | uint8_t *pChannel, uint8_t *pDwellTime, |
| 721 | uint8_t **pBuf, uint8_t *pBufLen) |
| 722 | { |
| 723 | const uint8_t *inPtr = pValue; |
| 724 | const uint8_t *dataEnd; |
| 725 | int tempInt; |
| 726 | int j = 0; |
| 727 | int i = 0; |
| 728 | int v = 0; |
| 729 | uint8_t tempBuf[32]; |
| 730 | uint8_t tempByte = 0; |
| 731 | |
| 732 | if (_hdd_parse_bssid_and_chan(&inPtr, pTargetApBssid, pChannel)) |
| 733 | return -EINVAL; |
| 734 | |
| 735 | /* point to the next argument */ |
| 736 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 737 | /* no argument after the command */ |
| 738 | if (NULL == inPtr) |
| 739 | return -EINVAL; |
| 740 | /* removing empty spaces */ |
| 741 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 742 | inPtr++; |
| 743 | |
| 744 | /* no argument followed by spaces */ |
| 745 | if ('\0' == *inPtr) { |
| 746 | return -EINVAL; |
| 747 | } |
| 748 | |
| 749 | /* getting the next argument ie the dwell time */ |
| 750 | v = sscanf(inPtr, "%31s ", tempBuf); |
| 751 | if (1 != v) |
| 752 | return -EINVAL; |
| 753 | |
| 754 | v = kstrtos32(tempBuf, 10, &tempInt); |
| 755 | if (v < 0 || tempInt < 0) |
| 756 | return -EINVAL; |
| 757 | |
| 758 | *pDwellTime = tempInt; |
| 759 | |
| 760 | /* point to the next argument */ |
| 761 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 762 | /* no argument after the command */ |
| 763 | if (NULL == inPtr) |
| 764 | return -EINVAL; |
| 765 | /* removing empty spaces */ |
| 766 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 767 | inPtr++; |
| 768 | |
| 769 | /* no argument followed by spaces */ |
| 770 | if ('\0' == *inPtr) { |
| 771 | return -EINVAL; |
| 772 | } |
| 773 | |
| 774 | /* find the length of data */ |
| 775 | dataEnd = inPtr; |
| 776 | while (('\0' != *dataEnd)) { |
| 777 | dataEnd++; |
| 778 | } |
| 779 | *pBufLen = dataEnd - inPtr; |
| 780 | if (*pBufLen <= 0) |
| 781 | return -EINVAL; |
| 782 | |
| 783 | /* |
| 784 | * Allocate the number of bytes based on the number of input characters |
| 785 | * whether it is even or odd. |
| 786 | * if the number of input characters are even, then we need N/2 byte. |
| 787 | * if the number of input characters are odd, then we need do (N+1)/2 |
| 788 | * to compensate rounding off. |
| 789 | * For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 790 | * If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes |
| 791 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 792 | *pBuf = qdf_mem_malloc((*pBufLen + 1) / 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | if (NULL == *pBuf) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 794 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 795 | return -ENOMEM; |
| 796 | } |
| 797 | |
| 798 | /* the buffer received from the upper layer is character buffer, |
| 799 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 800 | * decimal number for example 7f0000f0...form a buffer to contain 7f |
| 801 | * in 0th location, 00 in 1st and f0 in 3rd location |
| 802 | */ |
| 803 | for (i = 0, j = 0; j < *pBufLen; j += 2) { |
| 804 | if (j + 1 == *pBufLen) { |
| 805 | tempByte = hex_to_bin(inPtr[j]); |
| 806 | } else { |
| 807 | tempByte = |
| 808 | (hex_to_bin(inPtr[j]) << 4) | |
| 809 | (hex_to_bin(inPtr[j + 1])); |
| 810 | } |
| 811 | (*pBuf)[i++] = tempByte; |
| 812 | } |
| 813 | *pBufLen = i; |
| 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 819 | * @pValue: Pointer to input data (its a NULL terminated string) |
| 820 | * @pTargetApBssid: Pointer to target Ap bssid |
| 821 | * @pChannel: Pointer to the Target AP channel |
| 822 | * |
| 823 | * This function parses the reasoc command data passed in the format |
| 824 | * REASSOC<space><bssid><space><channel> |
| 825 | * |
| 826 | * Return: 0 for success non-zero for failure |
| 827 | */ |
| 828 | static int hdd_parse_reassoc_command_v1_data(const uint8_t *pValue, |
| 829 | uint8_t *pTargetApBssid, |
| 830 | uint8_t *pChannel) |
| 831 | { |
| 832 | const uint8_t *inPtr = pValue; |
| 833 | |
| 834 | if (_hdd_parse_bssid_and_chan(&inPtr, pTargetApBssid, pChannel)) |
| 835 | return -EINVAL; |
| 836 | |
| 837 | return 0; |
| 838 | } |
| 839 | |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 840 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 841 | void hdd_wma_send_fastreassoc_cmd(int sessionId, const tSirMacAddr bssid, |
| 842 | int channel) |
| 843 | { |
| 844 | struct wma_roam_invoke_cmd *fastreassoc; |
| 845 | cds_msg_t msg = {0}; |
| 846 | |
| 847 | fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc)); |
| 848 | if (NULL == fastreassoc) { |
| 849 | hdd_err("qdf_mem_malloc failed for fastreassoc"); |
| 850 | return; |
| 851 | } |
| 852 | fastreassoc->vdev_id = sessionId; |
| 853 | fastreassoc->channel = channel; |
| 854 | fastreassoc->bssid[0] = bssid[0]; |
| 855 | fastreassoc->bssid[1] = bssid[1]; |
| 856 | fastreassoc->bssid[2] = bssid[2]; |
| 857 | fastreassoc->bssid[3] = bssid[3]; |
| 858 | fastreassoc->bssid[4] = bssid[4]; |
| 859 | fastreassoc->bssid[5] = bssid[5]; |
| 860 | |
| 861 | msg.type = SIR_HAL_ROAM_INVOKE; |
| 862 | msg.reserved = 0; |
| 863 | msg.bodyptr = fastreassoc; |
| 864 | if (QDF_STATUS_SUCCESS != cds_mq_post_message(QDF_MODULE_ID_WMA, |
| 865 | &msg)) { |
| 866 | qdf_mem_free(fastreassoc); |
| 867 | hdd_err("Not able to post ROAM_INVOKE_CMD message to WMA"); |
| 868 | } |
| 869 | } |
| 870 | #else |
| 871 | void hdd_wma_send_fastreassoc_cmd(int sessionId, const tSirMacAddr bssid, |
| 872 | int channel) |
| 873 | { |
| 874 | } |
| 875 | |
| 876 | #endif |
| 877 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 878 | /** |
| 879 | * hdd_reassoc() - perform a userspace-directed reassoc |
| 880 | * @adapter: Adapter upon which the command was received |
| 881 | * @bssid: BSSID with which to reassociate |
| 882 | * @channel: channel upon which to reassociate |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 883 | * @src: The source for the trigger of this action |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 884 | * |
| 885 | * This function performs a userspace-directed reassoc operation |
| 886 | * |
| 887 | * Return: 0 for success non-zero for failure |
| 888 | */ |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 889 | int hdd_reassoc(hdd_adapter_t *adapter, const uint8_t *bssid, |
| 890 | const uint8_t channel, const handoff_src src) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 891 | { |
| 892 | hdd_station_ctx_t *pHddStaCtx; |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 893 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | int ret = 0; |
| 895 | |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 896 | if (hdd_ctx == NULL) { |
| 897 | hdd_err("Invalid hdd ctx"); |
| 898 | return -EINVAL; |
| 899 | } |
| 900 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 901 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 902 | hdd_warn("Unsupported in mode %s(%d)", |
| 903 | hdd_device_mode_to_string(adapter->device_mode), |
| 904 | adapter->device_mode); |
| 905 | return -EINVAL; |
| 906 | } |
| 907 | |
| 908 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 909 | |
| 910 | /* if not associated, no need to proceed with reassoc */ |
| 911 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 912 | hdd_info("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 913 | ret = -EINVAL; |
| 914 | goto exit; |
| 915 | } |
| 916 | |
| 917 | /* |
| 918 | * if the target bssid is same as currently associated AP, |
| 919 | * then no need to proceed with reassoc |
| 920 | */ |
| 921 | if (!memcmp(bssid, pHddStaCtx->conn_info.bssId.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 922 | QDF_MAC_ADDR_SIZE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 923 | hdd_info("Reassoc BSSID is same as currently associated AP bssid"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 924 | ret = -EINVAL; |
| 925 | goto exit; |
| 926 | } |
| 927 | |
| 928 | /* Check channel number is a valid channel number */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 929 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 930 | wlan_hdd_validate_operation_channel(adapter, channel)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 931 | hdd_err("Invalid Channel %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 932 | ret = -EINVAL; |
| 933 | goto exit; |
| 934 | } |
| 935 | |
| 936 | /* Proceed with reassoc */ |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 937 | if (roaming_offload_enabled(hdd_ctx)) { |
| 938 | hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId, |
| 939 | bssid, (int)channel); |
| 940 | } else { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | tCsrHandoffRequest handoffInfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 942 | |
| 943 | handoffInfo.channel = channel; |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 944 | handoffInfo.src = src; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 945 | qdf_mem_copy(handoffInfo.bssid.bytes, bssid, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 946 | sme_handoff_request(hdd_ctx->hHal, adapter->sessionId, |
| 947 | &handoffInfo); |
| 948 | } |
| 949 | exit: |
| 950 | return ret; |
| 951 | } |
| 952 | |
| 953 | /** |
| 954 | * hdd_parse_reassoc_v1() - parse version 1 of the REASSOC command |
| 955 | * @adapter: Adapter upon which the command was received |
| 956 | * @command: ASCII text command that was received |
| 957 | * |
| 958 | * This function parses the v1 REASSOC command with the format |
| 959 | * |
| 960 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 961 | * |
| 962 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 963 | * BSSID and CH is the ASCII representation of the channel. For |
| 964 | * example |
| 965 | * |
| 966 | * REASSOC 00:0a:0b:11:22:33 48 |
| 967 | * |
| 968 | * Return: 0 for success non-zero for failure |
| 969 | */ |
| 970 | static int hdd_parse_reassoc_v1(hdd_adapter_t *adapter, const char *command) |
| 971 | { |
| 972 | uint8_t channel = 0; |
| 973 | tSirMacAddr bssid; |
| 974 | int ret; |
| 975 | |
| 976 | ret = hdd_parse_reassoc_command_v1_data(command, bssid, &channel); |
| 977 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 978 | hdd_err("Failed to parse reassoc command data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 979 | } else { |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 980 | ret = hdd_reassoc(adapter, bssid, channel, REASSOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 981 | } |
| 982 | return ret; |
| 983 | } |
| 984 | |
| 985 | /** |
| 986 | * hdd_parse_reassoc_v2() - parse version 2 of the REASSOC command |
| 987 | * @adapter: Adapter upon which the command was received |
| 988 | * @command: Command that was received, ASCII command |
| 989 | * followed by binary data |
| 990 | * |
| 991 | * This function parses the v2 REASSOC command with the format |
| 992 | * |
| 993 | * REASSOC <android_wifi_reassoc_params> |
| 994 | * |
| 995 | * Return: 0 for success non-zero for failure |
| 996 | */ |
| 997 | static int hdd_parse_reassoc_v2(hdd_adapter_t *adapter, const char *command) |
| 998 | { |
| 999 | struct android_wifi_reassoc_params params; |
| 1000 | tSirMacAddr bssid; |
| 1001 | int ret; |
| 1002 | |
| 1003 | /* The params are located after "REASSOC " */ |
| 1004 | memcpy(¶ms, command + 8, sizeof(params)); |
| 1005 | |
| 1006 | if (!mac_pton(params.bssid, (u8 *) &bssid)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1007 | hdd_err("MAC address parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | ret = -EINVAL; |
| 1009 | } else { |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 1010 | ret = hdd_reassoc(adapter, bssid, params.channel, REASSOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1011 | } |
| 1012 | return ret; |
| 1013 | } |
| 1014 | |
| 1015 | /** |
| 1016 | * hdd_parse_reassoc() - parse the REASSOC command |
| 1017 | * @adapter: Adapter upon which the command was received |
| 1018 | * @command: Command that was received |
| 1019 | * |
| 1020 | * There are two different versions of the REASSOC command. Version 1 |
| 1021 | * of the command contains a parameter list that is ASCII characters |
| 1022 | * whereas version 2 contains a combination of ASCII and binary |
| 1023 | * payload. Determine if a version 1 or a version 2 command is being |
| 1024 | * parsed by examining the parameters, and then dispatch the parser |
| 1025 | * that is appropriate for the command. |
| 1026 | * |
| 1027 | * Return: 0 for success non-zero for failure |
| 1028 | */ |
| 1029 | static int hdd_parse_reassoc(hdd_adapter_t *adapter, const char *command) |
| 1030 | { |
| 1031 | int ret; |
| 1032 | |
| 1033 | /* both versions start with "REASSOC " |
| 1034 | * v1 has a bssid and channel # as an ASCII string |
| 1035 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 1036 | * v2 has a C struct |
| 1037 | * REASSOC <binary c struct> |
| 1038 | * |
| 1039 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1040 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1041 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1042 | * REASSOC xx:xx:xx:xx:xx:xx* |
| 1043 | * 1111111111222222 |
| 1044 | * 01234567890123456789012345 |
| 1045 | */ |
| 1046 | if (command[25]) { |
| 1047 | ret = hdd_parse_reassoc_v1(adapter, command); |
| 1048 | } else { |
| 1049 | ret = hdd_parse_reassoc_v2(adapter, command); |
| 1050 | } |
| 1051 | |
| 1052 | return ret; |
| 1053 | } |
| 1054 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1055 | /** |
| 1056 | * hdd_sendactionframe() - send a userspace-supplied action frame |
| 1057 | * @adapter: Adapter upon which the command was received |
| 1058 | * @bssid: BSSID target of the action frame |
| 1059 | * @channel: Channel upon which to send the frame |
| 1060 | * @dwell_time: Amount of time to dwell when the frame is sent |
| 1061 | * @payload_len:Length of the payload |
| 1062 | * @payload: Payload of the frame |
| 1063 | * |
| 1064 | * This function sends a userspace-supplied action frame |
| 1065 | * |
| 1066 | * Return: 0 for success non-zero for failure |
| 1067 | */ |
| 1068 | static int |
| 1069 | hdd_sendactionframe(hdd_adapter_t *adapter, const uint8_t *bssid, |
| 1070 | const uint8_t channel, const uint8_t dwell_time, |
| 1071 | const uint8_t payload_len, const uint8_t *payload) |
| 1072 | { |
| 1073 | struct ieee80211_channel chan; |
| 1074 | uint8_t frame_len; |
| 1075 | uint8_t *frame; |
| 1076 | struct ieee80211_hdr_3addr *hdr; |
| 1077 | u64 cookie; |
| 1078 | hdd_station_ctx_t *pHddStaCtx; |
| 1079 | hdd_context_t *hdd_ctx; |
| 1080 | int ret = 0; |
| 1081 | tpSirMacVendorSpecificFrameHdr pVendorSpecific = |
| 1082 | (tpSirMacVendorSpecificFrameHdr) payload; |
| 1083 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1084 | struct cfg80211_mgmt_tx_params params; |
| 1085 | #endif |
| 1086 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 1087 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1088 | hdd_warn("Unsupported in mode %s(%d)", |
| 1089 | hdd_device_mode_to_string(adapter->device_mode), |
| 1090 | adapter->device_mode); |
| 1091 | return -EINVAL; |
| 1092 | } |
| 1093 | |
| 1094 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 1095 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1096 | |
| 1097 | /* if not associated, no need to send action frame */ |
| 1098 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1099 | hdd_info("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1100 | ret = -EINVAL; |
| 1101 | goto exit; |
| 1102 | } |
| 1103 | |
| 1104 | /* |
| 1105 | * if the target bssid is different from currently associated AP, |
| 1106 | * then no need to send action frame |
| 1107 | */ |
| 1108 | if (memcmp(bssid, pHddStaCtx->conn_info.bssId.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1109 | QDF_MAC_ADDR_SIZE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1110 | hdd_info("STA is not associated to this AP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1111 | ret = -EINVAL; |
| 1112 | goto exit; |
| 1113 | } |
| 1114 | |
| 1115 | chan.center_freq = sme_chn_to_freq(channel); |
| 1116 | /* Check if it is specific action frame */ |
| 1117 | if (pVendorSpecific->category == |
| 1118 | SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY) { |
| 1119 | static const uint8_t Oui[] = { 0x00, 0x00, 0xf0 }; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1120 | if (!qdf_mem_cmp(pVendorSpecific->Oui, (void *)Oui, 3)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | /* |
| 1122 | * if the channel number is different from operating |
| 1123 | * channel then no need to send action frame |
| 1124 | */ |
| 1125 | if (channel != 0) { |
| 1126 | if (channel != |
| 1127 | pHddStaCtx->conn_info.operationChannel) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1128 | hdd_info("channel(%d) is different from operating channel(%d)", |
| 1129 | channel, |
| 1130 | pHddStaCtx->conn_info. |
| 1131 | operationChannel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1132 | ret = -EINVAL; |
| 1133 | goto exit; |
| 1134 | } |
| 1135 | /* |
| 1136 | * If channel number is specified and same |
| 1137 | * as home channel, ensure that action frame |
| 1138 | * is sent immediately by cancelling |
| 1139 | * roaming scans. Otherwise large dwell times |
| 1140 | * may cause long delays in sending action |
| 1141 | * frames. |
| 1142 | */ |
| 1143 | sme_abort_roam_scan(hdd_ctx->hHal, |
| 1144 | adapter->sessionId); |
| 1145 | } else { |
| 1146 | /* |
| 1147 | * 0 is accepted as current home channel, |
| 1148 | * delayed transmission of action frame is ok. |
| 1149 | */ |
| 1150 | chan.center_freq = |
| 1151 | sme_chn_to_freq(pHddStaCtx->conn_info. |
| 1152 | operationChannel); |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | if (chan.center_freq == 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1157 | hdd_err("Invalid channel number %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1158 | ret = -EINVAL; |
| 1159 | goto exit; |
| 1160 | } |
| 1161 | |
| 1162 | frame_len = payload_len + 24; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1163 | frame = qdf_mem_malloc(frame_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1164 | if (!frame) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1165 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1166 | ret = -ENOMEM; |
| 1167 | goto exit; |
| 1168 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1169 | qdf_mem_zero(frame, frame_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1170 | |
| 1171 | hdr = (struct ieee80211_hdr_3addr *)frame; |
| 1172 | hdr->frame_control = |
| 1173 | cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1174 | qdf_mem_copy(hdr->addr1, bssid, QDF_MAC_ADDR_SIZE); |
| 1175 | qdf_mem_copy(hdr->addr2, adapter->macAddressCurrent.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1176 | QDF_MAC_ADDR_SIZE); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1177 | qdf_mem_copy(hdr->addr3, bssid, QDF_MAC_ADDR_SIZE); |
| 1178 | qdf_mem_copy(hdr + 1, payload, payload_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1179 | |
| 1180 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1181 | params.chan = &chan; |
| 1182 | params.offchan = 0; |
| 1183 | params.wait = dwell_time; |
| 1184 | params.buf = frame; |
| 1185 | params.len = frame_len; |
| 1186 | params.no_cck = 1; |
| 1187 | params.dont_wait_for_ack = 1; |
| 1188 | ret = wlan_hdd_mgmt_tx(NULL, &adapter->wdev, ¶ms, &cookie); |
| 1189 | #else |
| 1190 | ret = wlan_hdd_mgmt_tx(NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1191 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | &chan, 0, |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 1193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1194 | dwell_time, frame, frame_len, 1, 1, &cookie); |
| 1195 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) */ |
| 1196 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1197 | qdf_mem_free(frame); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | exit: |
| 1199 | return ret; |
| 1200 | } |
| 1201 | |
| 1202 | /** |
| 1203 | * hdd_parse_sendactionframe_v1() - parse version 1 of the |
| 1204 | * SENDACTIONFRAME command |
| 1205 | * @adapter: Adapter upon which the command was received |
| 1206 | * @command: ASCII text command that was received |
| 1207 | * |
| 1208 | * This function parses the v1 SENDACTIONFRAME command with the format |
| 1209 | * |
| 1210 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DW xxxxxx |
| 1211 | * |
| 1212 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 1213 | * BSSID, CH is the ASCII representation of the channel, DW is the |
| 1214 | * ASCII representation of the dwell time, and xxxxxx is the Hex-ASCII |
| 1215 | * payload. For example |
| 1216 | * |
| 1217 | * SENDACTIONFRAME 00:0a:0b:11:22:33 48 40 aabbccddee |
| 1218 | * |
| 1219 | * Return: 0 for success non-zero for failure |
| 1220 | */ |
| 1221 | static int |
| 1222 | hdd_parse_sendactionframe_v1(hdd_adapter_t *adapter, const char *command) |
| 1223 | { |
| 1224 | uint8_t channel = 0; |
| 1225 | uint8_t dwell_time = 0; |
| 1226 | uint8_t payload_len = 0; |
| 1227 | uint8_t *payload = NULL; |
| 1228 | tSirMacAddr bssid; |
| 1229 | int ret; |
| 1230 | |
| 1231 | ret = hdd_parse_send_action_frame_v1_data(command, bssid, &channel, |
| 1232 | &dwell_time, &payload, |
| 1233 | &payload_len); |
| 1234 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1235 | hdd_err("Failed to parse send action frame data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1236 | } else { |
| 1237 | ret = hdd_sendactionframe(adapter, bssid, channel, |
| 1238 | dwell_time, payload_len, payload); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1239 | qdf_mem_free(payload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | return ret; |
| 1243 | } |
| 1244 | |
| 1245 | /** |
| 1246 | * hdd_parse_sendactionframe_v2() - parse version 2 of the |
| 1247 | * SENDACTIONFRAME command |
| 1248 | * @adapter: Adapter upon which the command was received |
| 1249 | * @command: Command that was received, ASCII command |
| 1250 | * followed by binary data |
| 1251 | * |
| 1252 | * This function parses the v2 SENDACTIONFRAME command with the format |
| 1253 | * |
| 1254 | * SENDACTIONFRAME <android_wifi_af_params> |
| 1255 | * |
| 1256 | * Return: 0 for success non-zero for failure |
| 1257 | */ |
| 1258 | static int |
| 1259 | hdd_parse_sendactionframe_v2(hdd_adapter_t *adapter, const char *command) |
| 1260 | { |
| 1261 | struct android_wifi_af_params *params; |
| 1262 | tSirMacAddr bssid; |
| 1263 | int ret; |
| 1264 | |
| 1265 | /* params are large so keep off the stack */ |
| 1266 | params = kmalloc(sizeof(*params), GFP_KERNEL); |
| 1267 | if (!params) |
| 1268 | return -ENOMEM; |
| 1269 | |
| 1270 | /* The params are located after "SENDACTIONFRAME " */ |
| 1271 | memcpy(params, command + 16, sizeof(*params)); |
| 1272 | |
| 1273 | if (!mac_pton(params->bssid, (u8 *) &bssid)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1274 | hdd_err("MAC address parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1275 | ret = -EINVAL; |
| 1276 | } else { |
| 1277 | ret = hdd_sendactionframe(adapter, bssid, params->channel, |
| 1278 | params->dwell_time, params->len, |
| 1279 | params->data); |
| 1280 | } |
| 1281 | kfree(params); |
| 1282 | return ret; |
| 1283 | } |
| 1284 | |
| 1285 | /** |
| 1286 | * hdd_parse_sendactionframe() - parse the SENDACTIONFRAME command |
| 1287 | * @adapter: Adapter upon which the command was received |
| 1288 | * @command: Command that was received |
| 1289 | * |
| 1290 | * There are two different versions of the SENDACTIONFRAME command. |
| 1291 | * Version 1 of the command contains a parameter list that is ASCII |
| 1292 | * characters whereas version 2 contains a combination of ASCII and |
| 1293 | * binary payload. Determine if a version 1 or a version 2 command is |
| 1294 | * being parsed by examining the parameters, and then dispatch the |
| 1295 | * parser that is appropriate for the version of the command. |
| 1296 | * |
| 1297 | * Return: 0 for success non-zero for failure |
| 1298 | */ |
| 1299 | static int |
| 1300 | hdd_parse_sendactionframe(hdd_adapter_t *adapter, const char *command) |
| 1301 | { |
| 1302 | int ret; |
| 1303 | |
| 1304 | /* |
| 1305 | * both versions start with "SENDACTIONFRAME " |
| 1306 | * v1 has a bssid and other parameters as an ASCII string |
| 1307 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DWELL LEN FRAME |
| 1308 | * v2 has a C struct |
| 1309 | * SENDACTIONFRAME <binary c struct> |
| 1310 | * |
| 1311 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1312 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1313 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1314 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx* |
| 1315 | * 111111111122222222223333 |
| 1316 | * 0123456789012345678901234567890123 |
| 1317 | */ |
| 1318 | if (command[33]) { |
| 1319 | ret = hdd_parse_sendactionframe_v1(adapter, command); |
| 1320 | } else { |
| 1321 | ret = hdd_parse_sendactionframe_v2(adapter, command); |
| 1322 | } |
| 1323 | |
| 1324 | return ret; |
| 1325 | } |
| 1326 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1327 | /** |
| 1328 | * hdd_parse_channellist() - HDD Parse channel list |
| 1329 | * @pValue: Pointer to input channel list |
| 1330 | * @ChannelList: Pointer to local output array to record |
| 1331 | * channel list |
| 1332 | * @pNumChannels: Pointer to number of roam scan channels |
| 1333 | * |
| 1334 | * This function parses the channel list passed in the format |
| 1335 | * SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N |
| 1336 | * if the Number of channels (N) does not match with the actual number |
| 1337 | * of channels passed then take the minimum of N and count of |
| 1338 | * (Ch1, Ch2, ...Ch M). For example, if SETROAMSCANCHANNELS 3 36 40 44 48, |
| 1339 | * only 36, 40 and 44 shall be taken. If SETROAMSCANCHANNELS 5 36 40 44 48, |
| 1340 | * ignore 5 and take 36, 40, 44 and 48. This function does not take care of |
| 1341 | * removing duplicate channels from the list |
| 1342 | * |
| 1343 | * Return: 0 for success non-zero for failure |
| 1344 | */ |
| 1345 | static int |
| 1346 | hdd_parse_channellist(const uint8_t *pValue, uint8_t *pChannelList, |
| 1347 | uint8_t *pNumChannels) |
| 1348 | { |
| 1349 | const uint8_t *inPtr = pValue; |
| 1350 | int tempInt; |
| 1351 | int j = 0; |
| 1352 | int v = 0; |
| 1353 | char buf[32]; |
| 1354 | |
| 1355 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1356 | /* no argument after the command */ |
| 1357 | if (NULL == inPtr) { |
| 1358 | return -EINVAL; |
| 1359 | } |
| 1360 | |
| 1361 | /* no space after the command */ |
| 1362 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 1363 | return -EINVAL; |
| 1364 | } |
| 1365 | |
| 1366 | /* remove empty spaces */ |
| 1367 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 1368 | inPtr++; |
| 1369 | |
| 1370 | /* no argument followed by spaces */ |
| 1371 | if ('\0' == *inPtr) { |
| 1372 | return -EINVAL; |
| 1373 | } |
| 1374 | |
| 1375 | /* get the first argument ie the number of channels */ |
| 1376 | v = sscanf(inPtr, "%31s ", buf); |
| 1377 | if (1 != v) |
| 1378 | return -EINVAL; |
| 1379 | |
| 1380 | v = kstrtos32(buf, 10, &tempInt); |
| 1381 | if ((v < 0) || |
| 1382 | (tempInt <= 0) || (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) { |
| 1383 | return -EINVAL; |
| 1384 | } |
| 1385 | |
| 1386 | *pNumChannels = tempInt; |
| 1387 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1388 | hdd_info("Number of channels are: %d", *pNumChannels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1389 | |
| 1390 | for (j = 0; j < (*pNumChannels); j++) { |
| 1391 | /* |
| 1392 | * inPtr pointing to the beginning of first space after number |
| 1393 | * of channels |
| 1394 | */ |
| 1395 | inPtr = strpbrk(inPtr, " "); |
| 1396 | /* no channel list after the number of channels argument */ |
| 1397 | if (NULL == inPtr) { |
| 1398 | if (0 != j) { |
| 1399 | *pNumChannels = j; |
| 1400 | return 0; |
| 1401 | } else { |
| 1402 | return -EINVAL; |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | /* remove empty space */ |
| 1407 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 1408 | inPtr++; |
| 1409 | |
| 1410 | /* |
| 1411 | * no channel list after the number of channels |
| 1412 | * argument and spaces |
| 1413 | */ |
| 1414 | if ('\0' == *inPtr) { |
| 1415 | if (0 != j) { |
| 1416 | *pNumChannels = j; |
| 1417 | return 0; |
| 1418 | } else { |
| 1419 | return -EINVAL; |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | v = sscanf(inPtr, "%31s ", buf); |
| 1424 | if (1 != v) |
| 1425 | return -EINVAL; |
| 1426 | |
| 1427 | v = kstrtos32(buf, 10, &tempInt); |
| 1428 | if ((v < 0) || |
| 1429 | (tempInt <= 0) || |
| 1430 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
| 1431 | return -EINVAL; |
| 1432 | } |
| 1433 | pChannelList[j] = tempInt; |
| 1434 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1435 | hdd_info("Channel %d added to preferred channel list", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | pChannelList[j]); |
| 1437 | } |
| 1438 | |
| 1439 | return 0; |
| 1440 | } |
| 1441 | |
| 1442 | /** |
| 1443 | * hdd_parse_set_roam_scan_channels_v1() - parse version 1 of the |
| 1444 | * SETROAMSCANCHANNELS command |
| 1445 | * @adapter: Adapter upon which the command was received |
| 1446 | * @command: ASCII text command that was received |
| 1447 | * |
| 1448 | * This function parses the v1 SETROAMSCANCHANNELS command with the format |
| 1449 | * |
| 1450 | * SETROAMSCANCHANNELS N C1 C2 ... Cn |
| 1451 | * |
| 1452 | * Where "N" is the ASCII representation of the number of channels and |
| 1453 | * C1 thru Cn is the ASCII representation of the channels. For example |
| 1454 | * |
| 1455 | * SETROAMSCANCHANNELS 4 36 40 44 48 |
| 1456 | * |
| 1457 | * Return: 0 for success non-zero for failure |
| 1458 | */ |
| 1459 | static int |
| 1460 | hdd_parse_set_roam_scan_channels_v1(hdd_adapter_t *adapter, |
| 1461 | const char *command) |
| 1462 | { |
| 1463 | uint8_t channel_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
| 1464 | uint8_t num_chan = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1465 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1466 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1467 | int ret; |
| 1468 | |
| 1469 | ret = hdd_parse_channellist(command, channel_list, &num_chan); |
| 1470 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1471 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | goto exit; |
| 1473 | } |
| 1474 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1475 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 1477 | adapter->sessionId, num_chan)); |
| 1478 | |
| 1479 | if (num_chan > WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1480 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
| 1481 | num_chan, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1482 | ret = -EINVAL; |
| 1483 | goto exit; |
| 1484 | } |
| 1485 | |
| 1486 | status = |
| 1487 | sme_change_roam_scan_channel_list(hdd_ctx->hHal, |
| 1488 | adapter->sessionId, |
| 1489 | channel_list, num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1490 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1491 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | ret = -EINVAL; |
| 1493 | goto exit; |
| 1494 | } |
| 1495 | exit: |
| 1496 | return ret; |
| 1497 | } |
| 1498 | |
| 1499 | /** |
| 1500 | * hdd_parse_set_roam_scan_channels_v2() - parse version 2 of the |
| 1501 | * SETROAMSCANCHANNELS command |
| 1502 | * @adapter: Adapter upon which the command was received |
| 1503 | * @command: Command that was received, ASCII command |
| 1504 | * followed by binary data |
| 1505 | * |
| 1506 | * This function parses the v2 SETROAMSCANCHANNELS command with the format |
| 1507 | * |
| 1508 | * SETROAMSCANCHANNELS [N][C1][C2][Cn] |
| 1509 | * |
| 1510 | * The command begins with SETROAMSCANCHANNELS followed by a space, but |
| 1511 | * what follows the space is an array of u08 parameters. For example |
| 1512 | * |
| 1513 | * SETROAMSCANCHANNELS [0x04 0x24 0x28 0x2c 0x30] |
| 1514 | * |
| 1515 | * Return: 0 for success non-zero for failure |
| 1516 | */ |
| 1517 | static int |
| 1518 | hdd_parse_set_roam_scan_channels_v2(hdd_adapter_t *adapter, |
| 1519 | const char *command) |
| 1520 | { |
| 1521 | const uint8_t *value; |
| 1522 | uint8_t channel_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
| 1523 | uint8_t channel; |
| 1524 | uint8_t num_chan; |
| 1525 | int i; |
| 1526 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1527 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1528 | int ret = 0; |
| 1529 | |
| 1530 | /* array of values begins after "SETROAMSCANCHANNELS " */ |
| 1531 | value = command + 20; |
| 1532 | |
| 1533 | num_chan = *value++; |
| 1534 | if (num_chan > WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1535 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
| 1536 | num_chan, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1537 | ret = -EINVAL; |
| 1538 | goto exit; |
| 1539 | } |
| 1540 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1541 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 1543 | adapter->sessionId, num_chan)); |
| 1544 | |
| 1545 | for (i = 0; i < num_chan; i++) { |
| 1546 | channel = *value++; |
| 1547 | if (channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1548 | hdd_err("index %d invalid channel %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | i, channel); |
| 1550 | ret = -EINVAL; |
| 1551 | goto exit; |
| 1552 | } |
| 1553 | channel_list[i] = channel; |
| 1554 | } |
| 1555 | status = |
| 1556 | sme_change_roam_scan_channel_list(hdd_ctx->hHal, |
| 1557 | adapter->sessionId, |
| 1558 | channel_list, num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1559 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1560 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1561 | ret = -EINVAL; |
| 1562 | goto exit; |
| 1563 | } |
| 1564 | exit: |
| 1565 | return ret; |
| 1566 | } |
| 1567 | |
| 1568 | /** |
| 1569 | * hdd_parse_set_roam_scan_channels() - parse the |
| 1570 | * SETROAMSCANCHANNELS command |
| 1571 | * @adapter: Adapter upon which the command was received |
| 1572 | * @command: Command that was received |
| 1573 | * |
| 1574 | * There are two different versions of the SETROAMSCANCHANNELS command. |
| 1575 | * Version 1 of the command contains a parameter list that is ASCII |
| 1576 | * characters whereas version 2 contains a binary payload. Determine |
| 1577 | * if a version 1 or a version 2 command is being parsed by examining |
| 1578 | * the parameters, and then dispatch the parser that is appropriate for |
| 1579 | * the command. |
| 1580 | * |
| 1581 | * Return: 0 for success non-zero for failure |
| 1582 | */ |
| 1583 | static int |
| 1584 | hdd_parse_set_roam_scan_channels(hdd_adapter_t *adapter, const char *command) |
| 1585 | { |
| 1586 | const char *cursor; |
| 1587 | char ch; |
| 1588 | bool v1; |
| 1589 | int ret; |
| 1590 | |
| 1591 | /* start after "SETROAMSCANCHANNELS " */ |
| 1592 | cursor = command + 20; |
| 1593 | |
| 1594 | /* assume we have a version 1 command until proven otherwise */ |
| 1595 | v1 = true; |
| 1596 | |
| 1597 | /* v1 params will only contain ASCII digits and space */ |
| 1598 | while ((ch = *cursor++) && v1) { |
| 1599 | if (!(isdigit(ch) || isspace(ch))) { |
| 1600 | v1 = false; |
| 1601 | } |
| 1602 | } |
| 1603 | if (v1) { |
| 1604 | ret = hdd_parse_set_roam_scan_channels_v1(adapter, command); |
| 1605 | } else { |
| 1606 | ret = hdd_parse_set_roam_scan_channels_v2(adapter, command); |
| 1607 | } |
| 1608 | |
| 1609 | return ret; |
| 1610 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 1612 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1613 | /** |
| 1614 | * hdd_parse_plm_cmd() - HDD Parse Plm command |
| 1615 | * @pValue: Pointer to input data |
| 1616 | * @pPlmRequest:Pointer to output struct tpSirPlmReq |
| 1617 | * |
| 1618 | * This function parses the plm command passed in the format |
| 1619 | * CCXPLMREQ<space><enable><space><dialog_token><space> |
| 1620 | * <meas_token><space><num_of_bursts><space><burst_int><space> |
| 1621 | * <measu duration><space><burst_len><space><desired_tx_pwr> |
| 1622 | * <space><multcast_addr><space><number_of_channels> |
| 1623 | * <space><channel_numbers> |
| 1624 | * |
| 1625 | * Return: 0 for success non-zero for failure |
| 1626 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1627 | QDF_STATUS hdd_parse_plm_cmd(uint8_t *pValue, tSirPlmReq *pPlmRequest) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1628 | { |
| 1629 | uint8_t *cmdPtr = NULL; |
| 1630 | int count, content = 0, ret = 0; |
| 1631 | char buf[32]; |
| 1632 | |
| 1633 | /* move to argument list */ |
| 1634 | cmdPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1635 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1636 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | |
| 1638 | /* no space after the command */ |
| 1639 | if (SPACE_ASCII_VALUE != *cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1640 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1641 | |
| 1642 | /* remove empty spaces */ |
| 1643 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1644 | cmdPtr++; |
| 1645 | |
| 1646 | /* START/STOP PLM req */ |
| 1647 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1648 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1649 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1650 | |
| 1651 | ret = kstrtos32(buf, 10, &content); |
| 1652 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1653 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1654 | |
| 1655 | pPlmRequest->enable = content; |
| 1656 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1657 | |
| 1658 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1659 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1660 | |
| 1661 | /* remove empty spaces */ |
| 1662 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1663 | cmdPtr++; |
| 1664 | |
| 1665 | /* Dialog token of radio meas req containing meas reqIE */ |
| 1666 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1667 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1668 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1669 | |
| 1670 | ret = kstrtos32(buf, 10, &content); |
| 1671 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1672 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1673 | |
| 1674 | pPlmRequest->diag_token = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1675 | hdd_debug("diag token %d", pPlmRequest->diag_token); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1676 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1677 | |
| 1678 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1679 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1680 | |
| 1681 | /* remove empty spaces */ |
| 1682 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1683 | cmdPtr++; |
| 1684 | |
| 1685 | /* measurement token of meas req IE */ |
| 1686 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1687 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1688 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1689 | |
| 1690 | ret = kstrtos32(buf, 10, &content); |
| 1691 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1692 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | |
| 1694 | pPlmRequest->meas_token = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1695 | hdd_debug("meas token %d", pPlmRequest->meas_token); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1696 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1697 | hdd_err("PLM req %s", pPlmRequest->enable ? "START" : "STOP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1698 | if (pPlmRequest->enable) { |
| 1699 | |
| 1700 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1701 | |
| 1702 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1703 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1704 | |
| 1705 | /* remove empty spaces */ |
| 1706 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1707 | cmdPtr++; |
| 1708 | |
| 1709 | /* total number of bursts after which STA stops sending */ |
| 1710 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1711 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1712 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1713 | |
| 1714 | ret = kstrtos32(buf, 10, &content); |
| 1715 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1716 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1717 | |
| 1718 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1719 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1720 | |
| 1721 | pPlmRequest->numBursts = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1722 | hdd_debug("num burst %d", pPlmRequest->numBursts); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1723 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1724 | |
| 1725 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1726 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1727 | |
| 1728 | /* remove empty spaces */ |
| 1729 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1730 | cmdPtr++; |
| 1731 | |
| 1732 | /* burst interval in seconds */ |
| 1733 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1734 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1735 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1736 | |
| 1737 | ret = kstrtos32(buf, 10, &content); |
| 1738 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1739 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1740 | |
| 1741 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1742 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1743 | |
| 1744 | pPlmRequest->burstInt = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1745 | hdd_debug("burst Int %d", pPlmRequest->burstInt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1746 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1747 | |
| 1748 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1749 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1750 | |
| 1751 | /* remove empty spaces */ |
| 1752 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1753 | cmdPtr++; |
| 1754 | |
| 1755 | /* Meas dur in TU's,STA goes off-ch and transmit PLM bursts */ |
| 1756 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1757 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1758 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1759 | |
| 1760 | ret = kstrtos32(buf, 10, &content); |
| 1761 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1762 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1763 | |
| 1764 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1765 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1766 | |
| 1767 | pPlmRequest->measDuration = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1768 | hdd_debug("measDur %d", pPlmRequest->measDuration); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1769 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1770 | |
| 1771 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1772 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1773 | |
| 1774 | /* remove empty spaces */ |
| 1775 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1776 | cmdPtr++; |
| 1777 | |
| 1778 | /* burst length of PLM bursts */ |
| 1779 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1780 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1781 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1782 | |
| 1783 | ret = kstrtos32(buf, 10, &content); |
| 1784 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1785 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1786 | |
| 1787 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1788 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1789 | |
| 1790 | pPlmRequest->burstLen = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1791 | hdd_debug("burstLen %d", pPlmRequest->burstLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1792 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1793 | |
| 1794 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1795 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1796 | |
| 1797 | /* remove empty spaces */ |
| 1798 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1799 | cmdPtr++; |
| 1800 | |
| 1801 | /* desired tx power for transmission of PLM bursts */ |
| 1802 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1803 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1804 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1805 | |
| 1806 | ret = kstrtos32(buf, 10, &content); |
| 1807 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1808 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1809 | |
| 1810 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1811 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1812 | |
| 1813 | pPlmRequest->desiredTxPwr = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1814 | hdd_debug("desiredTxPwr %d", |
| 1815 | pPlmRequest->desiredTxPwr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1816 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1817 | for (count = 0; count < QDF_MAC_ADDR_SIZE; count++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1818 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1819 | |
| 1820 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1821 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1822 | |
| 1823 | /* remove empty spaces */ |
| 1824 | while ((SPACE_ASCII_VALUE == *cmdPtr) |
| 1825 | && ('\0' != *cmdPtr)) |
| 1826 | cmdPtr++; |
| 1827 | |
| 1828 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1829 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1830 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1831 | |
| 1832 | ret = kstrtos32(buf, 16, &content); |
| 1833 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1834 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1835 | |
Srinivas Girigowda | 5146dee | 2015-11-18 21:46:48 -0800 | [diff] [blame] | 1836 | pPlmRequest->mac_addr.bytes[count] = content; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1837 | } |
| 1838 | |
Srinivas Girigowda | 5146dee | 2015-11-18 21:46:48 -0800 | [diff] [blame] | 1839 | hdd_debug("MC addr " MAC_ADDRESS_STR, |
| 1840 | MAC_ADDR_ARRAY(pPlmRequest->mac_addr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1841 | |
| 1842 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1843 | |
| 1844 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1845 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1846 | |
| 1847 | /* remove empty spaces */ |
| 1848 | while ((SPACE_ASCII_VALUE == *cmdPtr) && ('\0' != *cmdPtr)) |
| 1849 | cmdPtr++; |
| 1850 | |
| 1851 | /* number of channels */ |
| 1852 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1853 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1854 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | |
| 1856 | ret = kstrtos32(buf, 10, &content); |
| 1857 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1858 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1859 | |
| 1860 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1861 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1862 | |
| 1863 | pPlmRequest->plmNumCh = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1864 | hdd_debug("numch %d", pPlmRequest->plmNumCh); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1865 | |
| 1866 | /* Channel numbers */ |
| 1867 | for (count = 0; count < pPlmRequest->plmNumCh; count++) { |
| 1868 | cmdPtr = strpbrk(cmdPtr, " "); |
| 1869 | |
| 1870 | if (NULL == cmdPtr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1871 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1872 | |
| 1873 | /* remove empty spaces */ |
| 1874 | while ((SPACE_ASCII_VALUE == *cmdPtr) |
| 1875 | && ('\0' != *cmdPtr)) |
| 1876 | cmdPtr++; |
| 1877 | |
| 1878 | ret = sscanf(cmdPtr, "%31s ", buf); |
| 1879 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1880 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1881 | |
| 1882 | ret = kstrtos32(buf, 10, &content); |
| 1883 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1884 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1885 | |
| 1886 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1887 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1888 | |
| 1889 | pPlmRequest->plmChList[count] = content; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1890 | hdd_debug(" ch- %d", pPlmRequest->plmChList[count]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | } |
| 1892 | } |
| 1893 | /* If PLM START */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1894 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | } |
| 1896 | #endif |
| 1897 | |
| 1898 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 1899 | static void wlan_hdd_ready_to_extwow(void *callbackContext, bool is_success) |
| 1900 | { |
| 1901 | hdd_context_t *hdd_ctx = (hdd_context_t *) callbackContext; |
| 1902 | int rc; |
| 1903 | |
| 1904 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1905 | if (rc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | hdd_ctx->ext_wow_should_suspend = is_success; |
| 1908 | complete(&hdd_ctx->ready_to_extwow); |
| 1909 | } |
| 1910 | |
| 1911 | static int hdd_enable_ext_wow(hdd_adapter_t *adapter, |
| 1912 | tpSirExtWoWParams arg_params) |
| 1913 | { |
| 1914 | tSirExtWoWParams params; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1915 | QDF_STATUS qdf_ret_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1916 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1917 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 1918 | int rc; |
| 1919 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1920 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1921 | |
| 1922 | INIT_COMPLETION(hdd_ctx->ready_to_extwow); |
| 1923 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1924 | qdf_ret_status = sme_configure_ext_wow(hHal, ¶ms, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1925 | &wlan_hdd_ready_to_extwow, |
| 1926 | hdd_ctx); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1927 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1928 | hdd_err("sme_configure_ext_wow returned failure %d", |
| 1929 | qdf_ret_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | return -EPERM; |
| 1931 | } |
| 1932 | |
| 1933 | rc = wait_for_completion_timeout(&hdd_ctx->ready_to_extwow, |
| 1934 | msecs_to_jiffies(WLAN_WAIT_TIME_READY_TO_EXTWOW)); |
| 1935 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1936 | hdd_err("Failed to get ready to extwow"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1937 | return -EPERM; |
| 1938 | } |
| 1939 | |
| 1940 | if (hdd_ctx->ext_wow_should_suspend) { |
| 1941 | if (hdd_ctx->config->extWowGotoSuspend) { |
| 1942 | pm_message_t state; |
| 1943 | |
| 1944 | state.event = PM_EVENT_SUSPEND; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1945 | hdd_info("Received ready to ExtWoW. Going to suspend"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1946 | |
| 1947 | rc = wlan_hdd_cfg80211_suspend_wlan(hdd_ctx->wiphy, NULL); |
| 1948 | if (rc < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1949 | hdd_err("wlan_hdd_cfg80211_suspend_wlan failed, error = %d", |
| 1950 | rc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1951 | return rc; |
| 1952 | } |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1953 | qdf_ret_status = wlan_hdd_bus_suspend(state); |
| 1954 | if (qdf_ret_status != QDF_STATUS_SUCCESS) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1955 | hdd_err("wlan_hdd_suspend failed, status = %d", |
| 1956 | qdf_ret_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1957 | wlan_hdd_cfg80211_resume_wlan(hdd_ctx->wiphy); |
| 1958 | return -EPERM; |
| 1959 | } |
| 1960 | } |
| 1961 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1962 | hdd_err("Received ready to ExtWoW failure"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | return -EPERM; |
| 1964 | } |
| 1965 | |
| 1966 | return 0; |
| 1967 | } |
| 1968 | |
| 1969 | static int hdd_enable_ext_wow_parser(hdd_adapter_t *adapter, int vdev_id, |
| 1970 | int value) |
| 1971 | { |
| 1972 | tSirExtWoWParams params; |
| 1973 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1974 | int rc; |
| 1975 | |
| 1976 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1977 | if (rc) |
| 1978 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1979 | |
| 1980 | if (value < EXT_WOW_TYPE_APP_TYPE1 || |
| 1981 | value > EXT_WOW_TYPE_APP_TYPE1_2) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1982 | hdd_err("Invalid type"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1983 | return -EINVAL; |
| 1984 | } |
| 1985 | |
| 1986 | if (value == EXT_WOW_TYPE_APP_TYPE1 && |
| 1987 | hdd_ctx->is_extwow_app_type1_param_set) |
| 1988 | params.type = value; |
| 1989 | else if (value == EXT_WOW_TYPE_APP_TYPE2 && |
| 1990 | hdd_ctx->is_extwow_app_type2_param_set) |
| 1991 | params.type = value; |
| 1992 | else if (value == EXT_WOW_TYPE_APP_TYPE1_2 && |
| 1993 | hdd_ctx->is_extwow_app_type1_param_set && |
| 1994 | hdd_ctx->is_extwow_app_type2_param_set) |
| 1995 | params.type = value; |
| 1996 | else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1997 | hdd_err("Set app params before enable it value %d", |
| 1998 | value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1999 | return -EINVAL; |
| 2000 | } |
| 2001 | |
| 2002 | params.vdev_id = vdev_id; |
| 2003 | params.wakeup_pin_num = hdd_ctx->config->extWowApp1WakeupPinNumber | |
| 2004 | (hdd_ctx->config->extWowApp2WakeupPinNumber |
| 2005 | << 8); |
| 2006 | |
| 2007 | return hdd_enable_ext_wow(adapter, ¶ms); |
| 2008 | } |
| 2009 | |
| 2010 | static int hdd_set_app_type1_params(tHalHandle hHal, |
| 2011 | tpSirAppType1Params arg_params) |
| 2012 | { |
| 2013 | tSirAppType1Params params; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2014 | QDF_STATUS qdf_ret_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2015 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2016 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2018 | qdf_ret_status = sme_configure_app_type1_params(hHal, ¶ms); |
| 2019 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2020 | hdd_err("sme_configure_app_type1_params returned failure %d", |
| 2021 | qdf_ret_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2022 | return -EPERM; |
| 2023 | } |
| 2024 | |
| 2025 | return 0; |
| 2026 | } |
| 2027 | |
| 2028 | static int hdd_set_app_type1_parser(hdd_adapter_t *adapter, |
| 2029 | char *arg, int len) |
| 2030 | { |
| 2031 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2032 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 2033 | char id[20], password[20]; |
| 2034 | tSirAppType1Params params; |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 2035 | int rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2036 | |
| 2037 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2038 | if (rc) |
| 2039 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2040 | |
| 2041 | if (2 != sscanf(arg, "%8s %16s", id, password)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2042 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2043 | return -EINVAL; |
| 2044 | } |
| 2045 | |
| 2046 | memset(¶ms, 0, sizeof(tSirAppType1Params)); |
| 2047 | params.vdev_id = adapter->sessionId; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2048 | qdf_copy_macaddr(¶ms.wakee_mac_addr, &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2049 | |
| 2050 | params.id_length = strlen(id); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2051 | qdf_mem_copy(params.identification_id, id, params.id_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2052 | params.pass_length = strlen(password); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2053 | qdf_mem_copy(params.password, password, params.pass_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2054 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2055 | hdd_info("%d %pM %.8s %u %.16s %u", |
| 2056 | params.vdev_id, params.wakee_mac_addr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2057 | params.identification_id, params.id_length, |
| 2058 | params.password, params.pass_length); |
| 2059 | |
| 2060 | return hdd_set_app_type1_params(hHal, ¶ms); |
| 2061 | } |
| 2062 | |
| 2063 | static int hdd_set_app_type2_params(tHalHandle hHal, |
| 2064 | tpSirAppType2Params arg_params) |
| 2065 | { |
| 2066 | tSirAppType2Params params; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2067 | QDF_STATUS qdf_ret_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2068 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2069 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2070 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2071 | qdf_ret_status = sme_configure_app_type2_params(hHal, ¶ms); |
| 2072 | if (QDF_STATUS_SUCCESS != qdf_ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2073 | hdd_err("sme_configure_app_type2_params returned failure %d", |
| 2074 | qdf_ret_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2075 | return -EPERM; |
| 2076 | } |
| 2077 | |
| 2078 | return 0; |
| 2079 | } |
| 2080 | |
| 2081 | static int hdd_set_app_type2_parser(hdd_adapter_t *adapter, |
| 2082 | char *arg, int len) |
| 2083 | { |
| 2084 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2085 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 2086 | char mac_addr[20], rc4_key[20]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2087 | unsigned int gateway_mac[QDF_MAC_ADDR_SIZE]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2088 | tSirAppType2Params params; |
| 2089 | int ret; |
| 2090 | |
| 2091 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2092 | if (ret) |
| 2093 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2094 | |
| 2095 | memset(¶ms, 0, sizeof(tSirAppType2Params)); |
| 2096 | |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2097 | ret = sscanf(arg, "%17s %16s %x %x %x %u %u %hu %hu %u %u %u %u %u %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2098 | mac_addr, rc4_key, (unsigned int *)¶ms.ip_id, |
| 2099 | (unsigned int *)¶ms.ip_device_ip, |
| 2100 | (unsigned int *)¶ms.ip_server_ip, |
| 2101 | (unsigned int *)¶ms.tcp_seq, |
| 2102 | (unsigned int *)¶ms.tcp_ack_seq, |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2103 | (uint16_t *)¶ms.tcp_src_port, |
| 2104 | (uint16_t *)¶ms.tcp_dst_port, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2105 | (unsigned int *)¶ms.keepalive_init, |
| 2106 | (unsigned int *)¶ms.keepalive_min, |
| 2107 | (unsigned int *)¶ms.keepalive_max, |
| 2108 | (unsigned int *)¶ms.keepalive_inc, |
| 2109 | (unsigned int *)¶ms.tcp_tx_timeout_val, |
| 2110 | (unsigned int *)¶ms.tcp_rx_timeout_val); |
| 2111 | |
| 2112 | if (ret != 15 && ret != 7) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2113 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2114 | return -EINVAL; |
| 2115 | } |
| 2116 | |
| 2117 | if (6 != |
| 2118 | sscanf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", &gateway_mac[0], |
| 2119 | &gateway_mac[1], &gateway_mac[2], &gateway_mac[3], |
| 2120 | &gateway_mac[4], &gateway_mac[5])) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2121 | hdd_err("Invalid MacAddress Input %s", mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2122 | return -EINVAL; |
| 2123 | } |
| 2124 | |
| 2125 | if (params.tcp_src_port > WLAN_HDD_MAX_TCP_PORT || |
| 2126 | params.tcp_dst_port > WLAN_HDD_MAX_TCP_PORT) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2127 | hdd_err("Invalid TCP Port Number"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2128 | return -EINVAL; |
| 2129 | } |
| 2130 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2131 | qdf_mem_copy(¶ms.gateway_mac.bytes, (uint8_t *) &gateway_mac, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2132 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2133 | |
| 2134 | params.rc4_key_len = strlen(rc4_key); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2135 | qdf_mem_copy(params.rc4_key, rc4_key, params.rc4_key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2136 | |
| 2137 | params.vdev_id = adapter->sessionId; |
| 2138 | params.tcp_src_port = (params.tcp_src_port != 0) ? |
| 2139 | params.tcp_src_port : hdd_ctx->config->extWowApp2TcpSrcPort; |
| 2140 | params.tcp_dst_port = (params.tcp_dst_port != 0) ? |
| 2141 | params.tcp_dst_port : hdd_ctx->config->extWowApp2TcpDstPort; |
| 2142 | params.keepalive_init = (params.keepalive_init != 0) ? |
| 2143 | params.keepalive_init : hdd_ctx->config-> |
| 2144 | extWowApp2KAInitPingInterval; |
| 2145 | params.keepalive_min = |
| 2146 | (params.keepalive_min != 0) ? |
| 2147 | params.keepalive_min : |
| 2148 | hdd_ctx->config->extWowApp2KAMinPingInterval; |
| 2149 | params.keepalive_max = |
| 2150 | (params.keepalive_max != 0) ? |
| 2151 | params.keepalive_max : |
| 2152 | hdd_ctx->config->extWowApp2KAMaxPingInterval; |
| 2153 | params.keepalive_inc = |
| 2154 | (params.keepalive_inc != 0) ? |
| 2155 | params.keepalive_inc : |
| 2156 | hdd_ctx->config->extWowApp2KAIncPingInterval; |
| 2157 | params.tcp_tx_timeout_val = |
| 2158 | (params.tcp_tx_timeout_val != 0) ? |
| 2159 | params.tcp_tx_timeout_val : |
| 2160 | hdd_ctx->config->extWowApp2TcpTxTimeout; |
| 2161 | params.tcp_rx_timeout_val = |
| 2162 | (params.tcp_rx_timeout_val != 0) ? |
| 2163 | params.tcp_rx_timeout_val : |
| 2164 | hdd_ctx->config->extWowApp2TcpRxTimeout; |
| 2165 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2166 | hdd_info("%pM %.16s %u %u %u %u %u %u %u %u %u %u %u %u %u", |
| 2167 | gateway_mac, rc4_key, params.ip_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2168 | params.ip_device_ip, params.ip_server_ip, params.tcp_seq, |
| 2169 | params.tcp_ack_seq, params.tcp_src_port, params.tcp_dst_port, |
| 2170 | params.keepalive_init, params.keepalive_min, |
| 2171 | params.keepalive_max, params.keepalive_inc, |
| 2172 | params.tcp_tx_timeout_val, params.tcp_rx_timeout_val); |
| 2173 | |
| 2174 | return hdd_set_app_type2_params(hHal, ¶ms); |
| 2175 | } |
| 2176 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 2177 | |
| 2178 | /** |
| 2179 | * hdd_parse_setmaxtxpower_command() - HDD Parse MAXTXPOWER command |
| 2180 | * @pValue: Pointer to MAXTXPOWER command |
| 2181 | * @pDbm: Pointer to tx power |
| 2182 | * |
| 2183 | * This function parses the MAXTXPOWER command passed in the format |
| 2184 | * MAXTXPOWER<space>X(Tx power in dbm) |
| 2185 | * |
| 2186 | * For example input commands: |
| 2187 | * 1) MAXTXPOWER -8 -> This is translated into set max TX power to -8 dbm |
| 2188 | * 2) MAXTXPOWER -23 -> This is translated into set max TX power to -23 dbm |
| 2189 | * |
| 2190 | * Return: 0 for success non-zero for failure |
| 2191 | */ |
| 2192 | static int hdd_parse_setmaxtxpower_command(uint8_t *pValue, int *pTxPower) |
| 2193 | { |
| 2194 | uint8_t *inPtr = pValue; |
| 2195 | int tempInt; |
| 2196 | int v = 0; |
| 2197 | *pTxPower = 0; |
| 2198 | |
| 2199 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 2200 | /* no argument after the command */ |
| 2201 | if (NULL == inPtr) { |
| 2202 | return -EINVAL; |
| 2203 | } |
| 2204 | |
| 2205 | /* no space after the command */ |
| 2206 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 2207 | return -EINVAL; |
| 2208 | } |
| 2209 | |
| 2210 | /* remove empty spaces */ |
| 2211 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 2212 | inPtr++; |
| 2213 | |
| 2214 | /* no argument followed by spaces */ |
| 2215 | if ('\0' == *inPtr) { |
| 2216 | return 0; |
| 2217 | } |
| 2218 | |
| 2219 | v = kstrtos32(inPtr, 10, &tempInt); |
| 2220 | |
| 2221 | /* Range checking for passed parameter */ |
| 2222 | if ((tempInt < HDD_MIN_TX_POWER) || (tempInt > HDD_MAX_TX_POWER)) { |
| 2223 | return -EINVAL; |
| 2224 | } |
| 2225 | |
| 2226 | *pTxPower = tempInt; |
| 2227 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2228 | hdd_info("SETMAXTXPOWER: %d", *pTxPower); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2229 | |
| 2230 | return 0; |
| 2231 | } /* End of hdd_parse_setmaxtxpower_command */ |
| 2232 | |
| 2233 | static int hdd_get_dwell_time(struct hdd_config *pCfg, uint8_t *command, |
| 2234 | char *extra, uint8_t n, uint8_t *len) |
| 2235 | { |
| 2236 | int ret = 0; |
| 2237 | |
| 2238 | if (!pCfg || !command || !extra || !len) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2239 | hdd_err("argument passed for GETDWELLTIME is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2240 | ret = -EINVAL; |
| 2241 | return ret; |
| 2242 | } |
| 2243 | |
| 2244 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) { |
| 2245 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2246 | (int)pCfg->nActiveMaxChnTime); |
| 2247 | return ret; |
| 2248 | } else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) { |
| 2249 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2250 | (int)pCfg->nActiveMinChnTime); |
| 2251 | return ret; |
| 2252 | } else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) { |
| 2253 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2254 | (int)pCfg->nPassiveMaxChnTime); |
| 2255 | return ret; |
| 2256 | } else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) { |
| 2257 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2258 | (int)pCfg->nPassiveMinChnTime); |
| 2259 | return ret; |
| 2260 | } else if (strncmp(command, "GETDWELLTIME", 12) == 0) { |
| 2261 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2262 | (int)pCfg->nActiveMaxChnTime); |
| 2263 | return ret; |
| 2264 | } else { |
| 2265 | ret = -EINVAL; |
| 2266 | } |
| 2267 | |
| 2268 | return ret; |
| 2269 | } |
| 2270 | |
| 2271 | static int hdd_set_dwell_time(hdd_adapter_t *adapter, uint8_t *command) |
| 2272 | { |
| 2273 | tHalHandle hHal; |
| 2274 | struct hdd_config *pCfg; |
| 2275 | uint8_t *value = command; |
| 2276 | tSmeConfigParams smeConfig; |
| 2277 | int val = 0, temp = 0; |
| 2278 | |
| 2279 | pCfg = (WLAN_HDD_GET_CTX(adapter))->config; |
| 2280 | hHal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 2281 | if (!pCfg || !hHal) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2282 | hdd_err("argument passed for SETDWELLTIME is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2283 | return -EINVAL; |
| 2284 | } |
| 2285 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2286 | qdf_mem_zero(&smeConfig, sizeof(smeConfig)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2287 | sme_get_config_param(hHal, &smeConfig); |
| 2288 | |
| 2289 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0) { |
| 2290 | value = value + 24; |
| 2291 | temp = kstrtou32(value, 10, &val); |
| 2292 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2293 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2294 | hdd_err("argument passed for SETDWELLTIME ACTIVE MAX is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2295 | return -EFAULT; |
| 2296 | } |
| 2297 | pCfg->nActiveMaxChnTime = val; |
| 2298 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2299 | sme_update_config(hHal, &smeConfig); |
| 2300 | } else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) { |
| 2301 | value = value + 24; |
| 2302 | temp = kstrtou32(value, 10, &val); |
| 2303 | if (temp != 0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2304 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2305 | hdd_err("argument passed for SETDWELLTIME ACTIVE MIN is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2306 | return -EFAULT; |
| 2307 | } |
| 2308 | pCfg->nActiveMinChnTime = val; |
| 2309 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2310 | sme_update_config(hHal, &smeConfig); |
| 2311 | } else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) { |
| 2312 | value = value + 25; |
| 2313 | temp = kstrtou32(value, 10, &val); |
| 2314 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2315 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2316 | hdd_err("argument passed for SETDWELLTIME PASSIVE MAX is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2317 | return -EFAULT; |
| 2318 | } |
| 2319 | pCfg->nPassiveMaxChnTime = val; |
| 2320 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2321 | sme_update_config(hHal, &smeConfig); |
| 2322 | } else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) { |
| 2323 | value = value + 25; |
| 2324 | temp = kstrtou32(value, 10, &val); |
| 2325 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2326 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2327 | hdd_err("argument passed for SETDWELLTIME PASSIVE MIN is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2328 | return -EFAULT; |
| 2329 | } |
| 2330 | pCfg->nPassiveMinChnTime = val; |
| 2331 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2332 | sme_update_config(hHal, &smeConfig); |
| 2333 | } else if (strncmp(command, "SETDWELLTIME", 12) == 0) { |
| 2334 | value = value + 13; |
| 2335 | temp = kstrtou32(value, 10, &val); |
| 2336 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2337 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2338 | hdd_err("argument passed for SETDWELLTIME is incorrect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2339 | return -EFAULT; |
| 2340 | } |
| 2341 | pCfg->nActiveMaxChnTime = val; |
| 2342 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2343 | sme_update_config(hHal, &smeConfig); |
| 2344 | } else { |
| 2345 | return -EINVAL; |
| 2346 | } |
| 2347 | |
| 2348 | return 0; |
| 2349 | } |
| 2350 | |
| 2351 | static void hdd_get_link_status_cb(uint8_t status, void *context) |
| 2352 | { |
| 2353 | struct statsContext *pLinkContext; |
| 2354 | hdd_adapter_t *adapter; |
| 2355 | |
| 2356 | if (NULL == context) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2357 | hdd_err("Bad context [%p]", context); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2358 | return; |
| 2359 | } |
| 2360 | |
| 2361 | pLinkContext = context; |
| 2362 | adapter = pLinkContext->pAdapter; |
| 2363 | |
| 2364 | spin_lock(&hdd_context_lock); |
| 2365 | |
| 2366 | if ((NULL == adapter) || |
| 2367 | (LINK_STATUS_MAGIC != pLinkContext->magic)) { |
| 2368 | /* |
| 2369 | * the caller presumably timed out so there is |
| 2370 | * nothing we can do |
| 2371 | */ |
| 2372 | spin_unlock(&hdd_context_lock); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2373 | hdd_warn("Invalid context, adapter [%p] magic [%08x]", |
| 2374 | adapter, pLinkContext->magic); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2375 | return; |
| 2376 | } |
| 2377 | |
| 2378 | /* context is valid so caller is still waiting */ |
| 2379 | |
| 2380 | /* paranoia: invalidate the magic */ |
| 2381 | pLinkContext->magic = 0; |
| 2382 | |
| 2383 | /* copy over the status */ |
| 2384 | adapter->linkStatus = status; |
| 2385 | |
| 2386 | /* notify the caller */ |
| 2387 | complete(&pLinkContext->completion); |
| 2388 | |
| 2389 | /* serialization is complete */ |
| 2390 | spin_unlock(&hdd_context_lock); |
| 2391 | } |
| 2392 | |
| 2393 | /** |
| 2394 | * wlan_hdd_get_link_status() - get link status |
| 2395 | * @pAdapter: pointer to the adapter |
| 2396 | * |
| 2397 | * This function sends a request to query the link status and waits |
| 2398 | * on a timer to invoke the callback. if the callback is invoked then |
| 2399 | * latest link status shall be returned or otherwise cached value |
| 2400 | * will be returned. |
| 2401 | * |
| 2402 | * Return: On success, link status shall be returned. |
| 2403 | * On error or not associated, link status 0 will be returned. |
| 2404 | */ |
| 2405 | static int wlan_hdd_get_link_status(hdd_adapter_t *adapter) |
| 2406 | { |
| 2407 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2408 | hdd_station_ctx_t *pHddStaCtx = |
| 2409 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 2410 | struct statsContext context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2411 | QDF_STATUS hstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2412 | unsigned long rc; |
| 2413 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 2414 | if (cds_is_driver_recovering()) { |
| 2415 | hdd_warn("Recovery in Progress. State: 0x%x Ignore!!!", |
| 2416 | cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2417 | return 0; |
| 2418 | } |
| 2419 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 2420 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 2421 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2422 | hdd_warn("Unsupported in mode %s(%d)", |
| 2423 | hdd_device_mode_to_string(adapter->device_mode), |
| 2424 | adapter->device_mode); |
| 2425 | return 0; |
| 2426 | } |
| 2427 | |
| 2428 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 2429 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
| 2430 | /* If not associated, then expected link status return |
| 2431 | * value is 0 |
| 2432 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2433 | hdd_info("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2434 | return 0; |
| 2435 | } |
| 2436 | |
| 2437 | init_completion(&context.completion); |
| 2438 | context.pAdapter = adapter; |
| 2439 | context.magic = LINK_STATUS_MAGIC; |
| 2440 | hstatus = sme_get_link_status(WLAN_HDD_GET_HAL_CTX(adapter), |
| 2441 | hdd_get_link_status_cb, |
| 2442 | &context, adapter->sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2443 | if (QDF_STATUS_SUCCESS != hstatus) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2444 | hdd_err("Unable to retrieve link status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2445 | /* return a cached value */ |
| 2446 | } else { |
| 2447 | /* request is sent -- wait for the response */ |
| 2448 | rc = wait_for_completion_timeout(&context.completion, |
| 2449 | msecs_to_jiffies(WLAN_WAIT_TIME_LINK_STATUS)); |
| 2450 | if (!rc) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2451 | hdd_err("SME timed out while retrieving link status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2452 | } |
| 2453 | |
| 2454 | spin_lock(&hdd_context_lock); |
| 2455 | context.magic = 0; |
| 2456 | spin_unlock(&hdd_context_lock); |
| 2457 | |
| 2458 | /* either callback updated adapter stats or it has cached data */ |
| 2459 | return adapter->linkStatus; |
| 2460 | } |
| 2461 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2462 | static void hdd_tx_fail_ind_callback(uint8_t *MacAddr, uint8_t seqNo) |
| 2463 | { |
| 2464 | int payload_len; |
| 2465 | struct sk_buff *skb; |
| 2466 | struct nlmsghdr *nlh; |
| 2467 | uint8_t *data; |
| 2468 | |
| 2469 | payload_len = ETH_ALEN; |
| 2470 | |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 2471 | if (0 == cesium_pid || cesium_nl_srv_sock == NULL) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2472 | hdd_err("cesium process not registered"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2473 | return; |
| 2474 | } |
| 2475 | |
| 2476 | skb = nlmsg_new(payload_len, GFP_ATOMIC); |
| 2477 | if (skb == NULL) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2478 | hdd_err("nlmsg_new() failed for msg size[%d]", |
| 2479 | NLMSG_SPACE(payload_len)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2480 | return; |
| 2481 | } |
| 2482 | |
| 2483 | nlh = nlmsg_put(skb, cesium_pid, seqNo, 0, payload_len, NLM_F_REQUEST); |
| 2484 | |
| 2485 | if (NULL == nlh) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2486 | hdd_err("nlmsg_put() failed for msg size[%d]", |
| 2487 | NLMSG_SPACE(payload_len)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2488 | |
| 2489 | kfree_skb(skb); |
| 2490 | return; |
| 2491 | } |
| 2492 | |
| 2493 | data = nlmsg_data(nlh); |
| 2494 | memcpy(data, MacAddr, ETH_ALEN); |
| 2495 | |
| 2496 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2497 | hdd_err("nlmsg_unicast() failed for msg size[%d]", |
| 2498 | NLMSG_SPACE(payload_len)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2499 | } |
| 2500 | |
| 2501 | return; |
| 2502 | } |
| 2503 | |
| 2504 | |
| 2505 | /** |
| 2506 | * hdd_ParseuserParams - return a pointer to the next argument |
| 2507 | * @pValue: Input argument string |
| 2508 | * @ppArg: Output pointer to the next argument |
| 2509 | * |
| 2510 | * This function parses argument stream and finds the pointer |
| 2511 | * to the next argument |
| 2512 | * |
| 2513 | * Return: 0 if the next argument found; -EINVAL otherwise |
| 2514 | */ |
| 2515 | static int hdd_parse_user_params(uint8_t *pValue, uint8_t **ppArg) |
| 2516 | { |
| 2517 | uint8_t *pVal; |
| 2518 | |
| 2519 | pVal = strnchr(pValue, strlen(pValue), ' '); |
| 2520 | |
| 2521 | if (NULL == pVal) { |
| 2522 | /* no argument remains */ |
| 2523 | return -EINVAL; |
| 2524 | } else if (SPACE_ASCII_VALUE != *pVal) { |
| 2525 | /* no space after the current argument */ |
| 2526 | return -EINVAL; |
| 2527 | } |
| 2528 | |
| 2529 | pVal++; |
| 2530 | |
| 2531 | /* remove empty spaces */ |
| 2532 | while ((SPACE_ASCII_VALUE == *pVal) && ('\0' != *pVal)) { |
| 2533 | pVal++; |
| 2534 | } |
| 2535 | |
| 2536 | /* no argument followed by spaces */ |
| 2537 | if ('\0' == *pVal) { |
| 2538 | return -EINVAL; |
| 2539 | } |
| 2540 | |
| 2541 | *ppArg = pVal; |
| 2542 | |
| 2543 | return 0; |
| 2544 | } |
| 2545 | |
| 2546 | /** |
| 2547 | * hdd_parse_ibsstx_fail_event_params - Parse params |
| 2548 | * for SETIBSSTXFAILEVENT |
| 2549 | * @pValue: Input ibss tx fail event argument |
| 2550 | * @tx_fail_count: (Output parameter) Tx fail counter |
| 2551 | * @pid: (Output parameter) PID |
| 2552 | * |
| 2553 | * Return: 0 if the parsing succeeds; -EINVAL otherwise |
| 2554 | */ |
| 2555 | static int hdd_parse_ibsstx_fail_event_params(uint8_t *pValue, |
| 2556 | uint8_t *tx_fail_count, |
| 2557 | uint16_t *pid) |
| 2558 | { |
| 2559 | uint8_t *param = NULL; |
| 2560 | int ret; |
| 2561 | |
| 2562 | ret = hdd_parse_user_params(pValue, ¶m); |
| 2563 | |
| 2564 | if (0 == ret && NULL != param) { |
| 2565 | if (1 != sscanf(param, "%hhu", tx_fail_count)) { |
| 2566 | ret = -EINVAL; |
| 2567 | goto done; |
| 2568 | } |
| 2569 | } else { |
| 2570 | goto done; |
| 2571 | } |
| 2572 | |
| 2573 | if (0 == *tx_fail_count) { |
| 2574 | *pid = 0; |
| 2575 | goto done; |
| 2576 | } |
| 2577 | |
| 2578 | pValue = param; |
| 2579 | pValue++; |
| 2580 | |
| 2581 | ret = hdd_parse_user_params(pValue, ¶m); |
| 2582 | |
| 2583 | if (0 == ret) { |
| 2584 | if (1 != sscanf(param, "%hu", pid)) { |
| 2585 | ret = -EINVAL; |
| 2586 | goto done; |
| 2587 | } |
| 2588 | } else { |
| 2589 | goto done; |
| 2590 | } |
| 2591 | |
| 2592 | done: |
| 2593 | return ret; |
| 2594 | } |
| 2595 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 2596 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2597 | /** |
| 2598 | * hdd_parse_ese_beacon_req() - Parse ese beacon request |
| 2599 | * @pValue: Pointer to data |
| 2600 | * @pEseBcnReq: Output pointer to store parsed ie information |
| 2601 | * |
| 2602 | * This function parses the ese beacon request passed in the format |
| 2603 | * CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 2604 | * <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 2605 | * <space>Scan Mode N<space>Meas Duration N |
| 2606 | * |
| 2607 | * If the Number of bcn req fields (N) does not match with the |
| 2608 | * actual number of fields passed then take N. |
| 2609 | * <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated |
| 2610 | * as one pair. For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 2611 | * This function does not take care of removing duplicate channels from the |
| 2612 | * list |
| 2613 | * |
| 2614 | * Return: 0 for success non-zero for failure |
| 2615 | */ |
| 2616 | static int hdd_parse_ese_beacon_req(uint8_t *pValue, |
| 2617 | tCsrEseBeaconReq *pEseBcnReq) |
| 2618 | { |
| 2619 | uint8_t *inPtr = pValue; |
| 2620 | int tempInt = 0; |
| 2621 | int j = 0, i = 0, v = 0; |
| 2622 | char buf[32]; |
| 2623 | |
| 2624 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 2625 | /* no argument after the command */ |
| 2626 | if (NULL == inPtr) { |
| 2627 | return -EINVAL; |
| 2628 | } |
| 2629 | /* no space after the command */ |
| 2630 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 2631 | return -EINVAL; |
| 2632 | } |
| 2633 | |
| 2634 | /* remove empty spaces */ |
| 2635 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 2636 | inPtr++; |
| 2637 | |
| 2638 | /* no argument followed by spaces */ |
| 2639 | if ('\0' == *inPtr) |
| 2640 | return -EINVAL; |
| 2641 | |
| 2642 | /* get the first argument ie measurement token */ |
| 2643 | v = sscanf(inPtr, "%31s ", buf); |
| 2644 | if (1 != v) |
| 2645 | return -EINVAL; |
| 2646 | |
| 2647 | v = kstrtos32(buf, 10, &tempInt); |
| 2648 | if (v < 0) |
| 2649 | return -EINVAL; |
| 2650 | |
| 2651 | pEseBcnReq->numBcnReqIe = tempInt; |
| 2652 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2653 | hdd_info("Number of Bcn Req Ie fields(%d)", |
| 2654 | pEseBcnReq->numBcnReqIe); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2655 | |
| 2656 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) { |
| 2657 | for (i = 0; i < 4; i++) { |
| 2658 | /* |
| 2659 | * inPtr pointing to the beginning of 1st space |
| 2660 | * after number of ie fields |
| 2661 | */ |
| 2662 | inPtr = strpbrk(inPtr, " "); |
| 2663 | /* no ie data after the number of ie fields argument */ |
| 2664 | if (NULL == inPtr) |
| 2665 | return -EINVAL; |
| 2666 | |
| 2667 | /* remove empty space */ |
| 2668 | while ((SPACE_ASCII_VALUE == *inPtr) |
| 2669 | && ('\0' != *inPtr)) |
| 2670 | inPtr++; |
| 2671 | |
| 2672 | /* |
| 2673 | * no ie data after the number of ie fields |
| 2674 | * argument and spaces |
| 2675 | */ |
| 2676 | if ('\0' == *inPtr) |
| 2677 | return -EINVAL; |
| 2678 | |
| 2679 | v = sscanf(inPtr, "%31s ", buf); |
| 2680 | if (1 != v) |
| 2681 | return -EINVAL; |
| 2682 | |
| 2683 | v = kstrtos32(buf, 10, &tempInt); |
| 2684 | if (v < 0) |
| 2685 | return -EINVAL; |
| 2686 | |
| 2687 | switch (i) { |
| 2688 | case 0: /* Measurement token */ |
| 2689 | if (tempInt <= 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2690 | hdd_err("Invalid Measurement Token(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2691 | tempInt); |
| 2692 | return -EINVAL; |
| 2693 | } |
| 2694 | pEseBcnReq->bcnReq[j].measurementToken = |
| 2695 | tempInt; |
| 2696 | break; |
| 2697 | |
| 2698 | case 1: /* Channel number */ |
| 2699 | if ((tempInt <= 0) || |
| 2700 | (tempInt > |
| 2701 | WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2702 | hdd_err("Invalid Channel Number(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2703 | tempInt); |
| 2704 | return -EINVAL; |
| 2705 | } |
| 2706 | pEseBcnReq->bcnReq[j].channel = tempInt; |
| 2707 | break; |
| 2708 | |
| 2709 | case 2: /* Scan mode */ |
| 2710 | if ((tempInt < eSIR_PASSIVE_SCAN) |
| 2711 | || (tempInt > eSIR_BEACON_TABLE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2712 | hdd_err("Invalid Scan Mode(%d) Expected{0|1|2}", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2713 | tempInt); |
| 2714 | return -EINVAL; |
| 2715 | } |
| 2716 | pEseBcnReq->bcnReq[j].scanMode = tempInt; |
| 2717 | break; |
| 2718 | |
| 2719 | case 3: /* Measurement duration */ |
| 2720 | if (((tempInt <= 0) |
| 2721 | && (pEseBcnReq->bcnReq[j].scanMode != |
| 2722 | eSIR_BEACON_TABLE)) || |
| 2723 | ((tempInt < 0) && |
| 2724 | (pEseBcnReq->bcnReq[j].scanMode == |
| 2725 | eSIR_BEACON_TABLE))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2726 | hdd_err("Invalid Measurement Duration(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2727 | tempInt); |
| 2728 | return -EINVAL; |
| 2729 | } |
| 2730 | pEseBcnReq->bcnReq[j].measurementDuration = |
| 2731 | tempInt; |
| 2732 | break; |
| 2733 | } |
| 2734 | } |
| 2735 | } |
| 2736 | |
| 2737 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2738 | hdd_info("Index(%d) Measurement Token(%u) Channel(%u) Scan Mode(%u) Measurement Duration(%u)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2739 | j, |
| 2740 | pEseBcnReq->bcnReq[j].measurementToken, |
| 2741 | pEseBcnReq->bcnReq[j].channel, |
| 2742 | pEseBcnReq->bcnReq[j].scanMode, |
| 2743 | pEseBcnReq->bcnReq[j].measurementDuration); |
| 2744 | } |
| 2745 | |
| 2746 | return 0; |
| 2747 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2748 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2749 | /** |
| 2750 | * hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 2751 | * @pValue: Pointer to input data |
| 2752 | * @pCckmIe: Pointer to output cckm Ie |
| 2753 | * @pCckmIeLen: Pointer to output cckm ie length |
| 2754 | * |
| 2755 | * This function parses the SETCCKM IE command |
| 2756 | * SETCCKMIE<space><ie data> |
| 2757 | * |
| 2758 | * Return: 0 for success non-zero for failure |
| 2759 | */ |
| 2760 | static int hdd_parse_get_cckm_ie(uint8_t *pValue, uint8_t **pCckmIe, |
| 2761 | uint8_t *pCckmIeLen) |
| 2762 | { |
| 2763 | uint8_t *inPtr = pValue; |
| 2764 | uint8_t *dataEnd; |
| 2765 | int j = 0; |
| 2766 | int i = 0; |
| 2767 | uint8_t tempByte = 0; |
| 2768 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 2769 | /* no argument after the command */ |
| 2770 | if (NULL == inPtr) { |
| 2771 | return -EINVAL; |
| 2772 | } |
| 2773 | /* no space after the command */ |
| 2774 | else if (SPACE_ASCII_VALUE != *inPtr) { |
| 2775 | return -EINVAL; |
| 2776 | } |
| 2777 | /* remove empty spaces */ |
| 2778 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) |
| 2779 | inPtr++; |
| 2780 | /* no argument followed by spaces */ |
| 2781 | if ('\0' == *inPtr) { |
| 2782 | return -EINVAL; |
| 2783 | } |
| 2784 | /* find the length of data */ |
| 2785 | dataEnd = inPtr; |
| 2786 | while (('\0' != *dataEnd)) { |
| 2787 | dataEnd++; |
| 2788 | ++(*pCckmIeLen); |
| 2789 | } |
| 2790 | if (*pCckmIeLen <= 0) |
| 2791 | return -EINVAL; |
| 2792 | /* |
| 2793 | * Allocate the number of bytes based on the number of input characters |
| 2794 | * whether it is even or odd. |
| 2795 | * if the number of input characters are even, then we need N / 2 byte. |
| 2796 | * if the number of input characters are odd, then we need do |
| 2797 | * (N + 1) / 2 to compensate rounding off. |
| 2798 | * For example, if N = 18, then (18 + 1) / 2 = 9 bytes are enough. |
| 2799 | * If N = 19, then we need 10 bytes, hence (19 + 1) / 2 = 10 bytes |
| 2800 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2801 | *pCckmIe = qdf_mem_malloc((*pCckmIeLen + 1) / 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2802 | if (NULL == *pCckmIe) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2803 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2804 | return -ENOMEM; |
| 2805 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2806 | qdf_mem_zero(*pCckmIe, (*pCckmIeLen + 1) / 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2807 | /* |
| 2808 | * the buffer received from the upper layer is character buffer, |
| 2809 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 2810 | * decimal number for example 7f0000f0...form a buffer to contain |
| 2811 | * 7f in 0th location, 00 in 1st and f0 in 3rd location |
| 2812 | */ |
| 2813 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) { |
| 2814 | tempByte = (hex_to_bin(inPtr[j]) << 4) | |
| 2815 | (hex_to_bin(inPtr[j + 1])); |
| 2816 | (*pCckmIe)[i++] = tempByte; |
| 2817 | } |
| 2818 | *pCckmIeLen = i; |
| 2819 | return 0; |
| 2820 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 2821 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2822 | |
| 2823 | int wlan_hdd_set_mc_rate(hdd_adapter_t *pAdapter, int targetRate) |
| 2824 | { |
| 2825 | tSirRateUpdateInd rateUpdate = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2826 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2827 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2828 | struct hdd_config *pConfig = NULL; |
| 2829 | |
| 2830 | if (pHddCtx == NULL) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2831 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2832 | return -EINVAL; |
| 2833 | } |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 2834 | if ((QDF_IBSS_MODE != pAdapter->device_mode) && |
| 2835 | (QDF_SAP_MODE != pAdapter->device_mode) && |
| 2836 | (QDF_STA_MODE != pAdapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2837 | hdd_err("Received SETMCRATE cmd in invalid mode %s(%d)", |
| 2838 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 2839 | pAdapter->device_mode); |
| 2840 | hdd_err("SETMCRATE cmd is allowed only in STA, IBSS or SOFTAP mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2841 | return -EINVAL; |
| 2842 | } |
| 2843 | pConfig = pHddCtx->config; |
| 2844 | rateUpdate.nss = (pConfig->enable2x2 == 0) ? 0 : 1; |
| 2845 | rateUpdate.dev_mode = pAdapter->device_mode; |
| 2846 | rateUpdate.mcastDataRate24GHz = targetRate; |
| 2847 | rateUpdate.mcastDataRate24GHzTxFlag = 1; |
| 2848 | rateUpdate.mcastDataRate5GHz = targetRate; |
| 2849 | rateUpdate.bcastDataRate = -1; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2850 | qdf_copy_macaddr(&rateUpdate.bssid, &pAdapter->macAddressCurrent); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2851 | hdd_info("MC Target rate %d, mac = %pM, dev_mode %s(%d)", |
| 2852 | rateUpdate.mcastDataRate24GHz, rateUpdate.bssid.bytes, |
| 2853 | hdd_device_mode_to_string(pAdapter->device_mode), |
| 2854 | pAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2855 | status = sme_send_rate_update_ind(pHddCtx->hHal, &rateUpdate); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2856 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2857 | hdd_err("SETMCRATE failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2858 | return -EFAULT; |
| 2859 | } |
| 2860 | return 0; |
| 2861 | } |
| 2862 | |
| 2863 | static int drv_cmd_p2p_dev_addr(hdd_adapter_t *adapter, |
| 2864 | hdd_context_t *hdd_ctx, |
| 2865 | uint8_t *command, |
| 2866 | uint8_t command_len, |
| 2867 | hdd_priv_data_t *priv_data) |
| 2868 | { |
| 2869 | int ret = 0; |
| 2870 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2871 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2872 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2873 | adapter->sessionId, |
| 2874 | (unsigned)(*(hdd_ctx->p2pDeviceAddress.bytes + 2) |
| 2875 | << 24 | *(hdd_ctx->p2pDeviceAddress.bytes |
| 2876 | + 3) << 16 | *(hdd_ctx-> |
| 2877 | p2pDeviceAddress.bytes + 4) << 8 | |
| 2878 | *(hdd_ctx->p2pDeviceAddress.bytes + |
| 2879 | 5)))); |
| 2880 | |
| 2881 | if (copy_to_user(priv_data->buf, hdd_ctx->p2pDeviceAddress.bytes, |
| 2882 | sizeof(tSirMacAddr))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2883 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2884 | ret = -EFAULT; |
| 2885 | } |
| 2886 | |
| 2887 | return ret; |
| 2888 | } |
| 2889 | |
| 2890 | /** |
| 2891 | * drv_cmd_p2p_set_noa() - Handler for P2P_SET_NOA driver command |
| 2892 | * @adapter: Adapter on which the command was received |
| 2893 | * @hdd_ctx: HDD global context |
| 2894 | * @command: Entire driver command received from userspace |
| 2895 | * @command_len: Length of @command |
| 2896 | * @priv_data: Pointer to ioctl private data structure |
| 2897 | * |
| 2898 | * This is a trivial command hander function which simply forwards the |
| 2899 | * command to the actual command processor within the P2P module. |
| 2900 | * |
| 2901 | * Return: 0 on success, non-zero on failure |
| 2902 | */ |
| 2903 | static int drv_cmd_p2p_set_noa(hdd_adapter_t *adapter, |
| 2904 | hdd_context_t *hdd_ctx, |
| 2905 | uint8_t *command, |
| 2906 | uint8_t command_len, |
| 2907 | hdd_priv_data_t *priv_data) |
| 2908 | { |
| 2909 | return hdd_set_p2p_noa(adapter->dev, command); |
| 2910 | } |
| 2911 | |
| 2912 | /** |
| 2913 | * drv_cmd_p2p_set_ps() - Handler for P2P_SET_PS driver command |
| 2914 | * @adapter: Adapter on which the command was received |
| 2915 | * @hdd_ctx: HDD global context |
| 2916 | * @command: Entire driver command received from userspace |
| 2917 | * @command_len: Length of @command |
| 2918 | * @priv_data: Pointer to ioctl private data structure |
| 2919 | * |
| 2920 | * This is a trivial command hander function which simply forwards the |
| 2921 | * command to the actual command processor within the P2P module. |
| 2922 | * |
| 2923 | * Return: 0 on success, non-zero on failure |
| 2924 | */ |
| 2925 | static int drv_cmd_p2p_set_ps(hdd_adapter_t *adapter, |
| 2926 | hdd_context_t *hdd_ctx, |
| 2927 | uint8_t *command, |
| 2928 | uint8_t command_len, |
| 2929 | hdd_priv_data_t *priv_data) |
| 2930 | { |
| 2931 | return hdd_set_p2p_opps(adapter->dev, command); |
| 2932 | } |
| 2933 | |
| 2934 | static int drv_cmd_set_band(hdd_adapter_t *adapter, |
| 2935 | hdd_context_t *hdd_ctx, |
| 2936 | uint8_t *command, |
| 2937 | uint8_t command_len, |
| 2938 | hdd_priv_data_t *priv_data) |
| 2939 | { |
| 2940 | int ret = 0; |
| 2941 | |
| 2942 | uint8_t *ptr = command; |
| 2943 | |
| 2944 | /* Change band request received */ |
| 2945 | |
| 2946 | /* |
| 2947 | * First 8 bytes will have "SETBAND " and |
| 2948 | * 9 byte will have band setting value |
| 2949 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2950 | hdd_info("SetBandCommand Info comm %s UL %d, TL %d", |
| 2951 | command, priv_data->used_len, |
| 2952 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2953 | |
| 2954 | /* Change band request received */ |
| 2955 | ret = hdd_set_band_helper(adapter->dev, ptr); |
| 2956 | |
| 2957 | return ret; |
| 2958 | } |
| 2959 | |
| 2960 | static int drv_cmd_set_wmmps(hdd_adapter_t *adapter, |
| 2961 | hdd_context_t *hdd_ctx, |
| 2962 | uint8_t *command, |
| 2963 | uint8_t command_len, |
| 2964 | hdd_priv_data_t *priv_data) |
| 2965 | { |
| 2966 | return hdd_wmmps_helper(adapter, command); |
| 2967 | } |
| 2968 | |
| 2969 | static int drv_cmd_country(hdd_adapter_t *adapter, |
| 2970 | hdd_context_t *hdd_ctx, |
| 2971 | uint8_t *command, |
| 2972 | uint8_t command_len, |
| 2973 | hdd_priv_data_t *priv_data) |
| 2974 | { |
| 2975 | int ret = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2976 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2977 | unsigned long rc; |
| 2978 | char *country_code; |
| 2979 | |
| 2980 | country_code = command + 8; |
| 2981 | |
| 2982 | INIT_COMPLETION(adapter->change_country_code); |
| 2983 | |
| 2984 | status = sme_change_country_code(hdd_ctx->hHal, |
| 2985 | wlan_hdd_change_country_code_callback, |
| 2986 | country_code, |
| 2987 | adapter, |
| 2988 | hdd_ctx->pcds_context, |
| 2989 | eSIR_TRUE, |
| 2990 | eSIR_TRUE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2991 | if (status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2992 | rc = wait_for_completion_timeout( |
| 2993 | &adapter->change_country_code, |
| 2994 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2995 | if (!rc) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2996 | hdd_err("SME while setting country code timed out"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2997 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2998 | hdd_err("SME Change Country code fail, status %d", |
| 2999 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3000 | ret = -EINVAL; |
| 3001 | } |
| 3002 | |
| 3003 | return ret; |
| 3004 | } |
| 3005 | |
| 3006 | static int drv_cmd_set_roam_trigger(hdd_adapter_t *adapter, |
| 3007 | hdd_context_t *hdd_ctx, |
| 3008 | uint8_t *command, |
| 3009 | uint8_t command_len, |
| 3010 | hdd_priv_data_t *priv_data) |
| 3011 | { |
| 3012 | int ret = 0; |
| 3013 | uint8_t *value = command; |
| 3014 | int8_t rssi = 0; |
| 3015 | uint8_t lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3016 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3017 | |
| 3018 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 3019 | value = value + command_len + 1; |
| 3020 | |
| 3021 | /* Convert the value from ascii to integer */ |
| 3022 | ret = kstrtos8(value, 10, &rssi); |
| 3023 | if (ret < 0) { |
| 3024 | /* |
| 3025 | * If the input value is greater than max value of datatype, |
| 3026 | * then also kstrtou8 fails |
| 3027 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3028 | hdd_err("kstrtou8 failed Input value may be out of range[%d - %d]", |
| 3029 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 3030 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3031 | ret = -EINVAL; |
| 3032 | goto exit; |
| 3033 | } |
| 3034 | |
| 3035 | lookUpThreshold = abs(rssi); |
| 3036 | |
| 3037 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) |
| 3038 | || (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3039 | hdd_err("Neighbor lookup threshold value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3040 | lookUpThreshold, |
| 3041 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 3042 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 3043 | ret = -EINVAL; |
| 3044 | goto exit; |
| 3045 | } |
| 3046 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3047 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 3049 | adapter->sessionId, lookUpThreshold)); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3050 | hdd_info("Received Command to Set Roam trigger (Neighbor lookup threshold) = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3051 | lookUpThreshold); |
| 3052 | |
| 3053 | hdd_ctx->config->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 3054 | status = sme_set_neighbor_lookup_rssi_threshold(hdd_ctx->hHal, |
| 3055 | adapter->sessionId, |
| 3056 | lookUpThreshold); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3057 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3058 | hdd_err("Failed to set roam trigger, try again"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3059 | ret = -EPERM; |
| 3060 | goto exit; |
| 3061 | } |
| 3062 | |
| 3063 | exit: |
| 3064 | return ret; |
| 3065 | } |
| 3066 | |
| 3067 | static int drv_cmd_get_roam_trigger(hdd_adapter_t *adapter, |
| 3068 | hdd_context_t *hdd_ctx, |
| 3069 | uint8_t *command, |
| 3070 | uint8_t command_len, |
| 3071 | hdd_priv_data_t *priv_data) |
| 3072 | { |
| 3073 | int ret = 0; |
| 3074 | uint8_t lookUpThreshold = |
| 3075 | sme_get_neighbor_lookup_rssi_threshold(hdd_ctx->hHal); |
| 3076 | int rssi = (-1) * lookUpThreshold; |
| 3077 | char extra[32]; |
| 3078 | uint8_t len = 0; |
| 3079 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3080 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3081 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 3082 | adapter->sessionId, lookUpThreshold)); |
| 3083 | |
| 3084 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3085 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3087 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3088 | ret = -EFAULT; |
| 3089 | } |
| 3090 | |
| 3091 | return ret; |
| 3092 | } |
| 3093 | |
| 3094 | static int drv_cmd_set_roam_scan_period(hdd_adapter_t *adapter, |
| 3095 | hdd_context_t *hdd_ctx, |
| 3096 | uint8_t *command, |
| 3097 | uint8_t command_len, |
| 3098 | hdd_priv_data_t *priv_data) |
| 3099 | { |
| 3100 | int ret = 0; |
| 3101 | uint8_t *value = command; |
| 3102 | uint8_t roamScanPeriod = 0; |
| 3103 | uint16_t neighborEmptyScanRefreshPeriod = |
| 3104 | CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
| 3105 | |
| 3106 | /* input refresh period is in terms of seconds */ |
| 3107 | |
| 3108 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 3109 | value = value + command_len + 1; |
| 3110 | |
| 3111 | /* Convert the value from ascii to integer */ |
| 3112 | ret = kstrtou8(value, 10, &roamScanPeriod); |
| 3113 | if (ret < 0) { |
| 3114 | /* |
| 3115 | * If the input value is greater than max value of datatype, |
| 3116 | * then also kstrtou8 fails |
| 3117 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3118 | hdd_err("kstrtou8 failed Input value may be out of range[%d - %d]", |
| 3119 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN / 1000), |
| 3120 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3121 | ret = -EINVAL; |
| 3122 | goto exit; |
| 3123 | } |
| 3124 | |
| 3125 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN / 1000)) |
| 3126 | || (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX / 1000))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3127 | hdd_err("Roam scan period value %d is out of range (Min: %d Max: %d)", |
| 3128 | roamScanPeriod, |
| 3129 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN / 1000), |
| 3130 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3131 | ret = -EINVAL; |
| 3132 | goto exit; |
| 3133 | } |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3134 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3135 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 3136 | adapter->sessionId, roamScanPeriod)); |
| 3137 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
| 3138 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3139 | hdd_info("Received Command to Set roam scan period (Empty Scan refresh period) = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | roamScanPeriod); |
| 3141 | |
| 3142 | hdd_ctx->config->nEmptyScanRefreshPeriod = |
| 3143 | neighborEmptyScanRefreshPeriod; |
| 3144 | sme_update_empty_scan_refresh_period(hdd_ctx->hHal, |
| 3145 | adapter->sessionId, |
| 3146 | neighborEmptyScanRefreshPeriod); |
| 3147 | |
| 3148 | exit: |
| 3149 | return ret; |
| 3150 | } |
| 3151 | |
| 3152 | static int drv_cmd_get_roam_scan_period(hdd_adapter_t *adapter, |
| 3153 | hdd_context_t *hdd_ctx, |
| 3154 | uint8_t *command, |
| 3155 | uint8_t command_len, |
| 3156 | hdd_priv_data_t *priv_data) |
| 3157 | { |
| 3158 | int ret = 0; |
| 3159 | uint16_t nEmptyScanRefreshPeriod = |
| 3160 | sme_get_empty_scan_refresh_period(hdd_ctx->hHal); |
| 3161 | char extra[32]; |
| 3162 | uint8_t len = 0; |
| 3163 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3164 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3165 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 3166 | adapter->sessionId, |
| 3167 | nEmptyScanRefreshPeriod)); |
| 3168 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3169 | "GETROAMSCANPERIOD", |
| 3170 | (nEmptyScanRefreshPeriod / 1000)); |
| 3171 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3172 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3174 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3175 | ret = -EFAULT; |
| 3176 | } |
| 3177 | |
| 3178 | return ret; |
| 3179 | } |
| 3180 | |
| 3181 | static int drv_cmd_set_roam_scan_refresh_period(hdd_adapter_t *adapter, |
| 3182 | hdd_context_t *hdd_ctx, |
| 3183 | uint8_t *command, |
| 3184 | uint8_t command_len, |
| 3185 | hdd_priv_data_t *priv_data) |
| 3186 | { |
| 3187 | int ret = 0; |
| 3188 | uint8_t *value = command; |
| 3189 | uint8_t roamScanRefreshPeriod = 0; |
| 3190 | uint16_t neighborScanRefreshPeriod = |
| 3191 | CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
| 3192 | |
| 3193 | /* input refresh period is in terms of seconds */ |
| 3194 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 3195 | value = value + command_len + 1; |
| 3196 | |
| 3197 | /* Convert the value from ascii to integer */ |
| 3198 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
| 3199 | if (ret < 0) { |
| 3200 | /* |
| 3201 | * If the input value is greater than max value of datatype, |
| 3202 | * then also kstrtou8 fails |
| 3203 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3204 | hdd_err("kstrtou8 failed Input value may be out of range[%d - %d]", |
| 3205 | CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN / 1000, |
| 3206 | CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX / 1000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3207 | ret = -EINVAL; |
| 3208 | goto exit; |
| 3209 | } |
| 3210 | |
| 3211 | if ((roamScanRefreshPeriod < |
| 3212 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN / 1000)) |
| 3213 | || (roamScanRefreshPeriod > |
| 3214 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX / 1000))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3215 | hdd_err("Neighbor scan results refresh period value %d is out of range (Min: %d Max: %d)", |
| 3216 | roamScanRefreshPeriod, |
| 3217 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN |
| 3218 | / 1000), |
| 3219 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX |
| 3220 | / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3221 | ret = -EINVAL; |
| 3222 | goto exit; |
| 3223 | } |
| 3224 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 3225 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3226 | hdd_info("Received Command to Set roam scan refresh period (Scan refresh period) = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3227 | roamScanRefreshPeriod); |
| 3228 | |
| 3229 | hdd_ctx->config->nNeighborResultsRefreshPeriod = |
| 3230 | neighborScanRefreshPeriod; |
| 3231 | sme_set_neighbor_scan_refresh_period(hdd_ctx->hHal, |
| 3232 | adapter->sessionId, |
| 3233 | neighborScanRefreshPeriod); |
| 3234 | |
| 3235 | exit: |
| 3236 | return ret; |
| 3237 | } |
| 3238 | |
| 3239 | static int drv_cmd_get_roam_scan_refresh_period(hdd_adapter_t *adapter, |
| 3240 | hdd_context_t *hdd_ctx, |
| 3241 | uint8_t *command, |
| 3242 | uint8_t command_len, |
| 3243 | hdd_priv_data_t *priv_data) |
| 3244 | { |
| 3245 | int ret = 0; |
| 3246 | uint16_t value = |
| 3247 | sme_get_neighbor_scan_refresh_period(hdd_ctx->hHal); |
| 3248 | char extra[32]; |
| 3249 | uint8_t len = 0; |
| 3250 | |
| 3251 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3252 | "GETROAMSCANREFRESHPERIOD", |
| 3253 | (value / 1000)); |
| 3254 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3255 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3257 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | ret = -EFAULT; |
| 3259 | } |
| 3260 | |
| 3261 | return ret; |
| 3262 | } |
| 3263 | |
| 3264 | static int drv_cmd_set_roam_mode(hdd_adapter_t *adapter, |
| 3265 | hdd_context_t *hdd_ctx, |
| 3266 | uint8_t *command, |
| 3267 | uint8_t command_len, |
| 3268 | hdd_priv_data_t *priv_data) |
| 3269 | { |
| 3270 | int ret = 0; |
| 3271 | uint8_t *value = command; |
| 3272 | uint8_t roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3273 | |
| 3274 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 3275 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 3276 | |
| 3277 | /* Convert the value from ascii to integer */ |
| 3278 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 3279 | if (ret < 0) { |
| 3280 | /* |
| 3281 | * If the input value is greater than max value of datatype, |
| 3282 | * then also kstrtou8 fails |
| 3283 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3284 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 3285 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3286 | CFG_LFR_FEATURE_ENABLED_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | ret = -EINVAL; |
| 3288 | goto exit; |
| 3289 | } |
| 3290 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3291 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3292 | hdd_err("Roam Mode value %d is out of range (Min: %d Max: %d)", |
| 3293 | roamMode, |
| 3294 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3295 | CFG_LFR_FEATURE_ENABLED_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | ret = -EINVAL; |
| 3297 | goto exit; |
| 3298 | } |
| 3299 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3300 | hdd_debug("Received Command to Set Roam Mode = %d", |
| 3301 | roamMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3302 | /* |
| 3303 | * Note that |
| 3304 | * SETROAMMODE 0 is to enable LFR while |
| 3305 | * SETROAMMODE 1 is to disable LFR, but |
| 3306 | * notify_is_fast_roam_ini_feature_enabled 0/1 is to |
| 3307 | * enable/disable. So, we have to invert the value |
| 3308 | * to call sme_update_is_fast_roam_ini_feature_enabled. |
| 3309 | */ |
| 3310 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 3311 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 3312 | else |
| 3313 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 3314 | |
| 3315 | hdd_ctx->config->isFastRoamIniFeatureEnabled = roamMode; |
| 3316 | if (roamMode) { |
| 3317 | hdd_ctx->config->isRoamOffloadScanEnabled = roamMode; |
| 3318 | sme_update_roam_scan_offload_enabled( |
| 3319 | (tHalHandle)(hdd_ctx->hHal), |
| 3320 | hdd_ctx->config->isRoamOffloadScanEnabled); |
| 3321 | sme_update_is_fast_roam_ini_feature_enabled( |
| 3322 | hdd_ctx->hHal, |
| 3323 | adapter->sessionId, |
| 3324 | roamMode); |
| 3325 | } else { |
| 3326 | sme_update_is_fast_roam_ini_feature_enabled( |
| 3327 | hdd_ctx->hHal, |
| 3328 | adapter->sessionId, |
| 3329 | roamMode); |
| 3330 | hdd_ctx->config->isRoamOffloadScanEnabled = roamMode; |
| 3331 | sme_update_roam_scan_offload_enabled( |
| 3332 | (tHalHandle)(hdd_ctx->hHal), |
| 3333 | hdd_ctx->config->isRoamOffloadScanEnabled); |
| 3334 | } |
| 3335 | |
| 3336 | |
| 3337 | exit: |
| 3338 | return ret; |
| 3339 | } |
| 3340 | |
| 3341 | static int drv_cmd_get_roam_mode(hdd_adapter_t *adapter, |
| 3342 | hdd_context_t *hdd_ctx, |
| 3343 | uint8_t *command, |
| 3344 | uint8_t command_len, |
| 3345 | hdd_priv_data_t *priv_data) |
| 3346 | { |
| 3347 | int ret = 0; |
| 3348 | bool roamMode = sme_get_is_lfr_feature_enabled(hdd_ctx->hHal); |
| 3349 | char extra[32]; |
| 3350 | uint8_t len = 0; |
| 3351 | |
| 3352 | /* |
| 3353 | * roamMode value shall be inverted because the sementics is different. |
| 3354 | */ |
| 3355 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 3356 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 3357 | else |
| 3358 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 3359 | |
| 3360 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3361 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3362 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3363 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | ret = -EFAULT; |
| 3365 | } |
| 3366 | |
| 3367 | return ret; |
| 3368 | } |
| 3369 | |
| 3370 | static int drv_cmd_set_roam_delta(hdd_adapter_t *adapter, |
| 3371 | hdd_context_t *hdd_ctx, |
| 3372 | uint8_t *command, |
| 3373 | uint8_t command_len, |
| 3374 | hdd_priv_data_t *priv_data) |
| 3375 | { |
| 3376 | int ret = 0; |
| 3377 | uint8_t *value = command; |
| 3378 | uint8_t roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 3379 | |
| 3380 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 3381 | value = value + command_len + 1; |
| 3382 | |
| 3383 | /* Convert the value from ascii to integer */ |
| 3384 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 3385 | if (ret < 0) { |
| 3386 | /* |
| 3387 | * If the input value is greater than max value of datatype, |
| 3388 | * then also kstrtou8 fails |
| 3389 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3390 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 3391 | CFG_ROAM_RSSI_DIFF_MIN, |
| 3392 | CFG_ROAM_RSSI_DIFF_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | ret = -EINVAL; |
| 3394 | goto exit; |
| 3395 | } |
| 3396 | |
| 3397 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 3398 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3399 | hdd_err("Roam rssi diff value %d is out of range (Min: %d Max: %d)", |
| 3400 | roamRssiDiff, |
| 3401 | CFG_ROAM_RSSI_DIFF_MIN, |
| 3402 | CFG_ROAM_RSSI_DIFF_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3403 | ret = -EINVAL; |
| 3404 | goto exit; |
| 3405 | } |
| 3406 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3407 | hdd_info("Received Command to Set roam rssi diff = %d", |
| 3408 | roamRssiDiff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3409 | |
| 3410 | hdd_ctx->config->RoamRssiDiff = roamRssiDiff; |
| 3411 | sme_update_roam_rssi_diff(hdd_ctx->hHal, |
| 3412 | adapter->sessionId, |
| 3413 | roamRssiDiff); |
| 3414 | |
| 3415 | exit: |
| 3416 | return ret; |
| 3417 | } |
| 3418 | |
| 3419 | static int drv_cmd_get_roam_delta(hdd_adapter_t *adapter, |
| 3420 | hdd_context_t *hdd_ctx, |
| 3421 | uint8_t *command, |
| 3422 | uint8_t command_len, |
| 3423 | hdd_priv_data_t *priv_data) |
| 3424 | { |
| 3425 | int ret = 0; |
| 3426 | uint8_t roamRssiDiff = |
| 3427 | sme_get_roam_rssi_diff(hdd_ctx->hHal); |
| 3428 | char extra[32]; |
| 3429 | uint8_t len = 0; |
| 3430 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3431 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 3433 | adapter->sessionId, roamRssiDiff)); |
| 3434 | |
| 3435 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3436 | command, roamRssiDiff); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3437 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | |
| 3439 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3440 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3441 | ret = -EFAULT; |
| 3442 | } |
| 3443 | |
| 3444 | return ret; |
| 3445 | } |
| 3446 | |
| 3447 | static int drv_cmd_get_band(hdd_adapter_t *adapter, |
| 3448 | hdd_context_t *hdd_ctx, |
| 3449 | uint8_t *command, |
| 3450 | uint8_t command_len, |
| 3451 | hdd_priv_data_t *priv_data) |
| 3452 | { |
| 3453 | int ret = 0; |
| 3454 | int band = -1; |
| 3455 | char extra[32]; |
| 3456 | uint8_t len = 0; |
| 3457 | |
| 3458 | hdd_get_band_helper(hdd_ctx, &band); |
| 3459 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3460 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3461 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 3462 | adapter->sessionId, band)); |
| 3463 | |
| 3464 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3465 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3466 | |
| 3467 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3468 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3469 | ret = -EFAULT; |
| 3470 | } |
| 3471 | |
| 3472 | return ret; |
| 3473 | } |
| 3474 | |
| 3475 | static int drv_cmd_set_roam_scan_channels(hdd_adapter_t *adapter, |
| 3476 | hdd_context_t *hdd_ctx, |
| 3477 | uint8_t *command, |
| 3478 | uint8_t command_len, |
| 3479 | hdd_priv_data_t *priv_data) |
| 3480 | { |
| 3481 | return hdd_parse_set_roam_scan_channels(adapter, command); |
| 3482 | } |
| 3483 | |
| 3484 | static int drv_cmd_get_roam_scan_channels(hdd_adapter_t *adapter, |
| 3485 | hdd_context_t *hdd_ctx, |
| 3486 | uint8_t *command, |
| 3487 | uint8_t command_len, |
| 3488 | hdd_priv_data_t *priv_data) |
| 3489 | { |
| 3490 | int ret = 0; |
| 3491 | uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
| 3492 | uint8_t numChannels = 0; |
| 3493 | uint8_t j = 0; |
| 3494 | char extra[128] = { 0 }; |
| 3495 | int len; |
| 3496 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3497 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3498 | sme_get_roam_scan_channel_list(hdd_ctx->hHal, |
| 3499 | ChannelList, |
| 3500 | &numChannels, |
| 3501 | adapter->sessionId)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3502 | hdd_alert("failed to get roam scan channel list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3503 | ret = -EFAULT; |
| 3504 | goto exit; |
| 3505 | } |
| 3506 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3507 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3508 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 3509 | adapter->sessionId, numChannels)); |
| 3510 | /* |
| 3511 | * output channel list is of the format |
| 3512 | * [Number of roam scan channels][Channel1][Channel2]... |
| 3513 | * copy the number of channels in the 0th index |
| 3514 | */ |
| 3515 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
| 3516 | numChannels); |
| 3517 | for (j = 0; (j < numChannels); j++) |
| 3518 | len += scnprintf(extra + len, sizeof(extra) - len, |
| 3519 | " %d", ChannelList[j]); |
| 3520 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3521 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3523 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3524 | ret = -EFAULT; |
| 3525 | goto exit; |
| 3526 | } |
| 3527 | |
| 3528 | exit: |
| 3529 | return ret; |
| 3530 | } |
| 3531 | |
| 3532 | static int drv_cmd_get_ccx_mode(hdd_adapter_t *adapter, |
| 3533 | hdd_context_t *hdd_ctx, |
| 3534 | uint8_t *command, |
| 3535 | uint8_t command_len, |
| 3536 | hdd_priv_data_t *priv_data) |
| 3537 | { |
| 3538 | int ret = 0; |
| 3539 | bool eseMode = sme_get_is_ese_feature_enabled(hdd_ctx->hHal); |
| 3540 | char extra[32]; |
| 3541 | uint8_t len = 0; |
| 3542 | |
| 3543 | /* |
| 3544 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 3545 | * then this operation is not permitted (return FAILURE) |
| 3546 | */ |
| 3547 | if (eseMode && |
| 3548 | hdd_is_okc_mode_enabled(hdd_ctx) && |
| 3549 | sme_get_is_ft_feature_enabled(hdd_ctx->hHal)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3550 | hdd_warn("OKC/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3551 | ret = -EPERM; |
| 3552 | goto exit; |
| 3553 | } |
| 3554 | |
| 3555 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3556 | "GETCCXMODE", eseMode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3557 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3558 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3559 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3560 | ret = -EFAULT; |
| 3561 | goto exit; |
| 3562 | } |
| 3563 | |
| 3564 | exit: |
| 3565 | return ret; |
| 3566 | } |
| 3567 | |
| 3568 | static int drv_cmd_get_okc_mode(hdd_adapter_t *adapter, |
| 3569 | hdd_context_t *hdd_ctx, |
| 3570 | uint8_t *command, |
| 3571 | uint8_t command_len, |
| 3572 | hdd_priv_data_t *priv_data) |
| 3573 | { |
| 3574 | int ret = 0; |
| 3575 | bool okcMode = hdd_is_okc_mode_enabled(hdd_ctx); |
| 3576 | char extra[32]; |
| 3577 | uint8_t len = 0; |
| 3578 | |
| 3579 | /* |
| 3580 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 3581 | * then this operation is not permitted (return FAILURE) |
| 3582 | */ |
| 3583 | if (okcMode && |
| 3584 | sme_get_is_ese_feature_enabled(hdd_ctx->hHal) && |
| 3585 | sme_get_is_ft_feature_enabled(hdd_ctx->hHal)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3586 | hdd_warn("OKC/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | ret = -EPERM; |
| 3588 | goto exit; |
| 3589 | } |
| 3590 | |
| 3591 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3592 | "GETOKCMODE", okcMode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3593 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | |
| 3595 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3596 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3597 | ret = -EFAULT; |
| 3598 | goto exit; |
| 3599 | } |
| 3600 | |
| 3601 | exit: |
| 3602 | return ret; |
| 3603 | } |
| 3604 | |
| 3605 | static int drv_cmd_get_fast_roam(hdd_adapter_t *adapter, |
| 3606 | hdd_context_t *hdd_ctx, |
| 3607 | uint8_t *command, |
| 3608 | uint8_t command_len, |
| 3609 | hdd_priv_data_t *priv_data) |
| 3610 | { |
| 3611 | int ret = 0; |
| 3612 | bool lfrMode = sme_get_is_lfr_feature_enabled(hdd_ctx->hHal); |
| 3613 | char extra[32]; |
| 3614 | uint8_t len = 0; |
| 3615 | |
| 3616 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3617 | "GETFASTROAM", lfrMode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3618 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3619 | |
| 3620 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3621 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | ret = -EFAULT; |
| 3623 | } |
| 3624 | |
| 3625 | return ret; |
| 3626 | } |
| 3627 | |
| 3628 | static int drv_cmd_get_fast_transition(hdd_adapter_t *adapter, |
| 3629 | hdd_context_t *hdd_ctx, |
| 3630 | uint8_t *command, |
| 3631 | uint8_t command_len, |
| 3632 | hdd_priv_data_t *priv_data) |
| 3633 | { |
| 3634 | int ret = 0; |
| 3635 | bool ft = sme_get_is_ft_feature_enabled(hdd_ctx->hHal); |
| 3636 | char extra[32]; |
| 3637 | uint8_t len = 0; |
| 3638 | |
| 3639 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3640 | "GETFASTTRANSITION", ft); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3641 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3642 | |
| 3643 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3644 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3645 | ret = -EFAULT; |
| 3646 | } |
| 3647 | |
| 3648 | return ret; |
| 3649 | } |
| 3650 | |
| 3651 | static int drv_cmd_set_roam_scan_channel_min_time(hdd_adapter_t *adapter, |
| 3652 | hdd_context_t *hdd_ctx, |
| 3653 | uint8_t *command, |
| 3654 | uint8_t command_len, |
| 3655 | hdd_priv_data_t *priv_data) |
| 3656 | { |
| 3657 | int ret = 0; |
| 3658 | uint8_t *value = command; |
| 3659 | uint8_t minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 3660 | |
| 3661 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 3662 | value = value + command_len + 1; |
| 3663 | |
| 3664 | /* Convert the value from ascii to integer */ |
| 3665 | ret = kstrtou8(value, 10, &minTime); |
| 3666 | if (ret < 0) { |
| 3667 | /* |
| 3668 | * If the input value is greater than max value of datatype, |
| 3669 | * then also kstrtou8 fails |
| 3670 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3671 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 3672 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 3673 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3674 | ret = -EINVAL; |
| 3675 | goto exit; |
| 3676 | } |
| 3677 | |
| 3678 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 3679 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3680 | hdd_err("scan min channel time value %d is out of range (Min: %d Max: %d)", |
| 3681 | minTime, |
| 3682 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 3683 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | ret = -EINVAL; |
| 3685 | goto exit; |
| 3686 | } |
| 3687 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3688 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 3690 | adapter->sessionId, minTime)); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3691 | hdd_info("Received Command to change channel min time = %d", |
| 3692 | minTime); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3693 | |
| 3694 | hdd_ctx->config->nNeighborScanMinChanTime = minTime; |
| 3695 | sme_set_neighbor_scan_min_chan_time(hdd_ctx->hHal, |
| 3696 | minTime, |
| 3697 | adapter->sessionId); |
| 3698 | |
| 3699 | exit: |
| 3700 | return ret; |
| 3701 | } |
| 3702 | |
| 3703 | static int drv_cmd_send_action_frame(hdd_adapter_t *adapter, |
| 3704 | hdd_context_t *hdd_ctx, |
| 3705 | uint8_t *command, |
| 3706 | uint8_t command_len, |
| 3707 | hdd_priv_data_t *priv_data) |
| 3708 | { |
| 3709 | return hdd_parse_sendactionframe(adapter, command); |
| 3710 | } |
| 3711 | |
| 3712 | static int drv_cmd_get_roam_scan_channel_min_time(hdd_adapter_t *adapter, |
| 3713 | hdd_context_t *hdd_ctx, |
| 3714 | uint8_t *command, |
| 3715 | uint8_t command_len, |
| 3716 | hdd_priv_data_t *priv_data) |
| 3717 | { |
| 3718 | int ret = 0; |
| 3719 | uint16_t val = sme_get_neighbor_scan_min_chan_time(hdd_ctx->hHal, |
| 3720 | adapter->sessionId); |
| 3721 | char extra[32]; |
| 3722 | uint8_t len = 0; |
| 3723 | |
| 3724 | /* value is interms of msec */ |
| 3725 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3726 | "GETROAMSCANCHANNELMINTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3727 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3728 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3729 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3730 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 3731 | adapter->sessionId, val)); |
| 3732 | |
| 3733 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3734 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3735 | ret = -EFAULT; |
| 3736 | } |
| 3737 | |
| 3738 | return ret; |
| 3739 | } |
| 3740 | |
| 3741 | static int drv_cmd_set_scan_channel_time(hdd_adapter_t *adapter, |
| 3742 | hdd_context_t *hdd_ctx, |
| 3743 | uint8_t *command, |
| 3744 | uint8_t command_len, |
| 3745 | hdd_priv_data_t *priv_data) |
| 3746 | { |
| 3747 | int ret = 0; |
| 3748 | uint8_t *value = command; |
| 3749 | uint16_t maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
| 3750 | |
| 3751 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 3752 | value = value + command_len + 1; |
| 3753 | |
| 3754 | /* Convert the value from ascii to integer */ |
| 3755 | ret = kstrtou16(value, 10, &maxTime); |
| 3756 | if (ret < 0) { |
| 3757 | /* |
| 3758 | * If the input value is greater than max value of datatype, |
| 3759 | * then also kstrtou8 fails |
| 3760 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3761 | hdd_err("kstrtou16 failed range [%d - %d]", |
| 3762 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3763 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3764 | ret = -EINVAL; |
| 3765 | goto exit; |
| 3766 | } |
| 3767 | |
| 3768 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 3769 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3770 | hdd_err("lfr mode value %d is out of range (Min: %d Max: %d)", |
| 3771 | maxTime, |
| 3772 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3773 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3774 | ret = -EINVAL; |
| 3775 | goto exit; |
| 3776 | } |
| 3777 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3778 | hdd_info("Received Command to change channel max time = %d", |
| 3779 | maxTime); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | |
| 3781 | hdd_ctx->config->nNeighborScanMaxChanTime = maxTime; |
| 3782 | sme_set_neighbor_scan_max_chan_time(hdd_ctx->hHal, |
| 3783 | adapter->sessionId, |
| 3784 | maxTime); |
| 3785 | |
| 3786 | exit: |
| 3787 | return ret; |
| 3788 | } |
| 3789 | |
| 3790 | static int drv_cmd_get_scan_channel_time(hdd_adapter_t *adapter, |
| 3791 | hdd_context_t *hdd_ctx, |
| 3792 | uint8_t *command, |
| 3793 | uint8_t command_len, |
| 3794 | hdd_priv_data_t *priv_data) |
| 3795 | { |
| 3796 | int ret = 0; |
| 3797 | uint16_t val = sme_get_neighbor_scan_max_chan_time(hdd_ctx->hHal, |
| 3798 | adapter->sessionId); |
| 3799 | char extra[32]; |
| 3800 | uint8_t len = 0; |
| 3801 | |
| 3802 | /* value is interms of msec */ |
| 3803 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3804 | "GETSCANCHANNELTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3805 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | |
| 3807 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3808 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3809 | ret = -EFAULT; |
| 3810 | } |
| 3811 | |
| 3812 | return ret; |
| 3813 | } |
| 3814 | |
| 3815 | static int drv_cmd_set_scan_home_time(hdd_adapter_t *adapter, |
| 3816 | hdd_context_t *hdd_ctx, |
| 3817 | uint8_t *command, |
| 3818 | uint8_t command_len, |
| 3819 | hdd_priv_data_t *priv_data) |
| 3820 | { |
| 3821 | int ret = 0; |
| 3822 | uint8_t *value = command; |
| 3823 | uint16_t val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3824 | |
| 3825 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3826 | value = value + command_len + 1; |
| 3827 | |
| 3828 | /* Convert the value from ascii to integer */ |
| 3829 | ret = kstrtou16(value, 10, &val); |
| 3830 | if (ret < 0) { |
| 3831 | /* |
| 3832 | * If the input value is greater than max value of datatype, |
| 3833 | * then also kstrtou8 fails |
| 3834 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3835 | hdd_err("kstrtou16 failed range [%d - %d]", |
| 3836 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3837 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3838 | ret = -EINVAL; |
| 3839 | goto exit; |
| 3840 | } |
| 3841 | |
| 3842 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3843 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3844 | hdd_err("scan home time value %d is out of range (Min: %d Max: %d)", |
| 3845 | val, |
| 3846 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3847 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3848 | ret = -EINVAL; |
| 3849 | goto exit; |
| 3850 | } |
| 3851 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3852 | hdd_info("Received Command to change scan home time = %d", |
| 3853 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3854 | |
| 3855 | hdd_ctx->config->nNeighborScanPeriod = val; |
| 3856 | sme_set_neighbor_scan_period(hdd_ctx->hHal, |
| 3857 | adapter->sessionId, val); |
| 3858 | |
| 3859 | exit: |
| 3860 | return ret; |
| 3861 | } |
| 3862 | |
| 3863 | static int drv_cmd_get_scan_home_time(hdd_adapter_t *adapter, |
| 3864 | hdd_context_t *hdd_ctx, |
| 3865 | uint8_t *command, |
| 3866 | uint8_t command_len, |
| 3867 | hdd_priv_data_t *priv_data) |
| 3868 | { |
| 3869 | int ret = 0; |
| 3870 | uint16_t val = sme_get_neighbor_scan_period(hdd_ctx->hHal, |
| 3871 | adapter-> |
| 3872 | sessionId); |
| 3873 | char extra[32]; |
| 3874 | uint8_t len = 0; |
| 3875 | |
| 3876 | /* value is interms of msec */ |
| 3877 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3878 | "GETSCANHOMETIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3879 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3880 | |
| 3881 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3882 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3883 | ret = -EFAULT; |
| 3884 | } |
| 3885 | |
| 3886 | return ret; |
| 3887 | } |
| 3888 | |
| 3889 | static int drv_cmd_set_roam_intra_band(hdd_adapter_t *adapter, |
| 3890 | hdd_context_t *hdd_ctx, |
| 3891 | uint8_t *command, |
| 3892 | uint8_t command_len, |
| 3893 | hdd_priv_data_t *priv_data) |
| 3894 | { |
| 3895 | int ret = 0; |
| 3896 | uint8_t *value = command; |
| 3897 | uint8_t val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3898 | |
| 3899 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3900 | value = value + command_len + 1; |
| 3901 | |
| 3902 | /* Convert the value from ascii to integer */ |
| 3903 | ret = kstrtou8(value, 10, &val); |
| 3904 | if (ret < 0) { |
| 3905 | /* |
| 3906 | * If the input value is greater than max value of datatype, |
| 3907 | * then also kstrtou8 fails |
| 3908 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3909 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 3910 | CFG_ROAM_INTRA_BAND_MIN, |
| 3911 | CFG_ROAM_INTRA_BAND_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3912 | ret = -EINVAL; |
| 3913 | goto exit; |
| 3914 | } |
| 3915 | |
| 3916 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3917 | (val > CFG_ROAM_INTRA_BAND_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3918 | hdd_err("intra band mode value %d is out of range (Min: %d Max: %d)", |
| 3919 | val, |
| 3920 | CFG_ROAM_INTRA_BAND_MIN, |
| 3921 | CFG_ROAM_INTRA_BAND_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3922 | ret = -EINVAL; |
| 3923 | goto exit; |
| 3924 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3925 | hdd_info("Received Command to change intra band = %d", |
| 3926 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | |
| 3928 | hdd_ctx->config->nRoamIntraBand = val; |
| 3929 | sme_set_roam_intra_band(hdd_ctx->hHal, val); |
| 3930 | |
| 3931 | exit: |
| 3932 | return ret; |
| 3933 | } |
| 3934 | |
| 3935 | static int drv_cmd_get_roam_intra_band(hdd_adapter_t *adapter, |
| 3936 | hdd_context_t *hdd_ctx, |
| 3937 | uint8_t *command, |
| 3938 | uint8_t command_len, |
| 3939 | hdd_priv_data_t *priv_data) |
| 3940 | { |
| 3941 | int ret = 0; |
| 3942 | uint16_t val = sme_get_roam_intra_band(hdd_ctx->hHal); |
| 3943 | char extra[32]; |
| 3944 | uint8_t len = 0; |
| 3945 | |
| 3946 | /* value is interms of msec */ |
| 3947 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3948 | "GETROAMINTRABAND", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3949 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3950 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3951 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3952 | ret = -EFAULT; |
| 3953 | } |
| 3954 | |
| 3955 | return ret; |
| 3956 | } |
| 3957 | |
| 3958 | static int drv_cmd_set_scan_n_probes(hdd_adapter_t *adapter, |
| 3959 | hdd_context_t *hdd_ctx, |
| 3960 | uint8_t *command, |
| 3961 | uint8_t command_len, |
| 3962 | hdd_priv_data_t *priv_data) |
| 3963 | { |
| 3964 | int ret = 0; |
| 3965 | uint8_t *value = command; |
| 3966 | uint8_t nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3967 | |
| 3968 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3969 | value = value + command_len + 1; |
| 3970 | |
| 3971 | /* Convert the value from ascii to integer */ |
| 3972 | ret = kstrtou8(value, 10, &nProbes); |
| 3973 | if (ret < 0) { |
| 3974 | /* |
| 3975 | * If the input value is greater than max value of datatype, |
| 3976 | * then also kstrtou8 fails |
| 3977 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3978 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 3979 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3980 | CFG_ROAM_SCAN_N_PROBES_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3981 | ret = -EINVAL; |
| 3982 | goto exit; |
| 3983 | } |
| 3984 | |
| 3985 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3986 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3987 | hdd_err("NProbes value %d is out of range (Min: %d Max: %d)", |
| 3988 | nProbes, |
| 3989 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3990 | CFG_ROAM_SCAN_N_PROBES_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3991 | ret = -EINVAL; |
| 3992 | goto exit; |
| 3993 | } |
| 3994 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3995 | hdd_info("Received Command to Set nProbes = %d", |
| 3996 | nProbes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3997 | |
| 3998 | hdd_ctx->config->nProbes = nProbes; |
| 3999 | sme_update_roam_scan_n_probes(hdd_ctx->hHal, |
| 4000 | adapter->sessionId, nProbes); |
| 4001 | |
| 4002 | exit: |
| 4003 | return ret; |
| 4004 | } |
| 4005 | |
| 4006 | static int drv_cmd_get_scan_n_probes(hdd_adapter_t *adapter, |
| 4007 | hdd_context_t *hdd_ctx, |
| 4008 | uint8_t *command, |
| 4009 | uint8_t command_len, |
| 4010 | hdd_priv_data_t *priv_data) |
| 4011 | { |
| 4012 | int ret = 0; |
| 4013 | uint8_t val = sme_get_roam_scan_n_probes(hdd_ctx->hHal); |
| 4014 | char extra[32]; |
| 4015 | uint8_t len = 0; |
| 4016 | |
| 4017 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4018 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4019 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4020 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4021 | ret = -EFAULT; |
| 4022 | } |
| 4023 | |
| 4024 | return ret; |
| 4025 | } |
| 4026 | |
| 4027 | static int drv_cmd_set_scan_home_away_time(hdd_adapter_t *adapter, |
| 4028 | hdd_context_t *hdd_ctx, |
| 4029 | uint8_t *command, |
| 4030 | uint8_t command_len, |
| 4031 | hdd_priv_data_t *priv_data) |
| 4032 | { |
| 4033 | int ret = 0; |
| 4034 | uint8_t *value = command; |
| 4035 | uint16_t homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 4036 | |
| 4037 | /* input value is in units of msec */ |
| 4038 | |
| 4039 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 4040 | value = value + command_len + 1; |
| 4041 | |
| 4042 | /* Convert the value from ascii to integer */ |
| 4043 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 4044 | if (ret < 0) { |
| 4045 | /* |
| 4046 | * If the input value is greater than max value of datatype, |
| 4047 | * then also kstrtou8 fails |
| 4048 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4049 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 4050 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 4051 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4052 | ret = -EINVAL; |
| 4053 | goto exit; |
| 4054 | } |
| 4055 | |
| 4056 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 4057 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4058 | hdd_err("homeAwayTime value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4059 | homeAwayTime, |
| 4060 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 4061 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 4062 | ret = -EINVAL; |
| 4063 | goto exit; |
| 4064 | } |
| 4065 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4066 | hdd_info("Received Command to Set scan away time = %d", |
| 4067 | homeAwayTime); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4068 | |
| 4069 | if (hdd_ctx->config->nRoamScanHomeAwayTime != |
| 4070 | homeAwayTime) { |
| 4071 | hdd_ctx->config->nRoamScanHomeAwayTime = homeAwayTime; |
| 4072 | sme_update_roam_scan_home_away_time(hdd_ctx->hHal, |
| 4073 | adapter->sessionId, |
| 4074 | homeAwayTime, |
| 4075 | true); |
| 4076 | } |
| 4077 | |
| 4078 | exit: |
| 4079 | return ret; |
| 4080 | } |
| 4081 | |
| 4082 | static int drv_cmd_get_scan_home_away_time(hdd_adapter_t *adapter, |
| 4083 | hdd_context_t *hdd_ctx, |
| 4084 | uint8_t *command, |
| 4085 | uint8_t command_len, |
| 4086 | hdd_priv_data_t *priv_data) |
| 4087 | { |
| 4088 | int ret = 0; |
| 4089 | uint16_t val = sme_get_roam_scan_home_away_time(hdd_ctx->hHal); |
| 4090 | char extra[32]; |
| 4091 | uint8_t len = 0; |
| 4092 | |
| 4093 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4094 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | |
| 4096 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4097 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4098 | ret = -EFAULT; |
| 4099 | } |
| 4100 | |
| 4101 | return ret; |
| 4102 | } |
| 4103 | |
| 4104 | static int drv_cmd_reassoc(hdd_adapter_t *adapter, |
| 4105 | hdd_context_t *hdd_ctx, |
| 4106 | uint8_t *command, |
| 4107 | uint8_t command_len, |
| 4108 | hdd_priv_data_t *priv_data) |
| 4109 | { |
| 4110 | return hdd_parse_reassoc(adapter, command); |
| 4111 | } |
| 4112 | |
| 4113 | static int drv_cmd_set_wes_mode(hdd_adapter_t *adapter, |
| 4114 | hdd_context_t *hdd_ctx, |
| 4115 | uint8_t *command, |
| 4116 | uint8_t command_len, |
| 4117 | hdd_priv_data_t *priv_data) |
| 4118 | { |
| 4119 | int ret = 0; |
| 4120 | uint8_t *value = command; |
| 4121 | uint8_t wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 4122 | |
| 4123 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 4124 | value = value + command_len + 1; |
| 4125 | |
| 4126 | /* Convert the value from ascii to integer */ |
| 4127 | ret = kstrtou8(value, 10, &wesMode); |
| 4128 | if (ret < 0) { |
| 4129 | /* |
| 4130 | * If the input value is greater than max value of datatype, |
| 4131 | * then also kstrtou8 fails |
| 4132 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4133 | hdd_err("kstrtou8 failed range [%d - %d]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 4135 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 4136 | ret = -EINVAL; |
| 4137 | goto exit; |
| 4138 | } |
| 4139 | |
| 4140 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 4141 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4142 | hdd_err("WES Mode value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4143 | wesMode, |
| 4144 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 4145 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 4146 | ret = -EINVAL; |
| 4147 | goto exit; |
| 4148 | } |
| 4149 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4150 | hdd_info("Received Command to Set WES Mode rssi diff = %d", |
| 4151 | wesMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4152 | |
| 4153 | hdd_ctx->config->isWESModeEnabled = wesMode; |
| 4154 | sme_update_wes_mode(hdd_ctx->hHal, wesMode, adapter->sessionId); |
| 4155 | |
| 4156 | exit: |
| 4157 | return ret; |
| 4158 | } |
| 4159 | |
| 4160 | static int drv_cmd_get_wes_mode(hdd_adapter_t *adapter, |
| 4161 | hdd_context_t *hdd_ctx, |
| 4162 | uint8_t *command, |
| 4163 | uint8_t command_len, |
| 4164 | hdd_priv_data_t *priv_data) |
| 4165 | { |
| 4166 | int ret = 0; |
| 4167 | bool wesMode = sme_get_wes_mode(hdd_ctx->hHal); |
| 4168 | char extra[32]; |
| 4169 | uint8_t len = 0; |
| 4170 | |
| 4171 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4172 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4173 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4174 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4175 | ret = -EFAULT; |
| 4176 | } |
| 4177 | |
| 4178 | return ret; |
| 4179 | } |
| 4180 | |
| 4181 | static int drv_cmd_set_opportunistic_rssi_diff(hdd_adapter_t *adapter, |
| 4182 | hdd_context_t *hdd_ctx, |
| 4183 | uint8_t *command, |
| 4184 | uint8_t command_len, |
| 4185 | hdd_priv_data_t *priv_data) |
| 4186 | { |
| 4187 | int ret = 0; |
| 4188 | uint8_t *value = command; |
| 4189 | uint8_t nOpportunisticThresholdDiff = |
| 4190 | CFG_OPPORTUNISTIC_SCAN_THRESHOLD_DIFF_DEFAULT; |
| 4191 | |
| 4192 | /* Move pointer to ahead of SETOPPORTUNISTICRSSIDIFF<delimiter> */ |
| 4193 | value = value + command_len + 1; |
| 4194 | |
| 4195 | /* Convert the value from ascii to integer */ |
| 4196 | ret = kstrtou8(value, 10, &nOpportunisticThresholdDiff); |
| 4197 | if (ret < 0) { |
| 4198 | /* |
| 4199 | * If the input value is greater than max value of datatype, |
| 4200 | * then also kstrtou8 fails |
| 4201 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4202 | hdd_err("kstrtou8 failed."); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | ret = -EINVAL; |
| 4204 | goto exit; |
| 4205 | } |
| 4206 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4207 | hdd_info("Received Command to Set Opportunistic Threshold diff = %d", |
| 4208 | nOpportunisticThresholdDiff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4209 | |
| 4210 | sme_set_roam_opportunistic_scan_threshold_diff(hdd_ctx->hHal, |
| 4211 | adapter->sessionId, |
| 4212 | nOpportunisticThresholdDiff); |
| 4213 | |
| 4214 | exit: |
| 4215 | return ret; |
| 4216 | } |
| 4217 | |
| 4218 | static int drv_cmd_get_opportunistic_rssi_diff(hdd_adapter_t *adapter, |
| 4219 | hdd_context_t *hdd_ctx, |
| 4220 | uint8_t *command, |
| 4221 | uint8_t command_len, |
| 4222 | hdd_priv_data_t *priv_data) |
| 4223 | { |
| 4224 | int ret = 0; |
| 4225 | int8_t val = sme_get_roam_opportunistic_scan_threshold_diff( |
| 4226 | hdd_ctx->hHal); |
| 4227 | char extra[32]; |
| 4228 | uint8_t len = 0; |
| 4229 | |
| 4230 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4231 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4233 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4234 | ret = -EFAULT; |
| 4235 | } |
| 4236 | |
| 4237 | return ret; |
| 4238 | } |
| 4239 | |
| 4240 | static int drv_cmd_set_roam_rescan_rssi_diff(hdd_adapter_t *adapter, |
| 4241 | hdd_context_t *hdd_ctx, |
| 4242 | uint8_t *command, |
| 4243 | uint8_t command_len, |
| 4244 | hdd_priv_data_t *priv_data) |
| 4245 | { |
| 4246 | int ret = 0; |
| 4247 | uint8_t *value = command; |
| 4248 | uint8_t nRoamRescanRssiDiff = CFG_ROAM_RESCAN_RSSI_DIFF_DEFAULT; |
| 4249 | |
| 4250 | /* Move pointer to ahead of SETROAMRESCANRSSIDIFF<delimiter> */ |
| 4251 | value = value + command_len + 1; |
| 4252 | |
| 4253 | /* Convert the value from ascii to integer */ |
| 4254 | ret = kstrtou8(value, 10, &nRoamRescanRssiDiff); |
| 4255 | if (ret < 0) { |
| 4256 | /* |
| 4257 | * If the input value is greater than max value of datatype, |
| 4258 | * then also kstrtou8 fails |
| 4259 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4260 | hdd_err("kstrtou8 failed."); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4261 | ret = -EINVAL; |
| 4262 | goto exit; |
| 4263 | } |
| 4264 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4265 | hdd_info("Received Command to Set Roam Rescan RSSI Diff = %d", |
| 4266 | nRoamRescanRssiDiff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4267 | |
| 4268 | sme_set_roam_rescan_rssi_diff(hdd_ctx->hHal, |
| 4269 | adapter->sessionId, |
| 4270 | nRoamRescanRssiDiff); |
| 4271 | |
| 4272 | exit: |
| 4273 | return ret; |
| 4274 | } |
| 4275 | |
| 4276 | static int drv_cmd_get_roam_rescan_rssi_diff(hdd_adapter_t *adapter, |
| 4277 | hdd_context_t *hdd_ctx, |
| 4278 | uint8_t *command, |
| 4279 | uint8_t command_len, |
| 4280 | hdd_priv_data_t *priv_data) |
| 4281 | { |
| 4282 | int ret = 0; |
| 4283 | uint8_t val = sme_get_roam_rescan_rssi_diff(hdd_ctx->hHal); |
| 4284 | char extra[32]; |
| 4285 | uint8_t len = 0; |
| 4286 | |
| 4287 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4288 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4290 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4291 | ret = -EFAULT; |
| 4292 | } |
| 4293 | |
| 4294 | return ret; |
| 4295 | } |
| 4296 | |
| 4297 | static int drv_cmd_set_fast_roam(hdd_adapter_t *adapter, |
| 4298 | hdd_context_t *hdd_ctx, |
| 4299 | uint8_t *command, |
| 4300 | uint8_t command_len, |
| 4301 | hdd_priv_data_t *priv_data) |
| 4302 | { |
| 4303 | int ret = 0; |
| 4304 | uint8_t *value = command; |
| 4305 | uint8_t lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 4306 | |
| 4307 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4308 | value = value + command_len + 1; |
| 4309 | |
| 4310 | /* Convert the value from ascii to integer */ |
| 4311 | ret = kstrtou8(value, 10, &lfrMode); |
| 4312 | if (ret < 0) { |
| 4313 | /* |
| 4314 | * If the input value is greater than max value of datatype, |
| 4315 | * then also kstrtou8 fails |
| 4316 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4317 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 4318 | CFG_LFR_FEATURE_ENABLED_MIN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4319 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4320 | ret = -EINVAL; |
| 4321 | goto exit; |
| 4322 | } |
| 4323 | |
| 4324 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 4325 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4326 | hdd_err("lfr mode value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4327 | lfrMode, |
| 4328 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4329 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4330 | ret = -EINVAL; |
| 4331 | goto exit; |
| 4332 | } |
| 4333 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4334 | hdd_info("Received Command to change lfr mode = %d", |
| 4335 | lfrMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4336 | |
| 4337 | hdd_ctx->config->isFastRoamIniFeatureEnabled = lfrMode; |
| 4338 | sme_update_is_fast_roam_ini_feature_enabled(hdd_ctx->hHal, |
| 4339 | adapter-> |
| 4340 | sessionId, |
| 4341 | lfrMode); |
| 4342 | |
| 4343 | exit: |
| 4344 | return ret; |
| 4345 | } |
| 4346 | |
| 4347 | static int drv_cmd_set_fast_transition(hdd_adapter_t *adapter, |
| 4348 | hdd_context_t *hdd_ctx, |
| 4349 | uint8_t *command, |
| 4350 | uint8_t command_len, |
| 4351 | hdd_priv_data_t *priv_data) |
| 4352 | { |
| 4353 | int ret = 0; |
| 4354 | uint8_t *value = command; |
| 4355 | uint8_t ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 4356 | |
| 4357 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4358 | value = value + command_len + 1; |
| 4359 | |
| 4360 | /* Convert the value from ascii to integer */ |
| 4361 | ret = kstrtou8(value, 10, &ft); |
| 4362 | if (ret < 0) { |
| 4363 | /* |
| 4364 | * If the input value is greater than max value of datatype, |
| 4365 | * then also kstrtou8 fails |
| 4366 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4367 | hdd_err("kstrtou8 failed range [%d - %d]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4368 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 4369 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 4370 | ret = -EINVAL; |
| 4371 | goto exit; |
| 4372 | } |
| 4373 | |
| 4374 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 4375 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4376 | hdd_err("ft mode value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4377 | ft, |
| 4378 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 4379 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 4380 | ret = -EINVAL; |
| 4381 | goto exit; |
| 4382 | } |
| 4383 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4384 | hdd_info("Received Command to change ft mode = %d", ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4385 | |
| 4386 | hdd_ctx->config->isFastTransitionEnabled = ft; |
| 4387 | sme_update_fast_transition_enabled(hdd_ctx->hHal, ft); |
| 4388 | |
| 4389 | exit: |
| 4390 | return ret; |
| 4391 | } |
| 4392 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4393 | static int drv_cmd_fast_reassoc(hdd_adapter_t *adapter, |
| 4394 | hdd_context_t *hdd_ctx, |
| 4395 | uint8_t *command, |
| 4396 | uint8_t command_len, |
| 4397 | hdd_priv_data_t *priv_data) |
| 4398 | { |
| 4399 | int ret = 0; |
| 4400 | uint8_t *value = command; |
| 4401 | uint8_t channel = 0; |
| 4402 | tSirMacAddr targetApBssid; |
| 4403 | uint32_t roamId = 0; |
| 4404 | tCsrRoamModifyProfileFields modProfileFields; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | tCsrHandoffRequest handoffInfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | hdd_station_ctx_t *pHddStaCtx; |
| 4407 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4408 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4409 | hdd_warn("Unsupported in mode %s(%d)", |
| 4410 | hdd_device_mode_to_string(adapter->device_mode), |
| 4411 | adapter->device_mode); |
| 4412 | return -EINVAL; |
| 4413 | } |
| 4414 | |
| 4415 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4416 | |
| 4417 | /* if not associated, no need to proceed with reassoc */ |
| 4418 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4419 | hdd_info("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4420 | ret = -EINVAL; |
| 4421 | goto exit; |
| 4422 | } |
| 4423 | |
| 4424 | ret = hdd_parse_reassoc_command_v1_data(value, targetApBssid, |
| 4425 | &channel); |
| 4426 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4427 | hdd_err("Failed to parse reassoc command data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4428 | goto exit; |
| 4429 | } |
| 4430 | |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4431 | /* Check channel number is a valid channel number */ |
| 4432 | if (QDF_STATUS_SUCCESS != |
| 4433 | wlan_hdd_validate_operation_channel(adapter, channel)) { |
| 4434 | hdd_err("Invalid Channel [%d]", channel); |
| 4435 | return -EINVAL; |
| 4436 | } |
| 4437 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4438 | /* |
| 4439 | * if the target bssid is same as currently associated AP, |
| 4440 | * issue reassoc to same AP |
| 4441 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4442 | if (true != qdf_mem_cmp(targetApBssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4443 | pHddStaCtx->conn_info.bssId.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4444 | QDF_MAC_ADDR_SIZE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4445 | hdd_info("Reassoc BSSID is same as currently associated AP bssid"); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4446 | if (roaming_offload_enabled(hdd_ctx)) { |
| 4447 | hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId, |
| 4448 | targetApBssid, (int)channel); |
| 4449 | } else { |
| 4450 | sme_get_modify_profile_fields(hdd_ctx->hHal, |
| 4451 | adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4452 | &modProfileFields); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4453 | sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId, |
| 4454 | NULL, modProfileFields, &roamId, 1); |
| 4455 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4456 | return 0; |
| 4457 | } |
| 4458 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 4459 | if (roaming_offload_enabled(hdd_ctx)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4460 | hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId, |
| 4461 | targetApBssid, (int)channel); |
| 4462 | goto exit; |
| 4463 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4464 | /* Proceed with reassoc */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4465 | handoffInfo.channel = channel; |
| 4466 | handoffInfo.src = FASTREASSOC; |
Varun Reddy Yeturu | a66f9c5 | 2016-02-17 09:58:40 -0800 | [diff] [blame] | 4467 | qdf_mem_copy(handoffInfo.bssid.bytes, targetApBssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4468 | sizeof(tSirMacAddr)); |
| 4469 | sme_handoff_request(hdd_ctx->hHal, adapter->sessionId, |
| 4470 | &handoffInfo); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4471 | exit: |
| 4472 | return ret; |
| 4473 | } |
| 4474 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4475 | static int drv_cmd_set_roam_scan_control(hdd_adapter_t *adapter, |
| 4476 | hdd_context_t *hdd_ctx, |
| 4477 | uint8_t *command, |
| 4478 | uint8_t command_len, |
| 4479 | hdd_priv_data_t *priv_data) |
| 4480 | { |
| 4481 | int ret = 0; |
| 4482 | uint8_t *value = command; |
| 4483 | uint8_t roamScanControl = 0; |
| 4484 | |
| 4485 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 4486 | value = value + command_len + 1; |
| 4487 | |
| 4488 | /* Convert the value from ascii to integer */ |
| 4489 | ret = kstrtou8(value, 10, &roamScanControl); |
| 4490 | if (ret < 0) { |
| 4491 | /* |
| 4492 | * If the input value is greater than max value of datatype, |
| 4493 | * then also kstrtou8 fails |
| 4494 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4495 | hdd_err("kstrtou8 failed "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4496 | ret = -EINVAL; |
| 4497 | goto exit; |
| 4498 | } |
| 4499 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4500 | hdd_info("Received Command to Set roam scan control = %d", |
| 4501 | roamScanControl); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4502 | |
| 4503 | if (0 != roamScanControl) { |
| 4504 | ret = 0; /* return success but ignore param value "true" */ |
| 4505 | goto exit; |
| 4506 | } |
| 4507 | |
| 4508 | sme_set_roam_scan_control(hdd_ctx->hHal, |
| 4509 | adapter->sessionId, |
| 4510 | roamScanControl); |
| 4511 | |
| 4512 | exit: |
| 4513 | return ret; |
| 4514 | } |
| 4515 | |
| 4516 | static int drv_cmd_set_okc_mode(hdd_adapter_t *adapter, |
| 4517 | hdd_context_t *hdd_ctx, |
| 4518 | uint8_t *command, |
| 4519 | uint8_t command_len, |
| 4520 | hdd_priv_data_t *priv_data) |
| 4521 | { |
| 4522 | int ret = 0; |
| 4523 | uint8_t *value = command; |
| 4524 | uint8_t okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 4525 | |
| 4526 | /* |
| 4527 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 4528 | * then this operation is not permitted (return FAILURE) |
| 4529 | */ |
| 4530 | if (sme_get_is_ese_feature_enabled(hdd_ctx->hHal) && |
| 4531 | hdd_is_okc_mode_enabled(hdd_ctx) && |
| 4532 | sme_get_is_ft_feature_enabled(hdd_ctx->hHal)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4533 | hdd_warn("OKC/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4534 | ret = -EPERM; |
| 4535 | goto exit; |
| 4536 | } |
| 4537 | |
| 4538 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 4539 | value = value + command_len + 1; |
| 4540 | |
| 4541 | /* Convert the value from ascii to integer */ |
| 4542 | ret = kstrtou8(value, 10, &okcMode); |
| 4543 | if (ret < 0) { |
| 4544 | /* |
| 4545 | * If the input value is greater than max value of datatype, |
| 4546 | * then also kstrtou8 fails |
| 4547 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4548 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 4549 | CFG_OKC_FEATURE_ENABLED_MIN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4550 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 4551 | ret = -EINVAL; |
| 4552 | goto exit; |
| 4553 | } |
| 4554 | |
| 4555 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 4556 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4557 | hdd_err("Okc mode value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4558 | okcMode, |
| 4559 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 4560 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 4561 | ret = -EINVAL; |
| 4562 | goto exit; |
| 4563 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4564 | hdd_info("Received Command to change okc mode = %d", |
| 4565 | okcMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4566 | |
| 4567 | hdd_ctx->config->isOkcIniFeatureEnabled = okcMode; |
| 4568 | |
| 4569 | exit: |
| 4570 | return ret; |
| 4571 | } |
| 4572 | |
| 4573 | static int drv_cmd_get_roam_scan_control(hdd_adapter_t *adapter, |
| 4574 | hdd_context_t *hdd_ctx, |
| 4575 | uint8_t *command, |
| 4576 | uint8_t command_len, |
| 4577 | hdd_priv_data_t *priv_data) |
| 4578 | { |
| 4579 | int ret = 0; |
| 4580 | bool roamScanControl = sme_get_roam_scan_control(hdd_ctx->hHal); |
| 4581 | char extra[32]; |
| 4582 | uint8_t len = 0; |
| 4583 | |
| 4584 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4585 | command, roamScanControl); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4586 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4587 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4588 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4589 | ret = -EFAULT; |
| 4590 | } |
| 4591 | |
| 4592 | return ret; |
| 4593 | } |
| 4594 | |
| 4595 | static int drv_cmd_bt_coex_mode(hdd_adapter_t *adapter, |
| 4596 | hdd_context_t *hdd_ctx, |
| 4597 | uint8_t *command, |
| 4598 | uint8_t command_len, |
| 4599 | hdd_priv_data_t *priv_data) |
| 4600 | { |
| 4601 | int ret = 0; |
| 4602 | char *bcMode; |
| 4603 | |
| 4604 | bcMode = command + 11; |
| 4605 | if ('1' == *bcMode) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4606 | hdd_debug("BTCOEXMODE %d", *bcMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4607 | hdd_ctx->btCoexModeSet = true; |
| 4608 | ret = wlan_hdd_scan_abort(adapter); |
| 4609 | if (ret < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4610 | hdd_err("Failed to abort existing scan status: %d", |
| 4611 | ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4612 | } |
| 4613 | } else if ('2' == *bcMode) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4614 | hdd_debug("BTCOEXMODE %d", *bcMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4615 | hdd_ctx->btCoexModeSet = false; |
| 4616 | } |
| 4617 | |
| 4618 | return ret; |
| 4619 | } |
| 4620 | |
| 4621 | static int drv_cmd_scan_active(hdd_adapter_t *adapter, |
| 4622 | hdd_context_t *hdd_ctx, |
| 4623 | uint8_t *command, |
| 4624 | uint8_t command_len, |
| 4625 | hdd_priv_data_t *priv_data) |
| 4626 | { |
| 4627 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 4628 | return 0; |
| 4629 | } |
| 4630 | |
| 4631 | static int drv_cmd_scan_passive(hdd_adapter_t *adapter, |
| 4632 | hdd_context_t *hdd_ctx, |
| 4633 | uint8_t *command, |
| 4634 | uint8_t command_len, |
| 4635 | hdd_priv_data_t *priv_data) |
| 4636 | { |
| 4637 | hdd_ctx->ioctl_scan_mode = eSIR_PASSIVE_SCAN; |
| 4638 | return 0; |
| 4639 | } |
| 4640 | |
| 4641 | static int drv_cmd_get_dwell_time(hdd_adapter_t *adapter, |
| 4642 | hdd_context_t *hdd_ctx, |
| 4643 | uint8_t *command, |
| 4644 | uint8_t command_len, |
| 4645 | hdd_priv_data_t *priv_data) |
| 4646 | { |
| 4647 | int ret = 0; |
| 4648 | struct hdd_config *pCfg = |
| 4649 | (WLAN_HDD_GET_CTX(adapter))->config; |
| 4650 | char extra[32]; |
| 4651 | uint8_t len = 0; |
| 4652 | |
| 4653 | memset(extra, 0, sizeof(extra)); |
| 4654 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4655 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4656 | if (ret != 0 || copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4657 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4658 | ret = -EFAULT; |
| 4659 | goto exit; |
| 4660 | } |
| 4661 | ret = len; |
| 4662 | exit: |
| 4663 | return ret; |
| 4664 | } |
| 4665 | |
| 4666 | static int drv_cmd_set_dwell_time(hdd_adapter_t *adapter, |
| 4667 | hdd_context_t *hdd_ctx, |
| 4668 | uint8_t *command, |
| 4669 | uint8_t command_len, |
| 4670 | hdd_priv_data_t *priv_data) |
| 4671 | { |
| 4672 | return hdd_set_dwell_time(adapter, command); |
| 4673 | } |
| 4674 | |
| 4675 | static int drv_cmd_miracast(hdd_adapter_t *adapter, |
| 4676 | hdd_context_t *hdd_ctx, |
| 4677 | uint8_t *command, |
| 4678 | uint8_t command_len, |
| 4679 | hdd_priv_data_t *priv_data) |
| 4680 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4681 | QDF_STATUS ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4682 | int ret = 0; |
| 4683 | tHalHandle hHal; |
| 4684 | uint8_t filterType = 0; |
| 4685 | hdd_context_t *pHddCtx = NULL; |
| 4686 | uint8_t *value; |
| 4687 | |
| 4688 | pHddCtx = WLAN_HDD_GET_CTX(adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4689 | if (wlan_hdd_validate_context(pHddCtx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4690 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4691 | |
| 4692 | hHal = pHddCtx->hHal; |
| 4693 | value = command + 9; |
| 4694 | |
| 4695 | /* Convert the value from ascii to integer */ |
| 4696 | ret = kstrtou8(value, 10, &filterType); |
| 4697 | if (ret < 0) { |
| 4698 | /* |
| 4699 | * If the input value is greater than max value of datatype, |
| 4700 | * then also kstrtou8 fails |
| 4701 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4702 | hdd_err("kstrtou8 failed range "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4703 | ret = -EINVAL; |
| 4704 | goto exit; |
| 4705 | } |
| 4706 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL) |
| 4707 | || (filterType > |
| 4708 | WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4709 | hdd_err("Accepted Values are 0 to 2. 0-Disabled, 1-Source, 2-Sink "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | ret = -EINVAL; |
| 4711 | goto exit; |
| 4712 | } |
| 4713 | /* Filtertype value should be either 0-Disabled, 1-Source, 2-sink */ |
| 4714 | pHddCtx->miracast_value = filterType; |
| 4715 | |
| 4716 | ret_status = sme_set_miracast(hHal, filterType); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4717 | if (QDF_STATUS_SUCCESS != ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4718 | hdd_err("Failed to set miracast"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4719 | return -EBUSY; |
| 4720 | } |
| 4721 | |
Tushnim Bhattacharyya | ca50b32 | 2015-12-28 17:14:36 -0800 | [diff] [blame] | 4722 | if (cds_is_mcc_in_24G()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4723 | return cds_set_mas(adapter, filterType); |
| 4724 | |
| 4725 | exit: |
| 4726 | return ret; |
| 4727 | } |
| 4728 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4729 | /* Function header is left blank intentionally */ |
| 4730 | static int hdd_parse_set_ibss_oui_data_command(uint8_t *command, uint8_t *ie, |
| 4731 | int32_t *oui_length, int32_t limit) |
| 4732 | { |
| 4733 | uint8_t len; |
| 4734 | uint8_t data; |
| 4735 | |
| 4736 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 4737 | command++; |
| 4738 | limit--; |
| 4739 | } |
| 4740 | |
| 4741 | len = 2; |
| 4742 | |
| 4743 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 4744 | (limit > 1)) { |
| 4745 | sscanf(command, "%02x", (unsigned int *)&data); |
| 4746 | ie[len++] = data; |
| 4747 | command += 2; |
| 4748 | limit -= 2; |
| 4749 | } |
| 4750 | |
| 4751 | *oui_length = len - 2; |
| 4752 | |
| 4753 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 4754 | command++; |
| 4755 | limit--; |
| 4756 | } |
| 4757 | |
| 4758 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 4759 | (limit > 1)) { |
| 4760 | sscanf(command, "%02x", (unsigned int *)&data); |
| 4761 | ie[len++] = data; |
| 4762 | command += 2; |
| 4763 | limit -= 2; |
| 4764 | } |
| 4765 | |
| 4766 | ie[0] = IE_EID_VENDOR; |
| 4767 | ie[1] = len - 2; |
| 4768 | |
| 4769 | return len; |
| 4770 | } |
| 4771 | |
| 4772 | /** |
| 4773 | * drv_cmd_set_ibss_beacon_oui_data() - set ibss oui data command |
| 4774 | * @adapter: Pointer to adapter |
| 4775 | * @hdd_ctx: Pointer to HDD context |
| 4776 | * @command: Pointer to command string |
| 4777 | * @command_len : Command length |
| 4778 | * @priv_data : Pointer to priv data |
| 4779 | * |
| 4780 | * Return: |
| 4781 | * int status code |
| 4782 | */ |
| 4783 | static int drv_cmd_set_ibss_beacon_oui_data(hdd_adapter_t *adapter, |
| 4784 | hdd_context_t *hdd_ctx, |
| 4785 | uint8_t *command, |
| 4786 | uint8_t command_len, |
| 4787 | hdd_priv_data_t *priv_data) |
| 4788 | { |
| 4789 | int i = 0; |
| 4790 | int status; |
| 4791 | int ret = 0; |
| 4792 | uint8_t *ibss_ie; |
| 4793 | int32_t oui_length = 0; |
| 4794 | uint32_t ibss_ie_length; |
| 4795 | uint8_t *value = command; |
| 4796 | tSirModifyIE ibssModifyIE; |
| 4797 | tCsrRoamProfile *pRoamProfile; |
| 4798 | hdd_wext_state_t *pWextState; |
| 4799 | |
| 4800 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4801 | if (QDF_IBSS_MODE != adapter->device_mode) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4802 | hdd_info("Device_mode %s(%d) not IBSS", |
| 4803 | hdd_device_mode_to_string(adapter->device_mode), |
| 4804 | adapter->device_mode); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4805 | return ret; |
| 4806 | } |
| 4807 | |
| 4808 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 4809 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4810 | hdd_info("received command %s", ((char *)value)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4811 | |
| 4812 | |
| 4813 | /* validate argument of command */ |
| 4814 | if (strlen(value) <= command_len) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4815 | hdd_err("No arguments in command length %zu", |
| 4816 | strlen(value)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4817 | ret = -EFAULT; |
| 4818 | goto exit; |
| 4819 | } |
| 4820 | |
| 4821 | /* moving to arguments of commands */ |
| 4822 | value = value + command_len; |
| 4823 | command_len = strlen(value); |
| 4824 | |
| 4825 | /* oui_data can't be less than 3 bytes */ |
| 4826 | if (command_len < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4827 | hdd_err("Invalid SETIBSSBEACONOUIDATA command length %d", |
| 4828 | command_len); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4829 | ret = -EFAULT; |
| 4830 | goto exit; |
| 4831 | } |
| 4832 | |
| 4833 | ibss_ie = qdf_mem_malloc(command_len); |
| 4834 | if (!ibss_ie) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4835 | hdd_err("Could not allocate memory for command length %d", |
| 4836 | command_len); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4837 | ret = -ENOMEM; |
| 4838 | goto exit; |
| 4839 | } |
| 4840 | qdf_mem_zero(ibss_ie, command_len); |
| 4841 | |
| 4842 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 4843 | &oui_length, |
| 4844 | command_len); |
| 4845 | if (ibss_ie_length <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4846 | hdd_err("Could not parse command %s return length %d", |
| 4847 | value, ibss_ie_length); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4848 | ret = -EFAULT; |
| 4849 | qdf_mem_free(ibss_ie); |
| 4850 | goto exit; |
| 4851 | } |
| 4852 | |
| 4853 | pRoamProfile = &pWextState->roamProfile; |
| 4854 | |
| 4855 | qdf_copy_macaddr(&ibssModifyIE.bssid, |
| 4856 | pRoamProfile->BSSIDs.bssid); |
| 4857 | |
| 4858 | ibssModifyIE.smeSessionId = adapter->sessionId; |
| 4859 | ibssModifyIE.notify = true; |
| 4860 | ibssModifyIE.ieID = IE_EID_VENDOR; |
| 4861 | ibssModifyIE.ieIDLen = ibss_ie_length; |
| 4862 | ibssModifyIE.ieBufferlength = ibss_ie_length; |
| 4863 | ibssModifyIE.pIEBuffer = ibss_ie; |
| 4864 | ibssModifyIE.oui_length = oui_length; |
| 4865 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4866 | hdd_warn("ibss_ie length %d oui_length %d ibss_ie:", |
| 4867 | ibss_ie_length, oui_length); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4868 | while (i < ibssModifyIE.ieBufferlength) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4869 | hdd_warn("0x%x", ibss_ie[i++]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4870 | |
| 4871 | /* Probe Bcn modification */ |
| 4872 | sme_modify_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4873 | &ibssModifyIE, eUPDATE_IE_PROBE_BCN); |
| 4874 | |
| 4875 | /* Populating probe resp frame */ |
| 4876 | sme_modify_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4877 | &ibssModifyIE, eUPDATE_IE_PROBE_RESP); |
| 4878 | |
| 4879 | qdf_mem_free(ibss_ie); |
| 4880 | |
| 4881 | status = sme_send_cesium_enable_ind((tHalHandle)(hdd_ctx->hHal), |
| 4882 | adapter->sessionId); |
| 4883 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4884 | hdd_err("Could not send cesium enable indication %d", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4885 | status); |
| 4886 | ret = -EINVAL; |
| 4887 | goto exit; |
| 4888 | } |
| 4889 | |
| 4890 | exit: |
| 4891 | return ret; |
| 4892 | } |
| 4893 | |
| 4894 | static int drv_cmd_set_rmc_enable(hdd_adapter_t *adapter, |
| 4895 | hdd_context_t *hdd_ctx, |
| 4896 | uint8_t *command, |
| 4897 | uint8_t command_len, |
| 4898 | hdd_priv_data_t *priv_data) |
| 4899 | { |
| 4900 | int ret = 0; |
| 4901 | uint8_t *value = command; |
| 4902 | uint8_t ucRmcEnable = 0; |
| 4903 | int status; |
| 4904 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4905 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 4906 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4907 | hdd_err("Received SETRMCENABLE cmd in invalid mode %s(%d)", |
| 4908 | hdd_device_mode_to_string(adapter->device_mode), |
| 4909 | adapter->device_mode); |
| 4910 | hdd_err("SETRMCENABLE cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4911 | ret = -EINVAL; |
| 4912 | goto exit; |
| 4913 | } |
| 4914 | |
| 4915 | status = hdd_parse_setrmcenable_command(value, &ucRmcEnable); |
| 4916 | if (status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4917 | hdd_err("Invalid SETRMCENABLE command "); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4918 | ret = -EINVAL; |
| 4919 | goto exit; |
| 4920 | } |
| 4921 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4922 | hdd_info("ucRmcEnable %d ", ucRmcEnable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4923 | |
| 4924 | if (true == ucRmcEnable) { |
| 4925 | status = sme_enable_rmc((tHalHandle) |
| 4926 | (hdd_ctx->hHal), |
| 4927 | adapter->sessionId); |
| 4928 | } else if (false == ucRmcEnable) { |
| 4929 | status = sme_disable_rmc((tHalHandle) |
| 4930 | (hdd_ctx->hHal), |
| 4931 | adapter->sessionId); |
| 4932 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4933 | hdd_err("Invalid SETRMCENABLE command %d", |
| 4934 | ucRmcEnable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4935 | ret = -EINVAL; |
| 4936 | goto exit; |
| 4937 | } |
| 4938 | |
| 4939 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4940 | hdd_err("SETRMC %d failed status %d", |
| 4941 | ucRmcEnable, status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4942 | ret = -EINVAL; |
| 4943 | goto exit; |
| 4944 | } |
| 4945 | |
| 4946 | exit: |
| 4947 | return ret; |
| 4948 | } |
| 4949 | |
| 4950 | static int drv_cmd_set_rmc_action_period(hdd_adapter_t *adapter, |
| 4951 | hdd_context_t *hdd_ctx, |
| 4952 | uint8_t *command, |
| 4953 | uint8_t command_len, |
| 4954 | hdd_priv_data_t *priv_data) |
| 4955 | { |
| 4956 | int ret = 0; |
| 4957 | uint8_t *value = command; |
| 4958 | uint32_t uActionPeriod = 0; |
| 4959 | int status; |
| 4960 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4961 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 4962 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4963 | hdd_err("Received SETRMC cmd in invalid mode %s(%d)", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4964 | hdd_device_mode_to_string(adapter->device_mode), |
| 4965 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4966 | hdd_err("SETRMC cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4967 | ret = -EINVAL; |
| 4968 | goto exit; |
| 4969 | } |
| 4970 | |
| 4971 | status = hdd_parse_setrmcactionperiod_command(value, &uActionPeriod); |
| 4972 | if (status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4973 | hdd_err("Invalid SETRMCACTIONPERIOD command "); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4974 | ret = -EINVAL; |
| 4975 | goto exit; |
| 4976 | } |
| 4977 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4978 | hdd_info("uActionPeriod %d ", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4979 | uActionPeriod); |
| 4980 | |
| 4981 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 4982 | WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY, |
| 4983 | uActionPeriod)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4984 | hdd_err("Could not set SETRMCACTIONPERIOD %d", |
| 4985 | uActionPeriod); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4986 | ret = -EINVAL; |
| 4987 | goto exit; |
| 4988 | } |
| 4989 | |
| 4990 | status = sme_send_rmc_action_period((tHalHandle)(hdd_ctx->hHal), |
| 4991 | adapter->sessionId); |
| 4992 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4993 | hdd_err("Could not send cesium enable indication %d", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4994 | status); |
| 4995 | ret = -EINVAL; |
| 4996 | goto exit; |
| 4997 | } |
| 4998 | |
| 4999 | exit: |
| 5000 | return ret; |
| 5001 | } |
| 5002 | |
| 5003 | static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter, |
| 5004 | hdd_context_t *hdd_ctx, |
| 5005 | uint8_t *command, |
| 5006 | uint8_t command_len, |
| 5007 | hdd_priv_data_t *priv_data) |
| 5008 | { |
| 5009 | int ret = 0; |
| 5010 | int status = QDF_STATUS_SUCCESS; |
| 5011 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5012 | char *extra = NULL; |
| 5013 | int idx = 0; |
| 5014 | int length = 0; |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5015 | uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5016 | uint32_t numOfBytestoPrint = 0; |
| 5017 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5018 | if (QDF_IBSS_MODE != adapter->device_mode) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5019 | hdd_warn("Unsupported in mode %s(%d)", |
| 5020 | hdd_device_mode_to_string(adapter->device_mode), |
| 5021 | adapter->device_mode); |
| 5022 | return -EINVAL; |
| 5023 | } |
| 5024 | |
| 5025 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5026 | hdd_info("Received GETIBSSPEERINFOALL Command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5027 | |
| 5028 | /* Handle the command */ |
| 5029 | status = hdd_cfg80211_get_ibss_peer_info_all(adapter); |
| 5030 | if (QDF_STATUS_SUCCESS == status) { |
| 5031 | /* |
| 5032 | * The variable extra needed to be allocated on the heap since |
| 5033 | * amount of memory required to copy the data for 32 devices |
| 5034 | * exceeds the size of 1024 bytes of default stack size. On |
| 5035 | * 64 bit devices, the default max stack size of 2048 bytes |
| 5036 | */ |
| 5037 | extra = kmalloc(WLAN_MAX_BUF_SIZE, GFP_KERNEL); |
| 5038 | |
| 5039 | if (NULL == extra) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5040 | hdd_err("kmalloc failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5041 | ret = -EINVAL; |
| 5042 | goto exit; |
| 5043 | } |
| 5044 | |
| 5045 | /* Copy number of stations */ |
| 5046 | length = scnprintf(extra, WLAN_MAX_BUF_SIZE, "%d ", |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5047 | pHddStaCtx->ibss_peer_info.numPeers); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5048 | numOfBytestoPrint = length; |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5049 | for (idx = 0; idx < pHddStaCtx->ibss_peer_info.numPeers; |
| 5050 | idx++) { |
| 5051 | int8_t rssi; |
| 5052 | uint32_t tx_rate; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5053 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5054 | qdf_mem_copy(mac_addr, |
| 5055 | pHddStaCtx->ibss_peer_info.peerInfoParams[idx]. |
| 5056 | mac_addr, sizeof(mac_addr)); |
| 5057 | |
| 5058 | tx_rate = |
| 5059 | pHddStaCtx->ibss_peer_info.peerInfoParams[idx]. |
| 5060 | txRate; |
| 5061 | rssi = pHddStaCtx->ibss_peer_info.peerInfoParams[idx]. |
| 5062 | rssi; |
| 5063 | |
| 5064 | length += scnprintf((extra + length), |
| 5065 | WLAN_MAX_BUF_SIZE - length, |
| 5066 | "%02x:%02x:%02x:%02x:%02x:%02x %d %d ", |
| 5067 | mac_addr[0], mac_addr[1], mac_addr[2], |
| 5068 | mac_addr[3], mac_addr[4], mac_addr[5], |
| 5069 | tx_rate, rssi); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5070 | /* |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5071 | * cdf_trace_msg has limitation of 512 bytes for the |
| 5072 | * print buffer. Hence printing the data in two chunks. |
| 5073 | * The first chunk will have the data for 16 devices |
| 5074 | * and the second chunk will have the rest. |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5075 | */ |
| 5076 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
| 5077 | numOfBytestoPrint = length; |
| 5078 | } |
| 5079 | |
| 5080 | /* |
| 5081 | * Copy the data back into buffer, if the data to copy is |
| 5082 | * more than 512 bytes than we will split the data and do |
| 5083 | * it in two shots |
| 5084 | */ |
| 5085 | if (copy_to_user(priv_data->buf, extra, numOfBytestoPrint)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5086 | hdd_err("Copy into user data buffer failed "); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5087 | ret = -EFAULT; |
| 5088 | goto exit; |
| 5089 | } |
| 5090 | |
| 5091 | priv_data->buf[numOfBytestoPrint] = '\0'; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5092 | hdd_debug("%s", priv_data->buf); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5093 | |
| 5094 | if (length > numOfBytestoPrint) { |
| 5095 | if (copy_to_user |
| 5096 | (priv_data->buf + numOfBytestoPrint, |
| 5097 | extra + numOfBytestoPrint, |
| 5098 | length - numOfBytestoPrint + 1)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5099 | hdd_err("Copy into user data buffer failed "); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5100 | ret = -EFAULT; |
| 5101 | goto exit; |
| 5102 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5103 | hdd_debug("%s", &priv_data->buf[numOfBytestoPrint]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5104 | } |
| 5105 | |
| 5106 | /* Free temporary buffer */ |
| 5107 | kfree(extra); |
| 5108 | } else { |
| 5109 | /* Command failed, log error */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5110 | hdd_err("GETIBSSPEERINFOALL command failed with status code %d", |
| 5111 | status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5112 | ret = -EINVAL; |
| 5113 | goto exit; |
| 5114 | } |
| 5115 | ret = 0; |
| 5116 | |
| 5117 | exit: |
| 5118 | return ret; |
| 5119 | } |
| 5120 | |
| 5121 | /* Peer Info <Peer Addr> command */ |
| 5122 | static int drv_cmd_get_ibss_peer_info(hdd_adapter_t *adapter, |
| 5123 | hdd_context_t *hdd_ctx, |
| 5124 | uint8_t *command, |
| 5125 | uint8_t command_len, |
| 5126 | hdd_priv_data_t *priv_data) |
| 5127 | { |
| 5128 | int ret = 0; |
| 5129 | uint8_t *value = command; |
| 5130 | QDF_STATUS status; |
| 5131 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5132 | char extra[128] = { 0 }; |
| 5133 | uint32_t length = 0; |
| 5134 | uint8_t staIdx = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5135 | struct qdf_mac_addr peerMacAddr; |
| 5136 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5137 | if (QDF_IBSS_MODE != adapter->device_mode) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5138 | hdd_warn("Unsupported in mode %s(%d)", |
| 5139 | hdd_device_mode_to_string(adapter->device_mode), |
| 5140 | adapter->device_mode); |
| 5141 | return -EINVAL; |
| 5142 | } |
| 5143 | |
| 5144 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5145 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5146 | hdd_info("Received GETIBSSPEERINFO Command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5147 | |
| 5148 | /* if there are no peers, no need to continue with the command */ |
| 5149 | if (eConnectionState_IbssConnected != |
| 5150 | pHddStaCtx->conn_info.connState) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5151 | hdd_info("No IBSS Peers coalesced"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5152 | ret = -EINVAL; |
| 5153 | goto exit; |
| 5154 | } |
| 5155 | |
| 5156 | /* Parse the incoming command buffer */ |
| 5157 | status = hdd_parse_get_ibss_peer_info(value, &peerMacAddr); |
| 5158 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5159 | hdd_err("Invalid GETIBSSPEERINFO command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5160 | ret = -EINVAL; |
| 5161 | goto exit; |
| 5162 | } |
| 5163 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5164 | /* Get station index for the peer mac address and sanitize it */ |
Deepak Dhamdhere | 5872c8c | 2016-06-02 15:51:47 -0700 | [diff] [blame] | 5165 | hdd_get_peer_sta_id(pHddStaCtx, &peerMacAddr, &staIdx); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5166 | |
Naveen Rawat | c45d162 | 2016-07-05 12:20:09 -0700 | [diff] [blame] | 5167 | if (staIdx > MAX_PEERS) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5168 | hdd_err("Invalid StaIdx %d returned", staIdx); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5169 | ret = -EINVAL; |
| 5170 | goto exit; |
| 5171 | } |
| 5172 | |
| 5173 | /* Handle the command */ |
| 5174 | status = hdd_cfg80211_get_ibss_peer_info(adapter, staIdx); |
| 5175 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5176 | uint32_t txRate = |
| 5177 | pHddStaCtx->ibss_peer_info.peerInfoParams[0].txRate; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5178 | |
| 5179 | length = scnprintf(extra, sizeof(extra), "%d %d", |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5180 | (int)txRate, |
| 5181 | (int)pHddStaCtx->ibss_peer_info. |
| 5182 | peerInfoParams[0].rssi); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5183 | |
| 5184 | /* Copy the data back into buffer */ |
| 5185 | if (copy_to_user(priv_data->buf, &extra, length + 1)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5186 | hdd_err("copy data to user buffer failed GETIBSSPEERINFO command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5187 | ret = -EFAULT; |
| 5188 | goto exit; |
| 5189 | } |
| 5190 | } else { |
| 5191 | /* Command failed, log error */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5192 | hdd_err("GETIBSSPEERINFO command failed with status code %d", |
| 5193 | status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5194 | ret = -EINVAL; |
| 5195 | goto exit; |
| 5196 | } |
| 5197 | |
| 5198 | /* Success ! */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5199 | hdd_debug("%s", priv_data->buf); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5200 | ret = 0; |
| 5201 | |
| 5202 | exit: |
| 5203 | return ret; |
| 5204 | } |
| 5205 | |
| 5206 | static int drv_cmd_set_rmc_tx_rate(hdd_adapter_t *adapter, |
| 5207 | hdd_context_t *hdd_ctx, |
| 5208 | uint8_t *command, |
| 5209 | uint8_t command_len, |
| 5210 | hdd_priv_data_t *priv_data) |
| 5211 | { |
| 5212 | int ret = 0; |
| 5213 | uint8_t *value = command; |
| 5214 | uint32_t uRate = 0; |
| 5215 | tTxrateinfoflags txFlags = 0; |
| 5216 | tSirRateUpdateInd rateUpdateParams = {0}; |
| 5217 | int status; |
| 5218 | struct hdd_config *pConfig = hdd_ctx->config; |
| 5219 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5220 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5221 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5222 | hdd_err("Received SETRMCTXRATE cmd in invalid mode %s(%d)", |
| 5223 | hdd_device_mode_to_string(adapter->device_mode), |
| 5224 | adapter->device_mode); |
| 5225 | hdd_err("SETRMCTXRATE cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5226 | ret = -EINVAL; |
| 5227 | goto exit; |
| 5228 | } |
| 5229 | |
| 5230 | status = hdd_parse_setrmcrate_command(value, &uRate, &txFlags); |
| 5231 | if (status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5232 | hdd_err("Invalid SETRMCTXRATE command "); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5233 | ret = -EINVAL; |
| 5234 | goto exit; |
| 5235 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5236 | hdd_info("uRate %d ", uRate); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5237 | /* -1 implies ignore this param */ |
| 5238 | rateUpdateParams.ucastDataRate = -1; |
| 5239 | |
| 5240 | /* |
| 5241 | * Fill the user specifieed RMC rate param |
| 5242 | * and the derived tx flags. |
| 5243 | */ |
| 5244 | rateUpdateParams.nss = (pConfig->enable2x2 == 0) ? 0 : 1; |
| 5245 | rateUpdateParams.reliableMcastDataRate = uRate; |
| 5246 | rateUpdateParams.reliableMcastDataRateTxFlag = txFlags; |
| 5247 | rateUpdateParams.dev_mode = adapter->device_mode; |
| 5248 | rateUpdateParams.bcastDataRate = -1; |
| 5249 | memcpy(rateUpdateParams.bssid.bytes, |
| 5250 | adapter->macAddressCurrent.bytes, |
| 5251 | sizeof(rateUpdateParams.bssid)); |
| 5252 | status = sme_send_rate_update_ind((tHalHandle) (hdd_ctx->hHal), |
| 5253 | &rateUpdateParams); |
| 5254 | |
| 5255 | exit: |
| 5256 | return ret; |
| 5257 | } |
| 5258 | |
| 5259 | static int drv_cmd_set_ibss_tx_fail_event(hdd_adapter_t *adapter, |
| 5260 | hdd_context_t *hdd_ctx, |
| 5261 | uint8_t *command, |
| 5262 | uint8_t command_len, |
| 5263 | hdd_priv_data_t *priv_data) |
| 5264 | { |
| 5265 | int ret = 0; |
| 5266 | char *value; |
| 5267 | uint8_t tx_fail_count = 0; |
| 5268 | uint16_t pid = 0; |
| 5269 | |
| 5270 | value = command; |
| 5271 | |
| 5272 | ret = hdd_parse_ibsstx_fail_event_params(value, &tx_fail_count, &pid); |
| 5273 | |
| 5274 | if (0 != ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5275 | hdd_info("Failed to parse SETIBSSTXFAILEVENT arguments"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5276 | goto exit; |
| 5277 | } |
| 5278 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5279 | hdd_info("tx_fail_cnt=%hhu, pid=%hu", tx_fail_count, pid); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5280 | |
| 5281 | if (0 == tx_fail_count) { |
| 5282 | /* Disable TX Fail Indication */ |
| 5283 | if (QDF_STATUS_SUCCESS == |
| 5284 | sme_tx_fail_monitor_start_stop_ind(hdd_ctx->hHal, |
| 5285 | tx_fail_count, |
| 5286 | NULL)) { |
| 5287 | cesium_pid = 0; |
| 5288 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5289 | hdd_err("failed to disable TX Fail Event "); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5290 | ret = -EINVAL; |
| 5291 | } |
| 5292 | } else { |
| 5293 | if (QDF_STATUS_SUCCESS == |
| 5294 | sme_tx_fail_monitor_start_stop_ind(hdd_ctx->hHal, |
| 5295 | tx_fail_count, |
| 5296 | (void *)hdd_tx_fail_ind_callback)) { |
| 5297 | cesium_pid = pid; |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5298 | hdd_info("Registered Cesium pid %u", |
| 5299 | cesium_pid); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5300 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5301 | hdd_err("Failed to enable TX Fail Monitoring"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5302 | ret = -EINVAL; |
| 5303 | } |
| 5304 | } |
| 5305 | |
| 5306 | exit: |
| 5307 | return ret; |
| 5308 | } |
| 5309 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5310 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5311 | static int drv_cmd_set_ccx_roam_scan_channels(hdd_adapter_t *adapter, |
| 5312 | hdd_context_t *hdd_ctx, |
| 5313 | uint8_t *command, |
| 5314 | uint8_t command_len, |
| 5315 | hdd_priv_data_t *priv_data) |
| 5316 | { |
| 5317 | int ret = 0; |
| 5318 | uint8_t *value = command; |
| 5319 | uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
| 5320 | uint8_t numChannels = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5321 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5322 | |
| 5323 | ret = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 5324 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5325 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5326 | goto exit; |
| 5327 | } |
| 5328 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5329 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5330 | numChannels, |
| 5331 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 5332 | ret = -EINVAL; |
| 5333 | goto exit; |
| 5334 | } |
| 5335 | status = sme_set_ese_roam_scan_channel_list(hdd_ctx->hHal, |
| 5336 | adapter->sessionId, |
| 5337 | ChannelList, |
| 5338 | numChannels); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5339 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5340 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5341 | ret = -EINVAL; |
| 5342 | goto exit; |
| 5343 | } |
| 5344 | |
| 5345 | exit: |
| 5346 | return ret; |
| 5347 | } |
| 5348 | |
| 5349 | static int drv_cmd_get_tsm_stats(hdd_adapter_t *adapter, |
| 5350 | hdd_context_t *hdd_ctx, |
| 5351 | uint8_t *command, |
| 5352 | uint8_t command_len, |
| 5353 | hdd_priv_data_t *priv_data) |
| 5354 | { |
| 5355 | int ret = 0; |
| 5356 | uint8_t *value = command; |
| 5357 | char extra[128] = { 0 }; |
| 5358 | int len = 0; |
| 5359 | uint8_t tid = 0; |
| 5360 | hdd_station_ctx_t *pHddStaCtx; |
| 5361 | tAniTrafStrmMetrics tsm_metrics; |
| 5362 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5363 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 5364 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5365 | hdd_warn("Unsupported in mode %s(%d)", |
| 5366 | hdd_device_mode_to_string(adapter->device_mode), |
| 5367 | adapter->device_mode); |
| 5368 | return -EINVAL; |
| 5369 | } |
| 5370 | |
| 5371 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5372 | |
| 5373 | /* if not associated, return error */ |
| 5374 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5375 | hdd_err("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5376 | ret = -EINVAL; |
| 5377 | goto exit; |
| 5378 | } |
| 5379 | |
| 5380 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 5381 | value = value + command_len + 1; |
| 5382 | |
| 5383 | /* Convert the value from ascii to integer */ |
| 5384 | ret = kstrtou8(value, 10, &tid); |
| 5385 | if (ret < 0) { |
| 5386 | /* |
| 5387 | * If the input value is greater than max value of datatype, |
| 5388 | * then also kstrtou8 fails |
| 5389 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5390 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 5391 | TID_MIN_VALUE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5392 | TID_MAX_VALUE); |
| 5393 | ret = -EINVAL; |
| 5394 | goto exit; |
| 5395 | } |
| 5396 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5397 | hdd_err("tid value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5398 | tid, TID_MIN_VALUE, TID_MAX_VALUE); |
| 5399 | ret = -EINVAL; |
| 5400 | goto exit; |
| 5401 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5402 | hdd_info("Received Command to get tsm stats tid = %d", |
| 5403 | tid); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5404 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5405 | hdd_get_tsm_stats(adapter, tid, &tsm_metrics)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5406 | hdd_err("failed to get tsm stats"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5407 | ret = -EFAULT; |
| 5408 | goto exit; |
| 5409 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5410 | hdd_info( |
| 5411 | "UplinkPktQueueDly(%d) UplinkPktQueueDlyHist[0](%d) UplinkPktQueueDlyHist[1](%d) UplinkPktQueueDlyHist[2](%d) UplinkPktQueueDlyHist[3](%d) UplinkPktTxDly(%u) UplinkPktLoss(%d) UplinkPktCount(%d) RoamingCount(%d) RoamingDly(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5412 | tsm_metrics.UplinkPktQueueDly, |
| 5413 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5414 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5415 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5416 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5417 | tsm_metrics.UplinkPktTxDly, |
| 5418 | tsm_metrics.UplinkPktLoss, |
| 5419 | tsm_metrics.UplinkPktCount, |
| 5420 | tsm_metrics.RoamingCount, |
| 5421 | tsm_metrics.RoamingDly); |
| 5422 | /* |
| 5423 | * Output TSM stats is of the format |
| 5424 | * GETTSMSTATS [PktQueueDly] |
| 5425 | * [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 5426 | * eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 |
| 5427 | */ |
| 5428 | len = scnprintf(extra, |
| 5429 | sizeof(extra), |
| 5430 | "%s %d %d:%d:%d:%d %u %d %d %d %d", |
| 5431 | command, |
| 5432 | tsm_metrics.UplinkPktQueueDly, |
| 5433 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5434 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5435 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5436 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5437 | tsm_metrics.UplinkPktTxDly, |
| 5438 | tsm_metrics.UplinkPktLoss, |
| 5439 | tsm_metrics.UplinkPktCount, |
| 5440 | tsm_metrics.RoamingCount, |
| 5441 | tsm_metrics.RoamingDly); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5442 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5443 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5444 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5445 | ret = -EFAULT; |
| 5446 | goto exit; |
| 5447 | } |
| 5448 | |
| 5449 | exit: |
| 5450 | return ret; |
| 5451 | } |
| 5452 | |
| 5453 | static int drv_cmd_set_cckm_ie(hdd_adapter_t *adapter, |
| 5454 | hdd_context_t *hdd_ctx, |
| 5455 | uint8_t *command, |
| 5456 | uint8_t command_len, |
| 5457 | hdd_priv_data_t *priv_data) |
| 5458 | { |
| 5459 | int ret; |
| 5460 | uint8_t *value = command; |
| 5461 | uint8_t *cckmIe = NULL; |
| 5462 | uint8_t cckmIeLen = 0; |
| 5463 | |
| 5464 | ret = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 5465 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5466 | hdd_err("Failed to parse cckm ie data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5467 | goto exit; |
| 5468 | } |
| 5469 | |
| 5470 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5471 | hdd_err("CCKM Ie input length is more than max[%d]", |
| 5472 | DOT11F_IE_RSN_MAX_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5473 | if (NULL != cckmIe) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5474 | qdf_mem_free(cckmIe); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5475 | cckmIe = NULL; |
| 5476 | } |
| 5477 | ret = -EINVAL; |
| 5478 | goto exit; |
| 5479 | } |
| 5480 | |
| 5481 | sme_set_cckm_ie(hdd_ctx->hHal, adapter->sessionId, |
| 5482 | cckmIe, cckmIeLen); |
| 5483 | if (NULL != cckmIe) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5484 | qdf_mem_free(cckmIe); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5485 | cckmIe = NULL; |
| 5486 | } |
| 5487 | |
| 5488 | exit: |
| 5489 | return ret; |
| 5490 | } |
| 5491 | |
| 5492 | static int drv_cmd_ccx_beacon_req(hdd_adapter_t *adapter, |
| 5493 | hdd_context_t *hdd_ctx, |
| 5494 | uint8_t *command, |
| 5495 | uint8_t command_len, |
| 5496 | hdd_priv_data_t *priv_data) |
| 5497 | { |
| 5498 | int ret; |
| 5499 | uint8_t *value = command; |
| 5500 | tCsrEseBeaconReq eseBcnReq; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5501 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5502 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5503 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5504 | hdd_warn("Unsupported in mode %s(%d)", |
| 5505 | hdd_device_mode_to_string(adapter->device_mode), |
| 5506 | adapter->device_mode); |
| 5507 | return -EINVAL; |
| 5508 | } |
| 5509 | |
| 5510 | ret = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
| 5511 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5512 | hdd_err("Failed to parse ese beacon req"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5513 | goto exit; |
| 5514 | } |
| 5515 | |
| 5516 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5517 | hdd_info("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5518 | hdd_indicate_ese_bcn_report_no_results(adapter, |
| 5519 | eseBcnReq.bcnReq[0].measurementToken, |
| 5520 | 0x02, /* BIT(1) set for measurement done */ |
| 5521 | 0); /* no BSS */ |
| 5522 | goto exit; |
| 5523 | } |
| 5524 | |
| 5525 | status = sme_set_ese_beacon_request(hdd_ctx->hHal, |
| 5526 | adapter->sessionId, |
| 5527 | &eseBcnReq); |
| 5528 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5529 | if (QDF_STATUS_E_RESOURCES == status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5530 | hdd_info("sme_set_ese_beacon_request failed (%d), a request already in progress", |
| 5531 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5532 | ret = -EBUSY; |
| 5533 | goto exit; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5534 | } else if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5535 | hdd_err("sme_set_ese_beacon_request failed (%d)", |
| 5536 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5537 | ret = -EINVAL; |
| 5538 | goto exit; |
| 5539 | } |
| 5540 | |
| 5541 | exit: |
| 5542 | return ret; |
| 5543 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5544 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5545 | |
| 5546 | static int drv_cmd_set_mc_rate(hdd_adapter_t *adapter, |
| 5547 | hdd_context_t *hdd_ctx, |
| 5548 | uint8_t *command, |
| 5549 | uint8_t command_len, |
| 5550 | hdd_priv_data_t *priv_data) |
| 5551 | { |
| 5552 | int ret = 0; |
| 5553 | uint8_t *value = command; |
| 5554 | int targetRate; |
| 5555 | |
| 5556 | /* input value is in units of hundred kbps */ |
| 5557 | |
| 5558 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 5559 | value = value + command_len + 1; |
| 5560 | |
| 5561 | /* Convert the value from ascii to integer, decimal base */ |
| 5562 | ret = kstrtouint(value, 10, &targetRate); |
| 5563 | |
| 5564 | ret = wlan_hdd_set_mc_rate(adapter, targetRate); |
| 5565 | return ret; |
| 5566 | } |
| 5567 | |
| 5568 | static int drv_cmd_max_tx_power(hdd_adapter_t *adapter, |
| 5569 | hdd_context_t *hdd_ctx, |
| 5570 | uint8_t *command, |
| 5571 | uint8_t command_len, |
| 5572 | hdd_priv_data_t *priv_data) |
| 5573 | { |
| 5574 | int ret = 0; |
| 5575 | int status; |
| 5576 | int txPower; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5577 | QDF_STATUS qdf_status; |
| 5578 | QDF_STATUS smeStatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5579 | uint8_t *value = command; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5580 | struct qdf_mac_addr bssid = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
| 5581 | struct qdf_mac_addr selfMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5582 | hdd_adapter_list_node_t *pAdapterNode = NULL; |
| 5583 | hdd_adapter_list_node_t *pNext = NULL; |
| 5584 | |
| 5585 | status = hdd_parse_setmaxtxpower_command(value, &txPower); |
| 5586 | if (status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5587 | hdd_err("Invalid MAXTXPOWER command "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5588 | ret = -EINVAL; |
| 5589 | goto exit; |
| 5590 | } |
| 5591 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5592 | qdf_status = hdd_get_front_adapter(hdd_ctx, &pAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5593 | while (NULL != pAdapterNode |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5594 | && QDF_STATUS_SUCCESS == qdf_status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5595 | adapter = pAdapterNode->pAdapter; |
| 5596 | /* Assign correct self MAC address */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5597 | qdf_copy_macaddr(&bssid, |
Srinivas Girigowda | 9721523 | 2015-09-24 12:26:28 -0700 | [diff] [blame] | 5598 | &adapter->macAddressCurrent); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5599 | qdf_copy_macaddr(&selfMac, |
Srinivas Girigowda | 9721523 | 2015-09-24 12:26:28 -0700 | [diff] [blame] | 5600 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5601 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5602 | hdd_info("Device mode %d max tx power %d selfMac: " |
| 5603 | MAC_ADDRESS_STR " bssId: " MAC_ADDRESS_STR " ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5604 | adapter->device_mode, txPower, |
Srinivas Girigowda | 9721523 | 2015-09-24 12:26:28 -0700 | [diff] [blame] | 5605 | MAC_ADDR_ARRAY(selfMac.bytes), |
| 5606 | MAC_ADDR_ARRAY(bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5607 | |
Srinivas Girigowda | 9721523 | 2015-09-24 12:26:28 -0700 | [diff] [blame] | 5608 | smeStatus = sme_set_max_tx_power(hdd_ctx->hHal, |
| 5609 | bssid, selfMac, txPower); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5610 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5611 | hdd_err("Set max tx power failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5612 | ret = -EINVAL; |
| 5613 | goto exit; |
| 5614 | } |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5615 | hdd_info("Set max tx power success"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5616 | qdf_status = hdd_get_next_adapter(hdd_ctx, pAdapterNode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5617 | &pNext); |
| 5618 | pAdapterNode = pNext; |
| 5619 | } |
| 5620 | |
| 5621 | exit: |
| 5622 | return ret; |
| 5623 | } |
| 5624 | |
| 5625 | static int drv_cmd_set_dfs_scan_mode(hdd_adapter_t *adapter, |
| 5626 | hdd_context_t *hdd_ctx, |
| 5627 | uint8_t *command, |
| 5628 | uint8_t command_len, |
| 5629 | hdd_priv_data_t *priv_data) |
| 5630 | { |
| 5631 | int ret = 0; |
| 5632 | uint8_t *value = command; |
| 5633 | uint8_t dfsScanMode = CFG_ROAMING_DFS_CHANNEL_DEFAULT; |
| 5634 | |
| 5635 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 5636 | value = value + command_len + 1; |
| 5637 | |
| 5638 | /* Convert the value from ascii to integer */ |
| 5639 | ret = kstrtou8(value, 10, &dfsScanMode); |
| 5640 | if (ret < 0) { |
| 5641 | /* |
| 5642 | * If the input value is greater than max value of datatype, |
| 5643 | * then also kstrtou8 fails |
| 5644 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5645 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 5646 | CFG_ROAMING_DFS_CHANNEL_MIN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5647 | CFG_ROAMING_DFS_CHANNEL_MAX); |
| 5648 | ret = -EINVAL; |
| 5649 | goto exit; |
| 5650 | } |
| 5651 | |
| 5652 | if ((dfsScanMode < CFG_ROAMING_DFS_CHANNEL_MIN) || |
| 5653 | (dfsScanMode > CFG_ROAMING_DFS_CHANNEL_MAX)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5654 | hdd_err("dfsScanMode value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5655 | dfsScanMode, |
| 5656 | CFG_ROAMING_DFS_CHANNEL_MIN, |
| 5657 | CFG_ROAMING_DFS_CHANNEL_MAX); |
| 5658 | ret = -EINVAL; |
| 5659 | goto exit; |
| 5660 | } |
| 5661 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5662 | hdd_info("Received Command to Set DFS Scan Mode = %d", |
| 5663 | dfsScanMode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5664 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 5665 | /* When DFS scanning is disabled, the DFS channels need to be |
| 5666 | * removed from the operation of device. |
| 5667 | */ |
| 5668 | ret = wlan_hdd_disable_dfs_chan_scan(hdd_ctx, adapter, |
| 5669 | (dfsScanMode == CFG_ROAMING_DFS_CHANNEL_DISABLED)); |
| 5670 | if (ret < 0) { |
| 5671 | /* Some conditions prevented it from disabling DFS channels */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5672 | hdd_err("disable/enable DFS channel request was denied"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 5673 | goto exit; |
| 5674 | } |
| 5675 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5676 | hdd_ctx->config->allowDFSChannelRoam = dfsScanMode; |
| 5677 | sme_update_dfs_scan_mode(hdd_ctx->hHal, adapter->sessionId, |
| 5678 | dfsScanMode); |
| 5679 | |
| 5680 | exit: |
| 5681 | return ret; |
| 5682 | } |
| 5683 | |
| 5684 | static int drv_cmd_get_dfs_scan_mode(hdd_adapter_t *adapter, |
| 5685 | hdd_context_t *hdd_ctx, |
| 5686 | uint8_t *command, |
| 5687 | uint8_t command_len, |
| 5688 | hdd_priv_data_t *priv_data) |
| 5689 | { |
| 5690 | int ret = 0; |
| 5691 | uint8_t dfsScanMode = sme_get_dfs_scan_mode(hdd_ctx->hHal); |
| 5692 | char extra[32]; |
| 5693 | uint8_t len = 0; |
| 5694 | |
| 5695 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5696 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5697 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5698 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5699 | ret = -EFAULT; |
| 5700 | } |
| 5701 | |
| 5702 | return ret; |
| 5703 | } |
| 5704 | |
| 5705 | static int drv_cmd_get_link_status(hdd_adapter_t *adapter, |
| 5706 | hdd_context_t *hdd_ctx, |
| 5707 | uint8_t *command, |
| 5708 | uint8_t command_len, |
| 5709 | hdd_priv_data_t *priv_data) |
| 5710 | { |
| 5711 | int ret = 0; |
| 5712 | int value = wlan_hdd_get_link_status(adapter); |
| 5713 | char extra[32]; |
| 5714 | uint8_t len; |
| 5715 | |
| 5716 | len = scnprintf(extra, sizeof(extra), "%s %d", command, value); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5717 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5718 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5719 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5720 | ret = -EFAULT; |
| 5721 | } |
| 5722 | |
| 5723 | return ret; |
| 5724 | } |
| 5725 | |
| 5726 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 5727 | static int drv_cmd_enable_ext_wow(hdd_adapter_t *adapter, |
| 5728 | hdd_context_t *hdd_ctx, |
| 5729 | uint8_t *command, |
| 5730 | uint8_t command_len, |
| 5731 | hdd_priv_data_t *priv_data) |
| 5732 | { |
| 5733 | uint8_t *value = command; |
| 5734 | int set_value; |
| 5735 | |
| 5736 | /* Move pointer to ahead of ENABLEEXTWOW */ |
| 5737 | value = value + command_len; |
| 5738 | |
| 5739 | sscanf(value, "%d", &set_value); |
| 5740 | |
| 5741 | return hdd_enable_ext_wow_parser(adapter, |
| 5742 | adapter->sessionId, |
| 5743 | set_value); |
| 5744 | } |
| 5745 | |
| 5746 | static int drv_cmd_set_app1_params(hdd_adapter_t *adapter, |
| 5747 | hdd_context_t *hdd_ctx, |
| 5748 | uint8_t *command, |
| 5749 | uint8_t command_len, |
| 5750 | hdd_priv_data_t *priv_data) |
| 5751 | { |
| 5752 | int ret; |
| 5753 | uint8_t *value = command; |
| 5754 | |
| 5755 | /* Move pointer to ahead of SETAPP1PARAMS */ |
| 5756 | value = value + command_len; |
| 5757 | |
| 5758 | ret = hdd_set_app_type1_parser(adapter, |
| 5759 | value, strlen(value)); |
| 5760 | if (ret >= 0) |
| 5761 | hdd_ctx->is_extwow_app_type1_param_set = true; |
| 5762 | |
| 5763 | return ret; |
| 5764 | } |
| 5765 | |
| 5766 | static int drv_cmd_set_app2_params(hdd_adapter_t *adapter, |
| 5767 | hdd_context_t *hdd_ctx, |
| 5768 | uint8_t *command, |
| 5769 | uint8_t command_len, |
| 5770 | hdd_priv_data_t *priv_data) |
| 5771 | { |
| 5772 | int ret; |
| 5773 | uint8_t *value = command; |
| 5774 | |
| 5775 | /* Move pointer to ahead of SETAPP2PARAMS */ |
| 5776 | value = value + command_len; |
| 5777 | |
| 5778 | ret = hdd_set_app_type2_parser(adapter, value, strlen(value)); |
| 5779 | if (ret >= 0) |
| 5780 | hdd_ctx->is_extwow_app_type2_param_set = true; |
| 5781 | |
| 5782 | return ret; |
| 5783 | } |
| 5784 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 5785 | |
| 5786 | #ifdef FEATURE_WLAN_TDLS |
| 5787 | /** |
| 5788 | * drv_cmd_tdls_secondary_channel_offset() - secondary tdls off channel offset |
| 5789 | * @adapter: Pointer to the HDD adapter |
| 5790 | * @hdd_ctx: Pointer to the HDD context |
| 5791 | * @command: Driver command string |
| 5792 | * @command_len: Driver command string length |
| 5793 | * @priv_data: Private data coming with the driver command. Unused here |
| 5794 | * |
| 5795 | * This function handles driver command that sets the secondary tdls off channel |
| 5796 | * offset |
| 5797 | * |
| 5798 | * Return: 0 on success; negative errno otherwise |
| 5799 | */ |
| 5800 | static int drv_cmd_tdls_secondary_channel_offset(hdd_adapter_t *adapter, |
| 5801 | hdd_context_t *hdd_ctx, |
| 5802 | uint8_t *command, |
| 5803 | uint8_t command_len, |
| 5804 | hdd_priv_data_t *priv_data) |
| 5805 | { |
| 5806 | int ret; |
| 5807 | uint8_t *value = command; |
| 5808 | int set_value; |
| 5809 | |
| 5810 | /* Move pointer to point the string */ |
| 5811 | value += command_len; |
| 5812 | |
| 5813 | ret = sscanf(value, "%d", &set_value); |
| 5814 | if (ret != 1) |
| 5815 | return -EINVAL; |
| 5816 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5817 | hdd_info("Tdls offchannel offset:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5818 | |
| 5819 | ret = hdd_set_tdls_secoffchanneloffset(hdd_ctx, set_value); |
| 5820 | |
| 5821 | return ret; |
| 5822 | } |
| 5823 | |
| 5824 | /** |
| 5825 | * drv_cmd_tdls_off_channel_mode() - set tdls off channel mode |
| 5826 | * @adapter: Pointer to the HDD adapter |
| 5827 | * @hdd_ctx: Pointer to the HDD context |
| 5828 | * @command: Driver command string |
| 5829 | * @command_len: Driver command string length |
| 5830 | * @priv_data: Private data coming with the driver command. Unused here |
| 5831 | * |
| 5832 | * This function handles driver command that sets tdls off channel mode |
| 5833 | * |
| 5834 | * Return: 0 on success; negative errno otherwise |
| 5835 | */ |
| 5836 | static int drv_cmd_tdls_off_channel_mode(hdd_adapter_t *adapter, |
| 5837 | hdd_context_t *hdd_ctx, |
| 5838 | uint8_t *command, |
| 5839 | uint8_t command_len, |
| 5840 | hdd_priv_data_t *priv_data) |
| 5841 | { |
| 5842 | int ret; |
| 5843 | uint8_t *value = command; |
| 5844 | int set_value; |
| 5845 | |
| 5846 | /* Move pointer to point the string */ |
| 5847 | value += command_len; |
| 5848 | |
| 5849 | ret = sscanf(value, "%d", &set_value); |
| 5850 | if (ret != 1) |
| 5851 | return -EINVAL; |
| 5852 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5853 | hdd_info("Tdls offchannel mode:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5854 | |
| 5855 | ret = hdd_set_tdls_offchannelmode(adapter, set_value); |
| 5856 | |
| 5857 | return ret; |
| 5858 | } |
| 5859 | |
| 5860 | /** |
| 5861 | * drv_cmd_tdls_off_channel() - set tdls off channel number |
| 5862 | * @adapter: Pointer to the HDD adapter |
| 5863 | * @hdd_ctx: Pointer to the HDD context |
| 5864 | * @command: Driver command string |
| 5865 | * @command_len: Driver command string length |
| 5866 | * @priv_data: Private data coming with the driver command. Unused here |
| 5867 | * |
| 5868 | * This function handles driver command that sets tdls off channel number |
| 5869 | * |
| 5870 | * Return: 0 on success; negative errno otherwise |
| 5871 | */ |
| 5872 | static int drv_cmd_tdls_off_channel(hdd_adapter_t *adapter, |
| 5873 | hdd_context_t *hdd_ctx, |
| 5874 | uint8_t *command, |
| 5875 | uint8_t command_len, |
| 5876 | hdd_priv_data_t *priv_data) |
| 5877 | { |
| 5878 | int ret; |
| 5879 | uint8_t *value = command; |
| 5880 | int set_value; |
| 5881 | |
| 5882 | /* Move pointer to point the string */ |
| 5883 | value += command_len; |
| 5884 | |
| 5885 | ret = sscanf(value, "%d", &set_value); |
| 5886 | if (ret != 1) |
| 5887 | return -EINVAL; |
| 5888 | |
Krishna Kumaar Natarajan | 4d09035 | 2015-10-26 18:30:53 -0700 | [diff] [blame] | 5889 | if (CDS_IS_DFS_CH(set_value)) { |
| 5890 | hdd_err("DFS channel %d is passed for hdd_set_tdls_offchannel", |
| 5891 | set_value); |
| 5892 | return -EINVAL; |
| 5893 | } |
| 5894 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5895 | hdd_info("Tdls offchannel num: %d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5896 | |
| 5897 | ret = hdd_set_tdls_offchannel(hdd_ctx, set_value); |
| 5898 | |
| 5899 | return ret; |
| 5900 | } |
| 5901 | |
| 5902 | /** |
| 5903 | * drv_cmd_tdls_scan() - set tdls scan type |
| 5904 | * @adapter: Pointer to the HDD adapter |
| 5905 | * @hdd_ctx: Pointer to the HDD context |
| 5906 | * @command: Driver command string |
| 5907 | * @command_len: Driver command string length |
| 5908 | * @priv_data: Private data coming with the driver command. Unused here |
| 5909 | * |
| 5910 | * This function handles driver command that sets tdls scan type |
| 5911 | * |
| 5912 | * Return: 0 on success; negative errno otherwise |
| 5913 | */ |
| 5914 | static int drv_cmd_tdls_scan(hdd_adapter_t *adapter, |
| 5915 | hdd_context_t *hdd_ctx, |
| 5916 | uint8_t *command, |
| 5917 | uint8_t command_len, |
| 5918 | hdd_priv_data_t *priv_data) |
| 5919 | { |
| 5920 | int ret; |
| 5921 | uint8_t *value = command; |
| 5922 | int set_value; |
| 5923 | |
| 5924 | /* Move pointer to point the string */ |
| 5925 | value += command_len; |
| 5926 | |
| 5927 | ret = sscanf(value, "%d", &set_value); |
| 5928 | if (ret != 1) |
| 5929 | return -EINVAL; |
| 5930 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5931 | hdd_info("Tdls scan type val: %d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5932 | |
| 5933 | ret = hdd_set_tdls_scan_type(hdd_ctx, set_value); |
| 5934 | |
| 5935 | return ret; |
| 5936 | } |
| 5937 | #endif |
| 5938 | |
| 5939 | static int drv_cmd_get_rssi(hdd_adapter_t *adapter, |
| 5940 | hdd_context_t *hdd_ctx, |
| 5941 | uint8_t *command, |
| 5942 | uint8_t command_len, |
| 5943 | hdd_priv_data_t *priv_data) |
| 5944 | { |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 5945 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5946 | int8_t rssi = 0; |
| 5947 | char extra[32]; |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 5948 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5949 | uint8_t len = 0; |
| 5950 | |
| 5951 | wlan_hdd_get_rssi(adapter, &rssi); |
| 5952 | |
| 5953 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5954 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5955 | |
| 5956 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5957 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5958 | ret = -EFAULT; |
| 5959 | } |
| 5960 | |
| 5961 | return ret; |
| 5962 | } |
| 5963 | |
| 5964 | static int drv_cmd_get_linkspeed(hdd_adapter_t *adapter, |
| 5965 | hdd_context_t *hdd_ctx, |
| 5966 | uint8_t *command, |
| 5967 | uint8_t command_len, |
| 5968 | hdd_priv_data_t *priv_data) |
| 5969 | { |
| 5970 | int ret; |
| 5971 | uint32_t link_speed = 0; |
| 5972 | char extra[32]; |
| 5973 | uint8_t len = 0; |
| 5974 | |
| 5975 | ret = wlan_hdd_get_link_speed(adapter, &link_speed); |
| 5976 | if (0 != ret) |
| 5977 | return ret; |
| 5978 | |
| 5979 | len = scnprintf(extra, sizeof(extra), "%s %d", command, link_speed); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5980 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5981 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5982 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5983 | ret = -EFAULT; |
| 5984 | } |
| 5985 | |
| 5986 | return ret; |
| 5987 | } |
| 5988 | |
| 5989 | #ifdef FEATURE_NAPI |
| 5990 | /** |
| 5991 | * hdd_parse_napi() - helper functions to drv_cmd_napi |
| 5992 | * @str : source string to parse |
| 5993 | * @cmd : pointer to cmd part after parsing |
| 5994 | * @sub : pointer to subcmd part after parsing |
| 5995 | * @aux : pointer to optional aux part after parsing |
| 5996 | * |
| 5997 | * Example: |
| 5998 | * NAPI SCALE <n> +-- IN str |
| 5999 | * | | +------ OUT aux |
| 6000 | * | +------------ OUT subcmd |
| 6001 | * +----------------- OUT cmd |
| 6002 | * |
| 6003 | * Return: ==0: success; !=0: failure |
| 6004 | */ |
| 6005 | static int hdd_parse_napi(char **str, char **cmd, char **sub, char **aux) |
| 6006 | { |
| 6007 | int rc; |
| 6008 | char *token, *lcmd = NULL, *lsub = NULL, *laux = NULL; |
| 6009 | |
| 6010 | NAPI_DEBUG("-->\n"); |
| 6011 | |
| 6012 | token = strsep(str, " \t"); |
| 6013 | if (NULL == token) { |
| 6014 | hdd_err("cannot parse cmd"); |
| 6015 | goto parse_end; |
| 6016 | } |
| 6017 | lcmd = token; |
| 6018 | |
| 6019 | token = strsep(str, " \t"); |
| 6020 | if (NULL == token) { |
| 6021 | hdd_err("cannot parse subcmd"); |
| 6022 | goto parse_end; |
| 6023 | } |
| 6024 | lsub = token; |
| 6025 | |
| 6026 | token = strsep(str, " \t"); |
| 6027 | if (NULL == token) |
| 6028 | hdd_warn("cannot parse aux\n"); |
| 6029 | else |
| 6030 | laux = token; |
| 6031 | |
| 6032 | parse_end: |
| 6033 | if ((NULL == lcmd) || (NULL == lsub)) |
| 6034 | rc = -EINVAL; |
| 6035 | else { |
| 6036 | rc = 0; |
| 6037 | *cmd = lcmd; |
| 6038 | *sub = lsub; |
| 6039 | if (NULL != aux) |
| 6040 | *aux = laux; |
| 6041 | } |
| 6042 | NAPI_DEBUG("<--[rc=%d]\n", rc); |
| 6043 | return rc; |
| 6044 | } |
| 6045 | |
| 6046 | |
| 6047 | /** |
| 6048 | * hdd_parse_stats() - print NAPI stats into a buffer |
| 6049 | * @buf : buffer to write stats into |
| 6050 | * @max : "size of buffer" |
| 6051 | * @idp : NULL: all stats, otherwise, ptr to the NAPI instance |
| 6052 | * @napid: binary structure to retrieve the stats from |
| 6053 | * |
| 6054 | * Return: number of bytes written into the buffer |
| 6055 | */ |
| 6056 | int hdd_napi_stats(char *buf, |
| 6057 | int max, |
| 6058 | char *indp, |
| 6059 | struct qca_napi_data *napid) |
| 6060 | { |
| 6061 | int n = 0; |
| 6062 | int i, j, k; /* NAPI, CPU, bucket indices */ |
| 6063 | int from, to; |
| 6064 | struct qca_napi_info *napii; |
| 6065 | struct qca_napi_stat *napis; |
| 6066 | |
| 6067 | NAPI_DEBUG("-->\n"); |
| 6068 | |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6069 | if (NULL == napid) |
| 6070 | return n; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6071 | if (NULL == indp) { |
| 6072 | from = 0; |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6073 | to = CE_COUNT_MAX; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6074 | } else { |
| 6075 | if (0 > kstrtoint(indp, 10, &to)) { |
| 6076 | from = 0; |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6077 | to = CE_COUNT_MAX; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6078 | } else |
| 6079 | from = to; |
| 6080 | } |
| 6081 | |
| 6082 | for (i = from; i < to; i++) |
| 6083 | if (napid->ce_map & (0x01 << i)) { |
| 6084 | napii = &(napid->napis[i]); |
| 6085 | for (j = 0; j < NR_CPUS; j++) { |
| 6086 | napis = &(napii->stats[j]); |
| 6087 | n += scnprintf(buf + n, max - n, |
| 6088 | "STATS: NAPI[%d] CPU: %d scheds: %d polls: %d completes: %d done: %d ", |
| 6089 | i, j, |
| 6090 | napis->napi_schedules, |
| 6091 | napis->napi_polls, |
| 6092 | napis->napi_completes, |
| 6093 | napis->napi_workdone); |
| 6094 | |
| 6095 | for (k = 0; k < QCA_NAPI_NUM_BUCKETS; k++) { |
| 6096 | n += scnprintf( |
| 6097 | buf + n, max - n, |
| 6098 | " %d", |
| 6099 | napis->napi_budget_uses[k]); |
| 6100 | } |
| 6101 | n += scnprintf(buf+n, max - n, "\n"); |
| 6102 | } |
| 6103 | } |
| 6104 | |
| 6105 | NAPI_DEBUG("<--[n=%d]\n", n); |
| 6106 | return n; |
| 6107 | } |
| 6108 | |
| 6109 | /** |
| 6110 | * napi_set_scale() - sets the scale attribute in all NAPI entries |
| 6111 | * @sc : scale to set |
| 6112 | * |
| 6113 | * Return: void |
| 6114 | */ |
| 6115 | static void napi_set_scale(uint8_t sc) |
| 6116 | { |
| 6117 | uint32_t i; |
| 6118 | struct qca_napi_data *napi_data; |
| 6119 | |
| 6120 | napi_data = hdd_napi_get_all(); |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6121 | if (likely(NULL != napi_data)) |
| 6122 | for (i = 0; i < CE_COUNT_MAX; i++) |
| 6123 | if (napi_data->ce_map & (0x01 << i)) |
| 6124 | napi_data->napis[i].scale = sc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6125 | |
| 6126 | return; |
| 6127 | } |
| 6128 | /** |
| 6129 | * drv_cmd_napi() - processes NAPI commands |
| 6130 | * @adapter : net_device |
| 6131 | * @hdd_ctx : HDD context |
| 6132 | * @command : command string from user command (including "NAPI") |
| 6133 | * @command_len: length of command |
| 6134 | * @priv_data : ifr_data |
| 6135 | * |
| 6136 | * Commands supported: |
| 6137 | * NAPI ENABLE : enables NAPI administratively. Note that this may not |
| 6138 | * enable NAPI functionally, as some other conditions |
| 6139 | * may not have been satisfied yet |
| 6140 | * NAPI DISABLE : reverse operation of "enable" |
| 6141 | * NAPI STATUS : get global status of NAPI instances |
| 6142 | * NAPI STATS [<n>] : get the stats for a given NAPI instance |
| 6143 | * NAPI SCALE <n> : set the scale factor |
| 6144 | * |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6145 | * Return: 0: success; !0: failure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6146 | */ |
| 6147 | static int drv_cmd_napi(hdd_adapter_t *adapter, |
| 6148 | hdd_context_t *hdd_ctx, |
| 6149 | uint8_t *command, |
| 6150 | uint8_t command_len, |
| 6151 | hdd_priv_data_t *priv_data) |
| 6152 | { |
| 6153 | int rc = 0; |
| 6154 | int n, l; |
| 6155 | char *cmd = NULL, *subcmd = NULL, *aux = NULL; |
| 6156 | char *synopsis = "NAPI ENABLE\n" |
| 6157 | "NAPI DISABLE\n" |
| 6158 | "NAPI STATUS\n" |
| 6159 | "NAPI STATS [<n>] -- if no <n> then all\n" |
| 6160 | "NAPI SCALE <n> -- set the scale\n"; |
| 6161 | char *reply = NULL; |
| 6162 | |
| 6163 | /* make a local copy, as strsep modifies the str in place */ |
| 6164 | char *str = NULL; |
| 6165 | |
| 6166 | NAPI_DEBUG("-->\n"); |
| 6167 | |
| 6168 | /** |
| 6169 | * NOTE TO MAINTAINER: from this point to the end of the function, |
| 6170 | * please do not return anywhere in the code except the very end |
| 6171 | * to avoid memory leakage (goto end_drv_napi instead) |
| 6172 | * or make sure that reply+str is freed |
| 6173 | */ |
| 6174 | reply = kmalloc(MAX_USER_COMMAND_SIZE, GFP_KERNEL); |
| 6175 | if (NULL == reply) { |
| 6176 | hdd_err("could not allocate reply buffer"); |
| 6177 | rc = -ENOMEM; |
| 6178 | goto end_drv_napi; |
| 6179 | } |
| 6180 | |
| 6181 | str = kmalloc(strlen(command) + 1, GFP_KERNEL); |
| 6182 | if (NULL == str) { |
| 6183 | hdd_err("could not allocate copy of input buffer"); |
| 6184 | rc = -ENOMEM; |
| 6185 | goto end_drv_napi; |
| 6186 | } |
| 6187 | |
| 6188 | strlcpy(str, command, strlen(command) + 1); |
| 6189 | hdd_debug("parsing command into cmd=0x%p sub=0x%p aux=0x%p\n", |
| 6190 | cmd, subcmd, aux); |
| 6191 | |
| 6192 | |
| 6193 | rc = hdd_parse_napi(&str, &cmd, &subcmd, &aux); |
| 6194 | |
| 6195 | if (0 != rc) { |
| 6196 | const char *msg = "unknown or badly formatted cmd\n%s"; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6197 | l = QDF_MIN(MAX_USER_COMMAND_SIZE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6198 | strlen(msg)+strlen(synopsis)); |
| 6199 | n = scnprintf(reply, l, msg, synopsis); |
| 6200 | |
| 6201 | if (copy_to_user(priv_data->buf, reply, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6202 | QDF_MIN(priv_data->total_len, l))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6203 | hdd_err("failed to copy data to user buffer"); |
| 6204 | hdd_debug("reply: %s", reply); |
| 6205 | |
| 6206 | rc = -EINVAL; |
| 6207 | } else { |
| 6208 | hdd_debug("cmd=(%s) subcmd=(%s) aux=(%s)\n", |
| 6209 | cmd, subcmd, aux); |
| 6210 | if (!strcmp(subcmd, "ENABLE")) |
| 6211 | hdd_napi_event(NAPI_EVT_CMD_STATE, (void *)1); |
| 6212 | else if (!strcmp(subcmd, "DISABLE")) |
| 6213 | hdd_napi_event(NAPI_EVT_CMD_STATE, (void *)0); |
| 6214 | else if (!strcmp(subcmd, "STATUS")) { |
| 6215 | int n = 0; |
| 6216 | uint32_t i; |
| 6217 | struct qca_napi_data *napi_data; |
| 6218 | |
| 6219 | napi_data = hdd_napi_get_all(); |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6220 | if (unlikely(NULL == napi_data)) |
| 6221 | goto status_end; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6222 | n += scnprintf(reply+n, MAX_USER_COMMAND_SIZE - n, |
| 6223 | "NAPI state: 0x%08x map: 0x%08x\n", |
| 6224 | napi_data->state, |
| 6225 | napi_data->ce_map); |
| 6226 | |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6227 | for (i = 0; i < CE_COUNT_MAX; i++) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6228 | if (napi_data->ce_map & (0x01 << i)) { |
| 6229 | n += scnprintf( |
| 6230 | reply + n, |
| 6231 | MAX_USER_COMMAND_SIZE - n, |
| 6232 | "#%d: id: %d, scale=%d\n", |
| 6233 | i, |
| 6234 | napi_data->napis[i].id, |
| 6235 | napi_data->napis[i].scale); |
| 6236 | } |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6237 | status_end: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6238 | hdd_info("wlan: STATUS DATA:\n%s", reply); |
| 6239 | if (copy_to_user(priv_data->buf, reply, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6240 | QDF_MIN(n, priv_data->total_len))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6241 | rc = -EINVAL; |
| 6242 | } else if (!strcmp(subcmd, "STATS")) { |
| 6243 | int n = 0; |
| 6244 | struct qca_napi_data *napi_data; |
| 6245 | |
| 6246 | napi_data = hdd_napi_get_all(); |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6247 | if (NULL != napi_data) { |
| 6248 | n = hdd_napi_stats(reply, MAX_USER_COMMAND_SIZE, |
| 6249 | aux, napi_data); |
| 6250 | NAPI_DEBUG("STATS: returns %d\n", n); |
| 6251 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | if (n > 0) { |
| 6253 | if (copy_to_user(priv_data->buf, reply, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6254 | QDF_MIN(priv_data->total_len, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6255 | n))) |
| 6256 | rc = -EINVAL; |
| 6257 | hdd_info("wlan: STATS_DATA\n%s\n", reply); |
| 6258 | } else |
| 6259 | rc = -EINVAL; |
| 6260 | } else if (!strcmp(subcmd, "SCALE")) { |
| 6261 | if (NULL == aux) { |
| 6262 | rc = -EINVAL; |
| 6263 | hdd_err("wlan: SCALE cmd requires <n>"); |
| 6264 | } else { |
| 6265 | uint8_t sc; |
| 6266 | rc = kstrtou8(aux, 10, &sc); |
| 6267 | if (rc) { |
| 6268 | hdd_err("wlan: bad scale (%s)", aux); |
| 6269 | rc = -EINVAL; |
| 6270 | } else |
| 6271 | napi_set_scale(sc); |
| 6272 | } |
| 6273 | } /* SCALE */ |
| 6274 | } |
| 6275 | end_drv_napi: |
| 6276 | if (NULL != str) |
| 6277 | kfree(str); |
| 6278 | if (NULL != reply) |
| 6279 | kfree(reply); |
| 6280 | |
| 6281 | NAPI_DEBUG("<--[rc=%d]\n", rc); |
| 6282 | return rc; |
| 6283 | } |
| 6284 | #endif /* FEATURE_NAPI */ |
| 6285 | |
| 6286 | /** |
| 6287 | * hdd_set_rx_filter() - set RX filter |
| 6288 | * @adapter: Pointer to adapter |
| 6289 | * @action: Filter action |
| 6290 | * @pattern: Address pattern |
| 6291 | * |
| 6292 | * Address pattern is most significant byte of address for example |
| 6293 | * 0x01 for IPV4 multicast address |
| 6294 | * 0x33 for IPV6 multicast address |
| 6295 | * 0xFF for broadcast address |
| 6296 | * |
| 6297 | * Return: 0 for success, non-zero for failure |
| 6298 | */ |
| 6299 | static int hdd_set_rx_filter(hdd_adapter_t *adapter, bool action, |
| 6300 | uint8_t pattern) |
| 6301 | { |
| 6302 | int ret; |
| 6303 | uint8_t i; |
| 6304 | tHalHandle handle; |
| 6305 | tSirRcvFltMcAddrList *filter; |
| 6306 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6307 | |
| 6308 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6309 | if (0 != ret) |
| 6310 | return ret; |
| 6311 | |
| 6312 | handle = hdd_ctx->hHal; |
| 6313 | |
| 6314 | if (NULL == handle) { |
| 6315 | hdd_err("HAL Handle is NULL"); |
| 6316 | return -EINVAL; |
| 6317 | } |
| 6318 | |
| 6319 | /* |
| 6320 | * If action is false it means start dropping packets |
| 6321 | * Set addr_filter_pattern which will be used when sending |
| 6322 | * MC/BC address list to target |
| 6323 | */ |
| 6324 | if (!action) |
| 6325 | adapter->addr_filter_pattern = pattern; |
| 6326 | else |
| 6327 | adapter->addr_filter_pattern = 0; |
| 6328 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 6329 | if (((adapter->device_mode == QDF_STA_MODE) || |
| 6330 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6331 | adapter->mc_addr_list.mc_cnt && |
| 6332 | hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
| 6333 | |
| 6334 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6335 | filter = qdf_mem_malloc(sizeof(*filter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6336 | if (NULL == filter) { |
| 6337 | hdd_err("Could not allocate Memory"); |
| 6338 | return -ENOMEM; |
| 6339 | } |
| 6340 | filter->action = action; |
| 6341 | for (i = 0; i < adapter->mc_addr_list.mc_cnt; i++) { |
| 6342 | if (!memcmp(adapter->mc_addr_list.addr[i], |
| 6343 | &pattern, 1)) { |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 6344 | memcpy(filter->multicastAddr[i].bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | adapter->mc_addr_list.addr[i], |
| 6346 | sizeof(adapter->mc_addr_list.addr[i])); |
| 6347 | filter->ulMulticastAddrCnt++; |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 6348 | hdd_info("%s RX filter : addr =" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6349 | MAC_ADDRESS_STR, |
| 6350 | action ? "setting" : "clearing", |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 6351 | MAC_ADDR_ARRAY(filter->multicastAddr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6352 | } |
| 6353 | } |
| 6354 | /* Set rx filter */ |
| 6355 | sme_8023_multicast_list(handle, adapter->sessionId, filter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6356 | qdf_mem_free(filter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6357 | } else { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 6358 | hdd_info("mode %d mc_cnt %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6359 | adapter->device_mode, adapter->mc_addr_list.mc_cnt); |
| 6360 | } |
| 6361 | |
| 6362 | return 0; |
| 6363 | } |
| 6364 | |
| 6365 | /** |
| 6366 | * hdd_driver_rxfilter_comand_handler() - RXFILTER driver command handler |
| 6367 | * @command: Pointer to input string driver command |
| 6368 | * @adapter: Pointer to adapter |
| 6369 | * @action: Action to enable/disable filtering |
| 6370 | * |
| 6371 | * If action == false |
| 6372 | * Start filtering out data packets based on type |
| 6373 | * RXFILTER-REMOVE 0 -> Start filtering out unicast data packets |
| 6374 | * RXFILTER-REMOVE 1 -> Start filtering out broadcast data packets |
| 6375 | * RXFILTER-REMOVE 2 -> Start filtering out IPV4 mcast data packets |
| 6376 | * RXFILTER-REMOVE 3 -> Start filtering out IPV6 mcast data packets |
| 6377 | * |
| 6378 | * if action == true |
| 6379 | * Stop filtering data packets based on type |
| 6380 | * RXFILTER-ADD 0 -> Stop filtering unicast data packets |
| 6381 | * RXFILTER-ADD 1 -> Stop filtering broadcast data packets |
| 6382 | * RXFILTER-ADD 2 -> Stop filtering IPV4 mcast data packets |
| 6383 | * RXFILTER-ADD 3 -> Stop filtering IPV6 mcast data packets |
| 6384 | * |
| 6385 | * Current implementation only supports IPV4 address filtering by |
| 6386 | * selectively allowing IPV4 multicast data packest based on |
| 6387 | * address list received in .ndo_set_rx_mode |
| 6388 | * |
| 6389 | * Return: 0 for success, non-zero for failure |
| 6390 | */ |
| 6391 | static int hdd_driver_rxfilter_comand_handler(uint8_t *command, |
| 6392 | hdd_adapter_t *adapter, |
| 6393 | bool action) |
| 6394 | { |
| 6395 | int ret = 0; |
| 6396 | uint8_t *value; |
| 6397 | uint8_t type; |
| 6398 | |
| 6399 | value = command; |
| 6400 | /* Skip space after RXFILTER-REMOVE OR RXFILTER-ADD based on action */ |
| 6401 | if (!action) |
| 6402 | value = command + 16; |
| 6403 | else |
| 6404 | value = command + 13; |
| 6405 | ret = kstrtou8(value, 10, &type); |
| 6406 | if (ret < 0) { |
| 6407 | hdd_err("kstrtou8 failed invalid input value %d", type); |
| 6408 | return -EINVAL; |
| 6409 | } |
| 6410 | |
| 6411 | switch (type) { |
| 6412 | case 2: |
| 6413 | /* Set rx filter for IPV4 multicast data packets */ |
| 6414 | ret = hdd_set_rx_filter(adapter, action, 0x01); |
| 6415 | break; |
| 6416 | default: |
| 6417 | hdd_info("Unsupported RXFILTER type %d", type); |
| 6418 | break; |
| 6419 | } |
| 6420 | |
| 6421 | return ret; |
| 6422 | } |
| 6423 | |
| 6424 | /** |
| 6425 | * drv_cmd_rx_filter_remove() - RXFILTER REMOVE driver command handler |
| 6426 | * @adapter: Pointer to network adapter |
| 6427 | * @hdd_ctx: Pointer to hdd context |
| 6428 | * @command: Pointer to input command |
| 6429 | * @command_len: Command length |
| 6430 | * @priv_data: Pointer to private data in command |
| 6431 | */ |
| 6432 | static int drv_cmd_rx_filter_remove(hdd_adapter_t *adapter, |
| 6433 | hdd_context_t *hdd_ctx, |
| 6434 | uint8_t *command, |
| 6435 | uint8_t command_len, |
| 6436 | hdd_priv_data_t *priv_data) |
| 6437 | { |
| 6438 | return hdd_driver_rxfilter_comand_handler(command, adapter, false); |
| 6439 | } |
| 6440 | |
| 6441 | /** |
| 6442 | * drv_cmd_rx_filter_add() - RXFILTER ADD driver command handler |
| 6443 | * @adapter: Pointer to network adapter |
| 6444 | * @hdd_ctx: Pointer to hdd context |
| 6445 | * @command: Pointer to input command |
| 6446 | * @command_len: Command length |
| 6447 | * @priv_data: Pointer to private data in command |
| 6448 | */ |
| 6449 | static int drv_cmd_rx_filter_add(hdd_adapter_t *adapter, |
| 6450 | hdd_context_t *hdd_ctx, |
| 6451 | uint8_t *command, |
| 6452 | uint8_t command_len, |
| 6453 | hdd_priv_data_t *priv_data) |
| 6454 | { |
| 6455 | return hdd_driver_rxfilter_comand_handler(command, adapter, true); |
| 6456 | } |
| 6457 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6458 | /** |
| 6459 | * hdd_parse_setantennamode_command() - HDD Parse SETANTENNAMODE |
| 6460 | * command |
| 6461 | * @value: Pointer to SETANTENNAMODE command |
| 6462 | * @mode: Pointer to antenna mode |
| 6463 | * @reason: Pointer to reason for set antenna mode |
| 6464 | * |
| 6465 | * This function parses the SETANTENNAMODE command passed in the format |
| 6466 | * SETANTENNAMODE<space>mode |
| 6467 | * |
| 6468 | * Return: 0 for success non-zero for failure |
| 6469 | */ |
| 6470 | static int hdd_parse_setantennamode_command(const uint8_t *value) |
| 6471 | { |
| 6472 | const uint8_t *in_ptr = value; |
| 6473 | int tmp, v; |
| 6474 | char arg1[32]; |
| 6475 | |
| 6476 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 6477 | |
| 6478 | /* no argument after the command */ |
| 6479 | if (NULL == in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6480 | hdd_err("No argument after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6481 | return -EINVAL; |
| 6482 | } |
| 6483 | |
| 6484 | /* no space after the command */ |
| 6485 | if (SPACE_ASCII_VALUE != *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6486 | hdd_err("No space after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6487 | return -EINVAL; |
| 6488 | } |
| 6489 | |
| 6490 | /* remove empty spaces */ |
| 6491 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 6492 | in_ptr++; |
| 6493 | |
| 6494 | /* no argument followed by spaces */ |
| 6495 | if ('\0' == *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6496 | hdd_err("No argument followed by spaces"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6497 | return -EINVAL; |
| 6498 | } |
| 6499 | |
| 6500 | /* get the argument i.e. antenna mode */ |
| 6501 | v = sscanf(in_ptr, "%31s ", arg1); |
| 6502 | if (1 != v) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6503 | hdd_err("argument retrieval from cmd string failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6504 | return -EINVAL; |
| 6505 | } |
| 6506 | |
| 6507 | v = kstrtos32(arg1, 10, &tmp); |
| 6508 | if (v < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6509 | hdd_err("argument string to int conversion failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6510 | return -EINVAL; |
| 6511 | } |
| 6512 | |
| 6513 | return tmp; |
| 6514 | } |
| 6515 | |
| 6516 | /** |
| 6517 | * hdd_is_supported_chain_mask_2x2() - Verify if supported chain |
| 6518 | * mask is 2x2 mode |
| 6519 | * @hdd_ctx: Pointer to hdd contex |
| 6520 | * |
| 6521 | * Return: true if supported chain mask 2x2 else false |
| 6522 | */ |
| 6523 | static bool hdd_is_supported_chain_mask_2x2(hdd_context_t *hdd_ctx) |
| 6524 | { |
| 6525 | /* |
| 6526 | * Revisit and the update logic to determine the number |
| 6527 | * of TX/RX chains supported in the system when |
| 6528 | * antenna sharing per band chain mask support is |
| 6529 | * brought in |
| 6530 | */ |
| 6531 | return (hdd_ctx->config->enable2x2 == 0x01) ? true : false; |
| 6532 | } |
| 6533 | |
| 6534 | /** |
| 6535 | * hdd_is_supported_chain_mask_1x1() - Verify if the supported |
| 6536 | * chain mask is 1x1 |
| 6537 | * @hdd_ctx: Pointer to hdd contex |
| 6538 | * |
| 6539 | * Return: true if supported chain mask 1x1 else false |
| 6540 | */ |
| 6541 | static bool hdd_is_supported_chain_mask_1x1(hdd_context_t *hdd_ctx) |
| 6542 | { |
| 6543 | /* |
| 6544 | * Revisit and update the logic to determine the number |
| 6545 | * of TX/RX chains supported in the system when |
| 6546 | * antenna sharing per band chain mask support is |
| 6547 | * brought in |
| 6548 | */ |
| 6549 | return (!hdd_ctx->config->enable2x2) ? true : false; |
| 6550 | } |
| 6551 | |
| 6552 | /** |
| 6553 | * drv_cmd_set_antenna_mode() - SET ANTENNA MODE driver command |
| 6554 | * handler |
| 6555 | * @adapter: Pointer to network adapter |
| 6556 | * @hdd_ctx: Pointer to hdd context |
| 6557 | * @command: Pointer to input command |
| 6558 | * @command_len: Command length |
| 6559 | * @priv_data: Pointer to private data in command |
| 6560 | */ |
| 6561 | static int drv_cmd_set_antenna_mode(hdd_adapter_t *adapter, |
| 6562 | hdd_context_t *hdd_ctx, |
| 6563 | uint8_t *command, |
| 6564 | uint8_t command_len, |
| 6565 | hdd_priv_data_t *priv_data) |
| 6566 | { |
| 6567 | struct sir_antenna_mode_param params; |
| 6568 | QDF_STATUS status; |
| 6569 | int ret = 0; |
| 6570 | int mode; |
| 6571 | uint8_t *value = command; |
| 6572 | uint8_t smps_mode; |
| 6573 | uint8_t smps_enable; |
| 6574 | |
| 6575 | if (((1 << QDF_STA_MODE) != hdd_ctx->concurrency_mode) || |
| 6576 | (hdd_ctx->no_of_active_sessions[QDF_STA_MODE] > 1)) { |
| 6577 | hdd_err("Operation invalid in non sta or concurrent mode"); |
| 6578 | ret = -EPERM; |
| 6579 | goto exit; |
| 6580 | } |
| 6581 | |
| 6582 | mode = hdd_parse_setantennamode_command(value); |
| 6583 | if (mode < 0) { |
| 6584 | hdd_err("Invalid SETANTENNA command"); |
| 6585 | ret = mode; |
| 6586 | goto exit; |
| 6587 | } |
| 6588 | |
| 6589 | hdd_info("Processing antenna mode switch to: %d", mode); |
| 6590 | |
| 6591 | if (hdd_ctx->current_antenna_mode == mode) { |
| 6592 | hdd_err("System already in the requested mode"); |
| 6593 | ret = 0; |
| 6594 | goto exit; |
| 6595 | } |
| 6596 | |
| 6597 | if ((HDD_ANTENNA_MODE_2X2 == mode) && |
| 6598 | (!hdd_is_supported_chain_mask_2x2(hdd_ctx))) { |
| 6599 | hdd_err("System does not support 2x2 mode"); |
| 6600 | ret = -EPERM; |
| 6601 | goto exit; |
| 6602 | } |
| 6603 | |
| 6604 | if ((HDD_ANTENNA_MODE_1X1 == mode) && |
| 6605 | hdd_is_supported_chain_mask_1x1(hdd_ctx)) { |
| 6606 | hdd_err("System only supports 1x1 mode"); |
| 6607 | ret = 0; |
| 6608 | goto exit; |
| 6609 | } |
| 6610 | |
| 6611 | switch (mode) { |
| 6612 | case HDD_ANTENNA_MODE_1X1: |
| 6613 | params.num_rx_chains = 1; |
| 6614 | params.num_tx_chains = 1; |
| 6615 | break; |
| 6616 | case HDD_ANTENNA_MODE_2X2: |
| 6617 | params.num_rx_chains = 2; |
| 6618 | params.num_tx_chains = 2; |
| 6619 | break; |
| 6620 | default: |
| 6621 | hdd_err("unsupported antenna mode"); |
| 6622 | ret = -EINVAL; |
| 6623 | goto exit; |
| 6624 | } |
| 6625 | |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6626 | /* Check TDLS status and update antenna mode */ |
| 6627 | if ((QDF_STA_MODE == adapter->device_mode) && |
| 6628 | cds_is_sta_active_connection_exists() && |
| 6629 | (hdd_ctx->connected_peer_count > 0)) { |
Archana Ramachandran | 2ad7de2 | 2016-04-22 16:53:25 -0700 | [diff] [blame] | 6630 | ret = wlan_hdd_tdls_antenna_switch(hdd_ctx, adapter, |
| 6631 | mode); |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6632 | if (0 != ret) |
| 6633 | goto exit; |
| 6634 | } |
| 6635 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6636 | params.set_antenna_mode_resp = |
| 6637 | (void *)wlan_hdd_soc_set_antenna_mode_cb; |
| 6638 | hdd_info("Set antenna mode rx chains: %d tx chains: %d", |
| 6639 | params.num_rx_chains, |
| 6640 | params.num_tx_chains); |
| 6641 | |
| 6642 | |
| 6643 | INIT_COMPLETION(hdd_ctx->set_antenna_mode_cmpl); |
| 6644 | status = sme_soc_set_antenna_mode(hdd_ctx->hHal, ¶ms); |
| 6645 | if (QDF_STATUS_SUCCESS != status) { |
| 6646 | hdd_err("set antenna mode failed status : %d", status); |
| 6647 | ret = -EFAULT; |
| 6648 | goto exit; |
| 6649 | } |
| 6650 | |
| 6651 | ret = wait_for_completion_timeout( |
| 6652 | &hdd_ctx->set_antenna_mode_cmpl, |
| 6653 | msecs_to_jiffies(WLAN_WAIT_TIME_ANTENNA_MODE_REQ)); |
| 6654 | if (!ret) { |
| 6655 | ret = -EFAULT; |
| 6656 | hdd_err("send set antenna mode timed out"); |
| 6657 | goto exit; |
| 6658 | } |
| 6659 | |
| 6660 | /* Update SME SMPS config */ |
| 6661 | if (HDD_ANTENNA_MODE_1X1 == mode) { |
| 6662 | smps_enable = true; |
| 6663 | smps_mode = HDD_SMPS_MODE_STATIC; |
| 6664 | } else { |
| 6665 | smps_enable = false; |
| 6666 | smps_mode = HDD_SMPS_MODE_DISABLED; |
| 6667 | } |
| 6668 | |
| 6669 | hdd_info("Update SME SMPS enable: %d mode: %d", |
| 6670 | smps_enable, smps_mode); |
| 6671 | status = sme_update_mimo_power_save( |
| 6672 | hdd_ctx->hHal, smps_enable, smps_mode, false); |
| 6673 | if (QDF_STATUS_SUCCESS != status) { |
| 6674 | hdd_err("Update SMPS config failed enable: %d mode: %d status: %d", |
| 6675 | smps_enable, smps_mode, status); |
| 6676 | ret = -EFAULT; |
| 6677 | goto exit; |
| 6678 | } |
| 6679 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6680 | hdd_ctx->current_antenna_mode = mode; |
Archana Ramachandran | 5041b25 | 2016-04-25 14:29:25 -0700 | [diff] [blame] | 6681 | /* Update the user requested nss in the mac context. |
| 6682 | * This will be used in tdls protocol engine to form tdls |
| 6683 | * Management frames. |
| 6684 | */ |
| 6685 | sme_update_user_configured_nss( |
| 6686 | hdd_ctx->hHal, |
| 6687 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6688 | |
Archana Ramachandran | 5041b25 | 2016-04-25 14:29:25 -0700 | [diff] [blame] | 6689 | hdd_info("Successfully switched to mode: %d x %d", |
| 6690 | hdd_ctx->current_antenna_mode, |
| 6691 | hdd_ctx->current_antenna_mode); |
| 6692 | ret = 0; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6693 | exit: |
| 6694 | hdd_info("Set antenna status: %d current mode: %d", |
| 6695 | ret, hdd_ctx->current_antenna_mode); |
| 6696 | return ret; |
| 6697 | |
| 6698 | } |
| 6699 | |
| 6700 | /** |
| 6701 | * drv_cmd_get_antenna_mode() - GET ANTENNA MODE driver command |
| 6702 | * handler |
| 6703 | * @adapter: Pointer to hdd adapter |
| 6704 | * @hdd_ctx: Pointer to hdd context |
| 6705 | * @command: Pointer to input command |
| 6706 | * @command_len: length of the command |
| 6707 | * @priv_data: private data coming with the driver command |
| 6708 | * |
| 6709 | * Return: 0 for success non-zero for failure |
| 6710 | */ |
| 6711 | static inline int drv_cmd_get_antenna_mode(hdd_adapter_t *adapter, |
| 6712 | hdd_context_t *hdd_ctx, |
| 6713 | uint8_t *command, |
| 6714 | uint8_t command_len, |
| 6715 | hdd_priv_data_t *priv_data) |
| 6716 | { |
| 6717 | uint32_t antenna_mode = 0; |
| 6718 | char extra[32]; |
| 6719 | uint8_t len = 0; |
| 6720 | |
| 6721 | antenna_mode = hdd_ctx->current_antenna_mode; |
| 6722 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
| 6723 | antenna_mode); |
| 6724 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 6725 | if (copy_to_user(priv_data->buf, &extra, len)) { |
| 6726 | hdd_err("Failed to copy data to user buffer"); |
| 6727 | return -EFAULT; |
| 6728 | } |
| 6729 | |
| 6730 | hdd_info("Get antenna mode: %d", antenna_mode); |
| 6731 | |
| 6732 | return 0; |
| 6733 | } |
| 6734 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6735 | /* |
| 6736 | * dummy (no-op) hdd driver command handler |
| 6737 | */ |
| 6738 | static int drv_cmd_dummy(hdd_adapter_t *adapter, |
| 6739 | hdd_context_t *hdd_ctx, |
| 6740 | uint8_t *command, |
| 6741 | uint8_t command_len, |
| 6742 | hdd_priv_data_t *priv_data) |
| 6743 | { |
| 6744 | hdd_info("%s: Ignoring driver command \"%s\"", |
| 6745 | adapter->dev->name, command); |
| 6746 | return 0; |
| 6747 | } |
| 6748 | |
| 6749 | /* |
| 6750 | * handler for any unsupported wlan hdd driver command |
| 6751 | */ |
| 6752 | static int drv_cmd_invalid(hdd_adapter_t *adapter, |
| 6753 | hdd_context_t *hdd_ctx, |
| 6754 | uint8_t *command, |
| 6755 | uint8_t command_len, |
| 6756 | hdd_priv_data_t *priv_data) |
| 6757 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 6758 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6759 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 6760 | adapter->sessionId, 0)); |
| 6761 | |
| 6762 | hdd_warn("%s: Unsupported driver command \"%s\"", |
| 6763 | adapter->dev->name, command); |
| 6764 | |
| 6765 | return -ENOTSUPP; |
| 6766 | } |
| 6767 | |
| 6768 | /** |
| 6769 | * drv_cmd_set_fcc_channel() - handle fcc constraint request |
| 6770 | * @adapter: HDD adapter |
| 6771 | * @hdd_ctx: HDD context |
| 6772 | * @command: command ptr, SET_FCC_CHANNEL 0/1 is the command |
| 6773 | * @command_len: command len |
| 6774 | * @priv_data: private data |
| 6775 | * |
| 6776 | * Return: status |
| 6777 | */ |
| 6778 | static int drv_cmd_set_fcc_channel(hdd_adapter_t *adapter, |
| 6779 | hdd_context_t *hdd_ctx, |
| 6780 | uint8_t *command, |
| 6781 | uint8_t command_len, |
| 6782 | hdd_priv_data_t *priv_data) |
| 6783 | { |
| 6784 | uint8_t *value; |
| 6785 | uint8_t fcc_constraint; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6786 | QDF_STATUS status; |
Amar Singhal | 83a047a | 2016-05-19 15:56:11 -0700 | [diff] [blame] | 6787 | bool scan_pending; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6788 | int ret = 0; |
| 6789 | |
| 6790 | /* |
| 6791 | * this command would be called by user-space when it detects WLAN |
| 6792 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 6793 | * But it can be turned back on. Otherwise; when APM is turned back |
| 6794 | * off, WLAN would turn back on. So at that point the command is |
| 6795 | * expected to come down. 0 means disable, 1 means enable. The |
| 6796 | * constraint is removed when parameter 1 is set or different |
| 6797 | * country code is set |
| 6798 | */ |
| 6799 | |
| 6800 | value = command + command_len + 1; |
| 6801 | |
| 6802 | ret = kstrtou8(value, 10, &fcc_constraint); |
| 6803 | if ((ret < 0) || (fcc_constraint > 1)) { |
| 6804 | /* |
| 6805 | * If the input value is greater than max value of datatype, |
| 6806 | * then also it is a failure |
| 6807 | */ |
| 6808 | hdd_err("value out of range"); |
| 6809 | return -EINVAL; |
| 6810 | } |
| 6811 | |
Amar Singhal | 83a047a | 2016-05-19 15:56:11 -0700 | [diff] [blame] | 6812 | scan_pending = !qdf_list_empty(&hdd_ctx->hdd_scan_req_q); |
| 6813 | status = sme_handle_set_fcc_channel(hdd_ctx->hHal, !fcc_constraint, |
| 6814 | scan_pending); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6815 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6816 | hdd_err("sme disable fn. returned err"); |
| 6817 | ret = -EPERM; |
| 6818 | } |
| 6819 | |
| 6820 | return ret; |
| 6821 | } |
| 6822 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6823 | /** |
| 6824 | * hdd_parse_set_channel_switch_command() - Parse and validate CHANNEL_SWITCH |
| 6825 | * command |
| 6826 | * @value: Pointer to the command |
| 6827 | * @chan_number: Pointer to the channel number |
| 6828 | * @chan_bw: Pointer to the channel bandwidth |
| 6829 | * |
| 6830 | * Parses and provides the channel number and channel width from the input |
| 6831 | * command which is expected to be of the format: CHANNEL_SWITCH <CH> <BW> |
| 6832 | * <CH> is channel number to move (where 1 = channel 1, 149 = channel 149, ...) |
| 6833 | * <BW> is bandwidth to move (where 20 = BW 20, 40 = BW 40, 80 = BW 80) |
| 6834 | * |
| 6835 | * Return: 0 for success, non-zero for failure |
| 6836 | */ |
| 6837 | static int hdd_parse_set_channel_switch_command(uint8_t *value, |
| 6838 | uint32_t *chan_number, |
| 6839 | uint32_t *chan_bw) |
| 6840 | { |
| 6841 | const uint8_t *in_ptr = value; |
| 6842 | int ret; |
| 6843 | |
| 6844 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 6845 | |
| 6846 | /* no argument after the command */ |
| 6847 | if (NULL == in_ptr) { |
| 6848 | hdd_err("No argument after the command"); |
| 6849 | return -EINVAL; |
| 6850 | } |
| 6851 | |
| 6852 | /* no space after the command */ |
| 6853 | if (SPACE_ASCII_VALUE != *in_ptr) { |
| 6854 | hdd_err("No space after the command "); |
| 6855 | return -EINVAL; |
| 6856 | } |
| 6857 | |
| 6858 | /* remove empty spaces and move the next argument */ |
| 6859 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 6860 | in_ptr++; |
| 6861 | |
| 6862 | /* no argument followed by spaces */ |
| 6863 | if ('\0' == *in_ptr) { |
| 6864 | hdd_err("No argument followed by spaces"); |
| 6865 | return -EINVAL; |
| 6866 | } |
| 6867 | |
| 6868 | /* get the two arguments: channel number and bandwidth */ |
| 6869 | ret = sscanf(in_ptr, "%u %u", chan_number, chan_bw); |
| 6870 | if (ret != 2) { |
| 6871 | hdd_err("Arguments retrieval from cmd string failed"); |
| 6872 | return -EINVAL; |
| 6873 | } |
| 6874 | |
| 6875 | return 0; |
| 6876 | } |
| 6877 | |
| 6878 | /** |
| 6879 | * drv_cmd_set_channel_switch() - Switch SAP/P2P-GO operating channel |
| 6880 | * @adapter: HDD adapter |
| 6881 | * @hdd_ctx: HDD context |
| 6882 | * @command: Pointer to the input command CHANNEL_SWITCH |
| 6883 | * @command_len: Command len |
| 6884 | * @priv_data: Private data |
| 6885 | * |
| 6886 | * Handles private IOCTL CHANNEL_SWITCH command to switch the operating channel |
| 6887 | * of SAP/P2P-GO |
| 6888 | * |
| 6889 | * Return: 0 for success, non-zero for failure |
| 6890 | */ |
| 6891 | static int drv_cmd_set_channel_switch(hdd_adapter_t *adapter, |
| 6892 | hdd_context_t *hdd_ctx, |
| 6893 | uint8_t *command, |
| 6894 | uint8_t command_len, |
| 6895 | hdd_priv_data_t *priv_data) |
| 6896 | { |
| 6897 | struct net_device *dev = adapter->dev; |
| 6898 | int status; |
| 6899 | uint32_t chan_number = 0, chan_bw = 0; |
| 6900 | uint8_t *value = command; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 6901 | enum phy_ch_width width; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6902 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 6903 | if ((adapter->device_mode != QDF_P2P_GO_MODE) && |
| 6904 | (adapter->device_mode != QDF_SAP_MODE)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6905 | hdd_err("IOCTL CHANNEL_SWITCH not supported for mode %d", |
| 6906 | adapter->device_mode); |
| 6907 | return -EINVAL; |
| 6908 | } |
| 6909 | |
| 6910 | status = hdd_parse_set_channel_switch_command(value, |
| 6911 | &chan_number, &chan_bw); |
| 6912 | if (status) { |
| 6913 | hdd_err("Invalid CHANNEL_SWITCH command"); |
| 6914 | return status; |
| 6915 | } |
| 6916 | |
| 6917 | if ((chan_bw != 20) && (chan_bw != 40) && (chan_bw != 80)) { |
| 6918 | hdd_err("BW %d is not allowed for CHANNEL_SWITCH", chan_bw); |
| 6919 | return -EINVAL; |
| 6920 | } |
| 6921 | |
| 6922 | if (chan_bw == 80) |
| 6923 | width = CH_WIDTH_80MHZ; |
| 6924 | else if (chan_bw == 40) |
| 6925 | width = CH_WIDTH_40MHZ; |
| 6926 | else |
| 6927 | width = CH_WIDTH_20MHZ; |
| 6928 | |
| 6929 | hdd_info("CH:%d BW:%d", chan_number, chan_bw); |
| 6930 | |
| 6931 | status = hdd_softap_set_channel_change(dev, chan_number, width); |
| 6932 | if (status) { |
| 6933 | hdd_err("Set channel change fail"); |
| 6934 | return status; |
| 6935 | } |
| 6936 | |
| 6937 | return 0; |
| 6938 | } |
| 6939 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6940 | /* |
| 6941 | * The following table contains all supported WLAN HDD |
| 6942 | * IOCTL driver commands and the handler for each of them. |
| 6943 | */ |
| 6944 | static const hdd_drv_cmd_t hdd_drv_cmds[] = { |
| 6945 | {"P2P_DEV_ADDR", drv_cmd_p2p_dev_addr}, |
| 6946 | {"P2P_SET_NOA", drv_cmd_p2p_set_noa}, |
| 6947 | {"P2P_SET_PS", drv_cmd_p2p_set_ps}, |
| 6948 | {"SETBAND", drv_cmd_set_band}, |
| 6949 | {"SETWMMPS", drv_cmd_set_wmmps}, |
| 6950 | {"COUNTRY", drv_cmd_country}, |
| 6951 | {"SETSUSPENDMODE", drv_cmd_dummy}, |
| 6952 | {"SET_AP_WPS_P2P_IE", drv_cmd_dummy}, |
| 6953 | {"BTCOEXSCAN", drv_cmd_dummy}, |
| 6954 | {"RXFILTER", drv_cmd_dummy}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6955 | {"SETROAMTRIGGER", drv_cmd_set_roam_trigger}, |
| 6956 | {"GETROAMTRIGGER", drv_cmd_get_roam_trigger}, |
| 6957 | {"SETROAMSCANPERIOD", drv_cmd_set_roam_scan_period}, |
| 6958 | {"GETROAMSCANPERIOD", drv_cmd_get_roam_scan_period}, |
| 6959 | {"SETROAMSCANREFRESHPERIOD", drv_cmd_set_roam_scan_refresh_period}, |
| 6960 | {"GETROAMSCANREFRESHPERIOD", drv_cmd_get_roam_scan_refresh_period}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6961 | {"SETROAMMODE", drv_cmd_set_roam_mode}, |
| 6962 | {"GETROAMMODE", drv_cmd_get_roam_mode}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6963 | {"SETROAMDELTA", drv_cmd_set_roam_delta}, |
| 6964 | {"GETROAMDELTA", drv_cmd_get_roam_delta}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | {"GETBAND", drv_cmd_get_band}, |
| 6966 | {"SETROAMSCANCHANNELS", drv_cmd_set_roam_scan_channels}, |
| 6967 | {"GETROAMSCANCHANNELS", drv_cmd_get_roam_scan_channels}, |
| 6968 | {"GETCCXMODE", drv_cmd_get_ccx_mode}, |
| 6969 | {"GETOKCMODE", drv_cmd_get_okc_mode}, |
| 6970 | {"GETFASTROAM", drv_cmd_get_fast_roam}, |
| 6971 | {"GETFASTTRANSITION", drv_cmd_get_fast_transition}, |
| 6972 | {"SETROAMSCANCHANNELMINTIME", drv_cmd_set_roam_scan_channel_min_time}, |
| 6973 | {"SENDACTIONFRAME", drv_cmd_send_action_frame}, |
| 6974 | {"GETROAMSCANCHANNELMINTIME", drv_cmd_get_roam_scan_channel_min_time}, |
| 6975 | {"SETSCANCHANNELTIME", drv_cmd_set_scan_channel_time}, |
| 6976 | {"GETSCANCHANNELTIME", drv_cmd_get_scan_channel_time}, |
| 6977 | {"SETSCANHOMETIME", drv_cmd_set_scan_home_time}, |
| 6978 | {"GETSCANHOMETIME", drv_cmd_get_scan_home_time}, |
| 6979 | {"SETROAMINTRABAND", drv_cmd_set_roam_intra_band}, |
| 6980 | {"GETROAMINTRABAND", drv_cmd_get_roam_intra_band}, |
| 6981 | {"SETSCANNPROBES", drv_cmd_set_scan_n_probes}, |
| 6982 | {"GETSCANNPROBES", drv_cmd_get_scan_n_probes}, |
| 6983 | {"SETSCANHOMEAWAYTIME", drv_cmd_set_scan_home_away_time}, |
| 6984 | {"GETSCANHOMEAWAYTIME", drv_cmd_get_scan_home_away_time}, |
| 6985 | {"REASSOC", drv_cmd_reassoc}, |
| 6986 | {"SETWESMODE", drv_cmd_set_wes_mode}, |
| 6987 | {"GETWESMODE", drv_cmd_get_wes_mode}, |
| 6988 | {"SETOPPORTUNISTICRSSIDIFF", drv_cmd_set_opportunistic_rssi_diff}, |
| 6989 | {"GETOPPORTUNISTICRSSIDIFF", drv_cmd_get_opportunistic_rssi_diff}, |
| 6990 | {"SETROAMRESCANRSSIDIFF", drv_cmd_set_roam_rescan_rssi_diff}, |
| 6991 | {"GETROAMRESCANRSSIDIFF", drv_cmd_get_roam_rescan_rssi_diff}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6992 | {"SETFASTROAM", drv_cmd_set_fast_roam}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6993 | {"SETFASTTRANSITION", drv_cmd_set_fast_transition}, |
| 6994 | {"FASTREASSOC", drv_cmd_fast_reassoc}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6995 | {"SETROAMSCANCONTROL", drv_cmd_set_roam_scan_control}, |
| 6996 | #ifdef FEATURE_WLAN_OKC |
| 6997 | {"SETOKCMODE", drv_cmd_set_okc_mode}, |
| 6998 | #endif /* FEATURE_WLAN_OKC */ |
| 6999 | {"GETROAMSCANCONTROL", drv_cmd_get_roam_scan_control}, |
| 7000 | {"BTCOEXMODE", drv_cmd_bt_coex_mode}, |
| 7001 | {"SCAN-ACTIVE", drv_cmd_scan_active}, |
| 7002 | {"SCAN-PASSIVE", drv_cmd_scan_passive}, |
| 7003 | {"GETDWELLTIME", drv_cmd_get_dwell_time}, |
| 7004 | {"SETDWELLTIME", drv_cmd_set_dwell_time}, |
| 7005 | {"MIRACAST", drv_cmd_miracast}, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 7006 | {"SETIBSSBEACONOUIDATA", drv_cmd_set_ibss_beacon_oui_data}, |
| 7007 | {"SETRMCENABLE", drv_cmd_set_rmc_enable}, |
| 7008 | {"SETRMCACTIONPERIOD", drv_cmd_set_rmc_action_period}, |
| 7009 | {"GETIBSSPEERINFOALL", drv_cmd_get_ibss_peer_info_all}, |
| 7010 | {"GETIBSSPEERINFO", drv_cmd_get_ibss_peer_info}, |
| 7011 | {"SETRMCTXRATE", drv_cmd_set_rmc_tx_rate}, |
| 7012 | {"SETIBSSTXFAILEVENT", drv_cmd_set_ibss_tx_fail_event}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 7013 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | {"SETCCXROAMSCANCHANNELS", drv_cmd_set_ccx_roam_scan_channels}, |
| 7015 | {"GETTSMSTATS", drv_cmd_get_tsm_stats}, |
| 7016 | {"SETCCKMIE", drv_cmd_set_cckm_ie}, |
| 7017 | {"CCXBEACONREQ", drv_cmd_ccx_beacon_req}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 7018 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7019 | {"SETMCRATE", drv_cmd_set_mc_rate}, |
| 7020 | {"MAXTXPOWER", drv_cmd_max_tx_power}, |
| 7021 | {"SETDFSSCANMODE", drv_cmd_set_dfs_scan_mode}, |
| 7022 | {"GETDFSSCANMODE", drv_cmd_get_dfs_scan_mode}, |
| 7023 | {"GETLINKSTATUS", drv_cmd_get_link_status}, |
| 7024 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 7025 | {"ENABLEEXTWOW", drv_cmd_enable_ext_wow}, |
| 7026 | {"SETAPP1PARAMS", drv_cmd_set_app1_params}, |
| 7027 | {"SETAPP2PARAMS", drv_cmd_set_app2_params}, |
| 7028 | #endif |
| 7029 | #ifdef FEATURE_WLAN_TDLS |
| 7030 | {"TDLSSECONDARYCHANNELOFFSET", drv_cmd_tdls_secondary_channel_offset}, |
| 7031 | {"TDLSOFFCHANNELMODE", drv_cmd_tdls_off_channel_mode}, |
| 7032 | {"TDLSOFFCHANNEL", drv_cmd_tdls_off_channel}, |
| 7033 | {"TDLSSCAN", drv_cmd_tdls_scan}, |
| 7034 | #endif |
| 7035 | {"RSSI", drv_cmd_get_rssi}, |
| 7036 | {"LINKSPEED", drv_cmd_get_linkspeed}, |
| 7037 | #ifdef FEATURE_NAPI |
| 7038 | {"NAPI", drv_cmd_napi}, |
| 7039 | #endif /* FEATURE_NAPI */ |
| 7040 | {"RXFILTER-REMOVE", drv_cmd_rx_filter_remove}, |
| 7041 | {"RXFILTER-ADD", drv_cmd_rx_filter_add}, |
| 7042 | {"SET_FCC_CHANNEL", drv_cmd_set_fcc_channel}, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7043 | {"CHANNEL_SWITCH", drv_cmd_set_channel_switch}, |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7044 | {"SETANTENNAMODE", drv_cmd_set_antenna_mode}, |
| 7045 | {"GETANTENNAMODE", drv_cmd_get_antenna_mode}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7046 | }; |
| 7047 | |
| 7048 | /** |
| 7049 | * hdd_drv_cmd_process() - chooses and runs the proper |
| 7050 | * handler based on the input command |
| 7051 | * @adapter: Pointer to the hdd adapter |
| 7052 | * @cmd: Pointer to the driver command |
| 7053 | * @priv_data: Pointer to the data associated with the command |
| 7054 | * |
| 7055 | * This function parses the input hdd driver command and runs |
| 7056 | * the proper handler |
| 7057 | * |
| 7058 | * Return: 0 for success non-zero for failure |
| 7059 | */ |
| 7060 | static int hdd_drv_cmd_process(hdd_adapter_t *adapter, |
| 7061 | uint8_t *cmd, |
| 7062 | hdd_priv_data_t *priv_data) |
| 7063 | { |
| 7064 | hdd_context_t *hdd_ctx; |
| 7065 | int i; |
| 7066 | const int cmd_num_total = ARRAY_SIZE(hdd_drv_cmds); |
| 7067 | uint8_t *cmd_i = NULL; |
| 7068 | hdd_drv_cmd_handler_t handler = NULL; |
| 7069 | int len = 0; |
| 7070 | |
| 7071 | if (!adapter || !cmd || !priv_data) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7072 | hdd_err("at least 1 param is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7073 | return -EINVAL; |
| 7074 | } |
| 7075 | |
| 7076 | hdd_ctx = (hdd_context_t *)adapter->pHddCtx; |
| 7077 | |
| 7078 | for (i = 0; i < cmd_num_total; i++) { |
| 7079 | |
| 7080 | cmd_i = (uint8_t *)hdd_drv_cmds[i].cmd; |
| 7081 | handler = hdd_drv_cmds[i].handler; |
| 7082 | len = strlen(cmd_i); |
| 7083 | |
| 7084 | if (!handler) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7085 | hdd_err("no. %d handler is NULL", i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7086 | return -EINVAL; |
| 7087 | } |
| 7088 | |
| 7089 | if (strncasecmp(cmd, cmd_i, len) == 0) |
| 7090 | return handler(adapter, hdd_ctx, |
| 7091 | cmd, len, priv_data); |
| 7092 | } |
| 7093 | |
| 7094 | return drv_cmd_invalid(adapter, hdd_ctx, cmd, len, priv_data); |
| 7095 | } |
| 7096 | |
| 7097 | /** |
| 7098 | * hdd_driver_command() - top level wlan hdd driver command handler |
| 7099 | * @adapter: Pointer to the hdd adapter |
| 7100 | * @priv_data: Pointer to the raw command data |
| 7101 | * |
| 7102 | * This function is the top level wlan hdd driver command handler. It |
| 7103 | * handles the command with the help of hdd_drv_cmd_process() |
| 7104 | * |
| 7105 | * Return: 0 for success non-zero for failure |
| 7106 | */ |
| 7107 | static int hdd_driver_command(hdd_adapter_t *adapter, |
| 7108 | hdd_priv_data_t *priv_data) |
| 7109 | { |
| 7110 | uint8_t *command = NULL; |
| 7111 | int ret = 0; |
| 7112 | |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7113 | ENTER(); |
| 7114 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7115 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7116 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7117 | return -EINVAL; |
| 7118 | } |
| 7119 | |
| 7120 | /* |
| 7121 | * Note that valid pointers are provided by caller |
| 7122 | */ |
| 7123 | |
| 7124 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 7125 | if (priv_data->total_len <= 0 || |
| 7126 | priv_data->total_len > WLAN_PRIV_DATA_MAX_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7127 | hdd_warn("Invalid priv_data.total_len(%d)!!!", |
| 7128 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7129 | ret = -EINVAL; |
| 7130 | goto exit; |
| 7131 | } |
| 7132 | |
| 7133 | /* Allocate +1 for '\0' */ |
| 7134 | command = kmalloc(priv_data->total_len + 1, GFP_KERNEL); |
| 7135 | if (!command) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7136 | hdd_err("failed to allocate memory"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7137 | ret = -ENOMEM; |
| 7138 | goto exit; |
| 7139 | } |
| 7140 | |
| 7141 | if (copy_from_user(command, priv_data->buf, priv_data->total_len)) { |
| 7142 | ret = -EFAULT; |
| 7143 | goto exit; |
| 7144 | } |
| 7145 | |
| 7146 | /* Make sure the command is NUL-terminated */ |
| 7147 | command[priv_data->total_len] = '\0'; |
| 7148 | |
| 7149 | hdd_info("%s: %s", adapter->dev->name, command); |
| 7150 | ret = hdd_drv_cmd_process(adapter, command, priv_data); |
| 7151 | |
| 7152 | exit: |
| 7153 | if (command) |
| 7154 | kfree(command); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7155 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7156 | return ret; |
| 7157 | } |
| 7158 | |
| 7159 | #ifdef CONFIG_COMPAT |
| 7160 | static int hdd_driver_compat_ioctl(hdd_adapter_t *adapter, struct ifreq *ifr) |
| 7161 | { |
| 7162 | struct { |
| 7163 | compat_uptr_t buf; |
| 7164 | int used_len; |
| 7165 | int total_len; |
| 7166 | } compat_priv_data; |
| 7167 | hdd_priv_data_t priv_data; |
| 7168 | int ret = 0; |
| 7169 | |
| 7170 | /* |
| 7171 | * Note that adapter and ifr have already been verified by caller, |
| 7172 | * and HDD context has also been validated |
| 7173 | */ |
| 7174 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 7175 | sizeof(compat_priv_data))) { |
| 7176 | ret = -EFAULT; |
| 7177 | goto exit; |
| 7178 | } |
| 7179 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 7180 | priv_data.used_len = compat_priv_data.used_len; |
| 7181 | priv_data.total_len = compat_priv_data.total_len; |
| 7182 | ret = hdd_driver_command(adapter, &priv_data); |
| 7183 | exit: |
| 7184 | return ret; |
| 7185 | } |
| 7186 | #else /* CONFIG_COMPAT */ |
| 7187 | static int hdd_driver_compat_ioctl(hdd_adapter_t *adapter, struct ifreq *ifr) |
| 7188 | { |
| 7189 | /* will never be invoked */ |
| 7190 | return 0; |
| 7191 | } |
| 7192 | #endif /* CONFIG_COMPAT */ |
| 7193 | |
| 7194 | static int hdd_driver_ioctl(hdd_adapter_t *adapter, struct ifreq *ifr) |
| 7195 | { |
| 7196 | hdd_priv_data_t priv_data; |
| 7197 | int ret = 0; |
| 7198 | |
| 7199 | /* |
| 7200 | * Note that adapter and ifr have already been verified by caller, |
| 7201 | * and HDD context has also been validated |
| 7202 | */ |
| 7203 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) |
| 7204 | ret = -EFAULT; |
| 7205 | else |
| 7206 | ret = hdd_driver_command(adapter, &priv_data); |
| 7207 | |
| 7208 | return ret; |
| 7209 | } |
| 7210 | |
| 7211 | /** |
| 7212 | * __hdd_ioctl() - ioctl handler for wlan network interfaces |
| 7213 | * @dev: device upon which the ioctl was received |
| 7214 | * @ifr: ioctl request information |
| 7215 | * @cmd: ioctl command |
| 7216 | * |
| 7217 | * This function does initial processing of wlan device ioctls. |
| 7218 | * Currently two flavors of ioctls are supported. The primary ioctl |
| 7219 | * that is supported is the (SIOCDEVPRIVATE + 1) ioctl which is used |
| 7220 | * for Android "DRIVER" commands. The other ioctl that is |
| 7221 | * conditionally supported is the SIOCIOCTLTX99 ioctl which is used |
| 7222 | * for FTM on some platforms. This function simply verifies that the |
| 7223 | * driver is in a sane state, and that the ioctl is one of the |
| 7224 | * supported flavors, in which case flavor-specific handlers are |
| 7225 | * dispatched. |
| 7226 | * |
| 7227 | * Return: 0 on success, non-zero on error |
| 7228 | */ |
| 7229 | static int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 7230 | { |
| 7231 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7232 | hdd_context_t *hdd_ctx; |
| 7233 | int ret; |
| 7234 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 7235 | ENTER_DEV(dev); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7236 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7237 | if (dev != adapter->dev) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7238 | hdd_alert("HDD adapter/dev inconsistency"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7239 | ret = -ENODEV; |
| 7240 | goto exit; |
| 7241 | } |
| 7242 | |
| 7243 | if ((!ifr) || (!ifr->ifr_data)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7244 | hdd_err("invalid data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7245 | ret = -EINVAL; |
| 7246 | goto exit; |
| 7247 | } |
| 7248 | #if defined(QCA_WIFI_FTM) && defined(LINUX_QCMBR) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7249 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7250 | if (SIOCIOCTLTX99 == cmd) { |
| 7251 | ret = wlan_hdd_qcmbr_unified_ioctl(adapter, ifr); |
| 7252 | goto exit; |
| 7253 | } |
| 7254 | } |
| 7255 | #endif |
| 7256 | |
| 7257 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7258 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7259 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7260 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7261 | |
| 7262 | switch (cmd) { |
| 7263 | case (SIOCDEVPRIVATE + 1): |
| 7264 | if (is_compat_task()) |
| 7265 | ret = hdd_driver_compat_ioctl(adapter, ifr); |
| 7266 | else |
| 7267 | ret = hdd_driver_ioctl(adapter, ifr); |
| 7268 | break; |
| 7269 | default: |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7270 | hdd_err("unknown ioctl %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7271 | ret = -EINVAL; |
| 7272 | break; |
| 7273 | } |
| 7274 | exit: |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7275 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7276 | return ret; |
| 7277 | } |
| 7278 | |
| 7279 | /** |
| 7280 | * hdd_ioctl() - ioctl handler (wrapper) for wlan network interfaces |
| 7281 | * @dev: device upon which the ioctl was received |
| 7282 | * @ifr: ioctl request information |
| 7283 | * @cmd: ioctl command |
| 7284 | * |
| 7285 | * This function acts as an SSR-protecting wrapper to __hdd_ioctl() |
| 7286 | * which is where the ioctls are really handled. |
| 7287 | * |
| 7288 | * Return: 0 on success, non-zero on error |
| 7289 | */ |
| 7290 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 7291 | { |
| 7292 | int ret; |
| 7293 | |
| 7294 | cds_ssr_protect(__func__); |
| 7295 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 7296 | cds_ssr_unprotect(__func__); |
| 7297 | return ret; |
| 7298 | } |