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