blob: bc5ff7a88c262b925d3349763338601e34a3b2b4 [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
Jeff Johnson224f3702014-03-26 11:09:47 -07002572 /* allocate local buffer to build the response */
2573 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2574 if (!buf) {
2575 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2576 return -ENOMEM;
2577 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302578 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2579 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2580 if(pSapCtx == NULL){
2581 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2582 FL("psapCtx is NULL"));
2583 return -EFAULT;
2584 }
2585 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002586 /* start indexing beyond where the record count will be written */
2587 maclist_index = sizeof(maclist_index);
2588 left = wrqu->data.length - maclist_index;
2589
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302590 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002591 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2592 if ((pStaInfo[cnt].isUsed) &&
2593 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2594 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2595 VOS_MAC_ADDR_SIZE);
2596 maclist_index += VOS_MAC_ADDR_SIZE;
2597 left -= VOS_MAC_ADDR_SIZE;
2598 }
2599 cnt++;
2600 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302601 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002602
2603 *((u32 *)buf) = maclist_index;
2604 wrqu->data.length = maclist_index;
2605 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2606 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2607 ret = -EFAULT;
2608 }
2609 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302610
2611 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002612 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002613}
2614
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302615int
2616static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2617 struct iw_request_info *info,
2618 union iwreq_data *wrqu, char *extra)
2619{
2620 int ret;
2621
2622 vos_ssr_protect(__func__);
2623 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2624 vos_ssr_unprotect(__func__);
2625
2626 return ret;
2627}
2628
Jeff Johnson295189b2012-06-20 16:38:30 -07002629/* Usage:
2630 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2631 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2632 while using this ioctl
2633
2634 Syntax:
2635 iwpriv softap.0 disassoc_sta <6 octet mac address>
2636
2637 e.g.
2638 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2639 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2640*/
2641
2642int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302643static __iw_softap_disassoc_sta(struct net_device *dev,
2644 struct iw_request_info *info,
2645 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002646{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302647 hdd_adapter_t *pHostapdAdapter;
2648 hdd_context_t *pHddCtx;
2649 v_U8_t *peerMacAddr;
2650 int ret = 0;
2651
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302653 pHostapdAdapter = (netdev_priv(dev));
2654 if (NULL == pHostapdAdapter)
2655 {
2656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2657 "%s: Adapter is NULL",__func__);
2658 return -EINVAL;
2659 }
2660 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2661 ret = wlan_hdd_validate_context(pHddCtx);
2662 if (0 != ret)
2663 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302664 return ret;
2665 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302666 /* iwpriv tool or framework calls this ioctl with
2667 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302669 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002670
Arif Hussain24bafea2013-11-15 15:10:03 -08002671 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2672 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2674 EXIT();
2675 return 0;
2676}
2677
2678int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302679static iw_softap_disassoc_sta(struct net_device *dev,
2680 struct iw_request_info *info,
2681 union iwreq_data *wrqu, char *extra)
2682{
2683 int ret;
2684
2685 vos_ssr_protect(__func__);
2686 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2687 vos_ssr_unprotect(__func__);
2688
2689 return ret;
2690}
2691
2692int
2693static __iw_softap_ap_stats(struct net_device *dev,
2694 struct iw_request_info *info,
2695 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002696{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302697 hdd_adapter_t *pHostapdAdapter;
2698 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 WLANTL_TRANSFER_STA_TYPE statBuffer;
2700 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302701 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002702
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302703 ENTER();
2704
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302705 pHostapdAdapter = (netdev_priv(dev));
2706 if (NULL == pHostapdAdapter)
2707 {
2708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2709 "%s: Adapter is NULL",__func__);
2710 return -EINVAL;
2711 }
2712 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2713 ret = wlan_hdd_validate_context(pHddCtx);
2714 if (0 != ret)
2715 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302716 return ret;
2717 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002718 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002719 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2720 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002721
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302722 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002723 if(NULL == pstatbuf) {
2724 hddLog(LOG1, "unable to allocate memory");
2725 return -ENOMEM;
2726 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302727
2728 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002729 "RUF=%d RMF=%d RBF=%d "
2730 "RUB=%d RMB=%d RBB=%d "
2731 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302732 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002733 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2734 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2735 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2736 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2737 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2738 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002739
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302740 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002741 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2742 kfree(pstatbuf);
2743 return -EFAULT;
2744 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302745
2746 strlcpy(extra, pstatbuf, len);
2747 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002748 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302749
2750 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 return 0;
2752}
2753
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302754int
2755static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 struct iw_request_info *info,
2757 union iwreq_data *wrqu, char *extra)
2758{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302759 int ret;
2760
2761 vos_ssr_protect(__func__);
2762 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2763 vos_ssr_unprotect(__func__);
2764
2765 return ret;
2766}
2767
2768static int __iw_softap_set_channel_range(struct net_device *dev,
2769 struct iw_request_info *info,
2770 union iwreq_data *wrqu, char *extra)
2771{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302772 hdd_adapter_t *pHostapdAdapter;
2773 tHalHandle hHal;
2774 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 int *value = (int *)extra;
2776 int startChannel = value[0];
2777 int endChannel = value[1];
2778 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002779 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 int ret = 0; /* success */
2781
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302782 ENTER();
2783
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302784 pHostapdAdapter = (netdev_priv(dev));
2785 if (NULL == pHostapdAdapter)
2786 {
2787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2788 "%s: Adapter is NULL",__func__);
2789 return -EINVAL;
2790 }
2791 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2792 ret = wlan_hdd_validate_context(pHddCtx);
2793 if (0 != ret)
2794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302795 return ret;
2796 }
2797 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2798 if (NULL == hHal)
2799 {
2800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2801 "%s: Hal Context is NULL",__func__);
2802 return -EINVAL;
2803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2805 if(status != VOS_STATUS_SUCCESS)
2806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002807 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 startChannel,endChannel, band);
2809 ret = -EINVAL;
2810 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002811
2812 pHddCtx->is_dynamic_channel_range_set = 1;
2813
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302814 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 return ret;
2816}
2817
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302818static int iw_softap_set_channel_range(struct net_device *dev,
2819 struct iw_request_info *info,
2820 union iwreq_data *wrqu, char *extra)
2821{
2822 int ret;
2823
2824 vos_ssr_protect(__func__);
2825 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
2826 vos_ssr_unprotect(__func__);
2827
2828 return ret;
2829}
2830
2831
2832int __iw_softap_get_channel_list(struct net_device *dev,
2833 struct iw_request_info *info,
2834 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002835{
2836 v_U32_t num_channels = 0;
2837 v_U8_t i = 0;
2838 v_U8_t bandStartChannel = RF_CHAN_1;
2839 v_U8_t bandEndChannel = RF_CHAN_165;
2840 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302841 hdd_adapter_t *pHostapdAdapter;
2842 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002845 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302846 hdd_context_t *pHddCtx;
2847 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302848
2849 ENTER();
2850
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302851 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2852 if (NULL == pHostapdAdapter)
2853 {
2854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2855 "%s: Adapter is NULL",__func__);
2856 return -EINVAL;
2857 }
2858 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2859 ret = wlan_hdd_validate_context(pHddCtx);
2860 if (0 != ret)
2861 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302862 return ret;
2863 }
2864 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2865 if (NULL == hHal)
2866 {
2867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2868 "%s: Hal Context is NULL",__func__);
2869 return -EINVAL;
2870 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002871 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2872 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002873 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002874 return -EIO;
2875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 wrqu->data.length = sizeof(tChannelListInfo);
2877 ENTER();
2878
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002879 if (eCSR_BAND_24 == curBand)
2880 {
2881 bandStartChannel = RF_CHAN_1;
2882 bandEndChannel = RF_CHAN_14;
2883 }
2884 else if (eCSR_BAND_5G == curBand)
2885 {
2886 bandStartChannel = RF_CHAN_36;
2887 bandEndChannel = RF_CHAN_165;
2888 }
2889
Arif Hussain6d2a3322013-11-17 19:50:10 -08002890 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05302891 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002892 bandStartChannel, bandEndChannel );
2893
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2895 {
2896 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2897 {
2898 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2899 num_channels++;
2900 }
2901 }
2902
2903 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2904
2905 temp_num_channels = num_channels;
2906
2907 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2908 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302909 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002910 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 }
2912
Agarwal Ashish7b557c02014-07-02 12:32:39 +05302913 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
2914 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 {
2916 for(i = 0; i < temp_num_channels; i++)
2917 {
2918
2919 if((channel_list->channels[i] > 35) &&
2920 (channel_list->channels[i] < 49))
2921 {
2922 vos_mem_move(&channel_list->channels[i],
2923 &channel_list->channels[i+1],
2924 temp_num_channels - (i-1));
2925 num_channels--;
2926 temp_num_channels--;
2927 i--;
2928 }
2929 }
2930 }
2931
Arif Hussain6d2a3322013-11-17 19:50:10 -08002932 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002933
2934 if (num_channels > IW_MAX_FREQUENCIES)
2935 {
2936 num_channels = IW_MAX_FREQUENCIES;
2937 }
2938
2939 channel_list->num_channels = num_channels;
2940 EXIT();
2941
2942 return 0;
2943}
2944
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302945int iw_softap_get_channel_list(struct net_device *dev,
2946 struct iw_request_info *info,
2947 union iwreq_data *wrqu, char *extra)
2948{
2949 int ret;
2950
2951 vos_ssr_protect(__func__);
2952 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
2953 vos_ssr_unprotect(__func__);
2954
2955 return ret;
2956}
2957
2958static
2959int __iw_get_genie(struct net_device *dev,
2960 struct iw_request_info *info,
2961 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002962{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302963 hdd_adapter_t *pHostapdAdapter;
2964 hdd_context_t *pHddCtx;
2965 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 eHalStatus status;
2967 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2968 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302969 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302970
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302972
2973 pHostapdAdapter = (netdev_priv(dev));
2974 if (NULL == pHostapdAdapter)
2975 {
2976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2977 "%s: Adapter is NULL",__func__);
2978 return -EINVAL;
2979 }
2980 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2981 ret = wlan_hdd_validate_context(pHddCtx);
2982 if (0 != ret)
2983 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302984 return ret;
2985 }
2986 pVosContext = pHddCtx->pvosContext;
2987 if (NULL == pVosContext)
2988 {
2989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2990 "%s: vos context is not valid ",__func__);
2991 return -EINVAL;
2992 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08002993 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2995 status = WLANSap_getstationIE_information(pVosContext,
2996 &length,
2997 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07002998 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2999 if (wrqu->data.length < length ||
3000 copy_to_user(wrqu->data.pointer,
3001 (v_VOID_t*)genIeBytes, length))
3002 {
3003 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3004 return -EFAULT;
3005 }
3006 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003007
Arif Hussain6d2a3322013-11-17 19:50:10 -08003008 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003009
3010
3011 EXIT();
3012 return 0;
3013}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303014
3015static
3016int iw_get_genie(struct net_device *dev,
3017 struct iw_request_info *info,
3018 union iwreq_data *wrqu, char *extra)
3019{
3020 int ret;
3021
3022 vos_ssr_protect(__func__);
3023 ret = __iw_get_genie(dev, info, wrqu, extra);
3024 vos_ssr_unprotect(__func__);
3025
3026 return ret;
3027}
3028
3029static
3030int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3031 struct iw_request_info *info,
3032 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003033{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303034 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003035 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303036 hdd_ap_ctx_t *pHddApCtx;
3037 hdd_context_t *pHddCtx;
3038 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303039
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003041
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303042 pHostapdAdapter = (netdev_priv(dev));
3043 if (NULL == pHostapdAdapter)
3044 {
3045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3046 "%s: Adapter is NULL",__func__);
3047 return -EINVAL;
3048 }
3049 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3050 ret = wlan_hdd_validate_context(pHddCtx);
3051 if (0 != ret)
3052 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303053 return ret;
3054 }
3055 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3056 if (NULL == pHddApCtx)
3057 {
3058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3059 "%s: AP context is NULL",__func__);
3060 return -EINVAL;
3061 }
3062
Arif Hussain6d2a3322013-11-17 19:50:10 -08003063 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003064 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3065
3066 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3067 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3068 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3069 WPSPBCProbeReqIEs.probeReqIELen);
3070 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3071 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3072 sizeof(v_MACADDR_t));
3073 if (copy_to_user(wrqu->data.pointer,
3074 (void *)&WPSPBCProbeReqIEs,
3075 sizeof(WPSPBCProbeReqIEs)))
3076 {
3077 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3078 return -EFAULT;
3079 }
3080 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003081 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003082 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 up(&pHddApCtx->semWpsPBCOverlapInd);
3084 EXIT();
3085 return 0;
3086}
3087
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303088static
3089int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3090 struct iw_request_info *info,
3091 union iwreq_data *wrqu, char *extra)
3092{
3093 int ret;
3094
3095 vos_ssr_protect(__func__);
3096 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3097 vos_ssr_unprotect(__func__);
3098
3099 return ret;
3100}
3101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102/**---------------------------------------------------------------------------
3103
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303104 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 This function sets the auth type received from the wpa_supplicant.
3106
3107 \param - dev - Pointer to the net device.
3108 - info - Pointer to the iw_request_info.
3109 - wrqu - Pointer to the iwreq_data.
3110 - extra - Pointer to the data.
3111 \return - 0 for success, non zero for failure
3112
3113 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303114int __iw_set_auth_hostap(struct net_device *dev,
3115 struct iw_request_info *info,
3116 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003117{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303118 hdd_adapter_t *pAdapter;
3119 hdd_context_t *pHddCtx;
3120 hdd_wext_state_t *pWextState;
3121 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303122
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303124
3125 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3126 if (NULL == pAdapter)
3127 {
3128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3129 "%s: Adapter is NULL",__func__);
3130 return -EINVAL;
3131 }
3132
3133 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3134 ret = wlan_hdd_validate_context(pHddCtx);
3135 if (0 != ret)
3136 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303137 return ret;
3138 }
3139 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3140 if (NULL == pWextState)
3141 {
3142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3143 "%s: pWextState is NULL",__func__);
3144 return -EINVAL;
3145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 switch(wrqu->param.flags & IW_AUTH_INDEX)
3147 {
3148 case IW_AUTH_TKIP_COUNTERMEASURES:
3149 {
3150 if(wrqu->param.value) {
3151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3152 "Counter Measure started %d", wrqu->param.value);
3153 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303154 }
3155 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3157 "Counter Measure stopped=%d", wrqu->param.value);
3158 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3159 }
3160
3161 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3162 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303165
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303167
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003168 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 wrqu->param.flags & IW_AUTH_INDEX);
3170 break;
3171 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303172
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 EXIT();
3174 return 0;
3175}
3176
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303177int iw_set_auth_hostap(struct net_device *dev,
3178 struct iw_request_info *info,
3179 union iwreq_data *wrqu,char *extra)
3180{
3181 int ret;
3182
3183 vos_ssr_protect(__func__);
3184 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3185 vos_ssr_unprotect(__func__);
3186
3187 return ret;
3188}
3189
3190static int __iw_set_ap_encodeext(struct net_device *dev,
3191 struct iw_request_info *info,
3192 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003193{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303194 hdd_adapter_t *pHostapdAdapter;
3195 v_CONTEXT_t pVosContext;
3196 hdd_context_t *pHddCtx;
3197 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003198 int retval = 0;
3199 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3201 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3202 int key_index;
3203 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303204 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205// tCsrRoamRemoveKey RemoveKey;
3206 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303207
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303208 ENTER();
3209 pHostapdAdapter = (netdev_priv(dev));
3210 if (NULL == pHostapdAdapter)
3211 {
3212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3213 "%s: Adapter is NULL",__func__);
3214 return -EINVAL;
3215 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003216
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303217 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3218 retval = wlan_hdd_validate_context(pHddCtx);
3219 if (0 != retval)
3220 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303221 return retval;
3222 }
3223 pVosContext = pHddCtx->pvosContext;
3224 if (NULL == pVosContext)
3225 {
3226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3227 "%s: pVosContext is NULL",__func__);
3228 return -EINVAL;
3229 }
3230 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3231 if (NULL == pHddApCtx)
3232 {
3233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3234 "%s: AP Context is NULL",__func__);
3235 return -EINVAL;
3236 }
3237
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303239
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303241
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 /*Convert from 1-based to 0-based keying*/
3243 key_index--;
3244 }
3245 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303246#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 /*Set the encrytion type to NONE*/
3248#if 0
3249 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3250#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303251
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 RemoveKey.keyId = key_index;
3253 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3254 /*Key direction for group is RX only*/
3255 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3256 }
3257 else {
3258 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3259 }
3260 switch(ext->alg)
3261 {
3262 case IW_ENCODE_ALG_NONE:
3263 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3264 break;
3265 case IW_ENCODE_ALG_WEP:
3266 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3267 break;
3268 case IW_ENCODE_ALG_TKIP:
3269 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003270 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 case IW_ENCODE_ALG_CCMP:
3272 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3273 break;
3274 default:
3275 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3276 break;
3277 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003278 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 -07003279 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003281 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003283 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3284 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 {
3286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003287 __LINE__, vstatus );
3288 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003290#endif
3291 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003292
Jeff Johnson43971f52012-07-17 12:26:56 -07003293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003294
3295 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3296
3297 setKey.keyId = key_index;
3298 setKey.keyLength = ext->key_len;
3299
3300 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3301 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3302 }
3303
3304 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3305 /*Key direction for group is RX only*/
3306 setKey.keyDirection = eSIR_RX_ONLY;
3307 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3308 }
3309 else {
3310
3311 setKey.keyDirection = eSIR_TX_RX;
3312 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3313 }
3314 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3315 {
3316 setKey.keyDirection = eSIR_TX_DEFAULT;
3317 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3318 }
3319
3320 /*For supplicant pae role is zero*/
3321 setKey.paeRole = 0;
3322
3323 switch(ext->alg)
3324 {
3325 case IW_ENCODE_ALG_NONE:
3326 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3327 break;
3328
3329 case IW_ENCODE_ALG_WEP:
3330 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3331 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003332 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 break;
3334
3335 case IW_ENCODE_ALG_TKIP:
3336 {
3337 v_U8_t *pKey = &setKey.Key[0];
3338
3339 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3340
3341 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3342
3343 /*Supplicant sends the 32bytes key in this order
3344
3345 |--------------|----------|----------|
3346 | Tk1 |TX-MIC | RX Mic |
3347 |--------------|----------|----------|
3348 <---16bytes---><--8bytes--><--8bytes-->
3349
3350 */
3351 /*Sme expects the 32 bytes key to be in the below order
3352
3353 |--------------|----------|----------|
3354 | Tk1 |RX-MIC | TX Mic |
3355 |--------------|----------|----------|
3356 <---16bytes---><--8bytes--><--8bytes-->
3357 */
3358 /* Copy the Temporal Key 1 (TK1) */
3359 vos_mem_copy(pKey,ext->key,16);
3360
3361 /*Copy the rx mic first*/
3362 vos_mem_copy(&pKey[16],&ext->key[24],8);
3363
3364 /*Copy the tx mic */
3365 vos_mem_copy(&pKey[24],&ext->key[16],8);
3366
3367 }
3368 break;
3369
3370 case IW_ENCODE_ALG_CCMP:
3371 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3372 break;
3373
3374 default:
3375 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3376 break;
3377 }
3378
3379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303380 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 setKey.keyId);
3382 for(i=0; i< ext->key_len; i++)
3383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3384 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003385
3386 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3387 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 {
3389 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003390 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3391 retval = -EINVAL;
3392 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303393
3394 EXIT();
3395 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003396}
Jeff Johnson43971f52012-07-17 12:26:56 -07003397
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303398static int iw_set_ap_encodeext(struct net_device *dev,
3399 struct iw_request_info *info,
3400 union iwreq_data *wrqu, char *extra)
3401{
3402 int ret;
3403
3404 vos_ssr_protect(__func__);
3405 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3406 vos_ssr_unprotect(__func__);
3407
3408 return ret;
3409}
Jeff Johnson43971f52012-07-17 12:26:56 -07003410
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303411static int __iw_set_ap_mlme(struct net_device *dev,
3412 struct iw_request_info *info,
3413 union iwreq_data *wrqu,
3414 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003415{
3416#if 0
3417 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3418 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3419
3420 ENTER();
3421
3422 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3423 switch (mlme->cmd) {
3424 case IW_MLME_DISASSOC:
3425 case IW_MLME_DEAUTH:
3426 hddLog(LOG1, "Station disassociate");
3427 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3428 {
3429 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3430
3431 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3432 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3433
3434 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3435
3436 //clear all the reason codes
3437 if (status != 0)
3438 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003439 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 }
3441
3442 netif_stop_queue(dev);
3443 netif_carrier_off(dev);
3444 }
3445 else
3446 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003447 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 -07003448 }
3449 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003450 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 return -EINVAL;
3452 }//end of switch
3453 EXIT();
3454#endif
3455 return 0;
3456// return status;
3457}
3458
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303459static int iw_set_ap_mlme(struct net_device *dev,
3460 struct iw_request_info *info,
3461 union iwreq_data *wrqu,
3462 char *extra)
3463{
3464 int ret;
3465
3466 vos_ssr_protect(__func__);
3467 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3468 vos_ssr_unprotect(__func__);
3469
3470 return ret;
3471}
3472
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303473static int __iw_get_ap_rts_threshold(struct net_device *dev,
3474 struct iw_request_info *info,
3475 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003476{
3477 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3478 v_U32_t status = 0;
3479
3480 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3481
3482 return status;
3483}
3484
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303485static int iw_get_ap_rts_threshold(struct net_device *dev,
3486 struct iw_request_info *info,
3487 union iwreq_data *wrqu, char *extra)
3488{
3489 int ret;
3490
3491 vos_ssr_protect(__func__);
3492 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3493 vos_ssr_unprotect(__func__);
3494
3495 return ret;
3496}
3497
3498static int __iw_get_ap_frag_threshold(struct net_device *dev,
3499 struct iw_request_info *info,
3500 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003501{
3502 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3503 v_U32_t status = 0;
3504
3505 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3506
3507 return status;
3508}
3509
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303510static int iw_get_ap_frag_threshold(struct net_device *dev,
3511 struct iw_request_info *info,
3512 union iwreq_data *wrqu, char *extra)
3513{
3514 int ret;
3515
3516 vos_ssr_protect(__func__);
3517 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3518 vos_ssr_unprotect(__func__);
3519
3520 return ret;
3521}
3522
3523static int __iw_get_ap_freq(struct net_device *dev,
3524 struct iw_request_info *info,
3525 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003526{
Jeff Johnsone7245742012-09-05 17:12:55 -07003527 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303528 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 tHalHandle hHal;
3530 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303531 hdd_ap_ctx_t *pHddApCtx;
3532 hdd_context_t *pHddCtx;
3533 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003534
3535 ENTER();
3536
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303537 pHostapdAdapter = (netdev_priv(dev));
3538 if (NULL == pHostapdAdapter)
3539 {
3540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3541 "%s: Adapter is NULL",__func__);
3542 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303544 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3545 ret = wlan_hdd_validate_context(pHddCtx);
3546 if (0 != ret)
3547 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303548 return ret;
3549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303551 if (NULL == pHostapdState)
3552 {
3553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3554 "%s: pHostapdState is NULL",__func__);
3555 return -EINVAL;
3556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303558 if (NULL == hHal)
3559 {
3560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3561 "%s: Hal Context is NULL",__func__);
3562 return -EINVAL;
3563 }
3564 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3565 if (NULL == pHddApCtx)
3566 {
3567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3568 "%s: AP context is NULL",__func__);
3569 return -EINVAL;
3570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 if(pHostapdState->bssState == BSS_STOP )
3572 {
3573 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3574 != eHAL_STATUS_SUCCESS)
3575 {
c_hpothuffdb5272013-10-02 16:42:35 +05303576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3577 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 return -EIO;
3579 }
3580 else
3581 {
3582 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003583 if( TRUE == status)
3584 {
3585 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3586 * iwlist & iwconfig command shows frequency into proper
3587 * format (2.412 GHz instead of 246.2 MHz)*/
3588 fwrq->m = freq;
3589 fwrq->e = MHZ;
3590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 }
3592 }
3593 else
3594 {
3595 channel = pHddApCtx->operatingChannel;
3596 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003597 if( TRUE == status)
3598 {
3599 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3600 * iwlist & iwconfig command shows frequency into proper
3601 * format (2.412 GHz instead of 246.2 MHz)*/
3602 fwrq->m = freq;
3603 fwrq->e = MHZ;
3604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303606
3607 EXIT();
3608 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003609}
3610
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303611static int iw_get_ap_freq(struct net_device *dev,
3612 struct iw_request_info *info,
3613 struct iw_freq *fwrq, char *extra)
3614{
3615 int ret;
3616
3617 vos_ssr_protect(__func__);
3618 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3619 vos_ssr_unprotect(__func__);
3620
3621 return ret;
3622}
3623
3624static int __iw_get_mode(struct net_device *dev,
3625 struct iw_request_info *info,
3626 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303627{
3628 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303629 hdd_adapter_t *pAdapter;
3630 hdd_context_t *pHddCtx;
3631
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303632 ENTER();
3633
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303634 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3635 if (NULL == pAdapter)
3636 {
3637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3638 "%s: Adapter is NULL",__func__);
3639 return -EINVAL;
3640 }
3641 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3642 status = wlan_hdd_validate_context(pHddCtx);
3643 if (0 != status)
3644 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303645 return status;
3646 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303647
3648 wrqu->mode = IW_MODE_MASTER;
3649
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303650 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303651 return status;
3652}
3653
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303654static int iw_get_mode(struct net_device *dev,
3655 struct iw_request_info *info,
3656 union iwreq_data *wrqu, char *extra)
3657{
3658 int ret;
3659
3660 vos_ssr_protect(__func__);
3661 ret = __iw_get_mode(dev, info, wrqu, extra);
3662 vos_ssr_unprotect(__func__);
3663
3664 return ret;
3665}
3666
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303667static int __iw_softap_setwpsie(struct net_device *dev,
3668 struct iw_request_info *info,
3669 union iwreq_data *wrqu,
3670 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003671{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303672 hdd_adapter_t *pHostapdAdapter;
3673 hdd_context_t *pHddCtx;
3674 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 hdd_hostapd_state_t *pHostapdState;
3676 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003677 u_int8_t *wps_genie;
3678 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 u_int8_t *pos;
3680 tpSap_WPSIE pSap_WPSIe;
3681 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303682 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303683 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303684 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303685
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 ENTER();
3687
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303688 pHostapdAdapter = (netdev_priv(dev));
3689 if (NULL == pHostapdAdapter)
3690 {
3691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3692 "%s: Adapter is NULL",__func__);
3693 return -EINVAL;
3694 }
3695 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3696 ret = wlan_hdd_validate_context(pHddCtx);
3697 if (0 != ret)
3698 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303699 return ret;
3700 }
3701 pVosContext = pHddCtx->pvosContext;
3702 if (NULL == pVosContext)
3703 {
3704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3705 "%s: HDD context is not valid ",__func__);
3706 return -EINVAL;
3707 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303708 /* helper function to get iwreq_data with compat handling. */
3709 if (hdd_priv_get_data(&s_priv_data, wrqu))
3710 {
3711 return -EINVAL;
3712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003713
Girish Gowli07c05ec2014-06-17 20:47:03 +05303714 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3715 {
3716 return -EINVAL;
3717 }
3718
3719 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3720 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003721
Girish Gowli86c471e2014-06-17 19:28:05 +05303722 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003723 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303724 hddLog(LOG1, "%s: failed to alloc memory "
3725 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003726 return -EFAULT;
3727 }
3728
Girish Gowli86c471e2014-06-17 19:28:05 +05303729 fwps_genie = wps_genie;
3730
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3732 if (NULL == pSap_WPSIe)
3733 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003734 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003735 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 return -ENOMEM;
3737 }
3738 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3739
Arif Hussain6d2a3322013-11-17 19:50:10 -08003740 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 -07003741 WPSIeType = wps_genie[0];
3742 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3743 {
3744 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3745 wps_genie = wps_genie + 1;
3746 switch ( wps_genie[0] )
3747 {
3748 case DOT11F_EID_WPA:
3749 if (wps_genie[1] < 2 + 4)
3750 {
3751 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003752 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 return -EINVAL;
3754 }
3755 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3756 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003757 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 pos = &wps_genie[6];
3759 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3760 {
3761 switch((u_int16_t)(*pos<<8) | *(pos+1))
3762 {
3763 case HDD_WPS_ELEM_VERSION:
3764 pos += 4;
3765 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003766 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3768 pos += 1;
3769 break;
3770
3771 case HDD_WPS_ELEM_WPS_STATE:
3772 pos +=4;
3773 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003774 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3776 pos += 1;
3777 break;
3778 case HDD_WPS_ELEM_APSETUPLOCK:
3779 pos += 4;
3780 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003781 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3783 pos += 1;
3784 break;
3785 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3786 pos += 4;
3787 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003788 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3790 pos += 1;
3791 break;
3792 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3793 pos += 4;
3794 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003795 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3797 pos += 2;
3798 break;
3799 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3800 pos += 4;
3801 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003802 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3804 pos += 2;
3805 break;
3806
3807 case HDD_WPS_ELEM_UUID_E:
3808 pos += 2;
3809 length = *pos<<8 | *(pos+1);
3810 pos += 2;
3811 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3812 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3813 pos += length;
3814 break;
3815 case HDD_WPS_ELEM_RF_BANDS:
3816 pos += 4;
3817 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003818 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3820 pos += 1;
3821 break;
3822
3823 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003824 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003826 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 return -EINVAL;
3828 }
3829 }
3830 }
3831 else {
3832 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003833 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 }
3835 break;
3836
3837 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003838 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003840 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 return 0;
3842 }
3843 }
3844 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
3845 {
3846 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
3847 wps_genie = wps_genie + 1;
3848 switch ( wps_genie[0] )
3849 {
3850 case DOT11F_EID_WPA:
3851 if (wps_genie[1] < 2 + 4)
3852 {
3853 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003854 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 return -EINVAL;
3856 }
3857 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3858 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003859 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 pos = &wps_genie[6];
3861 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3862 {
3863 switch((u_int16_t)(*pos<<8) | *(pos+1))
3864 {
3865 case HDD_WPS_ELEM_VERSION:
3866 pos += 4;
3867 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003868 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
3870 pos += 1;
3871 break;
3872
3873 case HDD_WPS_ELEM_WPS_STATE:
3874 pos +=4;
3875 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003876 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
3878 pos += 1;
3879 break;
3880 case HDD_WPS_ELEM_APSETUPLOCK:
3881 pos += 4;
3882 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003883 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
3885 pos += 1;
3886 break;
3887 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3888 pos += 4;
3889 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003890 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
3892 pos += 1;
3893 break;
3894 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3895 pos += 4;
3896 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003897 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
3899 pos += 2;
3900 break;
3901 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3902 pos += 4;
3903 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003904 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
3906 pos += 2;
3907 break;
3908 case HDD_WPS_ELEM_RSP_TYPE:
3909 pos += 4;
3910 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003911 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
3913 pos += 1;
3914 break;
3915 case HDD_WPS_ELEM_UUID_E:
3916 pos += 2;
3917 length = *pos<<8 | *(pos+1);
3918 pos += 2;
3919 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
3920 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
3921 pos += length;
3922 break;
3923
3924 case HDD_WPS_ELEM_MANUFACTURER:
3925 pos += 2;
3926 length = *pos<<8 | *(pos+1);
3927 pos += 2;
3928 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
3929 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
3930 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
3931 pos += length;
3932 break;
3933
3934 case HDD_WPS_ELEM_MODEL_NAME:
3935 pos += 2;
3936 length = *pos<<8 | *(pos+1);
3937 pos += 2;
3938 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
3939 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
3940 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
3941 pos += length;
3942 break;
3943 case HDD_WPS_ELEM_MODEL_NUM:
3944 pos += 2;
3945 length = *pos<<8 | *(pos+1);
3946 pos += 2;
3947 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
3948 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
3949 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
3950 pos += length;
3951 break;
3952 case HDD_WPS_ELEM_SERIAL_NUM:
3953 pos += 2;
3954 length = *pos<<8 | *(pos+1);
3955 pos += 2;
3956 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
3957 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
3958 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
3959 pos += length;
3960 break;
3961 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
3962 pos += 4;
3963 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003964 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 pos += 2;
3966
3967 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003968 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 pos += 4;
3970 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003971 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 pos += 2;
3973 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
3974 break;
3975 case HDD_WPS_ELEM_DEVICE_NAME:
3976 pos += 2;
3977 length = *pos<<8 | *(pos+1);
3978 pos += 2;
3979 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
3980 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
3981 pos += length;
3982 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
3983 break;
3984 case HDD_WPS_ELEM_CONFIG_METHODS:
3985 pos += 4;
3986 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003987 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 pos += 2;
3989 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
3990 break;
3991
3992 case HDD_WPS_ELEM_RF_BANDS:
3993 pos += 4;
3994 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003995 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 pos += 1;
3997 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
3998 break;
3999 } // switch
4000 }
4001 }
4002 else
4003 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004004 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 }
4006
4007 } // switch
4008 }
4009 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
4010 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4011 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4012 {
4013 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4014 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4015 WLANSAP_Update_WpsIe ( pVosContext );
4016 }
4017
4018 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004019 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 EXIT();
4021 return halStatus;
4022}
4023
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304024static int iw_softap_setwpsie(struct net_device *dev,
4025 struct iw_request_info *info,
4026 union iwreq_data *wrqu,
4027 char *extra)
4028{
4029 int ret;
4030
4031 vos_ssr_protect(__func__);
4032 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4033 vos_ssr_unprotect(__func__);
4034
4035 return ret;
4036}
4037
4038static int __iw_softap_stopbss(struct net_device *dev,
4039 struct iw_request_info *info,
4040 union iwreq_data *wrqu,
4041 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004042{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304043 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304045 hdd_context_t *pHddCtx = NULL;
4046
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304048 pHostapdAdapter = (netdev_priv(dev));
4049 if (NULL == pHostapdAdapter)
4050 {
4051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4052 "%s: Adapter is NULL",__func__);
4053 return -EINVAL;
4054 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304055 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4056 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304057 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304058 return status;
4059 }
4060
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304061 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 {
4063 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4064 {
4065 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4066
4067 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304070 {
4071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004072 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 VOS_ASSERT(0);
4074 }
4075 }
4076 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304077 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 }
4079 EXIT();
4080 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4081}
4082
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304083static int iw_softap_stopbss(struct net_device *dev,
4084 struct iw_request_info *info,
4085 union iwreq_data *wrqu,
4086 char *extra)
4087{
4088 int ret;
4089
4090 vos_ssr_protect(__func__);
4091 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4092 vos_ssr_unprotect(__func__);
4093
4094 return ret;
4095}
4096
4097static int __iw_softap_version(struct net_device *dev,
4098 struct iw_request_info *info,
4099 union iwreq_data *wrqu,
4100 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004101{
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304103 hdd_context_t *pHddCtx;
4104 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304107 pHostapdAdapter = (netdev_priv(dev));
4108 if (NULL == pHostapdAdapter)
4109 {
4110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4111 "%s: Adapter is NULL",__func__);
4112 return -EINVAL;
4113 }
4114 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4115 ret = wlan_hdd_validate_context(pHddCtx);
4116 if (0 != ret)
4117 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304118 return ret;
4119 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004120 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 return 0;
4123}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004124
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304125static int iw_softap_version(struct net_device *dev,
4126 struct iw_request_info *info,
4127 union iwreq_data *wrqu,
4128 char *extra)
4129{
4130 int ret;
4131
4132 vos_ssr_protect(__func__);
4133 ret = __iw_softap_version(dev, info, wrqu, extra);
4134 vos_ssr_unprotect(__func__);
4135
4136 return ret;
4137}
4138
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004139VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004140{
4141 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004142 int len = 0;
4143 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304144 v_CONTEXT_t pVosContext;
4145 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304146 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304147
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304148 ENTER();
4149
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304150 if (NULL == pAdapter)
4151 {
4152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4153 "%s: Adapter is NULL",__func__);
4154 return -EINVAL;
4155 }
4156 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4157 if (0 != wlan_hdd_validate_context(pHddCtx))
4158 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304159 return VOS_STATUS_E_FAULT;
4160 }
4161 pVosContext = pHddCtx->pvosContext;
4162 if (NULL == pVosContext)
4163 {
4164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4165 "%s: VOS context is not valid",__func__);
4166 return VOS_STATUS_E_FAULT;
4167 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304168 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304169 if(pSapCtx == NULL)
4170 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304171 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4172 FL("psapCtx is NULL"));
4173 return VOS_STATUS_E_FAULT;
4174 }
4175
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004176 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004177 pBuf += len;
4178 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004179
4180 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4181 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304182 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004183 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004184 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304185 pSapCtx->aStaInfo[i].ucSTAId,
4186 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4187 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4188 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4189 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4190 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4191 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004192 pBuf += len;
4193 buf_len -= len;
4194 }
4195 if(WE_GET_STA_INFO_SIZE > buf_len)
4196 {
4197 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004198 }
4199 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304200 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004201 return VOS_STATUS_SUCCESS;
4202}
4203
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304204static int __iw_softap_get_sta_info(struct net_device *dev,
4205 struct iw_request_info *info,
4206 union iwreq_data *wrqu,
4207 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004208{
4209 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4210 VOS_STATUS status;
4211 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004212 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004213 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004214 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004215 return -EINVAL;
4216 }
4217 wrqu->data.length = strlen(extra);
4218 EXIT();
4219 return 0;
4220}
4221
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304222static int iw_softap_get_sta_info(struct net_device *dev,
4223 struct iw_request_info *info,
4224 union iwreq_data *wrqu,
4225 char *extra)
4226{
4227 int ret;
4228
4229 vos_ssr_protect(__func__);
4230 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4231 vos_ssr_unprotect(__func__);
4232
4233 return ret;
4234}
4235
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304236static int __iw_set_ap_genie(struct net_device *dev,
4237 struct iw_request_info *info,
4238 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004239{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304240
4241 hdd_adapter_t *pHostapdAdapter;
4242 hdd_context_t *pHddCtx;
4243 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004245 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304246 int ret = 0;
4247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304249 pHostapdAdapter = (netdev_priv(dev));
4250 if (NULL == pHostapdAdapter)
4251 {
4252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4253 "%s: Adapter is NULL",__func__);
4254 return -EINVAL;
4255 }
4256 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4257 ret = wlan_hdd_validate_context(pHddCtx);
4258 if (0 != ret)
4259 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304260 return ret;
4261 }
4262 pVosContext = pHddCtx->pvosContext;
4263 if (NULL == pVosContext)
4264 {
4265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4266 "%s: VOS Context is NULL",__func__);
4267 return -EINVAL;
4268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 if(!wrqu->data.length)
4270 {
4271 EXIT();
4272 return 0;
4273 }
Arif Hussained667642013-10-27 23:01:14 -07004274
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304275 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304277 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 case DOT11F_EID_RSN:
4279 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4280 {
4281 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4282 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004285 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304287
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004289 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 halStatus = 0;
4291 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304292
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304294 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004295}
4296
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304297static int iw_set_ap_genie(struct net_device *dev,
4298 struct iw_request_info *info,
4299 union iwreq_data *wrqu, char *extra)
4300{
4301 int ret;
4302
4303 vos_ssr_protect(__func__);
4304 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4305 vos_ssr_unprotect(__func__);
4306
4307 return ret;
4308}
4309
Jeff Johnson295189b2012-06-20 16:38:30 -07004310static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4311{
4312 eHalStatus hstatus;
4313 long lrc;
4314 struct statsContext context;
4315
4316 if (NULL == pAdapter)
4317 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304318 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 return VOS_STATUS_E_FAULT;
4320 }
4321
4322 init_completion(&context.completion);
4323 context.pAdapter = pAdapter;
4324 context.magic = STATS_CONTEXT_MAGIC;
4325 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4326 eCSR_HDD,
4327 SME_GLOBAL_CLASSA_STATS,
4328 hdd_GetClassA_statisticsCB,
4329 0, // not periodic
4330 FALSE, //non-cached results
4331 staid,
4332 &context);
4333 if (eHAL_STATUS_SUCCESS != hstatus)
4334 {
4335 hddLog(VOS_TRACE_LEVEL_ERROR,
4336 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004337 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 }
4339 else
4340 {
4341 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4342 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 if (lrc <= 0)
4344 {
4345 hddLog(VOS_TRACE_LEVEL_ERROR,
4346 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004347 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 }
4349 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004350
4351 /* either we never sent a request, we sent a request and received a
4352 response or we sent a request and timed out. if we never sent a
4353 request or if we sent a request and got a response, we want to
4354 clear the magic out of paranoia. if we timed out there is a
4355 race condition such that the callback function could be
4356 executing at the same time we are. of primary concern is if the
4357 callback function had already verified the "magic" but had not
4358 yet set the completion variable when a timeout occurred. we
4359 serialize these activities by invalidating the magic while
4360 holding a shared spinlock which will cause us to block if the
4361 callback is currently executing */
4362 spin_lock(&hdd_context_lock);
4363 context.magic = 0;
4364 spin_unlock(&hdd_context_lock);
4365
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 return VOS_STATUS_SUCCESS;
4367}
4368
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304369int __iw_get_softap_linkspeed(struct net_device *dev,
4370 struct iw_request_info *info,
4371 union iwreq_data *wrqu,
4372 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004373
4374{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304375 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304376 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004378 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304379 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304381 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004383 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304384 int rc, valid;
4385
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304386 ENTER();
4387
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304388 pHostapdAdapter = (netdev_priv(dev));
4389 if (NULL == pHostapdAdapter)
4390 {
4391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4392 "%s: Adapter is NULL",__func__);
4393 return -EINVAL;
4394 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304395 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304396 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304397 if (0 != valid)
4398 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304399 return valid;
4400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004401
Arif Hussain6d2a3322013-11-17 19:50:10 -08004402 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004403
4404 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004405 {
Arif Hussaina9571842014-01-15 16:43:41 -08004406 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4407 if (NULL == pmacAddress) {
4408 hddLog(LOG1, "unable to allocate memory");
4409 return -ENOMEM;
4410 }
4411 if (copy_from_user((void *)pmacAddress,
4412 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4413 {
4414 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4415 kfree(pmacAddress);
4416 return -EFAULT;
4417 }
4418 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4419
4420 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004421 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004422
4423 if (!VOS_IS_STATUS_SUCCESS(status ))
4424 {
4425 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4426 }
Arif Hussained667642013-10-27 23:01:14 -07004427 }
Kiet Lam61589852013-09-19 17:10:58 +05304428 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304429 * link speed for first connected client will be returned.
4430 */
Arif Hussaina9571842014-01-15 16:43:41 -08004431 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304432 {
4433 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4434 }
4435 else
4436 {
4437 status = hdd_softap_GetStaId(pHostapdAdapter,
4438 (v_MACADDR_t *)macAddress, (void *)(&staId));
4439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004440
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304441 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304443 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 link_speed = 0;
4445 }
4446 else
4447 {
4448 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304449
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 if (!VOS_IS_STATUS_SUCCESS(status ))
4451 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304452 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 return -EINVAL;
4454 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304455
4456 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4457 staId, &link_speed);
4458
4459 link_speed = link_speed / 10;
4460
4461 if (0 == link_speed)
4462 {
4463 /* The linkspeed returned by HAL is in units of 500kbps.
4464 * converting it to mbps.
4465 * This is required to support legacy firmware which does
4466 * not return link capacity.
4467 */
4468 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 }
4471
4472 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004473 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304474
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 if ((rc < 0) || (rc >= len))
4476 {
4477 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304478 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 return -EIO;
4480 }
4481
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304482 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 return 0;
4484}
4485
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304486int iw_get_softap_linkspeed(struct net_device *dev,
4487 struct iw_request_info *info,
4488 union iwreq_data *wrqu,
4489 char *extra)
4490{
4491 int ret;
4492
4493 vos_ssr_protect(__func__);
4494 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4495 vos_ssr_unprotect(__func__);
4496
4497 return ret;
4498}
4499
4500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501static const iw_handler hostapd_handler[] =
4502{
4503 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4504 (iw_handler) NULL, /* SIOCGIWNAME */
4505 (iw_handler) NULL, /* SIOCSIWNWID */
4506 (iw_handler) NULL, /* SIOCGIWNWID */
4507 (iw_handler) NULL, /* SIOCSIWFREQ */
4508 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4509 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304510 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 (iw_handler) NULL, /* SIOCSIWSENS */
4512 (iw_handler) NULL, /* SIOCGIWSENS */
4513 (iw_handler) NULL, /* SIOCSIWRANGE */
4514 (iw_handler) NULL, /* SIOCGIWRANGE */
4515 (iw_handler) NULL, /* SIOCSIWPRIV */
4516 (iw_handler) NULL, /* SIOCGIWPRIV */
4517 (iw_handler) NULL, /* SIOCSIWSTATS */
4518 (iw_handler) NULL, /* SIOCGIWSTATS */
4519 (iw_handler) NULL, /* SIOCSIWSPY */
4520 (iw_handler) NULL, /* SIOCGIWSPY */
4521 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4522 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4523 (iw_handler) NULL, /* SIOCSIWAP */
4524 (iw_handler) NULL, /* SIOCGIWAP */
4525 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4526 (iw_handler) NULL, /* SIOCGIWAPLIST */
4527 (iw_handler) NULL, /* SIOCSIWSCAN */
4528 (iw_handler) NULL, /* SIOCGIWSCAN */
4529 (iw_handler) NULL, /* SIOCSIWESSID */
4530 (iw_handler) NULL, /* SIOCGIWESSID */
4531 (iw_handler) NULL, /* SIOCSIWNICKN */
4532 (iw_handler) NULL, /* SIOCGIWNICKN */
4533 (iw_handler) NULL, /* -- hole -- */
4534 (iw_handler) NULL, /* -- hole -- */
4535 (iw_handler) NULL, /* SIOCSIWRATE */
4536 (iw_handler) NULL, /* SIOCGIWRATE */
4537 (iw_handler) NULL, /* SIOCSIWRTS */
4538 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4539 (iw_handler) NULL, /* SIOCSIWFRAG */
4540 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4541 (iw_handler) NULL, /* SIOCSIWTXPOW */
4542 (iw_handler) NULL, /* SIOCGIWTXPOW */
4543 (iw_handler) NULL, /* SIOCSIWRETRY */
4544 (iw_handler) NULL, /* SIOCGIWRETRY */
4545 (iw_handler) NULL, /* SIOCSIWENCODE */
4546 (iw_handler) NULL, /* SIOCGIWENCODE */
4547 (iw_handler) NULL, /* SIOCSIWPOWER */
4548 (iw_handler) NULL, /* SIOCGIWPOWER */
4549 (iw_handler) NULL, /* -- hole -- */
4550 (iw_handler) NULL, /* -- hole -- */
4551 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4552 (iw_handler) NULL, /* SIOCGIWGENIE */
4553 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4554 (iw_handler) NULL, /* SIOCGIWAUTH */
4555 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4556 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4557 (iw_handler) NULL, /* SIOCSIWPMKSA */
4558};
4559
Jeff Johnson224f3702014-03-26 11:09:47 -07004560/*
4561 * Note that the following ioctls were defined with semantics which
4562 * cannot be handled by the "iwpriv" userspace application and hence
4563 * they are not included in the hostapd_private_args array
4564 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4565 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004566
4567static const struct iw_priv_args hostapd_private_args[] = {
4568 { QCSAP_IOCTL_SETPARAM,
4569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4570 { QCSAP_IOCTL_SETPARAM,
4571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
4572 { QCSAP_PARAM_MAX_ASSOC,
4573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4574 { QCSAP_PARAM_HIDE_SSID,
4575 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004576 { QCSAP_PARAM_SET_MC_RATE,
4577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 { QCSAP_IOCTL_GETPARAM,
4579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4580 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4581 { QCSAP_IOCTL_GETPARAM, 0,
4582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4583 { QCSAP_PARAM_MAX_ASSOC, 0,
4584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004585 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4586 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4587 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304589 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4590 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 { QCSAP_PARAM_CLR_ACL, 0,
4592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4593 { QCSAP_PARAM_ACL_MODE,
4594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 { QCSAP_IOCTL_GET_STAWPAIE,
4596 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4597 { QCSAP_IOCTL_SETWPAIE,
4598 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4599 { QCSAP_IOCTL_STOPBSS,
4600 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4601 { QCSAP_IOCTL_VERSION, 0,
4602 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004603 { QCSAP_IOCTL_GET_STA_INFO, 0,
4604 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004606 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004609 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304611 { QCSAP_IOCTL_AP_STATS, 0,
4612 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4614 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304615 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004616
4617 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4619 /* handlers for sub-ioctl */
4620 { WE_SET_WLAN_DBG,
4621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4622 0,
4623 "setwlandbg" },
4624
4625 /* handlers for main ioctl */
4626 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4627 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4628 0,
4629 "" },
4630
4631 /* handlers for sub-ioctl */
4632 { WE_LOG_DUMP_CMD,
4633 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4634 0,
4635 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 { WE_P2P_NOA_CMD,
4637 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4638 0,
4639 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004640 /* handlers for sub ioctl */
4641 {
4642 WE_MCC_CONFIG_CREDENTIAL,
4643 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4644 0,
4645 "setMccCrdnl" },
4646
4647 /* handlers for sub ioctl */
4648 {
4649 WE_MCC_CONFIG_PARAMS,
4650 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4651 0,
4652 "setMccConfig" },
4653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 /* handlers for main ioctl */
4655 { QCSAP_IOCTL_MODIFY_ACL,
4656 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4657 0,
4658 "modify_acl" },
4659
4660 /* handlers for main ioctl */
4661 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4662 0,
4663 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4664 "getChannelList" },
4665
Jeff Johnsone7245742012-09-05 17:12:55 -07004666 /* handlers for main ioctl */
4667 { QCSAP_IOCTL_SET_TX_POWER,
4668 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4669 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304670 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004671
4672 /* handlers for main ioctl */
4673 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4674 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4675 0,
4676 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304677
4678 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4679 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4680 0,
4681 "dataSnapshot" },
4682
4683 /* handlers for main ioctl */
4684 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4685 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4686 0,
4687 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004688};
Jeff Johnsone7245742012-09-05 17:12:55 -07004689
Jeff Johnson295189b2012-06-20 16:38:30 -07004690static const iw_handler hostapd_private[] = {
4691 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4692 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4694 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4695 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4696 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4697 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4698 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4699 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4700 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4701 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304702 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4704 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4705 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4706 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004707 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004708 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4709 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004710 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304711 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304712 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Jeff Johnson295189b2012-06-20 16:38:30 -07004713};
4714const struct iw_handler_def hostapd_handler_def = {
4715 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4716 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4717 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4718 .standard = (iw_handler *)hostapd_handler,
4719 .private = (iw_handler *)hostapd_private,
4720 .private_args = hostapd_private_args,
4721 .get_wireless_stats = NULL,
4722};
4723#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4724struct net_device_ops net_ops_struct = {
4725 .ndo_open = hdd_hostapd_open,
4726 .ndo_stop = hdd_hostapd_stop,
4727 .ndo_uninit = hdd_hostapd_uninit,
4728 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4729 .ndo_tx_timeout = hdd_softap_tx_timeout,
4730 .ndo_get_stats = hdd_softap_stats,
4731 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4732 .ndo_do_ioctl = hdd_hostapd_ioctl,
4733 .ndo_change_mtu = hdd_hostapd_change_mtu,
4734 .ndo_select_queue = hdd_hostapd_select_queue,
4735 };
4736#endif
4737
4738int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4739{
4740 return VOS_STATUS_SUCCESS;
4741}
4742
4743void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4744{
4745#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4746 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4747#else
4748 pWlanHostapdDev->open = hdd_hostapd_open;
4749 pWlanHostapdDev->stop = hdd_hostapd_stop;
4750 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4751 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4752 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4753 pWlanHostapdDev->get_stats = hdd_softap_stats;
4754 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4755 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4756#endif
4757}
4758
4759VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304760{
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 hdd_hostapd_state_t * phostapdBuf;
4762 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004763 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004765#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004766 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4767 v_U16_t unsafeChannelCount;
4768#endif /* FEATURE_WLAN_CH_AVOID */
4769
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304770 if (pHddCtx->isLogpInProgress) {
4771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4772 "%s:LOGP in Progress. Ignore!!!",__func__);
4773 status = VOS_STATUS_E_FAILURE;
4774 }
4775
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304777 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304779
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004780 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4781
Leo Chang0b0e45a2013-12-15 15:18:55 -08004782#ifdef FEATURE_WLAN_CH_AVOID
4783 /* Get unsafe cahnnel list from cached location */
4784 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4785 sizeof(unsafeChannelList),
4786 &unsafeChannelCount);
4787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4788 "%s : Unsafe Channel count %d",
4789 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304790 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004791 unsafeChannelList,
4792 unsafeChannelCount);
4793#endif /* FEATURE_WLAN_CH_AVOID */
4794
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 // Zero the memory. This zeros the profile structure.
4796 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
4797
4798 // Set up the pointer to the Wireless Extensions state structure
4799 // NOP
4800 status = hdd_set_hostapd(pAdapter);
4801 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 return status;
4804 }
4805
4806 status = vos_event_init(&phostapdBuf->vosEvent);
4807 if (!VOS_IS_STATUS_SUCCESS(status))
4808 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 return status;
4811 }
4812
4813 init_completion(&pAdapter->session_close_comp_var);
4814 init_completion(&pAdapter->session_open_comp_var);
4815
4816 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4817
4818 // Register as a wireless device
4819 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4820
4821 //Initialize the data path module
4822 status = hdd_softap_init_tx_rx(pAdapter);
4823 if ( !VOS_IS_STATUS_SUCCESS( status ))
4824 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004825 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304827
4828 status = hdd_wmm_adapter_init( pAdapter );
4829 if (!VOS_IS_STATUS_SUCCESS(status))
4830 {
4831 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004832 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304833 status, status );
4834 goto error_wmm_init;
4835 }
4836
4837 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
4838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304840
4841 return status;
4842
4843error_wmm_init:
4844 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 EXIT();
4846 return status;
4847}
4848
4849hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4850{
4851 struct net_device *pWlanHostapdDev = NULL;
4852 hdd_adapter_t *pHostapdAdapter = NULL;
4853 v_CONTEXT_t pVosContext= NULL;
4854
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004856
4857 if (pWlanHostapdDev != NULL)
4858 {
4859 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4860
4861 //Init the net_device structure
4862 ether_setup(pWlanHostapdDev);
4863
4864 //Initialize the adapter context to zeros.
4865 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4866 pHostapdAdapter->dev = pWlanHostapdDev;
4867 pHostapdAdapter->pHddCtx = pHddCtx;
4868 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4869
4870 //Get the Global VOSS context.
4871 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4872 //Save the adapter context in global context for future.
4873 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4874
4875 //Init the net_device structure
4876 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4877
4878 hdd_set_ap_ops( pHostapdAdapter->dev );
4879
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4881 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4882
4883 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4884 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4885
4886 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4888 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4889 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
4890 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
4892 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05304893 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07004894#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4895 init_completion(&pHostapdAdapter->offchannel_tx_event);
4896#endif
4897
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4899 }
4900 return pHostapdAdapter;
4901}
4902
4903VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4904{
4905 struct net_device *dev = pAdapter->dev;
4906 VOS_STATUS status = VOS_STATUS_SUCCESS;
4907
4908 ENTER();
4909
4910 if( rtnl_lock_held )
4911 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004912 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 if( dev_alloc_name(dev, dev->name) < 0 )
4914 {
4915 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4916 return VOS_STATUS_E_FAILURE;
4917 }
4918 }
4919 if (register_netdevice(dev))
4920 {
4921 hddLog(VOS_TRACE_LEVEL_FATAL,
4922 "%s:Failed:register_netdevice", __func__);
4923 return VOS_STATUS_E_FAILURE;
4924 }
4925 }
4926 else
4927 {
4928 if (register_netdev(dev))
4929 {
4930 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
4931 return VOS_STATUS_E_FAILURE;
4932 }
4933 }
4934 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
4935
4936 EXIT();
4937 return status;
4938}
4939
c_hpothu002231a2015-02-05 14:58:51 +05304940VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07004941{
4942 ENTER();
4943
4944 hdd_softap_deinit_tx_rx(pAdapter);
4945
4946 /* if we are being called during driver unload, then the dev has already
4947 been invalidated. if we are being called at other times, then we can
4948 detatch the wireless device handlers */
4949 if (pAdapter->dev)
4950 {
c_hpothu002231a2015-02-05 14:58:51 +05304951 if (TRUE == rtnl_held)
4952 {
4953 pAdapter->dev->wireless_handlers = NULL;
4954 }
4955 else
4956 {
4957 rtnl_lock();
4958 pAdapter->dev->wireless_handlers = NULL;
4959 rtnl_unlock();
4960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 }
4962 EXIT();
4963 return 0;
4964}