blob: 9d5680a4f342ea0e09d8d6f004185925b0fa6a4f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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 Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
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 Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#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>
Jeff Johnson295189b2012-06-20 16:38:30 -070078#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070079#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053080#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081
Leo Chang0b0e45a2013-12-15 15:18:55 -080082#ifdef FEATURE_WLAN_CH_AVOID
83#include "wcnss_wlan.h"
84#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053085#include "wlan_hdd_trace.h"
86#include "vos_types.h"
87#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080088
Jeff Johnson295189b2012-06-20 16:38:30 -070089#define IS_UP(_dev) \
90 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
91#define IS_UP_AUTO(_ic) \
92 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
93#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070094#define WE_GET_STA_INFO_SIZE 30
95/* WEXT limition: MAX allowed buf len for any *
96 * IW_PRIV_TYPE_CHAR is 2Kbytes *
97 */
98#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -070099
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530100#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700101
Leo Chang0b0e45a2013-12-15 15:18:55 -0800102#ifdef FEATURE_WLAN_CH_AVOID
103/* Channle/Freqency table */
104extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
105safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
106{
107 /*CH , SAFE, default safe */
108 {1 , VOS_TRUE}, //RF_CHAN_1,
109 {2 , VOS_TRUE}, //RF_CHAN_2,
110 {3 , VOS_TRUE}, //RF_CHAN_3,
111 {4 , VOS_TRUE}, //RF_CHAN_4,
112 {5 , VOS_TRUE}, //RF_CHAN_5,
113 {6 , VOS_TRUE}, //RF_CHAN_6,
114 {7 , VOS_TRUE}, //RF_CHAN_7,
115 {8 , VOS_TRUE}, //RF_CHAN_8,
116 {9 , VOS_TRUE}, //RF_CHAN_9,
117 {10 , VOS_TRUE}, //RF_CHAN_10,
118 {11 , VOS_TRUE}, //RF_CHAN_11,
119 {12 , VOS_TRUE}, //RF_CHAN_12,
120 {13 , VOS_TRUE}, //RF_CHAN_13,
121 {14 , VOS_TRUE}, //RF_CHAN_14,
122 {240, VOS_TRUE}, //RF_CHAN_240,
123 {244, VOS_TRUE}, //RF_CHAN_244,
124 {248, VOS_TRUE}, //RF_CHAN_248,
125 {252, VOS_TRUE}, //RF_CHAN_252,
126 {208, VOS_TRUE}, //RF_CHAN_208,
127 {212, VOS_TRUE}, //RF_CHAN_212,
128 {216, VOS_TRUE}, //RF_CHAN_216,
129 {36 , VOS_TRUE}, //RF_CHAN_36,
130 {40 , VOS_TRUE}, //RF_CHAN_40,
131 {44 , VOS_TRUE}, //RF_CHAN_44,
132 {48 , VOS_TRUE}, //RF_CHAN_48,
133 {52 , VOS_TRUE}, //RF_CHAN_52,
134 {56 , VOS_TRUE}, //RF_CHAN_56,
135 {60 , VOS_TRUE}, //RF_CHAN_60,
136 {64 , VOS_TRUE}, //RF_CHAN_64,
137 {100, VOS_TRUE}, //RF_CHAN_100,
138 {104, VOS_TRUE}, //RF_CHAN_104,
139 {108, VOS_TRUE}, //RF_CHAN_108,
140 {112, VOS_TRUE}, //RF_CHAN_112,
141 {116, VOS_TRUE}, //RF_CHAN_116,
142 {120, VOS_TRUE}, //RF_CHAN_120,
143 {124, VOS_TRUE}, //RF_CHAN_124,
144 {128, VOS_TRUE}, //RF_CHAN_128,
145 {132, VOS_TRUE}, //RF_CHAN_132,
146 {136, VOS_TRUE}, //RF_CHAN_136,
147 {140, VOS_TRUE}, //RF_CHAN_140,
148 {149, VOS_TRUE}, //RF_CHAN_149,
149 {153, VOS_TRUE}, //RF_CHAN_153,
150 {157, VOS_TRUE}, //RF_CHAN_157,
151 {161, VOS_TRUE}, //RF_CHAN_161,
152 {165, VOS_TRUE}, //RF_CHAN_165,
153};
154#endif /* FEATURE_WLAN_CH_AVOID */
155
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530156/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 * Function definitions
158 *-------------------------------------------------------------------------*/
159/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530160
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530161 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530162
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 This is called in response to ifconfig up
164
165 \param - dev Pointer to net_device structure
166
167 \return - 0 for success non-zero for failure
168
169 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530170int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700171{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
173
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 ENTER();
175
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530176 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
177 {
178 //WMM_INIT OR BSS_START not completed
179 hddLog( LOGW, "Ignore hostadp open request");
180 EXIT();
181 return 0;
182 }
183
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530184 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
185 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 //Turn ON carrier state
187 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530188 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530189 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530191
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 EXIT();
193 return 0;
194}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530195
196int hdd_hostapd_open (struct net_device *dev)
197{
198 int ret;
199
200 vos_ssr_protect(__func__);
201 ret = __hdd_hostapd_open(dev);
202 vos_ssr_unprotect(__func__);
203
204 return ret;
205}
206
Jeff Johnson295189b2012-06-20 16:38:30 -0700207/**---------------------------------------------------------------------------
208
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530209 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700210
211 This is called in response to ifconfig down
212
213 \param - dev Pointer to net_device structure
214
215 \return - 0 for success non-zero for failure
216
217 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530218int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700219{
220 ENTER();
221
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530222 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530223 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530224 //Stop all tx queues
225 netif_tx_disable(dev);
226
227 //Turn OFF carrier state
228 netif_carrier_off(dev);
229 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700230
231 EXIT();
232 return 0;
233}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530234
235int hdd_hostapd_stop (struct net_device *dev)
236{
237 int ret;
238
239 vos_ssr_protect(__func__);
240 ret = __hdd_hostapd_stop(dev);
241 vos_ssr_unprotect(__func__);
242
243 return ret;
244}
245
Jeff Johnson295189b2012-06-20 16:38:30 -0700246/**---------------------------------------------------------------------------
247
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530248 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700249
250 This is called during the netdev unregister to uninitialize all data
251associated with the device
252
253 \param - dev Pointer to net_device structure
254
255 \return - void
256
257 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530258static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700259{
260 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530261 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700262
263 ENTER();
264
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530265 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530267 hddLog(VOS_TRACE_LEVEL_ERROR,
268 FL("Invalid magic"));
269 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530271 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
272 if (NULL == pHddCtx)
273 {
274 hddLog(VOS_TRACE_LEVEL_ERROR,
275 FL("NULL pHddCtx"));
276 return;
277 }
278
279 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
280
281 /* after uninit our adapter structure will no longer be valid */
282 pHostapdAdapter->dev = NULL;
283 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285 EXIT();
286}
287
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530288static void hdd_hostapd_uninit (struct net_device *dev)
289{
290 vos_ssr_protect(__func__);
291 __hdd_hostapd_uninit(dev);
292 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700293
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530294 return;
295}
Jeff Johnson295189b2012-06-20 16:38:30 -0700296/**============================================================================
297 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
298 transmitting packets. There are 2 versions of this function. One that uses
299 locked queue and other that uses lockless queues. Both have been retained to
300 do some performance testing
301 @param skb : [in] pointer to OS packet (sk_buff)
302 @param dev : [in] pointer to Libra network device
303
304 @return : NET_XMIT_DROP if packets are dropped
305 : NET_XMIT_SUCCESS if packet is enqueued succesfully
306 ===========================================================================*/
307int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
308{
309 return 0;
310}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530311
312int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700313{
314 return 0;
315}
316
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530317int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
318{
319 int ret;
320 vos_ssr_protect(__func__);
321 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
322 vos_ssr_unprotect(__func__);
323
324 return ret;
325}
326
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700327static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
328 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700329{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700330 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530331 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
332 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700333 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530334 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700335 /*
336 * Note that valid pointers are provided by caller
337 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530339 ENTER();
340
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700341 if (priv_data->total_len <= 0 ||
342 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
343 {
344 /* below we allocate one more byte for command buffer.
345 * To avoid addition overflow total_len should be
346 * smaller than INT_MAX. */
347 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
348 __func__, priv_data->total_len);
349 ret = -EFAULT;
350 goto exit;
351 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530352 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530353 if (0 != status)
354 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530355 return status;
356 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700357
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700358 /* Allocate +1 for '\0' */
359 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
360 if (!command)
361 {
362 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
363 ret = -ENOMEM;
364 goto exit;
365 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700367 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
368 {
369 ret = -EFAULT;
370 goto exit;
371 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800372
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700373 /* Make sure the command is NUL-terminated */
374 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 hddLog(VOS_TRACE_LEVEL_INFO,
377 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700379 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
380 {
381 hdd_setP2pNoa(pAdapter->dev, command);
382 }
383 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
384 {
385 hdd_setP2pOpps(pAdapter->dev, command);
386 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800387#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700388 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
389 {
390 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
391 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800392#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700393 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
394 {
395 /*
396 * command should be a string having format
397 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
398 */
399 hddLog(VOS_TRACE_LEVEL_INFO,
400 "%s: Received Command to Set Preferred Channels for SAP",
401 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800402
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700403 ret = sapSetPreferredChannel(command);
404 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530405 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
406 {
407 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
408 tANI_U8 filterType = 0;
409 tANI_U8 *value;
410 value = command + 9;
411
412 /* Convert the value from ascii to integer */
413 ret = kstrtou8(value, 10, &filterType);
414 if (ret < 0)
415 {
416 /* If the input value is greater than max value of datatype,
417 * then also kstrtou8 fails
418 */
419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
420 "%s: kstrtou8 failed range ", __func__);
421 ret = -EINVAL;
422 goto exit;
423 }
424 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
425 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
426 {
427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
428 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
429 " 2-Sink ", __func__);
430 ret = -EINVAL;
431 goto exit;
432 }
433 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
434 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530435 pScanInfo = &pHddCtx->scan_info;
436 if (filterType && pScanInfo != NULL &&
437 pHddCtx->scan_info.mScanPending)
438 {
439 /*Miracast Session started. Abort Scan */
440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
441 "%s, Aborting Scan For Miracast",__func__);
442 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
443 eCSR_SCAN_ABORT_DEFAULT);
444 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530445 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
446 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
447 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700448
Jeff Johnson295189b2012-06-20 16:38:30 -0700449exit:
450 if (command)
451 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700452 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530454 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 return ret;
456}
457
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700458#ifdef CONFIG_COMPAT
459static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
460 struct ifreq *ifr)
461{
462 struct {
463 compat_uptr_t buf;
464 int used_len;
465 int total_len;
466 } compat_priv_data;
467 hdd_priv_data_t priv_data;
468 int ret = 0;
469
470 /*
471 * Note that pAdapter and ifr have already been verified by caller,
472 * and HDD context has also been validated
473 */
474 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
475 sizeof(compat_priv_data))) {
476 ret = -EFAULT;
477 goto exit;
478 }
479 priv_data.buf = compat_ptr(compat_priv_data.buf);
480 priv_data.used_len = compat_priv_data.used_len;
481 priv_data.total_len = compat_priv_data.total_len;
482 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
483 exit:
484 return ret;
485}
486#else /* CONFIG_COMPAT */
487static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
488 struct ifreq *ifr)
489{
490 /* will never be invoked */
491 return 0;
492}
493#endif /* CONFIG_COMPAT */
494
495static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
496{
497 hdd_priv_data_t priv_data;
498 int ret = 0;
499
500 /*
501 * Note that pAdapter and ifr have already been verified by caller,
502 * and HDD context has also been validated
503 */
504 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
505 ret = -EFAULT;
506 } else {
507 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
508 }
509 return ret;
510}
511
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530512static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700513 struct ifreq *ifr, int cmd)
514{
515 hdd_adapter_t *pAdapter;
516 hdd_context_t *pHddCtx;
517 int ret;
518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530519 ENTER();
520
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700521 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
522 if (NULL == pAdapter) {
523 hddLog(VOS_TRACE_LEVEL_ERROR,
524 "%s: HDD adapter context is Null", __func__);
525 ret = -ENODEV;
526 goto exit;
527 }
528 if (dev != pAdapter->dev) {
529 hddLog(VOS_TRACE_LEVEL_ERROR,
530 "%s: HDD adapter/dev inconsistency", __func__);
531 ret = -ENODEV;
532 goto exit;
533 }
534
535 if ((!ifr) || (!ifr->ifr_data)) {
536 ret = -EINVAL;
537 goto exit;
538 }
539
540 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
541 ret = wlan_hdd_validate_context(pHddCtx);
542 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700543 ret = -EBUSY;
544 goto exit;
545 }
546
547 switch (cmd) {
548 case (SIOCDEVPRIVATE + 1):
549 if (is_compat_task())
550 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
551 else
552 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
553 break;
554 default:
555 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
556 __func__, cmd);
557 ret = -EINVAL;
558 break;
559 }
560 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530561 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700562 return ret;
563}
564
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530565static int hdd_hostapd_ioctl(struct net_device *dev,
566 struct ifreq *ifr, int cmd)
567{
568 int ret;
569
570 vos_ssr_protect(__func__);
571 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
572 vos_ssr_unprotect(__func__);
573
574 return ret;
575}
576
Jeff Johnson295189b2012-06-20 16:38:30 -0700577/**---------------------------------------------------------------------------
578
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530579 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 This function sets the user specified mac address using
581 the command ifconfig wlanX hw ether <mac adress>.
582
583 \param - dev - Pointer to the net device.
584 - addr - Pointer to the sockaddr.
585 \return - 0 for success, non zero for failure
586
587 --------------------------------------------------------------------------*/
588
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530589static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700590{
591 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530592 hdd_adapter_t *pAdapter;
593 hdd_context_t *pHddCtx;
594 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530595
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530597 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
598 if (NULL == pAdapter)
599 {
600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
601 "%s: Adapter is NULL",__func__);
602 return -EINVAL;
603 }
604 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
605 ret = wlan_hdd_validate_context(pHddCtx);
606 if (0 != ret)
607 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530608 return ret;
609 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
611 EXIT();
612 return 0;
613}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530614
615static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
616{
617 int ret;
618
619 vos_ssr_protect(__func__);
620 ret = __hdd_hostapd_set_mac_address(dev, addr);
621 vos_ssr_unprotect(__func__);
622
623 return ret;
624}
625
Jeff Johnson295189b2012-06-20 16:38:30 -0700626void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
627{
628 struct net_device *dev = (struct net_device *)usrDataForCallback;
629 v_BYTE_t we_custom_event[64];
630 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530632 hdd_context_t *pHddCtx;
633#ifdef DISABLE_CONCURRENCY_AUTOSAVE
634 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 hdd_ap_ctx_t *pHddApCtx;
636#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
637
638 /* event_name space-delimiter driver_module_name */
639 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
640 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
641 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
642
643 ENTER();
644
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530645 pHostapdAdapter = netdev_priv(dev);
646 if ((NULL == pHostapdAdapter) ||
647 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
648 {
649 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
650 return;
651 }
652 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
653 if (0 != (wlan_hdd_validate_context(pHddCtx)))
654 {
655 return;
656 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530657#ifdef DISABLE_CONCURRENCY_AUTOSAVE
658 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530659 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 /*
661 This timer routine is going to be called only when AP
662 persona is up.
663 If there are concurrent sessions running we do not want
664 to shut down the Bss.Instead we run the timer again so
665 that if Autosave is enabled next time and other session
666 was down only then we bring down AP
667 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
669 vos_status = vos_timer_start(
670 &pHddApCtx->hdd_ap_inactivity_timer,
671 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
672 * 1000);
673 if (!VOS_IS_STATUS_SUCCESS(vos_status))
674 {
675 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
676 }
677 EXIT();
678 return;
679 }
680#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
681 memset(&we_custom_event, '\0', sizeof(we_custom_event));
682 memcpy(&we_custom_event, autoShutEvent, event_len);
683
684 memset(&wrqu, 0, sizeof(wrqu));
685 wrqu.data.length = event_len;
686
687 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
688 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
689
690 EXIT();
691}
692
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800693VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
694{
695 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
696 ptSapContext pSapCtx = NULL;
697 eHalStatus halStatus = eHAL_STATUS_FAILURE;
698 v_PVOID_t hHal = NULL;
699
700 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
701 "%s: UPDATE Beacon Params", __func__);
702
703 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
704 pSapCtx = VOS_GET_SAP_CB(pVosContext);
705 if ( NULL == pSapCtx )
706 {
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
708 "%s: Invalid SAP pointer from pvosGCtx", __func__);
709 return VOS_STATUS_E_FAULT;
710 }
711
712 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
713 if ( NULL == hHal ){
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
715 "%s: Invalid HAL pointer from pvosGCtx", __func__);
716 return VOS_STATUS_E_FAULT;
717 }
718 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
719 if(halStatus == eHAL_STATUS_FAILURE ){
720 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
721 "%s: Failed to update Beacon Params", __func__);
722 return VOS_STATUS_E_FAILURE;
723 }
724 }
725 return VOS_STATUS_SUCCESS;
726}
727
728void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
729{
730 v_U8_t staId = 0;
731 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530732 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
733 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800734
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530735 dev = (struct net_device *)usrDataForCallback;
736 pSapCtx = VOS_GET_SAP_CB(pVosContext);
737 if(pSapCtx == NULL){
738 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
739 FL("psapCtx is NULL"));
740 return;
741 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800742 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800743 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
744 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530745 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800746 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
747 {
748 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530749 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750 }
751 }
752}
753
Agarwal Ashish8e538932014-12-24 18:12:52 +0530754static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800755{
756 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530757 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800758 VOS_STATUS status = VOS_STATUS_SUCCESS;
759 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530760
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800761 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530762
763 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
764 status = wlan_hdd_validate_context(pHddCtx);
765
766 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530767 return status;
768 }
769
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800770 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
771 {
772 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
773 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800775 }
776 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530777 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800778 }
779 EXIT();
780 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
781}
Jeff Johnson295189b2012-06-20 16:38:30 -0700782
783VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
784{
785 hdd_adapter_t *pHostapdAdapter;
786 hdd_ap_ctx_t *pHddApCtx;
787 hdd_hostapd_state_t *pHostapdState;
788 struct net_device *dev;
789 eSapHddEvent sapEvent;
790 union iwreq_data wrqu;
791 v_BYTE_t *we_custom_event_generic = NULL;
792 int we_event = 0;
793 int i = 0;
794 v_U8_t staId;
795 VOS_STATUS vos_status;
796 v_BOOL_t bWPSState;
797 v_BOOL_t bApActive = FALSE;
798 v_BOOL_t bAuthRequired = TRUE;
799 tpSap_AssocMacAddr pAssocStasArray = NULL;
800 char unknownSTAEvent[IW_CUSTOM_MAX+1];
801 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
802 v_BYTE_t we_custom_start_event[64];
803 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800804 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800805 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700806 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530807 v_CONTEXT_t pVosContext = NULL;
808 ptSapContext pSapCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700809
810 dev = (struct net_device *)usrDataForCallback;
811 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530812
813 if ((NULL == pHostapdAdapter) ||
814 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
815 {
816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
817 "invalid adapter or adapter has invalid magic");
818 return eHAL_STATUS_FAILURE;
819 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530820 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
821 pSapCtx = VOS_GET_SAP_CB(pVosContext);
822 if(pSapCtx == NULL){
823 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
824 FL("psapCtx is NULL"));
825 return eHAL_STATUS_FAILURE;
826 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
828 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
829 sapEvent = pSapEvent->sapHddEventCode;
830 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800831 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832
833 switch(sapEvent)
834 {
835 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800836 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
838 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
839 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
840
841 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
842 vos_status = vos_event_set(&pHostapdState->vosEvent);
843
844 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
845 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 goto stopbss;
848 }
849 else
850 {
851 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
852 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530853 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
854 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530855 {
c_hpothuffdb5272013-10-02 16:42:35 +0530856 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530857 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
858 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }
860
861 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
862 {
863 // AP Inactivity timer init and start
864 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
865 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
866 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800867 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700868
869 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
870 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800871 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700872
873 }
874 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
875 pHostapdState->bssState = BSS_START;
876
877 // Send current operating channel of SoftAP to BTC-ES
878 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 //Check if there is any group key pending to set.
881 if( pHddApCtx->groupKey.keyLength )
882 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700883 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
885 &pHddApCtx->groupKey ) )
886 {
887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
888 "%s: WLANSAP_SetKeySta failed", __func__);
889 }
890 pHddApCtx->groupKey.keyLength = 0;
891 }
892 else if ( pHddApCtx->wepKey[0].keyLength )
893 {
894 int i=0;
895 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
896 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700897 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
899 &pHddApCtx->wepKey[i] ) )
900 {
901 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
902 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
903 }
904 pHddApCtx->wepKey[i].keyLength = 0;
905 }
906 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
908 startBssEvent = "SOFTAP.enabled";
909 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
910 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
911 memset(&wrqu, 0, sizeof(wrqu));
912 wrqu.data.length = strlen(startBssEvent);
913 we_event = IWEVCUSTOM;
914 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700915 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 break; //Event will be sent after Switch-Case stmt
917
918 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800919 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
921
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700922 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700923 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 goto stopbss;
927 case eSAP_STA_SET_KEY_EVENT:
928 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800929 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
931 return VOS_STATUS_SUCCESS;
932 case eSAP_STA_DEL_KEY_EVENT:
933 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800934 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 return VOS_STATUS_SUCCESS;
936 case eSAP_STA_MIC_FAILURE_EVENT:
937 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 memset(&msg, '\0', sizeof(msg));
939 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800940 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800941 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700942 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 msg.flags = IW_MICFAILURE_GROUP;
944 else
945 msg.flags = IW_MICFAILURE_PAIRWISE;
946 memset(&wrqu, 0, sizeof(wrqu));
947 wrqu.data.length = sizeof(msg);
948 we_event = IWEVMICHAELMICFAILURE;
949 we_custom_event_generic = (v_BYTE_t *)&msg;
950 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 /* inform mic failure to nl80211 */
952 cfg80211_michael_mic_failure(dev,
953 pSapEvent->sapevt.
954 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700955 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 NL80211_KEYTYPE_GROUP :
957 NL80211_KEYTYPE_PAIRWISE),
958 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
959 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
960 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 break;
962
963 case eSAP_STA_ASSOC_EVENT:
964 case eSAP_STA_REASSOC_EVENT:
965 wrqu.addr.sa_family = ARPHRD_ETHER;
966 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800967 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800968 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 we_event = IWEVREGISTERED;
970
971 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
972
973 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
974 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
975 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
976 {
977 bAuthRequired = FALSE;
978 }
979
980 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
981 {
c_hpothuffdb5272013-10-02 16:42:35 +0530982 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 TRUE,
984 pHddApCtx->uPrivacy,
985 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
986 0,
987 0,
988 (v_MACADDR_t *)wrqu.addr.sa_data,
989 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +0530990
991 if (!VOS_IS_STATUS_SUCCESS(vos_status))
992 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
993 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 }
995 else
996 {
c_hpothuffdb5272013-10-02 16:42:35 +0530997 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 FALSE,
999 pHddApCtx->uPrivacy,
1000 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1001 0,
1002 0,
1003 (v_MACADDR_t *)wrqu.addr.sa_data,
1004 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301005 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1006 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1007 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001008 }
1009
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 // Stop AP inactivity timer
1011 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1012 {
1013 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1014 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001015 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001017#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001018 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1019 {
1020 wake_unlock(&pHddCtx->sap_wake_lock);
1021 }
Amar Singhal6144c002013-05-03 16:11:42 -07001022 wake_lock_timeout(&pHddCtx->sap_wake_lock, msecs_to_jiffies(HDD_SAP_WAKE_LOCK_DURATION));
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001023#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001024#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1025 {
1026 struct station_info staInfo;
1027 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1028
1029 memset(&staInfo, 0, sizeof(staInfo));
1030 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1031 {
1032 staInfo.assoc_req_ies =
1033 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1034 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001035#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001036 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1037#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 cfg80211_new_sta(dev,
1039 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1040 &staInfo, GFP_KERNEL);
1041 }
1042 else
1043 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001044 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 }
1046 }
1047#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001048 pScanInfo = &pHddCtx->scan_info;
1049 // Lets do abort scan to ensure smooth authentication for client
1050 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1051 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301052 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301053 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001055
1056 break;
1057 case eSAP_STA_DISASSOC_EVENT:
1058 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001059 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001060 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1062 hddLog(LOG1," User initiated disassociation");
1063 else
1064 hddLog(LOG1," MAC initiated disassociation");
1065 we_event = IWEVEXPIRED;
1066 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1067 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1068 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 return VOS_STATUS_E_FAILURE;
1071 }
1072 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1073
1074 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1075 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301076 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 // Start AP inactivity timer if no stations associated with it
1078 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1079 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301080 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 {
1082 bApActive = TRUE;
1083 break;
1084 }
1085 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301086 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001087
1088 if (bApActive == FALSE)
1089 {
1090 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1091 {
1092 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1093 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001094 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 }
1096 else
1097 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1098 }
1099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001100#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1101 cfg80211_del_sta(dev,
1102 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1103 GFP_KERNEL);
1104#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001105 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301106 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1107 if (VOS_STATUS_SUCCESS != vos_status)
1108 {
1109 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1110 __func__, vos_status);
1111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 break;
1113 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1114 {
1115 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1116 union iwreq_data wreq;
1117
1118 down(&pHddApCtx->semWpsPBCOverlapInd);
1119 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1120
1121 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1122 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1123
1124 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001125 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 memset(&wreq, 0, sizeof(wreq));
1127 wreq.data.length = strlen(message); // This is length of message
1128 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1129
1130 return VOS_STATUS_SUCCESS;
1131 }
1132 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1133 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1134 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1135 { // List of associated stations
1136 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1137 {
1138 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1139 i+1,
1140 pAssocStasArray->assocId,
1141 pAssocStasArray->staId,
1142 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1143 pAssocStasArray++;
1144 }
1145 }
1146 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001147 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 case eSAP_INDICATE_MGMT_FRAME:
1150 hdd_indicateMgmtFrame( pHostapdAdapter,
1151 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1152 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1153 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301154 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 return VOS_STATUS_SUCCESS;
1156 case eSAP_REMAIN_CHAN_READY:
1157 hdd_remainChanReadyHandler( pHostapdAdapter );
1158 return VOS_STATUS_SUCCESS;
1159 case eSAP_SEND_ACTION_CNF:
1160 hdd_sendActionCnf( pHostapdAdapter,
1161 ( eSAP_STATUS_SUCCESS ==
1162 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1163 TRUE : FALSE );
1164 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 case eSAP_UNKNOWN_STA_JOIN:
1166 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1167 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1168 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1169 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1170 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1171 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1172 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1173 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1174 wrqu.data.pointer = unknownSTAEvent;
1175 wrqu.data.length = strlen(unknownSTAEvent);
1176 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301177 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 break;
1179
1180 case eSAP_MAX_ASSOC_EXCEEDED:
1181 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1182 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1183 " one or more devices to enable the new device connection",
1184 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1185 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1186 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1187 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1188 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1189 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1190 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1191 wrqu.data.pointer = maxAssocExceededEvent;
1192 wrqu.data.length = strlen(maxAssocExceededEvent);
1193 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001194 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 break;
1196 case eSAP_STA_ASSOC_IND:
1197 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001198
1199 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001200 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001201 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1202 return VOS_STATUS_SUCCESS;
1203
1204 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301205 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301206 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1207 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301208 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301209 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001210 return VOS_STATUS_SUCCESS;
1211
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001213 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 goto stopbss;
1215 return VOS_STATUS_SUCCESS;
1216 }
1217 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1218 return VOS_STATUS_SUCCESS;
1219
1220stopbss :
1221 {
1222 v_BYTE_t we_custom_event[64];
1223 char *stopBssEvent = "STOP-BSS.response";//17
1224 int event_len = strlen(stopBssEvent);
1225
1226 hddLog(LOG1, FL("BSS stop status = %s"),
1227 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1228 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1229
1230 /* Change the BSS state now since, as we are shutting things down,
1231 * we don't want interfaces to become re-enabled */
1232 pHostapdState->bssState = BSS_STOP;
1233
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301234 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1235 {
1236 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1237 {
1238 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1239 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1240 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1241 }
1242
1243 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1244 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1245 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1246 }
1247
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 /* Stop the pkts from n/w stack as we are going to free all of
1249 * the TX WMM queues for all STAID's */
1250 hdd_hostapd_stop(dev);
1251
1252 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301253 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1254 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1255 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001256
Amar Singhal37e6f052013-03-05 16:16:54 -08001257 /* once the event is set, structure dev/pHostapdAdapter should
1258 * not be touched since they are now subject to being deleted
1259 * by another thread */
1260 if (eSAP_STOP_BSS_EVENT == sapEvent)
1261 vos_event_set(&pHostapdState->vosEvent);
1262
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 /* notify userspace that the BSS has stopped */
1264 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1265 memcpy(&we_custom_event, stopBssEvent, event_len);
1266 memset(&wrqu, 0, sizeof(wrqu));
1267 wrqu.data.length = event_len;
1268 we_event = IWEVCUSTOM;
1269 we_custom_event_generic = we_custom_event;
1270 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001271 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 }
1273 return VOS_STATUS_SUCCESS;
1274}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001275
1276int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001278 eCsrEncryptionType *pEncryptType,
1279 eCsrEncryptionType *mcEncryptType,
1280 eCsrAuthType *pAuthType,
1281 v_BOOL_t *pMFPCapable,
1282 v_BOOL_t *pMFPRequired,
1283 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 u_int8_t *gen_ie )
1285{
1286 tDot11fIERSN dot11RSNIE;
1287 tDot11fIEWPA dot11WPAIE;
1288
1289 tANI_U8 *pRsnIe;
1290 tANI_U16 RSNIeLen;
1291
1292 if (NULL == halHandle)
1293 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001294 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 return -EINVAL;
1296 }
1297
1298 // Validity checks
1299 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1300 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1301 return -EINVAL;
1302 // Type check
1303 if ( gen_ie[0] == DOT11F_EID_RSN)
1304 {
1305 // Validity checks
1306 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1307 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1308 {
1309 return VOS_STATUS_E_FAILURE;
1310 }
1311 // Skip past the EID byte and length byte
1312 pRsnIe = gen_ie + 2;
1313 RSNIeLen = gen_ie_len - 2;
1314 // Unpack the RSN IE
1315 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1316 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1317 pRsnIe,
1318 RSNIeLen,
1319 &dot11RSNIE);
1320 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001321 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001322 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001323 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001324 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 /*Here we have followed the apple base code,
1326 but probably I suspect we can do something different*/
1327 //dot11RSNIE.akm_suite_count
1328 // Just translate the FIRST one
1329 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1330 //dot11RSNIE.pwise_cipher_suite_count
1331 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1332 //dot11RSNIE.gp_cipher_suite_count
1333 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1334 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001335 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1336 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
1338 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1339 } else
1340 if (gen_ie[0] == DOT11F_EID_WPA)
1341 {
1342 // Validity checks
1343 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1344 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1345 {
1346 return VOS_STATUS_E_FAILURE;
1347 }
1348 // Skip past the EID byte and length byte - and four byte WiFi OUI
1349 pRsnIe = gen_ie + 2 + 4;
1350 RSNIeLen = gen_ie_len - (2 + 4);
1351 // Unpack the WPA IE
1352 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1353 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1354 pRsnIe,
1355 RSNIeLen,
1356 &dot11WPAIE);
1357 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001358 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001359 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001360 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001361 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 //dot11WPAIE.auth_suite_count
1363 // Just translate the FIRST one
1364 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1365 //dot11WPAIE.unicast_cipher_count
1366 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1367 //dot11WPAIE.unicast_cipher_count
1368 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001369 *pMFPCapable = VOS_FALSE;
1370 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 }
1372 else
1373 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001374 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 return VOS_STATUS_E_FAILURE;
1376 }
1377 return VOS_STATUS_SUCCESS;
1378}
Leo Chang614d2072013-08-22 14:59:44 -07001379
Leo Chang0b0e45a2013-12-15 15:18:55 -08001380#ifdef FEATURE_WLAN_CH_AVOID
1381/**---------------------------------------------------------------------------
1382
1383 \brief hdd_hostapd_freq_to_chn() -
1384
1385 Input frequency translated into channel number
1386
1387 \param - freq input frequency with order of kHz
1388
1389 \return - corresponding channel number.
1390 incannot find correct channel number, return 0
1391
1392 --------------------------------------------------------------------------*/
1393v_U16_t hdd_hostapd_freq_to_chn
1394(
1395 v_U16_t freq
1396)
1397{
1398 int loop;
1399
1400 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1401 {
1402 if (rfChannels[loop].targetFreq == freq)
1403 {
1404 return rfChannels[loop].channelNum;
1405 }
1406 }
1407
1408 return (0);
1409}
1410
1411/*==========================================================================
1412 FUNCTION sapUpdateUnsafeChannelList
1413
1414 DESCRIPTION
1415 Function Undate unsafe channel list table
1416
1417 DEPENDENCIES
1418 NA.
1419
1420 PARAMETERS
1421
1422 IN
1423 pSapCtx : SAP context pointer, include unsafe channel list
1424
1425 RETURN VALUE
1426 NONE
1427============================================================================*/
1428void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1429 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1430{
1431 v_U16_t i, j;
1432
1433 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1434 sizeof(pHddCtx->unsafeChannelList));
1435 if (0 == unsafeChannelCount)
1436 {
1437 pHddCtx->unsafeChannelCount = 0;
1438 }
1439 else
1440 {
c_hpothu8de53e42014-08-22 15:00:37 +05301441 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1442 {
1443 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1444 FL("unsafeChannelCount%hd greater than %d"),
1445 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1446 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1447 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001448 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1449 unsafeChannelList,
1450 unsafeChannelCount * sizeof(tANI_U16));
1451 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1452 }
1453
1454 /* Flush, default set all channel safe */
1455 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1456 {
1457 safeChannels[i].isSafe = VOS_TRUE;
1458 }
1459
1460 /* Try to find unsafe channel */
1461 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1462 {
1463 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1464 {
1465 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1466 {
1467 /* Found unsafe channel, update it */
1468 safeChannels[j].isSafe = VOS_FALSE;
1469 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1470 "%s : CH %d is not safe",
1471 __func__, pHddCtx->unsafeChannelList[i]);
1472 break;
1473 }
1474 }
1475 }
1476
1477 return;
1478}
1479
1480/**---------------------------------------------------------------------------
1481
1482 \brief hdd_hostapd_ch_avoid_cb() -
1483
1484 Avoid channel notification from FW handler.
1485 FW will send un-safe channle list to avoid overwrapping.
1486 hostapd should not use notified channel
1487
1488 \param - pAdapter HDD adapter pointer
1489 indParam channel avoid notification parameter
1490
1491 \return - None
1492
1493 --------------------------------------------------------------------------*/
1494void hdd_hostapd_ch_avoid_cb
1495(
1496 void *pAdapter,
1497 void *indParam
1498)
1499{
1500 hdd_adapter_t *pHostapdAdapter = NULL;
1501 hdd_context_t *hddCtxt;
1502 tSirChAvoidIndType *chAvoidInd;
1503 v_U8_t rangeLoop;
1504 v_U16_t channelLoop;
1505 v_U16_t dupCheck;
1506 v_U16_t startChannel;
1507 v_U16_t endChannel;
1508 v_U16_t unsafeChannelCount = 0;
1509 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1510 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001511 tHddAvoidFreqList hddAvoidFreqList;
1512 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301513#ifdef WLAN_FEATURE_AP_HT40_24G
1514 ptSapContext pSapCtx = NULL;
1515 tHalHandle hHal;
1516 v_U8_t cbMode;
1517 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1518 v_U32_t delay;
1519#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001520
1521 /* Basic sanity */
1522 if ((NULL == pAdapter) || (NULL == indParam))
1523 {
1524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1525 "%s : Invalid arguments", __func__);
1526 return;
1527 }
1528
1529 hddCtxt = (hdd_context_t *)pAdapter;
1530 chAvoidInd = (tSirChAvoidIndType *)indParam;
1531 pVosContext = hddCtxt->pvosContext;
1532
1533 /* Make unsafe channel list */
1534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1535 "%s : band count %d",
1536 __func__, chAvoidInd->avoidRangeCount);
1537 vos_mem_zero((void *)unsafeChannelList,
1538 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1539 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1540 {
1541 startChannel = hdd_hostapd_freq_to_chn(
1542 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1543 endChannel = hdd_hostapd_freq_to_chn(
1544 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1546 "%s : start %d : %d, end %d : %d",
1547 __func__,
1548 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1549 startChannel,
1550 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1551 endChannel);
1552 for (channelLoop = startChannel;
1553 channelLoop < (endChannel + 1);
1554 channelLoop++)
1555 {
1556 /* Channel duplicate check routine */
1557 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1558 {
1559 if (unsafeChannelList[dupCheck] == channelLoop)
1560 {
1561 /* This channel is duplicated */
1562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1563 "%s : found duplicated channel %d",
1564 __func__, channelLoop);
1565 break;
1566 }
1567 }
1568 if (dupCheck == unsafeChannelCount)
1569 {
c_hpothu8de53e42014-08-22 15:00:37 +05301570 int ii;
1571 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1572 {
1573 if (channelLoop == safeChannels[ii].channelNumber)
1574 {
1575 unsafeChannelList[unsafeChannelCount] = channelLoop;
1576 unsafeChannelCount++;
1577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1578 "%s : unsafe channel %d, count %d",
1579 __func__,
1580 channelLoop, unsafeChannelCount);
1581 }
1582 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001583 }
1584 else
1585 {
1586 /* DUP, do nothing */
1587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1588 "%s : duplicated channel %d",
1589 __func__, channelLoop);
1590 }
1591 }
1592 }
1593 /* Update unsafe channel cache
1594 * WCN Platform Driver cache */
1595 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1596 unsafeChannelCount);
1597
1598 /* Store into local cache
1599 * Start with STA and later start SAP
1600 * in this scenario, local cache will be used */
1601 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1602 unsafeChannelList,
1603 unsafeChannelCount);
1604
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001605 /* generate vendor specific event */
1606 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1607 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1608 {
1609 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1610 chAvoidInd->avoidFreqRange[i].startFreq;
1611 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1612 chAvoidInd->avoidFreqRange[i].endFreq;
1613 }
1614 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1615
1616 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1617
Leo Chang0b0e45a2013-12-15 15:18:55 -08001618 /* Get SAP context first
1619 * SAP and P2PGO would not concurrent */
1620 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301621#ifdef WLAN_FEATURE_AP_HT40_24G
1622 if (NULL == pHostapdAdapter)
1623 {
1624 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1625 }
1626#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301627 if ((pHostapdAdapter) &&
1628 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1629 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001630 {
1631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1632 "%s : Current operation channel %d",
1633 __func__,
1634 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1635 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1636 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301637 if ((unsafeChannelList[channelLoop] ==
1638 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1639 {
1640 if ((AUTO_CHANNEL_SELECT ==
1641 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1642 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1643 {
1644 /* current operating channel is un-safe channel
1645 * restart driver */
1646 hdd_hostapd_stop(pHostapdAdapter->dev);
1647 /* On LE, this event is handled by wlan-services to
1648 * restart SAP. On android, this event would be
1649 * ignored.
1650 */
1651 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1652 NULL, 0);
1653 }
1654 return;
1655 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001656 }
1657 }
1658
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301659#ifdef WLAN_FEATURE_AP_HT40_24G
1660 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1661 {
1662 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1663
1664 if(pSapCtx == NULL)
1665 {
1666 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1667 FL("psapCtx is NULL"));
1668 return;
1669 }
1670
1671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1672 FL("SAP Secondary channel: %d "),
1673 pSapCtx->sap_sec_chan);
1674
1675 /* tHalHandle */
1676 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1677
1678 if (NULL == hHal)
1679 {
1680 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1681 FL("In invalid hHal"));
1682 return;
1683 }
1684
1685 cbMode = sme_GetChannelBondingMode24G(hHal);
1686
1687 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1688 FL("Selected Channel bonding : %d"), cbMode);
1689
1690 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1691 {
1692 int i;
1693 eHalStatus halStatus;
1694
1695 for (i = 0; i < unsafeChannelCount; i++)
1696 {
1697 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1698 {
1699 /* Current SAP Secondary channel is un-safe channel */
1700 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1701 FL("Move SAP from HT40 to HT20"));
1702
1703 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1704 PHY_SINGLE_CHANNEL_CENTERED);
1705
1706 if (halStatus == eHAL_STATUS_FAILURE)
1707 {
1708 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1709 FL("Failed to change HT20/40 mode"));
1710 return;
1711 }
1712
1713 /* Disable Channel Bonding for 2.4GHz */
1714 sme_UpdateChannelBondingMode24G(hHal,
1715 PHY_SINGLE_CHANNEL_CENTERED);
1716 return;
1717 }
1718 }
1719 }
1720
1721 if ((!pSapCtx->numHT40IntoSta)
1722 && (pHostapdAdapter)
1723 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1724 {
1725 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1726 * are Safe then start HT20/40 timer to Move SAP from HT20
1727 * to HT40.
1728 */
1729 if (((!unsafeChannelCount)
1730 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1731 {
1732 /* Stop Previous Running HT20/40 Timer & Start timer
1733 with (OBSS TransitionDelayFactor * obss interval)
1734 delay after time out move AP from HT20 -> HT40
1735 mode
1736 */
1737 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1738 {
1739 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1740 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1741 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1742 FL("Failed to Stop HT20/40 timer"));
1743 }
1744
1745 delay =
1746 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1747
1748 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1749 FL("Start HT20/40 transition timer (%d sec)"), delay);
1750
1751 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1752 (delay * 1000));
1753
1754 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1755 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1756 FL("Failed to Start HT20/40 timer"));
1757 }
1758 else
1759 {
1760 /* Stop HT20/40 Timer */
1761 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1762 {
1763 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1764 FL("Stop HT20/40 transition timer"));
1765 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1766 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1767 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1768 FL("Failed to Stop HT20/40 timer"));
1769 }
1770 }
1771 }
1772 }
1773#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001774 return;
1775}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001776#endif /* FEATURE_WLAN_CH_AVOID */
1777
Jeff Johnson295189b2012-06-20 16:38:30 -07001778int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301779static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 struct iw_request_info *info,
1781 union iwreq_data *wrqu, char *extra)
1782{
1783 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001784 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301785 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 int *value = (int *)extra;
1787 int sub_cmd = value[0];
1788 int set_value = value[1];
1789 eHalStatus status;
1790 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001791 v_CONTEXT_t pVosContext;
1792
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301793 ENTER();
1794
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301795 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001796 {
1797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301798 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001799 __func__);
1800 return -1;
1801 }
1802
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301803 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1804 ret = wlan_hdd_validate_context(pHddCtx);
1805 if (0 != ret)
1806 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301807 return -1;
1808 }
1809
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001810 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1811 if (!hHal)
1812 {
1813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1814 "%s: Hal ctx is null", __func__);
1815 return -1;
1816 }
1817
1818 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1819 if (!pVosContext)
1820 {
1821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1822 "%s: Vos ctx is null", __func__);
1823 return -1;
1824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001825
1826 switch(sub_cmd)
1827 {
1828
1829 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001830 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301832 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 }
1834 break;
1835
1836 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301837 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1839 {
1840 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1841 ret = -EINVAL;
1842 }
1843 else
1844 {
1845 WLANSAP_SetMode(pVosContext, set_value);
1846 }
1847 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301848
1849 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1850 if ((0 != set_value) && (1 != set_value))
1851 {
1852 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1853 ret = -EINVAL;
1854 }
1855 else
1856 {
1857 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1858 }
1859 break;
1860
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 case QCSAP_PARAM_MAX_ASSOC:
1862 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1863 {
1864 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1865 ret = -EINVAL;
1866 }
1867 else
1868 {
1869 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1870 {
1871 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1872 "Setting it to max allowed and continuing"),
1873 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1874 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1875 }
1876 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1877 set_value, NULL, eANI_BOOLEAN_FALSE);
1878 if ( status != eHAL_STATUS_SUCCESS )
1879 {
1880 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1881 status);
1882 ret = -EIO;
1883 }
1884 }
1885 break;
1886
1887 case QCSAP_PARAM_HIDE_SSID:
1888 {
1889 eHalStatus status = eHAL_STATUS_SUCCESS;
1890 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1891 if(eHAL_STATUS_SUCCESS != status)
1892 {
1893 hddLog(VOS_TRACE_LEVEL_ERROR,
1894 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001895 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 return status;
1897 }
1898 break;
1899 }
1900
Leo Chang614d2072013-08-22 14:59:44 -07001901 case QCSAP_PARAM_SET_MC_RATE:
1902 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001903 tSirRateUpdateInd *rateUpdate;
1904
1905 rateUpdate = (tSirRateUpdateInd *)
1906 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1907 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001908 {
1909 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001910 "%s: SET_MC_RATE indication alloc fail", __func__);
1911 ret = -1;
1912 break;
1913 }
1914 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1915
1916 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1917 /* Ignore unicast */
1918 rateUpdate->ucastDataRate = -1;
1919 rateUpdate->mcastDataRate24GHz = set_value;
1920 rateUpdate->mcastDataRate5GHz = set_value;
1921 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1922 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1923 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1924 if (eHAL_STATUS_SUCCESS != status)
1925 {
1926 hddLog(VOS_TRACE_LEVEL_ERROR,
1927 "%s: SET_MC_RATE failed", __func__);
1928 vos_mem_free(rateUpdate);
1929 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001930 }
1931 break;
1932 }
1933
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 default:
1935 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1936 sub_cmd, set_value);
1937 ret = -EINVAL;
1938 break;
1939 }
1940
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301941 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 return ret;
1943}
1944
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301945int
1946static iw_softap_setparam(struct net_device *dev,
1947 struct iw_request_info *info,
1948 union iwreq_data *wrqu, char *extra)
1949{
1950 int ret;
1951
1952 vos_ssr_protect(__func__);
1953 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1954 vos_ssr_unprotect(__func__);
1955
1956 return ret;
1957}
Jeff Johnson295189b2012-06-20 16:38:30 -07001958
1959int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301960static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 struct iw_request_info *info,
1962 union iwreq_data *wrqu, char *extra)
1963{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301964 hdd_adapter_t *pHostapdAdapter;
1965 tHalHandle hHal;
1966 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 int *value = (int *)extra;
1968 int sub_cmd = value[0];
1969 eHalStatus status;
1970 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301971 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301973 ENTER();
1974
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301975 pHostapdAdapter = (netdev_priv(dev));
1976 if (NULL == pHostapdAdapter)
1977 {
1978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1979 "%s: Adapter is NULL",__func__);
1980 return -EINVAL;
1981 }
1982 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1983 ret = wlan_hdd_validate_context(pHddCtx);
1984 if (0 != ret)
1985 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301986 return ret;
1987 }
1988 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1989 if (NULL == hHal)
1990 {
1991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1992 "%s: Hal Context is NULL",__func__);
1993 return -EINVAL;
1994 }
1995 pVosContext = pHddCtx->pvosContext;
1996 if (NULL == pVosContext)
1997 {
1998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1999 "%s: pVosContext Context is NULL",__func__);
2000 return -EINVAL;
2001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 switch (sub_cmd)
2003 {
2004 case QCSAP_PARAM_MAX_ASSOC:
2005 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2006 if (eHAL_STATUS_SUCCESS != status)
2007 {
c_hpothuffdb5272013-10-02 16:42:35 +05302008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2009 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 ret = -EIO;
2011 }
Girish Gowli385be612014-09-18 11:17:20 +05302012
2013#ifdef WLAN_SOFTAP_VSTA_FEATURE
2014 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2015 {
2016 if (*value > VSTA_NUM_ASSOC_STA)
2017 {
2018 *value = VSTA_NUM_ASSOC_STA;
2019 }
2020 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2021 (*value > (VSTA_NUM_ASSOC_STA -
2022 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2023 {
2024 *value = (VSTA_NUM_ASSOC_STA -
2025 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2026 }
2027 }
2028 else
2029#endif
2030 {
2031 if (*value > NUM_ASSOC_STA)
2032 {
2033 *value = NUM_ASSOC_STA;
2034 }
2035 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2036 (*value > (NUM_ASSOC_STA -
2037 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2038 {
2039 *value = (NUM_ASSOC_STA -
2040 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2041 }
2042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302044
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002046 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 {
c_hpothuffdb5272013-10-02 16:42:35 +05302048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2049 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302050 ret = -EIO;
2051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 *value = 0;
2053 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302054
Jeff Johnson43971f52012-07-17 12:26:56 -07002055 case QCSAP_PARAM_GET_WLAN_DBG:
2056 {
2057 vos_trace_display();
2058 *value = 0;
2059 break;
2060 }
2061
2062 case QCSAP_PARAM_AUTO_CHANNEL:
2063 {
2064 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2065 break;
2066 }
2067
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 default:
2069 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2070 ret = -EINVAL;
2071 break;
2072
2073 }
2074
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302075 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 return ret;
2077}
2078
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302079int
2080static iw_softap_getparam(struct net_device *dev,
2081 struct iw_request_info *info,
2082 union iwreq_data *wrqu, char *extra)
2083{
2084 int ret;
2085
2086 vos_ssr_protect(__func__);
2087 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2088 vos_ssr_unprotect(__func__);
2089
2090 return ret;
2091}
Jeff Johnson295189b2012-06-20 16:38:30 -07002092/* Usage:
2093 BLACK_LIST = 0
2094 WHITE_LIST = 1
2095 ADD MAC = 0
2096 REMOVE MAC = 1
2097
2098 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2099 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2100 while using this ioctl
2101
2102 Syntax:
2103 iwpriv softap.0 modify_acl
2104 <6 octet mac addr> <list type> <cmd type>
2105
2106 Examples:
2107 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2108 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2109 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2110 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2111*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302112int __iw_softap_modify_acl(struct net_device *dev,
2113 struct iw_request_info *info,
2114 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002115{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302116 hdd_adapter_t *pHostapdAdapter;
2117 v_CONTEXT_t pVosContext;
2118 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 v_BYTE_t *value = (v_BYTE_t*)extra;
2120 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2121 int listType, cmd, i;
2122 int ret = 0; /* success */
2123
2124 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302125 pHostapdAdapter = (netdev_priv(dev));
2126 if (NULL == pHostapdAdapter)
2127 {
2128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2129 "%s: Adapter is NULL",__func__);
2130 return -EINVAL;
2131 }
2132 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2133 ret = wlan_hdd_validate_context(pHddCtx);
2134 if (0 != ret)
2135 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302136 return ret;
2137 }
2138 pVosContext = pHddCtx->pvosContext;
2139 if (NULL == pVosContext)
2140 {
2141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2142 "%s: Vos Context is NULL",__func__);
2143 return -EINVAL;
2144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2146 {
2147 pPeerStaMac[i] = *(value+i);
2148 }
2149 listType = (int)(*(value+i));
2150 i++;
2151 cmd = (int)(*(value+i));
2152
Arif Hussain24bafea2013-11-15 15:10:03 -08002153 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2154 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002155
2156 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2157 != VOS_STATUS_SUCCESS)
2158 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002159 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 ret = -EIO;
2161 }
2162 EXIT();
2163 return ret;
2164}
2165
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302166int iw_softap_modify_acl(struct net_device *dev,
2167 struct iw_request_info *info,
2168 union iwreq_data *wrqu, char *extra)
2169{
2170 int ret;
2171
2172 vos_ssr_protect(__func__);
2173 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2174 vos_ssr_unprotect(__func__);
2175
2176 return ret;
2177}
2178
Jeff Johnson295189b2012-06-20 16:38:30 -07002179int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302180static __iw_softap_getchannel(struct net_device *dev,
2181 struct iw_request_info *info,
2182 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002183{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302184 hdd_adapter_t *pHostapdAdapter;
2185 hdd_context_t *pHddCtx;
2186 int ret = 0;
2187 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302188
2189 ENTER();
2190
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302191 pHostapdAdapter = (netdev_priv(dev));
2192 if (NULL == pHostapdAdapter)
2193 {
2194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2195 "%s: Adapter is NULL",__func__);
2196 return -EINVAL;
2197 }
2198 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2199 ret = wlan_hdd_validate_context(pHddCtx);
2200 if (0 != ret)
2201 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302202 return ret;
2203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002204
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302205 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206
Jeff Johnson43971f52012-07-17 12:26:56 -07002207 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302208
2209 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 return 0;
2211}
2212
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302213
Jeff Johnsone7245742012-09-05 17:12:55 -07002214int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302215static iw_softap_getchannel(struct net_device *dev,
2216 struct iw_request_info *info,
2217 union iwreq_data *wrqu, char *extra)
2218{
2219 int ret;
2220
2221 vos_ssr_protect(__func__);
2222 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2223 vos_ssr_unprotect(__func__);
2224
2225 return ret;
2226}
2227
2228int
2229static __iw_softap_set_max_tx_power(struct net_device *dev,
2230 struct iw_request_info *info,
2231 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002232{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302233 hdd_adapter_t *pHostapdAdapter;
2234 tHalHandle hHal;
2235 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002236 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302237 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002238 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2239 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302241 ENTER();
2242
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302243 pHostapdAdapter = (netdev_priv(dev));
2244 if (NULL == pHostapdAdapter)
2245 {
2246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2247 "%s: Adapter is NULL",__func__);
2248 return -EINVAL;
2249 }
2250 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2251 ret = wlan_hdd_validate_context(pHddCtx);
2252 if (0 != ret)
2253 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302254 return ret;
2255 }
2256 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2257 if (NULL == hHal)
2258 {
2259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2260 "%s: Hal Context is NULL",__func__);
2261 return -EINVAL;
2262 }
schang86c22c42013-03-13 18:41:24 -07002263 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002264 return -ENOMEM;
2265
Leo Changd37675a2013-08-01 13:19:45 -07002266 /* Assign correct slef MAC address */
2267 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2268 VOS_MAC_ADDR_SIZE);
2269 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2270 VOS_MAC_ADDR_SIZE);
2271
schang86c22c42013-03-13 18:41:24 -07002272 set_value = value[0];
2273 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2274 {
2275 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002276 __func__);
schang86c22c42013-03-13 18:41:24 -07002277 return -EIO;
2278 }
2279
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302280 EXIT();
schang86c22c42013-03-13 18:41:24 -07002281 return 0;
2282}
2283
2284int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302285static iw_softap_set_max_tx_power(struct net_device *dev,
2286 struct iw_request_info *info,
2287 union iwreq_data *wrqu, char *extra)
2288{
2289 int ret;
2290
2291 vos_ssr_protect(__func__);
2292 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2293 vos_ssr_unprotect(__func__);
2294
2295 return ret;
2296}
2297
2298
2299int
2300static __iw_display_data_path_snapshot(struct net_device *dev,
2301 struct iw_request_info *info,
2302 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302303{
2304
2305 /* Function intitiating dumping states of
2306 * HDD(WMM Tx Queues)
2307 * TL State (with Per Client infor)
2308 * DXE Snapshot (Called at the end of TL Snapshot)
2309 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302310 hdd_adapter_t *pHostapdAdapter;
2311 hdd_context_t *pHddCtx;
2312 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302313
2314 ENTER();
2315
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302316 pHostapdAdapter = (netdev_priv(dev));
2317 if (NULL == pHostapdAdapter)
2318 {
2319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2320 "%s: Adapter is NULL",__func__);
2321 return -EINVAL;
2322 }
2323 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2324 ret = wlan_hdd_validate_context(pHddCtx);
2325 if (0 != ret)
2326 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302327 return ret;
2328 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302329 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302330 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302331
2332 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302333 return 0;
2334}
2335
2336int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302337static iw_display_data_path_snapshot(struct net_device *dev,
2338 struct iw_request_info *info,
2339 union iwreq_data *wrqu, char *extra)
2340{
2341 int ret;
2342
2343 vos_ssr_protect(__func__);
2344 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2345 vos_ssr_unprotect(__func__);
2346
2347 return ret;
2348}
2349
2350int
2351static __iw_softap_set_tx_power(struct net_device *dev,
2352 struct iw_request_info *info,
2353 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002354{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302355 hdd_adapter_t *pHostapdAdapter;
2356 hdd_context_t *pHddCtx;
2357 v_CONTEXT_t pVosContext;
2358 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002359 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302360 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002361 ptSapContext pSapCtx = NULL;
2362
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302363 ENTER();
2364
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302365 pHostapdAdapter = (netdev_priv(dev));
2366 if (NULL == pHostapdAdapter)
2367 {
2368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2369 "%s: Adapter is NULL",__func__);
2370 return -EINVAL;
2371 }
2372 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2373 ret = wlan_hdd_validate_context(pHddCtx);
2374 if (0 != ret)
2375 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302376 return ret;
2377 }
2378 pVosContext = pHddCtx->pvosContext;
2379 if (NULL == pVosContext)
2380 {
2381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2382 "%s: Vos Context is NULL",__func__);
2383 return -EINVAL;
2384 }
2385 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2386 if (NULL == hHal)
2387 {
2388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2389 "%s: Hal Context is NULL",__func__);
2390 return -EINVAL;
2391 }
schang86c22c42013-03-13 18:41:24 -07002392 if (NULL == value)
2393 return -ENOMEM;
2394
2395 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2396 if (NULL == pSapCtx)
2397 {
2398 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2399 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2400 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002401 }
2402
2403 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002404 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002405 {
schang86c22c42013-03-13 18:41:24 -07002406 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002407 __func__);
2408 return -EIO;
2409 }
2410
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302411 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002412 return 0;
2413}
2414
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302415int
2416static iw_softap_set_tx_power(struct net_device *dev,
2417 struct iw_request_info *info,
2418 union iwreq_data *wrqu, char *extra)
2419{
2420 int ret;
2421
2422 vos_ssr_protect(__func__);
2423 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2424 vos_ssr_unprotect(__func__);
2425
2426 return ret;
2427}
2428
Kiet Lambcf38522013-10-26 18:28:27 +05302429/**---------------------------------------------------------------------------
2430
2431 \brief iw_softap_set_trafficmonitor() -
2432 This function dynamically enable/disable traffic monitor functonality
2433 the command iwpriv wlanX setTrafficMon <value>.
2434
2435 \param - dev - Pointer to the net device.
2436 - addr - Pointer to the sockaddr.
2437 \return - 0 for success, non zero for failure
2438
2439 --------------------------------------------------------------------------*/
2440
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302441static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2442 struct iw_request_info *info,
2443 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302444{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302445 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302446 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302447 hdd_context_t *pHddCtx;
2448 int status;
2449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302450 ENTER();
2451
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302452 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302453 if (NULL == pAdapter)
2454 {
2455 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2456 "%s: HDD adapter is Null", __func__);
2457 return -ENODEV;
2458 }
2459
2460 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2461
2462 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302463 if (0 != status)
2464 {
Kiet Lambcf38522013-10-26 18:28:27 +05302465 return status;
2466 }
2467
2468 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2469
2470 if (NULL == isSetTrafficMon)
2471 {
2472 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2473 "%s: Invalid SAP pointer from extra", __func__);
2474 return -ENOMEM;
2475 }
2476
2477 if (TRUE == *isSetTrafficMon)
2478 {
2479 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2480 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2481 {
2482 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2483 "%s: failed to Start Traffic Monitor timer ", __func__ );
2484 return -EIO;
2485 }
2486 }
2487 else if (FALSE == *isSetTrafficMon)
2488 {
2489 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2490 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2491 {
2492 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2493 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2494 return -EIO;
2495 }
2496
2497 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302498
2499 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302500 return 0;
2501}
2502
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302503static int iw_softap_set_trafficmonitor(struct net_device *dev,
2504 struct iw_request_info *info,
2505 union iwreq_data *wrqu, char *extra)
2506{
2507 int ret;
2508
2509 vos_ssr_protect(__func__);
2510 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2511 vos_ssr_unprotect(__func__);
2512
2513 return ret;
2514}
2515
Jeff Johnson295189b2012-06-20 16:38:30 -07002516#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2517
2518int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302519static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2520 struct iw_request_info *info,
2521 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002522{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302523 hdd_adapter_t *pHostapdAdapter;
2524 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302525 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002526 char *buf;
2527 int cnt = 0;
2528 int left;
2529 int ret = 0;
2530 /* maclist_index must be u32 to match userspace */
2531 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302532 v_CONTEXT_t pVosContext = NULL;
2533 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302534
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302535 ENTER();
2536
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302537 pHostapdAdapter = (netdev_priv(dev));
2538 if (NULL == pHostapdAdapter)
2539 {
2540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2541 "%s: Adapter is NULL",__func__);
2542 return -EINVAL;
2543 }
2544 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2545 ret = wlan_hdd_validate_context(pHddCtx);
2546 if (0 != ret)
2547 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302548 return ret;
2549 }
2550
Jeff Johnson224f3702014-03-26 11:09:47 -07002551 /*
2552 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2553 * number, and even numbered iocts are supposed to have "set"
2554 * semantics. Hence the wireless extensions support in the kernel
2555 * won't correctly copy the result to userspace, so the ioctl
2556 * handler itself must copy the data. Output format is 32-bit
2557 * record length, followed by 0 or more 6-byte STA MAC addresses.
2558 *
2559 * Further note that due to the incorrect semantics, the "iwpriv"
2560 * userspace application is unable to correctly invoke this API,
2561 * hence it is not registered in the hostapd_private_args. This
2562 * API can only be invoked by directly invoking the ioctl() system
2563 * call.
2564 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002565
Jeff Johnson224f3702014-03-26 11:09:47 -07002566 /* make sure userspace allocated a reasonable buffer size */
2567 if (wrqu->data.length < sizeof(maclist_index)) {
2568 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2569 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002571
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302572 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2573 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2574 if(pSapCtx == NULL){
2575 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2576 FL("psapCtx is NULL"));
2577 return -EFAULT;
2578 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302579
2580 /* allocate local buffer to build the response */
2581 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2582 if (!buf) {
2583 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2584 return -ENOMEM;
2585 }
2586
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302587 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002588 /* start indexing beyond where the record count will be written */
2589 maclist_index = sizeof(maclist_index);
2590 left = wrqu->data.length - maclist_index;
2591
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302592 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002593 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2594 if ((pStaInfo[cnt].isUsed) &&
2595 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2596 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2597 VOS_MAC_ADDR_SIZE);
2598 maclist_index += VOS_MAC_ADDR_SIZE;
2599 left -= VOS_MAC_ADDR_SIZE;
2600 }
2601 cnt++;
2602 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302603 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002604
2605 *((u32 *)buf) = maclist_index;
2606 wrqu->data.length = maclist_index;
2607 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2608 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2609 ret = -EFAULT;
2610 }
2611 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302612
2613 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002614 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002615}
2616
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302617int
2618static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2619 struct iw_request_info *info,
2620 union iwreq_data *wrqu, char *extra)
2621{
2622 int ret;
2623
2624 vos_ssr_protect(__func__);
2625 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2626 vos_ssr_unprotect(__func__);
2627
2628 return ret;
2629}
2630
Jeff Johnson295189b2012-06-20 16:38:30 -07002631/* Usage:
2632 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2633 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2634 while using this ioctl
2635
2636 Syntax:
2637 iwpriv softap.0 disassoc_sta <6 octet mac address>
2638
2639 e.g.
2640 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2641 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2642*/
2643
2644int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302645static __iw_softap_disassoc_sta(struct net_device *dev,
2646 struct iw_request_info *info,
2647 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002648{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302649 hdd_adapter_t *pHostapdAdapter;
2650 hdd_context_t *pHddCtx;
2651 v_U8_t *peerMacAddr;
2652 int ret = 0;
2653
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302655 pHostapdAdapter = (netdev_priv(dev));
2656 if (NULL == pHostapdAdapter)
2657 {
2658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2659 "%s: Adapter is NULL",__func__);
2660 return -EINVAL;
2661 }
2662 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2663 ret = wlan_hdd_validate_context(pHddCtx);
2664 if (0 != ret)
2665 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302666 return ret;
2667 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302668 /* iwpriv tool or framework calls this ioctl with
2669 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302671 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002672
Arif Hussain24bafea2013-11-15 15:10:03 -08002673 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2674 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2676 EXIT();
2677 return 0;
2678}
2679
2680int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302681static iw_softap_disassoc_sta(struct net_device *dev,
2682 struct iw_request_info *info,
2683 union iwreq_data *wrqu, char *extra)
2684{
2685 int ret;
2686
2687 vos_ssr_protect(__func__);
2688 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2689 vos_ssr_unprotect(__func__);
2690
2691 return ret;
2692}
2693
2694int
2695static __iw_softap_ap_stats(struct net_device *dev,
2696 struct iw_request_info *info,
2697 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002698{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302699 hdd_adapter_t *pHostapdAdapter;
2700 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 WLANTL_TRANSFER_STA_TYPE statBuffer;
2702 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302703 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002704
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302705 ENTER();
2706
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302707 pHostapdAdapter = (netdev_priv(dev));
2708 if (NULL == pHostapdAdapter)
2709 {
2710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2711 "%s: Adapter is NULL",__func__);
2712 return -EINVAL;
2713 }
2714 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2715 ret = wlan_hdd_validate_context(pHddCtx);
2716 if (0 != ret)
2717 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302718 return ret;
2719 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002720 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002721 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2722 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002723
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302724 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002725 if(NULL == pstatbuf) {
2726 hddLog(LOG1, "unable to allocate memory");
2727 return -ENOMEM;
2728 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302729
2730 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002731 "RUF=%d RMF=%d RBF=%d "
2732 "RUB=%d RMB=%d RBB=%d "
2733 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302734 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002735 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2736 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2737 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2738 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2739 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2740 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002741
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302742 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002743 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2744 kfree(pstatbuf);
2745 return -EFAULT;
2746 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302747
2748 strlcpy(extra, pstatbuf, len);
2749 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002750 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302751
2752 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 return 0;
2754}
2755
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302756int
2757static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 struct iw_request_info *info,
2759 union iwreq_data *wrqu, char *extra)
2760{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302761 int ret;
2762
2763 vos_ssr_protect(__func__);
2764 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2765 vos_ssr_unprotect(__func__);
2766
2767 return ret;
2768}
2769
2770static int __iw_softap_set_channel_range(struct net_device *dev,
2771 struct iw_request_info *info,
2772 union iwreq_data *wrqu, char *extra)
2773{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302774 hdd_adapter_t *pHostapdAdapter;
2775 tHalHandle hHal;
2776 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 int *value = (int *)extra;
2778 int startChannel = value[0];
2779 int endChannel = value[1];
2780 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002781 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 int ret = 0; /* success */
2783
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302784 ENTER();
2785
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302786 pHostapdAdapter = (netdev_priv(dev));
2787 if (NULL == pHostapdAdapter)
2788 {
2789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2790 "%s: Adapter is NULL",__func__);
2791 return -EINVAL;
2792 }
2793 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2794 ret = wlan_hdd_validate_context(pHddCtx);
2795 if (0 != ret)
2796 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302797 return ret;
2798 }
2799 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2800 if (NULL == hHal)
2801 {
2802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2803 "%s: Hal Context is NULL",__func__);
2804 return -EINVAL;
2805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2807 if(status != VOS_STATUS_SUCCESS)
2808 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002809 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 startChannel,endChannel, band);
2811 ret = -EINVAL;
2812 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002813
2814 pHddCtx->is_dynamic_channel_range_set = 1;
2815
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302816 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 return ret;
2818}
2819
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302820static int iw_softap_set_channel_range(struct net_device *dev,
2821 struct iw_request_info *info,
2822 union iwreq_data *wrqu, char *extra)
2823{
2824 int ret;
2825
2826 vos_ssr_protect(__func__);
2827 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
2828 vos_ssr_unprotect(__func__);
2829
2830 return ret;
2831}
2832
2833
2834int __iw_softap_get_channel_list(struct net_device *dev,
2835 struct iw_request_info *info,
2836 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002837{
2838 v_U32_t num_channels = 0;
2839 v_U8_t i = 0;
2840 v_U8_t bandStartChannel = RF_CHAN_1;
2841 v_U8_t bandEndChannel = RF_CHAN_165;
2842 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302843 hdd_adapter_t *pHostapdAdapter;
2844 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002847 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302848 hdd_context_t *pHddCtx;
2849 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302850
2851 ENTER();
2852
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302853 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2854 if (NULL == pHostapdAdapter)
2855 {
2856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2857 "%s: Adapter is NULL",__func__);
2858 return -EINVAL;
2859 }
2860 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2861 ret = wlan_hdd_validate_context(pHddCtx);
2862 if (0 != ret)
2863 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302864 return ret;
2865 }
2866 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2867 if (NULL == hHal)
2868 {
2869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2870 "%s: Hal Context is NULL",__func__);
2871 return -EINVAL;
2872 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002873 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2874 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002875 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002876 return -EIO;
2877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 wrqu->data.length = sizeof(tChannelListInfo);
2879 ENTER();
2880
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002881 if (eCSR_BAND_24 == curBand)
2882 {
2883 bandStartChannel = RF_CHAN_1;
2884 bandEndChannel = RF_CHAN_14;
2885 }
2886 else if (eCSR_BAND_5G == curBand)
2887 {
2888 bandStartChannel = RF_CHAN_36;
2889 bandEndChannel = RF_CHAN_165;
2890 }
2891
Arif Hussain6d2a3322013-11-17 19:50:10 -08002892 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05302893 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002894 bandStartChannel, bandEndChannel );
2895
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2897 {
2898 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2899 {
2900 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2901 num_channels++;
2902 }
2903 }
2904
2905 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2906
2907 temp_num_channels = num_channels;
2908
2909 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2910 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302911 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002912 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 }
2914
Agarwal Ashish7b557c02014-07-02 12:32:39 +05302915 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
2916 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 {
2918 for(i = 0; i < temp_num_channels; i++)
2919 {
2920
2921 if((channel_list->channels[i] > 35) &&
2922 (channel_list->channels[i] < 49))
2923 {
2924 vos_mem_move(&channel_list->channels[i],
2925 &channel_list->channels[i+1],
2926 temp_num_channels - (i-1));
2927 num_channels--;
2928 temp_num_channels--;
2929 i--;
2930 }
2931 }
2932 }
2933
Arif Hussain6d2a3322013-11-17 19:50:10 -08002934 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002935
2936 if (num_channels > IW_MAX_FREQUENCIES)
2937 {
2938 num_channels = IW_MAX_FREQUENCIES;
2939 }
2940
2941 channel_list->num_channels = num_channels;
2942 EXIT();
2943
2944 return 0;
2945}
2946
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302947int iw_softap_get_channel_list(struct net_device *dev,
2948 struct iw_request_info *info,
2949 union iwreq_data *wrqu, char *extra)
2950{
2951 int ret;
2952
2953 vos_ssr_protect(__func__);
2954 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
2955 vos_ssr_unprotect(__func__);
2956
2957 return ret;
2958}
2959
2960static
2961int __iw_get_genie(struct net_device *dev,
2962 struct iw_request_info *info,
2963 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002964{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302965 hdd_adapter_t *pHostapdAdapter;
2966 hdd_context_t *pHddCtx;
2967 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 eHalStatus status;
2969 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2970 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302971 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302972
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302974
2975 pHostapdAdapter = (netdev_priv(dev));
2976 if (NULL == pHostapdAdapter)
2977 {
2978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2979 "%s: Adapter is NULL",__func__);
2980 return -EINVAL;
2981 }
2982 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2983 ret = wlan_hdd_validate_context(pHddCtx);
2984 if (0 != ret)
2985 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302986 return ret;
2987 }
2988 pVosContext = pHddCtx->pvosContext;
2989 if (NULL == pVosContext)
2990 {
2991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2992 "%s: vos context is not valid ",__func__);
2993 return -EINVAL;
2994 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08002995 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2997 status = WLANSap_getstationIE_information(pVosContext,
2998 &length,
2999 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003000 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3001 if (wrqu->data.length < length ||
3002 copy_to_user(wrqu->data.pointer,
3003 (v_VOID_t*)genIeBytes, length))
3004 {
3005 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3006 return -EFAULT;
3007 }
3008 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003009
Arif Hussain6d2a3322013-11-17 19:50:10 -08003010 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003011
3012
3013 EXIT();
3014 return 0;
3015}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303016
3017static
3018int iw_get_genie(struct net_device *dev,
3019 struct iw_request_info *info,
3020 union iwreq_data *wrqu, char *extra)
3021{
3022 int ret;
3023
3024 vos_ssr_protect(__func__);
3025 ret = __iw_get_genie(dev, info, wrqu, extra);
3026 vos_ssr_unprotect(__func__);
3027
3028 return ret;
3029}
3030
3031static
3032int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3033 struct iw_request_info *info,
3034 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003035{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303036 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003037 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303038 hdd_ap_ctx_t *pHddApCtx;
3039 hdd_context_t *pHddCtx;
3040 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303041
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003043
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303044 pHostapdAdapter = (netdev_priv(dev));
3045 if (NULL == pHostapdAdapter)
3046 {
3047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3048 "%s: Adapter is NULL",__func__);
3049 return -EINVAL;
3050 }
3051 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3052 ret = wlan_hdd_validate_context(pHddCtx);
3053 if (0 != ret)
3054 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303055 return ret;
3056 }
3057 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3058 if (NULL == pHddApCtx)
3059 {
3060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3061 "%s: AP context is NULL",__func__);
3062 return -EINVAL;
3063 }
3064
Arif Hussain6d2a3322013-11-17 19:50:10 -08003065 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003066 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3067
3068 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3069 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3070 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3071 WPSPBCProbeReqIEs.probeReqIELen);
3072 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3073 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3074 sizeof(v_MACADDR_t));
3075 if (copy_to_user(wrqu->data.pointer,
3076 (void *)&WPSPBCProbeReqIEs,
3077 sizeof(WPSPBCProbeReqIEs)))
3078 {
3079 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3080 return -EFAULT;
3081 }
3082 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003083 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003084 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 up(&pHddApCtx->semWpsPBCOverlapInd);
3086 EXIT();
3087 return 0;
3088}
3089
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303090static
3091int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3092 struct iw_request_info *info,
3093 union iwreq_data *wrqu, char *extra)
3094{
3095 int ret;
3096
3097 vos_ssr_protect(__func__);
3098 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3099 vos_ssr_unprotect(__func__);
3100
3101 return ret;
3102}
3103
Jeff Johnson295189b2012-06-20 16:38:30 -07003104/**---------------------------------------------------------------------------
3105
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303106 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 This function sets the auth type received from the wpa_supplicant.
3108
3109 \param - dev - Pointer to the net device.
3110 - info - Pointer to the iw_request_info.
3111 - wrqu - Pointer to the iwreq_data.
3112 - extra - Pointer to the data.
3113 \return - 0 for success, non zero for failure
3114
3115 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303116int __iw_set_auth_hostap(struct net_device *dev,
3117 struct iw_request_info *info,
3118 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003119{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303120 hdd_adapter_t *pAdapter;
3121 hdd_context_t *pHddCtx;
3122 hdd_wext_state_t *pWextState;
3123 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303124
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303126
3127 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3128 if (NULL == pAdapter)
3129 {
3130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3131 "%s: Adapter is NULL",__func__);
3132 return -EINVAL;
3133 }
3134
3135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3136 ret = wlan_hdd_validate_context(pHddCtx);
3137 if (0 != ret)
3138 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303139 return ret;
3140 }
3141 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3142 if (NULL == pWextState)
3143 {
3144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3145 "%s: pWextState is NULL",__func__);
3146 return -EINVAL;
3147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 switch(wrqu->param.flags & IW_AUTH_INDEX)
3149 {
3150 case IW_AUTH_TKIP_COUNTERMEASURES:
3151 {
3152 if(wrqu->param.value) {
3153 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3154 "Counter Measure started %d", wrqu->param.value);
3155 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303156 }
3157 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3159 "Counter Measure stopped=%d", wrqu->param.value);
3160 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3161 }
3162
3163 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3164 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303167
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303169
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003170 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 wrqu->param.flags & IW_AUTH_INDEX);
3172 break;
3173 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303174
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 EXIT();
3176 return 0;
3177}
3178
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303179int iw_set_auth_hostap(struct net_device *dev,
3180 struct iw_request_info *info,
3181 union iwreq_data *wrqu,char *extra)
3182{
3183 int ret;
3184
3185 vos_ssr_protect(__func__);
3186 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3187 vos_ssr_unprotect(__func__);
3188
3189 return ret;
3190}
3191
3192static int __iw_set_ap_encodeext(struct net_device *dev,
3193 struct iw_request_info *info,
3194 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003195{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303196 hdd_adapter_t *pHostapdAdapter;
3197 v_CONTEXT_t pVosContext;
3198 hdd_context_t *pHddCtx;
3199 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003200 int retval = 0;
3201 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3203 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3204 int key_index;
3205 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303206 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003207// tCsrRoamRemoveKey RemoveKey;
3208 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303209
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303210 ENTER();
3211 pHostapdAdapter = (netdev_priv(dev));
3212 if (NULL == pHostapdAdapter)
3213 {
3214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3215 "%s: Adapter is NULL",__func__);
3216 return -EINVAL;
3217 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003218
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303219 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3220 retval = wlan_hdd_validate_context(pHddCtx);
3221 if (0 != retval)
3222 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303223 return retval;
3224 }
3225 pVosContext = pHddCtx->pvosContext;
3226 if (NULL == pVosContext)
3227 {
3228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3229 "%s: pVosContext is NULL",__func__);
3230 return -EINVAL;
3231 }
3232 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3233 if (NULL == pHddApCtx)
3234 {
3235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3236 "%s: AP Context is NULL",__func__);
3237 return -EINVAL;
3238 }
3239
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303241
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303243
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 /*Convert from 1-based to 0-based keying*/
3245 key_index--;
3246 }
3247 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303248#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 /*Set the encrytion type to NONE*/
3250#if 0
3251 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3252#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303253
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 RemoveKey.keyId = key_index;
3255 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3256 /*Key direction for group is RX only*/
3257 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3258 }
3259 else {
3260 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3261 }
3262 switch(ext->alg)
3263 {
3264 case IW_ENCODE_ALG_NONE:
3265 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3266 break;
3267 case IW_ENCODE_ALG_WEP:
3268 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3269 break;
3270 case IW_ENCODE_ALG_TKIP:
3271 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003272 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 case IW_ENCODE_ALG_CCMP:
3274 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3275 break;
3276 default:
3277 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3278 break;
3279 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Remove key cipher_alg:%d key_len%d *pEncryptionType :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003281 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003283 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003285 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3286 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 {
3288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003289 __LINE__, vstatus );
3290 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003292#endif
3293 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003294
Jeff Johnson43971f52012-07-17 12:26:56 -07003295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003296
3297 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3298
3299 setKey.keyId = key_index;
3300 setKey.keyLength = ext->key_len;
3301
3302 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3303 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3304 }
3305
3306 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3307 /*Key direction for group is RX only*/
3308 setKey.keyDirection = eSIR_RX_ONLY;
3309 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3310 }
3311 else {
3312
3313 setKey.keyDirection = eSIR_TX_RX;
3314 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3315 }
3316 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3317 {
3318 setKey.keyDirection = eSIR_TX_DEFAULT;
3319 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3320 }
3321
3322 /*For supplicant pae role is zero*/
3323 setKey.paeRole = 0;
3324
3325 switch(ext->alg)
3326 {
3327 case IW_ENCODE_ALG_NONE:
3328 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3329 break;
3330
3331 case IW_ENCODE_ALG_WEP:
3332 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3333 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003334 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 break;
3336
3337 case IW_ENCODE_ALG_TKIP:
3338 {
3339 v_U8_t *pKey = &setKey.Key[0];
3340
3341 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3342
3343 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3344
3345 /*Supplicant sends the 32bytes key in this order
3346
3347 |--------------|----------|----------|
3348 | Tk1 |TX-MIC | RX Mic |
3349 |--------------|----------|----------|
3350 <---16bytes---><--8bytes--><--8bytes-->
3351
3352 */
3353 /*Sme expects the 32 bytes key to be in the below order
3354
3355 |--------------|----------|----------|
3356 | Tk1 |RX-MIC | TX Mic |
3357 |--------------|----------|----------|
3358 <---16bytes---><--8bytes--><--8bytes-->
3359 */
3360 /* Copy the Temporal Key 1 (TK1) */
3361 vos_mem_copy(pKey,ext->key,16);
3362
3363 /*Copy the rx mic first*/
3364 vos_mem_copy(&pKey[16],&ext->key[24],8);
3365
3366 /*Copy the tx mic */
3367 vos_mem_copy(&pKey[24],&ext->key[16],8);
3368
3369 }
3370 break;
3371
3372 case IW_ENCODE_ALG_CCMP:
3373 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3374 break;
3375
3376 default:
3377 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3378 break;
3379 }
3380
3381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303382 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 setKey.keyId);
3384 for(i=0; i< ext->key_len; i++)
3385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3386 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003387
3388 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3389 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 {
3391 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003392 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3393 retval = -EINVAL;
3394 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303395
3396 EXIT();
3397 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003398}
Jeff Johnson43971f52012-07-17 12:26:56 -07003399
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303400static int iw_set_ap_encodeext(struct net_device *dev,
3401 struct iw_request_info *info,
3402 union iwreq_data *wrqu, char *extra)
3403{
3404 int ret;
3405
3406 vos_ssr_protect(__func__);
3407 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3408 vos_ssr_unprotect(__func__);
3409
3410 return ret;
3411}
Jeff Johnson43971f52012-07-17 12:26:56 -07003412
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303413static int __iw_set_ap_mlme(struct net_device *dev,
3414 struct iw_request_info *info,
3415 union iwreq_data *wrqu,
3416 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003417{
3418#if 0
3419 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3420 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3421
3422 ENTER();
3423
3424 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3425 switch (mlme->cmd) {
3426 case IW_MLME_DISASSOC:
3427 case IW_MLME_DEAUTH:
3428 hddLog(LOG1, "Station disassociate");
3429 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3430 {
3431 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3432
3433 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3434 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3435
3436 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3437
3438 //clear all the reason codes
3439 if (status != 0)
3440 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003441 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
3443
3444 netif_stop_queue(dev);
3445 netif_carrier_off(dev);
3446 }
3447 else
3448 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003449 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 }
3451 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003452 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 return -EINVAL;
3454 }//end of switch
3455 EXIT();
3456#endif
3457 return 0;
3458// return status;
3459}
3460
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303461static int iw_set_ap_mlme(struct net_device *dev,
3462 struct iw_request_info *info,
3463 union iwreq_data *wrqu,
3464 char *extra)
3465{
3466 int ret;
3467
3468 vos_ssr_protect(__func__);
3469 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3470 vos_ssr_unprotect(__func__);
3471
3472 return ret;
3473}
3474
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303475static int __iw_get_ap_rts_threshold(struct net_device *dev,
3476 struct iw_request_info *info,
3477 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003478{
3479 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3480 v_U32_t status = 0;
3481
3482 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3483
3484 return status;
3485}
3486
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303487static int iw_get_ap_rts_threshold(struct net_device *dev,
3488 struct iw_request_info *info,
3489 union iwreq_data *wrqu, char *extra)
3490{
3491 int ret;
3492
3493 vos_ssr_protect(__func__);
3494 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3495 vos_ssr_unprotect(__func__);
3496
3497 return ret;
3498}
3499
3500static int __iw_get_ap_frag_threshold(struct net_device *dev,
3501 struct iw_request_info *info,
3502 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003503{
3504 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3505 v_U32_t status = 0;
3506
3507 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3508
3509 return status;
3510}
3511
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303512static int iw_get_ap_frag_threshold(struct net_device *dev,
3513 struct iw_request_info *info,
3514 union iwreq_data *wrqu, char *extra)
3515{
3516 int ret;
3517
3518 vos_ssr_protect(__func__);
3519 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3520 vos_ssr_unprotect(__func__);
3521
3522 return ret;
3523}
3524
3525static int __iw_get_ap_freq(struct net_device *dev,
3526 struct iw_request_info *info,
3527 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003528{
Jeff Johnsone7245742012-09-05 17:12:55 -07003529 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303530 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 tHalHandle hHal;
3532 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303533 hdd_ap_ctx_t *pHddApCtx;
3534 hdd_context_t *pHddCtx;
3535 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003536
3537 ENTER();
3538
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303539 pHostapdAdapter = (netdev_priv(dev));
3540 if (NULL == pHostapdAdapter)
3541 {
3542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3543 "%s: Adapter is NULL",__func__);
3544 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303546 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3547 ret = wlan_hdd_validate_context(pHddCtx);
3548 if (0 != ret)
3549 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303550 return ret;
3551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303553 if (NULL == pHostapdState)
3554 {
3555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3556 "%s: pHostapdState is NULL",__func__);
3557 return -EINVAL;
3558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303560 if (NULL == hHal)
3561 {
3562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3563 "%s: Hal Context is NULL",__func__);
3564 return -EINVAL;
3565 }
3566 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3567 if (NULL == pHddApCtx)
3568 {
3569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3570 "%s: AP context is NULL",__func__);
3571 return -EINVAL;
3572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 if(pHostapdState->bssState == BSS_STOP )
3574 {
3575 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3576 != eHAL_STATUS_SUCCESS)
3577 {
c_hpothuffdb5272013-10-02 16:42:35 +05303578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3579 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 return -EIO;
3581 }
3582 else
3583 {
3584 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003585 if( TRUE == status)
3586 {
3587 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3588 * iwlist & iwconfig command shows frequency into proper
3589 * format (2.412 GHz instead of 246.2 MHz)*/
3590 fwrq->m = freq;
3591 fwrq->e = MHZ;
3592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 }
3594 }
3595 else
3596 {
3597 channel = pHddApCtx->operatingChannel;
3598 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003599 if( TRUE == status)
3600 {
3601 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3602 * iwlist & iwconfig command shows frequency into proper
3603 * format (2.412 GHz instead of 246.2 MHz)*/
3604 fwrq->m = freq;
3605 fwrq->e = MHZ;
3606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303608
3609 EXIT();
3610 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003611}
3612
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303613static int iw_get_ap_freq(struct net_device *dev,
3614 struct iw_request_info *info,
3615 struct iw_freq *fwrq, char *extra)
3616{
3617 int ret;
3618
3619 vos_ssr_protect(__func__);
3620 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3621 vos_ssr_unprotect(__func__);
3622
3623 return ret;
3624}
3625
3626static int __iw_get_mode(struct net_device *dev,
3627 struct iw_request_info *info,
3628 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303629{
3630 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303631 hdd_adapter_t *pAdapter;
3632 hdd_context_t *pHddCtx;
3633
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303634 ENTER();
3635
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303636 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3637 if (NULL == pAdapter)
3638 {
3639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3640 "%s: Adapter is NULL",__func__);
3641 return -EINVAL;
3642 }
3643 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3644 status = wlan_hdd_validate_context(pHddCtx);
3645 if (0 != status)
3646 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303647 return status;
3648 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303649
3650 wrqu->mode = IW_MODE_MASTER;
3651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303652 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303653 return status;
3654}
3655
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303656static int iw_get_mode(struct net_device *dev,
3657 struct iw_request_info *info,
3658 union iwreq_data *wrqu, char *extra)
3659{
3660 int ret;
3661
3662 vos_ssr_protect(__func__);
3663 ret = __iw_get_mode(dev, info, wrqu, extra);
3664 vos_ssr_unprotect(__func__);
3665
3666 return ret;
3667}
3668
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303669static int __iw_softap_setwpsie(struct net_device *dev,
3670 struct iw_request_info *info,
3671 union iwreq_data *wrqu,
3672 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003673{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303674 hdd_adapter_t *pHostapdAdapter;
3675 hdd_context_t *pHddCtx;
3676 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 hdd_hostapd_state_t *pHostapdState;
3678 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003679 u_int8_t *wps_genie;
3680 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 u_int8_t *pos;
3682 tpSap_WPSIE pSap_WPSIe;
3683 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303684 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303685 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303686 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 ENTER();
3689
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303690 pHostapdAdapter = (netdev_priv(dev));
3691 if (NULL == pHostapdAdapter)
3692 {
3693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3694 "%s: Adapter is NULL",__func__);
3695 return -EINVAL;
3696 }
3697 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3698 ret = wlan_hdd_validate_context(pHddCtx);
3699 if (0 != ret)
3700 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303701 return ret;
3702 }
3703 pVosContext = pHddCtx->pvosContext;
3704 if (NULL == pVosContext)
3705 {
3706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3707 "%s: HDD context is not valid ",__func__);
3708 return -EINVAL;
3709 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303710 /* helper function to get iwreq_data with compat handling. */
3711 if (hdd_priv_get_data(&s_priv_data, wrqu))
3712 {
3713 return -EINVAL;
3714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003715
Girish Gowli07c05ec2014-06-17 20:47:03 +05303716 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3717 {
3718 return -EINVAL;
3719 }
3720
3721 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3722 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003723
Girish Gowli86c471e2014-06-17 19:28:05 +05303724 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003725 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303726 hddLog(LOG1, "%s: failed to alloc memory "
3727 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003728 return -EFAULT;
3729 }
3730
Girish Gowli86c471e2014-06-17 19:28:05 +05303731 fwps_genie = wps_genie;
3732
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3734 if (NULL == pSap_WPSIe)
3735 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003736 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003737 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 return -ENOMEM;
3739 }
3740 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3741
Arif Hussain6d2a3322013-11-17 19:50:10 -08003742 hddLog(LOG1,"%s WPS IE type[0x%X] IE[0x%X], LEN[%d]", __func__, wps_genie[0], wps_genie[1], wps_genie[2]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 WPSIeType = wps_genie[0];
3744 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3745 {
3746 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3747 wps_genie = wps_genie + 1;
3748 switch ( wps_genie[0] )
3749 {
3750 case DOT11F_EID_WPA:
3751 if (wps_genie[1] < 2 + 4)
3752 {
3753 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003754 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 return -EINVAL;
3756 }
3757 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3758 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003759 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 pos = &wps_genie[6];
3761 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3762 {
3763 switch((u_int16_t)(*pos<<8) | *(pos+1))
3764 {
3765 case HDD_WPS_ELEM_VERSION:
3766 pos += 4;
3767 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003768 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3770 pos += 1;
3771 break;
3772
3773 case HDD_WPS_ELEM_WPS_STATE:
3774 pos +=4;
3775 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003776 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3778 pos += 1;
3779 break;
3780 case HDD_WPS_ELEM_APSETUPLOCK:
3781 pos += 4;
3782 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003783 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3785 pos += 1;
3786 break;
3787 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3788 pos += 4;
3789 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003790 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3792 pos += 1;
3793 break;
3794 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3795 pos += 4;
3796 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003797 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3799 pos += 2;
3800 break;
3801 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3802 pos += 4;
3803 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003804 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3806 pos += 2;
3807 break;
3808
3809 case HDD_WPS_ELEM_UUID_E:
3810 pos += 2;
3811 length = *pos<<8 | *(pos+1);
3812 pos += 2;
3813 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3814 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3815 pos += length;
3816 break;
3817 case HDD_WPS_ELEM_RF_BANDS:
3818 pos += 4;
3819 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003820 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3822 pos += 1;
3823 break;
3824
3825 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003826 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003828 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 return -EINVAL;
3830 }
3831 }
3832 }
3833 else {
3834 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003835 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 }
3837 break;
3838
3839 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003840 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003842 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 return 0;
3844 }
3845 }
3846 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
3847 {
3848 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
3849 wps_genie = wps_genie + 1;
3850 switch ( wps_genie[0] )
3851 {
3852 case DOT11F_EID_WPA:
3853 if (wps_genie[1] < 2 + 4)
3854 {
3855 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003856 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 return -EINVAL;
3858 }
3859 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3860 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003861 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 pos = &wps_genie[6];
3863 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3864 {
3865 switch((u_int16_t)(*pos<<8) | *(pos+1))
3866 {
3867 case HDD_WPS_ELEM_VERSION:
3868 pos += 4;
3869 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003870 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
3872 pos += 1;
3873 break;
3874
3875 case HDD_WPS_ELEM_WPS_STATE:
3876 pos +=4;
3877 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003878 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
3880 pos += 1;
3881 break;
3882 case HDD_WPS_ELEM_APSETUPLOCK:
3883 pos += 4;
3884 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003885 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
3887 pos += 1;
3888 break;
3889 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3890 pos += 4;
3891 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003892 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
3894 pos += 1;
3895 break;
3896 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3897 pos += 4;
3898 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003899 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
3901 pos += 2;
3902 break;
3903 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3904 pos += 4;
3905 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003906 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
3908 pos += 2;
3909 break;
3910 case HDD_WPS_ELEM_RSP_TYPE:
3911 pos += 4;
3912 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
3915 pos += 1;
3916 break;
3917 case HDD_WPS_ELEM_UUID_E:
3918 pos += 2;
3919 length = *pos<<8 | *(pos+1);
3920 pos += 2;
3921 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
3922 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
3923 pos += length;
3924 break;
3925
3926 case HDD_WPS_ELEM_MANUFACTURER:
3927 pos += 2;
3928 length = *pos<<8 | *(pos+1);
3929 pos += 2;
3930 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
3931 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
3932 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
3933 pos += length;
3934 break;
3935
3936 case HDD_WPS_ELEM_MODEL_NAME:
3937 pos += 2;
3938 length = *pos<<8 | *(pos+1);
3939 pos += 2;
3940 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
3941 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
3942 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
3943 pos += length;
3944 break;
3945 case HDD_WPS_ELEM_MODEL_NUM:
3946 pos += 2;
3947 length = *pos<<8 | *(pos+1);
3948 pos += 2;
3949 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
3950 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
3951 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
3952 pos += length;
3953 break;
3954 case HDD_WPS_ELEM_SERIAL_NUM:
3955 pos += 2;
3956 length = *pos<<8 | *(pos+1);
3957 pos += 2;
3958 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
3959 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
3960 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
3961 pos += length;
3962 break;
3963 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
3964 pos += 4;
3965 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003966 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 pos += 2;
3968
3969 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003970 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 pos += 4;
3972 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003973 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 pos += 2;
3975 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
3976 break;
3977 case HDD_WPS_ELEM_DEVICE_NAME:
3978 pos += 2;
3979 length = *pos<<8 | *(pos+1);
3980 pos += 2;
3981 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
3982 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
3983 pos += length;
3984 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
3985 break;
3986 case HDD_WPS_ELEM_CONFIG_METHODS:
3987 pos += 4;
3988 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003989 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 pos += 2;
3991 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
3992 break;
3993
3994 case HDD_WPS_ELEM_RF_BANDS:
3995 pos += 4;
3996 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003997 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 pos += 1;
3999 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4000 break;
4001 } // switch
4002 }
4003 }
4004 else
4005 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004006 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 }
4008
4009 } // switch
4010 }
4011 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
4012 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4013 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4014 {
4015 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4016 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4017 WLANSAP_Update_WpsIe ( pVosContext );
4018 }
4019
4020 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004021 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 EXIT();
4023 return halStatus;
4024}
4025
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304026static int iw_softap_setwpsie(struct net_device *dev,
4027 struct iw_request_info *info,
4028 union iwreq_data *wrqu,
4029 char *extra)
4030{
4031 int ret;
4032
4033 vos_ssr_protect(__func__);
4034 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4035 vos_ssr_unprotect(__func__);
4036
4037 return ret;
4038}
4039
4040static int __iw_softap_stopbss(struct net_device *dev,
4041 struct iw_request_info *info,
4042 union iwreq_data *wrqu,
4043 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004044{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304045 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304047 hdd_context_t *pHddCtx = NULL;
4048
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304050 pHostapdAdapter = (netdev_priv(dev));
4051 if (NULL == pHostapdAdapter)
4052 {
4053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4054 "%s: Adapter is NULL",__func__);
4055 return -EINVAL;
4056 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304057 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4058 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304059 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304060 return status;
4061 }
4062
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304063 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 {
4065 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4066 {
4067 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4068
4069 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304070
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304072 {
4073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004074 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 VOS_ASSERT(0);
4076 }
4077 }
4078 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304079 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 }
4081 EXIT();
4082 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4083}
4084
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304085static int iw_softap_stopbss(struct net_device *dev,
4086 struct iw_request_info *info,
4087 union iwreq_data *wrqu,
4088 char *extra)
4089{
4090 int ret;
4091
4092 vos_ssr_protect(__func__);
4093 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4094 vos_ssr_unprotect(__func__);
4095
4096 return ret;
4097}
4098
4099static int __iw_softap_version(struct net_device *dev,
4100 struct iw_request_info *info,
4101 union iwreq_data *wrqu,
4102 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004103{
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304105 hdd_context_t *pHddCtx;
4106 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304109 pHostapdAdapter = (netdev_priv(dev));
4110 if (NULL == pHostapdAdapter)
4111 {
4112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4113 "%s: Adapter is NULL",__func__);
4114 return -EINVAL;
4115 }
4116 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4117 ret = wlan_hdd_validate_context(pHddCtx);
4118 if (0 != ret)
4119 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304120 return ret;
4121 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004122 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 return 0;
4125}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004126
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304127static int iw_softap_version(struct net_device *dev,
4128 struct iw_request_info *info,
4129 union iwreq_data *wrqu,
4130 char *extra)
4131{
4132 int ret;
4133
4134 vos_ssr_protect(__func__);
4135 ret = __iw_softap_version(dev, info, wrqu, extra);
4136 vos_ssr_unprotect(__func__);
4137
4138 return ret;
4139}
4140
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004141VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004142{
4143 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004144 int len = 0;
4145 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304146 v_CONTEXT_t pVosContext;
4147 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304148 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304149
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304150 ENTER();
4151
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304152 if (NULL == pAdapter)
4153 {
4154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4155 "%s: Adapter is NULL",__func__);
4156 return -EINVAL;
4157 }
4158 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4159 if (0 != wlan_hdd_validate_context(pHddCtx))
4160 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304161 return VOS_STATUS_E_FAULT;
4162 }
4163 pVosContext = pHddCtx->pvosContext;
4164 if (NULL == pVosContext)
4165 {
4166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4167 "%s: VOS context is not valid",__func__);
4168 return VOS_STATUS_E_FAULT;
4169 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304170 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304171 if(pSapCtx == NULL)
4172 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304173 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4174 FL("psapCtx is NULL"));
4175 return VOS_STATUS_E_FAULT;
4176 }
4177
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004178 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004179 pBuf += len;
4180 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004181
4182 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4183 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304184 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004185 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004186 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304187 pSapCtx->aStaInfo[i].ucSTAId,
4188 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4189 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4190 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4191 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4192 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4193 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004194 pBuf += len;
4195 buf_len -= len;
4196 }
4197 if(WE_GET_STA_INFO_SIZE > buf_len)
4198 {
4199 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004200 }
4201 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304202 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004203 return VOS_STATUS_SUCCESS;
4204}
4205
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304206static int __iw_softap_get_sta_info(struct net_device *dev,
4207 struct iw_request_info *info,
4208 union iwreq_data *wrqu,
4209 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004210{
4211 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4212 VOS_STATUS status;
4213 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004214 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004215 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004217 return -EINVAL;
4218 }
4219 wrqu->data.length = strlen(extra);
4220 EXIT();
4221 return 0;
4222}
4223
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304224static int iw_softap_get_sta_info(struct net_device *dev,
4225 struct iw_request_info *info,
4226 union iwreq_data *wrqu,
4227 char *extra)
4228{
4229 int ret;
4230
4231 vos_ssr_protect(__func__);
4232 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4233 vos_ssr_unprotect(__func__);
4234
4235 return ret;
4236}
4237
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304238static int __iw_set_ap_genie(struct net_device *dev,
4239 struct iw_request_info *info,
4240 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004241{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304242
4243 hdd_adapter_t *pHostapdAdapter;
4244 hdd_context_t *pHddCtx;
4245 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004247 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304248 int ret = 0;
4249
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304251 pHostapdAdapter = (netdev_priv(dev));
4252 if (NULL == pHostapdAdapter)
4253 {
4254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4255 "%s: Adapter is NULL",__func__);
4256 return -EINVAL;
4257 }
4258 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4259 ret = wlan_hdd_validate_context(pHddCtx);
4260 if (0 != ret)
4261 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304262 return ret;
4263 }
4264 pVosContext = pHddCtx->pvosContext;
4265 if (NULL == pVosContext)
4266 {
4267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4268 "%s: VOS Context is NULL",__func__);
4269 return -EINVAL;
4270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 if(!wrqu->data.length)
4272 {
4273 EXIT();
4274 return 0;
4275 }
Arif Hussained667642013-10-27 23:01:14 -07004276
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304277 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304279 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 case DOT11F_EID_RSN:
4281 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4282 {
4283 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4284 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004287 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304289
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004291 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 halStatus = 0;
4293 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304294
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304296 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004297}
4298
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304299static int iw_set_ap_genie(struct net_device *dev,
4300 struct iw_request_info *info,
4301 union iwreq_data *wrqu, char *extra)
4302{
4303 int ret;
4304
4305 vos_ssr_protect(__func__);
4306 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4307 vos_ssr_unprotect(__func__);
4308
4309 return ret;
4310}
4311
Jeff Johnson295189b2012-06-20 16:38:30 -07004312static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4313{
4314 eHalStatus hstatus;
4315 long lrc;
4316 struct statsContext context;
4317
4318 if (NULL == pAdapter)
4319 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304320 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 return VOS_STATUS_E_FAULT;
4322 }
4323
4324 init_completion(&context.completion);
4325 context.pAdapter = pAdapter;
4326 context.magic = STATS_CONTEXT_MAGIC;
4327 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4328 eCSR_HDD,
4329 SME_GLOBAL_CLASSA_STATS,
4330 hdd_GetClassA_statisticsCB,
4331 0, // not periodic
4332 FALSE, //non-cached results
4333 staid,
4334 &context);
4335 if (eHAL_STATUS_SUCCESS != hstatus)
4336 {
4337 hddLog(VOS_TRACE_LEVEL_ERROR,
4338 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004339 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 }
4341 else
4342 {
4343 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4344 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 if (lrc <= 0)
4346 {
4347 hddLog(VOS_TRACE_LEVEL_ERROR,
4348 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004349 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 }
4351 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004352
4353 /* either we never sent a request, we sent a request and received a
4354 response or we sent a request and timed out. if we never sent a
4355 request or if we sent a request and got a response, we want to
4356 clear the magic out of paranoia. if we timed out there is a
4357 race condition such that the callback function could be
4358 executing at the same time we are. of primary concern is if the
4359 callback function had already verified the "magic" but had not
4360 yet set the completion variable when a timeout occurred. we
4361 serialize these activities by invalidating the magic while
4362 holding a shared spinlock which will cause us to block if the
4363 callback is currently executing */
4364 spin_lock(&hdd_context_lock);
4365 context.magic = 0;
4366 spin_unlock(&hdd_context_lock);
4367
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 return VOS_STATUS_SUCCESS;
4369}
4370
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304371int __iw_get_softap_linkspeed(struct net_device *dev,
4372 struct iw_request_info *info,
4373 union iwreq_data *wrqu,
4374 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004375
4376{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304377 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304378 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004380 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304381 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304383 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004385 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304386 int rc, valid;
4387
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304388 ENTER();
4389
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304390 pHostapdAdapter = (netdev_priv(dev));
4391 if (NULL == pHostapdAdapter)
4392 {
4393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4394 "%s: Adapter is NULL",__func__);
4395 return -EINVAL;
4396 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304397 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304398 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304399 if (0 != valid)
4400 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304401 return valid;
4402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004403
Arif Hussain6d2a3322013-11-17 19:50:10 -08004404 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004405
4406 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004407 {
Arif Hussaina9571842014-01-15 16:43:41 -08004408 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4409 if (NULL == pmacAddress) {
4410 hddLog(LOG1, "unable to allocate memory");
4411 return -ENOMEM;
4412 }
4413 if (copy_from_user((void *)pmacAddress,
4414 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4415 {
4416 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4417 kfree(pmacAddress);
4418 return -EFAULT;
4419 }
4420 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4421
4422 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004423 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004424
4425 if (!VOS_IS_STATUS_SUCCESS(status ))
4426 {
4427 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4428 }
Arif Hussained667642013-10-27 23:01:14 -07004429 }
Kiet Lam61589852013-09-19 17:10:58 +05304430 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304431 * link speed for first connected client will be returned.
4432 */
Arif Hussaina9571842014-01-15 16:43:41 -08004433 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304434 {
4435 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4436 }
4437 else
4438 {
4439 status = hdd_softap_GetStaId(pHostapdAdapter,
4440 (v_MACADDR_t *)macAddress, (void *)(&staId));
4441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004442
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304443 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304445 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 link_speed = 0;
4447 }
4448 else
4449 {
4450 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304451
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 if (!VOS_IS_STATUS_SUCCESS(status ))
4453 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 return -EINVAL;
4456 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304457
4458 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4459 staId, &link_speed);
4460
4461 link_speed = link_speed / 10;
4462
4463 if (0 == link_speed)
4464 {
4465 /* The linkspeed returned by HAL is in units of 500kbps.
4466 * converting it to mbps.
4467 * This is required to support legacy firmware which does
4468 * not return link capacity.
4469 */
4470 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 }
4473
4474 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004475 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 if ((rc < 0) || (rc >= len))
4478 {
4479 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304480 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 return -EIO;
4482 }
4483
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304484 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 return 0;
4486}
4487
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304488int iw_get_softap_linkspeed(struct net_device *dev,
4489 struct iw_request_info *info,
4490 union iwreq_data *wrqu,
4491 char *extra)
4492{
4493 int ret;
4494
4495 vos_ssr_protect(__func__);
4496 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4497 vos_ssr_unprotect(__func__);
4498
4499 return ret;
4500}
4501
4502
Jeff Johnson295189b2012-06-20 16:38:30 -07004503static const iw_handler hostapd_handler[] =
4504{
4505 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4506 (iw_handler) NULL, /* SIOCGIWNAME */
4507 (iw_handler) NULL, /* SIOCSIWNWID */
4508 (iw_handler) NULL, /* SIOCGIWNWID */
4509 (iw_handler) NULL, /* SIOCSIWFREQ */
4510 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4511 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304512 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 (iw_handler) NULL, /* SIOCSIWSENS */
4514 (iw_handler) NULL, /* SIOCGIWSENS */
4515 (iw_handler) NULL, /* SIOCSIWRANGE */
4516 (iw_handler) NULL, /* SIOCGIWRANGE */
4517 (iw_handler) NULL, /* SIOCSIWPRIV */
4518 (iw_handler) NULL, /* SIOCGIWPRIV */
4519 (iw_handler) NULL, /* SIOCSIWSTATS */
4520 (iw_handler) NULL, /* SIOCGIWSTATS */
4521 (iw_handler) NULL, /* SIOCSIWSPY */
4522 (iw_handler) NULL, /* SIOCGIWSPY */
4523 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4524 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4525 (iw_handler) NULL, /* SIOCSIWAP */
4526 (iw_handler) NULL, /* SIOCGIWAP */
4527 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4528 (iw_handler) NULL, /* SIOCGIWAPLIST */
4529 (iw_handler) NULL, /* SIOCSIWSCAN */
4530 (iw_handler) NULL, /* SIOCGIWSCAN */
4531 (iw_handler) NULL, /* SIOCSIWESSID */
4532 (iw_handler) NULL, /* SIOCGIWESSID */
4533 (iw_handler) NULL, /* SIOCSIWNICKN */
4534 (iw_handler) NULL, /* SIOCGIWNICKN */
4535 (iw_handler) NULL, /* -- hole -- */
4536 (iw_handler) NULL, /* -- hole -- */
4537 (iw_handler) NULL, /* SIOCSIWRATE */
4538 (iw_handler) NULL, /* SIOCGIWRATE */
4539 (iw_handler) NULL, /* SIOCSIWRTS */
4540 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4541 (iw_handler) NULL, /* SIOCSIWFRAG */
4542 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4543 (iw_handler) NULL, /* SIOCSIWTXPOW */
4544 (iw_handler) NULL, /* SIOCGIWTXPOW */
4545 (iw_handler) NULL, /* SIOCSIWRETRY */
4546 (iw_handler) NULL, /* SIOCGIWRETRY */
4547 (iw_handler) NULL, /* SIOCSIWENCODE */
4548 (iw_handler) NULL, /* SIOCGIWENCODE */
4549 (iw_handler) NULL, /* SIOCSIWPOWER */
4550 (iw_handler) NULL, /* SIOCGIWPOWER */
4551 (iw_handler) NULL, /* -- hole -- */
4552 (iw_handler) NULL, /* -- hole -- */
4553 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4554 (iw_handler) NULL, /* SIOCGIWGENIE */
4555 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4556 (iw_handler) NULL, /* SIOCGIWAUTH */
4557 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4558 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4559 (iw_handler) NULL, /* SIOCSIWPMKSA */
4560};
4561
Jeff Johnson224f3702014-03-26 11:09:47 -07004562/*
4563 * Note that the following ioctls were defined with semantics which
4564 * cannot be handled by the "iwpriv" userspace application and hence
4565 * they are not included in the hostapd_private_args array
4566 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4567 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004568
4569static const struct iw_priv_args hostapd_private_args[] = {
4570 { QCSAP_IOCTL_SETPARAM,
4571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4572 { QCSAP_IOCTL_SETPARAM,
4573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
4574 { QCSAP_PARAM_MAX_ASSOC,
4575 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4576 { QCSAP_PARAM_HIDE_SSID,
4577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004578 { QCSAP_PARAM_SET_MC_RATE,
4579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 { QCSAP_IOCTL_GETPARAM,
4581 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4583 { QCSAP_IOCTL_GETPARAM, 0,
4584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4585 { QCSAP_PARAM_MAX_ASSOC, 0,
4586 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004587 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4589 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4590 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304591 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 { QCSAP_PARAM_CLR_ACL, 0,
4594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4595 { QCSAP_PARAM_ACL_MODE,
4596 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 { QCSAP_IOCTL_GET_STAWPAIE,
4598 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4599 { QCSAP_IOCTL_SETWPAIE,
4600 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4601 { QCSAP_IOCTL_STOPBSS,
4602 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4603 { QCSAP_IOCTL_VERSION, 0,
4604 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004605 { QCSAP_IOCTL_GET_STA_INFO, 0,
4606 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004608 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004610 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004611 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304613 { QCSAP_IOCTL_AP_STATS, 0,
4614 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4616 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304617 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004618
4619 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4620 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4621 /* handlers for sub-ioctl */
4622 { WE_SET_WLAN_DBG,
4623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4624 0,
4625 "setwlandbg" },
4626
4627 /* handlers for main ioctl */
4628 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4629 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4630 0,
4631 "" },
4632
4633 /* handlers for sub-ioctl */
4634 { WE_LOG_DUMP_CMD,
4635 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4636 0,
4637 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 { WE_P2P_NOA_CMD,
4639 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4640 0,
4641 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004642 /* handlers for sub ioctl */
4643 {
4644 WE_MCC_CONFIG_CREDENTIAL,
4645 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4646 0,
4647 "setMccCrdnl" },
4648
4649 /* handlers for sub ioctl */
4650 {
4651 WE_MCC_CONFIG_PARAMS,
4652 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4653 0,
4654 "setMccConfig" },
4655
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 /* handlers for main ioctl */
4657 { QCSAP_IOCTL_MODIFY_ACL,
4658 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4659 0,
4660 "modify_acl" },
4661
4662 /* handlers for main ioctl */
4663 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4664 0,
4665 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4666 "getChannelList" },
4667
Jeff Johnsone7245742012-09-05 17:12:55 -07004668 /* handlers for main ioctl */
4669 { QCSAP_IOCTL_SET_TX_POWER,
4670 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4671 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304672 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004673
4674 /* handlers for main ioctl */
4675 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4676 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4677 0,
4678 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304679
4680 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4681 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4682 0,
4683 "dataSnapshot" },
4684
4685 /* handlers for main ioctl */
4686 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4687 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4688 0,
4689 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004690};
Jeff Johnsone7245742012-09-05 17:12:55 -07004691
Jeff Johnson295189b2012-06-20 16:38:30 -07004692static const iw_handler hostapd_private[] = {
4693 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4694 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4696 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4697 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4698 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4699 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4700 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4701 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4702 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4703 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304704 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4706 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4707 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4708 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004709 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004710 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4711 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004712 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304713 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304714 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Jeff Johnson295189b2012-06-20 16:38:30 -07004715};
4716const struct iw_handler_def hostapd_handler_def = {
4717 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4718 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4719 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4720 .standard = (iw_handler *)hostapd_handler,
4721 .private = (iw_handler *)hostapd_private,
4722 .private_args = hostapd_private_args,
4723 .get_wireless_stats = NULL,
4724};
4725#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4726struct net_device_ops net_ops_struct = {
4727 .ndo_open = hdd_hostapd_open,
4728 .ndo_stop = hdd_hostapd_stop,
4729 .ndo_uninit = hdd_hostapd_uninit,
4730 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4731 .ndo_tx_timeout = hdd_softap_tx_timeout,
4732 .ndo_get_stats = hdd_softap_stats,
4733 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4734 .ndo_do_ioctl = hdd_hostapd_ioctl,
4735 .ndo_change_mtu = hdd_hostapd_change_mtu,
4736 .ndo_select_queue = hdd_hostapd_select_queue,
4737 };
4738#endif
4739
4740int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4741{
4742 return VOS_STATUS_SUCCESS;
4743}
4744
4745void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4746{
4747#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4748 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4749#else
4750 pWlanHostapdDev->open = hdd_hostapd_open;
4751 pWlanHostapdDev->stop = hdd_hostapd_stop;
4752 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4753 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4754 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4755 pWlanHostapdDev->get_stats = hdd_softap_stats;
4756 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4757 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4758#endif
4759}
4760
4761VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304762{
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 hdd_hostapd_state_t * phostapdBuf;
4764 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004765 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004767#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004768 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4769 v_U16_t unsafeChannelCount;
4770#endif /* FEATURE_WLAN_CH_AVOID */
4771
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304772 if (pHddCtx->isLogpInProgress) {
4773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4774 "%s:LOGP in Progress. Ignore!!!",__func__);
4775 status = VOS_STATUS_E_FAILURE;
4776 }
4777
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304779 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304781
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004782 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4783
Leo Chang0b0e45a2013-12-15 15:18:55 -08004784#ifdef FEATURE_WLAN_CH_AVOID
4785 /* Get unsafe cahnnel list from cached location */
4786 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4787 sizeof(unsafeChannelList),
4788 &unsafeChannelCount);
4789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4790 "%s : Unsafe Channel count %d",
4791 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304792 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004793 unsafeChannelList,
4794 unsafeChannelCount);
4795#endif /* FEATURE_WLAN_CH_AVOID */
4796
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 // Zero the memory. This zeros the profile structure.
4798 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
4799
4800 // Set up the pointer to the Wireless Extensions state structure
4801 // NOP
4802 status = hdd_set_hostapd(pAdapter);
4803 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 return status;
4806 }
4807
4808 status = vos_event_init(&phostapdBuf->vosEvent);
4809 if (!VOS_IS_STATUS_SUCCESS(status))
4810 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 return status;
4813 }
4814
4815 init_completion(&pAdapter->session_close_comp_var);
4816 init_completion(&pAdapter->session_open_comp_var);
4817
4818 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4819
4820 // Register as a wireless device
4821 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4822
4823 //Initialize the data path module
4824 status = hdd_softap_init_tx_rx(pAdapter);
4825 if ( !VOS_IS_STATUS_SUCCESS( status ))
4826 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004827 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304829
4830 status = hdd_wmm_adapter_init( pAdapter );
4831 if (!VOS_IS_STATUS_SUCCESS(status))
4832 {
4833 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004834 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304835 status, status );
4836 goto error_wmm_init;
4837 }
4838
4839 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
4840
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304842
4843 return status;
4844
4845error_wmm_init:
4846 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 EXIT();
4848 return status;
4849}
4850
4851hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4852{
4853 struct net_device *pWlanHostapdDev = NULL;
4854 hdd_adapter_t *pHostapdAdapter = NULL;
4855 v_CONTEXT_t pVosContext= NULL;
4856
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004858
4859 if (pWlanHostapdDev != NULL)
4860 {
4861 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4862
4863 //Init the net_device structure
4864 ether_setup(pWlanHostapdDev);
4865
4866 //Initialize the adapter context to zeros.
4867 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4868 pHostapdAdapter->dev = pWlanHostapdDev;
4869 pHostapdAdapter->pHddCtx = pHddCtx;
4870 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4871
4872 //Get the Global VOSS context.
4873 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4874 //Save the adapter context in global context for future.
4875 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4876
4877 //Init the net_device structure
4878 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4879
4880 hdd_set_ap_ops( pHostapdAdapter->dev );
4881
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4883 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4884
4885 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4886 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4887
4888 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4890 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4891 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
4892 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
4894 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05304895 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07004896#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4897 init_completion(&pHostapdAdapter->offchannel_tx_event);
4898#endif
4899
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4901 }
4902 return pHostapdAdapter;
4903}
4904
4905VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4906{
4907 struct net_device *dev = pAdapter->dev;
4908 VOS_STATUS status = VOS_STATUS_SUCCESS;
4909
4910 ENTER();
4911
4912 if( rtnl_lock_held )
4913 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004914 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 if( dev_alloc_name(dev, dev->name) < 0 )
4916 {
4917 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4918 return VOS_STATUS_E_FAILURE;
4919 }
4920 }
4921 if (register_netdevice(dev))
4922 {
4923 hddLog(VOS_TRACE_LEVEL_FATAL,
4924 "%s:Failed:register_netdevice", __func__);
4925 return VOS_STATUS_E_FAILURE;
4926 }
4927 }
4928 else
4929 {
4930 if (register_netdev(dev))
4931 {
4932 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
4933 return VOS_STATUS_E_FAILURE;
4934 }
4935 }
4936 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
4937
4938 EXIT();
4939 return status;
4940}
4941
c_hpothu002231a2015-02-05 14:58:51 +05304942VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07004943{
4944 ENTER();
4945
4946 hdd_softap_deinit_tx_rx(pAdapter);
4947
4948 /* if we are being called during driver unload, then the dev has already
4949 been invalidated. if we are being called at other times, then we can
4950 detatch the wireless device handlers */
4951 if (pAdapter->dev)
4952 {
c_hpothu002231a2015-02-05 14:58:51 +05304953 if (TRUE == rtnl_held)
4954 {
4955 pAdapter->dev->wireless_handlers = NULL;
4956 }
4957 else
4958 {
4959 rtnl_lock();
4960 pAdapter->dev->wireless_handlers = NULL;
4961 rtnl_unlock();
4962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 }
4964 EXIT();
4965 return 0;
4966}