Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Sourav Mohapatra | 5817dc4 | 2017-12-18 17:45:16 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 27 | |
| 28 | /**======================================================================== |
| 29 | |
| 30 | \file wlan_hdd_hostapd.c |
| 31 | \brief WLAN Host Device Driver implementation |
| 32 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 33 | |
| 34 | ========================================================================*/ |
| 35 | /**========================================================================= |
| 36 | EDIT HISTORY FOR FILE |
| 37 | |
| 38 | |
| 39 | This section contains comments describing changes made to the module. |
| 40 | Notice that changes are listed in reverse chronological order. |
| 41 | |
| 42 | $Header:$ $DateTime: $ $Author: $ |
| 43 | |
| 44 | |
| 45 | when who what, where, why |
| 46 | -------- --- -------------------------------------------------------- |
| 47 | 04/5/09 Shailender Created module. |
| 48 | 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure |
| 49 | ==========================================================================*/ |
| 50 | /*-------------------------------------------------------------------------- |
| 51 | Include Files |
| 52 | ------------------------------------------------------------------------*/ |
| 53 | |
| 54 | #include <linux/version.h> |
| 55 | #include <linux/module.h> |
| 56 | #include <linux/kernel.h> |
| 57 | #include <linux/init.h> |
| 58 | #include <linux/wireless.h> |
| 59 | #include <linux/semaphore.h> |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 60 | #include <linux/compat.h> |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 61 | #include <linux/rtnetlink.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 62 | #include <vos_api.h> |
| 63 | #include <vos_sched.h> |
| 64 | #include <linux/etherdevice.h> |
| 65 | #include <wlan_hdd_includes.h> |
| 66 | #include <qc_sap_ioctl.h> |
| 67 | #include <wlan_hdd_hostapd.h> |
| 68 | #include <sapApi.h> |
| 69 | #include <sapInternal.h> |
| 70 | #include <wlan_qct_tl.h> |
| 71 | #include <wlan_hdd_softap_tx_rx.h> |
| 72 | #include <wlan_hdd_main.h> |
| 73 | #include <linux/netdevice.h> |
| 74 | #include <linux/mmc/sdio_func.h> |
| 75 | #include "wlan_nlink_common.h" |
| 76 | #include "wlan_btc_svc.h" |
| 77 | #include <bap_hdd_main.h> |
Masti, Narayanraddi | 575ccc7 | 2015-08-17 18:04:57 +0530 | [diff] [blame] | 78 | #include "wlan_hdd_tdls.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 79 | #include "wlan_hdd_p2p.h" |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 80 | #include "cfgApi.h" |
Satyanarayana Dash | 6f43827 | 2015-03-03 18:01:06 +0530 | [diff] [blame] | 81 | #include "wniCfg.h" |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 82 | #include <wlan_hdd_wowl.h> |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 83 | #include "wlan_hdd_hostapd.h" |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 84 | #include "wlan_hdd_request_manager.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 86 | #ifdef FEATURE_WLAN_CH_AVOID |
| 87 | #include "wcnss_wlan.h" |
| 88 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 89 | #include "wlan_hdd_trace.h" |
| 90 | #include "vos_types.h" |
| 91 | #include "vos_trace.h" |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 92 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 93 | #define IS_UP(_dev) \ |
| 94 | (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP)) |
| 95 | #define IS_UP_AUTO(_ic) \ |
| 96 | (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO) |
| 97 | #define WE_WLAN_VERSION 1 |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 98 | #define WE_GET_STA_INFO_SIZE 30 |
| 99 | /* WEXT limition: MAX allowed buf len for any * |
| 100 | * IW_PRIV_TYPE_CHAR is 2Kbytes * |
| 101 | */ |
| 102 | #define WE_SAP_MAX_STA_INFO 0x7FF |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 103 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 104 | #define SAP_24GHZ_CH_COUNT (14) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 105 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 106 | #ifdef FEATURE_WLAN_CH_AVOID |
| 107 | /* Channle/Freqency table */ |
| 108 | extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS]; |
| 109 | safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] = |
| 110 | { |
| 111 | /*CH , SAFE, default safe */ |
| 112 | {1 , VOS_TRUE}, //RF_CHAN_1, |
| 113 | {2 , VOS_TRUE}, //RF_CHAN_2, |
| 114 | {3 , VOS_TRUE}, //RF_CHAN_3, |
| 115 | {4 , VOS_TRUE}, //RF_CHAN_4, |
| 116 | {5 , VOS_TRUE}, //RF_CHAN_5, |
| 117 | {6 , VOS_TRUE}, //RF_CHAN_6, |
| 118 | {7 , VOS_TRUE}, //RF_CHAN_7, |
| 119 | {8 , VOS_TRUE}, //RF_CHAN_8, |
| 120 | {9 , VOS_TRUE}, //RF_CHAN_9, |
| 121 | {10 , VOS_TRUE}, //RF_CHAN_10, |
| 122 | {11 , VOS_TRUE}, //RF_CHAN_11, |
| 123 | {12 , VOS_TRUE}, //RF_CHAN_12, |
| 124 | {13 , VOS_TRUE}, //RF_CHAN_13, |
| 125 | {14 , VOS_TRUE}, //RF_CHAN_14, |
| 126 | {240, VOS_TRUE}, //RF_CHAN_240, |
| 127 | {244, VOS_TRUE}, //RF_CHAN_244, |
| 128 | {248, VOS_TRUE}, //RF_CHAN_248, |
| 129 | {252, VOS_TRUE}, //RF_CHAN_252, |
| 130 | {208, VOS_TRUE}, //RF_CHAN_208, |
| 131 | {212, VOS_TRUE}, //RF_CHAN_212, |
| 132 | {216, VOS_TRUE}, //RF_CHAN_216, |
| 133 | {36 , VOS_TRUE}, //RF_CHAN_36, |
| 134 | {40 , VOS_TRUE}, //RF_CHAN_40, |
| 135 | {44 , VOS_TRUE}, //RF_CHAN_44, |
| 136 | {48 , VOS_TRUE}, //RF_CHAN_48, |
| 137 | {52 , VOS_TRUE}, //RF_CHAN_52, |
| 138 | {56 , VOS_TRUE}, //RF_CHAN_56, |
| 139 | {60 , VOS_TRUE}, //RF_CHAN_60, |
| 140 | {64 , VOS_TRUE}, //RF_CHAN_64, |
| 141 | {100, VOS_TRUE}, //RF_CHAN_100, |
| 142 | {104, VOS_TRUE}, //RF_CHAN_104, |
| 143 | {108, VOS_TRUE}, //RF_CHAN_108, |
| 144 | {112, VOS_TRUE}, //RF_CHAN_112, |
| 145 | {116, VOS_TRUE}, //RF_CHAN_116, |
| 146 | {120, VOS_TRUE}, //RF_CHAN_120, |
| 147 | {124, VOS_TRUE}, //RF_CHAN_124, |
| 148 | {128, VOS_TRUE}, //RF_CHAN_128, |
| 149 | {132, VOS_TRUE}, //RF_CHAN_132, |
| 150 | {136, VOS_TRUE}, //RF_CHAN_136, |
| 151 | {140, VOS_TRUE}, //RF_CHAN_140, |
| 152 | {149, VOS_TRUE}, //RF_CHAN_149, |
| 153 | {153, VOS_TRUE}, //RF_CHAN_153, |
| 154 | {157, VOS_TRUE}, //RF_CHAN_157, |
| 155 | {161, VOS_TRUE}, //RF_CHAN_161, |
| 156 | {165, VOS_TRUE}, //RF_CHAN_165, |
| 157 | }; |
| 158 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 159 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 160 | /*--------------------------------------------------------------------------- |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 161 | * Function definitions |
| 162 | *-------------------------------------------------------------------------*/ |
| 163 | /**--------------------------------------------------------------------------- |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 164 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 165 | \brief __hdd_hostapd_open() - HDD Open function for hostapd interface |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 166 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 167 | This is called in response to ifconfig up |
| 168 | |
| 169 | \param - dev Pointer to net_device structure |
| 170 | |
| 171 | \return - 0 for success non-zero for failure |
| 172 | |
| 173 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 174 | int __hdd_hostapd_open (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 175 | { |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 176 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 177 | hdd_context_t *pHddCtx; |
| 178 | VOS_STATUS status; |
| 179 | v_BOOL_t in_standby = TRUE; |
| 180 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 181 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 182 | ENTER(); |
| 183 | |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 184 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) { |
| 185 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: session already opened for the adapter", |
| 186 | __func__); |
| 187 | return 0; |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 188 | } |
| 189 | |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 190 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 191 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 192 | pAdapter->sessionId, pAdapter->device_mode)); |
| 193 | if (NULL == pHddCtx) |
| 194 | { |
| 195 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 196 | "%s: HDD context is Null", __func__); |
| 197 | return -ENODEV; |
| 198 | } |
| 199 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 200 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 201 | { |
| 202 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 203 | { |
| 204 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
| 205 | __func__); |
| 206 | in_standby = FALSE; |
| 207 | break; |
| 208 | } |
| 209 | else |
| 210 | { |
| 211 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 212 | pAdapterNode = pNext; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | if (TRUE == in_standby) |
| 217 | { |
| 218 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 219 | { |
| 220 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 221 | "wlan out of power save", __func__); |
| 222 | return -EINVAL; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | status = hdd_init_ap_mode( pAdapter, false); |
| 227 | if( VOS_STATUS_SUCCESS != status ) { |
| 228 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to create session for station mode", |
| 229 | __func__); |
| 230 | return -EINVAL; |
| 231 | } |
| 232 | |
| 233 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
| 234 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 235 | //Turn ON carrier state |
| 236 | netif_carrier_on(dev); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 237 | //Enable all Tx queues |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 238 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | netif_tx_start_all_queues(dev); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 240 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 241 | EXIT(); |
| 242 | return 0; |
| 243 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 244 | |
| 245 | int hdd_hostapd_open (struct net_device *dev) |
| 246 | { |
| 247 | int ret; |
| 248 | |
| 249 | vos_ssr_protect(__func__); |
| 250 | ret = __hdd_hostapd_open(dev); |
| 251 | vos_ssr_unprotect(__func__); |
| 252 | |
| 253 | return ret; |
| 254 | } |
| 255 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 256 | /**--------------------------------------------------------------------------- |
| 257 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 258 | \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 259 | |
| 260 | This is called in response to ifconfig down |
| 261 | |
| 262 | \param - dev Pointer to net_device structure |
| 263 | |
| 264 | \return - 0 for success non-zero for failure |
| 265 | |
| 266 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 267 | int __hdd_hostapd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 268 | { |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 269 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 270 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 271 | int ret; |
| 272 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 273 | ENTER(); |
| 274 | |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 275 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 276 | if (0 != ret) |
| 277 | return ret; |
Kanchanapally, Vidyullatha | 99bd6c4 | 2014-12-10 13:54:38 +0530 | [diff] [blame] | 278 | |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 279 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
| 280 | |
| 281 | //Stop all tx queues |
| 282 | netif_tx_disable(dev); |
| 283 | |
| 284 | //Turn OFF carrier state |
| 285 | netif_carrier_off(dev); |
| 286 | |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 287 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 288 | hdd_stop_adapter(hdd_ctx, adapter, VOS_TRUE); |
| 289 | hdd_deinit_adapter(hdd_ctx, adapter, TRUE); |
| 290 | } |
| 291 | |
| 292 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 293 | adapter->dev->wireless_handlers = NULL; |
| 294 | |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 295 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 296 | sme_ScanFlushResult(hdd_ctx->hHal, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 297 | |
| 298 | EXIT(); |
| 299 | return 0; |
| 300 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 301 | |
| 302 | int hdd_hostapd_stop (struct net_device *dev) |
| 303 | { |
| 304 | int ret; |
| 305 | |
| 306 | vos_ssr_protect(__func__); |
| 307 | ret = __hdd_hostapd_stop(dev); |
| 308 | vos_ssr_unprotect(__func__); |
| 309 | |
| 310 | return ret; |
| 311 | } |
| 312 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 313 | /**--------------------------------------------------------------------------- |
| 314 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 315 | \brief __hdd_hostapd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 316 | |
| 317 | This is called during the netdev unregister to uninitialize all data |
| 318 | associated with the device |
| 319 | |
| 320 | \param - dev Pointer to net_device structure |
| 321 | |
| 322 | \return - void |
| 323 | |
| 324 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 325 | static void __hdd_hostapd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 326 | { |
| 327 | hdd_adapter_t *pHostapdAdapter = netdev_priv(dev); |
Mukul Sharma | fe1959a | 2015-02-28 20:02:55 +0530 | [diff] [blame] | 328 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 329 | |
| 330 | ENTER(); |
| 331 | |
Mukul Sharma | fe1959a | 2015-02-28 20:02:55 +0530 | [diff] [blame] | 332 | if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 333 | { |
Mukul Sharma | fe1959a | 2015-02-28 20:02:55 +0530 | [diff] [blame] | 334 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 335 | FL("Invalid magic")); |
| 336 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 337 | } |
Mukul Sharma | fe1959a | 2015-02-28 20:02:55 +0530 | [diff] [blame] | 338 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 339 | if (NULL == pHddCtx) |
| 340 | { |
| 341 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 342 | FL("NULL pHddCtx")); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE); |
| 347 | |
| 348 | /* after uninit our adapter structure will no longer be valid */ |
| 349 | pHostapdAdapter->dev = NULL; |
| 350 | pHostapdAdapter->magic = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 351 | |
| 352 | EXIT(); |
| 353 | } |
| 354 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 355 | static void hdd_hostapd_uninit (struct net_device *dev) |
| 356 | { |
| 357 | vos_ssr_protect(__func__); |
| 358 | __hdd_hostapd_uninit(dev); |
| 359 | vos_ssr_unprotect(__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 360 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 361 | return; |
| 362 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 363 | /**============================================================================ |
| 364 | @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for |
| 365 | transmitting packets. There are 2 versions of this function. One that uses |
| 366 | locked queue and other that uses lockless queues. Both have been retained to |
| 367 | do some performance testing |
| 368 | @param skb : [in] pointer to OS packet (sk_buff) |
| 369 | @param dev : [in] pointer to Libra network device |
| 370 | |
| 371 | @return : NET_XMIT_DROP if packets are dropped |
| 372 | : NET_XMIT_SUCCESS if packet is enqueued succesfully |
| 373 | ===========================================================================*/ |
| 374 | int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 375 | { |
| 376 | return 0; |
| 377 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 378 | |
| 379 | int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 380 | { |
| 381 | return 0; |
| 382 | } |
| 383 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 384 | int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu) |
| 385 | { |
| 386 | int ret; |
| 387 | vos_ssr_protect(__func__); |
| 388 | ret = __hdd_hostapd_change_mtu(dev, new_mtu); |
| 389 | vos_ssr_unprotect(__func__); |
| 390 | |
| 391 | return ret; |
| 392 | } |
| 393 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 394 | static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter, |
| 395 | hdd_priv_data_t *priv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 396 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 397 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 398 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 399 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 400 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 401 | int status; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 402 | /* |
| 403 | * Note that valid pointers are provided by caller |
| 404 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 405 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 406 | ENTER(); |
| 407 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 408 | if (priv_data->total_len <= 0 || |
| 409 | priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX) |
| 410 | { |
| 411 | /* below we allocate one more byte for command buffer. |
| 412 | * To avoid addition overflow total_len should be |
| 413 | * smaller than INT_MAX. */ |
| 414 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d", |
| 415 | __func__, priv_data->total_len); |
| 416 | ret = -EFAULT; |
| 417 | goto exit; |
| 418 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 419 | status = wlan_hdd_validate_context(pHddCtx); |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 420 | if (0 != status) |
| 421 | { |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 422 | return status; |
| 423 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 424 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 425 | /* Allocate +1 for '\0' */ |
| 426 | command = kmalloc((priv_data->total_len + 1), GFP_KERNEL); |
| 427 | if (!command) |
| 428 | { |
| 429 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__); |
| 430 | ret = -ENOMEM; |
| 431 | goto exit; |
| 432 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 433 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 434 | if (copy_from_user(command, priv_data->buf, priv_data->total_len)) |
| 435 | { |
| 436 | ret = -EFAULT; |
| 437 | goto exit; |
| 438 | } |
Mingcheng Zhu | c7608ae | 2013-11-04 15:11:01 -0800 | [diff] [blame] | 439 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 440 | /* Make sure the command is NUL-terminated */ |
| 441 | command[priv_data->total_len] = '\0'; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 442 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 443 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 444 | "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 445 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 446 | if (strncmp(command, "P2P_SET_NOA", 11) == 0) |
| 447 | { |
| 448 | hdd_setP2pNoa(pAdapter->dev, command); |
| 449 | } |
| 450 | else if (strncmp(command, "P2P_SET_PS", 10) == 0) |
| 451 | { |
| 452 | hdd_setP2pOpps(pAdapter->dev, command); |
| 453 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 454 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 455 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
| 456 | { |
| 457 | ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command); |
| 458 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 459 | #endif |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 460 | else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
| 461 | { |
| 462 | /* |
| 463 | * command should be a string having format |
| 464 | * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces> |
| 465 | */ |
| 466 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 467 | "%s: Received Command to Set Preferred Channels for SAP", |
| 468 | __func__); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 469 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 470 | ret = sapSetPreferredChannel(command); |
| 471 | } |
Ganesh Kondabattini | 2d7c7f0 | 2014-09-04 22:21:39 +0530 | [diff] [blame] | 472 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 473 | { |
| 474 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 475 | tANI_U8 filterType = 0; |
| 476 | tANI_U8 *value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 477 | |
| 478 | ret = hdd_drv_cmd_validate(command, 8); |
| 479 | if (ret) |
| 480 | goto exit; |
| 481 | |
Ganesh Kondabattini | 2d7c7f0 | 2014-09-04 22:21:39 +0530 | [diff] [blame] | 482 | value = command + 9; |
| 483 | |
| 484 | /* Convert the value from ascii to integer */ |
| 485 | ret = kstrtou8(value, 10, &filterType); |
| 486 | if (ret < 0) |
| 487 | { |
| 488 | /* If the input value is greater than max value of datatype, |
| 489 | * then also kstrtou8 fails |
| 490 | */ |
| 491 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 492 | "%s: kstrtou8 failed range ", __func__); |
| 493 | ret = -EINVAL; |
| 494 | goto exit; |
| 495 | } |
| 496 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 497 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 498 | { |
| 499 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 500 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 501 | " 2-Sink ", __func__); |
| 502 | ret = -EINVAL; |
| 503 | goto exit; |
| 504 | } |
| 505 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 506 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 507 | pScanInfo = &pHddCtx->scan_info; |
| 508 | if (filterType && pScanInfo != NULL && |
| 509 | pHddCtx->scan_info.mScanPending) |
| 510 | { |
| 511 | /*Miracast Session started. Abort Scan */ |
| 512 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 513 | "%s, Aborting Scan For Miracast",__func__); |
| 514 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 515 | eCSR_SCAN_ABORT_DEFAULT); |
| 516 | } |
Ganesh Kondabattini | 2d7c7f0 | 2014-09-04 22:21:39 +0530 | [diff] [blame] | 517 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
| 518 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
| 519 | } |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 520 | else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0) |
| 521 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 522 | ret = hdd_drv_cmd_validate(command, 16); |
| 523 | if (ret) |
| 524 | goto exit; |
| 525 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 526 | ret = hdd_enable_disable_ca_event(pHddCtx, command, 16); |
| 527 | } |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 528 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 529 | /* |
| 530 | * command should be a string having format |
| 531 | * SET_DISABLE_CHANNEL_LIST <num of channels> |
| 532 | * <channels separated by spaces> |
| 533 | */ |
| 534 | else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) { |
| 535 | tANI_U8 *ptr = command; |
| 536 | |
| 537 | ret = hdd_drv_cmd_validate(command, 24); |
| 538 | if (ret) |
| 539 | goto exit; |
| 540 | |
| 541 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 542 | " Received Command to disable Channels for in %s", |
| 543 | __func__); |
| 544 | ret = hdd_parse_disable_chan_cmd(pAdapter, ptr); |
| 545 | } |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 546 | else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) { |
| 547 | char extra[128] = {0}; |
| 548 | int len; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 549 | |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 550 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 551 | " Received Command to get disable Channels list %s", |
| 552 | __func__); |
| 553 | |
| 554 | len = hdd_get_disable_ch_list(pHddCtx, extra, sizeof(extra)); |
| 555 | if (len == 0) { |
| 556 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 557 | FL("disable channel list are not yet programed")); |
| 558 | ret = -EINVAL; |
| 559 | goto exit; |
| 560 | } |
| 561 | |
| 562 | len = VOS_MIN(priv_data->total_len, len + 1); |
| 563 | if (copy_to_user(priv_data->buf, &extra, len)) { |
| 564 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 565 | "%s: failed to copy data to user buffer", __func__); |
| 566 | ret = -EFAULT; |
| 567 | goto exit; |
| 568 | } |
| 569 | |
| 570 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 571 | FL("data:%s"), extra); |
| 572 | } |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 573 | else { |
| 574 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 575 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 576 | pAdapter->sessionId, 0)); |
| 577 | hddLog(VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 578 | command); |
| 579 | } |
| 580 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 581 | exit: |
| 582 | if (command) |
| 583 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 584 | kfree(command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 585 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 586 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 587 | return ret; |
| 588 | } |
| 589 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 590 | #ifdef CONFIG_COMPAT |
| 591 | static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter, |
| 592 | struct ifreq *ifr) |
| 593 | { |
| 594 | struct { |
| 595 | compat_uptr_t buf; |
| 596 | int used_len; |
| 597 | int total_len; |
| 598 | } compat_priv_data; |
| 599 | hdd_priv_data_t priv_data; |
| 600 | int ret = 0; |
| 601 | |
| 602 | /* |
| 603 | * Note that pAdapter and ifr have already been verified by caller, |
| 604 | * and HDD context has also been validated |
| 605 | */ |
| 606 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 607 | sizeof(compat_priv_data))) { |
| 608 | ret = -EFAULT; |
| 609 | goto exit; |
| 610 | } |
| 611 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 612 | priv_data.used_len = compat_priv_data.used_len; |
| 613 | priv_data.total_len = compat_priv_data.total_len; |
| 614 | ret = hdd_hostapd_driver_command(pAdapter, &priv_data); |
| 615 | exit: |
| 616 | return ret; |
| 617 | } |
| 618 | #else /* CONFIG_COMPAT */ |
| 619 | static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter, |
| 620 | struct ifreq *ifr) |
| 621 | { |
| 622 | /* will never be invoked */ |
| 623 | return 0; |
| 624 | } |
| 625 | #endif /* CONFIG_COMPAT */ |
| 626 | |
| 627 | static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 628 | { |
| 629 | hdd_priv_data_t priv_data; |
| 630 | int ret = 0; |
| 631 | |
| 632 | /* |
| 633 | * Note that pAdapter and ifr have already been verified by caller, |
| 634 | * and HDD context has also been validated |
| 635 | */ |
| 636 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 637 | ret = -EFAULT; |
| 638 | } else { |
| 639 | ret = hdd_hostapd_driver_command(pAdapter, &priv_data); |
| 640 | } |
| 641 | return ret; |
| 642 | } |
| 643 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 644 | static int __hdd_hostapd_ioctl(struct net_device *dev, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 645 | struct ifreq *ifr, int cmd) |
| 646 | { |
| 647 | hdd_adapter_t *pAdapter; |
| 648 | hdd_context_t *pHddCtx; |
| 649 | int ret; |
| 650 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 651 | ENTER(); |
| 652 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 653 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 654 | if (NULL == pAdapter) { |
| 655 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 656 | "%s: HDD adapter context is Null", __func__); |
| 657 | ret = -ENODEV; |
| 658 | goto exit; |
| 659 | } |
| 660 | if (dev != pAdapter->dev) { |
| 661 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 662 | "%s: HDD adapter/dev inconsistency", __func__); |
| 663 | ret = -ENODEV; |
| 664 | goto exit; |
| 665 | } |
| 666 | |
| 667 | if ((!ifr) || (!ifr->ifr_data)) { |
| 668 | ret = -EINVAL; |
| 669 | goto exit; |
| 670 | } |
| 671 | |
| 672 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 673 | ret = wlan_hdd_validate_context(pHddCtx); |
| 674 | if (ret) { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 675 | ret = -EBUSY; |
| 676 | goto exit; |
| 677 | } |
| 678 | |
| 679 | switch (cmd) { |
| 680 | case (SIOCDEVPRIVATE + 1): |
| 681 | if (is_compat_task()) |
| 682 | ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr); |
| 683 | else |
| 684 | ret = hdd_hostapd_driver_ioctl(pAdapter, ifr); |
| 685 | break; |
| 686 | default: |
| 687 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 688 | __func__, cmd); |
| 689 | ret = -EINVAL; |
| 690 | break; |
| 691 | } |
| 692 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 693 | EXIT(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 694 | return ret; |
| 695 | } |
| 696 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 697 | static int hdd_hostapd_ioctl(struct net_device *dev, |
| 698 | struct ifreq *ifr, int cmd) |
| 699 | { |
| 700 | int ret; |
| 701 | |
| 702 | vos_ssr_protect(__func__); |
| 703 | ret = __hdd_hostapd_ioctl(dev, ifr, cmd); |
| 704 | vos_ssr_unprotect(__func__); |
| 705 | |
| 706 | return ret; |
| 707 | } |
| 708 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 709 | /**--------------------------------------------------------------------------- |
| 710 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 711 | \brief __hdd_hostapd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 712 | This function sets the user specified mac address using |
| 713 | the command ifconfig wlanX hw ether <mac adress>. |
| 714 | |
| 715 | \param - dev - Pointer to the net device. |
| 716 | - addr - Pointer to the sockaddr. |
| 717 | \return - 0 for success, non zero for failure |
| 718 | |
| 719 | --------------------------------------------------------------------------*/ |
| 720 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 721 | static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 722 | { |
| 723 | struct sockaddr *psta_mac_addr = addr; |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 724 | hdd_adapter_t *pAdapter, *adapter_temp; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 725 | hdd_context_t *pHddCtx; |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 726 | int ret = 0, i; |
| 727 | v_MACADDR_t mac_addr; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 728 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 729 | ENTER(); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 730 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 731 | if (NULL == pAdapter) |
| 732 | { |
| 733 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 734 | "%s: Adapter is NULL",__func__); |
| 735 | return -EINVAL; |
| 736 | } |
| 737 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 738 | ret = wlan_hdd_validate_context(pHddCtx); |
| 739 | if (0 != ret) |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 740 | return ret; |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 741 | |
| 742 | |
| 743 | memcpy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 744 | if(vos_is_macaddr_zero(&mac_addr)) { |
| 745 | hddLog(VOS_TRACE_LEVEL_ERROR, "Zero Mac address"); |
| 746 | return -EINVAL; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 747 | } |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 748 | |
| 749 | if (vos_is_macaddr_broadcast(&mac_addr)) { |
| 750 | hddLog(VOS_TRACE_LEVEL_ERROR,"MAC is Broadcast"); |
| 751 | return -EINVAL; |
| 752 | } |
| 753 | |
| 754 | if (vos_is_macaddr_multicast(&mac_addr)) { |
| 755 | hddLog(VOS_TRACE_LEVEL_ERROR, "Multicast Mac address"); |
| 756 | return -EINVAL; |
| 757 | } |
| 758 | |
| 759 | |
| 760 | adapter_temp = hdd_get_adapter_by_macaddr(pHddCtx, mac_addr.bytes); |
| 761 | if (adapter_temp) { |
| 762 | if (!strcmp(adapter_temp->dev->name, dev->name)) |
| 763 | return 0; |
| 764 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 765 | "%s: WLAN Mac Addr: " |
| 766 | MAC_ADDRESS_STR, __func__, |
| 767 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 768 | return -EINVAL; |
| 769 | } |
| 770 | |
| 771 | for (i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) { |
| 772 | if (!vos_mem_compare(&pAdapter->macAddressCurrent.bytes, |
| 773 | &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], VOS_MAC_ADDR_SIZE)) { |
| 774 | memcpy(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], mac_addr.bytes, |
| 775 | VOS_MAC_ADDR_SIZE); |
| 776 | break; |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 781 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 782 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 783 | EXIT(); |
| 784 | return 0; |
| 785 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 786 | |
| 787 | static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) |
| 788 | { |
| 789 | int ret; |
| 790 | |
| 791 | vos_ssr_protect(__func__); |
| 792 | ret = __hdd_hostapd_set_mac_address(dev, addr); |
| 793 | vos_ssr_unprotect(__func__); |
| 794 | |
| 795 | return ret; |
| 796 | } |
| 797 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 798 | void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback) |
| 799 | { |
| 800 | struct net_device *dev = (struct net_device *)usrDataForCallback; |
| 801 | v_BYTE_t we_custom_event[64]; |
| 802 | union iwreq_data wrqu; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 803 | hdd_adapter_t *pHostapdAdapter; |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 804 | hdd_context_t *pHddCtx; |
| 805 | #ifdef DISABLE_CONCURRENCY_AUTOSAVE |
| 806 | VOS_STATUS vos_status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 807 | hdd_ap_ctx_t *pHddApCtx; |
| 808 | #endif /*DISABLE_CONCURRENCY_AUTOSAVE */ |
| 809 | |
| 810 | /* event_name space-delimiter driver_module_name */ |
| 811 | /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */ |
| 812 | char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME; |
| 813 | int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */ |
| 814 | |
| 815 | ENTER(); |
| 816 | |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 817 | pHostapdAdapter = netdev_priv(dev); |
| 818 | if ((NULL == pHostapdAdapter) || |
| 819 | (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)) |
| 820 | { |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 821 | hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter); |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 822 | return; |
| 823 | } |
| 824 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 825 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 826 | { |
| 827 | return; |
| 828 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 829 | #ifdef DISABLE_CONCURRENCY_AUTOSAVE |
| 830 | if (vos_concurrent_open_sessions_running()) |
Mahesh A Saptasagar | 4534e2b | 2015-03-05 20:45:41 +0530 | [diff] [blame] | 831 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 832 | /* |
| 833 | This timer routine is going to be called only when AP |
| 834 | persona is up. |
| 835 | If there are concurrent sessions running we do not want |
| 836 | to shut down the Bss.Instead we run the timer again so |
| 837 | that if Autosave is enabled next time and other session |
| 838 | was down only then we bring down AP |
| 839 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 840 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 841 | vos_status = vos_timer_start( |
| 842 | &pHddApCtx->hdd_ap_inactivity_timer, |
| 843 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff |
| 844 | * 1000); |
| 845 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 846 | { |
| 847 | hddLog(LOGE, FL("Failed to init AP inactivity timer")); |
| 848 | } |
| 849 | EXIT(); |
| 850 | return; |
| 851 | } |
| 852 | #endif /*DISABLE_CONCURRENCY_AUTOSAVE */ |
| 853 | memset(&we_custom_event, '\0', sizeof(we_custom_event)); |
| 854 | memcpy(&we_custom_event, autoShutEvent, event_len); |
| 855 | |
| 856 | memset(&wrqu, 0, sizeof(wrqu)); |
| 857 | wrqu.data.length = event_len; |
| 858 | |
| 859 | hddLog(LOG1, FL("Shutting down AP interface due to inactivity")); |
| 860 | wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event); |
| 861 | |
| 862 | EXIT(); |
| 863 | } |
| 864 | |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 865 | VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter) |
| 866 | { |
| 867 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 868 | ptSapContext pSapCtx = NULL; |
| 869 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
| 870 | v_PVOID_t hHal = NULL; |
| 871 | |
| 872 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, |
| 873 | "%s: UPDATE Beacon Params", __func__); |
| 874 | |
| 875 | if(VOS_STA_SAP_MODE == vos_get_conparam ( )){ |
| 876 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 877 | if ( NULL == pSapCtx ) |
| 878 | { |
| 879 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 880 | "%s: Invalid SAP pointer from pvosGCtx", __func__); |
| 881 | return VOS_STATUS_E_FAULT; |
| 882 | } |
| 883 | |
| 884 | hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx); |
| 885 | if ( NULL == hHal ){ |
| 886 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 887 | "%s: Invalid HAL pointer from pvosGCtx", __func__); |
| 888 | return VOS_STATUS_E_FAULT; |
| 889 | } |
| 890 | halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId); |
| 891 | if(halStatus == eHAL_STATUS_FAILURE ){ |
| 892 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 893 | "%s: Failed to update Beacon Params", __func__); |
| 894 | return VOS_STATUS_E_FAILURE; |
| 895 | } |
| 896 | } |
| 897 | return VOS_STATUS_SUCCESS; |
| 898 | } |
| 899 | |
| 900 | void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback) |
| 901 | { |
| 902 | v_U8_t staId = 0; |
| 903 | struct net_device *dev; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 904 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 905 | ptSapContext pSapCtx = NULL; |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 906 | |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 907 | dev = (struct net_device *)usrDataForCallback; |
| 908 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 909 | if(pSapCtx == NULL){ |
| 910 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 911 | FL("psapCtx is NULL")); |
| 912 | return; |
| 913 | } |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 914 | hddLog(LOGE, FL("Clearing all the STA entry....")); |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 915 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 916 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 917 | if ( pSapCtx->aStaInfo[staId].isUsed && |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 918 | ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)) |
| 919 | { |
| 920 | //Disconnect all the stations |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 921 | hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]); |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 922 | } |
| 923 | } |
| 924 | } |
| 925 | |
Agarwal Ashish | 8e53893 | 2014-12-24 18:12:52 +0530 | [diff] [blame] | 926 | static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback) |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 927 | { |
| 928 | struct net_device *dev; |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 929 | hdd_context_t *pHddCtx = NULL; |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 930 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 931 | dev = (struct net_device *)usrDataForCallback; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 932 | |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 933 | ENTER(); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 934 | |
| 935 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 936 | status = wlan_hdd_validate_context(pHddCtx); |
| 937 | |
| 938 | if (0 != status) { |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 939 | return status; |
| 940 | } |
| 941 | |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 942 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
| 943 | { |
| 944 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) ) |
| 945 | { |
Agarwal Ashish | 8e53893 | 2014-12-24 18:12:52 +0530 | [diff] [blame] | 946 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!")); |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 947 | } |
| 948 | clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 949 | wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode); |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 950 | } |
| 951 | EXIT(); |
| 952 | return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 953 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 954 | |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 955 | #ifdef SAP_AUTH_OFFLOAD |
Agrawal Ashish | 6773c90 | 2017-01-06 19:45:03 +0530 | [diff] [blame] | 956 | bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter, |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 957 | bool enabled) |
| 958 | { |
| 959 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 960 | struct tSirSapOffloadInfo sap_offload_info; |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 961 | |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 962 | vos_mem_copy( &sap_offload_info.macAddr, |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 963 | pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE); |
| 964 | |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 965 | sap_offload_info.sap_auth_offload_enable = enabled; |
| 966 | sap_offload_info.sap_auth_offload_sec_type = |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 967 | pHddCtx->cfg_ini->sap_auth_offload_sec_type; |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 968 | sap_offload_info.key_len = |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 969 | strlen(pHddCtx->cfg_ini->sap_auth_offload_key); |
| 970 | |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 971 | if (sap_offload_info.sap_auth_offload_enable && |
| 972 | sap_offload_info.sap_auth_offload_sec_type) |
| 973 | { |
| 974 | if (sap_offload_info.key_len < 8 || |
| 975 | sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH) |
| 976 | { |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 977 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 978 | "%s: invalid key length(%d) of WPA security!", __func__, |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 979 | sap_offload_info.key_len); |
Agrawal Ashish | 6773c90 | 2017-01-06 19:45:03 +0530 | [diff] [blame] | 980 | return false; |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 981 | } |
| 982 | } |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 983 | if (sap_offload_info.key_len) |
| 984 | { |
| 985 | vos_mem_copy(sap_offload_info.key, |
| 986 | pHddCtx->cfg_ini->sap_auth_offload_key, |
| 987 | sap_offload_info.key_len); |
| 988 | } |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 989 | if (eHAL_STATUS_SUCCESS != |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 990 | sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info)) |
| 991 | { |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 992 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 993 | "%s: sme_set_sap_auth_offload fail!", __func__); |
Agrawal Ashish | 6773c90 | 2017-01-06 19:45:03 +0530 | [diff] [blame] | 994 | return false; |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 998 | "%s: sme_set_sap_auth_offload successfully!", __func__); |
Agrawal Ashish | 6773c90 | 2017-01-06 19:45:03 +0530 | [diff] [blame] | 999 | return true; |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 1000 | } |
| 1001 | #endif |
| 1002 | |
Abhishek Singh | e8ebb92 | 2017-11-01 13:30:26 +0530 | [diff] [blame] | 1003 | /** |
| 1004 | * wlansap_get_phymode() - get SAP phymode. |
| 1005 | * @pctx: Pointer to the global vos context; a handle to SAP's control block |
| 1006 | * can be extracted from its context. When MBSSID feature is enabled, |
| 1007 | * SAP context is directly passed to SAP APIs. |
| 1008 | * |
| 1009 | * This function provides current phymode of SAP interface. |
| 1010 | * |
| 1011 | * Return: phymode with eCsrPhyMode type. |
| 1012 | */ |
| 1013 | static eCsrPhyMode |
| 1014 | wlansap_get_phymode(v_PVOID_t pctx) |
| 1015 | { |
| 1016 | ptSapContext psapctx = VOS_GET_SAP_CB(pctx); |
| 1017 | |
| 1018 | if (!psapctx) { |
| 1019 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 1020 | "%s: Invalid SAP pointer from pCtx", __func__); |
| 1021 | return eCSR_DOT11_MODE_AUTO; |
| 1022 | } |
| 1023 | return psapctx->csrRoamProfile.phyMode; |
| 1024 | } |
| 1025 | |
| 1026 | /** |
| 1027 | * hdd_update_chandef() - Function to update channel width and center freq |
| 1028 | * @chandef: cfg80211 chan def |
| 1029 | * @cb_mode: chan offset |
| 1030 | * |
| 1031 | * This function will be called to update channel width and center freq |
| 1032 | * |
| 1033 | * Return: None |
| 1034 | */ |
| 1035 | static void |
| 1036 | hdd_update_chandef(struct cfg80211_chan_def *chandef, |
| 1037 | ePhyChanBondState cb_mode) |
| 1038 | { |
| 1039 | uint8_t center_chan, chan; |
| 1040 | |
| 1041 | if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) |
| 1042 | return; |
| 1043 | |
| 1044 | chan = vos_freq_to_chan(chandef->chan->center_freq); |
| 1045 | chandef->width = NL80211_CHAN_WIDTH_80; |
| 1046 | switch (cb_mode) { |
| 1047 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED: |
| 1048 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW: |
| 1049 | center_chan = chan + 2; |
| 1050 | break; |
| 1051 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW: |
| 1052 | center_chan = chan + 6; |
| 1053 | break; |
| 1054 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH: |
| 1055 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED: |
| 1056 | center_chan = chan - 2; |
| 1057 | break; |
| 1058 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH: |
| 1059 | center_chan = chan - 6; |
| 1060 | break; |
| 1061 | default: |
| 1062 | center_chan = chan; |
| 1063 | break; |
| 1064 | } |
| 1065 | |
| 1066 | chandef->center_freq1 = vos_chan_to_freq(center_chan); |
| 1067 | } |
| 1068 | |
| 1069 | /** |
| 1070 | * hdd_chan_change_notify() - Function to notify hostapd about channel change |
| 1071 | * @hostapd_adapter: hostapd adapter |
| 1072 | * @dev: Net device structure |
| 1073 | * @oper_chan: New operating channel |
| 1074 | * |
| 1075 | * This function is used to notify hostapd about the channel change |
| 1076 | * |
| 1077 | * Return: Success on intimating userspace |
| 1078 | * |
| 1079 | */ |
| 1080 | static VOS_STATUS hdd_chan_change_notify(hdd_adapter_t *hostapd_adapter, |
| 1081 | struct net_device *dev, uint8_t oper_chan) |
| 1082 | { |
| 1083 | struct ieee80211_channel *chan; |
| 1084 | struct cfg80211_chan_def chandef; |
| 1085 | enum nl80211_channel_type channel_type; |
| 1086 | eCsrPhyMode phy_mode; |
| 1087 | ePhyChanBondState cb_mode; |
| 1088 | uint32_t freq; |
| 1089 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(hostapd_adapter); |
| 1090 | tSmeConfigParams sme_config; |
| 1091 | |
| 1092 | if (!hal) { |
| 1093 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1094 | "%s: hal is NULL", __func__); |
| 1095 | return VOS_STATUS_E_FAILURE; |
| 1096 | } |
| 1097 | |
| 1098 | freq = vos_chan_to_freq(oper_chan); |
| 1099 | |
| 1100 | chan = __ieee80211_get_channel(hostapd_adapter->wdev.wiphy, freq); |
| 1101 | |
| 1102 | if (!chan) { |
| 1103 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1104 | "%s: Invalid input frequency for channel conversion", __func__); |
| 1105 | return VOS_STATUS_E_FAILURE; |
| 1106 | } |
| 1107 | |
| 1108 | phy_mode = wlansap_get_phymode( |
| 1109 | (WLAN_HDD_GET_CTX(hostapd_adapter))->pvosContext); |
| 1110 | sme_GetConfigParam(hal, &sme_config); |
| 1111 | if (oper_chan <= 14) |
| 1112 | cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode( |
| 1113 | sme_config.csrConfig.channelBondingMode24GHz); |
| 1114 | else |
| 1115 | cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode( |
| 1116 | sme_config.csrConfig.channelBondingMode5GHz); |
| 1117 | |
| 1118 | switch (phy_mode) { |
| 1119 | case eCSR_DOT11_MODE_11n: |
| 1120 | case eCSR_DOT11_MODE_11n_ONLY: |
| 1121 | case eCSR_DOT11_MODE_11ac: |
| 1122 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 1123 | switch (cb_mode) { |
| 1124 | case PHY_SINGLE_CHANNEL_CENTERED: |
| 1125 | channel_type = NL80211_CHAN_HT20; |
| 1126 | break; |
| 1127 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW: |
| 1128 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED: |
| 1129 | case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH: |
| 1130 | case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY: |
| 1131 | channel_type = NL80211_CHAN_HT40MINUS; |
| 1132 | break; |
| 1133 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW: |
| 1134 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED: |
| 1135 | case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH: |
| 1136 | case PHY_DOUBLE_CHANNEL_LOW_PRIMARY: |
| 1137 | channel_type = NL80211_CHAN_HT40PLUS; |
| 1138 | break; |
| 1139 | default: |
| 1140 | channel_type = NL80211_CHAN_HT20; |
| 1141 | break; |
| 1142 | } |
| 1143 | break; |
| 1144 | default: |
| 1145 | channel_type = NL80211_CHAN_NO_HT; |
| 1146 | break; |
| 1147 | } |
| 1148 | |
| 1149 | cfg80211_chandef_create(&chandef, chan, channel_type); |
| 1150 | if ((phy_mode == eCSR_DOT11_MODE_11ac) || |
| 1151 | (phy_mode == eCSR_DOT11_MODE_11ac_ONLY)) |
| 1152 | hdd_update_chandef(&chandef, cb_mode); |
| 1153 | |
| 1154 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1155 | "%s: phy_mode %d cb_mode %d chann_type %d oper_chan %d width %d freq_1 %d", |
| 1156 | __func__, phy_mode, cb_mode, channel_type, oper_chan, |
| 1157 | chandef.width, chandef.center_freq1); |
| 1158 | |
| 1159 | |
| 1160 | cfg80211_ch_switch_notify(dev, &chandef); |
| 1161 | |
| 1162 | return VOS_STATUS_SUCCESS; |
| 1163 | } |
| 1164 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 1165 | /** |
| 1166 | * hdd_convert_dot11mode_from_phymode() - get dot11mode to phymode |
| 1167 | * @phymode: phy mode |
| 1168 | * |
| 1169 | * This function is used to get dot11mode to phymode |
| 1170 | * |
| 1171 | * Return: dot11mode |
| 1172 | */ |
| 1173 | static int hdd_convert_dot11mode_from_phymode(int phymode) |
| 1174 | { |
| 1175 | switch (phymode) { |
Abhishek Singh | e8ebb92 | 2017-11-01 13:30:26 +0530 | [diff] [blame] | 1176 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 1177 | case VOS_MODE_11A: |
| 1178 | return QCA_WLAN_802_11_MODE_11A; |
| 1179 | |
| 1180 | case VOS_MODE_11B: |
| 1181 | return QCA_WLAN_802_11_MODE_11B; |
| 1182 | |
| 1183 | case VOS_MODE_11G: |
| 1184 | case VOS_MODE_11GONLY: |
| 1185 | return QCA_WLAN_802_11_MODE_11G; |
| 1186 | |
| 1187 | case VOS_MODE_11NA_HT20: |
| 1188 | case VOS_MODE_11NG_HT20: |
| 1189 | case VOS_MODE_11NA_HT40: |
| 1190 | case VOS_MODE_11NG_HT40: |
| 1191 | return QCA_WLAN_802_11_MODE_11N; |
| 1192 | |
| 1193 | case VOS_MODE_11AC_VHT20: |
| 1194 | case VOS_MODE_11AC_VHT40: |
| 1195 | case VOS_MODE_11AC_VHT80: |
| 1196 | case VOS_MODE_11AC_VHT20_2G: |
| 1197 | case VOS_MODE_11AC_VHT40_2G: |
| 1198 | case VOS_MODE_11AC_VHT80_2G: |
| 1199 | #ifdef CONFIG_160MHZ_SUPPORT |
| 1200 | case VOS_MODE_11AC_VHT80_80: |
| 1201 | case VOS_MODE_11AC_VHT160: |
| 1202 | #endif |
| 1203 | return QCA_WLAN_802_11_MODE_11AC; |
| 1204 | |
| 1205 | default: |
| 1206 | return QCA_WLAN_802_11_MODE_INVALID; |
| 1207 | } |
| 1208 | |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * hdd_fill_station_info() - fill station information |
| 1213 | * @sap_ctx: sap context |
| 1214 | * @event: assoc event |
| 1215 | * This function updates sta information from assoc event |
| 1216 | * |
| 1217 | * Return: none |
| 1218 | */ |
| 1219 | static void hdd_fill_station_info(ptSapContext sap_ctx, |
| 1220 | tSap_StationAssocReassocCompleteEvent *event) |
| 1221 | { |
| 1222 | struct hdd_cache_sta_info *sta_info = sap_ctx->cache_sta_info; |
| 1223 | int i=0; |
| 1224 | |
| 1225 | /* check if there is any dup entry */ |
| 1226 | while (i < WLAN_MAX_STA_COUNT) { |
| 1227 | if (vos_mem_compare(sta_info[i].macAddrSTA.bytes, |
| 1228 | event->staMac.bytes, |
| 1229 | VOS_MAC_ADDR_SIZE)) { |
| 1230 | vos_mem_zero(&sta_info[i], sizeof(*sta_info)); |
| 1231 | break; |
| 1232 | } |
| 1233 | i++; |
| 1234 | } |
| 1235 | if (i >= WLAN_MAX_STA_COUNT) { |
| 1236 | i = 0; |
| 1237 | while (i < WLAN_MAX_STA_COUNT) { |
| 1238 | if (sta_info[i].isUsed != TRUE) |
| 1239 | break; |
| 1240 | i++; |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | if (i < WLAN_MAX_STA_COUNT) { |
| 1245 | sta_info[i].isUsed = TRUE; |
| 1246 | sta_info[i].ucSTAId = event->staId; |
| 1247 | vos_mem_copy(sta_info[i].macAddrSTA.bytes, |
| 1248 | event->staMac.bytes, |
| 1249 | VOS_MAC_ADDR_SIZE); |
| 1250 | sta_info[i].freq = vos_chan_to_freq(event->chan_info.chan_id); |
| 1251 | sta_info[i].ch_width = event->ch_width; |
| 1252 | sta_info[i].nss = 1; |
| 1253 | sta_info[i].dot11_mode = hdd_convert_dot11mode_from_phymode( |
| 1254 | event->chan_info.info); |
| 1255 | if (event->HTCaps.present) { |
| 1256 | sta_info[i].ht_present = TRUE; |
| 1257 | hdd_copy_ht_caps(&sta_info[i].ht_caps, &event->HTCaps); |
| 1258 | } |
| 1259 | if (event->VHTCaps.present) { |
| 1260 | sta_info[i].vht_present = TRUE; |
| 1261 | hdd_copy_vht_caps(&sta_info[i].vht_caps, |
| 1262 | &event->VHTCaps); |
| 1263 | } |
| 1264 | } |
| 1265 | else |
| 1266 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "reached max staid, stainfo can't be cached"); |
| 1267 | } |
Abhishek Singh | e8ebb92 | 2017-11-01 13:30:26 +0530 | [diff] [blame] | 1268 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1269 | VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback) |
| 1270 | { |
| 1271 | hdd_adapter_t *pHostapdAdapter; |
| 1272 | hdd_ap_ctx_t *pHddApCtx; |
| 1273 | hdd_hostapd_state_t *pHostapdState; |
| 1274 | struct net_device *dev; |
| 1275 | eSapHddEvent sapEvent; |
| 1276 | union iwreq_data wrqu; |
| 1277 | v_BYTE_t *we_custom_event_generic = NULL; |
| 1278 | int we_event = 0; |
| 1279 | int i = 0; |
| 1280 | v_U8_t staId; |
| 1281 | VOS_STATUS vos_status; |
| 1282 | v_BOOL_t bWPSState; |
| 1283 | v_BOOL_t bApActive = FALSE; |
| 1284 | v_BOOL_t bAuthRequired = TRUE; |
| 1285 | tpSap_AssocMacAddr pAssocStasArray = NULL; |
| 1286 | char unknownSTAEvent[IW_CUSTOM_MAX+1]; |
| 1287 | char maxAssocExceededEvent[IW_CUSTOM_MAX+1]; |
| 1288 | v_BYTE_t we_custom_start_event[64]; |
| 1289 | char *startBssEvent; |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 1290 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 1291 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 5f12e90 | 2013-04-03 10:21:46 -0700 | [diff] [blame] | 1292 | struct iw_michaelmicfailure msg; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 1293 | v_CONTEXT_t pVosContext = NULL; |
| 1294 | ptSapContext pSapCtx = NULL; |
Deepthi Gowri | ed08509 | 2015-10-20 19:30:52 +0530 | [diff] [blame] | 1295 | hdd_config_t *cfg_param; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1296 | |
| 1297 | dev = (struct net_device *)usrDataForCallback; |
| 1298 | pHostapdAdapter = netdev_priv(dev); |
Madan Mohan Koyyalamudi | e1b791f | 2013-07-24 12:53:33 +0530 | [diff] [blame] | 1299 | |
| 1300 | if ((NULL == pHostapdAdapter) || |
| 1301 | (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)) |
| 1302 | { |
| 1303 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 1304 | "invalid adapter or adapter has invalid magic"); |
| 1305 | return eHAL_STATUS_FAILURE; |
| 1306 | } |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 1307 | pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 1308 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 1309 | if(pSapCtx == NULL){ |
| 1310 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 1311 | FL("psapCtx is NULL")); |
| 1312 | return eHAL_STATUS_FAILURE; |
| 1313 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1314 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1315 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 1316 | sapEvent = pSapEvent->sapHddEventCode; |
| 1317 | memset(&wrqu, '\0', sizeof(wrqu)); |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 1318 | pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx); |
Deepthi Gowri | ed08509 | 2015-10-20 19:30:52 +0530 | [diff] [blame] | 1319 | cfg_param = pHddCtx->cfg_ini; |
| 1320 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1321 | switch(sapEvent) |
| 1322 | { |
| 1323 | case eSAP_START_BSS_EVENT : |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1324 | hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1325 | pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS", |
| 1326 | pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel, |
| 1327 | pSapEvent->sapevt.sapStartBssCompleteEvent.staId); |
| 1328 | |
| 1329 | pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status; |
| 1330 | vos_status = vos_event_set(&pHostapdState->vosEvent); |
Deepthi Gowri | ed08509 | 2015-10-20 19:30:52 +0530 | [diff] [blame] | 1331 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1332 | if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus) |
Deepthi Gowri | ed08509 | 2015-10-20 19:30:52 +0530 | [diff] [blame] | 1333 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1334 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1335 | goto stopbss; |
| 1336 | } |
| 1337 | else |
Deepthi Gowri | ed08509 | 2015-10-20 19:30:52 +0530 | [diff] [blame] | 1338 | { |
| 1339 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 1340 | { |
| 1341 | if ((cfg_param->dynSplitscan) && |
| 1342 | (!pHddCtx->issplitscan_enabled)) |
| 1343 | { |
| 1344 | pHddCtx->issplitscan_enabled = TRUE; |
| 1345 | sme_enable_disable_split_scan( |
| 1346 | WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 1347 | cfg_param->nNumStaChanCombinedConc, |
| 1348 | cfg_param->nNumP2PChanCombinedConc); |
| 1349 | } |
| 1350 | } |
| 1351 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1352 | pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId; |
| 1353 | //@@@ need wep logic here to set privacy bit |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1354 | vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy); |
| 1355 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Agarwal Ashish | 8e53893 | 2014-12-24 18:12:52 +0530 | [diff] [blame] | 1356 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1357 | hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status); |
Agarwal Ashish | 8e53893 | 2014-12-24 18:12:52 +0530 | [diff] [blame] | 1358 | hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback); |
| 1359 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1360 | } |
Deepthi Gowri | ed08509 | 2015-10-20 19:30:52 +0530 | [diff] [blame] | 1361 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1362 | if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff) |
| 1363 | { |
| 1364 | // AP Inactivity timer init and start |
| 1365 | vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW, |
| 1366 | hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev ); |
| 1367 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1368 | hddLog(LOGE, FL("Failed to init AP inactivity timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1369 | |
| 1370 | vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000); |
| 1371 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1372 | hddLog(LOGE, FL("Failed to init AP inactivity timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1373 | |
| 1374 | } |
| 1375 | pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel; |
| 1376 | pHostapdState->bssState = BSS_START; |
| 1377 | |
| 1378 | // Send current operating channel of SoftAP to BTC-ES |
| 1379 | send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0); |
| 1380 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1381 | //Check if there is any group key pending to set. |
| 1382 | if( pHddApCtx->groupKey.keyLength ) |
| 1383 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1384 | if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1385 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, |
| 1386 | &pHddApCtx->groupKey ) ) |
| 1387 | { |
| 1388 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1389 | "%s: WLANSAP_SetKeySta failed", __func__); |
| 1390 | } |
| 1391 | pHddApCtx->groupKey.keyLength = 0; |
| 1392 | } |
| 1393 | else if ( pHddApCtx->wepKey[0].keyLength ) |
| 1394 | { |
| 1395 | int i=0; |
| 1396 | for ( i = 0; i < CSR_MAX_NUM_KEY; i++ ) |
| 1397 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1398 | if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1399 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, |
| 1400 | &pHddApCtx->wepKey[i] ) ) |
| 1401 | { |
| 1402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1403 | "%s: WLANSAP_SetKeySta failed idx %d", __func__, i); |
| 1404 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1405 | } |
| 1406 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled |
| 1408 | startBssEvent = "SOFTAP.enabled"; |
| 1409 | memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event)); |
| 1410 | memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent)); |
| 1411 | memset(&wrqu, 0, sizeof(wrqu)); |
| 1412 | wrqu.data.length = strlen(startBssEvent); |
| 1413 | we_event = IWEVCUSTOM; |
| 1414 | we_custom_event_generic = we_custom_start_event; |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 1415 | hdd_dump_concurrency_info(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1416 | break; //Event will be sent after Switch-Case stmt |
| 1417 | |
| 1418 | case eSAP_STOP_BSS_EVENT: |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1419 | hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1420 | "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS"); |
| 1421 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 1422 | //Free up Channel List incase if it is set |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 1423 | sapCleanupChannelList(); |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 1424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1425 | pHddApCtx->operatingChannel = 0; //Invalidate the channel info. |
Masti, Narayanraddi | fdde4d0 | 2015-04-16 14:41:51 +0530 | [diff] [blame] | 1426 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1427 | goto stopbss; |
| 1428 | case eSAP_STA_SET_KEY_EVENT: |
| 1429 | //TODO: forward the message to hostapd once implementtation is done for now just print |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1430 | hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1431 | "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS"); |
| 1432 | return VOS_STATUS_SUCCESS; |
| 1433 | case eSAP_STA_DEL_KEY_EVENT: |
| 1434 | //TODO: forward the message to hostapd once implementtation is done for now just print |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1435 | hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1436 | return VOS_STATUS_SUCCESS; |
| 1437 | case eSAP_STA_MIC_FAILURE_EVENT: |
| 1438 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1439 | memset(&msg, '\0', sizeof(msg)); |
| 1440 | msg.src_addr.sa_family = ARPHRD_ETHER; |
Kumar Pavan | 0cf0cf2 | 2012-12-13 15:13:41 -0800 | [diff] [blame] | 1441 | memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1442 | hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data)); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1443 | if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1444 | msg.flags = IW_MICFAILURE_GROUP; |
| 1445 | else |
| 1446 | msg.flags = IW_MICFAILURE_PAIRWISE; |
| 1447 | memset(&wrqu, 0, sizeof(wrqu)); |
| 1448 | wrqu.data.length = sizeof(msg); |
| 1449 | we_event = IWEVMICHAELMICFAILURE; |
| 1450 | we_custom_event_generic = (v_BYTE_t *)&msg; |
| 1451 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1452 | /* inform mic failure to nl80211 */ |
| 1453 | cfg80211_michael_mic_failure(dev, |
| 1454 | pSapEvent->sapevt. |
| 1455 | sapStationMICFailureEvent.staMac.bytes, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 1456 | ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1457 | NL80211_KEYTYPE_GROUP : |
| 1458 | NL80211_KEYTYPE_PAIRWISE), |
| 1459 | pSapEvent->sapevt.sapStationMICFailureEvent.keyId, |
| 1460 | pSapEvent->sapevt.sapStationMICFailureEvent.TSC, |
| 1461 | GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1462 | break; |
| 1463 | |
| 1464 | case eSAP_STA_ASSOC_EVENT: |
| 1465 | case eSAP_STA_REASSOC_EVENT: |
| 1466 | wrqu.addr.sa_family = ARPHRD_ETHER; |
| 1467 | memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac, |
Kumar Pavan | 0cf0cf2 | 2012-12-13 15:13:41 -0800 | [diff] [blame] | 1468 | sizeof(v_MACADDR_t)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1469 | hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1470 | we_event = IWEVREGISTERED; |
| 1471 | |
| 1472 | WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState); |
| 1473 | |
| 1474 | if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) || |
| 1475 | ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) || |
| 1476 | ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) ) |
| 1477 | { |
| 1478 | bAuthRequired = FALSE; |
| 1479 | } |
Abhishek Singh | 2c67928 | 2017-01-12 17:33:40 +0530 | [diff] [blame] | 1480 | /* fAuthRequiredshould should be false for sap offload */ |
| 1481 | if ((bAuthRequired || bWPSState) |
| 1482 | #ifdef SAP_AUTH_OFFLOAD |
| 1483 | && !cfg_param->enable_sap_auth_offload |
| 1484 | #endif |
| 1485 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1486 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1487 | vos_status = hdd_softap_RegisterSTA( pHostapdAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1488 | TRUE, |
| 1489 | pHddApCtx->uPrivacy, |
| 1490 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId, |
| 1491 | 0, |
| 1492 | 0, |
| 1493 | (v_MACADDR_t *)wrqu.addr.sa_data, |
| 1494 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1495 | |
| 1496 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1497 | hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""), |
| 1498 | vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1499 | } |
| 1500 | else |
| 1501 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1502 | vos_status = hdd_softap_RegisterSTA( pHostapdAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1503 | FALSE, |
| 1504 | pHddApCtx->uPrivacy, |
| 1505 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId, |
| 1506 | 0, |
| 1507 | 0, |
| 1508 | (v_MACADDR_t *)wrqu.addr.sa_data, |
| 1509 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1510 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1511 | hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""), |
| 1512 | vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data)); |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 1513 | } |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 1514 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1515 | hdd_fill_station_info(pSapCtx, |
| 1516 | &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent); |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 1517 | |
Deepthi Gowri | ae6a166 | 2015-10-12 12:59:37 +0530 | [diff] [blame] | 1518 | staId = |
| 1519 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId; |
| 1520 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1521 | { |
| 1522 | |
| 1523 | pSapCtx->aStaInfo[staId].rate_flags = |
| 1524 | pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags; |
| 1525 | } |
| 1526 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1527 | // Stop AP inactivity timer |
| 1528 | if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING) |
| 1529 | { |
| 1530 | vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer); |
| 1531 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1532 | hddLog(LOGE, FL("Failed to start AP inactivity timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1533 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 1534 | #ifdef WLAN_OPEN_SOURCE |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 1535 | if (vos_wake_lock_active(&pHddCtx->sap_wake_lock)) |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 1536 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 1537 | vos_wake_lock_release(&pHddCtx->sap_wake_lock, |
| 1538 | WIFI_POWER_EVENT_WAKELOCK_SAP); |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 1539 | } |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 1540 | vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock, |
| 1541 | HDD_SAP_WAKE_LOCK_DURATION, |
| 1542 | WIFI_POWER_EVENT_WAKELOCK_SAP); |
| 1543 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 1544 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1545 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 1546 | { |
SaidiReddy Yenuga | be255a6 | 2016-12-07 16:21:07 +0530 | [diff] [blame] | 1547 | struct station_info *staInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1548 | v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen; |
| 1549 | |
SaidiReddy Yenuga | be255a6 | 2016-12-07 16:21:07 +0530 | [diff] [blame] | 1550 | staInfo = vos_mem_malloc(sizeof(*staInfo)); |
| 1551 | if (staInfo == NULL) { |
| 1552 | hddLog(LOGE, FL("alloc station_info failed")); |
| 1553 | return VOS_STATUS_E_NOMEM; |
| 1554 | } |
| 1555 | |
| 1556 | memset(staInfo, 0, sizeof(*staInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1557 | if (iesLen <= MAX_ASSOC_IND_IE_LEN ) |
| 1558 | { |
SaidiReddy Yenuga | be255a6 | 2016-12-07 16:21:07 +0530 | [diff] [blame] | 1559 | staInfo->assoc_req_ies = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1560 | (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0]; |
SaidiReddy Yenuga | be255a6 | 2016-12-07 16:21:07 +0530 | [diff] [blame] | 1561 | staInfo->assoc_req_ies_len = iesLen; |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 1562 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) && \ |
| 1563 | ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \ |
| 1564 | !defined(WITH_BACKPORTS)) |
SaidiReddy Yenuga | be255a6 | 2016-12-07 16:21:07 +0530 | [diff] [blame] | 1565 | staInfo->filled |= STATION_INFO_ASSOC_REQ_IES; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1566 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1567 | cfg80211_new_sta(dev, |
| 1568 | (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0], |
SaidiReddy Yenuga | be255a6 | 2016-12-07 16:21:07 +0530 | [diff] [blame] | 1569 | staInfo, GFP_KERNEL); |
| 1570 | vos_mem_free(staInfo); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1571 | } |
| 1572 | else |
| 1573 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1574 | hddLog(LOGE, FL(" Assoc Ie length is too long")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1575 | } |
| 1576 | } |
| 1577 | #endif |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 1578 | hdd_manage_delack_timer(pHddCtx); |
| 1579 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 1580 | pScanInfo = &pHddCtx->scan_info; |
| 1581 | // Lets do abort scan to ensure smooth authentication for client |
| 1582 | if ((pScanInfo != NULL) && pScanInfo->mScanPending) |
| 1583 | { |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 1584 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 1585 | eCSR_SCAN_ABORT_DEFAULT); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 1586 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1587 | |
| 1588 | break; |
| 1589 | case eSAP_STA_DISASSOC_EVENT: |
| 1590 | memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, |
Kumar Pavan | 0cf0cf2 | 2012-12-13 15:13:41 -0800 | [diff] [blame] | 1591 | sizeof(v_MACADDR_t)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1592 | hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data)); |
Abhishek Singh | 1a9dbcf | 2019-09-06 12:50:03 +0530 | [diff] [blame] | 1593 | |
| 1594 | vos_status = vos_event_set(&pHostapdState->sta_discon_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1595 | if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC) |
| 1596 | hddLog(LOG1," User initiated disassociation"); |
| 1597 | else |
| 1598 | hddLog(LOG1," MAC initiated disassociation"); |
| 1599 | we_event = IWEVEXPIRED; |
| 1600 | vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId); |
| 1601 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1602 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1603 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1604 | return VOS_STATUS_E_FAILURE; |
| 1605 | } |
| 1606 | hdd_softap_DeregisterSTA(pHostapdAdapter, staId); |
| 1607 | |
| 1608 | if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff) |
| 1609 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 1610 | spin_lock_bh( &pSapCtx->staInfo_lock ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1611 | // Start AP inactivity timer if no stations associated with it |
| 1612 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 1613 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 1614 | if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1615 | { |
| 1616 | bApActive = TRUE; |
| 1617 | break; |
| 1618 | } |
| 1619 | } |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 1620 | spin_unlock_bh( &pSapCtx->staInfo_lock ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1621 | |
| 1622 | if (bApActive == FALSE) |
| 1623 | { |
| 1624 | if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED) |
| 1625 | { |
| 1626 | vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000); |
| 1627 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1628 | hddLog(LOGE, FL("Failed to init AP inactivity timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1629 | } |
| 1630 | else |
| 1631 | VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED); |
| 1632 | } |
| 1633 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1634 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 1635 | cfg80211_del_sta(dev, |
| 1636 | (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0], |
| 1637 | GFP_KERNEL); |
| 1638 | #endif |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 1639 | //Update the beacon Interval if it is P2P GO |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1640 | vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter); |
| 1641 | if (VOS_STATUS_SUCCESS != vos_status) |
| 1642 | { |
| 1643 | hddLog(LOGE, "%s: failed to update Beacon interval %d", |
| 1644 | __func__, vos_status); |
| 1645 | } |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 1646 | hdd_manage_delack_timer(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1647 | break; |
| 1648 | case eSAP_WPS_PBC_PROBE_REQ_EVENT: |
| 1649 | { |
| 1650 | static const char * message ="MLMEWPSPBCPROBEREQ.indication"; |
| 1651 | union iwreq_data wreq; |
| 1652 | |
| 1653 | down(&pHddApCtx->semWpsPBCOverlapInd); |
| 1654 | pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen; |
| 1655 | |
| 1656 | vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE, |
| 1657 | pHddApCtx->WPSPBCProbeReq.probeReqIELen); |
| 1658 | |
| 1659 | vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1660 | hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1661 | memset(&wreq, 0, sizeof(wreq)); |
| 1662 | wreq.data.length = strlen(message); // This is length of message |
| 1663 | wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message); |
| 1664 | |
| 1665 | return VOS_STATUS_SUCCESS; |
| 1666 | } |
| 1667 | case eSAP_ASSOC_STA_CALLBACK_EVENT: |
| 1668 | pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas; |
| 1669 | if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0) |
| 1670 | { // List of associated stations |
| 1671 | for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++) |
| 1672 | { |
| 1673 | hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR, |
| 1674 | i+1, |
| 1675 | pAssocStasArray->assocId, |
| 1676 | pAssocStasArray->staId, |
| 1677 | MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes)); |
| 1678 | pAssocStasArray++; |
| 1679 | } |
| 1680 | } |
| 1681 | vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1682 | pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1683 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1684 | case eSAP_REMAIN_CHAN_READY: |
| 1685 | hdd_remainChanReadyHandler( pHostapdAdapter ); |
| 1686 | return VOS_STATUS_SUCCESS; |
| 1687 | case eSAP_SEND_ACTION_CNF: |
| 1688 | hdd_sendActionCnf( pHostapdAdapter, |
| 1689 | ( eSAP_STATUS_SUCCESS == |
| 1690 | pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ? |
| 1691 | TRUE : FALSE ); |
| 1692 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1693 | case eSAP_UNKNOWN_STA_JOIN: |
| 1694 | snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x", |
| 1695 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0], |
| 1696 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1], |
| 1697 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2], |
| 1698 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3], |
| 1699 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4], |
| 1700 | pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]); |
| 1701 | we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */ |
| 1702 | wrqu.data.pointer = unknownSTAEvent; |
| 1703 | wrqu.data.length = strlen(unknownSTAEvent); |
| 1704 | we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent; |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 1705 | hddLog(LOGE,"%s", unknownSTAEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1706 | break; |
| 1707 | |
| 1708 | case eSAP_MAX_ASSOC_EXCEEDED: |
| 1709 | snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied" |
| 1710 | " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect" |
| 1711 | " one or more devices to enable the new device connection", |
| 1712 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0], |
| 1713 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1], |
| 1714 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2], |
| 1715 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3], |
| 1716 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4], |
| 1717 | pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]); |
| 1718 | we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */ |
| 1719 | wrqu.data.pointer = maxAssocExceededEvent; |
| 1720 | wrqu.data.length = strlen(maxAssocExceededEvent); |
| 1721 | we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1722 | hddLog(LOG1,"%s", maxAssocExceededEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1723 | break; |
| 1724 | case eSAP_STA_ASSOC_IND: |
| 1725 | return VOS_STATUS_SUCCESS; |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 1726 | |
| 1727 | case eSAP_DISCONNECT_ALL_P2P_CLIENT: |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1728 | hddLog(LOG1, FL(" Disconnecting all the P2P Clients....")); |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 1729 | hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback); |
| 1730 | return VOS_STATUS_SUCCESS; |
| 1731 | |
| 1732 | case eSAP_MAC_TRIG_STOP_BSS_EVENT : |
Agarwal Ashish | 8e53893 | 2014-12-24 18:12:52 +0530 | [diff] [blame] | 1733 | vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1734 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1735 | { |
Agarwal Ashish | 8e53893 | 2014-12-24 18:12:52 +0530 | [diff] [blame] | 1736 | hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status); |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1737 | } |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 1738 | return VOS_STATUS_SUCCESS; |
Abhishek Singh | e8ebb92 | 2017-11-01 13:30:26 +0530 | [diff] [blame] | 1739 | case eSAP_CHANNEL_CHANGED_EVENT: |
| 1740 | hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event")); |
Madan Mohan Koyyalamudi | 167b95e | 2012-11-27 15:53:38 -0800 | [diff] [blame] | 1741 | |
Abhishek Singh | e8ebb92 | 2017-11-01 13:30:26 +0530 | [diff] [blame] | 1742 | return hdd_chan_change_notify(pHostapdAdapter, dev, |
| 1743 | pSapEvent->sapevt.sap_chan_selected.new_chan); |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 1744 | case eSAP_STA_LOSTLINK_DETECTED: |
| 1745 | { |
| 1746 | tSap_StationDisassocCompleteEvent *disassoc_comp = |
| 1747 | &pSapEvent->sapevt.sapStationDisassocCompleteEvent; |
| 1748 | |
| 1749 | struct hdd_cache_sta_info *sta_info = hdd_get_cache_stainfo( |
| 1750 | pSapCtx->cache_sta_info, |
| 1751 | disassoc_comp->staMac.bytes); |
| 1752 | if (!sta_info) { |
| 1753 | hddLog(LOGE, FL("invalid cache sta info")); |
| 1754 | return VOS_STATUS_E_FAILURE; |
| 1755 | } |
| 1756 | |
| 1757 | WLANTL_GetSAPStaRSSi(pVosContext, disassoc_comp->staId, |
| 1758 | &sta_info->rssi); |
| 1759 | sta_info->rx_rate = |
| 1760 | wlan_tl_get_sta_rx_rate(pVosContext, disassoc_comp->staId); |
| 1761 | if (disassoc_comp->reason != eSAP_USR_INITATED_DISASSOC) |
| 1762 | sta_info->reason_code = disassoc_comp->reason; |
| 1763 | return VOS_STATUS_SUCCESS; |
| 1764 | } |
| 1765 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1766 | default: |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1767 | hddLog(LOG1,"SAP message is not handled"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1768 | goto stopbss; |
| 1769 | return VOS_STATUS_SUCCESS; |
| 1770 | } |
| 1771 | wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic); |
| 1772 | return VOS_STATUS_SUCCESS; |
| 1773 | |
| 1774 | stopbss : |
| 1775 | { |
| 1776 | v_BYTE_t we_custom_event[64]; |
| 1777 | char *stopBssEvent = "STOP-BSS.response";//17 |
| 1778 | int event_len = strlen(stopBssEvent); |
| 1779 | |
| 1780 | hddLog(LOG1, FL("BSS stop status = %s"), |
| 1781 | pSapEvent->sapevt.sapStopBssCompleteEvent.status ? |
| 1782 | "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS"); |
| 1783 | |
| 1784 | /* Change the BSS state now since, as we are shutting things down, |
| 1785 | * we don't want interfaces to become re-enabled */ |
| 1786 | pHostapdState->bssState = BSS_STOP; |
| 1787 | |
Gopichand Nakkala | f8fe15d | 2013-05-27 13:55:40 +0530 | [diff] [blame] | 1788 | if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff) |
| 1789 | { |
| 1790 | if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state) |
| 1791 | { |
| 1792 | vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer); |
| 1793 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1794 | hddLog(LOGE, FL("Failed to stop AP inactivity timer")); |
| 1795 | } |
| 1796 | |
| 1797 | vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer); |
| 1798 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1799 | hddLog(LOGE, FL("Failed to Destroy AP inactivity timer")); |
| 1800 | } |
| 1801 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1802 | /* Stop the pkts from n/w stack as we are going to free all of |
| 1803 | * the TX WMM queues for all STAID's */ |
Kapil Gupta | 0afd191 | 2016-12-28 12:52:13 +0530 | [diff] [blame] | 1804 | |
| 1805 | /* |
| 1806 | * If channel avoidance is in progress means driver is performing SAP |
| 1807 | * restart. So don't do carrier off, which may lead framework to do |
| 1808 | * driver reload. |
| 1809 | */ |
| 1810 | hddLog(LOG1, FL("ch avoid in progress: %d"), |
| 1811 | pHddCtx->is_ch_avoid_in_progress); |
| 1812 | if (pHddCtx->is_ch_avoid_in_progress && |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 1813 | pHddCtx->cfg_ini->sap_internal_restart) |
Kapil Gupta | 0afd191 | 2016-12-28 12:52:13 +0530 | [diff] [blame] | 1814 | netif_tx_disable(dev); |
| 1815 | else |
| 1816 | hdd_hostapd_stop(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1817 | |
| 1818 | /* reclaim all resources allocated to the BSS */ |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 1819 | vos_status = hdd_softap_stop_bss(pHostapdAdapter); |
| 1820 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 1821 | hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1822 | |
Amar Singhal | 37e6f05 | 2013-03-05 16:16:54 -0800 | [diff] [blame] | 1823 | /* once the event is set, structure dev/pHostapdAdapter should |
| 1824 | * not be touched since they are now subject to being deleted |
| 1825 | * by another thread */ |
| 1826 | if (eSAP_STOP_BSS_EVENT == sapEvent) |
| 1827 | vos_event_set(&pHostapdState->vosEvent); |
| 1828 | |
Yeshwanth Sriram Guntuka | b973f1c | 2018-03-29 19:35:49 +0530 | [diff] [blame] | 1829 | if (hdd_is_any_session_connected(pHddCtx) == VOS_STATUS_E_FAILURE) { |
| 1830 | hdd_enable_bmps_imps(pHddCtx); |
| 1831 | sme_request_imps(pHddCtx->hHal); |
| 1832 | } |
| 1833 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1834 | /* notify userspace that the BSS has stopped */ |
| 1835 | memset(&we_custom_event, '\0', sizeof(we_custom_event)); |
| 1836 | memcpy(&we_custom_event, stopBssEvent, event_len); |
| 1837 | memset(&wrqu, 0, sizeof(wrqu)); |
| 1838 | wrqu.data.length = event_len; |
| 1839 | we_event = IWEVCUSTOM; |
| 1840 | we_custom_event_generic = we_custom_event; |
| 1841 | wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic); |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 1842 | hdd_dump_concurrency_info(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1843 | } |
Bala Venkatesh | 5c06a25 | 2018-07-12 16:08:04 +0530 | [diff] [blame] | 1844 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO || |
| 1845 | pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 1846 | { |
| 1847 | hddLog(LOG1, |
| 1848 | FL("SAP or Go is getting removed and we are trying to re-enable TDLS")); |
| 1849 | wlan_hdd_tdls_reenable(pHddCtx); |
| 1850 | } |
| 1851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1852 | return VOS_STATUS_SUCCESS; |
| 1853 | } |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 1854 | |
| 1855 | int hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1856 | tHalHandle halHandle, |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 1857 | eCsrEncryptionType *pEncryptType, |
| 1858 | eCsrEncryptionType *mcEncryptType, |
| 1859 | eCsrAuthType *pAuthType, |
| 1860 | v_BOOL_t *pMFPCapable, |
| 1861 | v_BOOL_t *pMFPRequired, |
| 1862 | u_int16_t gen_ie_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1863 | u_int8_t *gen_ie ) |
| 1864 | { |
| 1865 | tDot11fIERSN dot11RSNIE; |
| 1866 | tDot11fIEWPA dot11WPAIE; |
| 1867 | |
| 1868 | tANI_U8 *pRsnIe; |
| 1869 | tANI_U16 RSNIeLen; |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 1870 | tANI_U32 status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1871 | |
| 1872 | if (NULL == halHandle) |
| 1873 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1874 | hddLog(LOGE, FL("Error haHandle returned NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1875 | return -EINVAL; |
| 1876 | } |
| 1877 | |
| 1878 | // Validity checks |
| 1879 | if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) || |
| 1880 | (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) ) |
| 1881 | return -EINVAL; |
| 1882 | // Type check |
| 1883 | if ( gen_ie[0] == DOT11F_EID_RSN) |
| 1884 | { |
| 1885 | // Validity checks |
| 1886 | if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) || |
| 1887 | (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) ) |
| 1888 | { |
| 1889 | return VOS_STATUS_E_FAILURE; |
| 1890 | } |
| 1891 | // Skip past the EID byte and length byte |
| 1892 | pRsnIe = gen_ie + 2; |
| 1893 | RSNIeLen = gen_ie_len - 2; |
| 1894 | // Unpack the RSN IE |
| 1895 | memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN)); |
Pragaspathi Thilagaraj | d1b02df | 2018-06-26 17:08:05 +0530 | [diff] [blame] | 1896 | |
| 1897 | status = sme_unpack_rsn_ie(halHandle, |
| 1898 | pRsnIe, |
| 1899 | RSNIeLen, |
| 1900 | &dot11RSNIE); |
Pragaspathi Thilagaraj | 03e2ab1 | 2018-06-22 12:19:48 +0530 | [diff] [blame] | 1901 | if (!DOT11F_SUCCEEDED(status)) |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 1902 | { |
| 1903 | hddLog(LOGE, |
| 1904 | FL("unpack failed for RSN IE status:(0x%08x)"), |
| 1905 | status); |
| 1906 | return -EINVAL; |
| 1907 | } |
| 1908 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1909 | // Copy out the encryption and authentication types |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1910 | hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1911 | __func__, dot11RSNIE.pwise_cipher_suite_count ); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1912 | hddLog(LOG1, FL("%s: authentication suite count: %d"), |
Pragaspathi Thilagaraj | d1b02df | 2018-06-26 17:08:05 +0530 | [diff] [blame] | 1913 | __func__, dot11RSNIE.akm_suite_cnt); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1914 | /*Here we have followed the apple base code, |
| 1915 | but probably I suspect we can do something different*/ |
Pragaspathi Thilagaraj | d1b02df | 2018-06-26 17:08:05 +0530 | [diff] [blame] | 1916 | //dot11RSNIE.akm_suite_cnt |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1917 | // Just translate the FIRST one |
Pragaspathi Thilagaraj | d1b02df | 2018-06-26 17:08:05 +0530 | [diff] [blame] | 1918 | *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1919 | //dot11RSNIE.pwise_cipher_suite_count |
| 1920 | *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]); |
| 1921 | //dot11RSNIE.gp_cipher_suite_count |
| 1922 | *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite); |
| 1923 | // Set the PMKSA ID Cache for this interface |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 1924 | *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80); |
| 1925 | *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1926 | |
| 1927 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
| 1928 | } else |
| 1929 | if (gen_ie[0] == DOT11F_EID_WPA) |
| 1930 | { |
| 1931 | // Validity checks |
| 1932 | if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) || |
| 1933 | (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) |
| 1934 | { |
| 1935 | return VOS_STATUS_E_FAILURE; |
| 1936 | } |
| 1937 | // Skip past the EID byte and length byte - and four byte WiFi OUI |
| 1938 | pRsnIe = gen_ie + 2 + 4; |
| 1939 | RSNIeLen = gen_ie_len - (2 + 4); |
| 1940 | // Unpack the WPA IE |
| 1941 | memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA)); |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 1942 | status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 1943 | pRsnIe, |
| 1944 | RSNIeLen, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1945 | &dot11WPAIE); |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 1946 | if (DOT11F_FAILED(status)) |
| 1947 | { |
| 1948 | hddLog(LOGE, |
| 1949 | FL("unpack failed for WPA IE status:(0x%08x)"), |
| 1950 | status); |
| 1951 | return -EINVAL; |
| 1952 | } |
| 1953 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1954 | // Copy out the encryption and authentication types |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1955 | hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1956 | __func__, dot11WPAIE.unicast_cipher_count ); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1957 | hddLog(LOG1, FL("%s: WPA authentication suite count: %d"), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 1958 | __func__, dot11WPAIE.auth_suite_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1959 | //dot11WPAIE.auth_suite_count |
| 1960 | // Just translate the FIRST one |
| 1961 | *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]); |
| 1962 | //dot11WPAIE.unicast_cipher_count |
| 1963 | *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]); |
| 1964 | //dot11WPAIE.unicast_cipher_count |
| 1965 | *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
Chet Lanctot | 8cecea2 | 2014-02-11 19:09:36 -0800 | [diff] [blame] | 1966 | *pMFPCapable = VOS_FALSE; |
| 1967 | *pMFPRequired = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1968 | } |
| 1969 | else |
| 1970 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1971 | hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1972 | return VOS_STATUS_E_FAILURE; |
| 1973 | } |
| 1974 | return VOS_STATUS_SUCCESS; |
| 1975 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 1976 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 1977 | #ifdef FEATURE_WLAN_CH_AVOID |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 1978 | |
| 1979 | /*========================================================================== |
| 1980 | FUNCTION sapUpdateUnsafeChannelList |
| 1981 | |
| 1982 | DESCRIPTION |
| 1983 | Function Undate unsafe channel list table |
| 1984 | |
| 1985 | DEPENDENCIES |
| 1986 | NA. |
| 1987 | |
| 1988 | PARAMETERS |
| 1989 | |
| 1990 | IN |
| 1991 | pSapCtx : SAP context pointer, include unsafe channel list |
| 1992 | |
| 1993 | RETURN VALUE |
| 1994 | NONE |
| 1995 | ============================================================================*/ |
| 1996 | void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx, |
| 1997 | v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount) |
| 1998 | { |
| 1999 | v_U16_t i, j; |
| 2000 | |
| 2001 | vos_mem_zero((void *)pHddCtx->unsafeChannelList, |
| 2002 | sizeof(pHddCtx->unsafeChannelList)); |
| 2003 | if (0 == unsafeChannelCount) |
| 2004 | { |
| 2005 | pHddCtx->unsafeChannelCount = 0; |
| 2006 | } |
| 2007 | else |
| 2008 | { |
c_hpothu | 8de53e4 | 2014-08-22 15:00:37 +0530 | [diff] [blame] | 2009 | if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS) |
| 2010 | { |
| 2011 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2012 | FL("unsafeChannelCount%hd greater than %d"), |
| 2013 | unsafeChannelCount, NUM_20MHZ_RF_CHANNELS); |
| 2014 | unsafeChannelCount = NUM_20MHZ_RF_CHANNELS; |
| 2015 | } |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2016 | vos_mem_copy((void *)pHddCtx->unsafeChannelList, |
| 2017 | unsafeChannelList, |
| 2018 | unsafeChannelCount * sizeof(tANI_U16)); |
| 2019 | pHddCtx->unsafeChannelCount = unsafeChannelCount; |
| 2020 | } |
| 2021 | |
| 2022 | /* Flush, default set all channel safe */ |
| 2023 | for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++) |
| 2024 | { |
| 2025 | safeChannels[i].isSafe = VOS_TRUE; |
| 2026 | } |
| 2027 | |
| 2028 | /* Try to find unsafe channel */ |
| 2029 | for (i = 0; i < pHddCtx->unsafeChannelCount; i++) |
| 2030 | { |
| 2031 | for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++) |
| 2032 | { |
| 2033 | if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i]) |
| 2034 | { |
| 2035 | /* Found unsafe channel, update it */ |
| 2036 | safeChannels[j].isSafe = VOS_FALSE; |
| 2037 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 2038 | "%s : CH %d is not safe", |
| 2039 | __func__, pHddCtx->unsafeChannelList[i]); |
| 2040 | break; |
| 2041 | } |
| 2042 | } |
| 2043 | } |
| 2044 | |
| 2045 | return; |
| 2046 | } |
| 2047 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2048 | /** |
| 2049 | * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel |
| 2050 | * @adapter: hdd ap adapter |
| 2051 | * |
| 2052 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 2053 | * and if ACS is enabled, driver will ask userspace to restart the |
| 2054 | * sap. User space on LTE coex indication restart driver. |
| 2055 | * |
| 2056 | * Return - none |
| 2057 | */ |
| 2058 | static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter, |
| 2059 | hdd_context_t *hdd_ctx) |
| 2060 | { |
| 2061 | |
| 2062 | if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) { |
| 2063 | return; |
| 2064 | } |
| 2065 | |
| 2066 | hddLog(LOG1, FL("Current operation channel %d"), |
| 2067 | adapter->sessionCtx.ap.operatingChannel); |
| 2068 | if (false == hdd_ctx->is_ch_avoid_in_progress) { |
| 2069 | hdd_change_ch_avoidance_status(hdd_ctx, true); |
| 2070 | |
| 2071 | vos_flush_work( |
| 2072 | &hdd_ctx->sap_start_work); |
| 2073 | |
| 2074 | /* |
| 2075 | * current operating channel |
| 2076 | * is un-safe channel, restart SAP |
| 2077 | */ |
| 2078 | hddLog(LOG1, |
| 2079 | FL("Restarting SAP due to unsafe channel")); |
| 2080 | |
| 2081 | adapter->sessionCtx.ap.sapConfig.channel = |
| 2082 | AUTO_CHANNEL_SELECT; |
| 2083 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2084 | |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 2085 | if (hdd_ctx->cfg_ini->sap_internal_restart) { |
Kapil Gupta | 0afd191 | 2016-12-28 12:52:13 +0530 | [diff] [blame] | 2086 | netif_tx_disable(adapter->dev); |
| 2087 | schedule_work(&hdd_ctx->sap_start_work); |
| 2088 | } else { |
| 2089 | hdd_hostapd_stop(adapter->dev); |
| 2090 | } |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2091 | |
| 2092 | return; |
| 2093 | } |
| 2094 | return; |
| 2095 | } |
| 2096 | |
Yeshwanth Sriram Guntuka | 06848b1 | 2018-07-20 14:58:22 +0530 | [diff] [blame] | 2097 | static v_U16_t hdd_get_safe_channel_from_acs_range(hdd_context_t *hdd_ctx, |
| 2098 | hdd_adapter_t *sap_adapter, v_U16_t *unsafeChannelList, |
| 2099 | v_U16_t unsafeChannelCount) |
| 2100 | { |
| 2101 | v_U8_t valid_channels[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 2102 | v_U32_t startChannelNum; |
| 2103 | v_U32_t endChannelNum; |
| 2104 | v_U32_t valid_channel_count = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 2105 | v_U16_t i, j; |
| 2106 | eHalStatus status; |
| 2107 | bool found; |
| 2108 | |
| 2109 | status = sme_GetCfgValidChannels(hdd_ctx->hHal, valid_channels, |
| 2110 | &valid_channel_count); |
| 2111 | if (!HAL_STATUS_SUCCESS(status)) |
| 2112 | return 0; |
| 2113 | |
| 2114 | ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL, |
| 2115 | &startChannelNum); |
| 2116 | ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL, |
| 2117 | &endChannelNum); |
| 2118 | |
| 2119 | for (i = 0; i < valid_channel_count; i++) { |
| 2120 | found = false; |
| 2121 | for (j = 0; j < unsafeChannelCount; j++) { |
| 2122 | if (valid_channels[i] == unsafeChannelList[j]) { |
| 2123 | found = true; |
| 2124 | break; |
| 2125 | } |
| 2126 | } |
| 2127 | |
| 2128 | if (found) |
| 2129 | continue; |
| 2130 | |
| 2131 | if ((valid_channels[i] >= startChannelNum) && |
| 2132 | (valid_channels[i] <= endChannelNum)) { |
| 2133 | return valid_channels[i]; |
| 2134 | } |
| 2135 | } |
| 2136 | |
| 2137 | return 0; |
| 2138 | } |
| 2139 | |
Ashish Kumar Dhanotiya | 42aa515 | 2017-01-03 20:25:57 +0530 | [diff] [blame] | 2140 | void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter, |
| 2141 | hdd_context_t *hdd_ctxt) |
| 2142 | { |
| 2143 | v_U16_t channelLoop; |
| 2144 | v_U16_t unsafeChannelCount = 0; |
| 2145 | v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS]; |
Yeshwanth Sriram Guntuka | 06848b1 | 2018-07-20 14:58:22 +0530 | [diff] [blame] | 2146 | v_U16_t sta_chan; |
| 2147 | v_U16_t restart_chan; |
| 2148 | v_CONTEXT_t vos_ctx; |
| 2149 | ptSapContext sap_ctx; |
| 2150 | |
| 2151 | vos_ctx = hdd_ctxt->pvosContext; |
| 2152 | if (!vos_ctx) { |
| 2153 | hddLog(LOGE, FL("vos_ctx is NULL")); |
| 2154 | return; |
| 2155 | } |
| 2156 | |
| 2157 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 2158 | if (!sap_ctx) { |
| 2159 | hddLog(LOGE, FL("sap_ctx is NULL")); |
| 2160 | return; |
| 2161 | } |
Ashish Kumar Dhanotiya | 42aa515 | 2017-01-03 20:25:57 +0530 | [diff] [blame] | 2162 | |
| 2163 | /* Get unsafe channel list */ |
| 2164 | vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList), |
| 2165 | &unsafeChannelCount); |
Yeshwanth Sriram Guntuka | 06848b1 | 2018-07-20 14:58:22 +0530 | [diff] [blame] | 2166 | sta_chan = hdd_get_operating_channel(hdd_ctxt, WLAN_HDD_INFRA_STATION); |
| 2167 | |
| 2168 | if (sta_chan) { |
| 2169 | hddLog(LOG1, FL("Only SCC supported for STA+SAP")); |
| 2170 | return; |
| 2171 | } |
| 2172 | |
Ashish Kumar Dhanotiya | 42aa515 | 2017-01-03 20:25:57 +0530 | [diff] [blame] | 2173 | for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++) |
| 2174 | { |
| 2175 | if ((unsafeChannelList[channelLoop] == |
| 2176 | phostapd_adapter->sessionCtx.ap.operatingChannel)) { |
| 2177 | if ((AUTO_CHANNEL_SELECT == |
| 2178 | phostapd_adapter->sessionCtx.ap.sapConfig.channel) |
| 2179 | && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) { |
| 2180 | /* |
| 2181 | * current operating channel is un-safe channel |
| 2182 | * restart driver |
| 2183 | */ |
Yeshwanth Sriram Guntuka | 06848b1 | 2018-07-20 14:58:22 +0530 | [diff] [blame] | 2184 | if (hdd_ctxt->cfg_ini->force_scc_with_ecsa) { |
| 2185 | restart_chan = hdd_get_safe_channel_from_acs_range(hdd_ctxt, |
| 2186 | phostapd_adapter, unsafeChannelList, |
| 2187 | unsafeChannelCount); |
| 2188 | |
| 2189 | if (!restart_chan) { |
| 2190 | hddLog(LOGE, FL("Failed to restart SAP as no safe channel found")); |
| 2191 | return; |
| 2192 | } else { |
| 2193 | if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx)) |
| 2194 | return; |
| 2195 | INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp); |
| 2196 | if (wlansap_set_channel_change(vos_ctx, restart_chan, |
| 2197 | false)) { |
| 2198 | wlansap_reset_chan_change_in_progress(sap_ctx); |
| 2199 | complete(&sap_ctx->ecsa_info.chan_switch_comp); |
| 2200 | return; |
| 2201 | } |
| 2202 | } |
| 2203 | } else { |
| 2204 | hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt); |
| 2205 | } |
Ashish Kumar Dhanotiya | 42aa515 | 2017-01-03 20:25:57 +0530 | [diff] [blame] | 2206 | /* |
| 2207 | * On LE, this event is handled by wlan-services to |
| 2208 | * restart SAP. On android, this event would be |
| 2209 | * ignored. |
| 2210 | */ |
| 2211 | wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND, |
| 2212 | NULL, 0); |
| 2213 | } |
| 2214 | break; |
| 2215 | } |
| 2216 | } |
| 2217 | return; |
| 2218 | } |
| 2219 | |
| 2220 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2221 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2222 | /**--------------------------------------------------------------------------- |
| 2223 | |
| 2224 | \brief hdd_hostapd_ch_avoid_cb() - |
| 2225 | |
| 2226 | Avoid channel notification from FW handler. |
| 2227 | FW will send un-safe channle list to avoid overwrapping. |
| 2228 | hostapd should not use notified channel |
| 2229 | |
| 2230 | \param - pAdapter HDD adapter pointer |
| 2231 | indParam channel avoid notification parameter |
| 2232 | |
| 2233 | \return - None |
| 2234 | |
| 2235 | --------------------------------------------------------------------------*/ |
| 2236 | void hdd_hostapd_ch_avoid_cb |
| 2237 | ( |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2238 | void *context, |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2239 | void *indParam |
| 2240 | ) |
| 2241 | { |
| 2242 | hdd_adapter_t *pHostapdAdapter = NULL; |
| 2243 | hdd_context_t *hddCtxt; |
| 2244 | tSirChAvoidIndType *chAvoidInd; |
| 2245 | v_U8_t rangeLoop; |
| 2246 | v_U16_t channelLoop; |
| 2247 | v_U16_t dupCheck; |
| 2248 | v_U16_t startChannel; |
| 2249 | v_U16_t endChannel; |
| 2250 | v_U16_t unsafeChannelCount = 0; |
| 2251 | v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS]; |
| 2252 | v_CONTEXT_t pVosContext; |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 2253 | tHddAvoidFreqList hddAvoidFreqList; |
| 2254 | tANI_U32 i; |
Hardik Kantilal Patel | 8c2d523 | 2015-01-08 00:31:38 +0530 | [diff] [blame] | 2255 | #ifdef WLAN_FEATURE_AP_HT40_24G |
| 2256 | ptSapContext pSapCtx = NULL; |
| 2257 | tHalHandle hHal; |
| 2258 | v_U8_t cbMode; |
| 2259 | VOS_STATUS vosStatus = VOS_STATUS_SUCCESS; |
| 2260 | v_U32_t delay; |
| 2261 | #endif |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2262 | |
| 2263 | /* Basic sanity */ |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2264 | if ((NULL == context) || (NULL == indParam)) |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2265 | { |
| 2266 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2267 | "%s : Invalid arguments", __func__); |
| 2268 | return; |
| 2269 | } |
| 2270 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 2271 | hddCtxt = (hdd_context_t *)context; |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2272 | chAvoidInd = (tSirChAvoidIndType *)indParam; |
| 2273 | pVosContext = hddCtxt->pvosContext; |
| 2274 | |
| 2275 | /* Make unsafe channel list */ |
| 2276 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2277 | "%s : band count %d", |
| 2278 | __func__, chAvoidInd->avoidRangeCount); |
| 2279 | vos_mem_zero((void *)unsafeChannelList, |
| 2280 | NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t)); |
| 2281 | for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++) |
| 2282 | { |
Abhishek Singh | 57a3154 | 2016-01-04 21:01:43 +0530 | [diff] [blame] | 2283 | if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) { |
| 2284 | hddLog(LOGW, FL("LTE Coex unsafe channel list full")); |
| 2285 | break; |
| 2286 | } |
| 2287 | startChannel = ieee80211_frequency_to_channel( |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2288 | chAvoidInd->avoidFreqRange[rangeLoop].startFreq); |
Abhishek Singh | 57a3154 | 2016-01-04 21:01:43 +0530 | [diff] [blame] | 2289 | endChannel = ieee80211_frequency_to_channel( |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2290 | chAvoidInd->avoidFreqRange[rangeLoop].endFreq); |
| 2291 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2292 | "%s : start %d : %d, end %d : %d", |
| 2293 | __func__, |
| 2294 | chAvoidInd->avoidFreqRange[rangeLoop].startFreq, |
| 2295 | startChannel, |
| 2296 | chAvoidInd->avoidFreqRange[rangeLoop].endFreq, |
| 2297 | endChannel); |
| 2298 | for (channelLoop = startChannel; |
| 2299 | channelLoop < (endChannel + 1); |
| 2300 | channelLoop++) |
| 2301 | { |
| 2302 | /* Channel duplicate check routine */ |
| 2303 | for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++) |
| 2304 | { |
| 2305 | if (unsafeChannelList[dupCheck] == channelLoop) |
| 2306 | { |
| 2307 | /* This channel is duplicated */ |
| 2308 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2309 | "%s : found duplicated channel %d", |
| 2310 | __func__, channelLoop); |
| 2311 | break; |
| 2312 | } |
| 2313 | } |
| 2314 | if (dupCheck == unsafeChannelCount) |
| 2315 | { |
c_hpothu | 8de53e4 | 2014-08-22 15:00:37 +0530 | [diff] [blame] | 2316 | int ii; |
| 2317 | for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++) |
| 2318 | { |
| 2319 | if (channelLoop == safeChannels[ii].channelNumber) |
| 2320 | { |
| 2321 | unsafeChannelList[unsafeChannelCount] = channelLoop; |
| 2322 | unsafeChannelCount++; |
| 2323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2324 | "%s : unsafe channel %d, count %d", |
| 2325 | __func__, |
| 2326 | channelLoop, unsafeChannelCount); |
Abhishek Singh | 57a3154 | 2016-01-04 21:01:43 +0530 | [diff] [blame] | 2327 | if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) { |
| 2328 | hddLog(LOGW, FL("LTE Coex unsafe channel list full")); |
| 2329 | break; |
| 2330 | } |
c_hpothu | 8de53e4 | 2014-08-22 15:00:37 +0530 | [diff] [blame] | 2331 | } |
| 2332 | } |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2333 | } |
| 2334 | else |
| 2335 | { |
| 2336 | /* DUP, do nothing */ |
| 2337 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2338 | "%s : duplicated channel %d", |
| 2339 | __func__, channelLoop); |
| 2340 | } |
| 2341 | } |
| 2342 | } |
| 2343 | /* Update unsafe channel cache |
| 2344 | * WCN Platform Driver cache */ |
| 2345 | wcnss_set_wlan_unsafe_channel(unsafeChannelList, |
| 2346 | unsafeChannelCount); |
| 2347 | |
| 2348 | /* Store into local cache |
| 2349 | * Start with STA and later start SAP |
| 2350 | * in this scenario, local cache will be used */ |
| 2351 | hdd_hostapd_update_unsafe_channel_list(hddCtxt, |
| 2352 | unsafeChannelList, |
| 2353 | unsafeChannelCount); |
| 2354 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 2355 | /* generate vendor specific event */ |
| 2356 | vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList)); |
| 2357 | for (i = 0; i < chAvoidInd->avoidRangeCount; i++) |
| 2358 | { |
| 2359 | hddAvoidFreqList.avoidFreqRange[i].startFreq = |
| 2360 | chAvoidInd->avoidFreqRange[i].startFreq; |
| 2361 | hddAvoidFreqList.avoidFreqRange[i].endFreq = |
| 2362 | chAvoidInd->avoidFreqRange[i].endFreq; |
| 2363 | } |
| 2364 | hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount; |
| 2365 | |
| 2366 | wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList); |
| 2367 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2368 | /* Get SAP context first |
| 2369 | * SAP and P2PGO would not concurrent */ |
| 2370 | pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP); |
Hardik Kantilal Patel | 8c2d523 | 2015-01-08 00:31:38 +0530 | [diff] [blame] | 2371 | #ifdef WLAN_FEATURE_AP_HT40_24G |
| 2372 | if (NULL == pHostapdAdapter) |
| 2373 | { |
| 2374 | pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO); |
| 2375 | } |
| 2376 | #endif |
Kanchanapally, Vidyullatha | 99bd6c4 | 2014-12-10 13:54:38 +0530 | [diff] [blame] | 2377 | if ((pHostapdAdapter) && |
| 2378 | (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) && |
| 2379 | (unsafeChannelCount)) |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2380 | { |
| 2381 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2382 | "%s : Current operation channel %d", |
| 2383 | __func__, |
| 2384 | pHostapdAdapter->sessionCtx.ap.operatingChannel); |
Ashish Kumar Dhanotiya | 42aa515 | 2017-01-03 20:25:57 +0530 | [diff] [blame] | 2385 | /* Check and Restart the SAP if it is on unsafe channel */ |
| 2386 | hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt); |
| 2387 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2388 | } |
| 2389 | |
Hardik Kantilal Patel | 8c2d523 | 2015-01-08 00:31:38 +0530 | [diff] [blame] | 2390 | #ifdef WLAN_FEATURE_AP_HT40_24G |
| 2391 | if (hddCtxt->cfg_ini->apHT40_24GEnabled) |
| 2392 | { |
| 2393 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 2394 | |
| 2395 | if(pSapCtx == NULL) |
| 2396 | { |
| 2397 | VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR, |
| 2398 | FL("psapCtx is NULL")); |
| 2399 | return; |
| 2400 | } |
| 2401 | |
| 2402 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2403 | FL("SAP Secondary channel: %d "), |
| 2404 | pSapCtx->sap_sec_chan); |
| 2405 | |
| 2406 | /* tHalHandle */ |
| 2407 | hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx); |
| 2408 | |
| 2409 | if (NULL == hHal) |
| 2410 | { |
| 2411 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2412 | FL("In invalid hHal")); |
| 2413 | return; |
| 2414 | } |
| 2415 | |
| 2416 | cbMode = sme_GetChannelBondingMode24G(hHal); |
| 2417 | |
| 2418 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 2419 | FL("Selected Channel bonding : %d"), cbMode); |
| 2420 | |
| 2421 | if (cbMode && (pSapCtx->sap_sec_chan > 0)) |
| 2422 | { |
| 2423 | int i; |
| 2424 | eHalStatus halStatus; |
| 2425 | |
| 2426 | for (i = 0; i < unsafeChannelCount; i++) |
| 2427 | { |
| 2428 | if ((pSapCtx->sap_sec_chan == unsafeChannelList[i])) |
| 2429 | { |
| 2430 | /* Current SAP Secondary channel is un-safe channel */ |
| 2431 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2432 | FL("Move SAP from HT40 to HT20")); |
| 2433 | |
| 2434 | halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId, |
| 2435 | PHY_SINGLE_CHANNEL_CENTERED); |
| 2436 | |
| 2437 | if (halStatus == eHAL_STATUS_FAILURE) |
| 2438 | { |
| 2439 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2440 | FL("Failed to change HT20/40 mode")); |
| 2441 | return; |
| 2442 | } |
| 2443 | |
| 2444 | /* Disable Channel Bonding for 2.4GHz */ |
| 2445 | sme_UpdateChannelBondingMode24G(hHal, |
| 2446 | PHY_SINGLE_CHANNEL_CENTERED); |
| 2447 | return; |
| 2448 | } |
| 2449 | } |
| 2450 | } |
| 2451 | |
| 2452 | if ((!pSapCtx->numHT40IntoSta) |
| 2453 | && (pHostapdAdapter) |
| 2454 | && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))) |
| 2455 | { |
| 2456 | /* if Unsafe channel is Zero or SAP Primary/Secondary channel |
| 2457 | * are Safe then start HT20/40 timer to Move SAP from HT20 |
| 2458 | * to HT40. |
| 2459 | */ |
| 2460 | if (((!unsafeChannelCount) |
| 2461 | || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode)) |
| 2462 | { |
| 2463 | /* Stop Previous Running HT20/40 Timer & Start timer |
| 2464 | with (OBSS TransitionDelayFactor * obss interval) |
| 2465 | delay after time out move AP from HT20 -> HT40 |
| 2466 | mode |
| 2467 | */ |
| 2468 | if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state) |
| 2469 | { |
| 2470 | vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer); |
| 2471 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 2472 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2473 | FL("Failed to Stop HT20/40 timer")); |
| 2474 | } |
| 2475 | |
| 2476 | delay = |
| 2477 | (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor); |
| 2478 | |
| 2479 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2480 | FL("Start HT20/40 transition timer (%d sec)"), delay); |
| 2481 | |
| 2482 | vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer, |
| 2483 | (delay * 1000)); |
| 2484 | |
| 2485 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 2486 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2487 | FL("Failed to Start HT20/40 timer")); |
| 2488 | } |
| 2489 | else |
| 2490 | { |
| 2491 | /* Stop HT20/40 Timer */ |
| 2492 | if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state) |
| 2493 | { |
| 2494 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, |
| 2495 | FL("Stop HT20/40 transition timer")); |
| 2496 | vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer); |
| 2497 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 2498 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 2499 | FL("Failed to Stop HT20/40 timer")); |
| 2500 | } |
| 2501 | } |
| 2502 | } |
| 2503 | } |
| 2504 | #endif |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2505 | return; |
| 2506 | } |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 2507 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 2508 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2509 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 2510 | static __iw_softap_setparam(struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2511 | struct iw_request_info *info, |
| 2512 | union iwreq_data *wrqu, char *extra) |
| 2513 | { |
| 2514 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2515 | tHalHandle hHal; |
Mahesh A Saptasagar | c449f10 | 2015-01-09 21:15:18 +0530 | [diff] [blame] | 2516 | hdd_context_t *pHddCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2517 | int *value = (int *)extra; |
| 2518 | int sub_cmd = value[0]; |
| 2519 | int set_value = value[1]; |
| 2520 | eHalStatus status; |
| 2521 | int ret = 0; /* success */ |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 2522 | int enable_pattrn_byte_match, enable_magic_pkt; |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2523 | v_CONTEXT_t pVosContext; |
| 2524 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2525 | ENTER(); |
| 2526 | |
Mahesh A Saptasagar | c449f10 | 2015-01-09 21:15:18 +0530 | [diff] [blame] | 2527 | if (NULL == pHostapdAdapter) |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2528 | { |
| 2529 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mahesh A Saptasagar | c449f10 | 2015-01-09 21:15:18 +0530 | [diff] [blame] | 2530 | "%s: hostapd Adapter is null", |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2531 | __func__); |
| 2532 | return -1; |
| 2533 | } |
| 2534 | |
Mahesh A Saptasagar | c449f10 | 2015-01-09 21:15:18 +0530 | [diff] [blame] | 2535 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 2536 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2537 | if (0 != ret) |
| 2538 | { |
Mahesh A Saptasagar | c449f10 | 2015-01-09 21:15:18 +0530 | [diff] [blame] | 2539 | return -1; |
| 2540 | } |
| 2541 | |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2542 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 2543 | if (!hHal) |
| 2544 | { |
| 2545 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2546 | "%s: Hal ctx is null", __func__); |
| 2547 | return -1; |
| 2548 | } |
| 2549 | |
| 2550 | pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 2551 | if (!pVosContext) |
| 2552 | { |
| 2553 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2554 | "%s: Vos ctx is null", __func__); |
| 2555 | return -1; |
| 2556 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2557 | |
| 2558 | switch(sub_cmd) |
| 2559 | { |
| 2560 | |
| 2561 | case QCSAP_PARAM_CLR_ACL: |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2562 | if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2563 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2564 | ret = -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2565 | } |
| 2566 | break; |
| 2567 | |
| 2568 | case QCSAP_PARAM_ACL_MODE: |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2569 | if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) || |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2570 | (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value)) |
| 2571 | { |
| 2572 | hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value); |
| 2573 | ret = -EINVAL; |
| 2574 | } |
| 2575 | else |
| 2576 | { |
| 2577 | WLANSAP_SetMode(pVosContext, set_value); |
| 2578 | } |
| 2579 | break; |
Ravi Shankar Upadrasta | bb216bb | 2014-06-13 14:40:24 +0530 | [diff] [blame] | 2580 | |
| 2581 | case QCSAP_PARAM_SET_AUTO_CHANNEL: |
| 2582 | if ((0 != set_value) && (1 != set_value)) |
| 2583 | { |
| 2584 | hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value); |
| 2585 | ret = -EINVAL; |
| 2586 | } |
| 2587 | else |
| 2588 | { |
| 2589 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value; |
| 2590 | } |
| 2591 | break; |
| 2592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2593 | case QCSAP_PARAM_MAX_ASSOC: |
| 2594 | if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) |
| 2595 | { |
| 2596 | hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value); |
| 2597 | ret = -EINVAL; |
| 2598 | } |
| 2599 | else |
| 2600 | { |
| 2601 | if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) |
| 2602 | { |
| 2603 | hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d." |
| 2604 | "Setting it to max allowed and continuing"), |
| 2605 | set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX); |
| 2606 | set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX; |
| 2607 | } |
| 2608 | status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, |
| 2609 | set_value, NULL, eANI_BOOLEAN_FALSE); |
| 2610 | if ( status != eHAL_STATUS_SUCCESS ) |
| 2611 | { |
| 2612 | hddLog(LOGE, FL("setMaxAssoc failure, status %d"), |
| 2613 | status); |
| 2614 | ret = -EIO; |
| 2615 | } |
| 2616 | } |
| 2617 | break; |
| 2618 | |
| 2619 | case QCSAP_PARAM_HIDE_SSID: |
| 2620 | { |
| 2621 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2622 | status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value); |
| 2623 | if(eHAL_STATUS_SUCCESS != status) |
| 2624 | { |
| 2625 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2626 | "%s: QCSAP_PARAM_HIDE_SSID failed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2627 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2628 | return status; |
| 2629 | } |
| 2630 | break; |
| 2631 | } |
| 2632 | |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 2633 | case QCSAP_PARAM_SET_MC_RATE: |
| 2634 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 2635 | tSirRateUpdateInd *rateUpdate; |
| 2636 | |
| 2637 | rateUpdate = (tSirRateUpdateInd *) |
| 2638 | vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 2639 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 2640 | { |
| 2641 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 2642 | "%s: SET_MC_RATE indication alloc fail", __func__); |
| 2643 | ret = -1; |
| 2644 | break; |
| 2645 | } |
| 2646 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 2647 | |
| 2648 | hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value); |
| 2649 | /* Ignore unicast */ |
| 2650 | rateUpdate->ucastDataRate = -1; |
| 2651 | rateUpdate->mcastDataRate24GHz = set_value; |
| 2652 | rateUpdate->mcastDataRate5GHz = set_value; |
| 2653 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 2654 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 2655 | status = sme_SendRateUpdateInd(hHal, rateUpdate); |
| 2656 | if (eHAL_STATUS_SUCCESS != status) |
| 2657 | { |
| 2658 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2659 | "%s: SET_MC_RATE failed", __func__); |
| 2660 | vos_mem_free(rateUpdate); |
| 2661 | ret = -1; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 2662 | } |
| 2663 | break; |
| 2664 | } |
Mahesh A Saptasagar | 786266f | 2015-10-08 19:09:21 +0530 | [diff] [blame] | 2665 | case QCSAP_PARAM_GET_FRAME_LOGS: |
| 2666 | { |
| 2667 | if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value) |
| 2668 | != VOS_STATUS_SUCCESS) |
| 2669 | { |
| 2670 | ret = -EINVAL; |
| 2671 | } |
| 2672 | break; |
| 2673 | } |
Hanumantha Reddy Pothula | 0490027 | 2016-01-08 15:39:47 +0530 | [diff] [blame] | 2674 | case QCSAP_PARAM_SET_PROXIMITY: |
| 2675 | { |
Padma, Santhosh Kumar | 98b5d25 | 2016-10-17 17:30:41 +0530 | [diff] [blame] | 2676 | ret = wlan_hdd_set_proximity(set_value, hHal); |
Hanumantha Reddy Pothula | 0490027 | 2016-01-08 15:39:47 +0530 | [diff] [blame] | 2677 | break; |
| 2678 | } |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 2679 | case QCSAP_PARAM_SET_WOWL: |
| 2680 | { |
| 2681 | if (!pHddCtx->is_ap_mode_wow_supported) |
| 2682 | { |
| 2683 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2684 | "%s: Not supported",__func__); |
| 2685 | return -ENOTSUPP; |
| 2686 | } |
| 2687 | switch (set_value) |
| 2688 | { |
| 2689 | case 0x00: |
| 2690 | hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER); |
| 2691 | break; |
| 2692 | case 0x01: |
| 2693 | case 0x02: |
| 2694 | case 0x03: |
| 2695 | enable_magic_pkt = (set_value & 0x01) ? 1 : 0; |
| 2696 | enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0; |
| 2697 | hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s", |
| 2698 | (enable_magic_pkt ? "YES":"NO"), |
| 2699 | (enable_pattrn_byte_match ? "YES":"NO")); |
| 2700 | hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt, |
| 2701 | enable_pattrn_byte_match); |
| 2702 | break; |
| 2703 | default: |
| 2704 | hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value); |
| 2705 | ret = -EINVAL; |
| 2706 | break; |
| 2707 | } |
| 2708 | break; |
| 2709 | } |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 2710 | case QCSAP_PARAM_CAP_TSF: |
| 2711 | { |
| 2712 | ret = hdd_capture_tsf(pHostapdAdapter, |
| 2713 | (uint32_t *)&set_value, 1); |
| 2714 | break; |
| 2715 | } |
Abhishek Singh | 0260509 | 2017-10-25 14:06:12 +0530 | [diff] [blame] | 2716 | case QCSAP_PARAM_SET_CHANNEL_CHANGE: |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 2717 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) { |
| 2718 | ptSapContext sap_ctx; |
| 2719 | |
| 2720 | sap_ctx = VOS_GET_SAP_CB(pVosContext); |
| 2721 | if (!sap_ctx) { |
| 2722 | hddLog(LOGE, FL("sap_ctx is NULL")); |
| 2723 | return -EINVAL; |
| 2724 | } |
| 2725 | ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx); |
| 2726 | if (ret) |
| 2727 | return ret; |
| 2728 | INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp); |
Abhishek Singh | 0260509 | 2017-10-25 14:06:12 +0530 | [diff] [blame] | 2729 | hddLog(LOG1, FL("ET Channel Change to new channel= %d"), |
| 2730 | set_value); |
Abhishek Singh | ceb6fe2 | 2017-11-27 13:53:18 +0530 | [diff] [blame] | 2731 | ret = wlansap_set_channel_change(pVosContext, set_value, false); |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 2732 | if (ret) { |
| 2733 | wlansap_reset_chan_change_in_progress(sap_ctx); |
| 2734 | complete(&sap_ctx->ecsa_info.chan_switch_comp); |
| 2735 | } |
Abhishek Singh | 0260509 | 2017-10-25 14:06:12 +0530 | [diff] [blame] | 2736 | } else { |
| 2737 | hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"), |
| 2738 | set_value); |
| 2739 | ret = -EINVAL; |
| 2740 | } |
| 2741 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2742 | default: |
| 2743 | hddLog(LOGE, FL("Invalid setparam command %d value %d"), |
| 2744 | sub_cmd, set_value); |
| 2745 | ret = -EINVAL; |
| 2746 | break; |
| 2747 | } |
| 2748 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2749 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2750 | return ret; |
| 2751 | } |
| 2752 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 2753 | int |
| 2754 | static iw_softap_setparam(struct net_device *dev, |
| 2755 | struct iw_request_info *info, |
| 2756 | union iwreq_data *wrqu, char *extra) |
| 2757 | { |
| 2758 | int ret; |
| 2759 | |
| 2760 | vos_ssr_protect(__func__); |
| 2761 | ret = __iw_softap_setparam(dev, info, wrqu, extra); |
| 2762 | vos_ssr_unprotect(__func__); |
| 2763 | |
| 2764 | return ret; |
| 2765 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2766 | |
| 2767 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 2768 | static __iw_softap_getparam(struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2769 | struct iw_request_info *info, |
| 2770 | union iwreq_data *wrqu, char *extra) |
| 2771 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2772 | hdd_adapter_t *pHostapdAdapter; |
| 2773 | tHalHandle hHal; |
| 2774 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2775 | int *value = (int *)extra; |
| 2776 | int sub_cmd = value[0]; |
| 2777 | eHalStatus status; |
| 2778 | int ret = 0; /* success */ |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2779 | v_CONTEXT_t pVosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2780 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2781 | ENTER(); |
| 2782 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2783 | pHostapdAdapter = (netdev_priv(dev)); |
| 2784 | if (NULL == pHostapdAdapter) |
| 2785 | { |
| 2786 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2787 | "%s: Adapter is NULL",__func__); |
| 2788 | return -EINVAL; |
| 2789 | } |
| 2790 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 2791 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2792 | if (0 != ret) |
| 2793 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2794 | return ret; |
| 2795 | } |
| 2796 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 2797 | if (NULL == hHal) |
| 2798 | { |
| 2799 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2800 | "%s: Hal Context is NULL",__func__); |
| 2801 | return -EINVAL; |
| 2802 | } |
| 2803 | pVosContext = pHddCtx->pvosContext; |
| 2804 | if (NULL == pVosContext) |
| 2805 | { |
| 2806 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2807 | "%s: pVosContext Context is NULL",__func__); |
| 2808 | return -EINVAL; |
| 2809 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2810 | switch (sub_cmd) |
| 2811 | { |
| 2812 | case QCSAP_PARAM_MAX_ASSOC: |
| 2813 | status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value); |
| 2814 | if (eHAL_STATUS_SUCCESS != status) |
| 2815 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 2816 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2817 | FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2818 | ret = -EIO; |
| 2819 | } |
Girish Gowli | 385be61 | 2014-09-18 11:17:20 +0530 | [diff] [blame] | 2820 | |
| 2821 | #ifdef WLAN_SOFTAP_VSTA_FEATURE |
| 2822 | if (pHddCtx->cfg_ini->fEnableVSTASupport) |
| 2823 | { |
| 2824 | if (*value > VSTA_NUM_ASSOC_STA) |
| 2825 | { |
| 2826 | *value = VSTA_NUM_ASSOC_STA; |
| 2827 | } |
| 2828 | if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) && |
| 2829 | (*value > (VSTA_NUM_ASSOC_STA - |
| 2830 | (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA)))) |
| 2831 | { |
| 2832 | *value = (VSTA_NUM_ASSOC_STA - |
| 2833 | (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA)); |
| 2834 | } |
| 2835 | } |
| 2836 | else |
| 2837 | #endif |
| 2838 | { |
| 2839 | if (*value > NUM_ASSOC_STA) |
| 2840 | { |
| 2841 | *value = NUM_ASSOC_STA; |
| 2842 | } |
| 2843 | if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) && |
| 2844 | (*value > (NUM_ASSOC_STA - |
| 2845 | (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA)))) |
| 2846 | { |
| 2847 | *value = (NUM_ASSOC_STA - |
| 2848 | (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA)); |
| 2849 | } |
| 2850 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2851 | break; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2852 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2853 | case QCSAP_PARAM_CLR_ACL: |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2854 | if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2855 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 2856 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2857 | FL("WLANSAP_ClearACL failed")); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2858 | ret = -EIO; |
| 2859 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2860 | *value = 0; |
| 2861 | break; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 2862 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 2863 | case QCSAP_PARAM_GET_WLAN_DBG: |
| 2864 | { |
| 2865 | vos_trace_display(); |
| 2866 | *value = 0; |
| 2867 | break; |
| 2868 | } |
| 2869 | |
| 2870 | case QCSAP_PARAM_AUTO_CHANNEL: |
| 2871 | { |
| 2872 | *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection; |
| 2873 | break; |
| 2874 | } |
| 2875 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2876 | default: |
| 2877 | hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd); |
| 2878 | ret = -EINVAL; |
| 2879 | break; |
| 2880 | |
| 2881 | } |
| 2882 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2883 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2884 | return ret; |
| 2885 | } |
| 2886 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 2887 | int |
| 2888 | static iw_softap_getparam(struct net_device *dev, |
| 2889 | struct iw_request_info *info, |
| 2890 | union iwreq_data *wrqu, char *extra) |
| 2891 | { |
| 2892 | int ret; |
| 2893 | |
| 2894 | vos_ssr_protect(__func__); |
| 2895 | ret = __iw_softap_getparam(dev, info, wrqu, extra); |
| 2896 | vos_ssr_unprotect(__func__); |
| 2897 | |
| 2898 | return ret; |
| 2899 | } |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 2900 | |
| 2901 | int |
| 2902 | static __iw_softap_setchar_getnone(struct net_device *dev, |
| 2903 | struct iw_request_info *info, |
| 2904 | union iwreq_data *wrqu, char *extra) |
| 2905 | { |
| 2906 | int sub_cmd; |
| 2907 | int ret = 0; /* success */ |
| 2908 | char *pBuffer = NULL; |
| 2909 | hdd_adapter_t *pAdapter; |
| 2910 | hdd_context_t *pHddCtx; |
| 2911 | struct iw_point s_priv_data; |
| 2912 | |
| 2913 | ENTER(); |
| 2914 | |
| 2915 | if (!capable(CAP_NET_ADMIN)) |
| 2916 | { |
| 2917 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2918 | FL("permission check failed")); |
| 2919 | return -EPERM; |
| 2920 | } |
| 2921 | |
| 2922 | pAdapter = (netdev_priv(dev)); |
| 2923 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2924 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2925 | if (0 != ret) |
| 2926 | { |
| 2927 | return ret; |
| 2928 | } |
| 2929 | |
| 2930 | if (!pHddCtx->is_ap_mode_wow_supported) |
| 2931 | { |
| 2932 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2933 | "%s: Not supported",__func__); |
| 2934 | return -ENOTSUPP; |
| 2935 | } |
| 2936 | |
| 2937 | /* helper function to get iwreq_data with compat handling. */ |
| 2938 | if (hdd_priv_get_data(&s_priv_data, wrqu)) |
| 2939 | { |
| 2940 | return -EINVAL; |
| 2941 | } |
| 2942 | |
| 2943 | /* make sure all params are correctly passed to function */ |
| 2944 | if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) |
| 2945 | { |
| 2946 | return -EINVAL; |
| 2947 | } |
| 2948 | |
| 2949 | sub_cmd = s_priv_data.flags; |
| 2950 | |
| 2951 | /* ODD number is used for set, copy data using copy_from_user */ |
| 2952 | pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer, |
| 2953 | s_priv_data.length); |
| 2954 | if (NULL == pBuffer) |
| 2955 | { |
| 2956 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2957 | "mem_alloc_copy_from_user_helper fail"); |
| 2958 | return -ENOMEM; |
| 2959 | } |
| 2960 | |
| 2961 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2962 | "%s: Received length %d", __func__, s_priv_data.length); |
| 2963 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2964 | "%s: Received data %s", __func__, pBuffer); |
| 2965 | |
| 2966 | switch(sub_cmd) |
| 2967 | { |
| 2968 | case WE_WOWL_ADD_PTRN: |
| 2969 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN"); |
| 2970 | ret = hdd_add_wowl_ptrn(pAdapter, pBuffer); |
| 2971 | if (!ret) |
| 2972 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2973 | "Failed to add pattern :%d", ret); |
| 2974 | break; |
| 2975 | case WE_WOWL_DEL_PTRN: |
| 2976 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN"); |
| 2977 | ret = hdd_del_wowl_ptrn(pAdapter, pBuffer); |
| 2978 | if (!ret) |
| 2979 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2980 | "Failed to del pattern :%d", ret); |
| 2981 | break; |
| 2982 | default: |
| 2983 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP"); |
| 2984 | ret = -EINVAL; |
| 2985 | break; |
| 2986 | } |
| 2987 | |
| 2988 | kfree(pBuffer); |
| 2989 | return ret; |
| 2990 | } |
| 2991 | |
| 2992 | int |
| 2993 | static iw_softap_setchar_getnone(struct net_device *dev, |
| 2994 | struct iw_request_info *info, |
| 2995 | union iwreq_data *wrqu, char *extra) |
| 2996 | { |
| 2997 | int ret; |
| 2998 | |
| 2999 | vos_ssr_protect(__func__); |
| 3000 | ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra); |
| 3001 | vos_ssr_unprotect(__func__); |
| 3002 | |
| 3003 | return ret; |
| 3004 | } |
| 3005 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3006 | /* Usage: |
| 3007 | BLACK_LIST = 0 |
| 3008 | WHITE_LIST = 1 |
| 3009 | ADD MAC = 0 |
| 3010 | REMOVE MAC = 1 |
| 3011 | |
| 3012 | mac addr will be accepted as a 6 octet mac address with each octet inputted in hex |
| 3013 | for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33 |
| 3014 | while using this ioctl |
| 3015 | |
| 3016 | Syntax: |
| 3017 | iwpriv softap.0 modify_acl |
| 3018 | <6 octet mac addr> <list type> <cmd type> |
| 3019 | |
| 3020 | Examples: |
| 3021 | eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list |
| 3022 | iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0 |
| 3023 | eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list |
| 3024 | iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1 |
| 3025 | */ |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3026 | int __iw_softap_modify_acl(struct net_device *dev, |
| 3027 | struct iw_request_info *info, |
| 3028 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3029 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3030 | hdd_adapter_t *pHostapdAdapter; |
| 3031 | v_CONTEXT_t pVosContext; |
| 3032 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3033 | v_BYTE_t *value = (v_BYTE_t*)extra; |
| 3034 | v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE]; |
| 3035 | int listType, cmd, i; |
| 3036 | int ret = 0; /* success */ |
| 3037 | |
| 3038 | ENTER(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3039 | pHostapdAdapter = (netdev_priv(dev)); |
| 3040 | if (NULL == pHostapdAdapter) |
| 3041 | { |
| 3042 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3043 | "%s: Adapter is NULL",__func__); |
| 3044 | return -EINVAL; |
| 3045 | } |
| 3046 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3047 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3048 | if (0 != ret) |
| 3049 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3050 | return ret; |
| 3051 | } |
| 3052 | pVosContext = pHddCtx->pvosContext; |
| 3053 | if (NULL == pVosContext) |
| 3054 | { |
| 3055 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3056 | "%s: Vos Context is NULL",__func__); |
| 3057 | return -EINVAL; |
| 3058 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3059 | for (i=0; i<VOS_MAC_ADDR_SIZE; i++) |
| 3060 | { |
| 3061 | pPeerStaMac[i] = *(value+i); |
| 3062 | } |
| 3063 | listType = (int)(*(value+i)); |
| 3064 | i++; |
| 3065 | cmd = (int)(*(value+i)); |
| 3066 | |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 3067 | hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d", |
| 3068 | __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3069 | |
| 3070 | if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd) |
| 3071 | != VOS_STATUS_SUCCESS) |
| 3072 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3073 | hddLog(LOGE, FL("Modify ACL failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3074 | ret = -EIO; |
| 3075 | } |
| 3076 | EXIT(); |
| 3077 | return ret; |
| 3078 | } |
| 3079 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3080 | int iw_softap_modify_acl(struct net_device *dev, |
| 3081 | struct iw_request_info *info, |
| 3082 | union iwreq_data *wrqu, char *extra) |
| 3083 | { |
| 3084 | int ret; |
| 3085 | |
| 3086 | vos_ssr_protect(__func__); |
| 3087 | ret = __iw_softap_modify_acl(dev, info, wrqu, extra); |
| 3088 | vos_ssr_unprotect(__func__); |
| 3089 | |
| 3090 | return ret; |
| 3091 | } |
| 3092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3093 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3094 | static __iw_softap_getchannel(struct net_device *dev, |
| 3095 | struct iw_request_info *info, |
| 3096 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3097 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3098 | hdd_adapter_t *pHostapdAdapter; |
| 3099 | hdd_context_t *pHddCtx; |
| 3100 | int ret = 0; |
| 3101 | int *value; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3102 | |
| 3103 | ENTER(); |
| 3104 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3105 | pHostapdAdapter = (netdev_priv(dev)); |
| 3106 | if (NULL == pHostapdAdapter) |
| 3107 | { |
| 3108 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3109 | "%s: Adapter is NULL",__func__); |
| 3110 | return -EINVAL; |
| 3111 | } |
| 3112 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3113 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3114 | if (0 != ret) |
| 3115 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3116 | return ret; |
| 3117 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3118 | |
Mukul Sharma | 6d0762c | 2015-03-05 17:13:47 +0530 | [diff] [blame] | 3119 | value = (int *)extra; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3120 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 3121 | *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3122 | |
| 3123 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3124 | return 0; |
| 3125 | } |
| 3126 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3127 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3128 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3129 | static iw_softap_getchannel(struct net_device *dev, |
| 3130 | struct iw_request_info *info, |
| 3131 | union iwreq_data *wrqu, char *extra) |
| 3132 | { |
| 3133 | int ret; |
| 3134 | |
| 3135 | vos_ssr_protect(__func__); |
| 3136 | ret = __iw_softap_getchannel(dev, info, wrqu, extra); |
| 3137 | vos_ssr_unprotect(__func__); |
| 3138 | |
| 3139 | return ret; |
| 3140 | } |
| 3141 | |
| 3142 | int |
| 3143 | static __iw_softap_set_max_tx_power(struct net_device *dev, |
| 3144 | struct iw_request_info *info, |
| 3145 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3146 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3147 | hdd_adapter_t *pHostapdAdapter; |
| 3148 | tHalHandle hHal; |
| 3149 | hdd_context_t *pHddCtx; |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3150 | int *value = (int *)extra; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3151 | int set_value, ret = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3152 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3153 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3154 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3155 | ENTER(); |
| 3156 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3157 | pHostapdAdapter = (netdev_priv(dev)); |
| 3158 | if (NULL == pHostapdAdapter) |
| 3159 | { |
| 3160 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3161 | "%s: Adapter is NULL",__func__); |
| 3162 | return -EINVAL; |
| 3163 | } |
| 3164 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3165 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3166 | if (0 != ret) |
| 3167 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3168 | return ret; |
| 3169 | } |
| 3170 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 3171 | if (NULL == hHal) |
| 3172 | { |
| 3173 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3174 | "%s: Hal Context is NULL",__func__); |
| 3175 | return -EINVAL; |
| 3176 | } |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3177 | if (NULL == value) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3178 | return -ENOMEM; |
| 3179 | |
Leo Chang | d37675a | 2013-08-01 13:19:45 -0700 | [diff] [blame] | 3180 | /* Assign correct slef MAC address */ |
| 3181 | vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes, |
| 3182 | VOS_MAC_ADDR_SIZE); |
| 3183 | vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes, |
| 3184 | VOS_MAC_ADDR_SIZE); |
| 3185 | |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3186 | set_value = value[0]; |
| 3187 | if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value)) |
| 3188 | { |
| 3189 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 3190 | __func__); |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3191 | return -EIO; |
| 3192 | } |
| 3193 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3194 | EXIT(); |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3195 | return 0; |
| 3196 | } |
| 3197 | |
| 3198 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3199 | static iw_softap_set_max_tx_power(struct net_device *dev, |
| 3200 | struct iw_request_info *info, |
| 3201 | union iwreq_data *wrqu, char *extra) |
| 3202 | { |
| 3203 | int ret; |
| 3204 | |
| 3205 | vos_ssr_protect(__func__); |
| 3206 | ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra); |
| 3207 | vos_ssr_unprotect(__func__); |
| 3208 | |
| 3209 | return ret; |
| 3210 | } |
| 3211 | |
| 3212 | |
| 3213 | int |
| 3214 | static __iw_display_data_path_snapshot(struct net_device *dev, |
| 3215 | struct iw_request_info *info, |
| 3216 | union iwreq_data *wrqu, char *extra) |
Madan Mohan Koyyalamudi | a96f544 | 2013-05-10 11:32:06 +0530 | [diff] [blame] | 3217 | { |
| 3218 | |
| 3219 | /* Function intitiating dumping states of |
| 3220 | * HDD(WMM Tx Queues) |
| 3221 | * TL State (with Per Client infor) |
| 3222 | * DXE Snapshot (Called at the end of TL Snapshot) |
| 3223 | */ |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3224 | hdd_adapter_t *pHostapdAdapter; |
| 3225 | hdd_context_t *pHddCtx; |
| 3226 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3227 | |
| 3228 | ENTER(); |
| 3229 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3230 | pHostapdAdapter = (netdev_priv(dev)); |
| 3231 | if (NULL == pHostapdAdapter) |
| 3232 | { |
| 3233 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3234 | "%s: Adapter is NULL",__func__); |
| 3235 | return -EINVAL; |
| 3236 | } |
| 3237 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3238 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3239 | if (0 != ret) |
| 3240 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3241 | return ret; |
| 3242 | } |
Madan Mohan Koyyalamudi | a96f544 | 2013-05-10 11:32:06 +0530 | [diff] [blame] | 3243 | hdd_wmm_tx_snapshot(pHostapdAdapter); |
Mihir Shete | 327c2ab | 2014-11-13 15:17:02 +0530 | [diff] [blame] | 3244 | WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3245 | |
| 3246 | EXIT(); |
Madan Mohan Koyyalamudi | a96f544 | 2013-05-10 11:32:06 +0530 | [diff] [blame] | 3247 | return 0; |
| 3248 | } |
| 3249 | |
| 3250 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3251 | static iw_display_data_path_snapshot(struct net_device *dev, |
| 3252 | struct iw_request_info *info, |
| 3253 | union iwreq_data *wrqu, char *extra) |
| 3254 | { |
| 3255 | int ret; |
| 3256 | |
| 3257 | vos_ssr_protect(__func__); |
| 3258 | ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra); |
| 3259 | vos_ssr_unprotect(__func__); |
| 3260 | |
| 3261 | return ret; |
| 3262 | } |
| 3263 | |
| 3264 | int |
| 3265 | static __iw_softap_set_tx_power(struct net_device *dev, |
| 3266 | struct iw_request_info *info, |
| 3267 | union iwreq_data *wrqu, char *extra) |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3268 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3269 | hdd_adapter_t *pHostapdAdapter; |
| 3270 | hdd_context_t *pHddCtx; |
| 3271 | v_CONTEXT_t pVosContext; |
| 3272 | tHalHandle hHal; |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3273 | int *value = (int *)extra; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3274 | int set_value, ret = 0; |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3275 | ptSapContext pSapCtx = NULL; |
| 3276 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3277 | ENTER(); |
| 3278 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3279 | pHostapdAdapter = (netdev_priv(dev)); |
| 3280 | if (NULL == pHostapdAdapter) |
| 3281 | { |
| 3282 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3283 | "%s: Adapter is NULL",__func__); |
| 3284 | return -EINVAL; |
| 3285 | } |
| 3286 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3287 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3288 | if (0 != ret) |
| 3289 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3290 | return ret; |
| 3291 | } |
| 3292 | pVosContext = pHddCtx->pvosContext; |
| 3293 | if (NULL == pVosContext) |
| 3294 | { |
| 3295 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3296 | "%s: Vos Context is NULL",__func__); |
| 3297 | return -EINVAL; |
| 3298 | } |
| 3299 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 3300 | if (NULL == hHal) |
| 3301 | { |
| 3302 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3303 | "%s: Hal Context is NULL",__func__); |
| 3304 | return -EINVAL; |
| 3305 | } |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3306 | if (NULL == value) |
| 3307 | return -ENOMEM; |
| 3308 | |
| 3309 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 3310 | if (NULL == pSapCtx) |
| 3311 | { |
| 3312 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 3313 | "%s: Invalid SAP pointer from pvosGCtx", __func__); |
| 3314 | return VOS_STATUS_E_FAULT; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3315 | } |
| 3316 | |
| 3317 | set_value = value[0]; |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3318 | if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3319 | { |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 3320 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed", |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3321 | __func__); |
| 3322 | return -EIO; |
| 3323 | } |
| 3324 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3325 | EXIT(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3326 | return 0; |
| 3327 | } |
| 3328 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3329 | int |
| 3330 | static iw_softap_set_tx_power(struct net_device *dev, |
| 3331 | struct iw_request_info *info, |
| 3332 | union iwreq_data *wrqu, char *extra) |
| 3333 | { |
| 3334 | int ret; |
| 3335 | |
| 3336 | vos_ssr_protect(__func__); |
| 3337 | ret = __iw_softap_set_tx_power(dev, info, wrqu, extra); |
| 3338 | vos_ssr_unprotect(__func__); |
| 3339 | |
| 3340 | return ret; |
| 3341 | } |
| 3342 | |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3343 | /**--------------------------------------------------------------------------- |
| 3344 | |
| 3345 | \brief iw_softap_set_trafficmonitor() - |
| 3346 | This function dynamically enable/disable traffic monitor functonality |
| 3347 | the command iwpriv wlanX setTrafficMon <value>. |
| 3348 | |
| 3349 | \param - dev - Pointer to the net device. |
| 3350 | - addr - Pointer to the sockaddr. |
| 3351 | \return - 0 for success, non zero for failure |
| 3352 | |
| 3353 | --------------------------------------------------------------------------*/ |
| 3354 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3355 | static int __iw_softap_set_trafficmonitor(struct net_device *dev, |
| 3356 | struct iw_request_info *info, |
| 3357 | union iwreq_data *wrqu, char *extra) |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3358 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3359 | hdd_adapter_t *pAdapter; |
Sushant Kaushik | 128a0bb | 2014-08-07 20:24:54 +0530 | [diff] [blame] | 3360 | int *isSetTrafficMon = (int *)extra; |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3361 | hdd_context_t *pHddCtx; |
| 3362 | int status; |
| 3363 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3364 | ENTER(); |
| 3365 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3366 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3367 | if (NULL == pAdapter) |
| 3368 | { |
| 3369 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 3370 | "%s: HDD adapter is Null", __func__); |
| 3371 | return -ENODEV; |
| 3372 | } |
| 3373 | |
| 3374 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3375 | |
| 3376 | status = wlan_hdd_validate_context(pHddCtx); |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3377 | if (0 != status) |
| 3378 | { |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3379 | return status; |
| 3380 | } |
| 3381 | |
| 3382 | hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__); |
| 3383 | |
| 3384 | if (NULL == isSetTrafficMon) |
| 3385 | { |
| 3386 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 3387 | "%s: Invalid SAP pointer from extra", __func__); |
| 3388 | return -ENOMEM; |
| 3389 | } |
| 3390 | |
| 3391 | if (TRUE == *isSetTrafficMon) |
| 3392 | { |
| 3393 | pHddCtx->cfg_ini->enableTrafficMonitor= TRUE; |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 3394 | if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false)) |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3395 | { |
| 3396 | VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR, |
| 3397 | "%s: failed to Start Traffic Monitor timer ", __func__ ); |
| 3398 | return -EIO; |
| 3399 | } |
| 3400 | } |
| 3401 | else if (FALSE == *isSetTrafficMon) |
| 3402 | { |
| 3403 | pHddCtx->cfg_ini->enableTrafficMonitor= FALSE; |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 3404 | if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false)) |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3405 | { |
| 3406 | VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR, |
| 3407 | "%s: failed to Stop Traffic Monitor timer ", __func__ ); |
| 3408 | return -EIO; |
| 3409 | } |
| 3410 | |
| 3411 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3412 | |
| 3413 | EXIT(); |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 3414 | return 0; |
| 3415 | } |
| 3416 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3417 | static int iw_softap_set_trafficmonitor(struct net_device *dev, |
| 3418 | struct iw_request_info *info, |
| 3419 | union iwreq_data *wrqu, char *extra) |
| 3420 | { |
| 3421 | int ret; |
| 3422 | |
| 3423 | vos_ssr_protect(__func__); |
| 3424 | ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra); |
| 3425 | vos_ssr_unprotect(__func__); |
| 3426 | |
| 3427 | return ret; |
| 3428 | } |
| 3429 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3430 | #define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0) |
| 3431 | |
| 3432 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3433 | static __iw_softap_getassoc_stamacaddr(struct net_device *dev, |
| 3434 | struct iw_request_info *info, |
| 3435 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3436 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3437 | hdd_adapter_t *pHostapdAdapter; |
| 3438 | hdd_context_t *pHddCtx; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 3439 | hdd_station_info_t *pStaInfo = NULL; |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3440 | char *buf; |
| 3441 | int cnt = 0; |
| 3442 | int left; |
| 3443 | int ret = 0; |
| 3444 | /* maclist_index must be u32 to match userspace */ |
| 3445 | u32 maclist_index; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 3446 | v_CONTEXT_t pVosContext = NULL; |
| 3447 | ptSapContext pSapCtx = NULL; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3448 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3449 | ENTER(); |
| 3450 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3451 | pHostapdAdapter = (netdev_priv(dev)); |
| 3452 | if (NULL == pHostapdAdapter) |
| 3453 | { |
| 3454 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3455 | "%s: Adapter is NULL",__func__); |
| 3456 | return -EINVAL; |
| 3457 | } |
| 3458 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3459 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3460 | if (0 != ret) |
| 3461 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3462 | return ret; |
| 3463 | } |
| 3464 | |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3465 | /* |
| 3466 | * NOTE WELL: this is a "get" ioctl but it uses an even ioctl |
| 3467 | * number, and even numbered iocts are supposed to have "set" |
| 3468 | * semantics. Hence the wireless extensions support in the kernel |
| 3469 | * won't correctly copy the result to userspace, so the ioctl |
| 3470 | * handler itself must copy the data. Output format is 32-bit |
| 3471 | * record length, followed by 0 or more 6-byte STA MAC addresses. |
| 3472 | * |
| 3473 | * Further note that due to the incorrect semantics, the "iwpriv" |
| 3474 | * userspace application is unable to correctly invoke this API, |
| 3475 | * hence it is not registered in the hostapd_private_args. This |
| 3476 | * API can only be invoked by directly invoking the ioctl() system |
| 3477 | * call. |
| 3478 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3479 | |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3480 | /* make sure userspace allocated a reasonable buffer size */ |
| 3481 | if (wrqu->data.length < sizeof(maclist_index)) { |
| 3482 | hddLog(LOG1, "%s: invalid userspace buffer", __func__); |
| 3483 | return -EINVAL; |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3484 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3485 | |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 3486 | pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
| 3487 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 3488 | if(pSapCtx == NULL){ |
| 3489 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 3490 | FL("psapCtx is NULL")); |
| 3491 | return -EFAULT; |
| 3492 | } |
Hema Aparna Medicharla | 749399f | 2015-03-10 13:02:04 +0530 | [diff] [blame] | 3493 | |
| 3494 | /* allocate local buffer to build the response */ |
| 3495 | buf = kmalloc(wrqu->data.length, GFP_KERNEL); |
| 3496 | if (!buf) { |
| 3497 | hddLog(LOG1, "%s: failed to allocate response buffer", __func__); |
| 3498 | return -ENOMEM; |
| 3499 | } |
| 3500 | |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 3501 | pStaInfo = pSapCtx->aStaInfo; |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3502 | /* start indexing beyond where the record count will be written */ |
| 3503 | maclist_index = sizeof(maclist_index); |
| 3504 | left = wrqu->data.length - maclist_index; |
| 3505 | |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 3506 | spin_lock_bh(&pSapCtx->staInfo_lock); |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3507 | while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) { |
| 3508 | if ((pStaInfo[cnt].isUsed) && |
| 3509 | (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) { |
| 3510 | memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA), |
| 3511 | VOS_MAC_ADDR_SIZE); |
| 3512 | maclist_index += VOS_MAC_ADDR_SIZE; |
| 3513 | left -= VOS_MAC_ADDR_SIZE; |
| 3514 | } |
| 3515 | cnt++; |
| 3516 | } |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 3517 | spin_unlock_bh(&pSapCtx->staInfo_lock); |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3518 | |
| 3519 | *((u32 *)buf) = maclist_index; |
| 3520 | wrqu->data.length = maclist_index; |
| 3521 | if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) { |
| 3522 | hddLog(LOG1, "%s: failed to copy response to user buffer", __func__); |
| 3523 | ret = -EFAULT; |
| 3524 | } |
| 3525 | kfree(buf); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3526 | |
| 3527 | EXIT(); |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 3528 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3529 | } |
| 3530 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3531 | int |
| 3532 | static iw_softap_getassoc_stamacaddr(struct net_device *dev, |
| 3533 | struct iw_request_info *info, |
| 3534 | union iwreq_data *wrqu, char *extra) |
| 3535 | { |
| 3536 | int ret; |
| 3537 | |
| 3538 | vos_ssr_protect(__func__); |
| 3539 | ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra); |
| 3540 | vos_ssr_unprotect(__func__); |
| 3541 | |
| 3542 | return ret; |
| 3543 | } |
| 3544 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3545 | /* Usage: |
| 3546 | mac addr will be accepted as a 6 octet mac address with each octet inputted in hex |
| 3547 | for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33 |
| 3548 | while using this ioctl |
| 3549 | |
| 3550 | Syntax: |
| 3551 | iwpriv softap.0 disassoc_sta <6 octet mac address> |
| 3552 | |
| 3553 | e.g. |
| 3554 | disassociate sta with mac addr 00:0a:f5:11:22:33 from softap |
| 3555 | iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33 |
| 3556 | */ |
| 3557 | |
| 3558 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3559 | static __iw_softap_disassoc_sta(struct net_device *dev, |
| 3560 | struct iw_request_info *info, |
| 3561 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3562 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3563 | hdd_adapter_t *pHostapdAdapter; |
| 3564 | hdd_context_t *pHddCtx; |
| 3565 | v_U8_t *peerMacAddr; |
| 3566 | int ret = 0; |
| 3567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3568 | ENTER(); |
Hanumantha Reddy Pothula | 6633f3f | 2015-10-27 23:01:21 +0530 | [diff] [blame] | 3569 | |
| 3570 | if (!capable(CAP_NET_ADMIN)) { |
| 3571 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3572 | FL("permission check failed")); |
| 3573 | return -EPERM; |
| 3574 | } |
| 3575 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3576 | pHostapdAdapter = (netdev_priv(dev)); |
| 3577 | if (NULL == pHostapdAdapter) |
| 3578 | { |
| 3579 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3580 | "%s: Adapter is NULL",__func__); |
| 3581 | return -EINVAL; |
| 3582 | } |
| 3583 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3584 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3585 | if (0 != ret) |
| 3586 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3587 | return ret; |
| 3588 | } |
Gopichand Nakkala | 252c9ef | 2013-02-27 17:01:23 +0530 | [diff] [blame] | 3589 | /* iwpriv tool or framework calls this ioctl with |
| 3590 | * data passed in extra (less than 16 octets); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3591 | */ |
Gopichand Nakkala | 252c9ef | 2013-02-27 17:01:23 +0530 | [diff] [blame] | 3592 | peerMacAddr = (v_U8_t *)(extra); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3593 | |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 3594 | hddLog(LOG1, "%s data " MAC_ADDRESS_STR, |
| 3595 | __func__, MAC_ADDR_ARRAY(peerMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3596 | hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr); |
| 3597 | EXIT(); |
| 3598 | return 0; |
| 3599 | } |
| 3600 | |
| 3601 | int |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3602 | static iw_softap_disassoc_sta(struct net_device *dev, |
| 3603 | struct iw_request_info *info, |
| 3604 | union iwreq_data *wrqu, char *extra) |
| 3605 | { |
| 3606 | int ret; |
| 3607 | |
| 3608 | vos_ssr_protect(__func__); |
| 3609 | ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra); |
| 3610 | vos_ssr_unprotect(__func__); |
| 3611 | |
| 3612 | return ret; |
| 3613 | } |
| 3614 | |
| 3615 | int |
| 3616 | static __iw_softap_ap_stats(struct net_device *dev, |
| 3617 | struct iw_request_info *info, |
| 3618 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3619 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3620 | hdd_adapter_t *pHostapdAdapter; |
| 3621 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3622 | WLANTL_TRANSFER_STA_TYPE statBuffer; |
| 3623 | char *pstatbuf; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3624 | int len, ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3625 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3626 | ENTER(); |
| 3627 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3628 | pHostapdAdapter = (netdev_priv(dev)); |
| 3629 | if (NULL == pHostapdAdapter) |
| 3630 | { |
| 3631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3632 | "%s: Adapter is NULL",__func__); |
| 3633 | return -EINVAL; |
| 3634 | } |
| 3635 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3636 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3637 | if (0 != ret) |
| 3638 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3639 | return ret; |
| 3640 | } |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 3641 | memset(&statBuffer, 0, sizeof(statBuffer)); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3642 | WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, |
| 3643 | &statBuffer, (v_BOOL_t)wrqu->data.flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3644 | |
Sandeep Puligilla | 38e31bf | 2014-05-12 15:37:02 +0530 | [diff] [blame] | 3645 | pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3646 | if(NULL == pstatbuf) { |
| 3647 | hddLog(LOG1, "unable to allocate memory"); |
| 3648 | return -ENOMEM; |
| 3649 | } |
Sandeep Puligilla | 38e31bf | 2014-05-12 15:37:02 +0530 | [diff] [blame] | 3650 | |
| 3651 | len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE, |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3652 | "RUF=%d RMF=%d RBF=%d " |
| 3653 | "RUB=%d RMB=%d RBB=%d " |
| 3654 | "TUF=%d TMF=%d TBF=%d " |
Sandeep Puligilla | 38e31bf | 2014-05-12 15:37:02 +0530 | [diff] [blame] | 3655 | "TUB=%d TMB=%d TBB=%d ", |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3656 | (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt, |
| 3657 | (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt, |
| 3658 | (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt, |
| 3659 | (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt, |
| 3660 | (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt, |
| 3661 | (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3662 | |
Sandeep Puligilla | 38e31bf | 2014-05-12 15:37:02 +0530 | [diff] [blame] | 3663 | if (len >= QCSAP_MAX_WSC_IE) { |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3664 | hddLog(LOG1, "%s: failed to copy data to user buffer", __func__); |
| 3665 | kfree(pstatbuf); |
| 3666 | return -EFAULT; |
| 3667 | } |
Sandeep Puligilla | 38e31bf | 2014-05-12 15:37:02 +0530 | [diff] [blame] | 3668 | |
| 3669 | strlcpy(extra, pstatbuf, len); |
| 3670 | wrqu->data.length = len; |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 3671 | kfree(pstatbuf); |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3672 | |
| 3673 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3674 | return 0; |
| 3675 | } |
Bhargav Shah | 7f03b81 | 2015-08-21 11:17:32 +0530 | [diff] [blame] | 3676 | int |
| 3677 | static __iw_softap_ap_get_stats(struct net_device *dev, |
| 3678 | struct iw_request_info *info, |
| 3679 | union iwreq_data *wrqu, char *extra) |
| 3680 | { |
| 3681 | hdd_adapter_t *pAdapter; |
| 3682 | hdd_tx_rx_stats_t *pStats; |
| 3683 | |
| 3684 | ENTER(); |
| 3685 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3686 | if (NULL == pAdapter) |
| 3687 | { |
| 3688 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3689 | "%s: Adapter is NULL",__func__); |
| 3690 | return -EINVAL; |
| 3691 | } |
| 3692 | |
| 3693 | pStats = &pAdapter->hdd_stats.hddTxRxStats; |
| 3694 | snprintf(extra, QCSAP_MAX_STR_LEN, |
| 3695 | "\nTransmit" |
| 3696 | "\ncalled %u, dropped %u, backpressured %u, queued %u" |
| 3697 | "\n dropped BK %u, BE %u, VI %u, VO %u" |
| 3698 | "\n classified BK %u, BE %u, VI %u, VO %u" |
| 3699 | "\nbackpressured BK %u, BE %u, VI %u, VO %u" |
| 3700 | "\n queued BK %u, BE %u, VI %u, VO %u" |
| 3701 | "\nfetched %u, empty %u, lowres %u, deqerr %u" |
| 3702 | "\ndequeued %u, depressured %u, deque-depressured %u,\ |
| 3703 | completed %u, flushed %u" |
| 3704 | "\n fetched BK %u, BE %u, VI %u, VO %u" |
| 3705 | "\n dequeued BK %u, BE %u, VI %u, VO %u" |
| 3706 | "\n depressured BK %u, BE %u, VI %u, VO %u" |
| 3707 | "\nDeque depressured BK %u, BE %u, VI %u, VO %u" |
| 3708 | "\n flushed BK %u, BE %u, VI %u, VO %u" |
| 3709 | "\n\nReceive" |
| 3710 | "\nchains %u, packets %u, dropped %u, delivered %u, refused %u" |
| 3711 | "\n\nResetsStats" |
| 3712 | "\n", |
| 3713 | pStats->txXmitCalled, |
| 3714 | pStats->txXmitDropped, |
| 3715 | pStats->txXmitBackPressured, |
| 3716 | pStats->txXmitQueued, |
| 3717 | |
| 3718 | pStats->txXmitDroppedAC[WLANTL_AC_BK], |
| 3719 | pStats->txXmitDroppedAC[WLANTL_AC_BE], |
| 3720 | pStats->txXmitDroppedAC[WLANTL_AC_VI], |
| 3721 | pStats->txXmitDroppedAC[WLANTL_AC_VO], |
| 3722 | |
| 3723 | pStats->txXmitClassifiedAC[WLANTL_AC_BK], |
| 3724 | pStats->txXmitClassifiedAC[WLANTL_AC_BE], |
| 3725 | pStats->txXmitClassifiedAC[WLANTL_AC_VI], |
| 3726 | pStats->txXmitClassifiedAC[WLANTL_AC_VO], |
| 3727 | |
| 3728 | pStats->txXmitBackPressuredAC[WLANTL_AC_BK], |
| 3729 | pStats->txXmitBackPressuredAC[WLANTL_AC_BE], |
| 3730 | pStats->txXmitBackPressuredAC[WLANTL_AC_VI], |
| 3731 | pStats->txXmitBackPressuredAC[WLANTL_AC_VO], |
| 3732 | |
| 3733 | pStats->txXmitQueuedAC[WLANTL_AC_BK], |
| 3734 | pStats->txXmitQueuedAC[WLANTL_AC_BE], |
| 3735 | pStats->txXmitQueuedAC[WLANTL_AC_VI], |
| 3736 | pStats->txXmitQueuedAC[WLANTL_AC_VO], |
| 3737 | |
| 3738 | pStats->txFetched, |
| 3739 | pStats->txFetchEmpty, |
| 3740 | pStats->txFetchLowResources, |
| 3741 | pStats->txFetchDequeueError, |
| 3742 | |
| 3743 | pStats->txFetchDequeued, |
| 3744 | pStats->txFetchDePressured, |
| 3745 | pStats->txDequeDePressured, |
| 3746 | pStats->txCompleted, |
| 3747 | pStats->txFlushed, |
| 3748 | |
| 3749 | pStats->txFetchedAC[WLANTL_AC_BK], |
| 3750 | pStats->txFetchedAC[WLANTL_AC_BE], |
| 3751 | pStats->txFetchedAC[WLANTL_AC_VI], |
| 3752 | pStats->txFetchedAC[WLANTL_AC_VO], |
| 3753 | |
| 3754 | pStats->txFetchDequeuedAC[WLANTL_AC_BK], |
| 3755 | pStats->txFetchDequeuedAC[WLANTL_AC_BE], |
| 3756 | pStats->txFetchDequeuedAC[WLANTL_AC_VI], |
| 3757 | pStats->txFetchDequeuedAC[WLANTL_AC_VO], |
| 3758 | |
| 3759 | pStats->txFetchDePressuredAC[WLANTL_AC_BK], |
| 3760 | pStats->txFetchDePressuredAC[WLANTL_AC_BE], |
| 3761 | pStats->txFetchDePressuredAC[WLANTL_AC_VI], |
| 3762 | pStats->txFetchDePressuredAC[WLANTL_AC_VO], |
| 3763 | |
| 3764 | pStats->txDequeDePressuredAC[WLANTL_AC_BK], |
| 3765 | pStats->txDequeDePressuredAC[WLANTL_AC_BE], |
| 3766 | pStats->txDequeDePressuredAC[WLANTL_AC_VI], |
| 3767 | pStats->txDequeDePressuredAC[WLANTL_AC_VO], |
| 3768 | |
| 3769 | pStats->txFlushedAC[WLANTL_AC_BK], |
| 3770 | pStats->txFlushedAC[WLANTL_AC_BE], |
| 3771 | pStats->txFlushedAC[WLANTL_AC_VI], |
| 3772 | pStats->txFlushedAC[WLANTL_AC_VO], |
| 3773 | |
| 3774 | pStats->rxChains, |
| 3775 | pStats->rxPackets, |
| 3776 | pStats->rxDropped, |
| 3777 | pStats->rxDelivered, |
| 3778 | pStats->rxRefused |
| 3779 | ); |
| 3780 | |
| 3781 | wrqu->data.length = strlen(extra) + 1; |
| 3782 | |
| 3783 | return 0; |
| 3784 | } |
| 3785 | |
| 3786 | int |
| 3787 | static __iw_softap_ap_clear_stats(struct net_device *dev, |
| 3788 | struct iw_request_info *info, |
| 3789 | union iwreq_data *wrqu, char *extra) |
| 3790 | { |
| 3791 | hdd_adapter_t *pAdapter; |
| 3792 | |
| 3793 | ENTER(); |
| 3794 | |
| 3795 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3796 | if (NULL == pAdapter) |
| 3797 | { |
| 3798 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3799 | "%s: Adapter is NULL",__func__); |
| 3800 | return -EINVAL; |
| 3801 | } |
| 3802 | |
| 3803 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__); |
| 3804 | memset(&pAdapter->stats, 0, sizeof(pAdapter->stats)); |
| 3805 | memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats)); |
| 3806 | return 0; |
| 3807 | } |
| 3808 | |
| 3809 | |
| 3810 | int |
| 3811 | static iw_softap_get_stats(struct net_device *dev, |
| 3812 | struct iw_request_info *info, |
| 3813 | union iwreq_data *wrqu, char *extra) |
| 3814 | { |
| 3815 | int ret; |
| 3816 | vos_ssr_protect(__func__); |
| 3817 | ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra); |
| 3818 | vos_ssr_unprotect(__func__); |
| 3819 | return ret; |
| 3820 | } |
| 3821 | |
| 3822 | int |
| 3823 | static iw_softap_clear_stats(struct net_device *dev, |
| 3824 | struct iw_request_info *info, |
| 3825 | union iwreq_data *wrqu, char *extra) |
| 3826 | { |
| 3827 | int ret; |
| 3828 | vos_ssr_protect(__func__); |
| 3829 | ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra); |
| 3830 | vos_ssr_unprotect(__func__); |
| 3831 | return ret; |
| 3832 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3833 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3834 | int |
| 3835 | static iw_softap_ap_stats(struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3836 | struct iw_request_info *info, |
| 3837 | union iwreq_data *wrqu, char *extra) |
| 3838 | { |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3839 | int ret; |
| 3840 | |
| 3841 | vos_ssr_protect(__func__); |
| 3842 | ret = __iw_softap_ap_stats(dev, info, wrqu, extra); |
| 3843 | vos_ssr_unprotect(__func__); |
| 3844 | |
| 3845 | return ret; |
| 3846 | } |
| 3847 | |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 3848 | /** |
| 3849 | * __iw_softap_get_three() - return three value to upper layer. |
| 3850 | * |
| 3851 | * @dev: pointer of net_device of this wireless card |
| 3852 | * @info: meta data about Request sent |
| 3853 | * @wrqu: include request info |
| 3854 | * @extra: buf used for in/out |
| 3855 | * |
| 3856 | * Return: execute result |
| 3857 | */ |
| 3858 | static int __iw_softap_get_three(struct net_device *dev, |
| 3859 | struct iw_request_info *info, |
| 3860 | union iwreq_data *wrqu, char *extra) |
| 3861 | { |
| 3862 | uint32_t *value = (uint32_t *)extra; |
| 3863 | uint32_t sub_cmd = value[0]; |
| 3864 | int ret = 0; /* success */ |
| 3865 | |
| 3866 | hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3867 | |
| 3868 | switch (sub_cmd) { |
| 3869 | case QCSAP_IOCTL_GET_TSF: |
| 3870 | ret = hdd_indicate_tsf(padapter, value, 3); |
| 3871 | break; |
| 3872 | default: |
| 3873 | hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd); |
| 3874 | break; |
| 3875 | } |
| 3876 | return ret; |
| 3877 | } |
| 3878 | |
| 3879 | |
| 3880 | /** |
| 3881 | * iw_softap_get_three() - return three value to upper layer. |
| 3882 | * |
| 3883 | * @dev: pointer of net_device of this wireless card |
| 3884 | * @info: meta data about Request sent |
| 3885 | * @wrqu: include request info |
| 3886 | * @extra: buf used for in/Output |
| 3887 | * |
| 3888 | * Return: execute result |
| 3889 | */ |
| 3890 | static int iw_softap_get_three(struct net_device *dev, |
| 3891 | struct iw_request_info *info, |
| 3892 | union iwreq_data *wrqu, char *extra) |
| 3893 | { |
| 3894 | int ret; |
| 3895 | |
| 3896 | vos_ssr_protect(__func__); |
| 3897 | ret = __iw_softap_get_three(dev, info, wrqu, extra); |
| 3898 | vos_ssr_unprotect(__func__); |
| 3899 | |
| 3900 | return ret; |
| 3901 | } |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3902 | static int __iw_softap_set_channel_range(struct net_device *dev, |
| 3903 | struct iw_request_info *info, |
| 3904 | union iwreq_data *wrqu, char *extra) |
| 3905 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3906 | hdd_adapter_t *pHostapdAdapter; |
| 3907 | tHalHandle hHal; |
| 3908 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3909 | int *value = (int *)extra; |
| 3910 | int startChannel = value[0]; |
| 3911 | int endChannel = value[1]; |
| 3912 | int band = value[2]; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 3913 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3914 | int ret = 0; /* success */ |
| 3915 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3916 | ENTER(); |
| 3917 | |
Hanumantha Reddy Pothula | bcb1abf | 2015-10-28 00:21:00 +0530 | [diff] [blame] | 3918 | if (!capable(CAP_NET_ADMIN)) |
| 3919 | { |
| 3920 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3921 | FL("permission check failed")); |
| 3922 | return -EPERM; |
| 3923 | } |
| 3924 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3925 | pHostapdAdapter = (netdev_priv(dev)); |
| 3926 | if (NULL == pHostapdAdapter) |
| 3927 | { |
| 3928 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3929 | "%s: Adapter is NULL",__func__); |
| 3930 | return -EINVAL; |
| 3931 | } |
| 3932 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 3933 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3934 | if (0 != ret) |
| 3935 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3936 | return ret; |
| 3937 | } |
| 3938 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 3939 | if (NULL == hHal) |
| 3940 | { |
| 3941 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3942 | "%s: Hal Context is NULL",__func__); |
| 3943 | return -EINVAL; |
| 3944 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3945 | status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band); |
| 3946 | if(status != VOS_STATUS_SUCCESS) |
| 3947 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3948 | hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3949 | startChannel,endChannel, band); |
| 3950 | ret = -EINVAL; |
| 3951 | } |
Gopichand Nakkala | f7e53c5 | 2013-01-07 14:52:52 -0800 | [diff] [blame] | 3952 | |
| 3953 | pHddCtx->is_dynamic_channel_range_set = 1; |
| 3954 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3955 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3956 | return ret; |
| 3957 | } |
| 3958 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 3959 | static int iw_softap_set_channel_range(struct net_device *dev, |
| 3960 | struct iw_request_info *info, |
| 3961 | union iwreq_data *wrqu, char *extra) |
| 3962 | { |
| 3963 | int ret; |
| 3964 | |
| 3965 | vos_ssr_protect(__func__); |
| 3966 | ret = __iw_softap_set_channel_range(dev, info, wrqu, extra); |
| 3967 | vos_ssr_unprotect(__func__); |
| 3968 | |
| 3969 | return ret; |
| 3970 | } |
| 3971 | |
| 3972 | |
| 3973 | int __iw_softap_get_channel_list(struct net_device *dev, |
| 3974 | struct iw_request_info *info, |
| 3975 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3976 | { |
| 3977 | v_U32_t num_channels = 0; |
| 3978 | v_U8_t i = 0; |
| 3979 | v_U8_t bandStartChannel = RF_CHAN_1; |
| 3980 | v_U8_t bandEndChannel = RF_CHAN_165; |
| 3981 | v_U32_t temp_num_channels = 0; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3982 | hdd_adapter_t *pHostapdAdapter; |
| 3983 | tHalHandle hHal; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3984 | v_REGDOMAIN_t domainIdCurrentSoftap; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3985 | tpChannelListInfo channel_list = (tpChannelListInfo) extra; |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 3986 | eCsrBand curBand = eCSR_BAND_ALL; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3987 | hdd_context_t *pHddCtx; |
| 3988 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3989 | |
| 3990 | ENTER(); |
| 3991 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 3992 | pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3993 | if (NULL == pHostapdAdapter) |
| 3994 | { |
| 3995 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3996 | "%s: Adapter is NULL",__func__); |
| 3997 | return -EINVAL; |
| 3998 | } |
| 3999 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4000 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4001 | if (0 != ret) |
| 4002 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4003 | return ret; |
| 4004 | } |
| 4005 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
| 4006 | if (NULL == hHal) |
| 4007 | { |
| 4008 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4009 | "%s: Hal Context is NULL",__func__); |
| 4010 | return -EINVAL; |
| 4011 | } |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 4012 | if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand)) |
| 4013 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4014 | hddLog(LOGE,FL("not able get the current frequency band")); |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 4015 | return -EIO; |
| 4016 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4017 | wrqu->data.length = sizeof(tChannelListInfo); |
| 4018 | ENTER(); |
| 4019 | |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 4020 | if (eCSR_BAND_24 == curBand) |
| 4021 | { |
| 4022 | bandStartChannel = RF_CHAN_1; |
| 4023 | bandEndChannel = RF_CHAN_14; |
| 4024 | } |
| 4025 | else if (eCSR_BAND_5G == curBand) |
| 4026 | { |
| 4027 | bandStartChannel = RF_CHAN_36; |
| 4028 | bandEndChannel = RF_CHAN_165; |
| 4029 | } |
| 4030 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4031 | hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, " |
Gopichand Nakkala | 29d0019 | 2013-06-20 19:03:52 +0530 | [diff] [blame] | 4032 | "bandEndChannel = %hu "), curBand, |
Madan Mohan Koyyalamudi | bb7b43a | 2012-10-11 14:55:09 -0700 | [diff] [blame] | 4033 | bandStartChannel, bandEndChannel ); |
| 4034 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4035 | for( i = bandStartChannel; i <= bandEndChannel; i++ ) |
| 4036 | { |
| 4037 | if( NV_CHANNEL_ENABLE == regChannels[i].enabled ) |
| 4038 | { |
| 4039 | channel_list->channels[num_channels] = rfChannels[i].channelNum; |
| 4040 | num_channels++; |
| 4041 | } |
| 4042 | } |
| 4043 | |
| 4044 | /* remove indoor channels if the domain is FCC, channels 36 - 48 */ |
| 4045 | |
| 4046 | temp_num_channels = num_channels; |
| 4047 | |
| 4048 | if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap)) |
| 4049 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 4050 | hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 4051 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4052 | } |
| 4053 | |
Agarwal Ashish | 7b557c0 | 2014-07-02 12:32:39 +0530 | [diff] [blame] | 4054 | if(REGDOMAIN_FCC == domainIdCurrentSoftap && |
| 4055 | pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4056 | { |
| 4057 | for(i = 0; i < temp_num_channels; i++) |
| 4058 | { |
| 4059 | |
| 4060 | if((channel_list->channels[i] > 35) && |
| 4061 | (channel_list->channels[i] < 49)) |
| 4062 | { |
| 4063 | vos_mem_move(&channel_list->channels[i], |
| 4064 | &channel_list->channels[i+1], |
| 4065 | temp_num_channels - (i-1)); |
| 4066 | num_channels--; |
| 4067 | temp_num_channels--; |
| 4068 | i--; |
| 4069 | } |
| 4070 | } |
| 4071 | } |
| 4072 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4073 | hddLog(LOG1,FL(" number of channels %d"), num_channels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4074 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4075 | channel_list->num_channels = num_channels; |
| 4076 | EXIT(); |
| 4077 | |
| 4078 | return 0; |
| 4079 | } |
| 4080 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 4081 | int iw_softap_get_channel_list(struct net_device *dev, |
| 4082 | struct iw_request_info *info, |
| 4083 | union iwreq_data *wrqu, char *extra) |
| 4084 | { |
| 4085 | int ret; |
| 4086 | |
| 4087 | vos_ssr_protect(__func__); |
| 4088 | ret = __iw_softap_get_channel_list(dev, info, wrqu, extra); |
| 4089 | vos_ssr_unprotect(__func__); |
| 4090 | |
| 4091 | return ret; |
| 4092 | } |
| 4093 | |
| 4094 | static |
| 4095 | int __iw_get_genie(struct net_device *dev, |
| 4096 | struct iw_request_info *info, |
| 4097 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4098 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4099 | hdd_adapter_t *pHostapdAdapter; |
| 4100 | hdd_context_t *pHddCtx; |
| 4101 | v_CONTEXT_t pVosContext; |
Manjeet Singh | 0fc1271 | 2016-08-02 19:08:02 +0530 | [diff] [blame] | 4102 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4103 | v_U32_t length = DOT11F_IE_RSN_MAX_LEN; |
| 4104 | v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN]; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4105 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4106 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4107 | ENTER(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4108 | |
| 4109 | pHostapdAdapter = (netdev_priv(dev)); |
| 4110 | if (NULL == pHostapdAdapter) |
| 4111 | { |
| 4112 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4113 | "%s: Adapter is NULL",__func__); |
| 4114 | return -EINVAL; |
| 4115 | } |
| 4116 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4117 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4118 | if (0 != ret) |
| 4119 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4120 | return ret; |
| 4121 | } |
| 4122 | pVosContext = pHddCtx->pvosContext; |
| 4123 | if (NULL == pVosContext) |
| 4124 | { |
| 4125 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4126 | "%s: vos context is not valid ",__func__); |
| 4127 | return -EINVAL; |
| 4128 | } |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4129 | hddLog(LOG1,FL("getGEN_IE ioctl")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4130 | // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.) |
| 4131 | status = WLANSap_getstationIE_information(pVosContext, |
| 4132 | &length, |
| 4133 | genIeBytes); |
Manjeet Singh | 0fc1271 | 2016-08-02 19:08:02 +0530 | [diff] [blame] | 4134 | |
| 4135 | if (VOS_STATUS_SUCCESS != status) { |
| 4136 | hddLog(LOGE, FL("failed to get sta ies")); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4137 | return -EFAULT; |
| 4138 | } |
Manjeet Singh | 0fc1271 | 2016-08-02 19:08:02 +0530 | [diff] [blame] | 4139 | |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4140 | wrqu->data.length = length; |
Manjeet Singh | 0fc1271 | 2016-08-02 19:08:02 +0530 | [diff] [blame] | 4141 | if (length > DOT11F_IE_RSN_MAX_LEN) { |
| 4142 | hddLog(LOGE, |
| 4143 | FL("invalid buffer length length:%d"), length); |
| 4144 | return -E2BIG; |
| 4145 | } |
| 4146 | |
| 4147 | vos_mem_copy(extra, genIeBytes, length); |
| 4148 | |
| 4149 | hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length); |
| 4150 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4151 | EXIT(); |
| 4152 | return 0; |
| 4153 | } |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 4154 | |
| 4155 | static |
| 4156 | int iw_get_genie(struct net_device *dev, |
| 4157 | struct iw_request_info *info, |
| 4158 | union iwreq_data *wrqu, char *extra) |
| 4159 | { |
| 4160 | int ret; |
| 4161 | |
| 4162 | vos_ssr_protect(__func__); |
| 4163 | ret = __iw_get_genie(dev, info, wrqu, extra); |
| 4164 | vos_ssr_unprotect(__func__); |
| 4165 | |
| 4166 | return ret; |
| 4167 | } |
| 4168 | |
| 4169 | static |
| 4170 | int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev, |
| 4171 | struct iw_request_info *info, |
| 4172 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4173 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4174 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4175 | sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4176 | hdd_ap_ctx_t *pHddApCtx; |
| 4177 | hdd_context_t *pHddCtx; |
| 4178 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4180 | ENTER(); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4181 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4182 | pHostapdAdapter = (netdev_priv(dev)); |
| 4183 | if (NULL == pHostapdAdapter) |
| 4184 | { |
| 4185 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4186 | "%s: Adapter is NULL",__func__); |
| 4187 | return -EINVAL; |
| 4188 | } |
| 4189 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4190 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4191 | if (0 != ret) |
| 4192 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4193 | return ret; |
| 4194 | } |
| 4195 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 4196 | if (NULL == pHddApCtx) |
| 4197 | { |
| 4198 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4199 | "%s: AP context is NULL",__func__); |
| 4200 | return -EINVAL; |
| 4201 | } |
| 4202 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4203 | hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl")); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4204 | memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs)); |
| 4205 | |
| 4206 | WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen; |
| 4207 | vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE, |
| 4208 | pHddApCtx->WPSPBCProbeReq.probeReqIE, |
| 4209 | WPSPBCProbeReqIEs.probeReqIELen); |
| 4210 | vos_mem_copy(&WPSPBCProbeReqIEs.macaddr, |
| 4211 | pHddApCtx->WPSPBCProbeReq.peerMacAddr, |
| 4212 | sizeof(v_MACADDR_t)); |
| 4213 | if (copy_to_user(wrqu->data.pointer, |
| 4214 | (void *)&WPSPBCProbeReqIEs, |
| 4215 | sizeof(WPSPBCProbeReqIEs))) |
| 4216 | { |
| 4217 | hddLog(LOG1, "%s: failed to copy data to user buffer", __func__); |
| 4218 | return -EFAULT; |
| 4219 | } |
| 4220 | wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4221 | hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR), |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4222 | MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4223 | up(&pHddApCtx->semWpsPBCOverlapInd); |
| 4224 | EXIT(); |
| 4225 | return 0; |
| 4226 | } |
| 4227 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 4228 | static |
| 4229 | int iw_get_WPSPBCProbeReqIEs(struct net_device *dev, |
| 4230 | struct iw_request_info *info, |
| 4231 | union iwreq_data *wrqu, char *extra) |
| 4232 | { |
| 4233 | int ret; |
| 4234 | |
| 4235 | vos_ssr_protect(__func__); |
| 4236 | ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra); |
| 4237 | vos_ssr_unprotect(__func__); |
| 4238 | |
| 4239 | return ret; |
| 4240 | } |
| 4241 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4242 | /**--------------------------------------------------------------------------- |
| 4243 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4244 | \brief __iw_set_auth_hostap() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4245 | This function sets the auth type received from the wpa_supplicant. |
| 4246 | |
| 4247 | \param - dev - Pointer to the net device. |
| 4248 | - info - Pointer to the iw_request_info. |
| 4249 | - wrqu - Pointer to the iwreq_data. |
| 4250 | - extra - Pointer to the data. |
| 4251 | \return - 0 for success, non zero for failure |
| 4252 | |
| 4253 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4254 | int __iw_set_auth_hostap(struct net_device *dev, |
| 4255 | struct iw_request_info *info, |
| 4256 | union iwreq_data *wrqu,char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4257 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4258 | hdd_adapter_t *pAdapter; |
| 4259 | hdd_context_t *pHddCtx; |
| 4260 | hdd_wext_state_t *pWextState; |
| 4261 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4263 | ENTER(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4264 | |
| 4265 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4266 | if (NULL == pAdapter) |
| 4267 | { |
| 4268 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4269 | "%s: Adapter is NULL",__func__); |
| 4270 | return -EINVAL; |
| 4271 | } |
| 4272 | |
| 4273 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4274 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4275 | if (0 != ret) |
| 4276 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4277 | return ret; |
| 4278 | } |
| 4279 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4280 | if (NULL == pWextState) |
| 4281 | { |
| 4282 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4283 | "%s: pWextState is NULL",__func__); |
| 4284 | return -EINVAL; |
| 4285 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4286 | switch(wrqu->param.flags & IW_AUTH_INDEX) |
| 4287 | { |
| 4288 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 4289 | { |
| 4290 | if(wrqu->param.value) { |
| 4291 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 4292 | "Counter Measure started %d", wrqu->param.value); |
| 4293 | pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4294 | } |
| 4295 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4296 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 4297 | "Counter Measure stopped=%d", wrqu->param.value); |
| 4298 | pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED; |
| 4299 | } |
| 4300 | |
| 4301 | hdd_softap_tkip_mic_fail_counter_measure(pAdapter, |
| 4302 | wrqu->param.value); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4303 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4304 | break; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4305 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4306 | default: |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4307 | |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4308 | hddLog(LOGW, "%s called with unsupported auth type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4309 | wrqu->param.flags & IW_AUTH_INDEX); |
| 4310 | break; |
| 4311 | } |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4312 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4313 | EXIT(); |
| 4314 | return 0; |
| 4315 | } |
| 4316 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4317 | int iw_set_auth_hostap(struct net_device *dev, |
| 4318 | struct iw_request_info *info, |
| 4319 | union iwreq_data *wrqu,char *extra) |
| 4320 | { |
| 4321 | int ret; |
| 4322 | |
| 4323 | vos_ssr_protect(__func__); |
| 4324 | ret = __iw_set_auth_hostap(dev, info, wrqu, extra); |
| 4325 | vos_ssr_unprotect(__func__); |
| 4326 | |
| 4327 | return ret; |
| 4328 | } |
| 4329 | |
| 4330 | static int __iw_set_ap_encodeext(struct net_device *dev, |
| 4331 | struct iw_request_info *info, |
| 4332 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4333 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4334 | hdd_adapter_t *pHostapdAdapter; |
| 4335 | v_CONTEXT_t pVosContext; |
| 4336 | hdd_context_t *pHddCtx; |
| 4337 | hdd_ap_ctx_t *pHddApCtx; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4338 | int retval = 0; |
| 4339 | VOS_STATUS vstatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4340 | struct iw_encode_ext *ext = (struct iw_encode_ext*)extra; |
| 4341 | v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 4342 | int key_index; |
| 4343 | struct iw_point *encoding = &wrqu->encoding; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4344 | tCsrRoamSetKey setKey; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4345 | // tCsrRoamRemoveKey RemoveKey; |
| 4346 | int i; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4347 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4348 | ENTER(); |
| 4349 | pHostapdAdapter = (netdev_priv(dev)); |
| 4350 | if (NULL == pHostapdAdapter) |
| 4351 | { |
| 4352 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4353 | "%s: Adapter is NULL",__func__); |
| 4354 | return -EINVAL; |
| 4355 | } |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4356 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4357 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4358 | retval = wlan_hdd_validate_context(pHddCtx); |
| 4359 | if (0 != retval) |
| 4360 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4361 | return retval; |
| 4362 | } |
| 4363 | pVosContext = pHddCtx->pvosContext; |
| 4364 | if (NULL == pVosContext) |
| 4365 | { |
| 4366 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4367 | "%s: pVosContext is NULL",__func__); |
| 4368 | return -EINVAL; |
| 4369 | } |
| 4370 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 4371 | if (NULL == pHddApCtx) |
| 4372 | { |
| 4373 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4374 | "%s: AP Context is NULL",__func__); |
| 4375 | return -EINVAL; |
| 4376 | } |
| 4377 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4378 | key_index = encoding->flags & IW_ENCODE_INDEX; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4379 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4380 | if(key_index > 0) { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4381 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4382 | /*Convert from 1-based to 0-based keying*/ |
| 4383 | key_index--; |
| 4384 | } |
Ashish Kumar Dhanotiya | 2855c95 | 2018-01-02 19:52:26 +0530 | [diff] [blame] | 4385 | if(!ext->key_len || ext->key_len > CSR_MAX_KEY_LEN) { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4386 | #if 0 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4387 | /*Set the encrytion type to NONE*/ |
| 4388 | #if 0 |
| 4389 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 4390 | #endif |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4391 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4392 | RemoveKey.keyId = key_index; |
| 4393 | if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 4394 | /*Key direction for group is RX only*/ |
| 4395 | vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 4396 | } |
| 4397 | else { |
| 4398 | vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 4399 | } |
| 4400 | switch(ext->alg) |
| 4401 | { |
| 4402 | case IW_ENCODE_ALG_NONE: |
| 4403 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 4404 | break; |
| 4405 | case IW_ENCODE_ALG_WEP: |
| 4406 | RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104; |
| 4407 | break; |
| 4408 | case IW_ENCODE_ALG_TKIP: |
| 4409 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4410 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4411 | case IW_ENCODE_ALG_CCMP: |
| 4412 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 4413 | break; |
| 4414 | default: |
| 4415 | RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 4416 | break; |
| 4417 | } |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4418 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Remove key cipher_alg:%d key_len%d *pEncryptionType :%d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4419 | __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4420 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4421 | __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4422 | ); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4423 | vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey); |
| 4424 | if ( vstatus != VOS_STATUS_SUCCESS ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4425 | { |
| 4426 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d", |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4427 | __LINE__, vstatus ); |
| 4428 | retval = -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4429 | } |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4430 | #endif |
Ashish Kumar Dhanotiya | 2855c95 | 2018-01-02 19:52:26 +0530 | [diff] [blame] | 4431 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4432 | |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4433 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4434 | |
| 4435 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 4436 | |
| 4437 | setKey.keyId = key_index; |
| 4438 | setKey.keyLength = ext->key_len; |
| 4439 | |
Ashish Kumar Dhanotiya | 2855c95 | 2018-01-02 19:52:26 +0530 | [diff] [blame] | 4440 | vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4441 | |
| 4442 | if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { |
| 4443 | /*Key direction for group is RX only*/ |
| 4444 | setKey.keyDirection = eSIR_RX_ONLY; |
| 4445 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 4446 | } |
| 4447 | else { |
| 4448 | |
| 4449 | setKey.keyDirection = eSIR_TX_RX; |
| 4450 | vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 4451 | } |
| 4452 | if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) |
| 4453 | { |
| 4454 | setKey.keyDirection = eSIR_TX_DEFAULT; |
| 4455 | vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN); |
| 4456 | } |
| 4457 | |
| 4458 | /*For supplicant pae role is zero*/ |
| 4459 | setKey.paeRole = 0; |
| 4460 | |
| 4461 | switch(ext->alg) |
| 4462 | { |
| 4463 | case IW_ENCODE_ALG_NONE: |
| 4464 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 4465 | break; |
| 4466 | |
| 4467 | case IW_ENCODE_ALG_WEP: |
| 4468 | setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104; |
| 4469 | pHddApCtx->uPrivacy = 1; |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4470 | hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4471 | break; |
| 4472 | |
| 4473 | case IW_ENCODE_ALG_TKIP: |
| 4474 | { |
| 4475 | v_U8_t *pKey = &setKey.Key[0]; |
| 4476 | |
| 4477 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 4478 | |
| 4479 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 4480 | |
| 4481 | /*Supplicant sends the 32bytes key in this order |
| 4482 | |
| 4483 | |--------------|----------|----------| |
| 4484 | | Tk1 |TX-MIC | RX Mic | |
| 4485 | |--------------|----------|----------| |
| 4486 | <---16bytes---><--8bytes--><--8bytes--> |
| 4487 | |
| 4488 | */ |
| 4489 | /*Sme expects the 32 bytes key to be in the below order |
| 4490 | |
| 4491 | |--------------|----------|----------| |
| 4492 | | Tk1 |RX-MIC | TX Mic | |
| 4493 | |--------------|----------|----------| |
| 4494 | <---16bytes---><--8bytes--><--8bytes--> |
| 4495 | */ |
| 4496 | /* Copy the Temporal Key 1 (TK1) */ |
| 4497 | vos_mem_copy(pKey,ext->key,16); |
| 4498 | |
| 4499 | /*Copy the rx mic first*/ |
| 4500 | vos_mem_copy(&pKey[16],&ext->key[24],8); |
| 4501 | |
| 4502 | /*Copy the tx mic */ |
| 4503 | vos_mem_copy(&pKey[24],&ext->key[16],8); |
| 4504 | |
| 4505 | } |
| 4506 | break; |
| 4507 | |
| 4508 | case IW_ENCODE_ALG_CCMP: |
| 4509 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 4510 | break; |
| 4511 | |
| 4512 | default: |
| 4513 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 4514 | break; |
| 4515 | } |
| 4516 | |
| 4517 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 4518 | ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4519 | setKey.keyId); |
| 4520 | for(i=0; i< ext->key_len; i++) |
| 4521 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4522 | ("%02x"), setKey.Key[i]); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4523 | |
| 4524 | vstatus = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 4525 | if ( vstatus != VOS_STATUS_SUCCESS ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4526 | { |
| 4527 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4528 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus ); |
| 4529 | retval = -EINVAL; |
| 4530 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4531 | |
| 4532 | EXIT(); |
| 4533 | return retval; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4534 | } |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4535 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4536 | static int iw_set_ap_encodeext(struct net_device *dev, |
| 4537 | struct iw_request_info *info, |
| 4538 | union iwreq_data *wrqu, char *extra) |
| 4539 | { |
| 4540 | int ret; |
| 4541 | |
| 4542 | vos_ssr_protect(__func__); |
| 4543 | ret = __iw_set_ap_encodeext(dev, info, wrqu, extra); |
| 4544 | vos_ssr_unprotect(__func__); |
| 4545 | |
| 4546 | return ret; |
| 4547 | } |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4548 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 4549 | static int __iw_set_ap_mlme(struct net_device *dev, |
| 4550 | struct iw_request_info *info, |
| 4551 | union iwreq_data *wrqu, |
| 4552 | char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4553 | { |
| 4554 | #if 0 |
| 4555 | hdd_adapter_t *pAdapter = (netdev_priv(dev)); |
| 4556 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 4557 | |
| 4558 | ENTER(); |
| 4559 | |
| 4560 | //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED |
| 4561 | switch (mlme->cmd) { |
| 4562 | case IW_MLME_DISASSOC: |
| 4563 | case IW_MLME_DEAUTH: |
| 4564 | hddLog(LOG1, "Station disassociate"); |
| 4565 | if( pAdapter->conn_info.connState == eConnectionState_Associated ) |
| 4566 | { |
| 4567 | eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 4568 | |
| 4569 | if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE ) |
| 4570 | reason = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 4571 | |
| 4572 | status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason); |
| 4573 | |
| 4574 | //clear all the reason codes |
| 4575 | if (status != 0) |
| 4576 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4577 | hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4578 | } |
| 4579 | |
| 4580 | netif_stop_queue(dev); |
| 4581 | netif_carrier_off(dev); |
| 4582 | } |
| 4583 | else |
| 4584 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4585 | hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4586 | } |
| 4587 | default: |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4588 | hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4589 | return -EINVAL; |
| 4590 | }//end of switch |
| 4591 | EXIT(); |
| 4592 | #endif |
| 4593 | return 0; |
| 4594 | // return status; |
| 4595 | } |
| 4596 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 4597 | static int iw_set_ap_mlme(struct net_device *dev, |
| 4598 | struct iw_request_info *info, |
| 4599 | union iwreq_data *wrqu, |
| 4600 | char *extra) |
| 4601 | { |
| 4602 | int ret; |
| 4603 | |
| 4604 | vos_ssr_protect(__func__); |
| 4605 | ret = __iw_set_ap_mlme(dev, info, wrqu, extra); |
| 4606 | vos_ssr_unprotect(__func__); |
| 4607 | |
| 4608 | return ret; |
| 4609 | } |
| 4610 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4611 | static int __iw_get_ap_rts_threshold(struct net_device *dev, |
| 4612 | struct iw_request_info *info, |
| 4613 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4614 | { |
| 4615 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 4616 | v_U32_t status = 0; |
| 4617 | |
| 4618 | status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu); |
| 4619 | |
| 4620 | return status; |
| 4621 | } |
| 4622 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4623 | static int iw_get_ap_rts_threshold(struct net_device *dev, |
| 4624 | struct iw_request_info *info, |
| 4625 | union iwreq_data *wrqu, char *extra) |
| 4626 | { |
| 4627 | int ret; |
| 4628 | |
| 4629 | vos_ssr_protect(__func__); |
| 4630 | ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra); |
| 4631 | vos_ssr_unprotect(__func__); |
| 4632 | |
| 4633 | return ret; |
| 4634 | } |
| 4635 | |
| 4636 | static int __iw_get_ap_frag_threshold(struct net_device *dev, |
| 4637 | struct iw_request_info *info, |
| 4638 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4639 | { |
| 4640 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
| 4641 | v_U32_t status = 0; |
| 4642 | |
| 4643 | status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu); |
| 4644 | |
| 4645 | return status; |
| 4646 | } |
| 4647 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4648 | static int iw_get_ap_frag_threshold(struct net_device *dev, |
| 4649 | struct iw_request_info *info, |
| 4650 | union iwreq_data *wrqu, char *extra) |
| 4651 | { |
| 4652 | int ret; |
| 4653 | |
| 4654 | vos_ssr_protect(__func__); |
| 4655 | ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra); |
| 4656 | vos_ssr_unprotect(__func__); |
| 4657 | |
| 4658 | return ret; |
| 4659 | } |
| 4660 | |
| 4661 | static int __iw_get_ap_freq(struct net_device *dev, |
| 4662 | struct iw_request_info *info, |
| 4663 | struct iw_freq *fwrq, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4664 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4665 | v_U32_t status = FALSE, channel = 0, freq = 0; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4666 | hdd_adapter_t *pHostapdAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4667 | tHalHandle hHal; |
| 4668 | hdd_hostapd_state_t *pHostapdState; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4669 | hdd_ap_ctx_t *pHddApCtx; |
| 4670 | hdd_context_t *pHddCtx; |
| 4671 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4672 | |
| 4673 | ENTER(); |
| 4674 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4675 | pHostapdAdapter = (netdev_priv(dev)); |
| 4676 | if (NULL == pHostapdAdapter) |
| 4677 | { |
| 4678 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4679 | "%s: Adapter is NULL",__func__); |
| 4680 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4681 | } |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4682 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4683 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4684 | if (0 != ret) |
| 4685 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4686 | return ret; |
| 4687 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4688 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4689 | if (NULL == pHostapdState) |
| 4690 | { |
| 4691 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4692 | "%s: pHostapdState is NULL",__func__); |
| 4693 | return -EINVAL; |
| 4694 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4695 | hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4696 | if (NULL == hHal) |
| 4697 | { |
| 4698 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4699 | "%s: Hal Context is NULL",__func__); |
| 4700 | return -EINVAL; |
| 4701 | } |
| 4702 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter); |
| 4703 | if (NULL == pHddApCtx) |
| 4704 | { |
| 4705 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4706 | "%s: AP context is NULL",__func__); |
| 4707 | return -EINVAL; |
| 4708 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4709 | if(pHostapdState->bssState == BSS_STOP ) |
| 4710 | { |
| 4711 | if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel) |
| 4712 | != eHAL_STATUS_SUCCESS) |
| 4713 | { |
c_hpothu | ffdb527 | 2013-10-02 16:42:35 +0530 | [diff] [blame] | 4714 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4715 | FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4716 | return -EIO; |
| 4717 | } |
| 4718 | else |
| 4719 | { |
| 4720 | status = hdd_wlan_get_freq(channel, &freq); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 4721 | if( 0 == status) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4722 | { |
| 4723 | /* Set Exponent parameter as 6 (MHZ) in struct iw_freq |
| 4724 | * iwlist & iwconfig command shows frequency into proper |
| 4725 | * format (2.412 GHz instead of 246.2 MHz)*/ |
| 4726 | fwrq->m = freq; |
| 4727 | fwrq->e = MHZ; |
| 4728 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4729 | } |
| 4730 | } |
| 4731 | else |
| 4732 | { |
| 4733 | channel = pHddApCtx->operatingChannel; |
| 4734 | status = hdd_wlan_get_freq(channel, &freq); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 4735 | if( 0 == status) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4736 | { |
| 4737 | /* Set Exponent parameter as 6 (MHZ) in struct iw_freq |
| 4738 | * iwlist & iwconfig command shows frequency into proper |
| 4739 | * format (2.412 GHz instead of 246.2 MHz)*/ |
| 4740 | fwrq->m = freq; |
| 4741 | fwrq->e = MHZ; |
| 4742 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4743 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4744 | |
| 4745 | EXIT(); |
| 4746 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4747 | } |
| 4748 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4749 | static int iw_get_ap_freq(struct net_device *dev, |
| 4750 | struct iw_request_info *info, |
| 4751 | struct iw_freq *fwrq, char *extra) |
| 4752 | { |
| 4753 | int ret; |
| 4754 | |
| 4755 | vos_ssr_protect(__func__); |
| 4756 | ret = __iw_get_ap_freq(dev, info, fwrq, extra); |
| 4757 | vos_ssr_unprotect(__func__); |
| 4758 | |
| 4759 | return ret; |
| 4760 | } |
| 4761 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 4762 | static int __iw_softap_stopbss(struct net_device *dev, |
| 4763 | struct iw_request_info *info, |
| 4764 | union iwreq_data *wrqu, |
| 4765 | char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4766 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4767 | hdd_adapter_t *pHostapdAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4768 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 4769 | hdd_context_t *pHddCtx = NULL; |
| 4770 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4771 | ENTER(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4772 | pHostapdAdapter = (netdev_priv(dev)); |
| 4773 | if (NULL == pHostapdAdapter) |
| 4774 | { |
| 4775 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4776 | "%s: Adapter is NULL",__func__); |
| 4777 | return -EINVAL; |
| 4778 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 4779 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4780 | status = wlan_hdd_validate_context(pHddCtx); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 4781 | if (0 != status) { |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 4782 | return status; |
| 4783 | } |
| 4784 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4785 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4786 | { |
Hanumanth Reddy Pothula | 74ba68c | 2018-06-22 17:52:09 +0530 | [diff] [blame] | 4787 | hdd_hostapd_state_t *pHostapdState = |
| 4788 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 4789 | |
| 4790 | vos_event_reset(&pHostapdState->vosEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4791 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) ) |
| 4792 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4793 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4794 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4795 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4796 | { |
| 4797 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4798 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4799 | VOS_ASSERT(0); |
| 4800 | } |
| 4801 | } |
| 4802 | clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 4803 | wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4804 | } |
| 4805 | EXIT(); |
| 4806 | return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY; |
| 4807 | } |
| 4808 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 4809 | static int iw_softap_stopbss(struct net_device *dev, |
| 4810 | struct iw_request_info *info, |
| 4811 | union iwreq_data *wrqu, |
| 4812 | char *extra) |
| 4813 | { |
| 4814 | int ret; |
| 4815 | |
| 4816 | vos_ssr_protect(__func__); |
| 4817 | ret = __iw_softap_stopbss(dev, info, wrqu, extra); |
| 4818 | vos_ssr_unprotect(__func__); |
| 4819 | |
| 4820 | return ret; |
| 4821 | } |
| 4822 | |
| 4823 | static int __iw_softap_version(struct net_device *dev, |
| 4824 | struct iw_request_info *info, |
| 4825 | union iwreq_data *wrqu, |
| 4826 | char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4827 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4828 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4829 | hdd_context_t *pHddCtx; |
| 4830 | int ret = 0; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4831 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4832 | ENTER(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4833 | pHostapdAdapter = (netdev_priv(dev)); |
| 4834 | if (NULL == pHostapdAdapter) |
| 4835 | { |
| 4836 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4837 | "%s: Adapter is NULL",__func__); |
| 4838 | return -EINVAL; |
| 4839 | } |
| 4840 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4841 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4842 | if (0 != ret) |
| 4843 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4844 | return ret; |
| 4845 | } |
Jeff Johnson | 4824d4c | 2013-02-12 14:23:57 -0800 | [diff] [blame] | 4846 | hdd_wlan_get_version(pHostapdAdapter, wrqu, extra); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4847 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4848 | return 0; |
| 4849 | } |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4850 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 4851 | static int iw_softap_version(struct net_device *dev, |
| 4852 | struct iw_request_info *info, |
| 4853 | union iwreq_data *wrqu, |
| 4854 | char *extra) |
| 4855 | { |
| 4856 | int ret; |
| 4857 | |
| 4858 | vos_ssr_protect(__func__); |
| 4859 | ret = __iw_softap_version(dev, info, wrqu, extra); |
| 4860 | vos_ssr_unprotect(__func__); |
| 4861 | |
| 4862 | return ret; |
| 4863 | } |
| 4864 | |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4865 | int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len) |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4866 | { |
| 4867 | v_U8_t i; |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 4868 | int len = 0; |
| 4869 | const char sta_info_header[] = "staId staAddress\n"; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4870 | v_CONTEXT_t pVosContext; |
| 4871 | hdd_context_t *pHddCtx; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 4872 | ptSapContext pSapCtx = NULL; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4873 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4874 | ENTER(); |
| 4875 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4876 | if (NULL == pAdapter) |
| 4877 | { |
| 4878 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4879 | "%s: Adapter is NULL",__func__); |
| 4880 | return -EINVAL; |
| 4881 | } |
| 4882 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4883 | if (0 != wlan_hdd_validate_context(pHddCtx)) |
| 4884 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4885 | return VOS_STATUS_E_FAULT; |
| 4886 | } |
| 4887 | pVosContext = pHddCtx->pvosContext; |
| 4888 | if (NULL == pVosContext) |
| 4889 | { |
| 4890 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4891 | "%s: VOS context is not valid",__func__); |
| 4892 | return VOS_STATUS_E_FAULT; |
| 4893 | } |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 4894 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4895 | if(pSapCtx == NULL) |
| 4896 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 4897 | VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 4898 | FL("psapCtx is NULL")); |
| 4899 | return VOS_STATUS_E_FAULT; |
| 4900 | } |
| 4901 | |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4902 | len = snprintf(pBuf, buf_len, sta_info_header); |
| 4903 | if (len >= buf_len) { |
| 4904 | hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len); |
| 4905 | return -E2BIG; |
| 4906 | } |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 4907 | pBuf += len; |
| 4908 | buf_len -= len; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4909 | |
| 4910 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 4911 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 4912 | if(pSapCtx->aStaInfo[i].isUsed) |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4913 | { |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 4914 | len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n", |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 4915 | pSapCtx->aStaInfo[i].ucSTAId, |
| 4916 | pSapCtx->aStaInfo[i].macAddrSTA.bytes[0], |
| 4917 | pSapCtx->aStaInfo[i].macAddrSTA.bytes[1], |
| 4918 | pSapCtx->aStaInfo[i].macAddrSTA.bytes[2], |
| 4919 | pSapCtx->aStaInfo[i].macAddrSTA.bytes[3], |
| 4920 | pSapCtx->aStaInfo[i].macAddrSTA.bytes[4], |
| 4921 | pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]); |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4922 | if (len >= buf_len) { |
| 4923 | hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len); |
| 4924 | return -E2BIG; |
| 4925 | } |
Yathish Hanumapuradoddi Shivanna | 7b65940 | 2013-03-25 14:12:32 -0700 | [diff] [blame] | 4926 | pBuf += len; |
| 4927 | buf_len -= len; |
| 4928 | } |
| 4929 | if(WE_GET_STA_INFO_SIZE > buf_len) |
| 4930 | { |
| 4931 | break; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4932 | } |
| 4933 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4934 | EXIT(); |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4935 | return 0; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4936 | } |
| 4937 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 4938 | static int __iw_softap_get_sta_info(struct net_device *dev, |
| 4939 | struct iw_request_info *info, |
| 4940 | union iwreq_data *wrqu, |
| 4941 | char *extra) |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4942 | { |
| 4943 | hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev)); |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4944 | int ret; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4945 | ENTER(); |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4946 | ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO); |
| 4947 | if (ret) { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4948 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__); |
Chandrasekaran, Manishekar | ac8122b | 2016-04-22 16:42:41 +0530 | [diff] [blame] | 4949 | return ret; |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 4950 | } |
| 4951 | wrqu->data.length = strlen(extra); |
| 4952 | EXIT(); |
| 4953 | return 0; |
| 4954 | } |
| 4955 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 4956 | static int iw_softap_get_sta_info(struct net_device *dev, |
| 4957 | struct iw_request_info *info, |
| 4958 | union iwreq_data *wrqu, |
| 4959 | char *extra) |
| 4960 | { |
| 4961 | int ret; |
| 4962 | |
| 4963 | vos_ssr_protect(__func__); |
| 4964 | ret = __iw_softap_get_sta_info(dev, info, wrqu, extra); |
| 4965 | vos_ssr_unprotect(__func__); |
| 4966 | |
| 4967 | return ret; |
| 4968 | } |
| 4969 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 4970 | static int __iw_set_ap_genie(struct net_device *dev, |
| 4971 | struct iw_request_info *info, |
| 4972 | union iwreq_data *wrqu, char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4973 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4974 | |
| 4975 | hdd_adapter_t *pHostapdAdapter; |
| 4976 | hdd_context_t *pHddCtx; |
| 4977 | v_CONTEXT_t pVosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4978 | eHalStatus halStatus= eHAL_STATUS_SUCCESS; |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 4979 | u_int8_t *genie = (u_int8_t *)extra; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4980 | int ret = 0; |
| 4981 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4982 | ENTER(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4983 | pHostapdAdapter = (netdev_priv(dev)); |
| 4984 | if (NULL == pHostapdAdapter) |
| 4985 | { |
| 4986 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4987 | "%s: Adapter is NULL",__func__); |
| 4988 | return -EINVAL; |
| 4989 | } |
| 4990 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
| 4991 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4992 | if (0 != ret) |
| 4993 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 4994 | return ret; |
| 4995 | } |
| 4996 | pVosContext = pHddCtx->pvosContext; |
| 4997 | if (NULL == pVosContext) |
| 4998 | { |
| 4999 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5000 | "%s: VOS Context is NULL",__func__); |
| 5001 | return -EINVAL; |
| 5002 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5003 | if(!wrqu->data.length) |
| 5004 | { |
| 5005 | EXIT(); |
| 5006 | return 0; |
| 5007 | } |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 5008 | |
Nishank Aggarwal | bd8e0f6 | 2017-02-10 15:48:13 +0530 | [diff] [blame] | 5009 | if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN) |
| 5010 | { |
| 5011 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5012 | "%s: WPARSN Ie input length is more than max[%d]", __func__, |
| 5013 | wrqu->data.length); |
| 5014 | return -EINVAL; |
| 5015 | } |
| 5016 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5017 | switch (genie[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5018 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5019 | case DOT11F_EID_WPA: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5020 | case DOT11F_EID_RSN: |
| 5021 | if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0) |
| 5022 | { |
| 5023 | hdd_softap_Deregister_BC_STA(pHostapdAdapter); |
| 5024 | hdd_softap_Register_BC_STA(pHostapdAdapter, 1); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5025 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5026 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1; |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 5027 | halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5028 | break; |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5029 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5030 | default: |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5031 | hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5032 | halStatus = 0; |
| 5033 | } |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5034 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5035 | EXIT(); |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5036 | return halStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5037 | } |
| 5038 | |
Mahesh A Saptasagar | f176a86 | 2014-08-20 21:25:21 +0530 | [diff] [blame] | 5039 | static int iw_set_ap_genie(struct net_device *dev, |
| 5040 | struct iw_request_info *info, |
| 5041 | union iwreq_data *wrqu, char *extra) |
| 5042 | { |
| 5043 | int ret; |
| 5044 | |
| 5045 | vos_ssr_protect(__func__); |
| 5046 | ret = __iw_set_ap_genie(dev, info, wrqu, extra); |
| 5047 | vos_ssr_unprotect(__func__); |
| 5048 | |
| 5049 | return ret; |
| 5050 | } |
| 5051 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5052 | static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid) |
| 5053 | { |
| 5054 | eHalStatus hstatus; |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5055 | int ret; |
| 5056 | void *cookie; |
| 5057 | struct hdd_request *request; |
| 5058 | struct stats_class_a_ctx *priv; |
| 5059 | static const struct hdd_request_params params = { |
| 5060 | .priv_size = sizeof(*priv), |
| 5061 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 5062 | }; |
| 5063 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5064 | |
| 5065 | if (NULL == pAdapter) |
| 5066 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5067 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5068 | return VOS_STATUS_E_FAULT; |
| 5069 | } |
| 5070 | |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5071 | request = hdd_request_alloc(¶ms); |
| 5072 | if (!request) { |
| 5073 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure")); |
| 5074 | return VOS_STATUS_E_NOMEM; |
| 5075 | } |
| 5076 | cookie = hdd_request_cookie(request); |
| 5077 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5078 | hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5079 | eCSR_HDD, |
| 5080 | SME_GLOBAL_CLASSA_STATS, |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5081 | hdd_get_class_a_statistics_cb, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5082 | 0, // not periodic |
| 5083 | FALSE, //non-cached results |
| 5084 | staid, |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5085 | cookie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5086 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 5087 | { |
| 5088 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5089 | "%s: Unable to retrieve statistics for link speed", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5090 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5091 | } |
| 5092 | else |
| 5093 | { |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5094 | ret = hdd_request_wait_for_response(request); |
| 5095 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5096 | { |
| 5097 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5098 | FL("SME timeout while retrieving link speed")); |
| 5099 | } |
| 5100 | else |
| 5101 | { |
| 5102 | priv = hdd_request_priv(request); |
| 5103 | pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5104 | } |
| 5105 | } |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 5106 | |
Hanumanth Reddy Pothula | c76f065 | 2018-04-06 17:31:52 +0530 | [diff] [blame] | 5107 | /* |
| 5108 | * either we never sent a request, we sent a request and received a |
| 5109 | * response or we sent a request and timed out. Regardless we are |
| 5110 | * done with the request. |
| 5111 | */ |
| 5112 | hdd_request_put(request); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 5113 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5114 | return VOS_STATUS_SUCCESS; |
| 5115 | } |
| 5116 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 5117 | int __iw_get_softap_linkspeed(struct net_device *dev, |
| 5118 | struct iw_request_info *info, |
| 5119 | union iwreq_data *wrqu, |
| 5120 | char *extra) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5121 | |
| 5122 | { |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5123 | hdd_adapter_t *pHostapdAdapter; |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5124 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5125 | char *pLinkSpeed = (char*)extra; |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 5126 | char *pmacAddress; |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5127 | v_U32_t link_speed; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5128 | unsigned short staId; |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5129 | int len = sizeof(v_U32_t)+1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5130 | v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE]; |
Arif Hussain | a957184 | 2014-01-15 16:43:41 -0800 | [diff] [blame] | 5131 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5132 | int rc, valid; |
| 5133 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5134 | ENTER(); |
| 5135 | |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5136 | pHostapdAdapter = (netdev_priv(dev)); |
| 5137 | if (NULL == pHostapdAdapter) |
| 5138 | { |
| 5139 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5140 | "%s: Adapter is NULL",__func__); |
| 5141 | return -EINVAL; |
| 5142 | } |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5143 | pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5144 | valid = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5145 | if (0 != valid) |
| 5146 | { |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5147 | return valid; |
| 5148 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5149 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5150 | hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length); |
Arif Hussain | a957184 | 2014-01-15 16:43:41 -0800 | [diff] [blame] | 5151 | |
| 5152 | if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1) |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 5153 | { |
Arif Hussain | a957184 | 2014-01-15 16:43:41 -0800 | [diff] [blame] | 5154 | pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL); |
| 5155 | if (NULL == pmacAddress) { |
| 5156 | hddLog(LOG1, "unable to allocate memory"); |
| 5157 | return -ENOMEM; |
| 5158 | } |
| 5159 | if (copy_from_user((void *)pmacAddress, |
| 5160 | wrqu->data.pointer, MAC_ADDRESS_STR_LEN)) |
| 5161 | { |
| 5162 | hddLog(LOG1, "%s: failed to copy data to user buffer", __func__); |
| 5163 | kfree(pmacAddress); |
| 5164 | return -EFAULT; |
| 5165 | } |
Manjeet Singh | a373974 | 2016-05-03 16:21:46 +0530 | [diff] [blame] | 5166 | pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0'; |
Arif Hussain | a957184 | 2014-01-15 16:43:41 -0800 | [diff] [blame] | 5167 | |
| 5168 | status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress ); |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 5169 | kfree(pmacAddress); |
Arif Hussain | a957184 | 2014-01-15 16:43:41 -0800 | [diff] [blame] | 5170 | |
| 5171 | if (!VOS_IS_STATUS_SUCCESS(status )) |
| 5172 | { |
| 5173 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed")); |
| 5174 | } |
Arif Hussain | ed66764 | 2013-10-27 23:01:14 -0700 | [diff] [blame] | 5175 | } |
Kiet Lam | 6158985 | 2013-09-19 17:10:58 +0530 | [diff] [blame] | 5176 | /* If no mac address is passed and/or its length is less than 17, |
Madan Mohan Koyyalamudi | e68989b | 2013-09-10 01:15:19 +0530 | [diff] [blame] | 5177 | * link speed for first connected client will be returned. |
| 5178 | */ |
Arif Hussain | a957184 | 2014-01-15 16:43:41 -0800 | [diff] [blame] | 5179 | if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status )) |
Madan Mohan Koyyalamudi | e68989b | 2013-09-10 01:15:19 +0530 | [diff] [blame] | 5180 | { |
| 5181 | status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId)); |
| 5182 | } |
| 5183 | else |
| 5184 | { |
| 5185 | status = hdd_softap_GetStaId(pHostapdAdapter, |
| 5186 | (v_MACADDR_t *)macAddress, (void *)(&staId)); |
| 5187 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5188 | |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5189 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5190 | { |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5191 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5192 | link_speed = 0; |
| 5193 | } |
| 5194 | else |
| 5195 | { |
| 5196 | status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId); |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5197 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5198 | if (!VOS_IS_STATUS_SUCCESS(status )) |
| 5199 | { |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5200 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5201 | return -EINVAL; |
| 5202 | } |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5203 | |
| 5204 | WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext, |
| 5205 | staId, &link_speed); |
| 5206 | |
| 5207 | link_speed = link_speed / 10; |
| 5208 | |
| 5209 | if (0 == link_speed) |
| 5210 | { |
| 5211 | /* The linkspeed returned by HAL is in units of 500kbps. |
| 5212 | * converting it to mbps. |
| 5213 | * This is required to support legacy firmware which does |
| 5214 | * not return link capacity. |
| 5215 | */ |
| 5216 | link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2; |
| 5217 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5218 | } |
| 5219 | |
| 5220 | wrqu->data.length = len; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 5221 | rc = snprintf(pLinkSpeed, len, "%u", link_speed); |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5222 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5223 | if ((rc < 0) || (rc >= len)) |
| 5224 | { |
| 5225 | // encoding or length error? |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5226 | hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5227 | return -EIO; |
| 5228 | } |
| 5229 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5230 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5231 | return 0; |
| 5232 | } |
| 5233 | |
Mahesh A Saptasagar | 69e944e | 2014-08-13 20:01:27 +0530 | [diff] [blame] | 5234 | int iw_get_softap_linkspeed(struct net_device *dev, |
| 5235 | struct iw_request_info *info, |
| 5236 | union iwreq_data *wrqu, |
| 5237 | char *extra) |
| 5238 | { |
| 5239 | int ret; |
| 5240 | |
| 5241 | vos_ssr_protect(__func__); |
| 5242 | ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra); |
| 5243 | vos_ssr_unprotect(__func__); |
| 5244 | |
| 5245 | return ret; |
| 5246 | } |
| 5247 | |
| 5248 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5249 | static const iw_handler hostapd_handler[] = |
| 5250 | { |
| 5251 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
| 5252 | (iw_handler) NULL, /* SIOCGIWNAME */ |
| 5253 | (iw_handler) NULL, /* SIOCSIWNWID */ |
| 5254 | (iw_handler) NULL, /* SIOCGIWNWID */ |
| 5255 | (iw_handler) NULL, /* SIOCSIWFREQ */ |
| 5256 | (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */ |
| 5257 | (iw_handler) NULL, /* SIOCSIWMODE */ |
Ashish Kumar Dhanotiya | 6b484a8 | 2018-04-24 15:11:55 +0530 | [diff] [blame] | 5258 | (iw_handler) NULL, /* SIOCGIWMODE */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5259 | (iw_handler) NULL, /* SIOCSIWSENS */ |
| 5260 | (iw_handler) NULL, /* SIOCGIWSENS */ |
| 5261 | (iw_handler) NULL, /* SIOCSIWRANGE */ |
| 5262 | (iw_handler) NULL, /* SIOCGIWRANGE */ |
| 5263 | (iw_handler) NULL, /* SIOCSIWPRIV */ |
| 5264 | (iw_handler) NULL, /* SIOCGIWPRIV */ |
| 5265 | (iw_handler) NULL, /* SIOCSIWSTATS */ |
| 5266 | (iw_handler) NULL, /* SIOCGIWSTATS */ |
| 5267 | (iw_handler) NULL, /* SIOCSIWSPY */ |
| 5268 | (iw_handler) NULL, /* SIOCGIWSPY */ |
| 5269 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ |
| 5270 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ |
| 5271 | (iw_handler) NULL, /* SIOCSIWAP */ |
| 5272 | (iw_handler) NULL, /* SIOCGIWAP */ |
| 5273 | (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */ |
| 5274 | (iw_handler) NULL, /* SIOCGIWAPLIST */ |
| 5275 | (iw_handler) NULL, /* SIOCSIWSCAN */ |
| 5276 | (iw_handler) NULL, /* SIOCGIWSCAN */ |
| 5277 | (iw_handler) NULL, /* SIOCSIWESSID */ |
| 5278 | (iw_handler) NULL, /* SIOCGIWESSID */ |
| 5279 | (iw_handler) NULL, /* SIOCSIWNICKN */ |
| 5280 | (iw_handler) NULL, /* SIOCGIWNICKN */ |
| 5281 | (iw_handler) NULL, /* -- hole -- */ |
| 5282 | (iw_handler) NULL, /* -- hole -- */ |
| 5283 | (iw_handler) NULL, /* SIOCSIWRATE */ |
| 5284 | (iw_handler) NULL, /* SIOCGIWRATE */ |
| 5285 | (iw_handler) NULL, /* SIOCSIWRTS */ |
| 5286 | (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */ |
| 5287 | (iw_handler) NULL, /* SIOCSIWFRAG */ |
| 5288 | (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */ |
| 5289 | (iw_handler) NULL, /* SIOCSIWTXPOW */ |
| 5290 | (iw_handler) NULL, /* SIOCGIWTXPOW */ |
| 5291 | (iw_handler) NULL, /* SIOCSIWRETRY */ |
| 5292 | (iw_handler) NULL, /* SIOCGIWRETRY */ |
| 5293 | (iw_handler) NULL, /* SIOCSIWENCODE */ |
| 5294 | (iw_handler) NULL, /* SIOCGIWENCODE */ |
| 5295 | (iw_handler) NULL, /* SIOCSIWPOWER */ |
| 5296 | (iw_handler) NULL, /* SIOCGIWPOWER */ |
| 5297 | (iw_handler) NULL, /* -- hole -- */ |
| 5298 | (iw_handler) NULL, /* -- hole -- */ |
| 5299 | (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */ |
| 5300 | (iw_handler) NULL, /* SIOCGIWGENIE */ |
| 5301 | (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */ |
| 5302 | (iw_handler) NULL, /* SIOCGIWAUTH */ |
| 5303 | (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */ |
| 5304 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ |
| 5305 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
| 5306 | }; |
| 5307 | |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 5308 | /* |
| 5309 | * Note that the following ioctls were defined with semantics which |
| 5310 | * cannot be handled by the "iwpriv" userspace application and hence |
| 5311 | * they are not included in the hostapd_private_args array |
| 5312 | * QCSAP_IOCTL_ASSOC_STA_MACADDR |
| 5313 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5314 | |
| 5315 | static const struct iw_priv_args hostapd_private_args[] = { |
| 5316 | { QCSAP_IOCTL_SETPARAM, |
| 5317 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" }, |
| 5318 | { QCSAP_IOCTL_SETPARAM, |
| 5319 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" }, |
Mahesh A Saptasagar | 786266f | 2015-10-08 19:09:21 +0530 | [diff] [blame] | 5320 | { QCSAP_PARAM_GET_FRAME_LOGS, |
| 5321 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5322 | { QCSAP_PARAM_MAX_ASSOC, |
| 5323 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" }, |
| 5324 | { QCSAP_PARAM_HIDE_SSID, |
| 5325 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" }, |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5326 | { QCSAP_PARAM_SET_MC_RATE, |
| 5327 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" }, |
Hanumantha Reddy Pothula | 0490027 | 2016-01-08 15:39:47 +0530 | [diff] [blame] | 5328 | { QCSAP_PARAM_SET_PROXIMITY, |
| 5329 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" }, |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 5330 | { QCSAP_PARAM_CAP_TSF, |
| 5331 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" }, |
Abhishek Singh | 0260509 | 2017-10-25 14:06:12 +0530 | [diff] [blame] | 5332 | {QCSAP_PARAM_SET_CHANNEL_CHANGE, |
| 5333 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"}, |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 5334 | { QCSAP_PARAM_SET_WOWL, |
| 5335 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5336 | { QCSAP_IOCTL_GETPARAM, |
| 5337 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 5338 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" }, |
| 5339 | { QCSAP_IOCTL_GETPARAM, 0, |
| 5340 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" }, |
| 5341 | { QCSAP_PARAM_MAX_ASSOC, 0, |
| 5342 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" }, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 5343 | { QCSAP_PARAM_GET_WLAN_DBG, 0, |
| 5344 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" }, |
| 5345 | { QCSAP_PARAM_AUTO_CHANNEL, 0, |
| 5346 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" }, |
Ravi Shankar Upadrasta | bb216bb | 2014-06-13 14:40:24 +0530 | [diff] [blame] | 5347 | { QCSAP_PARAM_SET_AUTO_CHANNEL, |
| 5348 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5349 | { QCSAP_PARAM_CLR_ACL, 0, |
| 5350 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" }, |
| 5351 | { QCSAP_PARAM_ACL_MODE, |
| 5352 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5353 | { QCSAP_IOCTL_GET_STAWPAIE, |
Manjeet Singh | 0fc1271 | 2016-08-02 19:08:02 +0530 | [diff] [blame] | 5354 | 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5355 | { QCSAP_IOCTL_STOPBSS, |
| 5356 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" }, |
| 5357 | { QCSAP_IOCTL_VERSION, 0, |
| 5358 | IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" }, |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 5359 | { QCSAP_IOCTL_GET_STA_INFO, 0, |
| 5360 | IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5361 | { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES, |
Arif Hussain | d443e33 | 2013-11-18 23:59:44 -0800 | [diff] [blame] | 5362 | IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5363 | { QCSAP_IOCTL_GET_CHANNEL, 0, |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 5364 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" }, |
Jeff Johnson | 224f370 | 2014-03-26 11:09:47 -0700 | [diff] [blame] | 5365 | { QCSAP_IOCTL_DISASSOC_STA, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5366 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" }, |
Girish Gowli | f376980 | 2014-06-16 21:17:16 +0530 | [diff] [blame] | 5367 | { QCSAP_IOCTL_AP_STATS, 0, |
| 5368 | IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" }, |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 5369 | /* handlers for main ioctl */ |
| 5370 | { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0, |
| 5371 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" }, |
| 5372 | #ifdef WLAN_FEATURE_TSF |
| 5373 | { QCSAP_IOCTL_GET_TSF, 0, |
| 5374 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 5375 | "get_tsf" }, |
| 5376 | #endif |
Bhargav Shah | 7f03b81 | 2015-08-21 11:17:32 +0530 | [diff] [blame] | 5377 | { QCSAP_IOCTL_GET_STATS, 0, |
| 5378 | IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"}, |
| 5379 | { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5380 | { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED, |
| 5381 | IW_PRIV_TYPE_CHAR | 18, |
Gopichand Nakkala | 8a2b144 | 2013-05-29 15:33:14 +0530 | [diff] [blame] | 5382 | IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5383 | |
| 5384 | { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE, |
| 5385 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" }, |
| 5386 | /* handlers for sub-ioctl */ |
| 5387 | { WE_SET_WLAN_DBG, |
| 5388 | IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, |
| 5389 | 0, |
| 5390 | "setwlandbg" }, |
| 5391 | |
| 5392 | /* handlers for main ioctl */ |
| 5393 | { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE, |
| 5394 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 5395 | 0, |
| 5396 | "" }, |
| 5397 | |
| 5398 | /* handlers for sub-ioctl */ |
| 5399 | { WE_LOG_DUMP_CMD, |
| 5400 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 5401 | 0, |
| 5402 | "dump" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5403 | { WE_P2P_NOA_CMD, |
| 5404 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 5405 | 0, |
| 5406 | "SetP2pPs" }, |
Madan Mohan Koyyalamudi | d5f04ca | 2012-11-06 15:51:26 -0800 | [diff] [blame] | 5407 | /* handlers for sub ioctl */ |
| 5408 | { |
| 5409 | WE_MCC_CONFIG_CREDENTIAL, |
| 5410 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 5411 | 0, |
| 5412 | "setMccCrdnl" }, |
| 5413 | |
| 5414 | /* handlers for sub ioctl */ |
| 5415 | { |
| 5416 | WE_MCC_CONFIG_PARAMS, |
| 5417 | IW_PRIV_TYPE_INT | MAX_VAR_ARGS, |
| 5418 | 0, |
| 5419 | "setMccConfig" }, |
| 5420 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5421 | /* handlers for main ioctl */ |
| 5422 | { QCSAP_IOCTL_MODIFY_ACL, |
| 5423 | IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8, |
| 5424 | 0, |
| 5425 | "modify_acl" }, |
| 5426 | |
| 5427 | /* handlers for main ioctl */ |
| 5428 | { QCSAP_IOCTL_GET_CHANNEL_LIST, |
| 5429 | 0, |
| 5430 | IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo), |
| 5431 | "getChannelList" }, |
| 5432 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5433 | /* handlers for main ioctl */ |
| 5434 | { QCSAP_IOCTL_SET_TX_POWER, |
| 5435 | IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1, |
| 5436 | 0, |
Madan Mohan Koyyalamudi | d12bf05 | 2012-11-27 19:07:55 +0530 | [diff] [blame] | 5437 | "setTxPower" }, |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 5438 | |
| 5439 | /* handlers for main ioctl */ |
| 5440 | { QCSAP_IOCTL_SET_MAX_TX_POWER, |
| 5441 | IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1, |
| 5442 | 0, |
| 5443 | "setTxMaxPower" }, |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 5444 | |
| 5445 | { QCSAP_IOCTL_DATAPATH_SNAP_SHOT, |
| 5446 | IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE, |
| 5447 | 0, |
| 5448 | "dataSnapshot" }, |
| 5449 | |
| 5450 | /* handlers for main ioctl */ |
| 5451 | { QCSAP_IOCTL_SET_TRAFFIC_MONITOR, |
| 5452 | IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1, |
| 5453 | 0, |
| 5454 | "setTrafficMon" }, |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 5455 | /* handlers for main ioctl */ |
| 5456 | { QCSAP_IOCTL_SET_CHAR_GET_NONE, |
| 5457 | IW_PRIV_TYPE_CHAR| 512, |
| 5458 | 0, |
| 5459 | "" }, |
| 5460 | |
| 5461 | /* handlers for sub-ioctl */ |
| 5462 | { WE_WOWL_ADD_PTRN, |
| 5463 | IW_PRIV_TYPE_CHAR| 512, |
| 5464 | 0, |
| 5465 | "wowlAddPtrn" }, |
| 5466 | |
| 5467 | { WE_WOWL_DEL_PTRN, |
| 5468 | IW_PRIV_TYPE_CHAR| 512, |
| 5469 | 0, |
| 5470 | "wowlDelPtrn" }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5471 | }; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5472 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5473 | static const iw_handler hostapd_private[] = { |
| 5474 | [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl |
Arun Khandavalli | 08bcafd | 2016-11-08 14:45:48 +0530 | [diff] [blame] | 5475 | [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl |
| 5476 | [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = |
| 5477 | iw_softap_setchar_getnone, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5478 | [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5479 | [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss |
| 5480 | [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version |
| 5481 | [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs, |
| 5482 | [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel, |
| 5483 | [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr, |
| 5484 | [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta, |
| 5485 | [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats, |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 5486 | [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three, |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 5487 | [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5488 | [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone, |
| 5489 | [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range, |
| 5490 | [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl, |
| 5491 | [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list, |
Gopichand Nakkala | 976e325 | 2013-01-03 15:45:56 -0800 | [diff] [blame] | 5492 | [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5493 | [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed, |
| 5494 | [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power, |
schang | 86c22c4 | 2013-03-13 18:41:24 -0700 | [diff] [blame] | 5495 | [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power, |
Madan Mohan Koyyalamudi | a96f544 | 2013-05-10 11:32:06 +0530 | [diff] [blame] | 5496 | [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot, |
Kiet Lam | bcf3852 | 2013-10-26 18:28:27 +0530 | [diff] [blame] | 5497 | [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor, |
Bhargav Shah | 7f03b81 | 2015-08-21 11:17:32 +0530 | [diff] [blame] | 5498 | [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats, |
| 5499 | [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5500 | }; |
| 5501 | const struct iw_handler_def hostapd_handler_def = { |
| 5502 | .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]), |
| 5503 | .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]), |
| 5504 | .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]), |
| 5505 | .standard = (iw_handler *)hostapd_handler, |
| 5506 | .private = (iw_handler *)hostapd_private, |
| 5507 | .private_args = hostapd_private_args, |
| 5508 | .get_wireless_stats = NULL, |
| 5509 | }; |
| 5510 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 5511 | struct net_device_ops net_ops_struct = { |
| 5512 | .ndo_open = hdd_hostapd_open, |
| 5513 | .ndo_stop = hdd_hostapd_stop, |
| 5514 | .ndo_uninit = hdd_hostapd_uninit, |
| 5515 | .ndo_start_xmit = hdd_softap_hard_start_xmit, |
| 5516 | .ndo_tx_timeout = hdd_softap_tx_timeout, |
| 5517 | .ndo_get_stats = hdd_softap_stats, |
| 5518 | .ndo_set_mac_address = hdd_hostapd_set_mac_address, |
| 5519 | .ndo_do_ioctl = hdd_hostapd_ioctl, |
| 5520 | .ndo_change_mtu = hdd_hostapd_change_mtu, |
| 5521 | .ndo_select_queue = hdd_hostapd_select_queue, |
| 5522 | }; |
| 5523 | #endif |
| 5524 | |
| 5525 | int hdd_set_hostapd(hdd_adapter_t *pAdapter) |
| 5526 | { |
| 5527 | return VOS_STATUS_SUCCESS; |
| 5528 | } |
| 5529 | |
| 5530 | void hdd_set_ap_ops( struct net_device *pWlanHostapdDev ) |
| 5531 | { |
| 5532 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 5533 | pWlanHostapdDev->netdev_ops = &net_ops_struct; |
| 5534 | #else |
| 5535 | pWlanHostapdDev->open = hdd_hostapd_open; |
| 5536 | pWlanHostapdDev->stop = hdd_hostapd_stop; |
| 5537 | pWlanHostapdDev->uninit = hdd_hostapd_uninit; |
| 5538 | pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit; |
| 5539 | pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout; |
| 5540 | pWlanHostapdDev->get_stats = hdd_softap_stats; |
| 5541 | pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address; |
| 5542 | pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl; |
| 5543 | #endif |
| 5544 | } |
| 5545 | |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5546 | VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init) |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5547 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5548 | hdd_hostapd_state_t * phostapdBuf; |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 5549 | #ifdef DHCP_SERVER_OFFLOAD |
| 5550 | hdd_dhcp_state_t *dhcp_status; |
| 5551 | #endif /* DHCP_SERVER_OFFLOAD */ |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 5552 | #ifdef MDNS_OFFLOAD |
| 5553 | hdd_mdns_state_t *mdns_status; |
| 5554 | #endif /* MDNS_OFFLOAD */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5555 | struct net_device *dev = pAdapter->dev; |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5556 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5557 | VOS_STATUS status; |
Hanumanth Reddy Pothula | b37ce86 | 2017-02-03 21:42:08 +0530 | [diff] [blame] | 5558 | hdd_config_t *ini_cfg; |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 5559 | #ifdef FEATURE_WLAN_CH_AVOID |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 5560 | v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS]; |
| 5561 | v_U16_t unsafeChannelCount; |
| 5562 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 5563 | |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5564 | if (pHddCtx->isLogpInProgress && !re_init) { |
Anand N Sunkad | 26d71b9 | 2014-12-24 18:08:22 +0530 | [diff] [blame] | 5565 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5566 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 5567 | status = VOS_STATUS_E_FAILURE; |
| 5568 | } |
| 5569 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5570 | ENTER(); |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 5571 | |
| 5572 | #ifdef SAP_AUTH_OFFLOAD |
| 5573 | if (pHddCtx->cfg_ini->enable_sap_auth_offload) |
Agrawal Ashish | 6773c90 | 2017-01-06 19:45:03 +0530 | [diff] [blame] | 5574 | { |
| 5575 | if (!hdd_set_sap_auth_offload(pAdapter, TRUE)) |
| 5576 | { |
| 5577 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5578 | FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP")); |
| 5579 | return VOS_STATUS_E_FAILURE; |
| 5580 | } |
| 5581 | } |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 5582 | #endif |
Agrawal Ashish | a8e8a72 | 2016-10-18 19:07:45 +0530 | [diff] [blame] | 5583 | |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 5584 | // Allocate the Wireless Extensions state structure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5585 | phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter ); |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 5586 | #ifdef DHCP_SERVER_OFFLOAD |
| 5587 | dhcp_status = &pAdapter->dhcp_status; |
| 5588 | #endif /* DHCP_SERVER_OFFLOAD */ |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 5589 | #ifdef MDNS_OFFLOAD |
| 5590 | mdns_status = &pAdapter->mdns_status; |
| 5591 | #endif /* MDNS_OFFLOAD */ |
Mahesh A Saptasagar | 153c466 | 2015-02-06 12:13:08 +0530 | [diff] [blame] | 5592 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 5593 | spin_lock_init(&pAdapter->sta_hash_lock); |
| 5594 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 5595 | |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5596 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
| 5597 | |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 5598 | #ifdef FEATURE_WLAN_CH_AVOID |
| 5599 | /* Get unsafe cahnnel list from cached location */ |
| 5600 | wcnss_get_wlan_unsafe_channel(unsafeChannelList, |
| 5601 | sizeof(unsafeChannelList), |
| 5602 | &unsafeChannelCount); |
| 5603 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5604 | "%s : Unsafe Channel count %d", |
| 5605 | __func__, unsafeChannelCount); |
Sushant Kaushik | 389e7f0 | 2014-06-11 19:56:10 +0530 | [diff] [blame] | 5606 | hdd_hostapd_update_unsafe_channel_list(pHddCtx, |
Leo Chang | 0b0e45a | 2013-12-15 15:18:55 -0800 | [diff] [blame] | 5607 | unsafeChannelList, |
| 5608 | unsafeChannelCount); |
| 5609 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 5610 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5611 | // Zero the memory. This zeros the profile structure. |
| 5612 | memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t)); |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 5613 | #ifdef DHCP_SERVER_OFFLOAD |
| 5614 | memset(dhcp_status, 0,sizeof(*dhcp_status)); |
| 5615 | #endif /* DHCP_SERVER_OFFLOAD */ |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 5616 | #ifdef MDNS_OFFLOAD |
| 5617 | memset(mdns_status, 0,sizeof(*mdns_status)); |
| 5618 | #endif /* MDNS_OFFLOAD */ |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 5619 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5620 | // Set up the pointer to the Wireless Extensions state structure |
| 5621 | // NOP |
| 5622 | status = hdd_set_hostapd(pAdapter); |
| 5623 | if(!VOS_IS_STATUS_SUCCESS(status)) { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5624 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5625 | return status; |
| 5626 | } |
| 5627 | |
| 5628 | status = vos_event_init(&phostapdBuf->vosEvent); |
| 5629 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 5630 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5631 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5632 | return status; |
| 5633 | } |
Abhishek Singh | 1a9dbcf | 2019-09-06 12:50:03 +0530 | [diff] [blame] | 5634 | status = vos_event_init(&phostapdBuf->sta_discon_event); |
| 5635 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 5636 | { |
| 5637 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ERROR: Hostapd HDD sta disassoc event init failed!!"); |
| 5638 | return status; |
| 5639 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 5640 | #ifdef DHCP_SERVER_OFFLOAD |
| 5641 | status = vos_event_init(&dhcp_status->vos_event); |
| 5642 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 5643 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!")); |
| 5644 | return status; |
| 5645 | } |
| 5646 | #endif /* DHCP_SERVER_OFFLOAD */ |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 5647 | #ifdef MDNS_OFFLOAD |
| 5648 | status = vos_event_init(&mdns_status->vos_event); |
| 5649 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 5650 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5651 | ("Hostapd HDD vos event init failed!!")); |
| 5652 | return status; |
| 5653 | } |
| 5654 | #endif /* MDNS_OFFLOAD */ |
| 5655 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5656 | sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1); |
| 5657 | |
| 5658 | // Register as a wireless device |
| 5659 | dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def; |
| 5660 | |
| 5661 | //Initialize the data path module |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5662 | status = hdd_softap_init_tx_rx(pAdapter, re_init); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5663 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 5664 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5665 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5666 | } |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 5667 | |
| 5668 | status = hdd_wmm_adapter_init( pAdapter ); |
| 5669 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 5670 | { |
| 5671 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5672 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 5673 | status, status ); |
| 5674 | goto error_wmm_init; |
| 5675 | } |
| 5676 | |
| 5677 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5678 | |
Hanumanth Reddy Pothula | b37ce86 | 2017-02-03 21:42:08 +0530 | [diff] [blame] | 5679 | ini_cfg = pHddCtx->cfg_ini; |
| 5680 | if (re_init && ini_cfg) { |
| 5681 | hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"), |
| 5682 | ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum, |
| 5683 | ini_cfg->apOperatingBand); |
| 5684 | WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5685 | ini_cfg->apStartChannelNum, |
| 5686 | ini_cfg->apEndChannelNum, |
| 5687 | ini_cfg->apOperatingBand); |
| 5688 | } |
| 5689 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 5690 | return status; |
| 5691 | |
| 5692 | error_wmm_init: |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5693 | hdd_softap_deinit_tx_rx(pAdapter, re_init); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5694 | EXIT(); |
| 5695 | return status; |
| 5696 | } |
| 5697 | |
| 5698 | hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name ) |
| 5699 | { |
| 5700 | struct net_device *pWlanHostapdDev = NULL; |
| 5701 | hdd_adapter_t *pHostapdAdapter = NULL; |
| 5702 | v_CONTEXT_t pVosContext= NULL; |
| 5703 | |
Anand N Sunkad | c34abbd | 2015-07-29 09:52:59 +0530 | [diff] [blame] | 5704 | pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, |
| 5705 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) |
| 5706 | NET_NAME_UNKNOWN, |
| 5707 | #endif |
| 5708 | ether_setup, NUM_TX_QUEUES); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5709 | if (pWlanHostapdDev != NULL) |
| 5710 | { |
| 5711 | pHostapdAdapter = netdev_priv(pWlanHostapdDev); |
| 5712 | |
| 5713 | //Init the net_device structure |
| 5714 | ether_setup(pWlanHostapdDev); |
| 5715 | |
| 5716 | //Initialize the adapter context to zeros. |
| 5717 | vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t )); |
| 5718 | pHostapdAdapter->dev = pWlanHostapdDev; |
| 5719 | pHostapdAdapter->pHddCtx = pHddCtx; |
| 5720 | pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 5721 | |
| 5722 | //Get the Global VOSS context. |
| 5723 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 5724 | //Save the adapter context in global context for future. |
| 5725 | ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter; |
| 5726 | |
| 5727 | //Init the net_device structure |
| 5728 | strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ); |
| 5729 | |
| 5730 | hdd_set_ap_ops( pHostapdAdapter->dev ); |
| 5731 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5732 | pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 5733 | pWlanHostapdDev->mtu = HDD_DEFAULT_MTU; |
| 5734 | |
| 5735 | vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr)); |
| 5736 | vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr)); |
| 5737 | |
| 5738 | pWlanHostapdDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5739 | pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ; |
| 5740 | pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 5741 | pHostapdAdapter->wdev.netdev = pWlanHostapdDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5742 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5743 | SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev); |
| 5744 | } |
| 5745 | return pHostapdAdapter; |
| 5746 | } |
| 5747 | |
| 5748 | VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 5749 | { |
| 5750 | struct net_device *dev = pAdapter->dev; |
| 5751 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5752 | |
| 5753 | ENTER(); |
| 5754 | |
| 5755 | if( rtnl_lock_held ) |
| 5756 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 5757 | if (strnchr(dev->name, strlen(dev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5758 | if( dev_alloc_name(dev, dev->name) < 0 ) |
| 5759 | { |
| 5760 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__); |
| 5761 | return VOS_STATUS_E_FAILURE; |
| 5762 | } |
| 5763 | } |
| 5764 | if (register_netdevice(dev)) |
| 5765 | { |
| 5766 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5767 | "%s:Failed:register_netdevice", __func__); |
| 5768 | return VOS_STATUS_E_FAILURE; |
| 5769 | } |
| 5770 | } |
| 5771 | else |
| 5772 | { |
| 5773 | if (register_netdev(dev)) |
| 5774 | { |
| 5775 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__); |
| 5776 | return VOS_STATUS_E_FAILURE; |
| 5777 | } |
| 5778 | } |
| 5779 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 5780 | |
| 5781 | EXIT(); |
| 5782 | return status; |
| 5783 | } |
| 5784 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 5785 | VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5786 | { |
| 5787 | ENTER(); |
| 5788 | |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5789 | hdd_softap_deinit_tx_rx(pAdapter, false); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5790 | |
| 5791 | /* if we are being called during driver unload, then the dev has already |
| 5792 | been invalidated. if we are being called at other times, then we can |
| 5793 | detatch the wireless device handlers */ |
| 5794 | if (pAdapter->dev) |
| 5795 | { |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 5796 | if (TRUE == rtnl_held) |
| 5797 | { |
| 5798 | pAdapter->dev->wireless_handlers = NULL; |
| 5799 | } |
| 5800 | else |
| 5801 | { |
| 5802 | rtnl_lock(); |
| 5803 | pAdapter->dev->wireless_handlers = NULL; |
| 5804 | rtnl_unlock(); |
| 5805 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5806 | } |
| 5807 | EXIT(); |
| 5808 | return 0; |
| 5809 | } |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5810 | |
| 5811 | /** |
| 5812 | * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication |
| 5813 | * to supplicant, if there any clients connected to SAP interface. |
| 5814 | * @adapter: sap adapter context |
| 5815 | * |
| 5816 | * Return: nothing |
| 5817 | */ |
| 5818 | void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter) |
| 5819 | { |
| 5820 | tSap_Event sap_event; |
| 5821 | int staId; |
| 5822 | hdd_context_t *hdd_ctx; |
| 5823 | v_CONTEXT_t vos_ctx; |
| 5824 | ptSapContext sap_ctx; |
| 5825 | |
| 5826 | ENTER(); |
| 5827 | |
| 5828 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5829 | if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) { |
| 5830 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5831 | "%s: HDD context is Null", __func__); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5832 | return; |
| 5833 | } |
| 5834 | |
| 5835 | vos_ctx = hdd_ctx->pvosContext; |
| 5836 | if (NULL == vos_ctx) { |
| 5837 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5838 | "%s: VOS context is not valid",__func__); |
| 5839 | return; |
| 5840 | } |
| 5841 | |
| 5842 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 5843 | if (!sap_ctx) { |
| 5844 | hddLog(LOGE, FL("invalid sap context")); |
| 5845 | return; |
| 5846 | } |
| 5847 | |
| 5848 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) { |
| 5849 | if (sap_ctx->aStaInfo[staId].isUsed) { |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 5850 | hddLog(LOG1, FL("staId: %d isUsed: %d %pK"), |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5851 | staId, sap_ctx->aStaInfo[staId].isUsed, |
| 5852 | sap_ctx); |
| 5853 | |
| 5854 | if (vos_is_macaddr_broadcast( |
| 5855 | &sap_ctx->aStaInfo[staId].macAddrSTA)) |
| 5856 | continue; |
| 5857 | |
| 5858 | sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT; |
| 5859 | vos_mem_copy( |
| 5860 | &sap_event.sapevt. |
| 5861 | sapStationDisassocCompleteEvent.staMac, |
| 5862 | &sap_ctx->aStaInfo[staId].macAddrSTA, |
| 5863 | sizeof(v_MACADDR_t)); |
| 5864 | sap_event.sapevt.sapStationDisassocCompleteEvent. |
| 5865 | reason = |
| 5866 | eSAP_MAC_INITATED_DISASSOC; |
| 5867 | sap_event.sapevt.sapStationDisassocCompleteEvent. |
| 5868 | statusCode = |
| 5869 | eSIR_SME_RESOURCES_UNAVAILABLE; |
| 5870 | hdd_hostapd_SAPEventCB(&sap_event, |
| 5871 | sap_ctx->pUsrContext); |
| 5872 | } |
| 5873 | } |
| 5874 | |
| 5875 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5876 | |
| 5877 | EXIT(); |
| 5878 | } |
| 5879 | |
| 5880 | /** |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5881 | * hdd_sap_destroy_timers() - Destroy sap timers |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5882 | * @adapter: sap adapter context |
| 5883 | * |
| 5884 | * Return: nothing |
| 5885 | */ |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5886 | void hdd_sap_destroy_timers(hdd_adapter_t *adapter) |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5887 | { |
| 5888 | hdd_context_t *hdd_ctx; |
| 5889 | v_CONTEXT_t vos_ctx; |
| 5890 | ptSapContext sap_ctx; |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5891 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5892 | |
| 5893 | ENTER(); |
| 5894 | |
| 5895 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5896 | if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) { |
| 5897 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5898 | "%s: HDD context is Null", __func__); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5899 | return; |
| 5900 | } |
| 5901 | |
| 5902 | vos_ctx = hdd_ctx->pvosContext; |
| 5903 | if (NULL == vos_ctx) { |
| 5904 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5905 | "%s: VOS context is not valid",__func__); |
| 5906 | return; |
| 5907 | } |
| 5908 | |
| 5909 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 5910 | if (!sap_ctx) { |
| 5911 | hddLog(LOGE, FL("invalid sap context")); |
| 5912 | return; |
| 5913 | } |
| 5914 | |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 5915 | if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) { |
| 5916 | status = vos_timer_stop(&sap_ctx->sap_HT2040_timer); |
| 5917 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 5918 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 5919 | FL("Failed to Stop HT20/40 timer")); |
| 5920 | } |
| 5921 | |
| 5922 | status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer); |
| 5923 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 5924 | VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, |
| 5925 | FL("Failed to Destroy HT20/40 timer")); |
| 5926 | |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 5927 | } |
Agrawal Ashish | 574b3e6 | 2017-02-09 18:58:34 +0530 | [diff] [blame] | 5928 | |
| 5929 | /** |
| 5930 | * hdd_force_scc_restart_sap - restart sap to forcer SCC |
| 5931 | * @adapter: hdd ap adapter |
| 5932 | * |
| 5933 | * hdd_force_scc_restart_sap will choose station channel and will |
| 5934 | * schedule work to restart the sap. |
| 5935 | * |
| 5936 | * Return - none |
| 5937 | */ |
| 5938 | void hdd_force_scc_restart_sap(hdd_adapter_t *adapter, |
| 5939 | hdd_context_t *hdd_ctx, tANI_U8 channelId) |
| 5940 | { |
| 5941 | if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) { |
| 5942 | return; |
| 5943 | } |
| 5944 | |
| 5945 | hddLog(LOG1, FL("Current operation channel %d"), |
| 5946 | adapter->sessionCtx.ap.operatingChannel); |
| 5947 | hddLog(LOG1, FL("STA channel is %d"), |
| 5948 | channelId); |
| 5949 | |
| 5950 | vos_flush_work( |
| 5951 | &hdd_ctx->sap_start_work); |
| 5952 | |
| 5953 | hddLog(LOGE, |
| 5954 | FL("Restarting SAP for force SCC ")); |
| 5955 | |
| 5956 | adapter->sessionCtx.ap.sapConfig.channel = channelId; |
| 5957 | |
| 5958 | if (hdd_ctx->cfg_ini->sap_internal_restart) { |
| 5959 | netif_tx_disable(adapter->dev); |
| 5960 | schedule_work(&hdd_ctx->sap_start_work); |
| 5961 | } else { |
| 5962 | hdd_hostapd_stop(adapter->dev); |
| 5963 | } |
| 5964 | return; |
| 5965 | } |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 5966 | |
| 5967 | /** |
| 5968 | * hdd_get_cache_stainfo() - get stainfo for the specified peer |
| 5969 | * @stainfo: array of station info |
| 5970 | * @mac_addr: mac address of requested peer |
| 5971 | * |
| 5972 | * This function find the stainfo for the peer with mac_addr |
| 5973 | * |
| 5974 | * Return: stainfo if found, NULL if not found |
| 5975 | */ |
| 5976 | struct hdd_cache_sta_info *hdd_get_cache_stainfo( |
| 5977 | struct hdd_cache_sta_info *astainfo, |
| 5978 | u8 *mac_addr) |
| 5979 | { |
| 5980 | struct hdd_cache_sta_info *stainfo = NULL; |
| 5981 | int i; |
| 5982 | |
| 5983 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
| 5984 | if (vos_mem_compare(&astainfo[i].macAddrSTA, |
| 5985 | mac_addr, |
| 5986 | HDD_MAC_ADDR_LEN)) { |
| 5987 | stainfo = &astainfo[i]; |
| 5988 | break; |
| 5989 | } |
| 5990 | } |
| 5991 | |
| 5992 | return stainfo; |
| 5993 | } |
| 5994 | |