Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [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 | ------------------------------------------------------------------------ * |
| 24 | |
| 25 | |
| 26 | \file wlan_hdd_wext.c |
| 27 | |
| 28 | \brief Airgo Linux Wireless Extensions Common Control Plane Types and |
| 29 | interfaces. |
| 30 | |
| 31 | $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $ |
| 32 | |
| 33 | Copyright (C) 2007 Airgo Networks, Incorporated |
| 34 | |
| 35 | This file defines all of the types that are utilized by the CCP module |
| 36 | of the "Portable" HDD. This file also includes the underlying Linux |
| 37 | Wireless Extensions Data types referred to by CCP. |
| 38 | |
| 39 | ======================================================================== */ |
| 40 | |
| 41 | #include <linux/version.h> |
| 42 | #include <linux/module.h> |
| 43 | #include <linux/kernel.h> |
| 44 | #include <linux/init.h> |
| 45 | #include <linux/wireless.h> |
| 46 | #include <wlan_hdd_includes.h> |
| 47 | #include <wlan_btc_svc.h> |
| 48 | #include <wlan_nlink_common.h> |
| 49 | #ifdef WLAN_BTAMP_FEATURE |
| 50 | #include <bap_hdd_main.h> |
| 51 | #endif |
| 52 | #include <vos_api.h> |
| 53 | #include <net/arp.h> |
| 54 | #include "ccmApi.h" |
| 55 | #include "sirParams.h" |
| 56 | #include "csrApi.h" |
| 57 | #include "csrInsideApi.h" |
| 58 | #if defined WLAN_FEATURE_VOWIFI |
| 59 | #include "smeRrmInternal.h" |
| 60 | #endif |
| 61 | #include <aniGlobal.h> |
| 62 | #include "dot11f.h" |
| 63 | #include <wlan_hdd_wowl.h> |
| 64 | #include <wlan_hdd_cfg.h> |
| 65 | #include <wlan_hdd_wmm.h> |
| 66 | #include "utilsApi.h" |
| 67 | #ifdef WLAN_FEATURE_P2P |
| 68 | #include "wlan_hdd_p2p.h" |
| 69 | #endif |
| 70 | |
| 71 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 72 | #include <linux/earlysuspend.h> |
| 73 | #endif |
| 74 | #include "wlan_hdd_power.h" |
| 75 | #include "qwlan_version.h" |
| 76 | #include <vos_power.h> |
| 77 | #include "wlan_hdd_host_offload.h" |
| 78 | #include "wlan_hdd_keep_alive.h" |
| 79 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 80 | #include "wlan_hdd_packet_filtering.h" |
| 81 | #endif |
| 82 | |
| 83 | #ifdef CONFIG_CFG80211 |
| 84 | #include <linux/wireless.h> |
| 85 | #include <net/cfg80211.h> |
| 86 | #endif |
| 87 | #ifdef FEATURE_WLAN_INTEGRATED_SOC |
| 88 | #include "wlan_qct_pal_trace.h" |
| 89 | #endif // FEATURE_WLAN_INTEGRATED_SOC |
| 90 | |
| 91 | #include "wlan_hdd_misc.h" |
| 92 | #include "bap_hdd_misc.h" |
| 93 | |
| 94 | #include "wlan_hdd_dev_pwr.h" |
| 95 | #include "qc_sap_ioctl.h" |
| 96 | #define WE_MAX_STR_LEN 1024 |
| 97 | |
| 98 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 99 | extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend); |
| 100 | extern void hdd_resume_wlan(struct early_suspend *wlan_suspend); |
| 101 | #endif |
| 102 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 103 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 104 | #define MAX_OEM_DATA_RSP_LEN 1024 |
| 105 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 106 | |
| 107 | #define HDD_FINISH_ULA_TIME_OUT 800 |
| 108 | |
| 109 | extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand); |
| 110 | int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr); |
| 111 | |
| 112 | static int ioctl_debug = 0; |
| 113 | module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 114 | |
| 115 | struct statsContext |
| 116 | { |
| 117 | struct completion completion; |
| 118 | hdd_adapter_t *pAdapter; |
| 119 | unsigned int magic; |
| 120 | }; |
| 121 | |
| 122 | #define STATS_CONTEXT_MAGIC 0x53544154 //STAT |
| 123 | #define RSSI_CONTEXT_MAGIC 0x52535349 //RSSI |
| 124 | #define POWER_CONTEXT_MAGIC 0x504F5752 // POWR |
| 125 | |
| 126 | /* To Validate Channel against the Frequency and Vice-Versa */ |
| 127 | static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2}, |
| 128 | {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8}, |
| 129 | {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13}, |
| 130 | {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252}, |
| 131 | {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44}, |
| 132 | {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100}, |
| 133 | {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120}, |
| 134 | {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140}, |
| 135 | {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165} }; |
| 136 | |
| 137 | #define FREQ_CHAN_MAP_TABLE_SIZE sizeof(freq_chan_map)/sizeof(freq_chan_map[0]) |
| 138 | |
| 139 | /* Private ioctls and their sub-ioctls */ |
| 140 | #define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0) |
| 141 | #define WE_SET_11D_STATE 1 |
| 142 | #define WE_WOWL 2 |
| 143 | #define WE_SET_POWER 3 |
| 144 | #define WE_SET_MAX_ASSOC 4 |
| 145 | #define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5 |
| 146 | #define WE_SET_DATA_INACTIVITY_TO 6 |
| 147 | #define WE_SET_MAX_TX_POWER 7 |
| 148 | #define WE_SET_HIGHER_DTIM_TRANSITION 8 |
| 149 | #define WE_SET_TM_LEVEL 9 |
| 150 | |
| 151 | /* Private ioctls and their sub-ioctls */ |
| 152 | #define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1) |
| 153 | #define WE_GET_11D_STATE 1 |
| 154 | #define WE_IBSS_STATUS 2 |
| 155 | #define WE_PMC_STATE 3 |
| 156 | #define WE_GET_WLAN_DBG 4 |
| 157 | #define WE_MODULE_DOWN_IND 5 |
| 158 | #define WE_GET_MAX_ASSOC 6 |
| 159 | #define WE_GET_WDI_DBG 7 |
| 160 | #define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8 |
| 161 | #define WE_GET_CONCURRENCY_MODE 9 |
| 162 | /* Private ioctls and their sub-ioctls */ |
| 163 | #define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2) |
| 164 | |
| 165 | /* Private ioctls and their sub-ioctls */ |
| 166 | #define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3) |
| 167 | #define WE_WOWL_ADD_PTRN 1 |
| 168 | #define WE_WOWL_DEL_PTRN 2 |
| 169 | #if defined WLAN_FEATURE_VOWIFI |
| 170 | #define WE_NEIGHBOR_REPORT_REQUEST 3 |
| 171 | #endif |
| 172 | #define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie. |
| 173 | #define WE_SET_CONFIG 5 |
| 174 | |
| 175 | /* Private ioctls and their sub-ioctls */ |
| 176 | #define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4) |
| 177 | #define WE_SET_WLAN_DBG 1 |
| 178 | #define WE_SET_WDI_DBG 2 |
| 179 | #define WE_SET_SAP_CHANNELS 3 |
| 180 | |
| 181 | /* Private ioctls and their sub-ioctls */ |
| 182 | #define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5) |
| 183 | #define WE_WLAN_VERSION 1 |
| 184 | #define WE_GET_STATS 2 |
| 185 | #define WE_GET_CFG 3 |
| 186 | #define WE_GET_WMM_STATUS 4 |
| 187 | #define WE_GET_CHANNEL_LIST 5 |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 188 | #ifdef WLAN_FEATURE_11AC |
| 189 | #define WE_GET_RSSI 6 |
| 190 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 191 | |
| 192 | /* Private ioctls and their sub-ioctls */ |
| 193 | #define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6) |
| 194 | #define WE_CLEAR_STATS 1 |
| 195 | #define WE_INIT_AP 2 |
| 196 | #define WE_STOP_AP 3 |
| 197 | #define WE_ENABLE_AMP 4 |
| 198 | #define WE_DISABLE_AMP 5 |
| 199 | |
| 200 | /* Private ioctls and their sub-ioctls */ |
| 201 | #define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7) |
| 202 | #define WE_LOG_DUMP_CMD 1 |
| 203 | |
| 204 | #ifdef WLAN_FEATURE_P2P |
| 205 | #define WE_P2P_NOA_CMD 2 |
| 206 | #endif |
| 207 | |
| 208 | #define MAX_VAR_ARGS 7 |
| 209 | |
| 210 | /* Private ioctls (with no sub-ioctls) */ |
| 211 | /* note that they must be odd so that they have "get" semantics */ |
| 212 | #define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9) |
| 213 | #define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11) |
| 214 | #define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13) |
| 215 | |
| 216 | #ifdef FEATURE_WLAN_WAPI |
| 217 | /* Private ioctls EVEN NO: SET, ODD NO:GET */ |
| 218 | #define WLAN_PRIV_SET_WAPI_MODE (SIOCIWFIRSTPRIV + 8) |
| 219 | #define WLAN_PRIV_GET_WAPI_MODE (SIOCIWFIRSTPRIV + 16) |
| 220 | #define WLAN_PRIV_SET_WAPI_ASSOC_INFO (SIOCIWFIRSTPRIV + 10) |
| 221 | #define WLAN_PRIV_SET_WAPI_KEY (SIOCIWFIRSTPRIV + 12) |
| 222 | #define WLAN_PRIV_SET_WAPI_BKID (SIOCIWFIRSTPRIV + 14) |
| 223 | #define WLAN_PRIV_GET_WAPI_BKID (SIOCIWFIRSTPRIV + 15) |
| 224 | #define WAPI_PSK_AKM_SUITE 0x02721400 |
| 225 | #define WAPI_CERT_AKM_SUITE 0x01721400 |
| 226 | #endif |
| 227 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 228 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 229 | /* Private ioctls for setting the measurement configuration */ |
| 230 | #define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17) |
| 231 | #define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19) |
| 232 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 233 | |
| 234 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 235 | #define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20) |
| 236 | #endif |
| 237 | |
| 238 | /* Private ioctl for setting the host offload feature */ |
| 239 | #define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18) |
| 240 | |
| 241 | /* Private ioctl to get the statistics */ |
| 242 | #define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21) |
| 243 | |
| 244 | /* Private ioctl to set the Keep Alive Params */ |
| 245 | #define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22) |
| 246 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 247 | /* Private ioctl to set the Packet Filtering Params */ |
| 248 | #define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23) |
| 249 | #endif |
| 250 | |
| 251 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 252 | /* Private ioctl to get the statistics */ |
| 253 | #define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24) |
| 254 | #endif |
| 255 | |
| 256 | #define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/ |
| 257 | |
| 258 | #define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26) |
| 259 | #define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27) |
| 260 | #define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29) |
| 261 | #define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31) |
| 262 | |
| 263 | #define WLAN_STATS_INVALID 0 |
| 264 | #define WLAN_STATS_RETRY_CNT 1 |
| 265 | #define WLAN_STATS_MUL_RETRY_CNT 2 |
| 266 | #define WLAN_STATS_TX_FRM_CNT 3 |
| 267 | #define WLAN_STATS_RX_FRM_CNT 4 |
| 268 | #define WLAN_STATS_FRM_DUP_CNT 5 |
| 269 | #define WLAN_STATS_FAIL_CNT 6 |
| 270 | #define WLAN_STATS_RTS_FAIL_CNT 7 |
| 271 | #define WLAN_STATS_ACK_FAIL_CNT 8 |
| 272 | #define WLAN_STATS_RTS_SUC_CNT 9 |
| 273 | #define WLAN_STATS_RX_DISCARD_CNT 10 |
| 274 | #define WLAN_STATS_RX_ERROR_CNT 11 |
| 275 | #define WLAN_STATS_TX_BYTE_CNT 12 |
| 276 | |
| 277 | #define WLAN_STATS_RX_BYTE_CNT 13 |
| 278 | #define WLAN_STATS_RX_RATE 14 |
| 279 | #define WLAN_STATS_TX_RATE 15 |
| 280 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 281 | #define WLAN_STATS_RX_UC_BYTE_CNT 16 |
| 282 | #define WLAN_STATS_RX_MC_BYTE_CNT 17 |
| 283 | #define WLAN_STATS_RX_BC_BYTE_CNT 18 |
| 284 | #define WLAN_STATS_TX_UC_BYTE_CNT 19 |
| 285 | #define WLAN_STATS_TX_MC_BYTE_CNT 20 |
| 286 | #define WLAN_STATS_TX_BC_BYTE_CNT 21 |
| 287 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 288 | #define FILL_TLV(__p, __type, __size, __val, __tlen) \ |
| 289 | {\ |
| 290 | if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \ |
| 291 | {\ |
| 292 | *__p++ = __type;\ |
| 293 | *__p++ = __size;\ |
| 294 | memcpy(__p, __val, __size);\ |
| 295 | __p += __size;\ |
| 296 | __tlen += __size + 2;\ |
| 297 | }\ |
| 298 | else \ |
| 299 | { \ |
| 300 | hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!\n");\ |
| 301 | } \ |
| 302 | }while(0); |
| 303 | |
| 304 | #define VERSION_VALUE_MAX_LEN 32 |
| 305 | |
| 306 | #define TX_PER_TRACKING_DEFAULT_RATIO 5 |
| 307 | #define TX_PER_TRACKING_MAX_RATIO 10 |
| 308 | #define TX_PER_TRACKING_DEFAULT_WATERMARK 5 |
| 309 | |
| 310 | #define WLAN_HDD_UI_BAND_AUTO 0 |
| 311 | #define WLAN_HDD_UI_BAND_5_GHZ 1 |
| 312 | #define WLAN_HDD_UI_BAND_2_4_GHZ 2 |
| 313 | #define WLAN_HDD_UI_SET_BAND_VALUE_OFFSET 8 |
| 314 | |
| 315 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 316 | int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest, |
| 317 | v_U8_t sessionId); |
| 318 | void wlan_hdd_set_mc_addr_list(hdd_context_t *pHddCtx, v_U8_t set, v_U8_t sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 319 | #endif |
| 320 | |
| 321 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 322 | /**--------------------------------------------------------------------------- |
| 323 | |
| 324 | \brief hdd_wlan_get_version() - |
| 325 | |
| 326 | This function use to get Wlan Driver And Firmware Version. |
| 327 | |
| 328 | \param - pAdapter Pointer to the adapter. |
| 329 | wrqu - Pointer to IOCTL REQUEST Data. |
| 330 | extra - Pointer to char |
| 331 | |
| 332 | \return - 0 for success, non zero for failure |
| 333 | |
| 334 | --------------------------------------------------------------------------*/ |
| 335 | int hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu, |
| 336 | char *extra) |
| 337 | { |
| 338 | VOS_STATUS status; |
| 339 | FwVersionInfo fwversion; |
| 340 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 341 | v_U32_t reg_val; |
| 342 | char *buf = extra; |
| 343 | |
| 344 | buf += snprintf(buf, VERSION_VALUE_MAX_LEN, "%s_", WLAN_CHIP_VERSION); |
| 345 | /*Read the RevID*/ |
| 346 | status = sme_DbgReadRegister(hHal, QWLAN_RFAPB_REV_ID_REG, ®_val); |
| 347 | |
| 348 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) { |
| 349 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!\n", __func__); |
| 350 | return -EINVAL; |
| 351 | } |
| 352 | |
| 353 | buf += snprintf(buf, VERSION_VALUE_MAX_LEN, "%x.%x-", (v_U8_t)(reg_val >> 8), |
| 354 | (v_U8_t)(reg_val & 0x000000FF)); |
| 355 | |
| 356 | status = sme_GetFwVersion(hHal, &fwversion); |
| 357 | |
| 358 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) { |
| 359 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!\n", __func__); |
| 360 | return -EINVAL; |
| 361 | } |
| 362 | buf += snprintf(buf, VERSION_VALUE_MAX_LEN, "%s-", QWLAN_VERSIONSTR); |
| 363 | buf += snprintf(buf, VERSION_VALUE_MAX_LEN, "%ld.%ld.%ld.%ld", |
| 364 | fwversion.uMj, fwversion.uMn, |
| 365 | fwversion.uPatch, fwversion.uBuild); |
| 366 | wrqu->data.length = strlen(extra); |
| 367 | |
| 368 | return 0; |
| 369 | } |
| 370 | |
| 371 | #endif |
| 372 | int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu) |
| 373 | { |
| 374 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 375 | v_U32_t threshold = 0,status = 0; |
| 376 | |
| 377 | ENTER(); |
| 378 | |
| 379 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 380 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 381 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 382 | return status; |
| 383 | } |
| 384 | |
| 385 | if ( eHAL_STATUS_SUCCESS != |
| 386 | ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) ) |
| 387 | { |
| 388 | return -EIO; |
| 389 | } |
| 390 | wrqu->rts.value = threshold; |
| 391 | |
| 392 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 393 | ("Rts-Threshold=%ld!!\n"), wrqu->rts.value); |
| 394 | |
| 395 | EXIT(); |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu) |
| 401 | { |
| 402 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 403 | v_U32_t threshold = 0,status = 0; |
| 404 | |
| 405 | ENTER(); |
| 406 | |
| 407 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 408 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 409 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 410 | return status; |
| 411 | } |
| 412 | |
| 413 | if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold) |
| 414 | != eHAL_STATUS_SUCCESS ) |
| 415 | { |
| 416 | return -EIO; |
| 417 | } |
| 418 | wrqu->frag.value = threshold; |
| 419 | |
| 420 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 421 | ("Frag-Threshold=%ld!!\n"), wrqu->frag.value); |
| 422 | |
| 423 | EXIT(); |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq) |
| 429 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 430 | int i; |
| 431 | if (channel > 0) |
| 432 | { |
| 433 | for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) |
| 434 | { |
| 435 | if (channel == freq_chan_map[i].chan) |
| 436 | { |
| 437 | *pfreq = freq_chan_map[i].freq; |
| 438 | return 1; |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 443 | ("Invalid channel no=%d!!\n"), channel); |
| 444 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | static v_BOOL_t |
| 448 | hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType) |
| 449 | { |
| 450 | v_BOOL_t rsnType = VOS_FALSE; |
| 451 | // is the authType supported? |
| 452 | switch (authType) |
| 453 | { |
| 454 | case eCSR_AUTH_TYPE_NONE: //never used |
| 455 | rsnType = eANI_BOOLEAN_FALSE; |
| 456 | break; |
| 457 | // MAC layer authentication types |
| 458 | case eCSR_AUTH_TYPE_OPEN_SYSTEM: |
| 459 | rsnType = eANI_BOOLEAN_FALSE; |
| 460 | break; |
| 461 | case eCSR_AUTH_TYPE_SHARED_KEY: |
| 462 | rsnType = eANI_BOOLEAN_FALSE; |
| 463 | break; |
| 464 | case eCSR_AUTH_TYPE_AUTOSWITCH: |
| 465 | rsnType = eANI_BOOLEAN_FALSE; |
| 466 | break; |
| 467 | |
| 468 | // Upper layer authentication types |
| 469 | case eCSR_AUTH_TYPE_WPA: |
| 470 | rsnType = eANI_BOOLEAN_TRUE; |
| 471 | break; |
| 472 | case eCSR_AUTH_TYPE_WPA_PSK: |
| 473 | rsnType = eANI_BOOLEAN_TRUE; |
| 474 | break; |
| 475 | case eCSR_AUTH_TYPE_WPA_NONE: |
| 476 | rsnType = eANI_BOOLEAN_TRUE; |
| 477 | break; |
| 478 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 479 | case eCSR_AUTH_TYPE_FT_RSN: |
| 480 | #endif |
| 481 | case eCSR_AUTH_TYPE_RSN: |
| 482 | rsnType = eANI_BOOLEAN_TRUE; |
| 483 | break; |
| 484 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 485 | case eCSR_AUTH_TYPE_FT_RSN_PSK: |
| 486 | #endif |
| 487 | case eCSR_AUTH_TYPE_RSN_PSK: |
| 488 | rsnType = eANI_BOOLEAN_TRUE; |
| 489 | break; |
| 490 | //case eCSR_AUTH_TYPE_FAILED: |
| 491 | case eCSR_AUTH_TYPE_UNKNOWN: |
| 492 | rsnType = eANI_BOOLEAN_FALSE; |
| 493 | break; |
| 494 | default: |
| 495 | hddLog(LOGE, FL("%s called with unknown authType - default to Open, None\n"), |
| 496 | __FUNCTION__); |
| 497 | rsnType = eANI_BOOLEAN_FALSE; |
| 498 | break; |
| 499 | } |
| 500 | hddLog(LOGE, FL("%s called with authType: %d, returned: %d\n"), |
| 501 | __FUNCTION__, authType, rsnType); |
| 502 | return rsnType; |
| 503 | } |
| 504 | |
| 505 | static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext ) |
| 506 | { |
| 507 | struct statsContext *pStatsContext; |
| 508 | hdd_adapter_t *pAdapter; |
| 509 | |
| 510 | if (ioctl_debug) |
| 511 | { |
| 512 | pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n", |
| 513 | __FUNCTION__, (int)rssi, (int)staId, pContext); |
| 514 | } |
| 515 | |
| 516 | if (NULL == pContext) |
| 517 | { |
| 518 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 519 | "%s: Bad param, pContext [%p]", |
| 520 | __FUNCTION__, pContext); |
| 521 | return; |
| 522 | } |
| 523 | |
| 524 | /* there is a race condition that exists between this callback function |
| 525 | and the caller since the caller could time out either before or |
| 526 | while this code is executing. we'll assume the timeout hasn't |
| 527 | occurred, but we'll verify that right before we save our work */ |
| 528 | |
| 529 | pStatsContext = pContext; |
| 530 | pAdapter = pStatsContext->pAdapter; |
| 531 | if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic)) |
| 532 | { |
| 533 | /* the caller presumably timed out so there is nothing we can do */ |
| 534 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 535 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 536 | __FUNCTION__, pAdapter, pStatsContext->magic); |
| 537 | if (ioctl_debug) |
| 538 | { |
| 539 | pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n", |
| 540 | __FUNCTION__, pAdapter, pStatsContext->magic); |
| 541 | } |
| 542 | return; |
| 543 | } |
| 544 | |
| 545 | /* the race is on. caller could have timed out immediately after |
| 546 | we verified the magic, but if so, caller will wait a short time |
| 547 | for us to copy over the rssi */ |
| 548 | pAdapter->rssi = rssi; |
| 549 | |
| 550 | /* and notify the caller */ |
| 551 | complete(&pStatsContext->completion); |
| 552 | } |
| 553 | |
| 554 | VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value) |
| 555 | { |
| 556 | struct statsContext context; |
| 557 | hdd_context_t *pHddCtx; |
| 558 | hdd_station_ctx_t *pHddStaCtx; |
| 559 | eHalStatus hstatus; |
| 560 | long lrc; |
| 561 | |
| 562 | if (NULL == pAdapter) |
| 563 | { |
| 564 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 565 | "%s: Invalid context, pAdapter", __func__); |
| 566 | return VOS_STATUS_E_FAULT; |
| 567 | } |
| 568 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 569 | { |
| 570 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 571 | /* return a cached value */ |
| 572 | *rssi_value = pAdapter->rssi; |
| 573 | return VOS_STATUS_SUCCESS; |
| 574 | } |
| 575 | |
| 576 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 577 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 578 | |
| 579 | init_completion(&context.completion); |
| 580 | context.pAdapter = pAdapter; |
| 581 | context.magic = RSSI_CONTEXT_MAGIC; |
| 582 | |
| 583 | hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB, |
| 584 | pHddStaCtx->conn_info.staId[ 0 ], |
| 585 | pHddStaCtx->conn_info.bssId, |
| 586 | &context, pHddCtx->pvosContext); |
| 587 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 588 | { |
| 589 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI", |
| 590 | __FUNCTION__); |
| 591 | /* we'll returned a cached value below */ |
| 592 | } |
| 593 | else |
| 594 | { |
| 595 | /* request was sent -- wait for the response */ |
| 596 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 597 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
| 598 | /* either we have a response or we timed out |
| 599 | either way, first invalidate our magic */ |
| 600 | context.magic = 0; |
| 601 | if (lrc <= 0) |
| 602 | { |
| 603 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI ", |
| 604 | __FUNCTION__, (0 == lrc) ? "timeout" : "interrupt"); |
| 605 | /* there is a race condition such that the callback |
| 606 | function could be executing at the same time we are. of |
| 607 | primary concern is if the callback function had already |
| 608 | verified the "magic" but hasn't yet set the completion |
| 609 | variable. Since the completion variable is on our |
| 610 | stack, we'll delay just a bit to make sure the data is |
| 611 | still valid if that is the case */ |
| 612 | msleep(50); |
| 613 | /* we'll now returned a cached value below */ |
| 614 | } |
| 615 | } |
| 616 | *rssi_value = pAdapter->rssi; |
| 617 | |
| 618 | return VOS_STATUS_SUCCESS; |
| 619 | } |
| 620 | |
| 621 | void hdd_StatisticsCB( void *pStats, void *pContext ) |
| 622 | { |
| 623 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext; |
| 624 | hdd_stats_t *pStatsCache = NULL; |
| 625 | hdd_wext_state_t *pWextState; |
| 626 | VOS_STATUS vos_status = VOS_STATUS_SUCCESS; |
| 627 | |
| 628 | tCsrSummaryStatsInfo *pSummaryStats = NULL; |
| 629 | tCsrGlobalClassAStatsInfo *pClassAStats = NULL; |
| 630 | tCsrGlobalClassBStatsInfo *pClassBStats = NULL; |
| 631 | tCsrGlobalClassCStatsInfo *pClassCStats = NULL; |
| 632 | tCsrGlobalClassDStatsInfo *pClassDStats = NULL; |
| 633 | tCsrPerStaStatsInfo *pPerStaStats = NULL; |
| 634 | |
| 635 | if (pAdapter!= NULL) |
| 636 | pStatsCache = &pAdapter->hdd_stats; |
| 637 | |
| 638 | |
| 639 | pSummaryStats = (tCsrSummaryStatsInfo *)pStats; |
| 640 | pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 ); |
| 641 | pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 ); |
| 642 | pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 ); |
| 643 | pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 ); |
| 644 | pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 ); |
| 645 | |
| 646 | if (pStatsCache!=NULL) |
| 647 | { |
| 648 | // and copy the stats into the cache we keep in the adapter instance structure |
| 649 | vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) ); |
| 650 | vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) ); |
| 651 | vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) ); |
| 652 | vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) ); |
| 653 | vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) ); |
| 654 | vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) ); |
| 655 | } |
| 656 | |
| 657 | if(pAdapter) |
| 658 | { |
| 659 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 660 | if(pWextState) |
| 661 | { |
| 662 | vos_status = vos_event_set(&pWextState->vosevent); |
| 663 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 664 | { |
| 665 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 666 | "%s: vos_event_set failed", __FUNCTION__); |
| 667 | return; |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result) |
| 674 | { |
| 675 | v_CONTEXT_t pVosContext; |
| 676 | hdd_context_t *pHddCtx; |
| 677 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ); |
| 678 | #if 0 |
| 679 | hdd_wext_state_t *pWextState; |
| 680 | v_U32_t roamId; |
| 681 | #endif |
| 682 | |
| 683 | ENTER(); |
| 684 | |
| 685 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL); |
| 686 | |
| 687 | pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext); |
| 688 | if (NULL == pHddCtx) |
| 689 | { |
| 690 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __FUNCTION__); |
| 691 | return; |
| 692 | } |
| 693 | #if 0 |
| 694 | pWextState = pAdapter->pWextState; |
| 695 | #endif |
| 696 | |
| 697 | if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result) |
| 698 | { |
| 699 | //TODO Verify is this is really used. If yes need to fix it. |
| 700 | hdd_reconnect_all_adapters( pHddCtx ); |
| 701 | #if 0 |
| 702 | pAdapter->conn_info.connState = eConnectionState_NotConnected; |
| 703 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 704 | vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 705 | |
| 706 | if(VOS_STATUS_SUCCESS == vosStatus) |
| 707 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 708 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 709 | |
| 710 | sme_RoamConnect(halHandle, |
| 711 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 712 | &roamId); |
| 713 | #endif |
| 714 | } |
| 715 | |
| 716 | EXIT(); |
| 717 | |
| 718 | } |
| 719 | |
| 720 | void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter) |
| 721 | { |
| 722 | int i = 0; |
| 723 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 724 | |
| 725 | /* clear WPA/RSN/WSC IE information in the profile */ |
| 726 | pWextState->roamProfile.nWPAReqIELength = 0; |
| 727 | pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL; |
| 728 | pWextState->roamProfile.nRSNReqIELength = 0; |
| 729 | pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL; |
| 730 | |
| 731 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 732 | pWextState->roamProfile.pAddIEScan = (tANI_U8 *)NULL; |
| 733 | pWextState->roamProfile.nAddIEScanLength = 0; |
| 734 | pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL; |
| 735 | pWextState->roamProfile.nAddIEAssocLength = 0; |
| 736 | |
| 737 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 738 | pWextState->roamProfile.EncryptionType.encryptionType[0] |
| 739 | = eCSR_ENCRYPT_TYPE_NONE; |
| 740 | |
| 741 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 742 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] |
| 743 | = eCSR_ENCRYPT_TYPE_NONE; |
| 744 | |
| 745 | pWextState->roamProfile.AuthType.numEntries = 1; |
| 746 | pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 747 | |
| 748 | pWextState->authKeyMgmt = 0; |
| 749 | |
| 750 | for (i=0; i < CSR_MAX_NUM_KEY; i++) |
| 751 | { |
| 752 | if (pWextState->roamProfile.Keys.KeyMaterial[i]) |
| 753 | { |
| 754 | pWextState->roamProfile.Keys.KeyLength[i] = 0; |
| 755 | } |
| 756 | } |
| 757 | #ifdef FEATURE_WLAN_WAPI |
| 758 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN; |
| 759 | pAdapter->wapi_info.nWapiMode = 0; |
| 760 | #endif |
| 761 | |
| 762 | vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN); |
| 763 | |
| 764 | } |
| 765 | |
| 766 | void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext) |
| 767 | { |
| 768 | hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext; |
| 769 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 770 | |
| 771 | complete(&pWextState->completion_var); |
| 772 | } |
| 773 | |
| 774 | VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter) |
| 775 | { |
| 776 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 777 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 778 | VOS_STATUS vos_status; |
| 779 | |
| 780 | if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated) |
| 781 | { |
| 782 | INIT_COMPLETION(pWextState->completion_var); |
| 783 | |
| 784 | /*To avoid race condition between the set key and the last EAPOL |
| 785 | packet, notify TL to finish upper layer authentication incase if the |
| 786 | last EAPOL packet pending in the TL queue.*/ |
| 787 | vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb,pAdapter); |
| 788 | |
| 789 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 790 | { |
| 791 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 792 | "[%4d] WLANTL_Finish_ULA returned ERROR status= %d", |
| 793 | __LINE__, vos_status ); |
| 794 | return vos_status; |
| 795 | |
| 796 | } |
| 797 | |
| 798 | wait_for_completion_timeout(&pWextState->completion_var, |
| 799 | msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT)); |
| 800 | } |
| 801 | return VOS_STATUS_SUCCESS; |
| 802 | } |
| 803 | |
| 804 | v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len) |
| 805 | { |
| 806 | |
| 807 | int left = ie_len; |
| 808 | v_U8_t *ptr = ie; |
| 809 | v_U8_t elem_id,elem_len; |
| 810 | v_U8_t eid = 0xDD; |
| 811 | |
| 812 | if ( NULL == ie || 0 == ie_len ) |
| 813 | return NULL; |
| 814 | |
| 815 | while(left >= 2) |
| 816 | { |
| 817 | elem_id = ptr[0]; |
| 818 | elem_len = ptr[1]; |
| 819 | left -= 2; |
| 820 | if(elem_len > left) |
| 821 | { |
| 822 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 823 | "****Invalid IEs eid = %d elem_len=%d left=%d*****\n", |
| 824 | eid,elem_len,left); |
| 825 | return NULL; |
| 826 | } |
| 827 | if (elem_id == eid) |
| 828 | { |
| 829 | if(memcmp( &ptr[2], oui, oui_size)==0) |
| 830 | return ptr; |
| 831 | } |
| 832 | |
| 833 | left -= elem_len; |
| 834 | ptr += (elem_len + 2); |
| 835 | } |
| 836 | return NULL; |
| 837 | } |
| 838 | |
| 839 | static int iw_set_commit(struct net_device *dev, struct iw_request_info *info, |
| 840 | union iwreq_data *wrqu, char *extra) |
| 841 | { |
| 842 | hddLog( LOG1, "In %s\n", __FUNCTION__); |
| 843 | /* Do nothing for now */ |
| 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | static int iw_get_name(struct net_device *dev, |
| 848 | struct iw_request_info *info, |
| 849 | char *wrqu, char *extra) |
| 850 | { |
| 851 | |
| 852 | ENTER(); |
| 853 | strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ); |
| 854 | EXIT(); |
| 855 | return 0; |
| 856 | } |
| 857 | |
| 858 | static int iw_set_mode(struct net_device *dev, |
| 859 | struct iw_request_info *info, |
| 860 | union iwreq_data *wrqu, char *extra) |
| 861 | { |
| 862 | hdd_wext_state_t *pWextState; |
| 863 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 864 | tCsrRoamProfile *pRoamProfile; |
| 865 | eCsrRoamBssType LastBSSType; |
| 866 | eMib_dot11DesiredBssType connectedBssType; |
| 867 | hdd_config_t *pConfig; |
| 868 | #ifdef CONFIG_CFG80211 |
| 869 | struct wireless_dev *wdev; |
| 870 | #endif |
| 871 | |
| 872 | ENTER(); |
| 873 | |
| 874 | if (NULL == pAdapter) |
| 875 | { |
| 876 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 877 | "%s: Invalid context, pAdapter", __func__); |
| 878 | return 0; |
| 879 | } |
| 880 | |
| 881 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 882 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 883 | return 0; |
| 884 | } |
| 885 | |
| 886 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 887 | if (pWextState == NULL) |
| 888 | { |
| 889 | hddLog (LOGE, "%s ERROR: Data Storage Corruption", __FUNCTION__); |
| 890 | return -EINVAL; |
| 891 | } |
| 892 | |
| 893 | #ifdef CONFIG_CFG80211 |
| 894 | wdev = dev->ieee80211_ptr; |
| 895 | #endif |
| 896 | pRoamProfile = &pWextState->roamProfile; |
| 897 | LastBSSType = pRoamProfile->BSSType; |
| 898 | |
| 899 | hddLog( LOG1,"%s Old Bss type = %d", __FUNCTION__, LastBSSType); |
| 900 | |
| 901 | switch (wrqu->mode) |
| 902 | { |
| 903 | case IW_MODE_ADHOC: |
| 904 | hddLog( LOG1,"%s Setting AP Mode as IW_MODE_ADHOC", __FUNCTION__); |
| 905 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 906 | // Set the phymode correctly for IBSS. |
| 907 | pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 908 | pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
| 909 | #ifdef CONFIG_CFG80211 |
| 910 | wdev->iftype = NL80211_IFTYPE_ADHOC; |
| 911 | #endif |
| 912 | break; |
| 913 | case IW_MODE_INFRA: |
| 914 | hddLog( LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __FUNCTION__); |
| 915 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
| 916 | #ifdef CONFIG_CFG80211 |
| 917 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 918 | #endif |
| 919 | break; |
| 920 | case IW_MODE_AUTO: |
| 921 | hddLog(LOG1,"%s Setting AP Mode as IW_MODE_AUTO", __FUNCTION__); |
| 922 | pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY; |
| 923 | break; |
| 924 | default: |
| 925 | hddLog(LOG1,"%s Unknown AP Mode value", __FUNCTION__); |
| 926 | return -EOPNOTSUPP; |
| 927 | } |
| 928 | |
| 929 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 930 | { |
| 931 | //the BSS mode changed |
| 932 | // We need to issue disconnect if connected or in IBSS disconnect state |
| 933 | if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 934 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 935 | { |
| 936 | VOS_STATUS vosStatus; |
| 937 | // need to issue a disconnect to CSR. |
| 938 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 939 | vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 940 | pAdapter->sessionId, |
| 941 | eCSR_DISCONNECT_REASON_IBSS_LEAVE ); |
| 942 | if(VOS_STATUS_SUCCESS == vosStatus) |
| 943 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 944 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | |
| 949 | |
| 950 | EXIT(); |
| 951 | return 0; |
| 952 | } |
| 953 | |
| 954 | |
| 955 | static int iw_get_mode(struct net_device *dev, |
| 956 | struct iw_request_info *info, |
| 957 | v_U32_t *uwrq, char *extra) |
| 958 | { |
| 959 | |
| 960 | hdd_wext_state_t *pWextState; |
| 961 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 962 | |
| 963 | hddLog (LOG1, "In %s",__FUNCTION__); |
| 964 | |
| 965 | if (NULL == pAdapter) |
| 966 | { |
| 967 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 968 | "%s: Invalid context, pAdapter", __func__); |
| 969 | return 0; |
| 970 | } |
| 971 | |
| 972 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 973 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 978 | if (pWextState == NULL) |
| 979 | { |
| 980 | hddLog (LOGE, "%s ERROR: Data Storage Corruption", __FUNCTION__); |
| 981 | return -EINVAL; |
| 982 | } |
| 983 | |
| 984 | switch (pWextState->roamProfile.BSSType) |
| 985 | { |
| 986 | case eCSR_BSS_TYPE_INFRASTRUCTURE: |
| 987 | hddLog(LOG1, "%s returns IW_MODE_INFRA\n", __FUNCTION__); |
| 988 | *uwrq = IW_MODE_INFRA ; |
| 989 | break; |
| 990 | case eCSR_BSS_TYPE_IBSS: |
| 991 | case eCSR_BSS_TYPE_START_IBSS: |
| 992 | hddLog( LOG1,"%s returns IW_MODE_ADHOC\n", __FUNCTION__); |
| 993 | *uwrq= IW_MODE_ADHOC; |
| 994 | break; |
| 995 | case eCSR_BSS_TYPE_ANY: |
| 996 | hddLog( LOG1,"%s returns IW_MODE_AUTO\n", __FUNCTION__); |
| 997 | *uwrq= IW_MODE_AUTO; |
| 998 | break; |
| 999 | default: |
| 1000 | hddLog( LOG1,"%s returns APMODE_UNKNOWN\n", __FUNCTION__); |
| 1001 | break; |
| 1002 | } |
| 1003 | return 0; |
| 1004 | } |
| 1005 | |
| 1006 | static int iw_set_freq(struct net_device *dev, struct iw_request_info *info, |
| 1007 | union iwreq_data *wrqu, char *extra) |
| 1008 | { |
| 1009 | v_U32_t numChans = 0; |
| 1010 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1011 | v_U32_t indx = 0; |
| 1012 | v_U32_t status = 0; |
| 1013 | |
| 1014 | hdd_wext_state_t *pWextState; |
| 1015 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1016 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1017 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1018 | tCsrRoamProfile * pRoamProfile; |
| 1019 | ENTER(); |
| 1020 | |
| 1021 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1022 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1023 | return status; |
| 1024 | } |
| 1025 | |
| 1026 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1027 | |
| 1028 | pRoamProfile = &pWextState->roamProfile; |
| 1029 | |
| 1030 | hddLog(LOG1,"setCHANNEL ioctl\n"); |
| 1031 | |
| 1032 | /* Link is up then return cant set channel*/ |
| 1033 | if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState || |
| 1034 | eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 1035 | { |
| 1036 | hddLog( LOGE, "IBSS Associated\n"); |
| 1037 | return -EOPNOTSUPP; |
| 1038 | } |
| 1039 | |
| 1040 | /* Settings by Frequency as input */ |
| 1041 | if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) && |
| 1042 | (wrqu->freq.m <= (tANI_U32)5.825e8)) |
| 1043 | { |
| 1044 | tANI_U32 freq = wrqu->freq.m / 100000; |
| 1045 | |
| 1046 | while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq)) |
| 1047 | indx++; |
| 1048 | if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) |
| 1049 | { |
| 1050 | return -EINVAL; |
| 1051 | } |
| 1052 | wrqu->freq.e = 0; |
| 1053 | wrqu->freq.m = freq_chan_map[indx].chan; |
| 1054 | |
| 1055 | } |
| 1056 | |
| 1057 | if (wrqu->freq.e == 0) |
| 1058 | { |
| 1059 | if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) || |
| 1060 | (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 1061 | { |
| 1062 | hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d\n", |
| 1063 | __FUNCTION__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1064 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1065 | return -EINVAL; |
| 1066 | } |
| 1067 | |
| 1068 | numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1069 | |
| 1070 | if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1071 | validChan, &numChans) != eHAL_STATUS_SUCCESS){ |
| 1072 | return -EIO; |
| 1073 | } |
| 1074 | |
| 1075 | for (indx = 0; indx < numChans; indx++) { |
| 1076 | if (wrqu->freq.m == validChan[indx]){ |
| 1077 | break; |
| 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | else{ |
| 1082 | |
| 1083 | return -EINVAL; |
| 1084 | } |
| 1085 | |
| 1086 | if(indx >= numChans) |
| 1087 | { |
| 1088 | return -EINVAL; |
| 1089 | } |
| 1090 | |
| 1091 | /* Set the Operational Channel */ |
| 1092 | numChans = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1093 | pHddStaCtx->conn_info.operationChannel = wrqu->freq.m; |
| 1094 | pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel; |
| 1095 | |
| 1096 | hddLog(LOG1,"pRoamProfile->operationChannel = %d\n", wrqu->freq.m); |
| 1097 | |
| 1098 | EXIT(); |
| 1099 | |
| 1100 | return status; |
| 1101 | } |
| 1102 | |
| 1103 | static int iw_get_freq(struct net_device *dev, struct iw_request_info *info, |
| 1104 | struct iw_freq *fwrq, char *extra) |
| 1105 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1106 | v_U32_t status = FALSE, channel = 0, freq = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1107 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1108 | tHalHandle hHal; |
| 1109 | hdd_wext_state_t *pWextState; |
| 1110 | tCsrRoamProfile * pRoamProfile; |
| 1111 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1112 | |
| 1113 | ENTER(); |
| 1114 | |
| 1115 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1116 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1117 | return status; |
| 1118 | } |
| 1119 | |
| 1120 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1121 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1122 | |
| 1123 | pRoamProfile = &pWextState->roamProfile; |
| 1124 | |
| 1125 | if( pHddStaCtx->conn_info.connState== eConnectionState_Associated ) |
| 1126 | { |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1127 | if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1128 | { |
| 1129 | return -EIO; |
| 1130 | } |
| 1131 | else |
| 1132 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1133 | status = hdd_wlan_get_freq(channel, &freq); |
| 1134 | if( TRUE == status ) |
| 1135 | { |
| 1136 | /* Set Exponent parameter as 6 (MHZ) in struct iw_freq |
| 1137 | * iwlist & iwconfig command shows frequency into proper |
| 1138 | * format (2.412 GHz instead of 246.2 MHz)*/ |
| 1139 | fwrq->m = freq; |
| 1140 | fwrq->e = MHZ; |
| 1141 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | else |
| 1145 | { |
| 1146 | channel = pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1147 | status = hdd_wlan_get_freq(channel, &freq); |
| 1148 | if( TRUE == status ) |
| 1149 | { |
| 1150 | /* Set Exponent parameter as 6 (MHZ) in struct iw_freq |
| 1151 | * iwlist & iwconfig command shows frequency into proper |
| 1152 | * format (2.412 GHz instead of 246.2 MHz)*/ |
| 1153 | fwrq->m = freq; |
| 1154 | fwrq->e = MHZ; |
| 1155 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1156 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1157 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | static int iw_get_tx_power(struct net_device *dev, |
| 1161 | struct iw_request_info *info, |
| 1162 | union iwreq_data *wrqu, char *extra) |
| 1163 | { |
| 1164 | |
| 1165 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1166 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1167 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1168 | |
| 1169 | if (pHddCtx->isLogpInProgress) |
| 1170 | { |
| 1171 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 1172 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1173 | return -EBUSY; |
| 1174 | } |
| 1175 | |
| 1176 | if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 1177 | { |
| 1178 | wrqu->txpower.value = 0; |
| 1179 | return 0; |
| 1180 | } |
| 1181 | wlan_hdd_get_classAstats(pAdapter); |
| 1182 | wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 1183 | |
| 1184 | return 0; |
| 1185 | } |
| 1186 | |
| 1187 | static int iw_set_tx_power(struct net_device *dev, |
| 1188 | struct iw_request_info *info, |
| 1189 | union iwreq_data *wrqu, char *extra) |
| 1190 | { |
| 1191 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1192 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1193 | |
| 1194 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 1195 | { |
| 1196 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | ENTER(); |
| 1201 | |
| 1202 | if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS ) |
| 1203 | { |
| 1204 | return -EIO; |
| 1205 | } |
| 1206 | |
| 1207 | EXIT(); |
| 1208 | |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
| 1212 | static int iw_get_bitrate(struct net_device *dev, |
| 1213 | struct iw_request_info *info, |
| 1214 | union iwreq_data *wrqu, char *extra) |
| 1215 | { |
| 1216 | VOS_STATUS vos_status = VOS_STATUS_SUCCESS; |
| 1217 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1218 | hdd_wext_state_t *pWextState; |
| 1219 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1220 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1221 | |
| 1222 | ENTER(); |
| 1223 | |
| 1224 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1225 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1226 | return status; |
| 1227 | } |
| 1228 | |
| 1229 | if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
| 1230 | wrqu->bitrate.value = 0; |
| 1231 | } |
| 1232 | else { |
| 1233 | status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD, |
| 1234 | SME_SUMMARY_STATS | |
| 1235 | SME_GLOBAL_CLASSA_STATS | |
| 1236 | SME_GLOBAL_CLASSB_STATS | |
| 1237 | SME_GLOBAL_CLASSC_STATS | |
| 1238 | SME_GLOBAL_CLASSD_STATS | |
| 1239 | SME_PER_STA_STATS, |
| 1240 | hdd_StatisticsCB, 0, FALSE, |
| 1241 | pHddStaCtx->conn_info.staId[0], pAdapter ); |
| 1242 | |
| 1243 | if(eHAL_STATUS_SUCCESS != status) |
| 1244 | { |
| 1245 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1246 | "%s: Unable to retrieve statistics", |
| 1247 | __FUNCTION__); |
| 1248 | return status; |
| 1249 | } |
| 1250 | |
| 1251 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1252 | |
| 1253 | vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS); |
| 1254 | |
| 1255 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1256 | { |
| 1257 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1258 | "%s: SME timeout while retrieving statistics", |
| 1259 | __FUNCTION__); |
| 1260 | return VOS_STATUS_E_FAILURE; |
| 1261 | } |
| 1262 | |
| 1263 | wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000; |
| 1264 | } |
| 1265 | |
| 1266 | EXIT(); |
| 1267 | |
| 1268 | return vos_status; |
| 1269 | } |
| 1270 | /* ccm call back function */ |
| 1271 | |
| 1272 | static int iw_set_bitrate(struct net_device *dev, |
| 1273 | struct iw_request_info *info, |
| 1274 | union iwreq_data *wrqu, |
| 1275 | char *extra) |
| 1276 | { |
| 1277 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1278 | hdd_wext_state_t *pWextState; |
| 1279 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1280 | v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN]; |
| 1281 | v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN; |
| 1282 | v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN; |
| 1283 | v_U32_t i, rate; |
| 1284 | v_U32_t valid_rate = FALSE, active_phy_mode = 0; |
| 1285 | |
| 1286 | ENTER(); |
| 1287 | |
| 1288 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1289 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1290 | return 0; |
| 1291 | } |
| 1292 | |
| 1293 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1294 | |
| 1295 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 1296 | { |
| 1297 | return -ENXIO ; |
| 1298 | } |
| 1299 | |
| 1300 | rate = wrqu->bitrate.value; |
| 1301 | |
| 1302 | if (rate == -1) |
| 1303 | { |
| 1304 | rate = WNI_CFG_FIXED_RATE_AUTO; |
| 1305 | valid_rate = TRUE; |
| 1306 | } |
| 1307 | else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1308 | WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS) |
| 1309 | { |
| 1310 | if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G |
| 1311 | || active_phy_mode == WNI_CFG_DOT11_MODE_11B) |
| 1312 | { |
| 1313 | if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1314 | WNI_CFG_SUPPORTED_RATES_11A, |
| 1315 | supp_rates, &a_len) == eHAL_STATUS_SUCCESS) && |
| 1316 | (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1317 | WNI_CFG_SUPPORTED_RATES_11B, |
| 1318 | supp_rates, &b_len) == eHAL_STATUS_SUCCESS)) |
| 1319 | { |
| 1320 | for (i = 0; i < (b_len + a_len); ++i) |
| 1321 | { |
| 1322 | /* supported rates returned is double the actual rate so we divide it by 2 */ |
| 1323 | if ((supp_rates[i]&0x7F)/2 == rate) |
| 1324 | { |
| 1325 | valid_rate = TRUE; |
| 1326 | rate = i + WNI_CFG_FIXED_RATE_1MBPS; |
| 1327 | break; |
| 1328 | } |
| 1329 | } |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | if (valid_rate != TRUE) |
| 1334 | { |
| 1335 | return -EINVAL; |
| 1336 | } |
| 1337 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1338 | WNI_CFG_FIXED_RATE, rate, |
| 1339 | ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 1340 | { |
| 1341 | return -EIO; |
| 1342 | } |
| 1343 | return 0; |
| 1344 | } |
| 1345 | |
| 1346 | |
| 1347 | static int iw_set_genie(struct net_device *dev, |
| 1348 | struct iw_request_info *info, |
| 1349 | union iwreq_data *wrqu, |
| 1350 | char *extra) |
| 1351 | { |
| 1352 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1353 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1354 | u_int8_t *genie; |
| 1355 | v_U16_t remLen; |
| 1356 | |
| 1357 | ENTER(); |
| 1358 | if(!wrqu->data.length) { |
| 1359 | hdd_clearRoamProfileIe(pAdapter); |
| 1360 | EXIT(); |
| 1361 | return 0; |
| 1362 | } |
| 1363 | |
| 1364 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1365 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1366 | return 0; |
| 1367 | } |
| 1368 | |
| 1369 | genie = wrqu->data.pointer; |
| 1370 | remLen = wrqu->data.length; |
| 1371 | |
| 1372 | hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]\n", genie[0], genie[1]); |
| 1373 | |
| 1374 | /* clear any previous genIE before this call */ |
| 1375 | memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) ); |
| 1376 | |
| 1377 | while (remLen >= 2) |
| 1378 | { |
| 1379 | v_U16_t eLen = 0; |
| 1380 | v_U8_t elementId; |
| 1381 | elementId = *genie++; |
| 1382 | eLen = *genie++; |
| 1383 | remLen -= 2; |
| 1384 | |
| 1385 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n", |
| 1386 | __func__, elementId, eLen); |
| 1387 | |
| 1388 | switch ( elementId ) |
| 1389 | { |
| 1390 | case IE_EID_VENDOR: |
| 1391 | if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */ |
| 1392 | return -EINVAL; |
| 1393 | |
| 1394 | if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
| 1395 | { |
| 1396 | v_U16_t curGenIELen = pWextState->genIE.length; |
| 1397 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)", |
| 1398 | __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2); |
| 1399 | |
| 1400 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) ) |
| 1401 | { |
| 1402 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. " |
| 1403 | "Need bigger buffer space\n"); |
| 1404 | VOS_ASSERT(0); |
| 1405 | return -ENOMEM; |
| 1406 | } |
| 1407 | // save to Additional IE ; it should be accumulated to handle WPS IE + other IE |
| 1408 | memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2); |
| 1409 | pWextState->genIE.length += eLen + 2; |
| 1410 | } |
| 1411 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 1412 | { |
| 1413 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 1414 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 1415 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)); |
| 1416 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 1417 | pWextState->roamProfile.nWPAReqIELength = eLen + 2; |
| 1418 | } |
| 1419 | else /* any vendorId except WPA IE should be accumulated to genIE */ |
| 1420 | { |
| 1421 | v_U16_t curGenIELen = pWextState->genIE.length; |
| 1422 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)", |
| 1423 | __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2); |
| 1424 | |
| 1425 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) ) |
| 1426 | { |
| 1427 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. " |
| 1428 | "Need bigger buffer space\n"); |
| 1429 | VOS_ASSERT(0); |
| 1430 | return -ENOMEM; |
| 1431 | } |
| 1432 | // save to Additional IE ; it should be accumulated to handle WPS IE + other IE |
| 1433 | memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2); |
| 1434 | pWextState->genIE.length += eLen + 2; |
| 1435 | } |
| 1436 | break; |
| 1437 | case DOT11F_EID_RSN: |
| 1438 | hddLog (LOG1, "%s Set RSN IE (len %d)",__FUNCTION__, eLen+2); |
| 1439 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 1440 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)); |
| 1441 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 1442 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; |
| 1443 | break; |
| 1444 | |
| 1445 | default: |
| 1446 | hddLog (LOGE, "%s Set UNKNOWN IE %X",__FUNCTION__, elementId); |
| 1447 | return 0; |
| 1448 | } |
| 1449 | genie += eLen; |
| 1450 | remLen -= eLen; |
| 1451 | } |
| 1452 | EXIT(); |
| 1453 | return 0; |
| 1454 | } |
| 1455 | |
| 1456 | static int iw_get_genie(struct net_device *dev, |
| 1457 | struct iw_request_info *info, |
| 1458 | union iwreq_data *wrqu, |
| 1459 | char *extra) |
| 1460 | { |
| 1461 | hdd_wext_state_t *pWextState; |
| 1462 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1463 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1464 | eHalStatus status; |
| 1465 | v_U32_t length = DOT11F_IE_RSN_MAX_LEN; |
| 1466 | v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN]; |
| 1467 | |
| 1468 | ENTER(); |
| 1469 | |
| 1470 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1471 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1472 | return 0; |
| 1473 | } |
| 1474 | |
| 1475 | |
| 1476 | hddLog(LOG1,"getGEN_IE ioctl\n"); |
| 1477 | |
| 1478 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1479 | |
| 1480 | if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) |
| 1481 | { |
| 1482 | return -ENXIO; |
| 1483 | } |
| 1484 | |
| 1485 | // Return something ONLY if we are associated with an RSN or WPA network |
| 1486 | if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1487 | pWextState->roamProfile.negotiatedAuthType)) |
| 1488 | { |
| 1489 | return -ENXIO; |
| 1490 | } |
| 1491 | |
| 1492 | // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.) |
| 1493 | status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1494 | pAdapter->sessionId, |
| 1495 | &length, |
| 1496 | genIeBytes); |
| 1497 | wrqu->data.length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN); |
| 1498 | |
| 1499 | vos_mem_copy( wrqu->data.pointer, (v_VOID_t*)genIeBytes, wrqu->data.length); |
| 1500 | |
| 1501 | hddLog(LOG1,"%s: RSN IE of %d bytes returned\n", __FUNCTION__, wrqu->data.length ); |
| 1502 | |
| 1503 | EXIT(); |
| 1504 | |
| 1505 | return 0; |
| 1506 | } |
| 1507 | |
| 1508 | static int iw_get_encode(struct net_device *dev, |
| 1509 | struct iw_request_info *info, |
| 1510 | struct iw_point *dwrq, char *extra) |
| 1511 | { |
| 1512 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1513 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1514 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 1515 | int keyId; |
| 1516 | eCsrAuthType authType = eCSR_AUTH_TYPE_NONE; |
| 1517 | int i; |
| 1518 | |
| 1519 | ENTER(); |
| 1520 | |
| 1521 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) { |
| 1522 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1523 | return 0; |
| 1524 | } |
| 1525 | |
| 1526 | keyId = pRoamProfile->Keys.defaultIndex; |
| 1527 | |
| 1528 | if(keyId < 0 || keyId >= MAX_WEP_KEYS) |
| 1529 | { |
| 1530 | hddLog(LOG1,"%s: Invalid keyId : %d\n",__FUNCTION__,keyId); |
| 1531 | return -EINVAL; |
| 1532 | } |
| 1533 | |
| 1534 | if(pRoamProfile->Keys.KeyLength[keyId] > 0) |
| 1535 | { |
| 1536 | dwrq->flags |= IW_ENCODE_ENABLED; |
| 1537 | dwrq->length = pRoamProfile->Keys.KeyLength[keyId]; |
| 1538 | vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]); |
| 1539 | |
| 1540 | dwrq->flags |= (keyId + 1); |
| 1541 | |
| 1542 | } |
| 1543 | else |
| 1544 | { |
| 1545 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 1546 | } |
| 1547 | |
| 1548 | for(i=0; i < MAX_WEP_KEYS; i++) |
| 1549 | { |
| 1550 | if(pRoamProfile->Keys.KeyMaterial[i] == NULL) |
| 1551 | { |
| 1552 | continue; |
| 1553 | } |
| 1554 | else |
| 1555 | { |
| 1556 | break; |
| 1557 | } |
| 1558 | } |
| 1559 | |
| 1560 | if(MAX_WEP_KEYS == i) |
| 1561 | { |
| 1562 | dwrq->flags |= IW_ENCODE_NOKEY; |
| 1563 | } |
| 1564 | |
| 1565 | authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType; |
| 1566 | |
| 1567 | if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) |
| 1568 | { |
| 1569 | dwrq->flags |= IW_ENCODE_OPEN; |
| 1570 | } |
| 1571 | else |
| 1572 | { |
| 1573 | dwrq->flags |= IW_ENCODE_RESTRICTED; |
| 1574 | } |
| 1575 | EXIT(); |
| 1576 | return 0; |
| 1577 | } |
| 1578 | |
| 1579 | #define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator, |
| 1580 | #define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant |
| 1581 | |
| 1582 | |
| 1583 | /* |
| 1584 | * This function sends a single 'key' to LIM at all time. |
| 1585 | */ |
| 1586 | |
| 1587 | static int iw_get_rts_threshold(struct net_device *dev, |
| 1588 | struct iw_request_info *info, |
| 1589 | union iwreq_data *wrqu, char *extra) |
| 1590 | { |
| 1591 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1592 | v_U32_t status = 0; |
| 1593 | |
| 1594 | status = hdd_wlan_get_rts_threshold(pAdapter,wrqu); |
| 1595 | |
| 1596 | return status; |
| 1597 | } |
| 1598 | |
| 1599 | static int iw_set_rts_threshold(struct net_device *dev, |
| 1600 | struct iw_request_info *info, |
| 1601 | union iwreq_data *wrqu, char *extra) |
| 1602 | { |
| 1603 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1604 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1605 | |
| 1606 | ENTER(); |
| 1607 | |
| 1608 | if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX ) |
| 1609 | { |
| 1610 | return -EINVAL; |
| 1611 | } |
| 1612 | |
| 1613 | if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS ) |
| 1614 | { |
| 1615 | return -EIO; |
| 1616 | } |
| 1617 | |
| 1618 | EXIT(); |
| 1619 | |
| 1620 | return 0; |
| 1621 | } |
| 1622 | |
| 1623 | static int iw_get_frag_threshold(struct net_device *dev, |
| 1624 | struct iw_request_info *info, |
| 1625 | union iwreq_data *wrqu, char *extra) |
| 1626 | { |
| 1627 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1628 | v_U32_t status = 0; |
| 1629 | |
| 1630 | status = hdd_wlan_get_frag_threshold(pAdapter,wrqu); |
| 1631 | |
| 1632 | return status; |
| 1633 | } |
| 1634 | |
| 1635 | static int iw_set_frag_threshold(struct net_device *dev, |
| 1636 | struct iw_request_info *info, |
| 1637 | union iwreq_data *wrqu, char *extra) |
| 1638 | { |
| 1639 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1640 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1641 | |
| 1642 | ENTER(); |
| 1643 | |
| 1644 | if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX ) |
| 1645 | { |
| 1646 | return -EINVAL; |
| 1647 | } |
| 1648 | |
| 1649 | if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS ) |
| 1650 | { |
| 1651 | return -EIO; |
| 1652 | } |
| 1653 | |
| 1654 | EXIT(); |
| 1655 | |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
| 1659 | static int iw_get_power_mode(struct net_device *dev, |
| 1660 | struct iw_request_info *info, |
| 1661 | union iwreq_data *wrqu, char *extra) |
| 1662 | { |
| 1663 | ENTER(); |
| 1664 | return -EOPNOTSUPP; |
| 1665 | } |
| 1666 | |
| 1667 | static int iw_set_power_mode(struct net_device *dev, |
| 1668 | struct iw_request_info *info, |
| 1669 | union iwreq_data *wrqu, char *extra) |
| 1670 | { |
| 1671 | ENTER(); |
| 1672 | return -EOPNOTSUPP; |
| 1673 | } |
| 1674 | |
| 1675 | static int iw_get_range(struct net_device *dev, struct iw_request_info *info, |
| 1676 | union iwreq_data *wrqu, char *extra) |
| 1677 | { |
| 1678 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1679 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1680 | struct iw_range *range = (struct iw_range *) extra; |
| 1681 | |
| 1682 | v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1683 | |
| 1684 | v_U32_t num_channels = sizeof(channels); |
| 1685 | v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN]; |
| 1686 | v_U32_t a_len; |
| 1687 | v_U32_t b_len; |
| 1688 | v_U32_t active_phy_mode = 0; |
| 1689 | v_U8_t index = 0, i; |
| 1690 | |
| 1691 | ENTER(); |
| 1692 | |
| 1693 | wrqu->data.length = sizeof(struct iw_range); |
| 1694 | memset(range, 0, sizeof(struct iw_range)); |
| 1695 | |
| 1696 | |
| 1697 | /*Get the phy mode*/ |
| 1698 | if (ccmCfgGetInt(hHal, |
| 1699 | WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS) |
| 1700 | { |
| 1701 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1702 | "active_phy_mode = %ld", active_phy_mode); |
| 1703 | |
| 1704 | if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G) |
| 1705 | { |
| 1706 | /*Get the supported rates for 11G band*/ |
| 1707 | if (ccmCfgGetStr(hHal, |
| 1708 | WNI_CFG_SUPPORTED_RATES_11A, |
| 1709 | supp_rates, &a_len) == eHAL_STATUS_SUCCESS) |
| 1710 | { |
| 1711 | if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) |
| 1712 | { |
| 1713 | a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN; |
| 1714 | } |
| 1715 | for (i = 0; i < a_len; i++) |
| 1716 | { |
| 1717 | range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000; |
| 1718 | } |
| 1719 | range->num_bitrates = a_len; |
| 1720 | } |
| 1721 | else |
| 1722 | { |
| 1723 | return -EIO; |
| 1724 | } |
| 1725 | } |
| 1726 | else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) |
| 1727 | { |
| 1728 | /*Get the supported rates for 11B band*/ |
| 1729 | if (ccmCfgGetStr(hHal, |
| 1730 | WNI_CFG_SUPPORTED_RATES_11B, |
| 1731 | supp_rates, &b_len) == eHAL_STATUS_SUCCESS) |
| 1732 | { |
| 1733 | if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) |
| 1734 | { |
| 1735 | b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN; |
| 1736 | } |
| 1737 | for (i = 0; i < b_len; i++) |
| 1738 | { |
| 1739 | range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000; |
| 1740 | } |
| 1741 | range->num_bitrates = b_len; |
| 1742 | } |
| 1743 | else |
| 1744 | { |
| 1745 | return -EIO; |
| 1746 | } |
| 1747 | } |
| 1748 | } |
| 1749 | |
| 1750 | range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX; |
| 1751 | range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN; |
| 1752 | range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX; |
| 1753 | |
| 1754 | range->encoding_size[0] = 5; |
| 1755 | range->encoding_size[1] = 13; |
| 1756 | range->num_encoding_sizes = 2; |
| 1757 | range->max_encoding_tokens = MAX_WEP_KEYS; |
| 1758 | |
| 1759 | // we support through Wireless Extensions 22 |
| 1760 | range->we_version_compiled = WIRELESS_EXT; |
| 1761 | range->we_version_source = 22; |
| 1762 | |
| 1763 | /*Supported Channels and Frequencies*/ |
| 1764 | if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS) |
| 1765 | { |
| 1766 | return -EIO; |
| 1767 | } |
| 1768 | if (num_channels > IW_MAX_FREQUENCIES) |
| 1769 | { |
| 1770 | num_channels = IW_MAX_FREQUENCIES; |
| 1771 | } |
| 1772 | |
| 1773 | range->num_channels = num_channels; |
| 1774 | range->num_frequency = num_channels; |
| 1775 | |
| 1776 | for (index=0; index < num_channels; index++) |
| 1777 | { |
| 1778 | v_U32_t frq_indx = 0; |
| 1779 | |
| 1780 | range->freq[index].i = channels[index]; |
| 1781 | while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) |
| 1782 | { |
| 1783 | if(channels[index] == freq_chan_map[frq_indx].chan) |
| 1784 | { |
| 1785 | range->freq[index].m = freq_chan_map[frq_indx].freq * 100000; |
| 1786 | range->freq[index].e = 1; |
| 1787 | break; |
| 1788 | } |
| 1789 | frq_indx++; |
| 1790 | } |
| 1791 | } |
| 1792 | |
| 1793 | /* Event capability (kernel + driver) */ |
| 1794 | range->event_capa[0] = (IW_EVENT_CAPA_K_0 | |
| 1795 | IW_EVENT_CAPA_MASK(SIOCGIWAP) | |
| 1796 | IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); |
| 1797 | range->event_capa[1] = IW_EVENT_CAPA_K_1; |
| 1798 | |
| 1799 | /*Encryption capability*/ |
| 1800 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | |
| 1801 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; |
| 1802 | |
| 1803 | /* Txpower capability */ |
| 1804 | range->txpower_capa = IW_TXPOW_MWATT; |
| 1805 | |
| 1806 | /*Scanning capability*/ |
| 1807 | #if WIRELESS_EXT >= 22 |
| 1808 | range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL; |
| 1809 | #endif |
| 1810 | |
| 1811 | EXIT(); |
| 1812 | return 0; |
| 1813 | } |
| 1814 | |
| 1815 | /* Callback function registered with PMC to know status of PMC request */ |
| 1816 | static void iw_power_callback_fn (void *pContext, eHalStatus status) |
| 1817 | { |
| 1818 | struct statsContext *pStatsContext; |
| 1819 | hdd_adapter_t *pAdapter; |
| 1820 | |
| 1821 | if (NULL == pContext) |
| 1822 | { |
| 1823 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1824 | "%s: Bad param, pContext [%p]", |
| 1825 | __FUNCTION__, pContext); |
| 1826 | return; |
| 1827 | } |
| 1828 | |
| 1829 | /* there is a race condition that exists between this callback function |
| 1830 | and the caller since the caller could time out either before or |
| 1831 | while this code is executing. we'll assume the timeout hasn't |
| 1832 | occurred, but we'll verify that right before we save our work */ |
| 1833 | |
| 1834 | pStatsContext = (struct statsContext *)pContext; |
| 1835 | pAdapter = pStatsContext->pAdapter; |
| 1836 | |
| 1837 | if ((NULL == pAdapter) || (POWER_CONTEXT_MAGIC != pStatsContext->magic)) |
| 1838 | { |
| 1839 | /* the caller presumably timed out so there is nothing we can do */ |
| 1840 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1841 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 1842 | __FUNCTION__, pAdapter, pStatsContext->magic); |
| 1843 | |
| 1844 | if (ioctl_debug) |
| 1845 | { |
| 1846 | pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n", |
| 1847 | __FUNCTION__, pAdapter, pStatsContext->magic); |
| 1848 | } |
| 1849 | return; |
| 1850 | } |
| 1851 | |
| 1852 | /* and notify the caller */ |
| 1853 | complete(&pStatsContext->completion); |
| 1854 | } |
| 1855 | |
| 1856 | /* Callback function for tx per hit */ |
| 1857 | void hdd_tx_per_hit_cb (void *pCallbackContext) |
| 1858 | { |
| 1859 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext; |
| 1860 | unsigned char tx_fail[16]; |
| 1861 | union iwreq_data wrqu; |
| 1862 | |
| 1863 | if (NULL == pAdapter) |
| 1864 | { |
| 1865 | hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL\n"); |
| 1866 | return; |
| 1867 | } |
| 1868 | memset(&wrqu, 0, sizeof(wrqu)); |
| 1869 | wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail)); |
| 1870 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail); |
| 1871 | } |
| 1872 | |
| 1873 | void hdd_GetClassA_statisticsCB(void *pStats, void *pContext) |
| 1874 | { |
| 1875 | struct statsContext *pStatsContext; |
| 1876 | tCsrGlobalClassAStatsInfo *pClassAStats; |
| 1877 | hdd_adapter_t *pAdapter; |
| 1878 | |
| 1879 | if (ioctl_debug) |
| 1880 | { |
| 1881 | pr_info("%s: pStats [%p] pContext [%p]\n", |
| 1882 | __FUNCTION__, pStats, pContext); |
| 1883 | } |
| 1884 | |
| 1885 | if ((NULL == pStats) || (NULL == pContext)) |
| 1886 | { |
| 1887 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1888 | "%s: Bad param, pStats [%p] pContext [%p]", |
| 1889 | __FUNCTION__, pStats, pContext); |
| 1890 | return; |
| 1891 | } |
| 1892 | |
| 1893 | /* there is a race condition that exists between this callback function |
| 1894 | and the caller since the caller could time out either before or |
| 1895 | while this code is executing. we'll assume the timeout hasn't |
| 1896 | occurred, but we'll verify that right before we save our work */ |
| 1897 | |
| 1898 | pClassAStats = pStats; |
| 1899 | pStatsContext = pContext; |
| 1900 | pAdapter = pStatsContext->pAdapter; |
| 1901 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 1902 | { |
| 1903 | /* the caller presumably timed out so there is nothing we can do */ |
| 1904 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1905 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 1906 | __FUNCTION__, pAdapter, pStatsContext->magic); |
| 1907 | if (ioctl_debug) |
| 1908 | { |
| 1909 | pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n", |
| 1910 | __FUNCTION__, pAdapter, pStatsContext->magic); |
| 1911 | } |
| 1912 | return; |
| 1913 | } |
| 1914 | |
| 1915 | /* the race is on. caller could have timed out immediately after |
| 1916 | we verified the magic, but if so, caller will wait a short time |
| 1917 | for us to copy over the stats. do so as a struct copy */ |
| 1918 | pAdapter->hdd_stats.ClassA_stat = *pClassAStats; |
| 1919 | |
| 1920 | /* and notify the caller */ |
| 1921 | complete(&pStatsContext->completion); |
| 1922 | } |
| 1923 | |
| 1924 | VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter) |
| 1925 | { |
| 1926 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1927 | eHalStatus hstatus; |
| 1928 | long lrc; |
| 1929 | struct statsContext context; |
| 1930 | |
| 1931 | if (NULL == pAdapter) |
| 1932 | { |
| 1933 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__); |
| 1934 | return VOS_STATUS_E_FAULT; |
| 1935 | } |
| 1936 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 1937 | { |
| 1938 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 1939 | return VOS_STATUS_SUCCESS; |
| 1940 | } |
| 1941 | |
| 1942 | /* we are connected |
| 1943 | prepare our callback context */ |
| 1944 | init_completion(&context.completion); |
| 1945 | context.pAdapter = pAdapter; |
| 1946 | context.magic = STATS_CONTEXT_MAGIC; |
| 1947 | /* query only for Class A statistics (which include link speed) */ |
| 1948 | hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1949 | eCSR_HDD, |
| 1950 | SME_GLOBAL_CLASSA_STATS, |
| 1951 | hdd_GetClassA_statisticsCB, |
| 1952 | 0, // not periodic |
| 1953 | FALSE, //non-cached results |
| 1954 | pHddStaCtx->conn_info.staId[0], |
| 1955 | &context); |
| 1956 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 1957 | { |
| 1958 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1959 | "%s: Unable to retrieve Class A statistics ", |
| 1960 | __FUNCTION__); |
| 1961 | /* we'll returned a cached value below */ |
| 1962 | } |
| 1963 | else |
| 1964 | { |
| 1965 | /* request was sent -- wait for the response */ |
| 1966 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 1967 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
| 1968 | /* either we have a response or we timed out |
| 1969 | either way, first invalidate our magic */ |
| 1970 | context.magic = 0; |
| 1971 | if (lrc <= 0) |
| 1972 | { |
| 1973 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1974 | "%s: SME %s while retrieving Class A statistics", |
| 1975 | __FUNCTION__, (0 == lrc) ? "timeout" : "interrupt"); |
| 1976 | /* there is a race condition such that the callback |
| 1977 | function could be executing at the same time we are. of |
| 1978 | primary concern is if the callback function had already |
| 1979 | verified the "magic" but hasn't yet set the completion |
| 1980 | variable. Since the completion variable is on our |
| 1981 | stack, we'll delay just a bit to make sure the data is |
| 1982 | still valid if that is the case */ |
| 1983 | msleep(50); |
| 1984 | } |
| 1985 | } |
| 1986 | return VOS_STATUS_SUCCESS; |
| 1987 | } |
| 1988 | |
| 1989 | /* |
| 1990 | * Support for the LINKSPEED private command |
| 1991 | * Per the WiFi framework the response must be of the form |
| 1992 | * "LinkSpeed xx" |
| 1993 | */ |
| 1994 | static int iw_get_linkspeed(struct net_device *dev, |
| 1995 | struct iw_request_info *info, |
| 1996 | union iwreq_data *wrqu, char *extra) |
| 1997 | { |
| 1998 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1999 | char *pLinkSpeed = (char*)extra; |
| 2000 | int len = sizeof(v_U16_t) + 1; |
| 2001 | v_U16_t link_speed; |
| 2002 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2003 | int rc; |
| 2004 | |
| 2005 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2006 | { |
| 2007 | /* we are not connected so we don't have a classAstats */ |
| 2008 | link_speed = 0; |
| 2009 | } |
| 2010 | else |
| 2011 | { |
| 2012 | wlan_hdd_get_classAstats(pAdapter); |
| 2013 | //The linkspeed returned by HAL is in units of 500kbps. |
| 2014 | //converting it to mbps |
| 2015 | link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2; |
| 2016 | } |
| 2017 | |
| 2018 | wrqu->data.length = len; |
| 2019 | // return the linkspeed in the format required by the WiFi Framework |
| 2020 | rc = snprintf(pLinkSpeed, len, "%u", link_speed); |
| 2021 | if ((rc < 0) || (rc >= len)) |
| 2022 | { |
| 2023 | // encoding or length error? |
| 2024 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2025 | "%s: Unable to encode link speed, got [%s]", |
| 2026 | __FUNCTION__,pLinkSpeed); |
| 2027 | return -EIO; |
| 2028 | } |
| 2029 | |
| 2030 | /* a value is being successfully returned */ |
| 2031 | return 0; |
| 2032 | } |
| 2033 | |
| 2034 | |
| 2035 | /* |
| 2036 | * Support for the RSSI & RSSI-APPROX private commands |
| 2037 | * Per the WiFi framework the response must be of the form |
| 2038 | * "<ssid> rssi <xx>" |
| 2039 | * unless we are not associated, in which case the response is |
| 2040 | * "OK" |
| 2041 | */ |
| 2042 | static int iw_get_rssi(struct net_device *dev, |
| 2043 | struct iw_request_info *info, |
| 2044 | union iwreq_data *wrqu, char *extra) |
| 2045 | { |
| 2046 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2047 | char *cmd = (char*)wrqu->data.pointer; |
| 2048 | int len = wrqu->data.length; |
| 2049 | v_S7_t s7Rssi = 0; |
| 2050 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2051 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 2052 | VOS_STATUS vosStatus; |
| 2053 | int rc; |
| 2054 | |
| 2055 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 2056 | (0 == ssidlen) || (ssidlen >= len)) |
| 2057 | { |
| 2058 | /* we are not connected or our SSID is too long |
| 2059 | so we cannot report an rssi */ |
| 2060 | rc = snprintf(cmd, len, "OK"); |
| 2061 | } |
| 2062 | else |
| 2063 | { |
| 2064 | /* we are connected with a valid SSID |
| 2065 | so we can write the SSID into the return buffer |
| 2066 | (note that it is not NUL-terminated) */ |
| 2067 | memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen ); |
| 2068 | |
| 2069 | vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi); |
| 2070 | |
| 2071 | if (VOS_STATUS_SUCCESS == vosStatus) |
| 2072 | { |
| 2073 | /* append the rssi to the ssid in the format required by |
| 2074 | the WiFI Framework */ |
| 2075 | rc = snprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi); |
| 2076 | } |
| 2077 | else |
| 2078 | { |
| 2079 | rc = -1; |
| 2080 | } |
| 2081 | } |
| 2082 | |
| 2083 | /* verify that we wrote a valid response */ |
| 2084 | if ((rc < 0) || (rc >= len)) |
| 2085 | { |
| 2086 | // encoding or length error? |
| 2087 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2088 | "%s: Unable to encode RSSI, got [%s]", |
| 2089 | __FUNCTION__, cmd); |
| 2090 | return -EIO; |
| 2091 | } |
| 2092 | |
| 2093 | /* a value is being successfully returned */ |
| 2094 | return 0; |
| 2095 | } |
| 2096 | |
| 2097 | /* |
| 2098 | * Support for SoftAP channel range private command |
| 2099 | */ |
| 2100 | static int iw_softap_set_channel_range( struct net_device *dev, |
| 2101 | int startChannel, |
| 2102 | int endChannel, |
| 2103 | int band) |
| 2104 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2105 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2106 | int ret = 0; |
| 2107 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 2108 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 2109 | |
| 2110 | status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band); |
| 2111 | if (VOS_STATUS_SUCCESS != status) |
| 2112 | { |
| 2113 | ret = -EINVAL; |
| 2114 | } |
| 2115 | return ret; |
| 2116 | } |
| 2117 | |
| 2118 | VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode) |
| 2119 | { |
| 2120 | struct statsContext context; |
| 2121 | eHalStatus status; |
| 2122 | hdd_context_t *pHddCtx; |
| 2123 | |
| 2124 | if (NULL == pAdapter) |
| 2125 | { |
| 2126 | hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL"); |
| 2127 | return VOS_STATUS_E_FAULT; |
| 2128 | } |
| 2129 | |
| 2130 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode); |
| 2131 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2132 | init_completion(&context.completion); |
| 2133 | |
| 2134 | context.pAdapter = pAdapter; |
| 2135 | context.magic = POWER_CONTEXT_MAGIC; |
| 2136 | |
| 2137 | if (DRIVER_POWER_MODE_ACTIVE == mode) |
| 2138 | { |
| 2139 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering " |
| 2140 | "Full Power", __func__); |
| 2141 | status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2142 | iw_power_callback_fn, &context, |
| 2143 | eSME_FULL_PWR_NEEDED_BY_HDD); |
| 2144 | // Enter Full power command received from GUI this means we are disconnected |
| 2145 | // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC |
| 2146 | sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE); |
| 2147 | if (eHAL_STATUS_PMC_PENDING == status) |
| 2148 | { |
| 2149 | int lrc = wait_for_completion_interruptible_timeout( |
| 2150 | &context.completion, |
| 2151 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
| 2152 | context.magic = 0; |
| 2153 | if (lrc <= 0) |
| 2154 | { |
| 2155 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ", |
| 2156 | __FUNCTION__, (0 == lrc) ? "timeout" : "interrupt"); |
| 2157 | /* there is a race condition such that the callback |
| 2158 | function could be executing at the same time we are. of |
| 2159 | primary concern is if the callback function had already |
| 2160 | verified the "magic" but hasn't yet set the completion |
| 2161 | variable. Since the completion variable is on our |
| 2162 | stack, we'll delay just a bit to make sure the data is |
| 2163 | still valid if that is the case */ |
| 2164 | msleep(50); |
| 2165 | /* we'll now returned a cached value below */ |
| 2166 | } |
| 2167 | } |
| 2168 | } |
| 2169 | else if (DRIVER_POWER_MODE_AUTO == mode) |
| 2170 | { |
| 2171 | if (pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 2172 | { |
| 2173 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ", |
| 2174 | __func__); |
| 2175 | // Enter BMPS command received from GUI this means DHCP is completed |
| 2176 | // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry |
| 2177 | sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2178 | FALSE); |
| 2179 | status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 2180 | iw_power_callback_fn, &context); |
| 2181 | if (eHAL_STATUS_PMC_PENDING == status) |
| 2182 | { |
| 2183 | int lrc = wait_for_completion_interruptible_timeout( |
| 2184 | &context.completion, |
| 2185 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
| 2186 | context.magic = 0; |
| 2187 | if (lrc <= 0) |
| 2188 | { |
| 2189 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting BMPS ", |
| 2190 | __FUNCTION__, (0 == lrc) ? "timeout" : "interrupt"); |
| 2191 | /* there is a race condition such that the callback |
| 2192 | function could be executing at the same time we are. of |
| 2193 | primary concern is if the callback function had already |
| 2194 | verified the "magic" but hasn't yet set the completion |
| 2195 | variable. Since the completion variable is on our |
| 2196 | stack, we'll delay just a bit to make sure the data is |
| 2197 | still valid if that is the case */ |
| 2198 | msleep(50); |
| 2199 | /* we'll now returned a cached value below */ |
| 2200 | } |
| 2201 | } |
| 2202 | } |
| 2203 | else |
| 2204 | { |
| 2205 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not " |
| 2206 | "enabled in the cfg"); |
| 2207 | } |
| 2208 | } |
| 2209 | return VOS_STATUS_SUCCESS; |
| 2210 | } |
| 2211 | |
| 2212 | VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx, |
| 2213 | hdd_adapter_t *pAdapter) |
| 2214 | { |
| 2215 | VOS_STATUS vos_Status; |
| 2216 | |
| 2217 | if ((NULL == pAdapter) || (NULL == pHddCtx)) |
| 2218 | { |
| 2219 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer"); |
| 2220 | return VOS_STATUS_E_FAULT; |
| 2221 | } |
| 2222 | |
| 2223 | /**Exit from Deep sleep or standby if we get the driver |
| 2224 | START cmd from android GUI |
| 2225 | */ |
| 2226 | if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop) |
| 2227 | { |
| 2228 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit " |
| 2229 | "from Stand by",__func__); |
| 2230 | vos_Status = hdd_exit_standby(pHddCtx); |
| 2231 | } |
| 2232 | else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state) |
| 2233 | { |
| 2234 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit " |
| 2235 | "from deep sleep",__func__); |
| 2236 | vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter); |
| 2237 | } |
| 2238 | else |
| 2239 | { |
| 2240 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. " |
| 2241 | "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state); |
| 2242 | vos_Status = VOS_STATUS_SUCCESS; |
| 2243 | } |
| 2244 | |
| 2245 | return vos_Status; |
| 2246 | } |
| 2247 | |
| 2248 | VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx) |
| 2249 | { |
| 2250 | VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE; |
| 2251 | |
| 2252 | if (NULL == pHddCtx) |
| 2253 | { |
| 2254 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "HDD context NULL"); |
| 2255 | return VOS_STATUS_E_FAULT; |
| 2256 | } |
| 2257 | |
| 2258 | if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop) |
| 2259 | { |
| 2260 | //Execute standby procedure. |
| 2261 | //Executing standby procedure will cause the STA to |
| 2262 | //disassociate first and then the chip will be put into standby. |
| 2263 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode"); |
| 2264 | vos_Status = hdd_enter_standby(pHddCtx); |
| 2265 | } |
| 2266 | else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP == |
| 2267 | pHddCtx->cfg_ini->nEnableDriverStop) |
| 2268 | { |
| 2269 | //Execute deep sleep procedure |
| 2270 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering " |
| 2271 | "deep sleep mode\n"); |
| 2272 | //Deep sleep not supported |
| 2273 | vos_Status = hdd_enter_standby(pHddCtx); |
| 2274 | } |
| 2275 | else |
| 2276 | { |
| 2277 | hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d", |
| 2278 | __func__, pHddCtx->cfg_ini->nEnableDriverStop); |
| 2279 | vos_Status = VOS_STATUS_SUCCESS; |
| 2280 | } |
| 2281 | |
| 2282 | return vos_Status; |
| 2283 | } |
| 2284 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2285 | |
| 2286 | void* wlan_hdd_change_country_code_callback(void *pAdapter) |
| 2287 | { |
| 2288 | |
| 2289 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 2290 | |
| 2291 | complete(&call_back_pAdapter->change_country_code); |
| 2292 | |
| 2293 | return NULL; |
| 2294 | } |
| 2295 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2296 | static int iw_set_priv(struct net_device *dev, |
| 2297 | struct iw_request_info *info, |
| 2298 | union iwreq_data *wrqu, char *extra) |
| 2299 | { |
| 2300 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2301 | char *cmd = (char*)wrqu->data.pointer; |
| 2302 | int cmd_len = wrqu->data.length; |
| 2303 | int ret = 0; |
| 2304 | int status = 0; |
| 2305 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2306 | |
| 2307 | ENTER(); |
| 2308 | |
| 2309 | if (ioctl_debug) |
| 2310 | { |
| 2311 | pr_info("%s: req [%s] len [%d]\n", __FUNCTION__, cmd, cmd_len); |
| 2312 | } |
| 2313 | |
| 2314 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "***Received %s cmd from Wi-Fi GUI***", cmd); |
| 2315 | |
| 2316 | if (pHddCtx->isLogpInProgress) { |
| 2317 | if (ioctl_debug) |
| 2318 | { |
| 2319 | pr_info("%s: RESTART in progress\n", __FUNCTION__); |
| 2320 | } |
| 2321 | |
| 2322 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2323 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2324 | return status; |
| 2325 | } |
| 2326 | |
| 2327 | if(strncmp(cmd, "CSCAN",5) == 0 ) |
| 2328 | { |
| 2329 | status = iw_set_cscan(dev, info, wrqu, extra); |
| 2330 | } |
| 2331 | else if( strcasecmp(cmd, "start") == 0 ) { |
| 2332 | |
| 2333 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command\n"); |
| 2334 | /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/ |
| 2335 | status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter); |
| 2336 | |
| 2337 | if(status == VOS_STATUS_SUCCESS) |
| 2338 | { |
| 2339 | union iwreq_data wrqu; |
| 2340 | char buf[10]; |
| 2341 | |
| 2342 | memset(&wrqu, 0, sizeof(wrqu)); |
| 2343 | wrqu.data.length = strlcpy(buf, "START", sizeof(buf)); |
| 2344 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf); |
| 2345 | } |
| 2346 | else |
| 2347 | { |
| 2348 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: START CMD Status %d", __func__, status); |
| 2349 | } |
| 2350 | goto done; |
| 2351 | } |
| 2352 | else if( strcasecmp(cmd, "stop") == 0 ) |
| 2353 | { |
| 2354 | union iwreq_data wrqu; |
| 2355 | char buf[10]; |
| 2356 | |
| 2357 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command\n"); |
| 2358 | |
| 2359 | wlan_hdd_enter_lowpower(pHddCtx); |
| 2360 | memset(&wrqu, 0, sizeof(wrqu)); |
| 2361 | wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf)); |
| 2362 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf); |
| 2363 | status = VOS_STATUS_SUCCESS; |
| 2364 | goto done; |
| 2365 | } |
| 2366 | else if (strcasecmp(cmd, "macaddr") == 0) |
| 2367 | { |
| 2368 | ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR, |
| 2369 | MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes)); |
| 2370 | } |
| 2371 | else if (strcasecmp(cmd, "scan-active") == 0) |
| 2372 | { |
| 2373 | pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
| 2374 | ret = snprintf(cmd, cmd_len, "OK"); |
| 2375 | } |
| 2376 | else if (strcasecmp(cmd, "scan-passive") == 0) |
| 2377 | { |
| 2378 | pAdapter->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
| 2379 | ret = snprintf(cmd, cmd_len, "OK"); |
| 2380 | } |
| 2381 | else if( strcasecmp(cmd, "scan-mode") == 0 ) |
| 2382 | { |
| 2383 | ret = snprintf(cmd, cmd_len, "ScanMode = %u", pAdapter->scan_info.scan_mode); |
| 2384 | } |
| 2385 | else if( strcasecmp(cmd, "linkspeed") == 0 ) |
| 2386 | { |
| 2387 | status = iw_get_linkspeed(dev, info, wrqu, extra); |
| 2388 | } |
| 2389 | else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) { |
| 2390 | char *country_code; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2391 | long lrc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2392 | |
| 2393 | country_code = cmd + 8; |
| 2394 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2395 | init_completion(&pAdapter->change_country_code); |
| 2396 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2397 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2398 | (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2399 | country_code, |
| 2400 | pAdapter, |
| 2401 | pHddCtx->pvosContext); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2402 | |
| 2403 | /* Wait for completion */ |
| 2404 | lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code, |
| 2405 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
| 2406 | |
| 2407 | if (lrc <= 0) |
| 2408 | { |
| 2409 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ", |
| 2410 | __FUNCTION__, "Timed out"); |
| 2411 | } |
| 2412 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2413 | if( 0 != status ) |
| 2414 | { |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2415 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2416 | "%s: SME Change Country code fail \n",__func__); |
| 2417 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2418 | } |
| 2419 | } |
| 2420 | else if( strncasecmp(cmd, "rssi", 4) == 0 ) |
| 2421 | { |
| 2422 | status = iw_get_rssi(dev, info, wrqu, extra); |
| 2423 | } |
| 2424 | else if( strncasecmp(cmd, "powermode", 9) == 0 ) { |
| 2425 | int mode; |
| 2426 | char *ptr = (char*)(cmd + 9); |
| 2427 | |
| 2428 | sscanf(ptr,"%d",&mode); |
| 2429 | wlan_hdd_enter_bmps(pAdapter, mode); |
| 2430 | /*TODO:Set the power mode*/ |
| 2431 | } |
| 2432 | else if (strncasecmp(cmd, "getpower", 8) == 0 ) { |
| 2433 | v_U32_t pmc_state; |
| 2434 | v_U16_t value; |
| 2435 | |
| 2436 | pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 2437 | if(pmc_state == BMPS) { |
| 2438 | value = DRIVER_POWER_MODE_AUTO; |
| 2439 | } |
| 2440 | else { |
| 2441 | value = DRIVER_POWER_MODE_ACTIVE; |
| 2442 | } |
| 2443 | ret = snprintf(cmd, cmd_len, "powermode = %u", value); |
| 2444 | } |
| 2445 | else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) { |
| 2446 | hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode\n"); |
| 2447 | /*TODO: set the btcoexmode*/ |
| 2448 | } |
| 2449 | else if( strcasecmp(cmd, "btcoexstat") == 0 ) { |
| 2450 | |
| 2451 | hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status\n"); |
| 2452 | /*TODO: Return the btcoex status*/ |
| 2453 | } |
| 2454 | else if( strcasecmp(cmd, "rxfilter-start") == 0 ) { |
| 2455 | |
| 2456 | hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command\n"); |
| 2457 | |
| 2458 | /*TODO: Enable Rx data Filter*/ |
| 2459 | } |
| 2460 | else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) { |
| 2461 | |
| 2462 | hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command\n"); |
| 2463 | |
| 2464 | /*TODO: Disable Rx data Filter*/ |
| 2465 | } |
| 2466 | else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) { |
| 2467 | |
| 2468 | hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command\n"); |
| 2469 | /*TODO: rxfilter-statistics*/ |
| 2470 | } |
| 2471 | else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) { |
| 2472 | |
| 2473 | hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add\n"); |
| 2474 | /*TODO: rxfilter-add*/ |
| 2475 | } |
| 2476 | else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) { |
| 2477 | |
| 2478 | hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove\n"); |
| 2479 | /*TODO: rxfilter-remove*/ |
| 2480 | } |
| 2481 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 2482 | else if( strncasecmp(cmd, "pno",3) == 0 ) { |
| 2483 | |
| 2484 | hddLog( VOS_TRACE_LEVEL_INFO, "pno\n"); |
| 2485 | status = iw_set_pno(dev, info, wrqu, extra, 3); |
| 2486 | return status; |
| 2487 | } |
| 2488 | else if( strncasecmp(cmd, "rssifilter",10) == 0 ) { |
| 2489 | |
| 2490 | hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter\n"); |
| 2491 | status = iw_set_rssi_filter(dev, info, wrqu, extra, 10); |
| 2492 | return status; |
| 2493 | } |
| 2494 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 2495 | else if( strncasecmp(cmd, "powerparams",11) == 0 ) { |
| 2496 | hddLog( VOS_TRACE_LEVEL_INFO, "powerparams\n"); |
| 2497 | status = iw_set_power_params(dev, info, wrqu, extra, 11); |
| 2498 | return status; |
| 2499 | } |
| 2500 | else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) { |
| 2501 | tSirTxPerTrackingParam tTxPerTrackingParam; |
| 2502 | char *ptr = (char*)(cmd + 18); |
| 2503 | sscanf(ptr,"%hhu %hhu %hhu %lu",&(tTxPerTrackingParam.ucTxPerTrackingEnable), &(tTxPerTrackingParam.ucTxPerTrackingPeriod), |
| 2504 | &(tTxPerTrackingParam.ucTxPerTrackingRatio), &(tTxPerTrackingParam.uTxPerTrackingWatermark)); |
| 2505 | |
| 2506 | // parameters checking |
| 2507 | // period has to be larger than 0 |
| 2508 | if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod) |
| 2509 | { |
| 2510 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct"); |
| 2511 | return VOS_STATUS_E_FAILURE; |
| 2512 | } |
| 2513 | |
| 2514 | // use default value 5 is the input is not reasonable. in unit of 10% |
| 2515 | if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio)) |
| 2516 | { |
| 2517 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5"); |
| 2518 | tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO; |
| 2519 | } |
| 2520 | |
| 2521 | // default is 5 |
| 2522 | if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark) |
| 2523 | { |
| 2524 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5"); |
| 2525 | tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK; |
| 2526 | } |
| 2527 | |
| 2528 | status = sme_SetTxPerTracking(pHddCtx->hHal, hdd_tx_per_hit_cb, (void*)pAdapter, &tTxPerTrackingParam); |
| 2529 | if(status != eHAL_STATUS_SUCCESS){ |
| 2530 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!"); |
| 2531 | } |
| 2532 | } |
| 2533 | else { |
| 2534 | hddLog( VOS_TRACE_LEVEL_WARN, "Unsupported GUI command %s", cmd); |
| 2535 | } |
| 2536 | done: |
| 2537 | /* many of the commands write information back into the command |
| 2538 | string using snprintf(). check the return value here in one |
| 2539 | place */ |
| 2540 | if ((ret < 0) || (ret >= cmd_len)) |
| 2541 | { |
| 2542 | /* there was an encoding error or overflow */ |
| 2543 | status = -EIO; |
| 2544 | } |
| 2545 | |
| 2546 | if (ioctl_debug) |
| 2547 | { |
| 2548 | pr_info("%s: rsp [%s] len [%d] status %d\n", |
| 2549 | __FUNCTION__, cmd, wrqu->data.length, status); |
| 2550 | } |
| 2551 | return status; |
| 2552 | |
| 2553 | } |
| 2554 | |
| 2555 | static int iw_set_nick(struct net_device *dev, |
| 2556 | struct iw_request_info *info, |
| 2557 | union iwreq_data *wrqu, char *extra) |
| 2558 | { |
| 2559 | ENTER(); |
| 2560 | return 0; |
| 2561 | } |
| 2562 | |
| 2563 | static int iw_get_nick(struct net_device *dev, |
| 2564 | struct iw_request_info *info, |
| 2565 | union iwreq_data *wrqu, char *extra) |
| 2566 | { |
| 2567 | ENTER(); |
| 2568 | return 0; |
| 2569 | } |
| 2570 | |
| 2571 | static struct iw_statistics *get_wireless_stats(struct net_device *dev) |
| 2572 | { |
| 2573 | ENTER(); |
| 2574 | return NULL; |
| 2575 | } |
| 2576 | |
| 2577 | static int iw_set_encode(struct net_device *dev,struct iw_request_info *info, |
| 2578 | union iwreq_data *wrqu,char *extra) |
| 2579 | |
| 2580 | { |
| 2581 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2582 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2583 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2584 | struct iw_point *encoderq = &(wrqu->encoding); |
| 2585 | v_U32_t keyId; |
| 2586 | v_U8_t key_length; |
| 2587 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 2588 | v_BOOL_t fKeyPresent = 0; |
| 2589 | int i; |
| 2590 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2591 | |
| 2592 | |
| 2593 | ENTER(); |
| 2594 | |
| 2595 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2596 | { |
| 2597 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2598 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2599 | return 0; |
| 2600 | } |
| 2601 | |
| 2602 | |
| 2603 | keyId = encoderq->flags & IW_ENCODE_INDEX; |
| 2604 | |
| 2605 | if(keyId) |
| 2606 | { |
| 2607 | if(keyId > MAX_WEP_KEYS) |
| 2608 | { |
| 2609 | return -EINVAL; |
| 2610 | } |
| 2611 | |
| 2612 | fKeyPresent = 1; |
| 2613 | keyId--; |
| 2614 | } |
| 2615 | else |
| 2616 | { |
| 2617 | fKeyPresent = 0; |
| 2618 | } |
| 2619 | |
| 2620 | |
| 2621 | if(wrqu->data.flags & IW_ENCODE_DISABLED) |
| 2622 | { |
| 2623 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****\n"); |
| 2624 | if(!fKeyPresent) { |
| 2625 | |
| 2626 | for(i=0;i < CSR_MAX_NUM_KEY; i++) { |
| 2627 | |
| 2628 | if(pWextState->roamProfile.Keys.KeyMaterial[i]) |
| 2629 | pWextState->roamProfile.Keys.KeyLength[i] = 0; |
| 2630 | } |
| 2631 | } |
| 2632 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2633 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 2634 | pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 2635 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 2636 | |
| 2637 | pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 2638 | pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 2639 | |
| 2640 | if(eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 2641 | { |
| 2642 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 2643 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2644 | if(eHAL_STATUS_SUCCESS == status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2645 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 2646 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 2647 | } |
| 2648 | |
| 2649 | return status; |
| 2650 | |
| 2651 | } |
| 2652 | |
| 2653 | if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) |
| 2654 | { |
| 2655 | hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on"); |
| 2656 | |
| 2657 | pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2658 | |
| 2659 | } |
| 2660 | |
| 2661 | |
| 2662 | if(wrqu->data.length > 0) |
| 2663 | { |
| 2664 | hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__FUNCTION__,wrqu->data.length); |
| 2665 | |
| 2666 | key_length = wrqu->data.length; |
| 2667 | |
| 2668 | /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/ |
| 2669 | |
| 2670 | if(5 == key_length) |
| 2671 | { |
| 2672 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__FUNCTION__,key_length); |
| 2673 | |
| 2674 | if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)) |
| 2675 | { |
| 2676 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
| 2677 | } |
| 2678 | else |
| 2679 | { |
| 2680 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 2681 | } |
| 2682 | } |
| 2683 | else if(13 == key_length) |
| 2684 | { |
| 2685 | hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__FUNCTION__,key_length); |
| 2686 | |
| 2687 | if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)) |
| 2688 | { |
| 2689 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
| 2690 | } |
| 2691 | else |
| 2692 | { |
| 2693 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 2694 | } |
| 2695 | } |
| 2696 | else |
| 2697 | { |
| 2698 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d", |
| 2699 | __FUNCTION__, key_length); |
| 2700 | return -EINVAL; |
| 2701 | } |
| 2702 | |
| 2703 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 2704 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 2705 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 2706 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
| 2707 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 2708 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 2709 | |
| 2710 | if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) && |
| 2711 | ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) || |
| 2712 | (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType))) |
| 2713 | { |
| 2714 | |
| 2715 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length); |
| 2716 | |
| 2717 | pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length; |
| 2718 | pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId; |
| 2719 | |
| 2720 | return status; |
| 2721 | } |
| 2722 | } |
| 2723 | |
| 2724 | return 0; |
| 2725 | } |
| 2726 | |
| 2727 | static int iw_get_encodeext(struct net_device *dev, |
| 2728 | struct iw_request_info *info, |
| 2729 | struct iw_point *dwrq, |
| 2730 | char *extra) |
| 2731 | { |
| 2732 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2733 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2734 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 2735 | int keyId; |
| 2736 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 2737 | eCsrAuthType authType = eCSR_AUTH_TYPE_NONE; |
| 2738 | int i; |
| 2739 | |
| 2740 | ENTER(); |
| 2741 | |
| 2742 | keyId = pRoamProfile->Keys.defaultIndex; |
| 2743 | |
| 2744 | if(keyId < 0 || keyId >= MAX_WEP_KEYS) |
| 2745 | { |
| 2746 | hddLog(LOG1,"%s: Invalid keyId : %d\n",__FUNCTION__,keyId); |
| 2747 | return -EINVAL; |
| 2748 | } |
| 2749 | |
| 2750 | if(pRoamProfile->Keys.KeyLength[keyId] > 0) |
| 2751 | { |
| 2752 | dwrq->flags |= IW_ENCODE_ENABLED; |
| 2753 | dwrq->length = pRoamProfile->Keys.KeyLength[keyId]; |
| 2754 | palCopyMemory(dev,extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]); |
| 2755 | } |
| 2756 | else |
| 2757 | { |
| 2758 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 2759 | } |
| 2760 | |
| 2761 | for(i=0; i < MAX_WEP_KEYS; i++) |
| 2762 | { |
| 2763 | if(pRoamProfile->Keys.KeyMaterial[i] == NULL) |
| 2764 | { |
| 2765 | continue; |
| 2766 | } |
| 2767 | else |
| 2768 | { |
| 2769 | break; |
| 2770 | } |
| 2771 | } |
| 2772 | |
| 2773 | if(MAX_WEP_KEYS == i) |
| 2774 | { |
| 2775 | dwrq->flags |= IW_ENCODE_NOKEY; |
| 2776 | } |
| 2777 | else |
| 2778 | { |
| 2779 | dwrq->flags |= IW_ENCODE_ENABLED; |
| 2780 | } |
| 2781 | |
| 2782 | encryptionType = pRoamProfile->EncryptionType.encryptionType[0]; |
| 2783 | |
| 2784 | if(eCSR_ENCRYPT_TYPE_NONE == encryptionType) |
| 2785 | { |
| 2786 | dwrq->flags |= IW_ENCODE_DISABLED; |
| 2787 | } |
| 2788 | |
| 2789 | authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType; |
| 2790 | |
| 2791 | if(IW_AUTH_ALG_OPEN_SYSTEM == authType) |
| 2792 | { |
| 2793 | dwrq->flags |= IW_ENCODE_OPEN; |
| 2794 | } |
| 2795 | else |
| 2796 | { |
| 2797 | dwrq->flags |= IW_ENCODE_RESTRICTED; |
| 2798 | } |
| 2799 | EXIT(); |
| 2800 | return 0; |
| 2801 | |
| 2802 | } |
| 2803 | |
| 2804 | static int iw_set_encodeext(struct net_device *dev, |
| 2805 | struct iw_request_info *info, |
| 2806 | union iwreq_data *wrqu, char *extra) |
| 2807 | { |
| 2808 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2809 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2810 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 2811 | eHalStatus halStatus= eHAL_STATUS_SUCCESS; |
| 2812 | |
| 2813 | tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile; |
| 2814 | v_U32_t status = 0; |
| 2815 | |
| 2816 | struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; |
| 2817 | |
| 2818 | v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 2819 | |
| 2820 | int key_index; |
| 2821 | struct iw_point *encoding = &wrqu->encoding; |
| 2822 | tCsrRoamSetKey setKey; |
| 2823 | v_U32_t roamId= 0xFF; |
| 2824 | VOS_STATUS vos_status; |
| 2825 | |
| 2826 | ENTER(); |
| 2827 | |
| 2828 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 2829 | { |
| 2830 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2831 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 2832 | return 0; |
| 2833 | } |
| 2834 | |
| 2835 | key_index = encoding->flags & IW_ENCODE_INDEX; |
| 2836 | |
| 2837 | if(key_index > 0) { |
| 2838 | |
| 2839 | /*Convert from 1-based to 0-based keying*/ |
| 2840 | key_index--; |
| 2841 | } |
| 2842 | if(!ext->key_len) { |
| 2843 | |
| 2844 | /*Set the encrytion type to NONE*/ |
| 2845 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 2846 | return status; |
| 2847 | } |
| 2848 | |
| 2849 | if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState && |
| 2850 | (IW_ENCODE_ALG_WEP == ext->alg)) |
| 2851 | { |
| 2852 | if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) { |
| 2853 | |
| 2854 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,("Invalid Configuration:%s \n"),__FUNCTION__); |
| 2855 | return -EINVAL; |
| 2856 | } |
| 2857 | else { |
| 2858 | /*Static wep, update the roam profile with the keys */ |
| 2859 | if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) && |
| 2860 | key_index < CSR_MAX_NUM_KEY) { |
| 2861 | vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len); |
| 2862 | pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len; |
| 2863 | |
| 2864 | if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) |
| 2865 | pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index; |
| 2866 | |
| 2867 | } |
| 2868 | } |
| 2869 | return status; |
| 2870 | } |
| 2871 | |
| 2872 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 2873 | |
| 2874 | setKey.keyId = key_index; |
| 2875 | setKey.keyLength = ext->key_len; |
| 2876 | |
| 2877 | if(ext->key_len <= CSR_MAX_KEY_LEN) { |
| 2878 | vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len); |
| 2879 | } |
| 2880 | |
| 2881 | if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 2882 | /*Key direction for group is RX only*/ |
| 2883 | setKey.keyDirection = eSIR_RX_ONLY; |
| 2884 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 2885 | } |
| 2886 | else { |
| 2887 | |
| 2888 | setKey.keyDirection = eSIR_TX_RX; |
| 2889 | vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 2890 | } |
| 2891 | |
| 2892 | /*For supplicant pae role is zero*/ |
| 2893 | setKey.paeRole = 0; |
| 2894 | |
| 2895 | switch(ext->alg) |
| 2896 | { |
| 2897 | case IW_ENCODE_ALG_NONE: |
| 2898 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 2899 | break; |
| 2900 | |
| 2901 | case IW_ENCODE_ALG_WEP: |
| 2902 | setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104; |
| 2903 | break; |
| 2904 | |
| 2905 | case IW_ENCODE_ALG_TKIP: |
| 2906 | { |
| 2907 | v_U8_t *pKey = &setKey.Key[0]; |
| 2908 | |
| 2909 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 2910 | |
| 2911 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 2912 | |
| 2913 | /*Supplicant sends the 32bytes key in this order |
| 2914 | |
| 2915 | |--------------|----------|----------| |
| 2916 | | Tk1 |TX-MIC | RX Mic | |
| 2917 | |--------------|----------|----------| |
| 2918 | <---16bytes---><--8bytes--><--8bytes--> |
| 2919 | |
| 2920 | */ |
| 2921 | /*Sme expects the 32 bytes key to be in the below order |
| 2922 | |
| 2923 | |--------------|----------|----------| |
| 2924 | | Tk1 |RX-MIC | TX Mic | |
| 2925 | |--------------|----------|----------| |
| 2926 | <---16bytes---><--8bytes--><--8bytes--> |
| 2927 | */ |
| 2928 | /* Copy the Temporal Key 1 (TK1) */ |
| 2929 | vos_mem_copy(pKey,ext->key,16); |
| 2930 | |
| 2931 | /*Copy the rx mic first*/ |
| 2932 | vos_mem_copy(&pKey[16],&ext->key[24],8); |
| 2933 | |
| 2934 | /*Copy the tx mic */ |
| 2935 | vos_mem_copy(&pKey[24],&ext->key[16],8); |
| 2936 | |
| 2937 | } |
| 2938 | break; |
| 2939 | |
| 2940 | case IW_ENCODE_ALG_CCMP: |
| 2941 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 2942 | break; |
| 2943 | |
| 2944 | #ifdef FEATURE_WLAN_CCX |
| 2945 | #define IW_ENCODE_ALG_KRK 6 |
| 2946 | case IW_ENCODE_ALG_KRK: |
| 2947 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 2948 | break; |
| 2949 | #endif /* FEATURE_WLAN_CCX */ |
| 2950 | |
| 2951 | default: |
| 2952 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 2953 | break; |
| 2954 | } |
| 2955 | |
| 2956 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2957 | ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d \n"),__FUNCTION__,(int)ext->alg,(int)ext->key_len,setKey.encType); |
| 2958 | |
| 2959 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 2960 | /* The supplicant may attempt to set the PTK once pre-authentication is done. |
| 2961 | Save the key in the UMAC and include it in the ADD BSS request */ |
| 2962 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
| 2963 | if( halStatus == eHAL_STATUS_SUCCESS ) |
| 2964 | { |
| 2965 | return halStatus; |
| 2966 | } |
| 2967 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
| 2968 | |
| 2969 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 2970 | |
| 2971 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 2972 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 2973 | { |
| 2974 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2975 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 2976 | __LINE__, vos_status ); |
| 2977 | |
| 2978 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 2979 | } |
| 2980 | |
| 2981 | halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId ); |
| 2982 | |
| 2983 | if ( halStatus != eHAL_STATUS_SUCCESS ) |
| 2984 | { |
| 2985 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2986 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 2987 | __LINE__, halStatus ); |
| 2988 | |
| 2989 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 2990 | } |
| 2991 | |
| 2992 | return halStatus; |
| 2993 | } |
| 2994 | |
| 2995 | static int iw_set_retry(struct net_device *dev, struct iw_request_info *info, |
| 2996 | union iwreq_data *wrqu, char *extra) |
| 2997 | { |
| 2998 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2999 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3000 | |
| 3001 | ENTER(); |
| 3002 | |
| 3003 | if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN || |
| 3004 | wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) { |
| 3005 | |
| 3006 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%ld!!\n"),wrqu->retry.value); |
| 3007 | |
| 3008 | return -EINVAL; |
| 3009 | } |
| 3010 | |
| 3011 | if(wrqu->retry.flags & IW_RETRY_LIMIT) { |
| 3012 | |
| 3013 | if((wrqu->retry.flags & IW_RETRY_LONG)) |
| 3014 | { |
| 3015 | if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS ) |
| 3016 | { |
| 3017 | return -EIO; |
| 3018 | } |
| 3019 | } |
| 3020 | else if((wrqu->retry.flags & IW_RETRY_SHORT)) |
| 3021 | { |
| 3022 | if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS ) |
| 3023 | { |
| 3024 | return -EIO; |
| 3025 | } |
| 3026 | } |
| 3027 | } |
| 3028 | else |
| 3029 | { |
| 3030 | return -EOPNOTSUPP; |
| 3031 | } |
| 3032 | |
| 3033 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%ld!!\n"),wrqu->retry.value); |
| 3034 | |
| 3035 | EXIT(); |
| 3036 | |
| 3037 | return 0; |
| 3038 | |
| 3039 | } |
| 3040 | |
| 3041 | static int iw_get_retry(struct net_device *dev, struct iw_request_info *info, |
| 3042 | union iwreq_data *wrqu, char *extra) |
| 3043 | { |
| 3044 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3045 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3046 | v_U32_t retry = 0; |
| 3047 | |
| 3048 | ENTER(); |
| 3049 | |
| 3050 | if((wrqu->retry.flags & IW_RETRY_LONG)) |
| 3051 | { |
| 3052 | wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG; |
| 3053 | |
| 3054 | if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS ) |
| 3055 | { |
| 3056 | return -EIO; |
| 3057 | } |
| 3058 | |
| 3059 | wrqu->retry.value = retry; |
| 3060 | } |
| 3061 | else if ((wrqu->retry.flags & IW_RETRY_SHORT)) |
| 3062 | { |
| 3063 | wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT; |
| 3064 | |
| 3065 | if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS ) |
| 3066 | { |
| 3067 | return -EIO; |
| 3068 | } |
| 3069 | |
| 3070 | wrqu->retry.value = retry; |
| 3071 | } |
| 3072 | else { |
| 3073 | return -EOPNOTSUPP; |
| 3074 | } |
| 3075 | |
| 3076 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%ld!!\n"),retry); |
| 3077 | |
| 3078 | EXIT(); |
| 3079 | |
| 3080 | return 0; |
| 3081 | } |
| 3082 | |
| 3083 | static int iw_set_mlme(struct net_device *dev, |
| 3084 | struct iw_request_info *info, |
| 3085 | union iwreq_data *wrqu, |
| 3086 | char *extra) |
| 3087 | { |
| 3088 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3089 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3090 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 3091 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3092 | |
| 3093 | ENTER(); |
| 3094 | |
| 3095 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 3096 | { |
| 3097 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3098 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 3099 | return 0; |
| 3100 | } |
| 3101 | |
| 3102 | //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED |
| 3103 | switch (mlme->cmd) { |
| 3104 | case IW_MLME_DISASSOC: |
| 3105 | case IW_MLME_DEAUTH: |
| 3106 | |
| 3107 | if( pHddStaCtx->conn_info.connState == eConnectionState_Associated ) |
| 3108 | { |
| 3109 | eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 3110 | |
| 3111 | if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE ) |
| 3112 | reason = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 3113 | |
| 3114 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 3115 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason); |
| 3116 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 3117 | if(eHAL_STATUS_SUCCESS == status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3118 | wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
| 3119 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 3120 | else |
| 3121 | hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d \n", |
| 3122 | __FUNCTION__, (int)mlme->cmd, (int)status ); |
| 3123 | |
| 3124 | /* Resetting authKeyMgmt */ |
| 3125 | (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0; |
| 3126 | |
| 3127 | netif_tx_disable(dev); |
| 3128 | netif_carrier_off(dev); |
| 3129 | |
| 3130 | } |
| 3131 | else |
| 3132 | { |
| 3133 | hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state \n", __FUNCTION__, (int)mlme->cmd ); |
| 3134 | } |
| 3135 | break; |
| 3136 | default: |
| 3137 | hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate \n", __FUNCTION__, (int)mlme->cmd ); |
| 3138 | return -EINVAL; |
| 3139 | }//end of switch |
| 3140 | |
| 3141 | EXIT(); |
| 3142 | |
| 3143 | return status; |
| 3144 | |
| 3145 | } |
| 3146 | |
| 3147 | /* set param sub-ioctls */ |
| 3148 | static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info, |
| 3149 | union iwreq_data *wrqu, char *extra) |
| 3150 | { |
| 3151 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3152 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3153 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3154 | int *value = (int *)extra; |
| 3155 | int sub_cmd = value[0]; |
| 3156 | int set_value = value[1]; |
| 3157 | int ret = 0; /* success */ |
| 3158 | int enable_pbm, enable_mp; |
| 3159 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 3160 | v_U8_t nEnableSuspendOld; |
| 3161 | #endif |
| 3162 | INIT_COMPLETION(pWextState->completion_var); |
| 3163 | |
| 3164 | switch(sub_cmd) |
| 3165 | { |
| 3166 | case WE_SET_11D_STATE: |
| 3167 | { |
| 3168 | tSmeConfigParams smeConfig;; |
| 3169 | if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) { |
| 3170 | |
| 3171 | sme_GetConfigParam(hHal,&smeConfig); |
| 3172 | smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value; |
| 3173 | |
| 3174 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),smeConfig.csrConfig.Is11dSupportEnabled); |
| 3175 | |
| 3176 | sme_UpdateConfig(hHal,&smeConfig); |
| 3177 | } |
| 3178 | else { |
| 3179 | return -EINVAL; |
| 3180 | } |
| 3181 | break; |
| 3182 | } |
| 3183 | |
| 3184 | case WE_WOWL: |
| 3185 | { |
| 3186 | switch (set_value) |
| 3187 | { |
| 3188 | case 0x00: |
| 3189 | hdd_exit_wowl(); |
| 3190 | break; |
| 3191 | case 0x01: |
| 3192 | case 0x02: |
| 3193 | case 0x03: |
| 3194 | enable_mp = (set_value & 0x01) ? 1 : 0; |
| 3195 | enable_pbm = (set_value & 0x02) ? 1 : 0; |
| 3196 | hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s\n", |
| 3197 | (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO")); |
| 3198 | hdd_enter_wowl(pAdapter, enable_mp, enable_pbm); |
| 3199 | break; |
| 3200 | default: |
| 3201 | hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL\n", set_value); |
| 3202 | ret = -EINVAL; |
| 3203 | break; |
| 3204 | } |
| 3205 | |
| 3206 | break; |
| 3207 | } |
| 3208 | case WE_SET_POWER: |
| 3209 | { |
| 3210 | switch (set_value) |
| 3211 | { |
| 3212 | case 0: //Full Power |
| 3213 | { |
| 3214 | struct statsContext context; |
| 3215 | eHalStatus status; |
| 3216 | |
| 3217 | init_completion(&context.completion); |
| 3218 | |
| 3219 | context.pAdapter = pAdapter; |
| 3220 | context.magic = POWER_CONTEXT_MAGIC; |
| 3221 | |
| 3222 | status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3223 | iw_power_callback_fn, &context, |
| 3224 | eSME_FULL_PWR_NEEDED_BY_HDD); |
| 3225 | if(eHAL_STATUS_PMC_PENDING == status) |
| 3226 | { |
| 3227 | int lrc = wait_for_completion_interruptible_timeout( |
| 3228 | &context.completion, |
| 3229 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
| 3230 | context.magic = 0; |
| 3231 | if (lrc <= 0) |
| 3232 | { |
| 3233 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while " |
| 3234 | "requesting fullpower ", |
| 3235 | __FUNCTION__, (0 == lrc) ? |
| 3236 | "timeout" : "interrupt"); |
| 3237 | /* there is a race condition such that the callback |
| 3238 | function could be executing at the same time we are. of |
| 3239 | primary concern is if the callback function had already |
| 3240 | verified the "magic" but hasn't yet set the completion |
| 3241 | variable. Since the completion variable is on our |
| 3242 | stack, we'll delay just a bit to make sure the data is |
| 3243 | still valid if that is the case */ |
| 3244 | msleep(50); |
| 3245 | /* we'll now returned a cached value below */ |
| 3246 | } |
| 3247 | } |
| 3248 | hddLog(LOGE, "iwpriv Full Power completed\n"); |
| 3249 | break; |
| 3250 | } |
| 3251 | case 1: //Enable BMPS |
| 3252 | sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 3253 | break; |
| 3254 | case 2: //Disable BMPS |
| 3255 | sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 3256 | break; |
| 3257 | case 3: //Request Bmps |
| 3258 | { |
| 3259 | struct statsContext context; |
| 3260 | eHalStatus status; |
| 3261 | |
| 3262 | init_completion(&context.completion); |
| 3263 | |
| 3264 | context.pAdapter = pAdapter; |
| 3265 | context.magic = POWER_CONTEXT_MAGIC; |
| 3266 | |
| 3267 | status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3268 | iw_power_callback_fn, &context); |
| 3269 | if(eHAL_STATUS_PMC_PENDING == status) |
| 3270 | { |
| 3271 | int lrc = wait_for_completion_interruptible_timeout( |
| 3272 | &context.completion, |
| 3273 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
| 3274 | context.magic = 0; |
| 3275 | if (lrc <= 0) |
| 3276 | { |
| 3277 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while " |
| 3278 | "requesting BMPS", |
| 3279 | __FUNCTION__, (0 == lrc) ? "timeout" : |
| 3280 | "interrupt"); |
| 3281 | /* there is a race condition such that the callback |
| 3282 | function could be executing at the same time we are. of |
| 3283 | primary concern is if the callback function had already |
| 3284 | verified the "magic" but hasn't yet set the completion |
| 3285 | variable. Since the completion variable is on our |
| 3286 | stack, we'll delay just a bit to make sure the data is |
| 3287 | still valid if that is the case */ |
| 3288 | msleep(50); |
| 3289 | /* we'll now returned a cached value below */ |
| 3290 | } |
| 3291 | } |
| 3292 | hddLog(LOGE, "iwpriv Request BMPS completed\n"); |
| 3293 | break; |
| 3294 | } |
| 3295 | case 4: //Enable IMPS |
| 3296 | sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 3297 | break; |
| 3298 | case 5: //Disable IMPS |
| 3299 | sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 3300 | break; |
| 3301 | case 6: //Enable Standby |
| 3302 | sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE); |
| 3303 | break; |
| 3304 | case 7: //Disable Standby |
| 3305 | sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE); |
| 3306 | break; |
| 3307 | case 8: //Request Standby |
| 3308 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 3309 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3310 | (void)hdd_enter_standby(pAdapter->pHddCtx); |
| 3311 | #endif |
| 3312 | #endif |
| 3313 | break; |
| 3314 | case 9: //Start Auto Bmps Timer |
| 3315 | sme_StartAutoBmpsTimer(hHal); |
| 3316 | break; |
| 3317 | case 10://Stop Auto BMPS Timer |
| 3318 | sme_StopAutoBmpsTimer(hHal); |
| 3319 | break; |
| 3320 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 3321 | case 11://suspend to standby |
| 3322 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 3323 | nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend; |
| 3324 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1; |
| 3325 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3326 | hdd_suspend_wlan(NULL); |
| 3327 | #endif |
| 3328 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld; |
| 3329 | #endif |
| 3330 | break; |
| 3331 | case 12://suspend to deep sleep |
| 3332 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 3333 | nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend; |
| 3334 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2; |
| 3335 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3336 | hdd_suspend_wlan(NULL); |
| 3337 | #endif |
| 3338 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld; |
| 3339 | #endif |
| 3340 | break; |
| 3341 | case 13://resume from suspend |
| 3342 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 3343 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3344 | hdd_resume_wlan(NULL); |
| 3345 | #endif |
| 3346 | #endif |
| 3347 | break; |
| 3348 | #endif |
| 3349 | case 14://reset wlan (power down/power up) |
| 3350 | vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION); |
| 3351 | break; |
| 3352 | default: |
| 3353 | hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL\n", set_value); |
| 3354 | ret = -EINVAL; |
| 3355 | break; |
| 3356 | } |
| 3357 | break; |
| 3358 | } |
| 3359 | |
| 3360 | case WE_SET_MAX_ASSOC: |
| 3361 | { |
| 3362 | if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) || |
| 3363 | (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) |
| 3364 | { |
| 3365 | ret = -EINVAL; |
| 3366 | } |
| 3367 | else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, |
| 3368 | set_value, NULL, eANI_BOOLEAN_FALSE) |
| 3369 | != eHAL_STATUS_SUCCESS ) |
| 3370 | { |
| 3371 | ret = -EIO; |
| 3372 | } |
| 3373 | break; |
| 3374 | } |
| 3375 | |
| 3376 | case WE_SET_SAP_AUTO_CHANNEL_SELECTION: |
| 3377 | { |
| 3378 | if( 0 == set_value ) |
| 3379 | { |
| 3380 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0; |
| 3381 | } |
| 3382 | else if ( 1 == set_value ) |
| 3383 | { |
| 3384 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1; |
| 3385 | } |
| 3386 | else |
| 3387 | { |
| 3388 | hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL\n", set_value); |
| 3389 | ret = -EINVAL; |
| 3390 | } |
| 3391 | break; |
| 3392 | } |
| 3393 | |
| 3394 | case WE_SET_DATA_INACTIVITY_TO: |
| 3395 | { |
| 3396 | if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) || |
| 3397 | (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) || |
| 3398 | (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 3399 | WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT, |
| 3400 | set_value, |
| 3401 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)) |
| 3402 | { |
| 3403 | hddLog(LOGE,"Failure: Could not pass on " |
| 3404 | "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info " |
| 3405 | "to CCM\n"); |
| 3406 | ret = -EINVAL; |
| 3407 | } |
| 3408 | break; |
| 3409 | } |
| 3410 | case WE_SET_MAX_TX_POWER: |
| 3411 | { |
| 3412 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3413 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3414 | |
| 3415 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm", |
| 3416 | __func__, set_value); |
| 3417 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) != |
| 3418 | eHAL_STATUS_SUCCESS ) |
| 3419 | { |
| 3420 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 3421 | __func__); |
| 3422 | return -EIO; |
| 3423 | } |
| 3424 | |
| 3425 | break; |
| 3426 | } |
| 3427 | case WE_SET_HIGHER_DTIM_TRANSITION: |
| 3428 | { |
| 3429 | if(!((set_value == eANI_BOOLEAN_FALSE) || |
| 3430 | (set_value == eANI_BOOLEAN_TRUE))) |
| 3431 | { |
| 3432 | hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value); |
| 3433 | ret = -EINVAL; |
| 3434 | } |
| 3435 | else |
| 3436 | { |
| 3437 | if(pAdapter->higherDtimTransition != set_value) |
| 3438 | { |
| 3439 | pAdapter->higherDtimTransition = set_value; |
| 3440 | hddLog(LOG1, "%s: higherDtimTransition set to :%d", __FUNCTION__, pAdapter->higherDtimTransition); |
| 3441 | } |
| 3442 | } |
| 3443 | |
| 3444 | break; |
| 3445 | } |
| 3446 | |
| 3447 | case WE_SET_TM_LEVEL: |
| 3448 | { |
| 3449 | hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter); |
| 3450 | hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value); |
| 3451 | hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value); |
| 3452 | |
| 3453 | break; |
| 3454 | } |
| 3455 | |
| 3456 | default: |
| 3457 | { |
| 3458 | hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d \n", |
| 3459 | sub_cmd, set_value); |
| 3460 | break; |
| 3461 | } |
| 3462 | } |
| 3463 | |
| 3464 | return ret; |
| 3465 | } |
| 3466 | |
| 3467 | /* set param sub-ioctls */ |
| 3468 | static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info, |
| 3469 | union iwreq_data *wrqu, char *extra) |
| 3470 | { |
| 3471 | VOS_STATUS vstatus; |
| 3472 | int sub_cmd = wrqu->data.flags; |
| 3473 | int ret = 0; /* success */ |
| 3474 | hdd_adapter_t *pAdapter = (netdev_priv(dev)); |
| 3475 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3476 | #ifdef WLAN_FEATURE_VOWIFI |
| 3477 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 3478 | #endif /* WLAN_FEATURE_VOWIFI */ |
| 3479 | |
| 3480 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received length %d", __FUNCTION__, wrqu->data.length); |
| 3481 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Received data %s", __FUNCTION__, (char*)wrqu->data.pointer); |
| 3482 | |
| 3483 | switch(sub_cmd) |
| 3484 | { |
| 3485 | case WE_WOWL_ADD_PTRN: |
| 3486 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN\n"); |
| 3487 | hdd_add_wowl_ptrn((char*)wrqu->data.pointer); |
| 3488 | break; |
| 3489 | case WE_WOWL_DEL_PTRN: |
| 3490 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN\n"); |
| 3491 | hdd_del_wowl_ptrn((char*)wrqu->data.pointer); |
| 3492 | break; |
| 3493 | #if defined WLAN_FEATURE_VOWIFI |
| 3494 | case WE_NEIGHBOR_REPORT_REQUEST: |
| 3495 | { |
| 3496 | tRrmNeighborReq neighborReq; |
| 3497 | tRrmNeighborRspCallbackInfo callbackInfo; |
| 3498 | |
| 3499 | if (pConfig->fRrmEnable) |
| 3500 | { |
| 3501 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request\n"); |
| 3502 | neighborReq.no_ssid = (wrqu->data.length - 1) ? false : true ; |
| 3503 | if( !neighborReq.no_ssid ) |
| 3504 | { |
| 3505 | neighborReq.ssid.length = (wrqu->data.length - 1) > 32 ? 32 : (wrqu->data.length - 1) ; |
| 3506 | vos_mem_copy( neighborReq.ssid.ssId, wrqu->data.pointer, neighborReq.ssid.length ); |
| 3507 | } |
| 3508 | |
| 3509 | callbackInfo.neighborRspCallback = NULL; |
| 3510 | callbackInfo.neighborRspCallbackContext = NULL; |
| 3511 | callbackInfo.timeout = 5000; //5 seconds |
| 3512 | sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo ); |
| 3513 | } |
| 3514 | else |
| 3515 | { |
| 3516 | hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled\n", __func__); |
| 3517 | ret = -EINVAL; |
| 3518 | } |
| 3519 | } |
| 3520 | break; |
| 3521 | #endif |
| 3522 | #ifdef WLAN_FEATURE_P2P |
| 3523 | case WE_SET_AP_WPS_IE: |
| 3524 | hddLog( LOGE, "Received WE_SET_AP_WPS_IE" ); |
| 3525 | #ifdef WLAN_FEATURE_P2P |
| 3526 | sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), wrqu->data.pointer, wrqu->data.length ); |
| 3527 | #endif // WLAN_FEATURE_P2P |
| 3528 | break; |
| 3529 | #endif |
| 3530 | case WE_SET_CONFIG: |
| 3531 | vstatus = hdd_execute_config_command(pHddCtx, wrqu->data.pointer); |
| 3532 | if (VOS_STATUS_SUCCESS != vstatus) |
| 3533 | { |
| 3534 | ret = -EINVAL; |
| 3535 | } |
| 3536 | break; |
| 3537 | default: |
| 3538 | { |
| 3539 | hddLog(LOGE, "%s: Invalid sub command %d\n",__FUNCTION__, sub_cmd); |
| 3540 | ret = -EINVAL; |
| 3541 | break; |
| 3542 | } |
| 3543 | } |
| 3544 | return ret; |
| 3545 | } |
| 3546 | |
| 3547 | /* get param sub-ioctls */ |
| 3548 | static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info, |
| 3549 | union iwreq_data *wrqu, char *extra) |
| 3550 | { |
| 3551 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3552 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3553 | int *value = (int *)extra; |
| 3554 | int ret = 0; /* success */ |
| 3555 | |
| 3556 | |
| 3557 | switch (value[0]) |
| 3558 | { |
| 3559 | case WE_GET_11D_STATE: |
| 3560 | { |
| 3561 | tSmeConfigParams smeConfig;; |
| 3562 | |
| 3563 | sme_GetConfigParam(hHal,&smeConfig); |
| 3564 | |
| 3565 | *value = smeConfig.csrConfig.Is11dSupportEnabled; |
| 3566 | |
| 3567 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%ld!!\n"),*value); |
| 3568 | |
| 3569 | break; |
| 3570 | } |
| 3571 | |
| 3572 | case WE_IBSS_STATUS: |
| 3573 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****\n"); |
| 3574 | break; |
| 3575 | |
| 3576 | case WE_PMC_STATE: |
| 3577 | { |
| 3578 | *value = pmcGetPmcState(hHal); |
| 3579 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%ld!!\n"),*value); |
| 3580 | break; |
| 3581 | } |
| 3582 | case WE_GET_WLAN_DBG: |
| 3583 | { |
| 3584 | vos_trace_display(); |
| 3585 | *value = 0; |
| 3586 | break; |
| 3587 | } |
| 3588 | case WE_MODULE_DOWN_IND: |
| 3589 | { |
| 3590 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: sending WLAN_MODULE_DOWN_IND", __FUNCTION__); |
| 3591 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
| 3592 | #ifdef WLAN_BTAMP_FEATURE |
| 3593 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: Take down AMP PAL", __FUNCTION__); |
| 3594 | BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 3595 | #endif |
| 3596 | //WLANBAP_Close(vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 3597 | |
| 3598 | *value = 0; |
| 3599 | break; |
| 3600 | } |
| 3601 | case WE_GET_MAX_ASSOC: |
| 3602 | { |
| 3603 | if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS) |
| 3604 | { |
| 3605 | ret = -EIO; |
| 3606 | } |
| 3607 | break; |
| 3608 | } |
| 3609 | |
| 3610 | #ifdef FEATURE_WLAN_INTEGRATED_SOC |
| 3611 | case WE_GET_WDI_DBG: |
| 3612 | { |
| 3613 | wpalTraceDisplay(); |
| 3614 | *value = 0; |
| 3615 | break; |
| 3616 | } |
| 3617 | #endif // FEATURE_WLAN_INTEGRATED_SOC |
| 3618 | |
| 3619 | case WE_GET_SAP_AUTO_CHANNEL_SELECTION: |
| 3620 | { |
| 3621 | *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection; |
| 3622 | break; |
| 3623 | } |
| 3624 | case WE_GET_CONCURRENCY_MODE: |
| 3625 | { |
| 3626 | *value = hdd_get_concurrency_mode ( ); |
| 3627 | |
| 3628 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d \n"),*value); |
| 3629 | break; |
| 3630 | } |
| 3631 | |
| 3632 | default: |
| 3633 | { |
| 3634 | hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]); |
| 3635 | break; |
| 3636 | } |
| 3637 | } |
| 3638 | |
| 3639 | return ret; |
| 3640 | } |
| 3641 | |
| 3642 | /* set param sub-ioctls */ |
| 3643 | int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info, |
| 3644 | union iwreq_data *wrqu, char *extra) |
| 3645 | { |
| 3646 | int *value = (int *)extra; |
| 3647 | int sub_cmd = value[0]; |
| 3648 | int ret = 0; |
| 3649 | |
| 3650 | switch(sub_cmd) |
| 3651 | { |
| 3652 | case WE_SET_WLAN_DBG: |
| 3653 | { |
| 3654 | vos_trace_setValue( value[1], value[2], value[3]); |
| 3655 | break; |
| 3656 | } |
| 3657 | #ifdef FEATURE_WLAN_INTEGRATED_SOC |
| 3658 | case WE_SET_WDI_DBG: |
| 3659 | { |
| 3660 | wpalTraceSetLevel( value[1], value[2], value[3]); |
| 3661 | break; |
| 3662 | } |
| 3663 | #endif // FEATURE_WLAN_INTEGRATED_SOC |
| 3664 | case WE_SET_SAP_CHANNELS: |
| 3665 | { |
| 3666 | ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]); |
| 3667 | break; |
| 3668 | } |
| 3669 | |
| 3670 | default: |
| 3671 | { |
| 3672 | hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd ); |
| 3673 | break; |
| 3674 | } |
| 3675 | } |
| 3676 | return ret; |
| 3677 | } |
| 3678 | |
| 3679 | static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info, |
| 3680 | union iwreq_data *wrqu, char *extra) |
| 3681 | { |
| 3682 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3683 | int sub_cmd = wrqu->data.flags; |
| 3684 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3685 | VOS_STATUS status; |
| 3686 | #endif // FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3687 | switch(sub_cmd) |
| 3688 | { |
| 3689 | case WE_WLAN_VERSION: |
| 3690 | { |
| 3691 | #ifdef FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3692 | status = hdd_wlan_get_version(pAdapter, wrqu, extra); |
| 3693 | #else // FEATURE_WLAN_NON_INTEGRATED_SOC |
| 3694 | char *buf = extra; |
| 3695 | wrqu->data.length = snprintf(buf, WE_MAX_STR_LEN, "%s_", |
| 3696 | WLAN_CHIP_VERSION); |
| 3697 | #endif |
| 3698 | break; |
| 3699 | } |
| 3700 | |
| 3701 | case WE_GET_STATS: |
| 3702 | { |
| 3703 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3704 | hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats; |
| 3705 | hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats; |
| 3706 | |
| 3707 | snprintf(extra, WE_MAX_STR_LEN, |
| 3708 | "\nTransmit" |
| 3709 | "\ncalled %u, dropped %u, backpressured %u, queued %u" |
| 3710 | "\n dropped BK %u, BE %u, VI %u, VO %u" |
| 3711 | "\n classified BK %u, BE %u, VI %u, VO %u" |
| 3712 | "\nbackpressured BK %u, BE %u, VI %u, VO %u" |
| 3713 | "\n queued BK %u, BE %u, VI %u, VO %u" |
| 3714 | "\nfetched %u, empty %u, lowres %u, deqerr %u" |
| 3715 | "\ndequeued %u, depressured %u, completed %u, flushed %u" |
| 3716 | "\n fetched BK %u, BE %u, VI %u, VO %u" |
| 3717 | "\n dequeued BK %u, BE %u, VI %u, VO %u" |
| 3718 | "\n depressured BK %u, BE %u, VI %u, VO %u" |
| 3719 | "\n flushed BK %u, BE %u, VI %u, VO %u" |
| 3720 | "\n\nReceive" |
| 3721 | "\nchains %u, packets %u, dropped %u, delivered %u, refused %u" |
| 3722 | "\n\nResetsStats" |
| 3723 | "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u" |
| 3724 | "\n", |
| 3725 | pStats->txXmitCalled, |
| 3726 | pStats->txXmitDropped, |
| 3727 | pStats->txXmitBackPressured, |
| 3728 | pStats->txXmitQueued, |
| 3729 | |
| 3730 | pStats->txXmitDroppedAC[WLANTL_AC_BK], |
| 3731 | pStats->txXmitDroppedAC[WLANTL_AC_BE], |
| 3732 | pStats->txXmitDroppedAC[WLANTL_AC_VI], |
| 3733 | pStats->txXmitDroppedAC[WLANTL_AC_VO], |
| 3734 | |
| 3735 | pStats->txXmitClassifiedAC[WLANTL_AC_BK], |
| 3736 | pStats->txXmitClassifiedAC[WLANTL_AC_BE], |
| 3737 | pStats->txXmitClassifiedAC[WLANTL_AC_VI], |
| 3738 | pStats->txXmitClassifiedAC[WLANTL_AC_VO], |
| 3739 | |
| 3740 | pStats->txXmitBackPressuredAC[WLANTL_AC_BK], |
| 3741 | pStats->txXmitBackPressuredAC[WLANTL_AC_BE], |
| 3742 | pStats->txXmitBackPressuredAC[WLANTL_AC_VI], |
| 3743 | pStats->txXmitBackPressuredAC[WLANTL_AC_VO], |
| 3744 | |
| 3745 | pStats->txXmitQueuedAC[WLANTL_AC_BK], |
| 3746 | pStats->txXmitQueuedAC[WLANTL_AC_BE], |
| 3747 | pStats->txXmitQueuedAC[WLANTL_AC_VI], |
| 3748 | pStats->txXmitQueuedAC[WLANTL_AC_VO], |
| 3749 | |
| 3750 | pStats->txFetched, |
| 3751 | pStats->txFetchEmpty, |
| 3752 | pStats->txFetchLowResources, |
| 3753 | pStats->txFetchDequeueError, |
| 3754 | |
| 3755 | pStats->txFetchDequeued, |
| 3756 | pStats->txFetchDePressured, |
| 3757 | pStats->txCompleted, |
| 3758 | pStats->txFlushed, |
| 3759 | |
| 3760 | pStats->txFetchedAC[WLANTL_AC_BK], |
| 3761 | pStats->txFetchedAC[WLANTL_AC_BE], |
| 3762 | pStats->txFetchedAC[WLANTL_AC_VI], |
| 3763 | pStats->txFetchedAC[WLANTL_AC_VO], |
| 3764 | |
| 3765 | pStats->txFetchDequeuedAC[WLANTL_AC_BK], |
| 3766 | pStats->txFetchDequeuedAC[WLANTL_AC_BE], |
| 3767 | pStats->txFetchDequeuedAC[WLANTL_AC_VI], |
| 3768 | pStats->txFetchDequeuedAC[WLANTL_AC_VO], |
| 3769 | |
| 3770 | pStats->txFetchDePressuredAC[WLANTL_AC_BK], |
| 3771 | pStats->txFetchDePressuredAC[WLANTL_AC_BE], |
| 3772 | pStats->txFetchDePressuredAC[WLANTL_AC_VI], |
| 3773 | pStats->txFetchDePressuredAC[WLANTL_AC_VO], |
| 3774 | |
| 3775 | pStats->txFlushedAC[WLANTL_AC_BK], |
| 3776 | pStats->txFlushedAC[WLANTL_AC_BE], |
| 3777 | pStats->txFlushedAC[WLANTL_AC_VI], |
| 3778 | pStats->txFlushedAC[WLANTL_AC_VO], |
| 3779 | |
| 3780 | pStats->rxChains, |
| 3781 | pStats->rxPackets, |
| 3782 | pStats->rxDropped, |
| 3783 | pStats->rxDelivered, |
| 3784 | pStats->rxRefused, |
| 3785 | |
| 3786 | pResetStats->totalLogpResets, |
| 3787 | pResetStats->totalCMD53Failures, |
| 3788 | pResetStats->totalMutexReadFailures, |
| 3789 | pResetStats->totalMIFErrorFailures, |
| 3790 | pResetStats->totalFWHearbeatFailures, |
| 3791 | pResetStats->totalUnknownExceptions |
| 3792 | ); |
| 3793 | wrqu->data.length = strlen(extra)+1; |
| 3794 | break; |
| 3795 | } |
| 3796 | |
| 3797 | case WE_GET_CFG: |
| 3798 | { |
| 3799 | hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN); |
| 3800 | wrqu->data.length = strlen(extra)+1; |
| 3801 | break; |
| 3802 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3803 | #ifdef WLAN_FEATURE_11AC |
| 3804 | case WE_GET_RSSI: |
| 3805 | { |
| 3806 | v_S7_t s7Rssi = 0; |
| 3807 | wlan_hdd_get_rssi(pAdapter, &s7Rssi); |
| 3808 | snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi); |
| 3809 | wrqu->data.length = strlen(extra)+1; |
| 3810 | break; |
| 3811 | } |
| 3812 | #endif |
| 3813 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3814 | case WE_GET_WMM_STATUS: |
| 3815 | { |
| 3816 | snprintf(extra, WE_MAX_STR_LEN, |
| 3817 | "\nDir: 0=up, 1=down, 3=both\n" |
| 3818 | "|------------------------|\n" |
| 3819 | "|AC | ACM |Admitted| Dir |\n" |
| 3820 | "|------------------------|\n" |
| 3821 | "|VO | %d | %3s | %d |\n" |
| 3822 | "|VI | %d | %3s | %d |\n" |
| 3823 | "|BE | %d | %3s | %d |\n" |
| 3824 | "|BK | %d | %3s | %d |\n" |
| 3825 | "|------------------------|\n", |
| 3826 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired, |
| 3827 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO", |
| 3828 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction, |
| 3829 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired, |
| 3830 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO", |
| 3831 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction, |
| 3832 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired, |
| 3833 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO", |
| 3834 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction, |
| 3835 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired, |
| 3836 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO", |
| 3837 | pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction); |
| 3838 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3840 | wrqu->data.length = strlen(extra)+1; |
| 3841 | break; |
| 3842 | } |
| 3843 | case WE_GET_CHANNEL_LIST: |
| 3844 | { |
| 3845 | VOS_STATUS status; |
| 3846 | v_U8_t i, len; |
| 3847 | char* buf ; |
| 3848 | tChannelListInfo channel_list; |
| 3849 | |
| 3850 | status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list); |
| 3851 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 3852 | { |
| 3853 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!\n",__func__); |
| 3854 | return -EINVAL; |
| 3855 | } |
| 3856 | buf = extra; |
| 3857 | |
| 3858 | /** |
| 3859 | * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer |
| 3860 | * needed = 5 * number of channels. Check if sufficient buffer is available and |
| 3861 | * then proceed to fill the buffer. |
| 3862 | */ |
| 3863 | if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 3864 | { |
| 3865 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Insufficient Buffer to populate channel list\n",__func__); |
| 3866 | return -EINVAL; |
| 3867 | } |
| 3868 | len = snprintf(buf, 5, "%u ", channel_list.num_channels); |
| 3869 | buf += len; |
| 3870 | for(i = 0 ; i < channel_list.num_channels; i++) |
| 3871 | { |
| 3872 | len = snprintf(buf, 5, |
| 3873 | "%u ", channel_list.channels[i]); |
| 3874 | buf += len; |
| 3875 | } |
| 3876 | wrqu->data.length = strlen(extra)+1; |
| 3877 | |
| 3878 | break; |
| 3879 | } |
| 3880 | default: |
| 3881 | { |
| 3882 | hddLog(LOGE, "Invalid IOCTL command %d \n", sub_cmd ); |
| 3883 | break; |
| 3884 | } |
| 3885 | } |
| 3886 | |
| 3887 | return 0; |
| 3888 | } |
| 3889 | |
| 3890 | /* action sub-ioctls */ |
| 3891 | static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info, |
| 3892 | union iwreq_data *wrqu, char *extra) |
| 3893 | { |
| 3894 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3895 | int sub_cmd = wrqu->data.flags; |
| 3896 | int ret = 0; /* sucess */ |
| 3897 | |
| 3898 | switch (sub_cmd) |
| 3899 | { |
| 3900 | case WE_CLEAR_STATS: |
| 3901 | { |
| 3902 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __FUNCTION__); |
| 3903 | memset(&pAdapter->stats, 0, sizeof(pAdapter->stats)); |
| 3904 | memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats)); |
| 3905 | break; |
| 3906 | } |
| 3907 | #ifdef WLAN_SOFTAP_FEATURE |
| 3908 | case WE_INIT_AP: |
| 3909 | { |
| 3910 | pr_info("Init AP trigger\n"); |
| 3911 | hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d", |
| 3912 | wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE); |
| 3913 | break; |
| 3914 | } |
| 3915 | case WE_STOP_AP: |
| 3916 | { |
| 3917 | /*FIX ME: Need to be revisited if multiple SAPs to be supported */ |
| 3918 | /* As Soft AP mode has been changed to STA already with killing of Hostapd, |
| 3919 | * this is a dead code and need to find the adpater by name rather than mode */ |
| 3920 | hdd_adapter_t* pAdapter_to_stop = |
| 3921 | hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0"); |
| 3922 | if( pAdapter_to_stop ) |
| 3923 | { |
| 3924 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3925 | |
| 3926 | pr_info("Stopping AP mode\n"); |
| 3927 | |
| 3928 | /*Make sure that pAdapter cleaned properly*/ |
| 3929 | hdd_stop_adapter( pHddCtx, pAdapter_to_stop ); |
| 3930 | hdd_deinit_adapter( pHddCtx, pAdapter_to_stop ); |
| 3931 | memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx)); |
| 3932 | |
| 3933 | wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter), |
| 3934 | pAdapter_to_stop->macAddressCurrent.bytes); |
| 3935 | hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop, |
| 3936 | TRUE); |
| 3937 | } |
| 3938 | else |
| 3939 | { |
| 3940 | printk(KERN_ERR"SAP adaptor not found to stop it!\n"); |
| 3941 | } |
| 3942 | |
| 3943 | break; |
| 3944 | } |
| 3945 | #endif |
| 3946 | #ifdef WLAN_BTAMP_FEATURE |
| 3947 | case WE_ENABLE_AMP: |
| 3948 | { |
| 3949 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __FUNCTION__); |
| 3950 | WLANBAP_RegisterWithHCI(pAdapter); |
| 3951 | break; |
| 3952 | } |
| 3953 | case WE_DISABLE_AMP: |
| 3954 | { |
| 3955 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 3956 | VOS_STATUS status; |
| 3957 | |
| 3958 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __FUNCTION__); |
| 3959 | |
| 3960 | pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 3961 | status = WLANBAP_StopAmp(); |
| 3962 | if(VOS_STATUS_SUCCESS != status ) |
| 3963 | { |
| 3964 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 3965 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 3966 | "%s: Failed to stop AMP", __func__); |
| 3967 | } |
| 3968 | else |
| 3969 | { |
| 3970 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 3971 | msleep(500); |
| 3972 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 3973 | WLANBAP_DeregisterFromHCI(); |
| 3974 | } |
| 3975 | |
| 3976 | break; |
| 3977 | } |
| 3978 | #endif |
| 3979 | |
| 3980 | default: |
| 3981 | { |
| 3982 | hddLog(LOGE, "%s: unknown ioctl %d", __FUNCTION__, sub_cmd); |
| 3983 | break; |
| 3984 | } |
| 3985 | } |
| 3986 | |
| 3987 | return ret; |
| 3988 | } |
| 3989 | |
| 3990 | int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info, |
| 3991 | union iwreq_data *wrqu, char *extra) |
| 3992 | { |
| 3993 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3994 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 3995 | int sub_cmd = wrqu->data.flags; |
| 3996 | int *value = (int*)wrqu->data.pointer; |
| 3997 | int apps_args[MAX_VAR_ARGS] = {0}; |
| 3998 | int num_args = wrqu->data.length; |
| 3999 | |
| 4000 | hddLog(LOG1, "%s: Received length %d", __FUNCTION__, wrqu->data.length); |
| 4001 | if (num_args > MAX_VAR_ARGS) |
| 4002 | { |
| 4003 | num_args = MAX_VAR_ARGS; |
| 4004 | } |
| 4005 | vos_mem_copy(apps_args, value, (sizeof(int)) * num_args); |
| 4006 | |
| 4007 | switch (sub_cmd) |
| 4008 | { |
| 4009 | case WE_LOG_DUMP_CMD: |
| 4010 | { |
| 4011 | hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d", |
| 4012 | __FUNCTION__, apps_args[0], apps_args[1], apps_args[2], |
| 4013 | apps_args[3], apps_args[4]); |
| 4014 | |
| 4015 | logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2], |
| 4016 | apps_args[3], apps_args[4]); |
| 4017 | |
| 4018 | } |
| 4019 | break; |
| 4020 | |
| 4021 | #ifdef WLAN_FEATURE_P2P |
| 4022 | case WE_P2P_NOA_CMD: |
| 4023 | { |
| 4024 | p2p_app_setP2pPs_t p2pNoA; |
| 4025 | |
| 4026 | p2pNoA.opp_ps = apps_args[0]; |
| 4027 | p2pNoA.ctWindow = apps_args[1]; |
| 4028 | p2pNoA.duration = apps_args[2]; |
| 4029 | p2pNoA.interval = apps_args[3]; |
| 4030 | p2pNoA.count = apps_args[4]; |
| 4031 | p2pNoA.single_noa_duration = apps_args[5]; |
| 4032 | p2pNoA.psSelection = apps_args[6]; |
| 4033 | |
| 4034 | hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d " |
| 4035 | "interval %d count %d single noa duration %d PsSelection %x", |
| 4036 | __FUNCTION__, apps_args[0], apps_args[1], apps_args[2], |
| 4037 | apps_args[3], apps_args[4], apps_args[5], apps_args[6]); |
| 4038 | |
| 4039 | hdd_setP2pPs(dev, &p2pNoA); |
| 4040 | |
| 4041 | } |
| 4042 | break; |
| 4043 | #endif |
| 4044 | |
| 4045 | default: |
| 4046 | { |
| 4047 | hddLog(LOGE, "Invalid IOCTL command %d", sub_cmd ); |
| 4048 | } |
| 4049 | break; |
| 4050 | } |
| 4051 | |
| 4052 | return 0; |
| 4053 | } |
| 4054 | |
| 4055 | |
| 4056 | static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info, |
| 4057 | union iwreq_data *wrqu, char *extra) |
| 4058 | { |
| 4059 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4060 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4061 | hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra; |
| 4062 | int params[HDD_WLAN_WMM_PARAM_COUNT]; |
| 4063 | sme_QosWmmTspecInfo tSpec; |
| 4064 | v_U32_t handle; |
| 4065 | |
| 4066 | // make sure the application is sufficiently priviledged |
| 4067 | // note that the kernel will do this for "set" ioctls, but since |
| 4068 | // this ioctl wants to return status to user space it must be |
| 4069 | // defined as a "get" ioctl |
| 4070 | if (!capable(CAP_NET_ADMIN)) |
| 4071 | { |
| 4072 | return -EPERM; |
| 4073 | } |
| 4074 | |
| 4075 | // we must be associated in order to add a tspec |
| 4076 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4077 | { |
| 4078 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4079 | return 0; |
| 4080 | } |
| 4081 | |
| 4082 | // since we are defined to be a "get" ioctl, and since the number |
| 4083 | // of params exceeds the number of params that wireless extensions |
| 4084 | // will pass down in the iwreq_data, we must copy the "set" params |
| 4085 | // from user space ourselves |
| 4086 | if (copy_from_user(¶ms, wrqu->data.pointer, sizeof(params))) |
| 4087 | { |
| 4088 | // hmmm, can't get them |
| 4089 | return -EIO; |
| 4090 | } |
| 4091 | |
| 4092 | // clear the tspec |
| 4093 | memset(&tSpec, 0, sizeof(tSpec)); |
| 4094 | |
| 4095 | // validate the handle |
| 4096 | handle = params[HDD_WLAN_WMM_PARAM_HANDLE]; |
| 4097 | if (HDD_WMM_HANDLE_IMPLICIT == handle) |
| 4098 | { |
| 4099 | // that one is reserved |
| 4100 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4101 | return 0; |
| 4102 | } |
| 4103 | |
| 4104 | // validate the TID |
| 4105 | if (params[HDD_WLAN_WMM_PARAM_TID] > 7) |
| 4106 | { |
| 4107 | // out of range |
| 4108 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4109 | return 0; |
| 4110 | } |
| 4111 | tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID]; |
| 4112 | |
| 4113 | // validate the direction |
| 4114 | switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) |
| 4115 | { |
| 4116 | case HDD_WLAN_WMM_DIRECTION_UPSTREAM: |
| 4117 | tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK; |
| 4118 | break; |
| 4119 | |
| 4120 | case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM: |
| 4121 | tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK; |
| 4122 | break; |
| 4123 | |
| 4124 | case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL: |
| 4125 | tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH; |
| 4126 | break; |
| 4127 | |
| 4128 | default: |
| 4129 | // unknown |
| 4130 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4131 | return 0; |
| 4132 | } |
| 4133 | |
| 4134 | // validate the user priority |
| 4135 | if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) |
| 4136 | { |
| 4137 | // out of range |
| 4138 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4139 | return 0; |
| 4140 | } |
| 4141 | tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY]; |
| 4142 | |
| 4143 | tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE]; |
| 4144 | tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE]; |
| 4145 | tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE]; |
| 4146 | tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE]; |
| 4147 | tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE]; |
| 4148 | tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE]; |
| 4149 | tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE]; |
| 4150 | tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE]; |
| 4151 | tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL]; |
| 4152 | tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL]; |
| 4153 | tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL]; |
| 4154 | tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL]; |
| 4155 | |
| 4156 | tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN]; |
| 4157 | |
| 4158 | // validate the ts info ack policy |
| 4159 | switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) |
| 4160 | { |
| 4161 | case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK: |
| 4162 | tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK; |
| 4163 | break; |
| 4164 | |
| 4165 | case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK: |
| 4166 | tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK; |
| 4167 | break; |
| 4168 | |
| 4169 | default: |
| 4170 | // unknown |
| 4171 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4172 | return 0; |
| 4173 | } |
| 4174 | |
| 4175 | *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec); |
| 4176 | return 0; |
| 4177 | } |
| 4178 | |
| 4179 | |
| 4180 | static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info, |
| 4181 | union iwreq_data *wrqu, char *extra) |
| 4182 | { |
| 4183 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4184 | int *params = (int *)extra; |
| 4185 | hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra; |
| 4186 | v_U32_t handle; |
| 4187 | |
| 4188 | // make sure the application is sufficiently priviledged |
| 4189 | // note that the kernel will do this for "set" ioctls, but since |
| 4190 | // this ioctl wants to return status to user space it must be |
| 4191 | // defined as a "get" ioctl |
| 4192 | if (!capable(CAP_NET_ADMIN)) |
| 4193 | { |
| 4194 | return -EPERM; |
| 4195 | } |
| 4196 | |
| 4197 | // although we are defined to be a "get" ioctl, the params we require |
| 4198 | // will fit in the iwreq_data, therefore unlike iw_add_tspec() there |
| 4199 | // is no need to copy the params from user space |
| 4200 | |
| 4201 | // validate the handle |
| 4202 | handle = params[HDD_WLAN_WMM_PARAM_HANDLE]; |
| 4203 | if (HDD_WMM_HANDLE_IMPLICIT == handle) |
| 4204 | { |
| 4205 | // that one is reserved |
| 4206 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4207 | return 0; |
| 4208 | } |
| 4209 | |
| 4210 | *pStatus = hdd_wmm_delts(pAdapter, handle); |
| 4211 | return 0; |
| 4212 | } |
| 4213 | |
| 4214 | |
| 4215 | static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info, |
| 4216 | union iwreq_data *wrqu, char *extra) |
| 4217 | { |
| 4218 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4219 | int *params = (int *)extra; |
| 4220 | hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra; |
| 4221 | v_U32_t handle; |
| 4222 | |
| 4223 | // although we are defined to be a "get" ioctl, the params we require |
| 4224 | // will fit in the iwreq_data, therefore unlike iw_add_tspec() there |
| 4225 | // is no need to copy the params from user space |
| 4226 | |
| 4227 | // validate the handle |
| 4228 | handle = params[HDD_WLAN_WMM_PARAM_HANDLE]; |
| 4229 | if (HDD_WMM_HANDLE_IMPLICIT == handle) |
| 4230 | { |
| 4231 | // that one is reserved |
| 4232 | *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM; |
| 4233 | return 0; |
| 4234 | } |
| 4235 | |
| 4236 | *pStatus = hdd_wmm_checkts(pAdapter, handle); |
| 4237 | return 0; |
| 4238 | } |
| 4239 | |
| 4240 | |
| 4241 | #ifdef FEATURE_WLAN_WAPI |
| 4242 | static int iw_qcom_set_wapi_mode(struct net_device *dev, struct iw_request_info *info, |
| 4243 | union iwreq_data *wrqu, char *extra) |
| 4244 | { |
| 4245 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4246 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4247 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4248 | tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile; |
| 4249 | |
| 4250 | WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)wrqu->data.pointer; |
| 4251 | |
| 4252 | hddLog(LOG1, "The function iw_qcom_set_wapi_mode called"); |
| 4253 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)wrqu->data.pointer); |
| 4254 | hddLog(LOG1, "%s: Received length %d", __FUNCTION__, wrqu->data.length); |
| 4255 | hddLog(LOG1, "%s: Input Data (wreq) WAPI Mode:%02d", __FUNCTION__, pWapiMode->wapiMode); |
| 4256 | |
| 4257 | |
| 4258 | if(WZC_ORIGINAL == pWapiMode->wapiMode) { |
| 4259 | hddLog(LOG1, "%s: WAPI Mode Set to OFF", __FUNCTION__); |
| 4260 | /* Set Encryption mode to defualt , this allows next successfull non-WAPI Association */ |
| 4261 | pRoamProfile->EncryptionType.numEntries = 1; |
| 4262 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 4263 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 4264 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 4265 | |
| 4266 | pRoamProfile->AuthType.numEntries = 1; |
| 4267 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 4268 | pRoamProfile->AuthType.authType[0] = pHddStaCtx->conn_info.authType; |
| 4269 | } |
| 4270 | else if(WAPI_EXTENTION == pWapiMode->wapiMode) { |
| 4271 | hddLog(LOG1, "%s: WAPI Mode Set to ON", __FUNCTION__); |
| 4272 | } |
| 4273 | else |
| 4274 | return -EINVAL; |
| 4275 | |
| 4276 | pAdapter->wapi_info.nWapiMode = pWapiMode->wapiMode; |
| 4277 | |
| 4278 | return 0; |
| 4279 | } |
| 4280 | |
| 4281 | static int iw_qcom_get_wapi_mode(struct net_device *dev, struct iw_request_info *info, |
| 4282 | union iwreq_data *wrqu, char *extra) |
| 4283 | { |
| 4284 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4285 | WAPI_FUNCTION_MODE *pWapiMode = (WAPI_FUNCTION_MODE *)(extra); |
| 4286 | |
| 4287 | hddLog(LOG1, "The function iw_qcom_get_wapi_mode called"); |
| 4288 | |
| 4289 | pWapiMode->wapiMode = pAdapter->wapi_info.nWapiMode; |
| 4290 | hddLog(LOG1, "%s: GET WAPI Mode Value:%02d", __FUNCTION__, pWapiMode->wapiMode); |
| 4291 | printk("\nGET WAPI MODE:%d",pWapiMode->wapiMode); |
| 4292 | return 0; |
| 4293 | } |
| 4294 | |
| 4295 | static int iw_qcom_set_wapi_assoc_info(struct net_device *dev, struct iw_request_info *info, |
| 4296 | union iwreq_data *wrqu, char *extra) |
| 4297 | { |
| 4298 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4299 | // WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(wrqu->data.pointer); |
| 4300 | WAPI_AssocInfo *pWapiAssocInfo = (WAPI_AssocInfo *)(extra); |
| 4301 | int i = 0, j = 0; |
| 4302 | hddLog(LOG1, "The function iw_qcom_set_wapi_assoc_info called"); |
| 4303 | hddLog(LOG1, "%s: Received length %d", __FUNCTION__, wrqu->data.length); |
| 4304 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)wrqu->data.pointer); |
| 4305 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)extra); |
| 4306 | |
| 4307 | VOS_ASSERT(pWapiAssocInfo); |
| 4308 | |
| 4309 | hddLog(LOG1, "%s: INPUT DATA:\nElement ID:0x%02x Length:0x%02x Version:0x%04x\n",__FUNCTION__,pWapiAssocInfo->elementID,pWapiAssocInfo->length,pWapiAssocInfo->version); |
| 4310 | hddLog(LOG1,"%s: akm Suite Cnt:0x%04x",__FUNCTION__,pWapiAssocInfo->akmSuiteCount); |
| 4311 | for(i =0 ; i < 16 ; i++) |
| 4312 | hddLog(LOG1,"akm suite[%02d]:0x%08lx",i,pWapiAssocInfo->akmSuite[i]); |
| 4313 | |
| 4314 | hddLog(LOG1,"%s: Unicast Suite Cnt:0x%04x",__FUNCTION__,pWapiAssocInfo->unicastSuiteCount); |
| 4315 | for(i =0 ; i < 16 ; i++) |
| 4316 | hddLog(LOG1, "Unicast suite[%02d]:0x%08lx",i,pWapiAssocInfo->unicastSuite[i]); |
| 4317 | |
| 4318 | hddLog(LOG1,"%s: Multicast suite:0x%08lx Wapi capa:0x%04x",__FUNCTION__,pWapiAssocInfo->multicastSuite,pWapiAssocInfo->wapiCability); |
| 4319 | hddLog(LOG1, "%s: BKID Cnt:0x%04x\n",__FUNCTION__,pWapiAssocInfo->bkidCount); |
| 4320 | for(i = 0 ; i < 16 ; i++) { |
| 4321 | hddLog(LOG1, "BKID List[%02d].bkid:0x",i); |
| 4322 | for(j = 0 ; j < 16 ; j++) |
| 4323 | hddLog(LOG1,"%02x",pWapiAssocInfo->bkidList[i].bkid[j]); |
| 4324 | } |
| 4325 | |
| 4326 | /* We are not using the entire IE as provided by the supplicant. |
| 4327 | * This is being calculated by SME. This is the same as in the |
| 4328 | * case of WPA. Only the auth mode information needs to be |
| 4329 | * extracted here*/ |
| 4330 | if ( pWapiAssocInfo->akmSuite[0] == WAPI_PSK_AKM_SUITE ) { |
| 4331 | hddLog(LOG1, "%s: WAPI AUTH MODE SET TO PSK",__FUNCTION__); |
| 4332 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
| 4333 | } |
| 4334 | |
| 4335 | if ( pWapiAssocInfo->akmSuite[0] == WAPI_CERT_AKM_SUITE) { |
| 4336 | hddLog(LOG1, "%s: WAPI AUTH MODE SET TO CERTIFICATE",__FUNCTION__); |
| 4337 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 4338 | } |
| 4339 | return 0; |
| 4340 | } |
| 4341 | |
| 4342 | static int iw_qcom_set_wapi_key(struct net_device *dev, struct iw_request_info *info, |
| 4343 | union iwreq_data *wrqu, char *extra) |
| 4344 | { |
| 4345 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4346 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4347 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 4348 | tANI_U32 roamId = 0xFF; |
| 4349 | tANI_U8 *pKeyPtr = NULL; |
| 4350 | v_BOOL_t isConnected = TRUE; |
| 4351 | tCsrRoamSetKey setKey; |
| 4352 | int i = 0; |
| 4353 | |
| 4354 | // WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(wrqu->data.pointer); |
| 4355 | WLAN_WAPI_KEY *pWapiKey = (WLAN_WAPI_KEY *)(extra); |
| 4356 | |
| 4357 | hddLog(LOG1, "The function iw_qcom_set_wapi_key called "); |
| 4358 | hddLog(LOG1, "%s: Received length %d", __FUNCTION__, wrqu->data.length); |
| 4359 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)wrqu->data.pointer); |
| 4360 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)extra); |
| 4361 | |
| 4362 | hddLog(LOG1,":s: INPUT DATA:\nKey Type:0x%02x Key Direction:0x%02x KEY ID:0x%02x\n", __FUNCTION__,pWapiKey->keyType,pWapiKey->keyDirection,pWapiKey->keyId); |
| 4363 | hddLog(LOG1,"Add Index:0x"); |
| 4364 | for(i =0 ; i < 12 ; i++) |
| 4365 | hddLog(LOG1,"%02x",pWapiKey->addrIndex[i]); |
| 4366 | |
| 4367 | hddLog(LOG1,"\n%s: WAPI ENCRYPTION KEY LENGTH:0x%04x", __FUNCTION__,pWapiKey->wpiekLen); |
| 4368 | hddLog(LOG1, "WAPI ENCRYPTION KEY:0x"); |
| 4369 | for(i =0 ; i < 16 ; i++) |
| 4370 | hddLog(LOG1,"%02x",pWapiKey->wpiek[i]); |
| 4371 | |
| 4372 | hddLog(LOG1,"\n%s: WAPI INTEGRITY CHECK KEY LENGTH:0x%04x", __FUNCTION__,pWapiKey->wpickLen); |
| 4373 | hddLog(LOG1,"WAPI INTEGRITY CHECK KEY:0x"); |
| 4374 | for(i =0 ; i < 16 ; i++) |
| 4375 | hddLog(LOG1,"%02x",pWapiKey->wpick[i]); |
| 4376 | |
| 4377 | hddLog(LOG1,"\nWAPI PN NUMBER:0x"); |
| 4378 | for(i = 0 ; i < 16 ; i++) |
| 4379 | hddLog(LOG1,"%02x",pWapiKey->pn[i]); |
| 4380 | |
| 4381 | // Clear the setkey memory |
| 4382 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 4383 | // Store Key ID |
| 4384 | setKey.keyId = (unsigned char)( pWapiKey->keyId ); |
| 4385 | // SET WAPI Encryption |
| 4386 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; |
| 4387 | // Key Directionn both TX and RX |
| 4388 | setKey.keyDirection = eSIR_TX_RX; // Do WE NEED to update this based on Key Type as GRP/UNICAST?? |
| 4389 | // the PAE role |
| 4390 | setKey.paeRole = 0 ; |
| 4391 | |
| 4392 | switch ( pWapiKey->keyType ) |
| 4393 | { |
| 4394 | case HDD_PAIRWISE_WAPI_KEY: |
| 4395 | { |
| 4396 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 4397 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 4398 | break; |
| 4399 | } |
| 4400 | case HDD_GROUP_WAPI_KEY: |
| 4401 | { |
| 4402 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 4403 | break; |
| 4404 | } |
| 4405 | default: |
| 4406 | { |
| 4407 | //Any other option is invalid. |
| 4408 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4409 | "[%4d] %s() failed to Set Key. Invalid key type %d", __LINE__,__FUNCTION__ , -1 ); |
| 4410 | |
| 4411 | hddLog(LOGE," %s: Error WAPI Key Add Type",__FUNCTION__); |
| 4412 | halStatus = !eHAL_STATUS_SUCCESS; // NEED TO UPDATE THIS WITH CORRECT VALUE |
| 4413 | break; // NEED RETURN FROM HERE ???? |
| 4414 | } |
| 4415 | } |
| 4416 | |
| 4417 | // Concatenating the Encryption Key (EK) and the MIC key (CK): EK followed by CK |
| 4418 | setKey.keyLength = (v_U16_t)((pWapiKey->wpiekLen)+(pWapiKey->wpickLen)); |
| 4419 | pKeyPtr = setKey.Key; |
| 4420 | memcpy( pKeyPtr, pWapiKey->wpiek, pWapiKey->wpiekLen ); |
| 4421 | pKeyPtr += pWapiKey->wpiekLen; |
| 4422 | memcpy( pKeyPtr, pWapiKey->wpick, pWapiKey->wpickLen ); |
| 4423 | |
| 4424 | // Set the new key with SME. |
| 4425 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 4426 | |
| 4427 | if ( isConnected ) { |
| 4428 | halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &setKey, &roamId ); |
| 4429 | if ( halStatus != eHAL_STATUS_SUCCESS ) |
| 4430 | { |
| 4431 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4432 | "[%4d] sme_RoamSetKey returned ERROR status= %d", __LINE__, halStatus ); |
| 4433 | |
| 4434 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 4435 | } |
| 4436 | } |
| 4437 | #if 0 /// NEED TO CHECK ON THIS |
| 4438 | else |
| 4439 | { |
| 4440 | // Store the keys in the adapter to be moved to the profile & passed to |
| 4441 | // SME in the ConnectRequest if we are not yet in connected state. |
| 4442 | memcpy( &pAdapter->setKey[ setKey.keyId ], &setKey, sizeof( setKey ) ); |
| 4443 | pAdapter->fKeySet[ setKey.keyId ] = TRUE; |
| 4444 | |
| 4445 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 4446 | " Saving key [idx= %d] to apply when moving to connected state ", |
| 4447 | setKey.keyId ); |
| 4448 | |
| 4449 | } |
| 4450 | #endif |
| 4451 | return halStatus; |
| 4452 | } |
| 4453 | |
| 4454 | static int iw_qcom_set_wapi_bkid(struct net_device *dev, struct iw_request_info *info, |
| 4455 | union iwreq_data *wrqu, char *extra) |
| 4456 | { |
| 4457 | #ifdef WLAN_DEBUG |
| 4458 | int i = 0; |
| 4459 | WLAN_BKID_LIST *pBkid = ( WLAN_BKID_LIST *) (wrqu->data.pointer); |
| 4460 | #endif |
| 4461 | |
| 4462 | hddLog(LOG1, "The function iw_qcom_set_wapi_bkid called"); |
| 4463 | hddLog(LOG1, "%s: Received length %d", __FUNCTION__, wrqu->data.length); |
| 4464 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)wrqu->data.pointer); |
| 4465 | hddLog(LOG1, "%s: Received data %s", __FUNCTION__, (char*)extra); |
| 4466 | |
| 4467 | hddLog(LOG1,"%s: INPUT DATA:\n BKID Length:0x%08lx\n", __FUNCTION__,pBkid->length); |
| 4468 | hddLog(LOG1,"%s: BKID Cnt:0x%04lx",pBkid->BKIDCount); |
| 4469 | |
| 4470 | hddLog(LOG1,"BKID KEY LIST[0]:0x"); |
| 4471 | #ifdef WLAN_DEBUG |
| 4472 | for(i =0 ; i < 16 ; i++) |
| 4473 | hddLog(LOG1,"%02x",pBkid->BKID[0].bkid[i]); |
| 4474 | #endif |
| 4475 | |
| 4476 | return 0; |
| 4477 | } |
| 4478 | |
| 4479 | static int iw_qcom_get_wapi_bkid(struct net_device *dev, struct iw_request_info *info, |
| 4480 | union iwreq_data *wrqu, char *extra) |
| 4481 | { |
| 4482 | /* Yet to implement this function, 19th April 2010 */ |
| 4483 | hddLog(LOG1, "The function iw_qcom_get_wapi_bkid called "); |
| 4484 | |
| 4485 | return 0; |
| 4486 | } |
| 4487 | #endif /* FEATURE_WLAN_WAPI */ |
| 4488 | |
| 4489 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4490 | // |
| 4491 | // |
| 4492 | // Each time the supplicant has the auth_request or reassoc request |
| 4493 | // IEs ready. This is pushed to the driver. The driver will inturn use |
| 4494 | // it to send out the auth req and reassoc req for 11r FT Assoc. |
| 4495 | // |
| 4496 | static int iw_set_fties(struct net_device *dev, struct iw_request_info *info, |
| 4497 | union iwreq_data *wrqu, char *extra) |
| 4498 | { |
| 4499 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4500 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4501 | //v_CONTEXT_t pVosContext; |
| 4502 | |
| 4503 | if (!wrqu->data.length) |
| 4504 | { |
| 4505 | hddLog(LOGE, FL("%s called with 0 length IEs\n")); |
| 4506 | return -EINVAL; |
| 4507 | } |
| 4508 | if (wrqu->data.pointer == NULL) |
| 4509 | { |
| 4510 | hddLog(LOGE, FL("%s called with NULL IE\n")); |
| 4511 | return -EINVAL; |
| 4512 | } |
| 4513 | |
| 4514 | // Added for debug on reception of Re-assoc Req. |
| 4515 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4516 | { |
| 4517 | hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"), |
| 4518 | wrqu->data.length); |
| 4519 | hddLog(LOGE, FL("Should be Re-assoc Req IEs\n")); |
| 4520 | } |
| 4521 | |
| 4522 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
| 4523 | hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__, wrqu->data.length); |
| 4524 | #endif |
| 4525 | |
| 4526 | // Pass the received FT IEs to SME |
| 4527 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, wrqu->data.pointer, |
| 4528 | wrqu->data.length); |
| 4529 | |
| 4530 | return 0; |
| 4531 | } |
| 4532 | #endif |
| 4533 | |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4534 | static int iw_set_dynamic_mcbc_filter(struct net_device *dev, |
| 4535 | struct iw_request_info *info, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4536 | union iwreq_data *wrqu, char *extra) |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4537 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4538 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4539 | tpMcBcFilterCfg pRequest = (tpMcBcFilterCfg)wrqu->data.pointer; |
| 4540 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4541 | tpSirWlanSetRxpFilters wlanRxpFilterParam; |
Madan Mohan Koyyalamudi | 51d87f7 | 2012-09-24 12:05:23 -0700 | [diff] [blame^] | 4542 | VOS_STATUS vstatus = VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4543 | |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4544 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 4545 | "%s: Set MC BC Filter Config request: %d suspend %d", |
| 4546 | __FUNCTION__, pRequest->mcastBcastFilterSetting, |
| 4547 | pHddCtx->hdd_wlan_suspended); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4548 | |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4549 | wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters)); |
| 4550 | if(NULL == wlanRxpFilterParam) |
| 4551 | { |
| 4552 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4553 | "%s: vos_mem_alloc failed ", __func__); |
| 4554 | return -EINVAL; |
| 4555 | } |
| 4556 | |
| 4557 | pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting = |
| 4558 | pRequest->mcastBcastFilterSetting; |
| 4559 | pHddCtx->dynamic_mcbc_filter.enableCfg = TRUE; |
| 4560 | |
| 4561 | if(pHddCtx->hdd_wlan_suspended) |
| 4562 | { |
| 4563 | wlanRxpFilterParam->configuredMcstBcstFilterSetting = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4564 | pRequest->mcastBcastFilterSetting; |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4565 | wlanRxpFilterParam->setMcstBcstFilter = TRUE; |
| 4566 | |
| 4567 | if((pHddCtx->cfg_ini->fhostArpOffload) && |
| 4568 | (eConnectionState_Associated == |
| 4569 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 4570 | { |
Madan Mohan Koyyalamudi | 51d87f7 | 2012-09-24 12:05:23 -0700 | [diff] [blame^] | 4571 | vstatus = hdd_conf_hostarpoffload(pHddCtx, TRUE); |
| 4572 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4573 | { |
| 4574 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4575 | "%s:Failed to enable ARPOFFLOAD Feature %d\n", |
Madan Mohan Koyyalamudi | 51d87f7 | 2012-09-24 12:05:23 -0700 | [diff] [blame^] | 4576 | __func__, vstatus); |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4577 | } |
| 4578 | else |
| 4579 | { |
| 4580 | if (HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST_BROADCAST == |
| 4581 | pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting) |
| 4582 | { |
| 4583 | wlanRxpFilterParam->configuredMcstBcstFilterSetting = |
| 4584 | HDD_MCASTBCASTFILTER_FILTER_ALL_MULTICAST; |
| 4585 | } |
| 4586 | else if(HDD_MCASTBCASTFILTER_FILTER_ALL_BROADCAST == |
| 4587 | pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting) |
| 4588 | { |
| 4589 | wlanRxpFilterParam->configuredMcstBcstFilterSetting = |
| 4590 | HDD_MCASTBCASTFILTER_FILTER_NONE; |
| 4591 | } |
| 4592 | } |
| 4593 | } |
| 4594 | |
| 4595 | hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d", |
| 4596 | __func__, |
| 4597 | pHddCtx->dynamic_mcbc_filter.mcastBcastFilterSetting, |
| 4598 | wlanRxpFilterParam->configuredMcstBcstFilterSetting, |
| 4599 | wlanRxpFilterParam->setMcstBcstFilter); |
| 4600 | |
| 4601 | if (eHAL_STATUS_SUCCESS != sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4602 | wlanRxpFilterParam)) |
| 4603 | { |
| 4604 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4605 | "%s: Failure to execute set HW MC/BC Filter request\n", |
| 4606 | __func__); |
| 4607 | return -EINVAL; |
| 4608 | } |
| 4609 | |
| 4610 | pHddCtx->dynamic_mcbc_filter.mcBcFilterSuspend = |
| 4611 | wlanRxpFilterParam->configuredMcstBcstFilterSetting; |
| 4612 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4613 | |
| 4614 | return 0; |
| 4615 | } |
| 4616 | |
Madan Mohan Koyyalamudi | f55e62a | 2012-09-24 11:14:27 -0700 | [diff] [blame] | 4617 | static int iw_clear_dynamic_mcbc_filter(struct net_device *dev, |
| 4618 | struct iw_request_info *info, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4619 | union iwreq_data *wrqu, char *extra) |
| 4620 | { |
| 4621 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4622 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4623 | |
| 4624 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __FUNCTION__); |
| 4625 | |
| 4626 | pHddCtx->dynamic_mcbc_filter.enableCfg = FALSE; |
| 4627 | |
| 4628 | return 0; |
| 4629 | } |
| 4630 | |
| 4631 | static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info, |
| 4632 | union iwreq_data *wrqu, char *extra) |
| 4633 | { |
| 4634 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4635 | tpHostOffloadRequest pRequest = (tpHostOffloadRequest)wrqu->data.pointer; |
| 4636 | tSirHostOffloadReq offloadRequest; |
| 4637 | |
| 4638 | /* Debug display of request components. */ |
| 4639 | switch (pRequest->offloadType) |
| 4640 | { |
| 4641 | case WLAN_IPV4_ARP_REPLY_OFFLOAD: |
| 4642 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __FUNCTION__); |
| 4643 | switch (pRequest->enableOrDisable) |
| 4644 | { |
| 4645 | case WLAN_OFFLOAD_DISABLE: |
| 4646 | hddLog(VOS_TRACE_LEVEL_WARN, " disable"); |
| 4647 | break; |
| 4648 | case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE: |
| 4649 | hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable"); |
| 4650 | case WLAN_OFFLOAD_ENABLE: |
| 4651 | hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable"); |
| 4652 | hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d", |
| 4653 | pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1], |
| 4654 | pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]); |
| 4655 | } |
| 4656 | break; |
| 4657 | |
| 4658 | case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD: |
| 4659 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery\n", |
| 4660 | __FUNCTION__); |
| 4661 | switch (pRequest->enableOrDisable) |
| 4662 | { |
| 4663 | case WLAN_OFFLOAD_DISABLE: |
| 4664 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable"); |
| 4665 | break; |
| 4666 | case WLAN_OFFLOAD_ENABLE: |
| 4667 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable"); |
| 4668 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x", |
| 4669 | *(v_U16_t *)(pRequest->params.hostIpv6Addr), |
| 4670 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2), |
| 4671 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4), |
| 4672 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6), |
| 4673 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8), |
| 4674 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10), |
| 4675 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12), |
| 4676 | *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14)); |
| 4677 | } |
| 4678 | } |
| 4679 | |
| 4680 | /* Execute offload request. The reason that we can copy the request information |
| 4681 | from the ioctl structure to the SME structure is that they are laid out |
| 4682 | exactly the same. Otherwise, each piece of information would have to be |
| 4683 | copied individually. */ |
| 4684 | memcpy(&offloadRequest, pRequest, wrqu->data.length); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4685 | if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4686 | pAdapter->sessionId, &offloadRequest)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4687 | { |
| 4688 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request\n", |
| 4689 | __func__); |
| 4690 | return -EINVAL; |
| 4691 | } |
| 4692 | |
| 4693 | return 0; |
| 4694 | } |
| 4695 | |
| 4696 | static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info, |
| 4697 | union iwreq_data *wrqu, char *extra) |
| 4698 | { |
| 4699 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4700 | tpKeepAliveRequest pRequest = (tpKeepAliveRequest)wrqu->data.pointer; |
| 4701 | tSirKeepAliveReq keepaliveRequest; |
| 4702 | |
| 4703 | if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) |
| 4704 | { |
| 4705 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4706 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4707 | return 0; |
| 4708 | } |
| 4709 | |
| 4710 | /* Debug display of request components. */ |
| 4711 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Keep Alive Request : TimePeriod %d size %d", |
| 4712 | __FUNCTION__,pRequest->timePeriod, sizeof(tKeepAliveRequest)); |
| 4713 | |
| 4714 | switch (pRequest->packetType) |
| 4715 | { |
| 4716 | case WLAN_KEEP_ALIVE_NULL_PKT: |
| 4717 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __FUNCTION__); |
| 4718 | break; |
| 4719 | |
| 4720 | case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP: |
| 4721 | |
| 4722 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP\n", |
| 4723 | __FUNCTION__); |
| 4724 | |
| 4725 | hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d", |
| 4726 | pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1], |
| 4727 | pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]); |
| 4728 | |
| 4729 | hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d", |
| 4730 | pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1], |
| 4731 | pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]); |
| 4732 | |
| 4733 | hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d", |
| 4734 | pRequest->destMacAddr[0], pRequest->destMacAddr[1], |
| 4735 | pRequest->destMacAddr[2], pRequest->destMacAddr[3], |
| 4736 | pRequest->destMacAddr[4], pRequest->destMacAddr[5]); |
| 4737 | break; |
| 4738 | |
| 4739 | } |
| 4740 | |
| 4741 | /* Execute keep alive request. The reason that we can copy the request information |
| 4742 | from the ioctl structure to the SME structure is that they are laid out |
| 4743 | exactly the same. Otherwise, each piece of information would have to be |
| 4744 | copied individually. */ |
| 4745 | memcpy(&keepaliveRequest, pRequest, wrqu->data.length); |
| 4746 | |
| 4747 | hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d\n", keepaliveRequest.timePeriod); |
| 4748 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4749 | if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4750 | pAdapter->sessionId, &keepaliveRequest)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4751 | { |
| 4752 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive\n", |
| 4753 | __func__); |
| 4754 | return -EINVAL; |
| 4755 | } |
| 4756 | |
| 4757 | return 0; |
| 4758 | } |
| 4759 | |
| 4760 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4761 | int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest, |
| 4762 | tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4763 | { |
| 4764 | tSirRcvPktFilterCfgType packetFilterSetReq; |
| 4765 | tSirRcvFltPktClearParam packetFilterClrReq; |
| 4766 | int i=0; |
| 4767 | |
| 4768 | if (pHddCtx->cfg_ini->disablePacketFilter) |
| 4769 | { |
| 4770 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ", |
| 4771 | __FUNCTION__ ); |
| 4772 | return 0; |
| 4773 | } |
| 4774 | |
| 4775 | /* Debug display of request components. */ |
| 4776 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d", |
| 4777 | __FUNCTION__, pRequest->filterAction, pRequest->numParams); |
| 4778 | |
| 4779 | switch (pRequest->filterAction) |
| 4780 | { |
| 4781 | case HDD_RCV_FILTER_SET: |
| 4782 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d", |
| 4783 | __FUNCTION__, pRequest->filterId); |
| 4784 | |
| 4785 | packetFilterSetReq.filterId = pRequest->filterId; |
| 4786 | if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER) |
| 4787 | { |
| 4788 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d\n", |
| 4789 | __func__, pRequest->numParams); |
| 4790 | return -EINVAL; |
| 4791 | } |
| 4792 | packetFilterSetReq.numFieldParams = pRequest->numParams; |
| 4793 | packetFilterSetReq.coalesceTime = 0; |
| 4794 | packetFilterSetReq.filterType = 1; |
| 4795 | for (i=0; i < pRequest->numParams; i++) |
| 4796 | { |
| 4797 | packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer; |
| 4798 | packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag; |
| 4799 | packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset; |
| 4800 | packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength; |
| 4801 | packetFilterSetReq.paramsData[i].reserved = 0; |
| 4802 | |
| 4803 | hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type\n", |
| 4804 | pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag, |
| 4805 | packetFilterSetReq.filterType); |
| 4806 | |
| 4807 | hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d\n", |
| 4808 | pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength); |
| 4809 | |
| 4810 | memcpy(&packetFilterSetReq.paramsData[i].compareData, |
| 4811 | pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength); |
| 4812 | memcpy(&packetFilterSetReq.paramsData[i].dataMask, |
| 4813 | pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength); |
| 4814 | |
| 4815 | hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d\n", |
| 4816 | pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1], |
| 4817 | pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3], |
| 4818 | pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]); |
| 4819 | |
| 4820 | hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d\n", |
| 4821 | pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1], |
| 4822 | pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3], |
| 4823 | pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]); |
| 4824 | } |
| 4825 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4826 | if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx, &packetFilterSetReq, sessionId)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4827 | { |
| 4828 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter\n", |
| 4829 | __func__); |
| 4830 | return -EINVAL; |
| 4831 | } |
| 4832 | |
| 4833 | break; |
| 4834 | |
| 4835 | case HDD_RCV_FILTER_CLEAR: |
| 4836 | |
| 4837 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d\n", |
| 4838 | __FUNCTION__, pRequest->filterId); |
| 4839 | packetFilterClrReq.filterId = pRequest->filterId; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4840 | if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx, &packetFilterClrReq, sessionId)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4841 | { |
| 4842 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter\n", |
| 4843 | __func__); |
| 4844 | return -EINVAL; |
| 4845 | } |
| 4846 | break; |
| 4847 | |
| 4848 | default : |
| 4849 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d\n", |
| 4850 | __FUNCTION__, pRequest->filterAction); |
| 4851 | return -EINVAL; |
| 4852 | } |
| 4853 | return 0; |
| 4854 | } |
| 4855 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4856 | void wlan_hdd_set_mc_addr_list(hdd_context_t *pHddCtx, v_U8_t set, v_U8_t sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4857 | { |
| 4858 | v_U8_t filterAction = 0; |
| 4859 | tPacketFilterCfg request = {0}; |
| 4860 | v_U8_t i = 0; |
| 4861 | |
| 4862 | filterAction = set ? HDD_RCV_FILTER_SET : HDD_RCV_FILTER_CLEAR; |
| 4863 | |
| 4864 | /*set mulitcast addr list*/ |
| 4865 | for (i = 0; i < pHddCtx->mc_addr_list.mc_cnt; i++) |
| 4866 | { |
| 4867 | memset(&request, 0, sizeof (tPacketFilterCfg)); |
| 4868 | request.filterAction = filterAction; |
| 4869 | request.filterId = i; |
| 4870 | if (set) |
| 4871 | { |
| 4872 | request.numParams = 1; |
| 4873 | request.paramsData[0].protocolLayer = HDD_FILTER_PROTO_TYPE_MAC; |
| 4874 | request.paramsData[0].cmpFlag = HDD_FILTER_CMP_TYPE_EQUAL; |
| 4875 | request.paramsData[0].dataOffset = WLAN_HDD_80211_FRM_DA_OFFSET; |
| 4876 | request.paramsData[0].dataLength = ETH_ALEN; |
| 4877 | memcpy(&(request.paramsData[0].compareData[0]), |
| 4878 | &(pHddCtx->mc_addr_list.addr[i][0]), ETH_ALEN); |
| 4879 | /*set mulitcast filters*/ |
| 4880 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4881 | "%s: %s multicast filter: addr =" |
| 4882 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 4883 | __func__, set ? "setting" : "clearing", |
| 4884 | request.paramsData[0].compareData[0], |
| 4885 | request.paramsData[0].compareData[1], |
| 4886 | request.paramsData[0].compareData[2], |
| 4887 | request.paramsData[0].compareData[3], |
| 4888 | request.paramsData[0].compareData[4], |
| 4889 | request.paramsData[0].compareData[5]); |
| 4890 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4891 | wlan_hdd_set_filter(pHddCtx, &request, sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4892 | } |
| 4893 | pHddCtx->mc_addr_list.isFilterApplied = set ? TRUE : FALSE; |
| 4894 | } |
| 4895 | |
| 4896 | static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info, |
| 4897 | union iwreq_data *wrqu, char *extra) |
| 4898 | { |
| 4899 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4900 | tpPacketFilterCfg pRequest = (tpPacketFilterCfg)wrqu->data.pointer; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4901 | return wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4902 | } |
| 4903 | #endif |
| 4904 | static int iw_get_statistics(struct net_device *dev, |
| 4905 | struct iw_request_info *info, |
| 4906 | union iwreq_data *wrqu, char *extra) |
| 4907 | { |
| 4908 | |
| 4909 | VOS_STATUS vos_status = VOS_STATUS_SUCCESS; |
| 4910 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4911 | hdd_wext_state_t *pWextState; |
| 4912 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4913 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4914 | char *p = extra; |
| 4915 | int tlen = 0; |
| 4916 | tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat); |
| 4917 | |
| 4918 | tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat); |
| 4919 | tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat); |
| 4920 | |
| 4921 | ENTER(); |
| 4922 | |
| 4923 | if (pHddCtx->isLogpInProgress) { |
| 4924 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4925 | return -EINVAL; |
| 4926 | } |
| 4927 | |
| 4928 | if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) { |
| 4929 | |
| 4930 | wrqu->txpower.value = 0; |
| 4931 | } |
| 4932 | else { |
| 4933 | status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD, |
| 4934 | SME_SUMMARY_STATS | |
| 4935 | SME_GLOBAL_CLASSA_STATS | |
| 4936 | SME_GLOBAL_CLASSB_STATS | |
| 4937 | SME_GLOBAL_CLASSC_STATS | |
| 4938 | SME_GLOBAL_CLASSD_STATS | |
| 4939 | SME_PER_STA_STATS, |
| 4940 | hdd_StatisticsCB, 0, FALSE, |
| 4941 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter ); |
| 4942 | |
| 4943 | if (eHAL_STATUS_SUCCESS != status) |
| 4944 | { |
| 4945 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4946 | "%s: Unable to retrieve SME statistics", |
| 4947 | __FUNCTION__); |
| 4948 | return -EINVAL; |
| 4949 | } |
| 4950 | |
| 4951 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4952 | |
| 4953 | vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS); |
| 4954 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 4955 | { |
| 4956 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4957 | "%s: SME timeout while retrieving statistics", |
| 4958 | __FUNCTION__); |
| 4959 | /*Remove the SME statistics list by passing NULL in callback argument*/ |
| 4960 | status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD, |
| 4961 | SME_SUMMARY_STATS | |
| 4962 | SME_GLOBAL_CLASSA_STATS | |
| 4963 | SME_GLOBAL_CLASSB_STATS | |
| 4964 | SME_GLOBAL_CLASSC_STATS | |
| 4965 | SME_GLOBAL_CLASSD_STATS | |
| 4966 | SME_PER_STA_STATS, |
| 4967 | NULL, 0, FALSE, |
| 4968 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter ); |
| 4969 | |
| 4970 | return -EINVAL; |
| 4971 | } |
| 4972 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT, |
| 4973 | (tANI_U8) sizeof (pStats->retry_cnt), |
| 4974 | (char*) &(pStats->retry_cnt[0]), |
| 4975 | tlen); |
| 4976 | |
| 4977 | FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT, |
| 4978 | (tANI_U8) sizeof (pStats->multiple_retry_cnt), |
| 4979 | (char*) &(pStats->multiple_retry_cnt[0]), |
| 4980 | tlen); |
| 4981 | |
| 4982 | FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT, |
| 4983 | (tANI_U8) sizeof (pStats->tx_frm_cnt), |
| 4984 | (char*) &(pStats->tx_frm_cnt[0]), |
| 4985 | tlen); |
| 4986 | |
| 4987 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT, |
| 4988 | (tANI_U8) sizeof (pStats->rx_frm_cnt), |
| 4989 | (char*) &(pStats->rx_frm_cnt), |
| 4990 | tlen); |
| 4991 | |
| 4992 | FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT, |
| 4993 | (tANI_U8) sizeof (pStats->frm_dup_cnt), |
| 4994 | (char*) &(pStats->frm_dup_cnt), |
| 4995 | tlen); |
| 4996 | |
| 4997 | FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT, |
| 4998 | (tANI_U8) sizeof (pStats->fail_cnt), |
| 4999 | (char*) &(pStats->fail_cnt[0]), |
| 5000 | tlen); |
| 5001 | |
| 5002 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT, |
| 5003 | (tANI_U8) sizeof (pStats->rts_fail_cnt), |
| 5004 | (char*) &(pStats->rts_fail_cnt), |
| 5005 | tlen); |
| 5006 | |
| 5007 | FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT, |
| 5008 | (tANI_U8) sizeof (pStats->ack_fail_cnt), |
| 5009 | (char*) &(pStats->ack_fail_cnt), |
| 5010 | tlen); |
| 5011 | |
| 5012 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT, |
| 5013 | (tANI_U8) sizeof (pStats->rts_succ_cnt), |
| 5014 | (char*) &(pStats->rts_succ_cnt), |
| 5015 | tlen); |
| 5016 | |
| 5017 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT, |
| 5018 | (tANI_U8) sizeof (pStats->rx_discard_cnt), |
| 5019 | (char*) &(pStats->rx_discard_cnt), |
| 5020 | tlen); |
| 5021 | |
| 5022 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT, |
| 5023 | (tANI_U8) sizeof (pStats->rx_error_cnt), |
| 5024 | (char*) &(pStats->rx_error_cnt), |
| 5025 | tlen); |
| 5026 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5027 | FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT, |
| 5028 | (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]), |
| 5029 | (char*) &(dStats->tx_uc_byte_cnt[0]), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5030 | tlen); |
| 5031 | |
| 5032 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT, |
| 5033 | (tANI_U8) sizeof (dStats->rx_byte_cnt), |
| 5034 | (char*) &(dStats->rx_byte_cnt), |
| 5035 | tlen); |
| 5036 | |
| 5037 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE, |
| 5038 | (tANI_U8) sizeof (dStats->rx_rate), |
| 5039 | (char*) &(dStats->rx_rate), |
| 5040 | tlen); |
| 5041 | |
| 5042 | /* Transmit rate, in units of 500 kbit/sec */ |
| 5043 | FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE, |
| 5044 | (tANI_U8) sizeof (aStats->tx_rate), |
| 5045 | (char*) &(aStats->tx_rate), |
| 5046 | tlen); |
| 5047 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5048 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT, |
| 5049 | (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]), |
| 5050 | (char*) &(dStats->rx_uc_byte_cnt[0]), |
| 5051 | tlen); |
| 5052 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT, |
| 5053 | (tANI_U8) sizeof (dStats->rx_mc_byte_cnt), |
| 5054 | (char*) &(dStats->rx_mc_byte_cnt), |
| 5055 | tlen); |
| 5056 | FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT, |
| 5057 | (tANI_U8) sizeof (dStats->rx_bc_byte_cnt), |
| 5058 | (char*) &(dStats->rx_bc_byte_cnt), |
| 5059 | tlen); |
| 5060 | FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT, |
| 5061 | (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]), |
| 5062 | (char*) &(dStats->tx_uc_byte_cnt[0]), |
| 5063 | tlen); |
| 5064 | FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT, |
| 5065 | (tANI_U8) sizeof (dStats->tx_mc_byte_cnt), |
| 5066 | (char*) &(dStats->tx_mc_byte_cnt), |
| 5067 | tlen); |
| 5068 | FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT, |
| 5069 | (tANI_U8) sizeof (dStats->tx_bc_byte_cnt), |
| 5070 | (char*) &(dStats->tx_bc_byte_cnt), |
| 5071 | tlen); |
| 5072 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5073 | wrqu->data.length = tlen; |
| 5074 | |
| 5075 | } |
| 5076 | |
| 5077 | EXIT(); |
| 5078 | |
| 5079 | return 0; |
| 5080 | } |
| 5081 | |
| 5082 | |
| 5083 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 5084 | |
| 5085 | /*Max Len for PNO notification*/ |
| 5086 | #define MAX_PNO_NOTIFY_LEN 100 |
| 5087 | void found_pref_network_cb (void *callbackContext, |
| 5088 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 5089 | { |
| 5090 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 5091 | union iwreq_data wrqu; |
| 5092 | char buf[MAX_PNO_NOTIFY_LEN+1]; |
| 5093 | |
| 5094 | hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d", |
| 5095 | pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi); |
| 5096 | |
| 5097 | // create the event |
| 5098 | memset(&wrqu, 0, sizeof(wrqu)); |
| 5099 | memset(buf, 0, sizeof(buf)); |
| 5100 | |
| 5101 | snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u", |
| 5102 | pPrefNetworkFoundInd->ssId.ssId, |
| 5103 | (unsigned int)pPrefNetworkFoundInd->rssi); |
| 5104 | |
| 5105 | wrqu.data.pointer = buf; |
| 5106 | wrqu.data.length = strlen(buf); |
| 5107 | |
| 5108 | // send the event |
| 5109 | |
| 5110 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf); |
| 5111 | |
| 5112 | } |
| 5113 | |
| 5114 | |
| 5115 | /*string based input*/ |
| 5116 | VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info, |
| 5117 | union iwreq_data *wrqu, char *extra, int nOffset) |
| 5118 | { |
| 5119 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5120 | tSirPNOScanReq pnoRequest; |
| 5121 | char *ptr; |
| 5122 | v_U8_t i,j, ucParams, ucMode; |
| 5123 | /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
| 5124 | |
| 5125 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5126 | "PNO data len %d data %s", |
| 5127 | wrqu->data.length, |
| 5128 | wrqu->data.pointer); |
| 5129 | |
| 5130 | if (wrqu->data.length <= nOffset ) |
| 5131 | { |
| 5132 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct"); |
| 5133 | return VOS_STATUS_E_FAILURE; |
| 5134 | } |
| 5135 | |
| 5136 | pnoRequest.enable = 0; |
| 5137 | pnoRequest.ucNetworksCount = 0; |
| 5138 | /*----------------------------------------------------------------------- |
| 5139 | Input is string based and expected to be like this: |
| 5140 | |
| 5141 | <enabled> <netw_count> |
| 5142 | for each network: |
| 5143 | <ssid_len> <ssid> <authentication> <encryption> |
| 5144 | <ch_num> <channel_list optional> <bcast_type> <rssi_threshold> |
| 5145 | <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat> |
| 5146 | |
| 5147 | e.g: |
| 5148 | 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 2 5 2 300 0 |
| 5149 | |
| 5150 | this translates into: |
| 5151 | ----------------------------- |
| 5152 | enable PNO |
| 5153 | look for 2 networks: |
| 5154 | test - with authentication type 0 and encryption type 0, |
| 5155 | that can be found on 3 channels: 1 6 and 11 , |
| 5156 | SSID bcast type is unknown (directed probe will be sent if AP not found) |
| 5157 | and must meet -40dBm RSSI |
| 5158 | |
| 5159 | test2 - with auth and enrytption type 4/4 |
| 5160 | that can be found on 6 channels 1, 2, 3, 4, 5 and 6 |
| 5161 | bcast type is non-bcast (directed probe will be sent) |
| 5162 | and must not meet any RSSI threshold |
| 5163 | |
| 5164 | scan every 5 seconds 2 times, scan every 300 seconds until stopped |
| 5165 | -----------------------------------------------------------------------*/ |
| 5166 | ptr = (char*)(wrqu->data.pointer + nOffset); |
| 5167 | |
| 5168 | sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset); |
| 5169 | |
| 5170 | if ( 0 == pnoRequest.enable ) |
| 5171 | { |
| 5172 | /*Disable PNO*/ |
| 5173 | memset(&pnoRequest, 0, sizeof(pnoRequest)); |
| 5174 | sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest, |
| 5175 | pAdapter->sessionId, |
| 5176 | found_pref_network_cb, pAdapter); |
| 5177 | return VOS_STATUS_SUCCESS; |
| 5178 | } |
| 5179 | |
| 5180 | ptr += nOffset; |
| 5181 | sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset); |
| 5182 | |
| 5183 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5184 | "PNO enable %d networks count %d offset %d", |
| 5185 | pnoRequest.enable, |
| 5186 | pnoRequest.ucNetworksCount, |
| 5187 | nOffset); |
| 5188 | |
| 5189 | /* Parameters checking: |
| 5190 | ucNetworksCount has to be larger than 0*/ |
| 5191 | if (( 0 == pnoRequest.ucNetworksCount ) || |
| 5192 | ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 5193 | { |
| 5194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct"); |
| 5195 | return VOS_STATUS_E_FAILURE; |
| 5196 | } |
| 5197 | |
| 5198 | ptr += nOffset; |
| 5199 | |
| 5200 | for ( i = 0; i < pnoRequest.ucNetworksCount; i++ ) |
| 5201 | { |
| 5202 | |
| 5203 | pnoRequest.aNetworks[i].ssId.length = 0; |
| 5204 | |
| 5205 | sscanf(ptr,"%hhu %n", |
| 5206 | &(pnoRequest.aNetworks[i].ssId.length), &nOffset); |
| 5207 | |
| 5208 | if (( 0 == pnoRequest.aNetworks[i].ssId.length ) || |
| 5209 | ( pnoRequest.aNetworks[i].ssId.length > 32 ) ) |
| 5210 | { |
| 5211 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5212 | "SSID Len %d is not correct for network %d", |
| 5213 | pnoRequest.aNetworks[i].ssId.length, i); |
| 5214 | return VOS_STATUS_E_FAILURE; |
| 5215 | } |
| 5216 | |
| 5217 | /*Advance to SSID*/ |
| 5218 | ptr += nOffset; |
| 5219 | |
| 5220 | ucParams = sscanf(ptr,"%32s %lu %lu %hhu %n", |
| 5221 | pnoRequest.aNetworks[i].ssId.ssId, |
| 5222 | &(pnoRequest.aNetworks[i].authentication), |
| 5223 | &(pnoRequest.aNetworks[i].encryption), |
| 5224 | &(pnoRequest.aNetworks[i].ucChannelCount), |
| 5225 | &nOffset); |
| 5226 | |
| 5227 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5228 | "PNO len %d ssid %s auth %d encry %d channel count %d offset %d", |
| 5229 | pnoRequest.aNetworks[i].ssId.length, |
| 5230 | pnoRequest.aNetworks[i].ssId.ssId, |
| 5231 | pnoRequest.aNetworks[i].authentication, |
| 5232 | pnoRequest.aNetworks[i].encryption, |
| 5233 | pnoRequest.aNetworks[i].ucChannelCount, |
| 5234 | nOffset ); |
| 5235 | |
| 5236 | if ( 4 != ucParams ) |
| 5237 | { |
| 5238 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 5239 | "Incorrect cmd"); |
| 5240 | return VOS_STATUS_E_FAILURE; |
| 5241 | } |
| 5242 | |
| 5243 | /*Advance to channel list*/ |
| 5244 | ptr += nOffset; |
| 5245 | |
| 5246 | if ( SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount ) |
| 5247 | { |
| 5248 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 5249 | "Incorrect number of channels"); |
| 5250 | return VOS_STATUS_E_FAILURE; |
| 5251 | } |
| 5252 | |
| 5253 | if ( 0 != pnoRequest.aNetworks[i].ucChannelCount) |
| 5254 | { |
| 5255 | for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++) |
| 5256 | { |
| 5257 | sscanf(ptr,"%hhu %n", |
| 5258 | &(pnoRequest.aNetworks[i].aChannels[j]), &nOffset); |
| 5259 | /*Advance to next channel number*/ |
| 5260 | ptr += nOffset; |
| 5261 | } |
| 5262 | } |
| 5263 | |
| 5264 | sscanf(ptr,"%lu %n", |
| 5265 | &(pnoRequest.aNetworks[i].bcastNetwType), &nOffset); |
| 5266 | |
| 5267 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5268 | "PNO bcastNetwType %d offset %d", |
| 5269 | pnoRequest.aNetworks[i].bcastNetwType, |
| 5270 | nOffset ); |
| 5271 | |
| 5272 | /*Advance to rssi Threshold*/ |
| 5273 | ptr += nOffset; |
| 5274 | |
| 5275 | sscanf(ptr,"%hhu %n", |
| 5276 | &(pnoRequest.aNetworks[i].rssiThreshold), &nOffset); |
| 5277 | |
| 5278 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5279 | "PNO rssi %d offset %d", |
| 5280 | pnoRequest.aNetworks[i].rssiThreshold, |
| 5281 | nOffset ); |
| 5282 | /*Advance to next network*/ |
| 5283 | ptr += nOffset; |
| 5284 | }/*For ucNetworkCount*/ |
| 5285 | |
| 5286 | ucParams = sscanf(ptr,"%hhu %n", |
| 5287 | &(pnoRequest.scanTimers.ucScanTimersCount), &nOffset); |
| 5288 | |
| 5289 | /*Read the scan timers*/ |
| 5290 | if (( 1 == ucParams )&&( pnoRequest.scanTimers.ucScanTimersCount >= 0 )) |
| 5291 | { |
| 5292 | ptr += nOffset; |
| 5293 | |
| 5294 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5295 | "Scan timer count %d offset %d", |
| 5296 | pnoRequest.scanTimers.ucScanTimersCount, |
| 5297 | nOffset ); |
| 5298 | |
| 5299 | if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount ) |
| 5300 | { |
| 5301 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5302 | "Incorrect cmd - too many scan timers"); |
| 5303 | return VOS_STATUS_E_FAILURE; |
| 5304 | } |
| 5305 | |
| 5306 | for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ ) |
| 5307 | { |
| 5308 | ucParams = sscanf(ptr,"%lu %lu %n", |
| 5309 | &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue), |
| 5310 | &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat), |
| 5311 | &nOffset); |
| 5312 | |
| 5313 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5314 | "PNO Timer value %d Timer repeat %d offset %d", |
| 5315 | pnoRequest.scanTimers.aTimerValues[i].uTimerValue, |
| 5316 | pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat, |
| 5317 | nOffset ); |
| 5318 | |
| 5319 | if ( 2 != ucParams ) |
| 5320 | { |
| 5321 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5322 | "Incorrect cmd - diff params then expected %d", ucParams); |
| 5323 | return VOS_STATUS_E_FAILURE; |
| 5324 | } |
| 5325 | |
| 5326 | ptr += nOffset; |
| 5327 | } |
| 5328 | |
| 5329 | } |
| 5330 | else |
| 5331 | { |
| 5332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5333 | "No scan timers provided param count %d scan timers %d", |
| 5334 | ucParams, pnoRequest.scanTimers.ucScanTimersCount ); |
| 5335 | |
| 5336 | /*Scan timers defaults to 5 minutes*/ |
| 5337 | pnoRequest.scanTimers.ucScanTimersCount = 1; |
| 5338 | pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60; |
| 5339 | pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0; |
| 5340 | } |
| 5341 | |
| 5342 | ucParams = sscanf(ptr,"%hhu %n", |
| 5343 | &(ucMode), &nOffset); |
| 5344 | |
| 5345 | pnoRequest.modePNO = ucMode; |
| 5346 | /*for LA we just expose suspend option*/ |
| 5347 | if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX )) |
| 5348 | { |
| 5349 | pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND; |
| 5350 | } |
| 5351 | |
| 5352 | sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest, |
| 5353 | pAdapter->sessionId, |
| 5354 | found_pref_network_cb, pAdapter); |
| 5355 | |
| 5356 | return VOS_STATUS_SUCCESS; |
| 5357 | }/*iw_set_pno*/ |
| 5358 | |
| 5359 | VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info, |
| 5360 | union iwreq_data *wrqu, char *extra, int nOffset) |
| 5361 | { |
| 5362 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5363 | v_U8_t rssiThreshold = 0; |
| 5364 | v_U8_t nRead; |
| 5365 | |
| 5366 | nRead = sscanf(wrqu->data.pointer + nOffset,"%hhu", |
| 5367 | &rssiThreshold); |
| 5368 | |
| 5369 | if ( 1 != nRead ) |
| 5370 | { |
| 5371 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 5372 | "Incorrect format"); |
| 5373 | return VOS_STATUS_E_FAILURE; |
| 5374 | } |
| 5375 | |
| 5376 | sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold); |
| 5377 | return VOS_STATUS_SUCCESS; |
| 5378 | } |
| 5379 | |
| 5380 | |
| 5381 | static int iw_set_pno_priv(struct net_device *dev, |
| 5382 | struct iw_request_info *info, |
| 5383 | union iwreq_data *wrqu, char *extra) |
| 5384 | { |
| 5385 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5386 | "Set PNO Private"); |
| 5387 | return iw_set_pno(dev,info,wrqu,extra,0); |
| 5388 | } |
| 5389 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 5390 | |
| 5391 | //Common function to SetBand |
| 5392 | int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr) |
| 5393 | { |
| 5394 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5395 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 5396 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5397 | tANI_U8 band = 0; |
| 5398 | eCsrBand currBand = eCSR_BAND_MAX; |
| 5399 | |
| 5400 | band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/ |
| 5401 | |
| 5402 | switch(band) |
| 5403 | { |
| 5404 | case WLAN_HDD_UI_BAND_AUTO: |
| 5405 | band = eCSR_BAND_ALL; |
| 5406 | break; |
| 5407 | case WLAN_HDD_UI_BAND_5_GHZ: |
| 5408 | band = eCSR_BAND_5G; |
| 5409 | break; |
| 5410 | case WLAN_HDD_UI_BAND_2_4_GHZ: |
| 5411 | band = eCSR_BAND_24; |
| 5412 | break; |
| 5413 | default: |
| 5414 | band = eCSR_BAND_MAX; |
| 5415 | } |
| 5416 | |
| 5417 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u", |
| 5418 | __FUNCTION__, band); |
| 5419 | |
| 5420 | if (band == eCSR_BAND_MAX) |
| 5421 | { |
| 5422 | /* Received change band request with invalid band value */ |
| 5423 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5424 | "%s: Invalid band value %u", __FUNCTION__, band); |
| 5425 | return -EIO; |
| 5426 | } |
| 5427 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 5428 | if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) || |
| 5429 | (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) || |
| 5430 | (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0)) |
| 5431 | { |
| 5432 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5433 | "%s: band value %u violate INI settings %u", __FUNCTION__, |
| 5434 | band, pHddCtx->cfg_ini->nBandCapability); |
| 5435 | return -EIO; |
| 5436 | } |
| 5437 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5438 | if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand)) |
| 5439 | { |
| 5440 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5441 | "%s: Failed to get current band config", |
| 5442 | __FUNCTION__); |
| 5443 | return -EIO; |
| 5444 | } |
| 5445 | |
| 5446 | if (currBand != band) |
| 5447 | { |
| 5448 | /* Change band request received. |
| 5449 | * Abort pending scan requests, flush the existing scan results, |
| 5450 | * and change the band capability |
| 5451 | */ |
| 5452 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5453 | "%s: Current band value = %u, new setting %u ", |
| 5454 | __FUNCTION__, currBand, band); |
| 5455 | |
| 5456 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5457 | { |
| 5458 | hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station; |
| 5459 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5460 | long lrc; |
| 5461 | |
| 5462 | /* STA already connected on current band, So issue disconnect first, |
| 5463 | * then change the band*/ |
| 5464 | |
| 5465 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5466 | "%s STA connected in band %u, Changing band to %u, Issuing Disconnect", |
| 5467 | __func__, csrGetCurrentBand(hHal), band); |
| 5468 | |
| 5469 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5470 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 5471 | |
| 5472 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5473 | pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 5474 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 5475 | if ( eHAL_STATUS_SUCCESS != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5476 | { |
| 5477 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5478 | "%s csrRoamDisconnect failure, returned %d \n", |
| 5479 | __func__, (int)status ); |
| 5480 | return -EINVAL; |
| 5481 | } |
| 5482 | |
| 5483 | lrc = wait_for_completion_interruptible_timeout( |
| 5484 | &pAdapter->disconnect_comp_var, |
| 5485 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 5486 | |
| 5487 | if(lrc <= 0) { |
| 5488 | |
| 5489 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while while waiting for csrRoamDisconnect ", |
| 5490 | __FUNCTION__, (0 == lrc) ? "Timeout" : "Interrupt"); |
| 5491 | |
| 5492 | return (0 == lrc) ? -ETIMEDOUT : -EINTR; |
| 5493 | } |
| 5494 | } |
| 5495 | |
| 5496 | hdd_abort_mac_scan(pHddCtx); |
| 5497 | sme_ScanFlushResult(hHal, pAdapter->sessionId); |
| 5498 | if(eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band)) |
| 5499 | { |
| 5500 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5501 | "%s: failed to set the band value to %u ", |
| 5502 | __FUNCTION__, band); |
| 5503 | return -EINVAL; |
| 5504 | } |
| 5505 | #ifdef CONFIG_CFG80211 |
| 5506 | wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band); |
| 5507 | #endif |
| 5508 | } |
| 5509 | return 0; |
| 5510 | } |
| 5511 | |
| 5512 | static int iw_set_band_config(struct net_device *dev, |
| 5513 | struct iw_request_info *info, |
| 5514 | union iwreq_data *wrqu, char *extra) |
| 5515 | { |
| 5516 | tANI_U8 *ptr = (tANI_U8*)wrqu->data.pointer; |
| 5517 | int ret = 0; |
| 5518 | |
| 5519 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,"%s: ", __FUNCTION__); |
| 5520 | |
| 5521 | if (memcmp(ptr, "SETBAND ", 8) == 0) |
| 5522 | { |
| 5523 | /* Change band request received */ |
| 5524 | ret = hdd_setBand_helper(dev, ptr); |
| 5525 | return ret; |
| 5526 | |
| 5527 | } |
| 5528 | return 0; |
| 5529 | } |
| 5530 | |
| 5531 | static int iw_set_power_params_priv(struct net_device *dev, |
| 5532 | struct iw_request_info *info, |
| 5533 | union iwreq_data *wrqu, char *extra) |
| 5534 | { |
| 5535 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5536 | "Set power params Private"); |
| 5537 | return iw_set_power_params(dev,info,wrqu,extra,0); |
| 5538 | } |
| 5539 | |
| 5540 | |
| 5541 | |
| 5542 | /*string based input*/ |
| 5543 | VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info, |
| 5544 | union iwreq_data *wrqu, char *extra, int nOffset) |
| 5545 | { |
| 5546 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5547 | tSirSetPowerParamsReq powerRequest; |
| 5548 | char *ptr; |
| 5549 | v_U8_t ucType; |
| 5550 | v_U32_t uTotalSize, uValue; |
| 5551 | /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
| 5552 | |
| 5553 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5554 | "Power Params data len %d data %s", |
| 5555 | wrqu->data.length, |
| 5556 | wrqu->data.pointer); |
| 5557 | |
| 5558 | if (wrqu->data.length <= nOffset ) |
| 5559 | { |
| 5560 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct"); |
| 5561 | return VOS_STATUS_E_FAILURE; |
| 5562 | } |
| 5563 | |
| 5564 | uTotalSize = wrqu->data.length - nOffset; |
| 5565 | |
| 5566 | /*----------------------------------------------------------------------- |
| 5567 | Input is string based and expected to be like this: |
| 5568 | |
| 5569 | <param_type> <param_value> <param_type> <param_value> ... |
| 5570 | |
| 5571 | e.g: |
| 5572 | 1 2 2 3 3 0 4 1 5 1 |
| 5573 | |
| 5574 | e.g. setting just a few: |
| 5575 | 1 2 4 1 |
| 5576 | |
| 5577 | parameter types: |
| 5578 | ----------------------------- |
| 5579 | 1 - Ignore DTIM |
| 5580 | 2 - Listen Interval |
| 5581 | 3 - Broadcast Multicas Filter |
| 5582 | 4 - Beacon Early Termination |
| 5583 | 5 - Beacon Early Termination Interval |
| 5584 | -----------------------------------------------------------------------*/ |
| 5585 | powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE; |
| 5586 | powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE; |
| 5587 | powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE; |
| 5588 | powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE; |
| 5589 | powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE; |
| 5590 | |
| 5591 | ptr = (char*)(wrqu->data.pointer + nOffset); |
| 5592 | |
| 5593 | while ( uTotalSize ) |
| 5594 | { |
| 5595 | sscanf(ptr,"%hhu %n", &(ucType), &nOffset); |
| 5596 | |
| 5597 | uTotalSize -= nOffset; |
| 5598 | |
| 5599 | if (!uTotalSize) |
| 5600 | { |
| 5601 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5602 | "Invalid input parametery type : %d with no value at offset %d", |
| 5603 | ucType, nOffset); |
| 5604 | return VOS_STATUS_E_FAILURE; |
| 5605 | } |
| 5606 | |
| 5607 | ptr += nOffset; |
| 5608 | sscanf(ptr,"%lu %n", &(uValue), &nOffset); |
| 5609 | |
| 5610 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5611 | "Power request parameter %d value %d offset %d", |
| 5612 | ucType, uValue, nOffset); |
| 5613 | |
| 5614 | switch (ucType) |
| 5615 | { |
| 5616 | case eSIR_IGNORE_DTIM: |
| 5617 | powerRequest.uIgnoreDTIM = uValue; |
| 5618 | break; |
| 5619 | case eSIR_LISTEN_INTERVAL: |
| 5620 | powerRequest.uListenInterval = uValue; |
| 5621 | break; |
| 5622 | case eSIR_MCAST_BCAST_FILTER: |
| 5623 | powerRequest.uBcastMcastFilter = uValue; |
| 5624 | break; |
| 5625 | case eSIR_ENABLE_BET: |
| 5626 | powerRequest.uEnableBET = uValue; |
| 5627 | break; |
| 5628 | case eSIR_BET_INTERVAL: |
| 5629 | powerRequest.uBETInterval = uValue; |
| 5630 | break; |
| 5631 | default: |
| 5632 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5633 | "Invalid input parametery type : %d with value: %d at offset %d", |
| 5634 | ucType, uValue, nOffset); |
| 5635 | return VOS_STATUS_E_FAILURE; |
| 5636 | } |
| 5637 | |
| 5638 | uTotalSize -= nOffset; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5639 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5640 | "Power request parameter %d Total size", |
| 5641 | uTotalSize); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5642 | ptr += nOffset; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5643 | /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/ |
| 5644 | if(!(uTotalSize - nOffset) && |
| 5645 | (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE)) |
| 5646 | { |
| 5647 | uTotalSize = 0; |
| 5648 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5649 | |
| 5650 | }/*Go for as long as we have a valid string*/ |
| 5651 | |
| 5652 | /* put the device into full power*/ |
| 5653 | wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE); |
| 5654 | |
| 5655 | /* Apply the power save params*/ |
| 5656 | sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest); |
| 5657 | |
| 5658 | /* put the device back to power save*/ |
| 5659 | wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO); |
| 5660 | |
| 5661 | return VOS_STATUS_SUCCESS; |
| 5662 | }/*iw_set_power_params*/ |
| 5663 | |
| 5664 | |
| 5665 | // Define the Wireless Extensions to the Linux Network Device structure |
| 5666 | // A number of these routines are NULL (meaning they are not implemented.) |
| 5667 | |
| 5668 | static const iw_handler we_handler[] = |
| 5669 | { |
| 5670 | (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */ |
| 5671 | (iw_handler) iw_get_name, /* SIOCGIWNAME */ |
| 5672 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 5673 | (iw_handler) NULL, /* SIOCGIWNWID */ |
| 5674 | (iw_handler) iw_set_freq, /* SIOCSIWFREQ */ |
| 5675 | (iw_handler) iw_get_freq, /* SIOCGIWFREQ */ |
| 5676 | (iw_handler) iw_set_mode, /* SIOCSIWMODE */ |
| 5677 | (iw_handler) iw_get_mode, /* SIOCGIWMODE */ |
| 5678 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 5679 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 5680 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
| 5681 | (iw_handler) iw_get_range, /* SIOCGIWRANGE */ |
| 5682 | (iw_handler) iw_set_priv, /* SIOCSIWPRIV */ |
| 5683 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 5684 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 5685 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 5686 | iw_handler_set_spy, /* SIOCSIWSPY */ |
| 5687 | iw_handler_get_spy, /* SIOCGIWSPY */ |
| 5688 | iw_handler_set_thrspy, /* SIOCSIWTHRSPY */ |
| 5689 | iw_handler_get_thrspy, /* SIOCGIWTHRSPY */ |
| 5690 | (iw_handler) iw_set_ap_address, /* SIOCSIWAP */ |
| 5691 | (iw_handler) iw_get_ap_address, /* SIOCGIWAP */ |
| 5692 | (iw_handler) iw_set_mlme, /* SIOCSIWMLME */ |
| 5693 | (iw_handler) NULL, /* SIOCGIWAPLIST */ |
| 5694 | (iw_handler) iw_set_scan, /* SIOCSIWSCAN */ |
| 5695 | (iw_handler) iw_get_scan, /* SIOCGIWSCAN */ |
| 5696 | (iw_handler) iw_set_essid, /* SIOCSIWESSID */ |
| 5697 | (iw_handler) iw_get_essid, /* SIOCGIWESSID */ |
| 5698 | (iw_handler) iw_set_nick, /* SIOCSIWNICKN */ |
| 5699 | (iw_handler) iw_get_nick, /* SIOCGIWNICKN */ |
| 5700 | (iw_handler) NULL, /* -- hole -- */ |
| 5701 | (iw_handler) NULL, /* -- hole -- */ |
| 5702 | (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */ |
| 5703 | (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */ |
| 5704 | (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */ |
| 5705 | (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */ |
| 5706 | (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */ |
| 5707 | (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */ |
| 5708 | (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */ |
| 5709 | (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */ |
| 5710 | (iw_handler) iw_set_retry, /* SIOCSIWRETRY */ |
| 5711 | (iw_handler) iw_get_retry, /* SIOCGIWRETRY */ |
| 5712 | (iw_handler) iw_set_encode, /* SIOCSIWENCODE */ |
| 5713 | (iw_handler) iw_get_encode, /* SIOCGIWENCODE */ |
| 5714 | (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */ |
| 5715 | (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */ |
| 5716 | (iw_handler) NULL, /* -- hole -- */ |
| 5717 | (iw_handler) NULL, /* -- hole -- */ |
| 5718 | (iw_handler) iw_set_genie, /* SIOCSIWGENIE */ |
| 5719 | (iw_handler) iw_get_genie, /* SIOCGIWGENIE */ |
| 5720 | (iw_handler) iw_set_auth, /* SIOCSIWAUTH */ |
| 5721 | (iw_handler) iw_get_auth, /* SIOCGIWAUTH */ |
| 5722 | (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */ |
| 5723 | (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */ |
| 5724 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 5725 | }; |
| 5726 | |
| 5727 | static const iw_handler we_private[] = { |
| 5728 | |
| 5729 | [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl |
| 5730 | [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl |
| 5731 | [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl |
| 5732 | [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone, |
| 5733 | [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone, |
| 5734 | [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl |
| 5735 | [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone, |
| 5736 | [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec, |
| 5737 | [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec, |
| 5738 | [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5739 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 5740 | [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc |
| 5741 | [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc |
| 5742 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5743 | |
| 5744 | #ifdef FEATURE_WLAN_WAPI |
| 5745 | [WLAN_PRIV_SET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_mode, |
| 5746 | [WLAN_PRIV_GET_WAPI_MODE - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_mode, |
| 5747 | [WLAN_PRIV_SET_WAPI_ASSOC_INFO - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_assoc_info, |
| 5748 | [WLAN_PRIV_SET_WAPI_KEY - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_key, |
| 5749 | [WLAN_PRIV_SET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_set_wapi_bkid, |
| 5750 | [WLAN_PRIV_GET_WAPI_BKID - SIOCIWFIRSTPRIV] = iw_qcom_get_wapi_bkid, |
| 5751 | #endif /* FEATURE_WLAN_WAPI */ |
| 5752 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5753 | [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties, |
| 5754 | #endif |
| 5755 | [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload, |
| 5756 | [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics, |
| 5757 | [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params |
| 5758 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5759 | , |
| 5760 | [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params |
| 5761 | #endif |
| 5762 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 5763 | , |
| 5764 | [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv |
| 5765 | #endif |
| 5766 | , |
| 5767 | [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config, |
| 5768 | [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter, |
| 5769 | [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter, |
| 5770 | [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv, |
| 5771 | [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed |
| 5772 | }; |
| 5773 | |
| 5774 | /*Maximum command length can be only 15 */ |
| 5775 | static const struct iw_priv_args we_private_args[] = { |
| 5776 | |
| 5777 | /* handlers for main ioctl */ |
| 5778 | { WLAN_PRIV_SET_INT_GET_NONE, |
| 5779 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5780 | 0, |
| 5781 | "" }, |
| 5782 | |
| 5783 | /* handlers for sub-ioctl */ |
| 5784 | { WE_SET_11D_STATE, |
| 5785 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5786 | 0, |
| 5787 | "set11Dstate" }, |
| 5788 | |
| 5789 | { WE_WOWL, |
| 5790 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5791 | 0, |
| 5792 | "wowl" }, |
| 5793 | |
| 5794 | { WE_SET_POWER, |
| 5795 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5796 | 0, |
| 5797 | "setPower" }, |
| 5798 | |
| 5799 | { WE_SET_MAX_ASSOC, |
| 5800 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5801 | 0, |
| 5802 | "setMaxAssoc" }, |
| 5803 | |
| 5804 | { WE_SET_SAP_AUTO_CHANNEL_SELECTION, |
| 5805 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5806 | 0, |
| 5807 | "setAutoChannel" }, |
| 5808 | |
| 5809 | { WE_SET_DATA_INACTIVITY_TO, |
| 5810 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5811 | 0, |
| 5812 | "inactivityTO" }, |
| 5813 | |
| 5814 | { WE_SET_MAX_TX_POWER, |
| 5815 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5816 | 0, |
| 5817 | "setMaxTxPower" }, |
| 5818 | /* set Higher DTIM Transition (DTIM1 to DTIM3) |
| 5819 | * 1 = enable and 0 = disable */ |
| 5820 | { |
| 5821 | WE_SET_HIGHER_DTIM_TRANSITION, |
| 5822 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5823 | 0, |
| 5824 | "setHDtimTransn" }, |
| 5825 | |
| 5826 | { WE_SET_TM_LEVEL, |
| 5827 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5828 | 0, |
| 5829 | "setTmLevel" }, |
| 5830 | |
| 5831 | /* handlers for main ioctl */ |
| 5832 | { WLAN_PRIV_SET_NONE_GET_INT, |
| 5833 | 0, |
| 5834 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5835 | "" }, |
| 5836 | |
| 5837 | /* handlers for sub-ioctl */ |
| 5838 | { WE_GET_11D_STATE, |
| 5839 | 0, |
| 5840 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5841 | "get11Dstate" }, |
| 5842 | |
| 5843 | { WE_IBSS_STATUS, |
| 5844 | 0, |
| 5845 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5846 | "getAdhocStatus" }, |
| 5847 | |
| 5848 | { WE_PMC_STATE, |
| 5849 | 0, |
| 5850 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5851 | "pmcState" }, |
| 5852 | |
| 5853 | { WE_GET_WLAN_DBG, |
| 5854 | 0, |
| 5855 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5856 | "getwlandbg" }, |
| 5857 | |
| 5858 | { WE_MODULE_DOWN_IND, |
| 5859 | 0, |
| 5860 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5861 | "moduleDownInd" }, |
| 5862 | |
| 5863 | { WE_GET_MAX_ASSOC, |
| 5864 | 0, |
| 5865 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5866 | "getMaxAssoc" }, |
| 5867 | |
| 5868 | #ifdef FEATURE_WLAN_INTEGRATED_SOC |
| 5869 | { WE_GET_WDI_DBG, |
| 5870 | 0, |
| 5871 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5872 | "getwdidbg" }, |
| 5873 | #endif // FEATURE_WLAN_INTEGRATED_SOC |
| 5874 | |
| 5875 | { WE_GET_SAP_AUTO_CHANNEL_SELECTION, |
| 5876 | 0, |
| 5877 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5878 | "getAutoChannel" }, |
| 5879 | |
| 5880 | { WE_GET_CONCURRENCY_MODE, |
| 5881 | 0, |
| 5882 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5883 | "getconcurrency" }, |
| 5884 | |
| 5885 | /* handlers for main ioctl */ |
| 5886 | { WLAN_PRIV_SET_CHAR_GET_NONE, |
| 5887 | IW_PRIV_TYPE_CHAR| 512, |
| 5888 | 0, |
| 5889 | "" }, |
| 5890 | |
| 5891 | /* handlers for sub-ioctl */ |
| 5892 | { WE_WOWL_ADD_PTRN, |
| 5893 | IW_PRIV_TYPE_CHAR| 512, |
| 5894 | 0, |
| 5895 | "wowlAddPtrn" }, |
| 5896 | |
| 5897 | { WE_WOWL_DEL_PTRN, |
| 5898 | IW_PRIV_TYPE_CHAR| 512, |
| 5899 | 0, |
| 5900 | "wowlDelPtrn" }, |
| 5901 | |
| 5902 | #if defined WLAN_FEATURE_VOWIFI |
| 5903 | /* handlers for sub-ioctl */ |
| 5904 | { WE_NEIGHBOR_REPORT_REQUEST, |
| 5905 | IW_PRIV_TYPE_CHAR | 512, |
| 5906 | 0, |
| 5907 | "neighbor" }, |
| 5908 | #endif |
| 5909 | { WE_SET_AP_WPS_IE, |
| 5910 | IW_PRIV_TYPE_CHAR| 512, |
| 5911 | 0, |
| 5912 | "set_ap_wps_ie" }, |
| 5913 | |
| 5914 | { WE_SET_CONFIG, |
| 5915 | IW_PRIV_TYPE_CHAR| 512, |
| 5916 | 0, |
| 5917 | "setConfig" }, |
| 5918 | |
| 5919 | /* handlers for main ioctl */ |
| 5920 | { WLAN_PRIV_SET_THREE_INT_GET_NONE, |
| 5921 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 5922 | 0, |
| 5923 | "" }, |
| 5924 | |
| 5925 | /* handlers for sub-ioctl */ |
| 5926 | { WE_SET_WLAN_DBG, |
| 5927 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 5928 | 0, |
| 5929 | "setwlandbg" }, |
| 5930 | |
| 5931 | #ifdef FEATURE_WLAN_INTEGRATED_SOC |
| 5932 | { WE_SET_WDI_DBG, |
| 5933 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 5934 | 0, |
| 5935 | "setwdidbg" }, |
| 5936 | #endif // FEATURE_WLAN_INTEGRATED_SOC |
| 5937 | |
| 5938 | { WE_SET_SAP_CHANNELS, |
| 5939 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 5940 | 0, |
| 5941 | "setsapchannels" }, |
| 5942 | |
| 5943 | /* handlers for main ioctl */ |
| 5944 | { WLAN_PRIV_GET_CHAR_SET_NONE, |
| 5945 | 0, |
| 5946 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5947 | "" }, |
| 5948 | |
| 5949 | /* handlers for sub-ioctl */ |
| 5950 | { WE_WLAN_VERSION, |
| 5951 | 0, |
| 5952 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5953 | "version" }, |
| 5954 | { WE_GET_STATS, |
| 5955 | 0, |
| 5956 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5957 | "getStats" }, |
| 5958 | { WE_GET_CFG, |
| 5959 | 0, |
| 5960 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5961 | "getConfig" }, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5962 | #ifdef WLAN_FEATURE_11AC |
| 5963 | { WE_GET_RSSI, |
| 5964 | 0, |
| 5965 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5966 | "getRSSI" }, |
| 5967 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5968 | { WE_GET_WMM_STATUS, |
| 5969 | 0, |
| 5970 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5971 | "getWmmStatus" }, |
| 5972 | { |
| 5973 | WE_GET_CHANNEL_LIST, |
| 5974 | 0, |
| 5975 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 5976 | "getChannelList" }, |
| 5977 | |
| 5978 | /* handlers for main ioctl */ |
| 5979 | { WLAN_PRIV_SET_NONE_GET_NONE, |
| 5980 | 0, |
| 5981 | 0, |
| 5982 | "" }, |
| 5983 | |
| 5984 | /* handlers for sub-ioctl */ |
| 5985 | { WE_CLEAR_STATS, |
| 5986 | 0, |
| 5987 | 0, |
| 5988 | "clearStats" }, |
| 5989 | { WE_INIT_AP, |
| 5990 | 0, |
| 5991 | 0, |
| 5992 | "initAP" }, |
| 5993 | { WE_STOP_AP, |
| 5994 | 0, |
| 5995 | 0, |
| 5996 | "exitAP" }, |
| 5997 | { WE_ENABLE_AMP, |
| 5998 | 0, |
| 5999 | 0, |
| 6000 | "enableAMP" }, |
| 6001 | { WE_DISABLE_AMP, |
| 6002 | 0, |
| 6003 | 0, |
| 6004 | "disableAMP" }, |
| 6005 | |
| 6006 | /* handlers for main ioctl */ |
| 6007 | { WLAN_PRIV_SET_VAR_INT_GET_NONE, |
| 6008 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 6009 | 0, |
| 6010 | "" }, |
| 6011 | |
| 6012 | /* handlers for sub-ioctl */ |
| 6013 | { WE_LOG_DUMP_CMD, |
| 6014 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 6015 | 0, |
| 6016 | "dump" }, |
| 6017 | |
| 6018 | /* handlers for main ioctl */ |
| 6019 | { WLAN_PRIV_ADD_TSPEC, |
| 6020 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT, |
| 6021 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6022 | "addTspec" }, |
| 6023 | |
| 6024 | /* handlers for main ioctl */ |
| 6025 | { WLAN_PRIV_DEL_TSPEC, |
| 6026 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6027 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6028 | "delTspec" }, |
| 6029 | |
| 6030 | /* handlers for main ioctl */ |
| 6031 | { WLAN_PRIV_GET_TSPEC, |
| 6032 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6033 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6034 | "getTspec" }, |
| 6035 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6036 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 6037 | /* handlers for main ioctl - OEM DATA */ |
| 6038 | { |
| 6039 | WLAN_PRIV_SET_OEM_DATA_REQ, |
| 6040 | IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED, |
| 6041 | 0, |
| 6042 | "set_oem_data_req" }, |
| 6043 | |
| 6044 | /* handlers for main ioctl - OEM DATA */ |
| 6045 | { |
| 6046 | WLAN_PRIV_GET_OEM_DATA_RSP, |
| 6047 | 0, |
| 6048 | IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN, |
| 6049 | "get_oem_data_rsp" }, |
| 6050 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6051 | |
| 6052 | #ifdef FEATURE_WLAN_WAPI |
| 6053 | /* handlers for main ioctl SET_WAPI_MODE */ |
| 6054 | { WLAN_PRIV_SET_WAPI_MODE, |
| 6055 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6056 | 0, |
| 6057 | "SET_WAPI_MODE" }, |
| 6058 | |
| 6059 | /* handlers for main ioctl GET_WAPI_MODE */ |
| 6060 | { WLAN_PRIV_GET_WAPI_MODE, |
| 6061 | 0, |
| 6062 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 6063 | "GET_WAPI_MODE" }, |
| 6064 | |
| 6065 | /* handlers for main ioctl SET_ASSOC_INFO */ |
| 6066 | { WLAN_PRIV_SET_WAPI_ASSOC_INFO, |
| 6067 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 400, |
| 6068 | 0, |
| 6069 | "SET_WAPI_ASSOC" }, |
| 6070 | |
| 6071 | /* handlers for main ioctl SET_WAPI_KEY */ |
| 6072 | { WLAN_PRIV_SET_WAPI_KEY, |
| 6073 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 71, |
| 6074 | 0, |
| 6075 | "SET_WAPI_KEY" }, |
| 6076 | |
| 6077 | /* handlers for main ioctl SET_WAPI_BKID */ |
| 6078 | { WLAN_PRIV_SET_WAPI_BKID, |
| 6079 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24, |
| 6080 | 0, |
| 6081 | "SET_WAPI_BKID" }, |
| 6082 | |
| 6083 | /* handlers for main ioctl GET_WAPI_BKID */ |
| 6084 | { WLAN_PRIV_GET_WAPI_BKID, |
| 6085 | 0, |
| 6086 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 24, |
| 6087 | "GET_WAPI_BKID" }, |
| 6088 | #endif /* FEATURE_WLAN_WAPI */ |
| 6089 | |
| 6090 | /* handlers for main ioctl - host offload */ |
| 6091 | { |
| 6092 | WLAN_PRIV_SET_HOST_OFFLOAD, |
| 6093 | IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest), |
| 6094 | 0, |
| 6095 | "setHostOffload" }, |
| 6096 | |
| 6097 | { |
| 6098 | WLAN_GET_WLAN_STATISTICS, |
| 6099 | 0, |
| 6100 | IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN, |
| 6101 | "getWlanStats" }, |
| 6102 | |
| 6103 | { |
| 6104 | WLAN_SET_KEEPALIVE_PARAMS, |
| 6105 | IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest), |
| 6106 | 0, |
| 6107 | "setKeepAlive" }, |
| 6108 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 6109 | { |
| 6110 | WLAN_SET_PACKET_FILTER_PARAMS, |
| 6111 | IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg), |
| 6112 | 0, |
| 6113 | "setPktFilter" }, |
| 6114 | #endif |
| 6115 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 6116 | { |
| 6117 | WLAN_SET_PNO, |
| 6118 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 6119 | 0, |
| 6120 | "setpno" }, |
| 6121 | #endif |
| 6122 | { |
| 6123 | WLAN_SET_BAND_CONFIG, |
| 6124 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 6125 | 0, |
| 6126 | "SETBAND" }, |
| 6127 | /* handlers for dynamic MC BC ioctl */ |
| 6128 | { |
| 6129 | WLAN_PRIV_SET_MCBC_FILTER, |
| 6130 | IW_PRIV_TYPE_BYTE | sizeof(tMcBcFilterCfg), |
| 6131 | 0, |
| 6132 | "setMCBCFilter" }, |
| 6133 | { |
| 6134 | WLAN_PRIV_CLEAR_MCBC_FILTER, |
| 6135 | 0, |
| 6136 | 0, |
| 6137 | "clearMCBCFilter" }, |
| 6138 | { |
| 6139 | WLAN_SET_POWER_PARAMS, |
| 6140 | IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN, |
| 6141 | 0, |
| 6142 | "setpowerparams" }, |
| 6143 | { |
| 6144 | WLAN_GET_LINK_SPEED, |
| 6145 | IW_PRIV_TYPE_CHAR | 18, |
| 6146 | IW_PRIV_TYPE_CHAR | 3, "getLinkSpeed" }, |
| 6147 | }; |
| 6148 | |
| 6149 | |
| 6150 | |
| 6151 | const struct iw_handler_def we_handler_def = { |
| 6152 | .num_standard = sizeof(we_handler) / sizeof(we_handler[0]), |
| 6153 | .num_private = sizeof(we_private) / sizeof(we_private[0]), |
| 6154 | .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]), |
| 6155 | |
| 6156 | .standard = (iw_handler *)we_handler, |
| 6157 | .private = (iw_handler *)we_private, |
| 6158 | .private_args = we_private_args, |
| 6159 | .get_wireless_stats = get_wireless_stats, |
| 6160 | }; |
| 6161 | |
| 6162 | int hdd_set_wext(hdd_adapter_t *pAdapter) |
| 6163 | { |
| 6164 | hdd_wext_state_t *pwextBuf; |
| 6165 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6166 | |
| 6167 | pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6168 | |
| 6169 | // Now configure the roaming profile links. To SSID and bssid. |
| 6170 | pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0; |
| 6171 | pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID; |
| 6172 | |
| 6173 | pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0; |
| 6174 | pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId; |
| 6175 | |
| 6176 | /*Set the numOfChannels to zero to scan all the channels*/ |
| 6177 | pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0; |
| 6178 | pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL; |
| 6179 | |
| 6180 | /* Default is no encryption */ |
| 6181 | pwextBuf->roamProfile.EncryptionType.numEntries = 1; |
| 6182 | pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 6183 | |
| 6184 | pwextBuf->roamProfile.mcEncryptionType.numEntries = 1; |
| 6185 | pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 6186 | |
| 6187 | pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
| 6188 | |
| 6189 | /* Default is no authentication */ |
| 6190 | pwextBuf->roamProfile.AuthType.numEntries = 1; |
| 6191 | pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6192 | |
| 6193 | pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS; |
| 6194 | pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 6195 | |
| 6196 | /*Set the default scan mode*/ |
| 6197 | pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
| 6198 | |
| 6199 | hdd_clearRoamProfileIe(pAdapter); |
| 6200 | |
| 6201 | return VOS_STATUS_SUCCESS; |
| 6202 | |
| 6203 | } |
| 6204 | |
| 6205 | int hdd_register_wext(struct net_device *dev) |
| 6206 | { |
| 6207 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6208 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6209 | VOS_STATUS status; |
| 6210 | |
| 6211 | ENTER(); |
| 6212 | |
| 6213 | // Zero the memory. This zeros the profile structure. |
| 6214 | memset(pwextBuf, 0,sizeof(hdd_wext_state_t)); |
| 6215 | |
| 6216 | init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var); |
| 6217 | |
| 6218 | |
| 6219 | status = hdd_set_wext(pAdapter); |
| 6220 | |
| 6221 | if(!VOS_IS_STATUS_SUCCESS(status)) { |
| 6222 | |
| 6223 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!\n")); |
| 6224 | return eHAL_STATUS_FAILURE; |
| 6225 | } |
| 6226 | |
| 6227 | if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent))) |
| 6228 | { |
| 6229 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!\n")); |
| 6230 | return eHAL_STATUS_FAILURE; |
| 6231 | } |
| 6232 | |
| 6233 | if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent))) |
| 6234 | { |
| 6235 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!\n")); |
| 6236 | return eHAL_STATUS_FAILURE; |
| 6237 | } |
| 6238 | |
| 6239 | // Register as a wireless device |
| 6240 | dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def; |
| 6241 | |
| 6242 | EXIT(); |
| 6243 | return 0; |
| 6244 | } |
| 6245 | |
| 6246 | int hdd_UnregisterWext(struct net_device *dev) |
| 6247 | { |
| 6248 | #if 0 |
| 6249 | hdd_wext_state_t *wextBuf; |
| 6250 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6251 | |
| 6252 | ENTER(); |
| 6253 | // Set up the pointer to the Wireless Extensions state structure |
| 6254 | wextBuf = pAdapter->pWextState; |
| 6255 | |
| 6256 | // De-allocate the Wireless Extensions state structure |
| 6257 | kfree(wextBuf); |
| 6258 | |
| 6259 | // Clear out the pointer to the Wireless Extensions state structure |
| 6260 | pAdapter->pWextState = NULL; |
| 6261 | |
| 6262 | EXIT(); |
| 6263 | #endif |
| 6264 | dev->wireless_handlers = NULL; |
| 6265 | return 0; |
| 6266 | } |
| 6267 | |
| 6268 | |