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