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