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