blob: 70a76d4a1e7b444e2404db10af6ebee61713c1ea [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.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530926
927 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
928 (TRUE == sme_IsFeatureSupportedByFW(TDLS)))
929 {
930 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
931 {
932 /* Enable TDLS support Once P2P session ends since
933 * upond detection of concurrency TDLS would be disabled
934 */
935 hddLog(LOG1, FL("Enable TDLS support"));
936 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_ENABLED, FALSE);
937 }
938 }
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 goto stopbss;
941 case eSAP_STA_SET_KEY_EVENT:
942 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800943 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
945 return VOS_STATUS_SUCCESS;
946 case eSAP_STA_DEL_KEY_EVENT:
947 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800948 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 return VOS_STATUS_SUCCESS;
950 case eSAP_STA_MIC_FAILURE_EVENT:
951 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 memset(&msg, '\0', sizeof(msg));
953 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800954 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800955 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700956 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 msg.flags = IW_MICFAILURE_GROUP;
958 else
959 msg.flags = IW_MICFAILURE_PAIRWISE;
960 memset(&wrqu, 0, sizeof(wrqu));
961 wrqu.data.length = sizeof(msg);
962 we_event = IWEVMICHAELMICFAILURE;
963 we_custom_event_generic = (v_BYTE_t *)&msg;
964 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 /* inform mic failure to nl80211 */
966 cfg80211_michael_mic_failure(dev,
967 pSapEvent->sapevt.
968 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700969 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 NL80211_KEYTYPE_GROUP :
971 NL80211_KEYTYPE_PAIRWISE),
972 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
973 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
974 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 break;
976
977 case eSAP_STA_ASSOC_EVENT:
978 case eSAP_STA_REASSOC_EVENT:
979 wrqu.addr.sa_family = ARPHRD_ETHER;
980 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800981 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800982 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 we_event = IWEVREGISTERED;
984
985 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
986
987 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
988 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
989 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
990 {
991 bAuthRequired = FALSE;
992 }
993
994 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
995 {
c_hpothuffdb5272013-10-02 16:42:35 +0530996 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 TRUE,
998 pHddApCtx->uPrivacy,
999 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1000 0,
1001 0,
1002 (v_MACADDR_t *)wrqu.addr.sa_data,
1003 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301004
1005 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));
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 }
1009 else
1010 {
c_hpothuffdb5272013-10-02 16:42:35 +05301011 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 FALSE,
1013 pHddApCtx->uPrivacy,
1014 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1015 0,
1016 0,
1017 (v_MACADDR_t *)wrqu.addr.sa_data,
1018 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301019 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1020 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1021 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001022 }
1023
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 // Stop AP inactivity timer
1025 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1026 {
1027 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1028 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001029 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001031#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001032 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1033 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301034 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1035 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001036 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301037 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1038 HDD_SAP_WAKE_LOCK_DURATION,
1039 WIFI_POWER_EVENT_WAKELOCK_SAP);
1040
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001041#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001042#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1043 {
1044 struct station_info staInfo;
1045 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1046
1047 memset(&staInfo, 0, sizeof(staInfo));
1048 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1049 {
1050 staInfo.assoc_req_ies =
1051 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1052 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001053#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001054 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 cfg80211_new_sta(dev,
1057 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1058 &staInfo, GFP_KERNEL);
1059 }
1060 else
1061 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001062 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 }
1064 }
1065#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001066 pScanInfo = &pHddCtx->scan_info;
1067 // Lets do abort scan to ensure smooth authentication for client
1068 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1069 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301070 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301071 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001073
1074 break;
1075 case eSAP_STA_DISASSOC_EVENT:
1076 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001077 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001078 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1080 hddLog(LOG1," User initiated disassociation");
1081 else
1082 hddLog(LOG1," MAC initiated disassociation");
1083 we_event = IWEVEXPIRED;
1084 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1085 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1086 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001087 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 -07001088 return VOS_STATUS_E_FAILURE;
1089 }
1090 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1091
1092 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1093 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301094 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 // Start AP inactivity timer if no stations associated with it
1096 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1097 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301098 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 {
1100 bApActive = TRUE;
1101 break;
1102 }
1103 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301104 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001105
1106 if (bApActive == FALSE)
1107 {
1108 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1109 {
1110 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1111 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001112 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 }
1114 else
1115 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1116 }
1117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001118#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1119 cfg80211_del_sta(dev,
1120 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1121 GFP_KERNEL);
1122#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001123 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301124 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1125 if (VOS_STATUS_SUCCESS != vos_status)
1126 {
1127 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1128 __func__, vos_status);
1129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 break;
1131 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1132 {
1133 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1134 union iwreq_data wreq;
1135
1136 down(&pHddApCtx->semWpsPBCOverlapInd);
1137 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1138
1139 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1140 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1141
1142 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001143 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 memset(&wreq, 0, sizeof(wreq));
1145 wreq.data.length = strlen(message); // This is length of message
1146 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1147
1148 return VOS_STATUS_SUCCESS;
1149 }
1150 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1151 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1152 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1153 { // List of associated stations
1154 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1155 {
1156 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1157 i+1,
1158 pAssocStasArray->assocId,
1159 pAssocStasArray->staId,
1160 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1161 pAssocStasArray++;
1162 }
1163 }
1164 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001165 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 case eSAP_INDICATE_MGMT_FRAME:
1168 hdd_indicateMgmtFrame( pHostapdAdapter,
1169 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1170 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1171 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301172 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 return VOS_STATUS_SUCCESS;
1174 case eSAP_REMAIN_CHAN_READY:
1175 hdd_remainChanReadyHandler( pHostapdAdapter );
1176 return VOS_STATUS_SUCCESS;
1177 case eSAP_SEND_ACTION_CNF:
1178 hdd_sendActionCnf( pHostapdAdapter,
1179 ( eSAP_STATUS_SUCCESS ==
1180 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1181 TRUE : FALSE );
1182 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 case eSAP_UNKNOWN_STA_JOIN:
1184 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1185 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1186 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1187 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1188 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1189 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1190 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1191 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1192 wrqu.data.pointer = unknownSTAEvent;
1193 wrqu.data.length = strlen(unknownSTAEvent);
1194 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301195 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 break;
1197
1198 case eSAP_MAX_ASSOC_EXCEEDED:
1199 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1200 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1201 " one or more devices to enable the new device connection",
1202 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1203 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1204 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1205 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1206 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1207 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1208 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1209 wrqu.data.pointer = maxAssocExceededEvent;
1210 wrqu.data.length = strlen(maxAssocExceededEvent);
1211 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001212 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 break;
1214 case eSAP_STA_ASSOC_IND:
1215 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001216
1217 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001218 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001219 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1220 return VOS_STATUS_SUCCESS;
1221
1222 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301223 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301224 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1225 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301226 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301227 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001228 return VOS_STATUS_SUCCESS;
1229
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001231 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 goto stopbss;
1233 return VOS_STATUS_SUCCESS;
1234 }
1235 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1236 return VOS_STATUS_SUCCESS;
1237
1238stopbss :
1239 {
1240 v_BYTE_t we_custom_event[64];
1241 char *stopBssEvent = "STOP-BSS.response";//17
1242 int event_len = strlen(stopBssEvent);
1243
1244 hddLog(LOG1, FL("BSS stop status = %s"),
1245 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1246 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1247
1248 /* Change the BSS state now since, as we are shutting things down,
1249 * we don't want interfaces to become re-enabled */
1250 pHostapdState->bssState = BSS_STOP;
1251
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301252 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1253 {
1254 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1255 {
1256 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1257 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1258 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1259 }
1260
1261 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1262 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1263 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1264 }
1265
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 /* Stop the pkts from n/w stack as we are going to free all of
1267 * the TX WMM queues for all STAID's */
1268 hdd_hostapd_stop(dev);
1269
1270 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301271 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1272 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1273 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
Amar Singhal37e6f052013-03-05 16:16:54 -08001275 /* once the event is set, structure dev/pHostapdAdapter should
1276 * not be touched since they are now subject to being deleted
1277 * by another thread */
1278 if (eSAP_STOP_BSS_EVENT == sapEvent)
1279 vos_event_set(&pHostapdState->vosEvent);
1280
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 /* notify userspace that the BSS has stopped */
1282 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1283 memcpy(&we_custom_event, stopBssEvent, event_len);
1284 memset(&wrqu, 0, sizeof(wrqu));
1285 wrqu.data.length = event_len;
1286 we_event = IWEVCUSTOM;
1287 we_custom_event_generic = we_custom_event;
1288 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001289 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 }
1291 return VOS_STATUS_SUCCESS;
1292}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001293
1294int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001296 eCsrEncryptionType *pEncryptType,
1297 eCsrEncryptionType *mcEncryptType,
1298 eCsrAuthType *pAuthType,
1299 v_BOOL_t *pMFPCapable,
1300 v_BOOL_t *pMFPRequired,
1301 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 u_int8_t *gen_ie )
1303{
1304 tDot11fIERSN dot11RSNIE;
1305 tDot11fIEWPA dot11WPAIE;
1306
1307 tANI_U8 *pRsnIe;
1308 tANI_U16 RSNIeLen;
1309
1310 if (NULL == halHandle)
1311 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001312 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 return -EINVAL;
1314 }
1315
1316 // Validity checks
1317 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1318 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1319 return -EINVAL;
1320 // Type check
1321 if ( gen_ie[0] == DOT11F_EID_RSN)
1322 {
1323 // Validity checks
1324 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1325 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1326 {
1327 return VOS_STATUS_E_FAILURE;
1328 }
1329 // Skip past the EID byte and length byte
1330 pRsnIe = gen_ie + 2;
1331 RSNIeLen = gen_ie_len - 2;
1332 // Unpack the RSN IE
1333 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1334 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1335 pRsnIe,
1336 RSNIeLen,
1337 &dot11RSNIE);
1338 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001339 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001340 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001341 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001342 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 /*Here we have followed the apple base code,
1344 but probably I suspect we can do something different*/
1345 //dot11RSNIE.akm_suite_count
1346 // Just translate the FIRST one
1347 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1348 //dot11RSNIE.pwise_cipher_suite_count
1349 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1350 //dot11RSNIE.gp_cipher_suite_count
1351 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1352 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001353 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1354 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001355
1356 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1357 } else
1358 if (gen_ie[0] == DOT11F_EID_WPA)
1359 {
1360 // Validity checks
1361 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1362 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1363 {
1364 return VOS_STATUS_E_FAILURE;
1365 }
1366 // Skip past the EID byte and length byte - and four byte WiFi OUI
1367 pRsnIe = gen_ie + 2 + 4;
1368 RSNIeLen = gen_ie_len - (2 + 4);
1369 // Unpack the WPA IE
1370 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1371 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1372 pRsnIe,
1373 RSNIeLen,
1374 &dot11WPAIE);
1375 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001376 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001377 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001378 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001379 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 //dot11WPAIE.auth_suite_count
1381 // Just translate the FIRST one
1382 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1383 //dot11WPAIE.unicast_cipher_count
1384 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1385 //dot11WPAIE.unicast_cipher_count
1386 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001387 *pMFPCapable = VOS_FALSE;
1388 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 }
1390 else
1391 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001392 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 return VOS_STATUS_E_FAILURE;
1394 }
1395 return VOS_STATUS_SUCCESS;
1396}
Leo Chang614d2072013-08-22 14:59:44 -07001397
Leo Chang0b0e45a2013-12-15 15:18:55 -08001398#ifdef FEATURE_WLAN_CH_AVOID
1399/**---------------------------------------------------------------------------
1400
1401 \brief hdd_hostapd_freq_to_chn() -
1402
1403 Input frequency translated into channel number
1404
1405 \param - freq input frequency with order of kHz
1406
1407 \return - corresponding channel number.
1408 incannot find correct channel number, return 0
1409
1410 --------------------------------------------------------------------------*/
1411v_U16_t hdd_hostapd_freq_to_chn
1412(
1413 v_U16_t freq
1414)
1415{
1416 int loop;
1417
1418 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1419 {
1420 if (rfChannels[loop].targetFreq == freq)
1421 {
1422 return rfChannels[loop].channelNum;
1423 }
1424 }
1425
1426 return (0);
1427}
1428
1429/*==========================================================================
1430 FUNCTION sapUpdateUnsafeChannelList
1431
1432 DESCRIPTION
1433 Function Undate unsafe channel list table
1434
1435 DEPENDENCIES
1436 NA.
1437
1438 PARAMETERS
1439
1440 IN
1441 pSapCtx : SAP context pointer, include unsafe channel list
1442
1443 RETURN VALUE
1444 NONE
1445============================================================================*/
1446void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1447 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1448{
1449 v_U16_t i, j;
1450
1451 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1452 sizeof(pHddCtx->unsafeChannelList));
1453 if (0 == unsafeChannelCount)
1454 {
1455 pHddCtx->unsafeChannelCount = 0;
1456 }
1457 else
1458 {
c_hpothu8de53e42014-08-22 15:00:37 +05301459 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1460 {
1461 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1462 FL("unsafeChannelCount%hd greater than %d"),
1463 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1464 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1465 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001466 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1467 unsafeChannelList,
1468 unsafeChannelCount * sizeof(tANI_U16));
1469 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1470 }
1471
1472 /* Flush, default set all channel safe */
1473 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1474 {
1475 safeChannels[i].isSafe = VOS_TRUE;
1476 }
1477
1478 /* Try to find unsafe channel */
1479 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1480 {
1481 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1482 {
1483 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1484 {
1485 /* Found unsafe channel, update it */
1486 safeChannels[j].isSafe = VOS_FALSE;
1487 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1488 "%s : CH %d is not safe",
1489 __func__, pHddCtx->unsafeChannelList[i]);
1490 break;
1491 }
1492 }
1493 }
1494
1495 return;
1496}
1497
1498/**---------------------------------------------------------------------------
1499
1500 \brief hdd_hostapd_ch_avoid_cb() -
1501
1502 Avoid channel notification from FW handler.
1503 FW will send un-safe channle list to avoid overwrapping.
1504 hostapd should not use notified channel
1505
1506 \param - pAdapter HDD adapter pointer
1507 indParam channel avoid notification parameter
1508
1509 \return - None
1510
1511 --------------------------------------------------------------------------*/
1512void hdd_hostapd_ch_avoid_cb
1513(
1514 void *pAdapter,
1515 void *indParam
1516)
1517{
1518 hdd_adapter_t *pHostapdAdapter = NULL;
1519 hdd_context_t *hddCtxt;
1520 tSirChAvoidIndType *chAvoidInd;
1521 v_U8_t rangeLoop;
1522 v_U16_t channelLoop;
1523 v_U16_t dupCheck;
1524 v_U16_t startChannel;
1525 v_U16_t endChannel;
1526 v_U16_t unsafeChannelCount = 0;
1527 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1528 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001529 tHddAvoidFreqList hddAvoidFreqList;
1530 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301531#ifdef WLAN_FEATURE_AP_HT40_24G
1532 ptSapContext pSapCtx = NULL;
1533 tHalHandle hHal;
1534 v_U8_t cbMode;
1535 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1536 v_U32_t delay;
1537#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001538
1539 /* Basic sanity */
1540 if ((NULL == pAdapter) || (NULL == indParam))
1541 {
1542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1543 "%s : Invalid arguments", __func__);
1544 return;
1545 }
1546
1547 hddCtxt = (hdd_context_t *)pAdapter;
1548 chAvoidInd = (tSirChAvoidIndType *)indParam;
1549 pVosContext = hddCtxt->pvosContext;
1550
1551 /* Make unsafe channel list */
1552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1553 "%s : band count %d",
1554 __func__, chAvoidInd->avoidRangeCount);
1555 vos_mem_zero((void *)unsafeChannelList,
1556 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1557 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1558 {
1559 startChannel = hdd_hostapd_freq_to_chn(
1560 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1561 endChannel = hdd_hostapd_freq_to_chn(
1562 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1564 "%s : start %d : %d, end %d : %d",
1565 __func__,
1566 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1567 startChannel,
1568 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1569 endChannel);
1570 for (channelLoop = startChannel;
1571 channelLoop < (endChannel + 1);
1572 channelLoop++)
1573 {
1574 /* Channel duplicate check routine */
1575 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1576 {
1577 if (unsafeChannelList[dupCheck] == channelLoop)
1578 {
1579 /* This channel is duplicated */
1580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1581 "%s : found duplicated channel %d",
1582 __func__, channelLoop);
1583 break;
1584 }
1585 }
1586 if (dupCheck == unsafeChannelCount)
1587 {
c_hpothu8de53e42014-08-22 15:00:37 +05301588 int ii;
1589 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1590 {
1591 if (channelLoop == safeChannels[ii].channelNumber)
1592 {
1593 unsafeChannelList[unsafeChannelCount] = channelLoop;
1594 unsafeChannelCount++;
1595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1596 "%s : unsafe channel %d, count %d",
1597 __func__,
1598 channelLoop, unsafeChannelCount);
1599 }
1600 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001601 }
1602 else
1603 {
1604 /* DUP, do nothing */
1605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1606 "%s : duplicated channel %d",
1607 __func__, channelLoop);
1608 }
1609 }
1610 }
1611 /* Update unsafe channel cache
1612 * WCN Platform Driver cache */
1613 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1614 unsafeChannelCount);
1615
1616 /* Store into local cache
1617 * Start with STA and later start SAP
1618 * in this scenario, local cache will be used */
1619 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1620 unsafeChannelList,
1621 unsafeChannelCount);
1622
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001623 /* generate vendor specific event */
1624 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1625 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1626 {
1627 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1628 chAvoidInd->avoidFreqRange[i].startFreq;
1629 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1630 chAvoidInd->avoidFreqRange[i].endFreq;
1631 }
1632 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1633
1634 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1635
Leo Chang0b0e45a2013-12-15 15:18:55 -08001636 /* Get SAP context first
1637 * SAP and P2PGO would not concurrent */
1638 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301639#ifdef WLAN_FEATURE_AP_HT40_24G
1640 if (NULL == pHostapdAdapter)
1641 {
1642 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1643 }
1644#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301645 if ((pHostapdAdapter) &&
1646 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1647 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001648 {
1649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1650 "%s : Current operation channel %d",
1651 __func__,
1652 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1653 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1654 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301655 if ((unsafeChannelList[channelLoop] ==
1656 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1657 {
1658 if ((AUTO_CHANNEL_SELECT ==
1659 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1660 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1661 {
1662 /* current operating channel is un-safe channel
1663 * restart driver */
1664 hdd_hostapd_stop(pHostapdAdapter->dev);
1665 /* On LE, this event is handled by wlan-services to
1666 * restart SAP. On android, this event would be
1667 * ignored.
1668 */
1669 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1670 NULL, 0);
1671 }
1672 return;
1673 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001674 }
1675 }
1676
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301677#ifdef WLAN_FEATURE_AP_HT40_24G
1678 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1679 {
1680 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1681
1682 if(pSapCtx == NULL)
1683 {
1684 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1685 FL("psapCtx is NULL"));
1686 return;
1687 }
1688
1689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1690 FL("SAP Secondary channel: %d "),
1691 pSapCtx->sap_sec_chan);
1692
1693 /* tHalHandle */
1694 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1695
1696 if (NULL == hHal)
1697 {
1698 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1699 FL("In invalid hHal"));
1700 return;
1701 }
1702
1703 cbMode = sme_GetChannelBondingMode24G(hHal);
1704
1705 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1706 FL("Selected Channel bonding : %d"), cbMode);
1707
1708 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1709 {
1710 int i;
1711 eHalStatus halStatus;
1712
1713 for (i = 0; i < unsafeChannelCount; i++)
1714 {
1715 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1716 {
1717 /* Current SAP Secondary channel is un-safe channel */
1718 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1719 FL("Move SAP from HT40 to HT20"));
1720
1721 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1722 PHY_SINGLE_CHANNEL_CENTERED);
1723
1724 if (halStatus == eHAL_STATUS_FAILURE)
1725 {
1726 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1727 FL("Failed to change HT20/40 mode"));
1728 return;
1729 }
1730
1731 /* Disable Channel Bonding for 2.4GHz */
1732 sme_UpdateChannelBondingMode24G(hHal,
1733 PHY_SINGLE_CHANNEL_CENTERED);
1734 return;
1735 }
1736 }
1737 }
1738
1739 if ((!pSapCtx->numHT40IntoSta)
1740 && (pHostapdAdapter)
1741 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1742 {
1743 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1744 * are Safe then start HT20/40 timer to Move SAP from HT20
1745 * to HT40.
1746 */
1747 if (((!unsafeChannelCount)
1748 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1749 {
1750 /* Stop Previous Running HT20/40 Timer & Start timer
1751 with (OBSS TransitionDelayFactor * obss interval)
1752 delay after time out move AP from HT20 -> HT40
1753 mode
1754 */
1755 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1756 {
1757 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1758 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1759 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1760 FL("Failed to Stop HT20/40 timer"));
1761 }
1762
1763 delay =
1764 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1765
1766 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1767 FL("Start HT20/40 transition timer (%d sec)"), delay);
1768
1769 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1770 (delay * 1000));
1771
1772 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1773 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1774 FL("Failed to Start HT20/40 timer"));
1775 }
1776 else
1777 {
1778 /* Stop HT20/40 Timer */
1779 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1780 {
1781 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1782 FL("Stop HT20/40 transition timer"));
1783 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1784 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1785 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1786 FL("Failed to Stop HT20/40 timer"));
1787 }
1788 }
1789 }
1790 }
1791#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001792 return;
1793}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001794#endif /* FEATURE_WLAN_CH_AVOID */
1795
Jeff Johnson295189b2012-06-20 16:38:30 -07001796int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301797static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 struct iw_request_info *info,
1799 union iwreq_data *wrqu, char *extra)
1800{
1801 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001802 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301803 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 int *value = (int *)extra;
1805 int sub_cmd = value[0];
1806 int set_value = value[1];
1807 eHalStatus status;
1808 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001809 v_CONTEXT_t pVosContext;
1810
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301811 ENTER();
1812
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301813 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001814 {
1815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301816 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001817 __func__);
1818 return -1;
1819 }
1820
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301821 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1822 ret = wlan_hdd_validate_context(pHddCtx);
1823 if (0 != ret)
1824 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301825 return -1;
1826 }
1827
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001828 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1829 if (!hHal)
1830 {
1831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1832 "%s: Hal ctx is null", __func__);
1833 return -1;
1834 }
1835
1836 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1837 if (!pVosContext)
1838 {
1839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1840 "%s: Vos ctx is null", __func__);
1841 return -1;
1842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001843
1844 switch(sub_cmd)
1845 {
1846
1847 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001848 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301850 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 }
1852 break;
1853
1854 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301855 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1857 {
1858 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1859 ret = -EINVAL;
1860 }
1861 else
1862 {
1863 WLANSAP_SetMode(pVosContext, set_value);
1864 }
1865 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301866
1867 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1868 if ((0 != set_value) && (1 != set_value))
1869 {
1870 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1871 ret = -EINVAL;
1872 }
1873 else
1874 {
1875 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1876 }
1877 break;
1878
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 case QCSAP_PARAM_MAX_ASSOC:
1880 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1881 {
1882 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1883 ret = -EINVAL;
1884 }
1885 else
1886 {
1887 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1888 {
1889 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1890 "Setting it to max allowed and continuing"),
1891 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1892 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1893 }
1894 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1895 set_value, NULL, eANI_BOOLEAN_FALSE);
1896 if ( status != eHAL_STATUS_SUCCESS )
1897 {
1898 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1899 status);
1900 ret = -EIO;
1901 }
1902 }
1903 break;
1904
1905 case QCSAP_PARAM_HIDE_SSID:
1906 {
1907 eHalStatus status = eHAL_STATUS_SUCCESS;
1908 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1909 if(eHAL_STATUS_SUCCESS != status)
1910 {
1911 hddLog(VOS_TRACE_LEVEL_ERROR,
1912 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001913 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 return status;
1915 }
1916 break;
1917 }
1918
Leo Chang614d2072013-08-22 14:59:44 -07001919 case QCSAP_PARAM_SET_MC_RATE:
1920 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001921 tSirRateUpdateInd *rateUpdate;
1922
1923 rateUpdate = (tSirRateUpdateInd *)
1924 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1925 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001926 {
1927 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001928 "%s: SET_MC_RATE indication alloc fail", __func__);
1929 ret = -1;
1930 break;
1931 }
1932 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1933
1934 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1935 /* Ignore unicast */
1936 rateUpdate->ucastDataRate = -1;
1937 rateUpdate->mcastDataRate24GHz = set_value;
1938 rateUpdate->mcastDataRate5GHz = set_value;
1939 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1940 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1941 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1942 if (eHAL_STATUS_SUCCESS != status)
1943 {
1944 hddLog(VOS_TRACE_LEVEL_ERROR,
1945 "%s: SET_MC_RATE failed", __func__);
1946 vos_mem_free(rateUpdate);
1947 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001948 }
1949 break;
1950 }
1951
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 default:
1953 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1954 sub_cmd, set_value);
1955 ret = -EINVAL;
1956 break;
1957 }
1958
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301959 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 return ret;
1961}
1962
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301963int
1964static iw_softap_setparam(struct net_device *dev,
1965 struct iw_request_info *info,
1966 union iwreq_data *wrqu, char *extra)
1967{
1968 int ret;
1969
1970 vos_ssr_protect(__func__);
1971 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1972 vos_ssr_unprotect(__func__);
1973
1974 return ret;
1975}
Jeff Johnson295189b2012-06-20 16:38:30 -07001976
1977int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301978static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 struct iw_request_info *info,
1980 union iwreq_data *wrqu, char *extra)
1981{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301982 hdd_adapter_t *pHostapdAdapter;
1983 tHalHandle hHal;
1984 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 int *value = (int *)extra;
1986 int sub_cmd = value[0];
1987 eHalStatus status;
1988 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301989 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001990
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301991 ENTER();
1992
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301993 pHostapdAdapter = (netdev_priv(dev));
1994 if (NULL == pHostapdAdapter)
1995 {
1996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1997 "%s: Adapter is NULL",__func__);
1998 return -EINVAL;
1999 }
2000 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2001 ret = wlan_hdd_validate_context(pHddCtx);
2002 if (0 != ret)
2003 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302004 return ret;
2005 }
2006 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2007 if (NULL == hHal)
2008 {
2009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2010 "%s: Hal Context is NULL",__func__);
2011 return -EINVAL;
2012 }
2013 pVosContext = pHddCtx->pvosContext;
2014 if (NULL == pVosContext)
2015 {
2016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2017 "%s: pVosContext Context is NULL",__func__);
2018 return -EINVAL;
2019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 switch (sub_cmd)
2021 {
2022 case QCSAP_PARAM_MAX_ASSOC:
2023 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2024 if (eHAL_STATUS_SUCCESS != status)
2025 {
c_hpothuffdb5272013-10-02 16:42:35 +05302026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2027 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 ret = -EIO;
2029 }
Girish Gowli385be612014-09-18 11:17:20 +05302030
2031#ifdef WLAN_SOFTAP_VSTA_FEATURE
2032 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2033 {
2034 if (*value > VSTA_NUM_ASSOC_STA)
2035 {
2036 *value = VSTA_NUM_ASSOC_STA;
2037 }
2038 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2039 (*value > (VSTA_NUM_ASSOC_STA -
2040 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2041 {
2042 *value = (VSTA_NUM_ASSOC_STA -
2043 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2044 }
2045 }
2046 else
2047#endif
2048 {
2049 if (*value > NUM_ASSOC_STA)
2050 {
2051 *value = NUM_ASSOC_STA;
2052 }
2053 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2054 (*value > (NUM_ASSOC_STA -
2055 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2056 {
2057 *value = (NUM_ASSOC_STA -
2058 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2059 }
2060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302062
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002064 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 {
c_hpothuffdb5272013-10-02 16:42:35 +05302066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2067 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 ret = -EIO;
2069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 *value = 0;
2071 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302072
Jeff Johnson43971f52012-07-17 12:26:56 -07002073 case QCSAP_PARAM_GET_WLAN_DBG:
2074 {
2075 vos_trace_display();
2076 *value = 0;
2077 break;
2078 }
2079
2080 case QCSAP_PARAM_AUTO_CHANNEL:
2081 {
2082 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2083 break;
2084 }
2085
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 default:
2087 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2088 ret = -EINVAL;
2089 break;
2090
2091 }
2092
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302093 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 return ret;
2095}
2096
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302097int
2098static iw_softap_getparam(struct net_device *dev,
2099 struct iw_request_info *info,
2100 union iwreq_data *wrqu, char *extra)
2101{
2102 int ret;
2103
2104 vos_ssr_protect(__func__);
2105 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2106 vos_ssr_unprotect(__func__);
2107
2108 return ret;
2109}
Jeff Johnson295189b2012-06-20 16:38:30 -07002110/* Usage:
2111 BLACK_LIST = 0
2112 WHITE_LIST = 1
2113 ADD MAC = 0
2114 REMOVE MAC = 1
2115
2116 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2117 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2118 while using this ioctl
2119
2120 Syntax:
2121 iwpriv softap.0 modify_acl
2122 <6 octet mac addr> <list type> <cmd type>
2123
2124 Examples:
2125 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2126 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2127 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2128 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2129*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302130int __iw_softap_modify_acl(struct net_device *dev,
2131 struct iw_request_info *info,
2132 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002133{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302134 hdd_adapter_t *pHostapdAdapter;
2135 v_CONTEXT_t pVosContext;
2136 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 v_BYTE_t *value = (v_BYTE_t*)extra;
2138 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2139 int listType, cmd, i;
2140 int ret = 0; /* success */
2141
2142 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302143 pHostapdAdapter = (netdev_priv(dev));
2144 if (NULL == pHostapdAdapter)
2145 {
2146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2147 "%s: Adapter is NULL",__func__);
2148 return -EINVAL;
2149 }
2150 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2151 ret = wlan_hdd_validate_context(pHddCtx);
2152 if (0 != ret)
2153 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302154 return ret;
2155 }
2156 pVosContext = pHddCtx->pvosContext;
2157 if (NULL == pVosContext)
2158 {
2159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2160 "%s: Vos Context is NULL",__func__);
2161 return -EINVAL;
2162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2164 {
2165 pPeerStaMac[i] = *(value+i);
2166 }
2167 listType = (int)(*(value+i));
2168 i++;
2169 cmd = (int)(*(value+i));
2170
Arif Hussain24bafea2013-11-15 15:10:03 -08002171 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2172 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002173
2174 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2175 != VOS_STATUS_SUCCESS)
2176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002177 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 ret = -EIO;
2179 }
2180 EXIT();
2181 return ret;
2182}
2183
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302184int iw_softap_modify_acl(struct net_device *dev,
2185 struct iw_request_info *info,
2186 union iwreq_data *wrqu, char *extra)
2187{
2188 int ret;
2189
2190 vos_ssr_protect(__func__);
2191 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2192 vos_ssr_unprotect(__func__);
2193
2194 return ret;
2195}
2196
Jeff Johnson295189b2012-06-20 16:38:30 -07002197int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302198static __iw_softap_getchannel(struct net_device *dev,
2199 struct iw_request_info *info,
2200 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002201{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302202 hdd_adapter_t *pHostapdAdapter;
2203 hdd_context_t *pHddCtx;
2204 int ret = 0;
2205 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302206
2207 ENTER();
2208
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302209 pHostapdAdapter = (netdev_priv(dev));
2210 if (NULL == pHostapdAdapter)
2211 {
2212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2213 "%s: Adapter is NULL",__func__);
2214 return -EINVAL;
2215 }
2216 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2217 ret = wlan_hdd_validate_context(pHddCtx);
2218 if (0 != ret)
2219 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302220 return ret;
2221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002222
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302223 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002224
Jeff Johnson43971f52012-07-17 12:26:56 -07002225 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302226
2227 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 return 0;
2229}
2230
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302231
Jeff Johnsone7245742012-09-05 17:12:55 -07002232int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302233static iw_softap_getchannel(struct net_device *dev,
2234 struct iw_request_info *info,
2235 union iwreq_data *wrqu, char *extra)
2236{
2237 int ret;
2238
2239 vos_ssr_protect(__func__);
2240 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2241 vos_ssr_unprotect(__func__);
2242
2243 return ret;
2244}
2245
2246int
2247static __iw_softap_set_max_tx_power(struct net_device *dev,
2248 struct iw_request_info *info,
2249 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002250{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302251 hdd_adapter_t *pHostapdAdapter;
2252 tHalHandle hHal;
2253 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002254 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302255 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002256 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2257 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2258
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302259 ENTER();
2260
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302261 pHostapdAdapter = (netdev_priv(dev));
2262 if (NULL == pHostapdAdapter)
2263 {
2264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2265 "%s: Adapter is NULL",__func__);
2266 return -EINVAL;
2267 }
2268 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2269 ret = wlan_hdd_validate_context(pHddCtx);
2270 if (0 != ret)
2271 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302272 return ret;
2273 }
2274 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2275 if (NULL == hHal)
2276 {
2277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2278 "%s: Hal Context is NULL",__func__);
2279 return -EINVAL;
2280 }
schang86c22c42013-03-13 18:41:24 -07002281 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002282 return -ENOMEM;
2283
Leo Changd37675a2013-08-01 13:19:45 -07002284 /* Assign correct slef MAC address */
2285 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2286 VOS_MAC_ADDR_SIZE);
2287 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2288 VOS_MAC_ADDR_SIZE);
2289
schang86c22c42013-03-13 18:41:24 -07002290 set_value = value[0];
2291 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2292 {
2293 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002294 __func__);
schang86c22c42013-03-13 18:41:24 -07002295 return -EIO;
2296 }
2297
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302298 EXIT();
schang86c22c42013-03-13 18:41:24 -07002299 return 0;
2300}
2301
2302int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302303static iw_softap_set_max_tx_power(struct net_device *dev,
2304 struct iw_request_info *info,
2305 union iwreq_data *wrqu, char *extra)
2306{
2307 int ret;
2308
2309 vos_ssr_protect(__func__);
2310 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2311 vos_ssr_unprotect(__func__);
2312
2313 return ret;
2314}
2315
2316
2317int
2318static __iw_display_data_path_snapshot(struct net_device *dev,
2319 struct iw_request_info *info,
2320 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302321{
2322
2323 /* Function intitiating dumping states of
2324 * HDD(WMM Tx Queues)
2325 * TL State (with Per Client infor)
2326 * DXE Snapshot (Called at the end of TL Snapshot)
2327 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302328 hdd_adapter_t *pHostapdAdapter;
2329 hdd_context_t *pHddCtx;
2330 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302331
2332 ENTER();
2333
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302334 pHostapdAdapter = (netdev_priv(dev));
2335 if (NULL == pHostapdAdapter)
2336 {
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2338 "%s: Adapter is NULL",__func__);
2339 return -EINVAL;
2340 }
2341 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2342 ret = wlan_hdd_validate_context(pHddCtx);
2343 if (0 != ret)
2344 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302345 return ret;
2346 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302347 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302348 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302349
2350 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302351 return 0;
2352}
2353
2354int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302355static iw_display_data_path_snapshot(struct net_device *dev,
2356 struct iw_request_info *info,
2357 union iwreq_data *wrqu, char *extra)
2358{
2359 int ret;
2360
2361 vos_ssr_protect(__func__);
2362 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2363 vos_ssr_unprotect(__func__);
2364
2365 return ret;
2366}
2367
2368int
2369static __iw_softap_set_tx_power(struct net_device *dev,
2370 struct iw_request_info *info,
2371 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002372{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302373 hdd_adapter_t *pHostapdAdapter;
2374 hdd_context_t *pHddCtx;
2375 v_CONTEXT_t pVosContext;
2376 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002377 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302378 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002379 ptSapContext pSapCtx = NULL;
2380
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302381 ENTER();
2382
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302383 pHostapdAdapter = (netdev_priv(dev));
2384 if (NULL == pHostapdAdapter)
2385 {
2386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2387 "%s: Adapter is NULL",__func__);
2388 return -EINVAL;
2389 }
2390 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2391 ret = wlan_hdd_validate_context(pHddCtx);
2392 if (0 != ret)
2393 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302394 return ret;
2395 }
2396 pVosContext = pHddCtx->pvosContext;
2397 if (NULL == pVosContext)
2398 {
2399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2400 "%s: Vos Context is NULL",__func__);
2401 return -EINVAL;
2402 }
2403 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2404 if (NULL == hHal)
2405 {
2406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2407 "%s: Hal Context is NULL",__func__);
2408 return -EINVAL;
2409 }
schang86c22c42013-03-13 18:41:24 -07002410 if (NULL == value)
2411 return -ENOMEM;
2412
2413 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2414 if (NULL == pSapCtx)
2415 {
2416 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2417 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2418 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002419 }
2420
2421 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002422 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002423 {
schang86c22c42013-03-13 18:41:24 -07002424 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002425 __func__);
2426 return -EIO;
2427 }
2428
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302429 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002430 return 0;
2431}
2432
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302433int
2434static iw_softap_set_tx_power(struct net_device *dev,
2435 struct iw_request_info *info,
2436 union iwreq_data *wrqu, char *extra)
2437{
2438 int ret;
2439
2440 vos_ssr_protect(__func__);
2441 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2442 vos_ssr_unprotect(__func__);
2443
2444 return ret;
2445}
2446
Kiet Lambcf38522013-10-26 18:28:27 +05302447/**---------------------------------------------------------------------------
2448
2449 \brief iw_softap_set_trafficmonitor() -
2450 This function dynamically enable/disable traffic monitor functonality
2451 the command iwpriv wlanX setTrafficMon <value>.
2452
2453 \param - dev - Pointer to the net device.
2454 - addr - Pointer to the sockaddr.
2455 \return - 0 for success, non zero for failure
2456
2457 --------------------------------------------------------------------------*/
2458
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302459static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2460 struct iw_request_info *info,
2461 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302462{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302463 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302464 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302465 hdd_context_t *pHddCtx;
2466 int status;
2467
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302468 ENTER();
2469
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302470 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302471 if (NULL == pAdapter)
2472 {
2473 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2474 "%s: HDD adapter is Null", __func__);
2475 return -ENODEV;
2476 }
2477
2478 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2479
2480 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302481 if (0 != status)
2482 {
Kiet Lambcf38522013-10-26 18:28:27 +05302483 return status;
2484 }
2485
2486 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2487
2488 if (NULL == isSetTrafficMon)
2489 {
2490 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2491 "%s: Invalid SAP pointer from extra", __func__);
2492 return -ENOMEM;
2493 }
2494
2495 if (TRUE == *isSetTrafficMon)
2496 {
2497 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2498 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2499 {
2500 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2501 "%s: failed to Start Traffic Monitor timer ", __func__ );
2502 return -EIO;
2503 }
2504 }
2505 else if (FALSE == *isSetTrafficMon)
2506 {
2507 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2508 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2509 {
2510 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2511 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2512 return -EIO;
2513 }
2514
2515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302516
2517 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302518 return 0;
2519}
2520
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302521static int iw_softap_set_trafficmonitor(struct net_device *dev,
2522 struct iw_request_info *info,
2523 union iwreq_data *wrqu, char *extra)
2524{
2525 int ret;
2526
2527 vos_ssr_protect(__func__);
2528 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2529 vos_ssr_unprotect(__func__);
2530
2531 return ret;
2532}
2533
Jeff Johnson295189b2012-06-20 16:38:30 -07002534#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2535
2536int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302537static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2538 struct iw_request_info *info,
2539 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002540{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302541 hdd_adapter_t *pHostapdAdapter;
2542 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302543 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002544 char *buf;
2545 int cnt = 0;
2546 int left;
2547 int ret = 0;
2548 /* maclist_index must be u32 to match userspace */
2549 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302550 v_CONTEXT_t pVosContext = NULL;
2551 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302553 ENTER();
2554
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302555 pHostapdAdapter = (netdev_priv(dev));
2556 if (NULL == pHostapdAdapter)
2557 {
2558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2559 "%s: Adapter is NULL",__func__);
2560 return -EINVAL;
2561 }
2562 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2563 ret = wlan_hdd_validate_context(pHddCtx);
2564 if (0 != ret)
2565 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302566 return ret;
2567 }
2568
Jeff Johnson224f3702014-03-26 11:09:47 -07002569 /*
2570 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2571 * number, and even numbered iocts are supposed to have "set"
2572 * semantics. Hence the wireless extensions support in the kernel
2573 * won't correctly copy the result to userspace, so the ioctl
2574 * handler itself must copy the data. Output format is 32-bit
2575 * record length, followed by 0 or more 6-byte STA MAC addresses.
2576 *
2577 * Further note that due to the incorrect semantics, the "iwpriv"
2578 * userspace application is unable to correctly invoke this API,
2579 * hence it is not registered in the hostapd_private_args. This
2580 * API can only be invoked by directly invoking the ioctl() system
2581 * call.
2582 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002583
Jeff Johnson224f3702014-03-26 11:09:47 -07002584 /* make sure userspace allocated a reasonable buffer size */
2585 if (wrqu->data.length < sizeof(maclist_index)) {
2586 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2587 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002589
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302590 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2591 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2592 if(pSapCtx == NULL){
2593 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2594 FL("psapCtx is NULL"));
2595 return -EFAULT;
2596 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302597
2598 /* allocate local buffer to build the response */
2599 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2600 if (!buf) {
2601 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2602 return -ENOMEM;
2603 }
2604
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302605 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002606 /* start indexing beyond where the record count will be written */
2607 maclist_index = sizeof(maclist_index);
2608 left = wrqu->data.length - maclist_index;
2609
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302610 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002611 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2612 if ((pStaInfo[cnt].isUsed) &&
2613 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2614 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2615 VOS_MAC_ADDR_SIZE);
2616 maclist_index += VOS_MAC_ADDR_SIZE;
2617 left -= VOS_MAC_ADDR_SIZE;
2618 }
2619 cnt++;
2620 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302621 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002622
2623 *((u32 *)buf) = maclist_index;
2624 wrqu->data.length = maclist_index;
2625 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2626 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2627 ret = -EFAULT;
2628 }
2629 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302630
2631 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002632 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002633}
2634
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302635int
2636static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2637 struct iw_request_info *info,
2638 union iwreq_data *wrqu, char *extra)
2639{
2640 int ret;
2641
2642 vos_ssr_protect(__func__);
2643 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2644 vos_ssr_unprotect(__func__);
2645
2646 return ret;
2647}
2648
Jeff Johnson295189b2012-06-20 16:38:30 -07002649/* Usage:
2650 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2651 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2652 while using this ioctl
2653
2654 Syntax:
2655 iwpriv softap.0 disassoc_sta <6 octet mac address>
2656
2657 e.g.
2658 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2659 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2660*/
2661
2662int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302663static __iw_softap_disassoc_sta(struct net_device *dev,
2664 struct iw_request_info *info,
2665 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002666{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302667 hdd_adapter_t *pHostapdAdapter;
2668 hdd_context_t *pHddCtx;
2669 v_U8_t *peerMacAddr;
2670 int ret = 0;
2671
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302673 pHostapdAdapter = (netdev_priv(dev));
2674 if (NULL == pHostapdAdapter)
2675 {
2676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2677 "%s: Adapter is NULL",__func__);
2678 return -EINVAL;
2679 }
2680 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2681 ret = wlan_hdd_validate_context(pHddCtx);
2682 if (0 != ret)
2683 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302684 return ret;
2685 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302686 /* iwpriv tool or framework calls this ioctl with
2687 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302689 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002690
Arif Hussain24bafea2013-11-15 15:10:03 -08002691 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2692 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2694 EXIT();
2695 return 0;
2696}
2697
2698int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302699static iw_softap_disassoc_sta(struct net_device *dev,
2700 struct iw_request_info *info,
2701 union iwreq_data *wrqu, char *extra)
2702{
2703 int ret;
2704
2705 vos_ssr_protect(__func__);
2706 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2707 vos_ssr_unprotect(__func__);
2708
2709 return ret;
2710}
2711
2712int
2713static __iw_softap_ap_stats(struct net_device *dev,
2714 struct iw_request_info *info,
2715 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002716{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302717 hdd_adapter_t *pHostapdAdapter;
2718 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 WLANTL_TRANSFER_STA_TYPE statBuffer;
2720 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302721 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002722
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302723 ENTER();
2724
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302725 pHostapdAdapter = (netdev_priv(dev));
2726 if (NULL == pHostapdAdapter)
2727 {
2728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2729 "%s: Adapter is NULL",__func__);
2730 return -EINVAL;
2731 }
2732 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2733 ret = wlan_hdd_validate_context(pHddCtx);
2734 if (0 != ret)
2735 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302736 return ret;
2737 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002738 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002739 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2740 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002741
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302742 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002743 if(NULL == pstatbuf) {
2744 hddLog(LOG1, "unable to allocate memory");
2745 return -ENOMEM;
2746 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302747
2748 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002749 "RUF=%d RMF=%d RBF=%d "
2750 "RUB=%d RMB=%d RBB=%d "
2751 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302752 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002753 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2754 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2755 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2756 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2757 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2758 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002759
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302760 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002761 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2762 kfree(pstatbuf);
2763 return -EFAULT;
2764 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302765
2766 strlcpy(extra, pstatbuf, len);
2767 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002768 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302769
2770 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 return 0;
2772}
2773
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302774int
2775static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 struct iw_request_info *info,
2777 union iwreq_data *wrqu, char *extra)
2778{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302779 int ret;
2780
2781 vos_ssr_protect(__func__);
2782 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2783 vos_ssr_unprotect(__func__);
2784
2785 return ret;
2786}
2787
2788static int __iw_softap_set_channel_range(struct net_device *dev,
2789 struct iw_request_info *info,
2790 union iwreq_data *wrqu, char *extra)
2791{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302792 hdd_adapter_t *pHostapdAdapter;
2793 tHalHandle hHal;
2794 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 int *value = (int *)extra;
2796 int startChannel = value[0];
2797 int endChannel = value[1];
2798 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002799 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 int ret = 0; /* success */
2801
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302802 ENTER();
2803
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302804 pHostapdAdapter = (netdev_priv(dev));
2805 if (NULL == pHostapdAdapter)
2806 {
2807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2808 "%s: Adapter is NULL",__func__);
2809 return -EINVAL;
2810 }
2811 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2812 ret = wlan_hdd_validate_context(pHddCtx);
2813 if (0 != ret)
2814 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302815 return ret;
2816 }
2817 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2818 if (NULL == hHal)
2819 {
2820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2821 "%s: Hal Context is NULL",__func__);
2822 return -EINVAL;
2823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2825 if(status != VOS_STATUS_SUCCESS)
2826 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002827 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 startChannel,endChannel, band);
2829 ret = -EINVAL;
2830 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002831
2832 pHddCtx->is_dynamic_channel_range_set = 1;
2833
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302834 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 return ret;
2836}
2837
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302838static int iw_softap_set_channel_range(struct net_device *dev,
2839 struct iw_request_info *info,
2840 union iwreq_data *wrqu, char *extra)
2841{
2842 int ret;
2843
2844 vos_ssr_protect(__func__);
2845 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
2846 vos_ssr_unprotect(__func__);
2847
2848 return ret;
2849}
2850
2851
2852int __iw_softap_get_channel_list(struct net_device *dev,
2853 struct iw_request_info *info,
2854 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002855{
2856 v_U32_t num_channels = 0;
2857 v_U8_t i = 0;
2858 v_U8_t bandStartChannel = RF_CHAN_1;
2859 v_U8_t bandEndChannel = RF_CHAN_165;
2860 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302861 hdd_adapter_t *pHostapdAdapter;
2862 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002865 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302866 hdd_context_t *pHddCtx;
2867 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302868
2869 ENTER();
2870
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302871 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2872 if (NULL == pHostapdAdapter)
2873 {
2874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2875 "%s: Adapter is NULL",__func__);
2876 return -EINVAL;
2877 }
2878 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2879 ret = wlan_hdd_validate_context(pHddCtx);
2880 if (0 != ret)
2881 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302882 return ret;
2883 }
2884 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2885 if (NULL == hHal)
2886 {
2887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2888 "%s: Hal Context is NULL",__func__);
2889 return -EINVAL;
2890 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002891 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2892 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002893 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002894 return -EIO;
2895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 wrqu->data.length = sizeof(tChannelListInfo);
2897 ENTER();
2898
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002899 if (eCSR_BAND_24 == curBand)
2900 {
2901 bandStartChannel = RF_CHAN_1;
2902 bandEndChannel = RF_CHAN_14;
2903 }
2904 else if (eCSR_BAND_5G == curBand)
2905 {
2906 bandStartChannel = RF_CHAN_36;
2907 bandEndChannel = RF_CHAN_165;
2908 }
2909
Arif Hussain6d2a3322013-11-17 19:50:10 -08002910 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05302911 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002912 bandStartChannel, bandEndChannel );
2913
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2915 {
2916 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2917 {
2918 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2919 num_channels++;
2920 }
2921 }
2922
2923 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2924
2925 temp_num_channels = num_channels;
2926
2927 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2928 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302929 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002930 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 }
2932
Agarwal Ashish7b557c02014-07-02 12:32:39 +05302933 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
2934 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 {
2936 for(i = 0; i < temp_num_channels; i++)
2937 {
2938
2939 if((channel_list->channels[i] > 35) &&
2940 (channel_list->channels[i] < 49))
2941 {
2942 vos_mem_move(&channel_list->channels[i],
2943 &channel_list->channels[i+1],
2944 temp_num_channels - (i-1));
2945 num_channels--;
2946 temp_num_channels--;
2947 i--;
2948 }
2949 }
2950 }
2951
Arif Hussain6d2a3322013-11-17 19:50:10 -08002952 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
2954 if (num_channels > IW_MAX_FREQUENCIES)
2955 {
2956 num_channels = IW_MAX_FREQUENCIES;
2957 }
2958
2959 channel_list->num_channels = num_channels;
2960 EXIT();
2961
2962 return 0;
2963}
2964
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302965int iw_softap_get_channel_list(struct net_device *dev,
2966 struct iw_request_info *info,
2967 union iwreq_data *wrqu, char *extra)
2968{
2969 int ret;
2970
2971 vos_ssr_protect(__func__);
2972 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
2973 vos_ssr_unprotect(__func__);
2974
2975 return ret;
2976}
2977
2978static
2979int __iw_get_genie(struct net_device *dev,
2980 struct iw_request_info *info,
2981 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002982{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302983 hdd_adapter_t *pHostapdAdapter;
2984 hdd_context_t *pHddCtx;
2985 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 eHalStatus status;
2987 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2988 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302989 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302990
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302992
2993 pHostapdAdapter = (netdev_priv(dev));
2994 if (NULL == pHostapdAdapter)
2995 {
2996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2997 "%s: Adapter is NULL",__func__);
2998 return -EINVAL;
2999 }
3000 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3001 ret = wlan_hdd_validate_context(pHddCtx);
3002 if (0 != ret)
3003 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303004 return ret;
3005 }
3006 pVosContext = pHddCtx->pvosContext;
3007 if (NULL == pVosContext)
3008 {
3009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3010 "%s: vos context is not valid ",__func__);
3011 return -EINVAL;
3012 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003013 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3015 status = WLANSap_getstationIE_information(pVosContext,
3016 &length,
3017 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003018 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3019 if (wrqu->data.length < length ||
3020 copy_to_user(wrqu->data.pointer,
3021 (v_VOID_t*)genIeBytes, length))
3022 {
3023 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3024 return -EFAULT;
3025 }
3026 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003027
Arif Hussain6d2a3322013-11-17 19:50:10 -08003028 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003029
3030
3031 EXIT();
3032 return 0;
3033}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303034
3035static
3036int iw_get_genie(struct net_device *dev,
3037 struct iw_request_info *info,
3038 union iwreq_data *wrqu, char *extra)
3039{
3040 int ret;
3041
3042 vos_ssr_protect(__func__);
3043 ret = __iw_get_genie(dev, info, wrqu, extra);
3044 vos_ssr_unprotect(__func__);
3045
3046 return ret;
3047}
3048
3049static
3050int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3051 struct iw_request_info *info,
3052 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003053{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303054 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003055 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303056 hdd_ap_ctx_t *pHddApCtx;
3057 hdd_context_t *pHddCtx;
3058 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303059
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003061
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303062 pHostapdAdapter = (netdev_priv(dev));
3063 if (NULL == pHostapdAdapter)
3064 {
3065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: Adapter is NULL",__func__);
3067 return -EINVAL;
3068 }
3069 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3070 ret = wlan_hdd_validate_context(pHddCtx);
3071 if (0 != ret)
3072 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303073 return ret;
3074 }
3075 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3076 if (NULL == pHddApCtx)
3077 {
3078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3079 "%s: AP context is NULL",__func__);
3080 return -EINVAL;
3081 }
3082
Arif Hussain6d2a3322013-11-17 19:50:10 -08003083 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003084 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3085
3086 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3087 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3088 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3089 WPSPBCProbeReqIEs.probeReqIELen);
3090 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3091 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3092 sizeof(v_MACADDR_t));
3093 if (copy_to_user(wrqu->data.pointer,
3094 (void *)&WPSPBCProbeReqIEs,
3095 sizeof(WPSPBCProbeReqIEs)))
3096 {
3097 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3098 return -EFAULT;
3099 }
3100 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003101 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003102 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 up(&pHddApCtx->semWpsPBCOverlapInd);
3104 EXIT();
3105 return 0;
3106}
3107
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303108static
3109int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3110 struct iw_request_info *info,
3111 union iwreq_data *wrqu, char *extra)
3112{
3113 int ret;
3114
3115 vos_ssr_protect(__func__);
3116 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3117 vos_ssr_unprotect(__func__);
3118
3119 return ret;
3120}
3121
Jeff Johnson295189b2012-06-20 16:38:30 -07003122/**---------------------------------------------------------------------------
3123
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303124 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 This function sets the auth type received from the wpa_supplicant.
3126
3127 \param - dev - Pointer to the net device.
3128 - info - Pointer to the iw_request_info.
3129 - wrqu - Pointer to the iwreq_data.
3130 - extra - Pointer to the data.
3131 \return - 0 for success, non zero for failure
3132
3133 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303134int __iw_set_auth_hostap(struct net_device *dev,
3135 struct iw_request_info *info,
3136 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003137{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303138 hdd_adapter_t *pAdapter;
3139 hdd_context_t *pHddCtx;
3140 hdd_wext_state_t *pWextState;
3141 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303142
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303144
3145 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3146 if (NULL == pAdapter)
3147 {
3148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3149 "%s: Adapter is NULL",__func__);
3150 return -EINVAL;
3151 }
3152
3153 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3154 ret = wlan_hdd_validate_context(pHddCtx);
3155 if (0 != ret)
3156 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303157 return ret;
3158 }
3159 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3160 if (NULL == pWextState)
3161 {
3162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3163 "%s: pWextState is NULL",__func__);
3164 return -EINVAL;
3165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 switch(wrqu->param.flags & IW_AUTH_INDEX)
3167 {
3168 case IW_AUTH_TKIP_COUNTERMEASURES:
3169 {
3170 if(wrqu->param.value) {
3171 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3172 "Counter Measure started %d", wrqu->param.value);
3173 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303174 }
3175 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3177 "Counter Measure stopped=%d", wrqu->param.value);
3178 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3179 }
3180
3181 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3182 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303185
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303187
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003188 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 wrqu->param.flags & IW_AUTH_INDEX);
3190 break;
3191 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303192
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 EXIT();
3194 return 0;
3195}
3196
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303197int iw_set_auth_hostap(struct net_device *dev,
3198 struct iw_request_info *info,
3199 union iwreq_data *wrqu,char *extra)
3200{
3201 int ret;
3202
3203 vos_ssr_protect(__func__);
3204 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3205 vos_ssr_unprotect(__func__);
3206
3207 return ret;
3208}
3209
3210static int __iw_set_ap_encodeext(struct net_device *dev,
3211 struct iw_request_info *info,
3212 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003213{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303214 hdd_adapter_t *pHostapdAdapter;
3215 v_CONTEXT_t pVosContext;
3216 hdd_context_t *pHddCtx;
3217 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003218 int retval = 0;
3219 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3221 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3222 int key_index;
3223 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303224 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003225// tCsrRoamRemoveKey RemoveKey;
3226 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303227
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303228 ENTER();
3229 pHostapdAdapter = (netdev_priv(dev));
3230 if (NULL == pHostapdAdapter)
3231 {
3232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3233 "%s: Adapter is NULL",__func__);
3234 return -EINVAL;
3235 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003236
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303237 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3238 retval = wlan_hdd_validate_context(pHddCtx);
3239 if (0 != retval)
3240 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303241 return retval;
3242 }
3243 pVosContext = pHddCtx->pvosContext;
3244 if (NULL == pVosContext)
3245 {
3246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3247 "%s: pVosContext is NULL",__func__);
3248 return -EINVAL;
3249 }
3250 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3251 if (NULL == pHddApCtx)
3252 {
3253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3254 "%s: AP Context is NULL",__func__);
3255 return -EINVAL;
3256 }
3257
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303259
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303261
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 /*Convert from 1-based to 0-based keying*/
3263 key_index--;
3264 }
3265 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303266#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 /*Set the encrytion type to NONE*/
3268#if 0
3269 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3270#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303271
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 RemoveKey.keyId = key_index;
3273 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3274 /*Key direction for group is RX only*/
3275 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3276 }
3277 else {
3278 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3279 }
3280 switch(ext->alg)
3281 {
3282 case IW_ENCODE_ALG_NONE:
3283 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3284 break;
3285 case IW_ENCODE_ALG_WEP:
3286 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3287 break;
3288 case IW_ENCODE_ALG_TKIP:
3289 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 case IW_ENCODE_ALG_CCMP:
3292 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3293 break;
3294 default:
3295 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3296 break;
3297 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003298 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 -07003299 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003301 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003303 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3304 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 {
3306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003307 __LINE__, vstatus );
3308 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003310#endif
3311 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003312
Jeff Johnson43971f52012-07-17 12:26:56 -07003313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003314
3315 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3316
3317 setKey.keyId = key_index;
3318 setKey.keyLength = ext->key_len;
3319
3320 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3321 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3322 }
3323
3324 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3325 /*Key direction for group is RX only*/
3326 setKey.keyDirection = eSIR_RX_ONLY;
3327 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3328 }
3329 else {
3330
3331 setKey.keyDirection = eSIR_TX_RX;
3332 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3333 }
3334 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3335 {
3336 setKey.keyDirection = eSIR_TX_DEFAULT;
3337 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3338 }
3339
3340 /*For supplicant pae role is zero*/
3341 setKey.paeRole = 0;
3342
3343 switch(ext->alg)
3344 {
3345 case IW_ENCODE_ALG_NONE:
3346 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3347 break;
3348
3349 case IW_ENCODE_ALG_WEP:
3350 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3351 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003352 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 break;
3354
3355 case IW_ENCODE_ALG_TKIP:
3356 {
3357 v_U8_t *pKey = &setKey.Key[0];
3358
3359 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3360
3361 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3362
3363 /*Supplicant sends the 32bytes key in this order
3364
3365 |--------------|----------|----------|
3366 | Tk1 |TX-MIC | RX Mic |
3367 |--------------|----------|----------|
3368 <---16bytes---><--8bytes--><--8bytes-->
3369
3370 */
3371 /*Sme expects the 32 bytes key to be in the below order
3372
3373 |--------------|----------|----------|
3374 | Tk1 |RX-MIC | TX Mic |
3375 |--------------|----------|----------|
3376 <---16bytes---><--8bytes--><--8bytes-->
3377 */
3378 /* Copy the Temporal Key 1 (TK1) */
3379 vos_mem_copy(pKey,ext->key,16);
3380
3381 /*Copy the rx mic first*/
3382 vos_mem_copy(&pKey[16],&ext->key[24],8);
3383
3384 /*Copy the tx mic */
3385 vos_mem_copy(&pKey[24],&ext->key[16],8);
3386
3387 }
3388 break;
3389
3390 case IW_ENCODE_ALG_CCMP:
3391 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3392 break;
3393
3394 default:
3395 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3396 break;
3397 }
3398
3399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303400 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 setKey.keyId);
3402 for(i=0; i< ext->key_len; i++)
3403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3404 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003405
3406 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3407 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 {
3409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003410 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3411 retval = -EINVAL;
3412 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303413
3414 EXIT();
3415 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003416}
Jeff Johnson43971f52012-07-17 12:26:56 -07003417
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303418static int iw_set_ap_encodeext(struct net_device *dev,
3419 struct iw_request_info *info,
3420 union iwreq_data *wrqu, char *extra)
3421{
3422 int ret;
3423
3424 vos_ssr_protect(__func__);
3425 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3426 vos_ssr_unprotect(__func__);
3427
3428 return ret;
3429}
Jeff Johnson43971f52012-07-17 12:26:56 -07003430
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303431static int __iw_set_ap_mlme(struct net_device *dev,
3432 struct iw_request_info *info,
3433 union iwreq_data *wrqu,
3434 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003435{
3436#if 0
3437 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3438 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3439
3440 ENTER();
3441
3442 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3443 switch (mlme->cmd) {
3444 case IW_MLME_DISASSOC:
3445 case IW_MLME_DEAUTH:
3446 hddLog(LOG1, "Station disassociate");
3447 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3448 {
3449 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3450
3451 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3452 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3453
3454 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3455
3456 //clear all the reason codes
3457 if (status != 0)
3458 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003459 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 }
3461
3462 netif_stop_queue(dev);
3463 netif_carrier_off(dev);
3464 }
3465 else
3466 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003467 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 -07003468 }
3469 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003470 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 return -EINVAL;
3472 }//end of switch
3473 EXIT();
3474#endif
3475 return 0;
3476// return status;
3477}
3478
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303479static int iw_set_ap_mlme(struct net_device *dev,
3480 struct iw_request_info *info,
3481 union iwreq_data *wrqu,
3482 char *extra)
3483{
3484 int ret;
3485
3486 vos_ssr_protect(__func__);
3487 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3488 vos_ssr_unprotect(__func__);
3489
3490 return ret;
3491}
3492
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303493static int __iw_get_ap_rts_threshold(struct net_device *dev,
3494 struct iw_request_info *info,
3495 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003496{
3497 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3498 v_U32_t status = 0;
3499
3500 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3501
3502 return status;
3503}
3504
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303505static int iw_get_ap_rts_threshold(struct net_device *dev,
3506 struct iw_request_info *info,
3507 union iwreq_data *wrqu, char *extra)
3508{
3509 int ret;
3510
3511 vos_ssr_protect(__func__);
3512 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3513 vos_ssr_unprotect(__func__);
3514
3515 return ret;
3516}
3517
3518static int __iw_get_ap_frag_threshold(struct net_device *dev,
3519 struct iw_request_info *info,
3520 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003521{
3522 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3523 v_U32_t status = 0;
3524
3525 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3526
3527 return status;
3528}
3529
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303530static int iw_get_ap_frag_threshold(struct net_device *dev,
3531 struct iw_request_info *info,
3532 union iwreq_data *wrqu, char *extra)
3533{
3534 int ret;
3535
3536 vos_ssr_protect(__func__);
3537 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3538 vos_ssr_unprotect(__func__);
3539
3540 return ret;
3541}
3542
3543static int __iw_get_ap_freq(struct net_device *dev,
3544 struct iw_request_info *info,
3545 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003546{
Jeff Johnsone7245742012-09-05 17:12:55 -07003547 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303548 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 tHalHandle hHal;
3550 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303551 hdd_ap_ctx_t *pHddApCtx;
3552 hdd_context_t *pHddCtx;
3553 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003554
3555 ENTER();
3556
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303557 pHostapdAdapter = (netdev_priv(dev));
3558 if (NULL == pHostapdAdapter)
3559 {
3560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3561 "%s: Adapter is NULL",__func__);
3562 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303564 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3565 ret = wlan_hdd_validate_context(pHddCtx);
3566 if (0 != ret)
3567 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303568 return ret;
3569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303571 if (NULL == pHostapdState)
3572 {
3573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3574 "%s: pHostapdState is NULL",__func__);
3575 return -EINVAL;
3576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303578 if (NULL == hHal)
3579 {
3580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3581 "%s: Hal Context is NULL",__func__);
3582 return -EINVAL;
3583 }
3584 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3585 if (NULL == pHddApCtx)
3586 {
3587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3588 "%s: AP context is NULL",__func__);
3589 return -EINVAL;
3590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 if(pHostapdState->bssState == BSS_STOP )
3592 {
3593 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3594 != eHAL_STATUS_SUCCESS)
3595 {
c_hpothuffdb5272013-10-02 16:42:35 +05303596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3597 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 return -EIO;
3599 }
3600 else
3601 {
3602 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003603 if( TRUE == status)
3604 {
3605 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3606 * iwlist & iwconfig command shows frequency into proper
3607 * format (2.412 GHz instead of 246.2 MHz)*/
3608 fwrq->m = freq;
3609 fwrq->e = MHZ;
3610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 }
3612 }
3613 else
3614 {
3615 channel = pHddApCtx->operatingChannel;
3616 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003617 if( TRUE == status)
3618 {
3619 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3620 * iwlist & iwconfig command shows frequency into proper
3621 * format (2.412 GHz instead of 246.2 MHz)*/
3622 fwrq->m = freq;
3623 fwrq->e = MHZ;
3624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303626
3627 EXIT();
3628 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003629}
3630
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303631static int iw_get_ap_freq(struct net_device *dev,
3632 struct iw_request_info *info,
3633 struct iw_freq *fwrq, char *extra)
3634{
3635 int ret;
3636
3637 vos_ssr_protect(__func__);
3638 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3639 vos_ssr_unprotect(__func__);
3640
3641 return ret;
3642}
3643
3644static int __iw_get_mode(struct net_device *dev,
3645 struct iw_request_info *info,
3646 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303647{
3648 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303649 hdd_adapter_t *pAdapter;
3650 hdd_context_t *pHddCtx;
3651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303652 ENTER();
3653
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303654 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3655 if (NULL == pAdapter)
3656 {
3657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3658 "%s: Adapter is NULL",__func__);
3659 return -EINVAL;
3660 }
3661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3662 status = wlan_hdd_validate_context(pHddCtx);
3663 if (0 != status)
3664 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303665 return status;
3666 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303667
3668 wrqu->mode = IW_MODE_MASTER;
3669
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303670 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303671 return status;
3672}
3673
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303674static int iw_get_mode(struct net_device *dev,
3675 struct iw_request_info *info,
3676 union iwreq_data *wrqu, char *extra)
3677{
3678 int ret;
3679
3680 vos_ssr_protect(__func__);
3681 ret = __iw_get_mode(dev, info, wrqu, extra);
3682 vos_ssr_unprotect(__func__);
3683
3684 return ret;
3685}
3686
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303687static int __iw_softap_setwpsie(struct net_device *dev,
3688 struct iw_request_info *info,
3689 union iwreq_data *wrqu,
3690 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003691{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303692 hdd_adapter_t *pHostapdAdapter;
3693 hdd_context_t *pHddCtx;
3694 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 hdd_hostapd_state_t *pHostapdState;
3696 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003697 u_int8_t *wps_genie;
3698 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 u_int8_t *pos;
3700 tpSap_WPSIE pSap_WPSIe;
3701 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303702 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303703 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303704 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 ENTER();
3707
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303708 pHostapdAdapter = (netdev_priv(dev));
3709 if (NULL == pHostapdAdapter)
3710 {
3711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3712 "%s: Adapter is NULL",__func__);
3713 return -EINVAL;
3714 }
3715 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3716 ret = wlan_hdd_validate_context(pHddCtx);
3717 if (0 != ret)
3718 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303719 return ret;
3720 }
3721 pVosContext = pHddCtx->pvosContext;
3722 if (NULL == pVosContext)
3723 {
3724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3725 "%s: HDD context is not valid ",__func__);
3726 return -EINVAL;
3727 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303728 /* helper function to get iwreq_data with compat handling. */
3729 if (hdd_priv_get_data(&s_priv_data, wrqu))
3730 {
3731 return -EINVAL;
3732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003733
Girish Gowli07c05ec2014-06-17 20:47:03 +05303734 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3735 {
3736 return -EINVAL;
3737 }
3738
3739 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3740 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003741
Girish Gowli86c471e2014-06-17 19:28:05 +05303742 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003743 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303744 hddLog(LOG1, "%s: failed to alloc memory "
3745 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003746 return -EFAULT;
3747 }
3748
Girish Gowli86c471e2014-06-17 19:28:05 +05303749 fwps_genie = wps_genie;
3750
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3752 if (NULL == pSap_WPSIe)
3753 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003754 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003755 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 return -ENOMEM;
3757 }
3758 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3759
Arif Hussain6d2a3322013-11-17 19:50:10 -08003760 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 -07003761 WPSIeType = wps_genie[0];
3762 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3763 {
3764 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3765 wps_genie = wps_genie + 1;
3766 switch ( wps_genie[0] )
3767 {
3768 case DOT11F_EID_WPA:
3769 if (wps_genie[1] < 2 + 4)
3770 {
3771 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003772 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 return -EINVAL;
3774 }
3775 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3776 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003777 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 pos = &wps_genie[6];
3779 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3780 {
3781 switch((u_int16_t)(*pos<<8) | *(pos+1))
3782 {
3783 case HDD_WPS_ELEM_VERSION:
3784 pos += 4;
3785 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003786 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3788 pos += 1;
3789 break;
3790
3791 case HDD_WPS_ELEM_WPS_STATE:
3792 pos +=4;
3793 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003794 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3796 pos += 1;
3797 break;
3798 case HDD_WPS_ELEM_APSETUPLOCK:
3799 pos += 4;
3800 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003801 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3803 pos += 1;
3804 break;
3805 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3806 pos += 4;
3807 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003808 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3810 pos += 1;
3811 break;
3812 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3813 pos += 4;
3814 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003815 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3817 pos += 2;
3818 break;
3819 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3820 pos += 4;
3821 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003822 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3824 pos += 2;
3825 break;
3826
3827 case HDD_WPS_ELEM_UUID_E:
3828 pos += 2;
3829 length = *pos<<8 | *(pos+1);
3830 pos += 2;
3831 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3832 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3833 pos += length;
3834 break;
3835 case HDD_WPS_ELEM_RF_BANDS:
3836 pos += 4;
3837 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003838 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3840 pos += 1;
3841 break;
3842
3843 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003844 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003846 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 return -EINVAL;
3848 }
3849 }
3850 }
3851 else {
3852 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003853 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 }
3855 break;
3856
3857 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003858 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003860 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 return 0;
3862 }
3863 }
3864 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
3865 {
3866 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
3867 wps_genie = wps_genie + 1;
3868 switch ( wps_genie[0] )
3869 {
3870 case DOT11F_EID_WPA:
3871 if (wps_genie[1] < 2 + 4)
3872 {
3873 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003874 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 return -EINVAL;
3876 }
3877 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3878 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003879 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 pos = &wps_genie[6];
3881 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3882 {
3883 switch((u_int16_t)(*pos<<8) | *(pos+1))
3884 {
3885 case HDD_WPS_ELEM_VERSION:
3886 pos += 4;
3887 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003888 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
3890 pos += 1;
3891 break;
3892
3893 case HDD_WPS_ELEM_WPS_STATE:
3894 pos +=4;
3895 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003896 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
3898 pos += 1;
3899 break;
3900 case HDD_WPS_ELEM_APSETUPLOCK:
3901 pos += 4;
3902 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003903 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
3905 pos += 1;
3906 break;
3907 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3908 pos += 4;
3909 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003910 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
3912 pos += 1;
3913 break;
3914 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3915 pos += 4;
3916 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003917 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
3919 pos += 2;
3920 break;
3921 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3922 pos += 4;
3923 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003924 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
3926 pos += 2;
3927 break;
3928 case HDD_WPS_ELEM_RSP_TYPE:
3929 pos += 4;
3930 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003931 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
3933 pos += 1;
3934 break;
3935 case HDD_WPS_ELEM_UUID_E:
3936 pos += 2;
3937 length = *pos<<8 | *(pos+1);
3938 pos += 2;
3939 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
3940 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
3941 pos += length;
3942 break;
3943
3944 case HDD_WPS_ELEM_MANUFACTURER:
3945 pos += 2;
3946 length = *pos<<8 | *(pos+1);
3947 pos += 2;
3948 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
3949 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
3950 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
3951 pos += length;
3952 break;
3953
3954 case HDD_WPS_ELEM_MODEL_NAME:
3955 pos += 2;
3956 length = *pos<<8 | *(pos+1);
3957 pos += 2;
3958 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
3959 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
3960 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
3961 pos += length;
3962 break;
3963 case HDD_WPS_ELEM_MODEL_NUM:
3964 pos += 2;
3965 length = *pos<<8 | *(pos+1);
3966 pos += 2;
3967 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
3968 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
3969 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
3970 pos += length;
3971 break;
3972 case HDD_WPS_ELEM_SERIAL_NUM:
3973 pos += 2;
3974 length = *pos<<8 | *(pos+1);
3975 pos += 2;
3976 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
3977 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
3978 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
3979 pos += length;
3980 break;
3981 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
3982 pos += 4;
3983 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003984 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 pos += 2;
3986
3987 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003988 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 pos += 4;
3990 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003991 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 pos += 2;
3993 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
3994 break;
3995 case HDD_WPS_ELEM_DEVICE_NAME:
3996 pos += 2;
3997 length = *pos<<8 | *(pos+1);
3998 pos += 2;
3999 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4000 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4001 pos += length;
4002 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4003 break;
4004 case HDD_WPS_ELEM_CONFIG_METHODS:
4005 pos += 4;
4006 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004007 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 pos += 2;
4009 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4010 break;
4011
4012 case HDD_WPS_ELEM_RF_BANDS:
4013 pos += 4;
4014 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004015 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 pos += 1;
4017 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4018 break;
4019 } // switch
4020 }
4021 }
4022 else
4023 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004024 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 }
4026
4027 } // switch
4028 }
4029 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
4030 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4031 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4032 {
4033 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4034 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4035 WLANSAP_Update_WpsIe ( pVosContext );
4036 }
4037
4038 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004039 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 EXIT();
4041 return halStatus;
4042}
4043
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304044static int iw_softap_setwpsie(struct net_device *dev,
4045 struct iw_request_info *info,
4046 union iwreq_data *wrqu,
4047 char *extra)
4048{
4049 int ret;
4050
4051 vos_ssr_protect(__func__);
4052 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4053 vos_ssr_unprotect(__func__);
4054
4055 return ret;
4056}
4057
4058static int __iw_softap_stopbss(struct net_device *dev,
4059 struct iw_request_info *info,
4060 union iwreq_data *wrqu,
4061 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004062{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304063 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304065 hdd_context_t *pHddCtx = NULL;
4066
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304068 pHostapdAdapter = (netdev_priv(dev));
4069 if (NULL == pHostapdAdapter)
4070 {
4071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4072 "%s: Adapter is NULL",__func__);
4073 return -EINVAL;
4074 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304075 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4076 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304077 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304078 return status;
4079 }
4080
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304081 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 {
4083 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4084 {
4085 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4086
4087 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304088
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304090 {
4091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004092 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 VOS_ASSERT(0);
4094 }
4095 }
4096 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304097 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 }
4099 EXIT();
4100 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4101}
4102
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304103static int iw_softap_stopbss(struct net_device *dev,
4104 struct iw_request_info *info,
4105 union iwreq_data *wrqu,
4106 char *extra)
4107{
4108 int ret;
4109
4110 vos_ssr_protect(__func__);
4111 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4112 vos_ssr_unprotect(__func__);
4113
4114 return ret;
4115}
4116
4117static int __iw_softap_version(struct net_device *dev,
4118 struct iw_request_info *info,
4119 union iwreq_data *wrqu,
4120 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004121{
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304123 hdd_context_t *pHddCtx;
4124 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304125
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304127 pHostapdAdapter = (netdev_priv(dev));
4128 if (NULL == pHostapdAdapter)
4129 {
4130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4131 "%s: Adapter is NULL",__func__);
4132 return -EINVAL;
4133 }
4134 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4135 ret = wlan_hdd_validate_context(pHddCtx);
4136 if (0 != ret)
4137 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304138 return ret;
4139 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004140 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 return 0;
4143}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004144
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304145static int iw_softap_version(struct net_device *dev,
4146 struct iw_request_info *info,
4147 union iwreq_data *wrqu,
4148 char *extra)
4149{
4150 int ret;
4151
4152 vos_ssr_protect(__func__);
4153 ret = __iw_softap_version(dev, info, wrqu, extra);
4154 vos_ssr_unprotect(__func__);
4155
4156 return ret;
4157}
4158
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004159VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004160{
4161 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004162 int len = 0;
4163 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304164 v_CONTEXT_t pVosContext;
4165 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304166 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304167
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304168 ENTER();
4169
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304170 if (NULL == pAdapter)
4171 {
4172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4173 "%s: Adapter is NULL",__func__);
4174 return -EINVAL;
4175 }
4176 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4177 if (0 != wlan_hdd_validate_context(pHddCtx))
4178 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304179 return VOS_STATUS_E_FAULT;
4180 }
4181 pVosContext = pHddCtx->pvosContext;
4182 if (NULL == pVosContext)
4183 {
4184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4185 "%s: VOS context is not valid",__func__);
4186 return VOS_STATUS_E_FAULT;
4187 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304188 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304189 if(pSapCtx == NULL)
4190 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304191 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4192 FL("psapCtx is NULL"));
4193 return VOS_STATUS_E_FAULT;
4194 }
4195
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004196 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004197 pBuf += len;
4198 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004199
4200 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4201 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304202 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004203 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004204 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304205 pSapCtx->aStaInfo[i].ucSTAId,
4206 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4207 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4208 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4209 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4210 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4211 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004212 pBuf += len;
4213 buf_len -= len;
4214 }
4215 if(WE_GET_STA_INFO_SIZE > buf_len)
4216 {
4217 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004218 }
4219 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304220 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004221 return VOS_STATUS_SUCCESS;
4222}
4223
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304224static int __iw_softap_get_sta_info(struct net_device *dev,
4225 struct iw_request_info *info,
4226 union iwreq_data *wrqu,
4227 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004228{
4229 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4230 VOS_STATUS status;
4231 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004232 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004233 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004235 return -EINVAL;
4236 }
4237 wrqu->data.length = strlen(extra);
4238 EXIT();
4239 return 0;
4240}
4241
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304242static int iw_softap_get_sta_info(struct net_device *dev,
4243 struct iw_request_info *info,
4244 union iwreq_data *wrqu,
4245 char *extra)
4246{
4247 int ret;
4248
4249 vos_ssr_protect(__func__);
4250 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4251 vos_ssr_unprotect(__func__);
4252
4253 return ret;
4254}
4255
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304256static int __iw_set_ap_genie(struct net_device *dev,
4257 struct iw_request_info *info,
4258 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004259{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304260
4261 hdd_adapter_t *pHostapdAdapter;
4262 hdd_context_t *pHddCtx;
4263 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004265 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304266 int ret = 0;
4267
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304269 pHostapdAdapter = (netdev_priv(dev));
4270 if (NULL == pHostapdAdapter)
4271 {
4272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4273 "%s: Adapter is NULL",__func__);
4274 return -EINVAL;
4275 }
4276 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4277 ret = wlan_hdd_validate_context(pHddCtx);
4278 if (0 != ret)
4279 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304280 return ret;
4281 }
4282 pVosContext = pHddCtx->pvosContext;
4283 if (NULL == pVosContext)
4284 {
4285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4286 "%s: VOS Context is NULL",__func__);
4287 return -EINVAL;
4288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 if(!wrqu->data.length)
4290 {
4291 EXIT();
4292 return 0;
4293 }
Arif Hussained667642013-10-27 23:01:14 -07004294
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304295 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304297 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 case DOT11F_EID_RSN:
4299 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4300 {
4301 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4302 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004305 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304307
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004309 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 halStatus = 0;
4311 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304312
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304314 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004315}
4316
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304317static int iw_set_ap_genie(struct net_device *dev,
4318 struct iw_request_info *info,
4319 union iwreq_data *wrqu, char *extra)
4320{
4321 int ret;
4322
4323 vos_ssr_protect(__func__);
4324 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4325 vos_ssr_unprotect(__func__);
4326
4327 return ret;
4328}
4329
Jeff Johnson295189b2012-06-20 16:38:30 -07004330static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4331{
4332 eHalStatus hstatus;
4333 long lrc;
4334 struct statsContext context;
4335
4336 if (NULL == pAdapter)
4337 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304338 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 return VOS_STATUS_E_FAULT;
4340 }
4341
4342 init_completion(&context.completion);
4343 context.pAdapter = pAdapter;
4344 context.magic = STATS_CONTEXT_MAGIC;
4345 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4346 eCSR_HDD,
4347 SME_GLOBAL_CLASSA_STATS,
4348 hdd_GetClassA_statisticsCB,
4349 0, // not periodic
4350 FALSE, //non-cached results
4351 staid,
4352 &context);
4353 if (eHAL_STATUS_SUCCESS != hstatus)
4354 {
4355 hddLog(VOS_TRACE_LEVEL_ERROR,
4356 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004357 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 }
4359 else
4360 {
4361 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4362 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 if (lrc <= 0)
4364 {
4365 hddLog(VOS_TRACE_LEVEL_ERROR,
4366 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004367 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 }
4369 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004370
4371 /* either we never sent a request, we sent a request and received a
4372 response or we sent a request and timed out. if we never sent a
4373 request or if we sent a request and got a response, we want to
4374 clear the magic out of paranoia. if we timed out there is a
4375 race condition such that the callback function could be
4376 executing at the same time we are. of primary concern is if the
4377 callback function had already verified the "magic" but had not
4378 yet set the completion variable when a timeout occurred. we
4379 serialize these activities by invalidating the magic while
4380 holding a shared spinlock which will cause us to block if the
4381 callback is currently executing */
4382 spin_lock(&hdd_context_lock);
4383 context.magic = 0;
4384 spin_unlock(&hdd_context_lock);
4385
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 return VOS_STATUS_SUCCESS;
4387}
4388
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304389int __iw_get_softap_linkspeed(struct net_device *dev,
4390 struct iw_request_info *info,
4391 union iwreq_data *wrqu,
4392 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004393
4394{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304395 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304396 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004398 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304399 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304401 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004403 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304404 int rc, valid;
4405
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304406 ENTER();
4407
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304408 pHostapdAdapter = (netdev_priv(dev));
4409 if (NULL == pHostapdAdapter)
4410 {
4411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4412 "%s: Adapter is NULL",__func__);
4413 return -EINVAL;
4414 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304415 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304416 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304417 if (0 != valid)
4418 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304419 return valid;
4420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004421
Arif Hussain6d2a3322013-11-17 19:50:10 -08004422 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004423
4424 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004425 {
Arif Hussaina9571842014-01-15 16:43:41 -08004426 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4427 if (NULL == pmacAddress) {
4428 hddLog(LOG1, "unable to allocate memory");
4429 return -ENOMEM;
4430 }
4431 if (copy_from_user((void *)pmacAddress,
4432 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4433 {
4434 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4435 kfree(pmacAddress);
4436 return -EFAULT;
4437 }
4438 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4439
4440 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004441 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004442
4443 if (!VOS_IS_STATUS_SUCCESS(status ))
4444 {
4445 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4446 }
Arif Hussained667642013-10-27 23:01:14 -07004447 }
Kiet Lam61589852013-09-19 17:10:58 +05304448 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304449 * link speed for first connected client will be returned.
4450 */
Arif Hussaina9571842014-01-15 16:43:41 -08004451 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304452 {
4453 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4454 }
4455 else
4456 {
4457 status = hdd_softap_GetStaId(pHostapdAdapter,
4458 (v_MACADDR_t *)macAddress, (void *)(&staId));
4459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004460
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304461 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304463 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 link_speed = 0;
4465 }
4466 else
4467 {
4468 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304469
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 if (!VOS_IS_STATUS_SUCCESS(status ))
4471 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 return -EINVAL;
4474 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304475
4476 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4477 staId, &link_speed);
4478
4479 link_speed = link_speed / 10;
4480
4481 if (0 == link_speed)
4482 {
4483 /* The linkspeed returned by HAL is in units of 500kbps.
4484 * converting it to mbps.
4485 * This is required to support legacy firmware which does
4486 * not return link capacity.
4487 */
4488 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 }
4491
4492 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004493 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 if ((rc < 0) || (rc >= len))
4496 {
4497 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304498 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 return -EIO;
4500 }
4501
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304502 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 return 0;
4504}
4505
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304506int iw_get_softap_linkspeed(struct net_device *dev,
4507 struct iw_request_info *info,
4508 union iwreq_data *wrqu,
4509 char *extra)
4510{
4511 int ret;
4512
4513 vos_ssr_protect(__func__);
4514 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4515 vos_ssr_unprotect(__func__);
4516
4517 return ret;
4518}
4519
4520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521static const iw_handler hostapd_handler[] =
4522{
4523 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4524 (iw_handler) NULL, /* SIOCGIWNAME */
4525 (iw_handler) NULL, /* SIOCSIWNWID */
4526 (iw_handler) NULL, /* SIOCGIWNWID */
4527 (iw_handler) NULL, /* SIOCSIWFREQ */
4528 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4529 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304530 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 (iw_handler) NULL, /* SIOCSIWSENS */
4532 (iw_handler) NULL, /* SIOCGIWSENS */
4533 (iw_handler) NULL, /* SIOCSIWRANGE */
4534 (iw_handler) NULL, /* SIOCGIWRANGE */
4535 (iw_handler) NULL, /* SIOCSIWPRIV */
4536 (iw_handler) NULL, /* SIOCGIWPRIV */
4537 (iw_handler) NULL, /* SIOCSIWSTATS */
4538 (iw_handler) NULL, /* SIOCGIWSTATS */
4539 (iw_handler) NULL, /* SIOCSIWSPY */
4540 (iw_handler) NULL, /* SIOCGIWSPY */
4541 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4542 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4543 (iw_handler) NULL, /* SIOCSIWAP */
4544 (iw_handler) NULL, /* SIOCGIWAP */
4545 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4546 (iw_handler) NULL, /* SIOCGIWAPLIST */
4547 (iw_handler) NULL, /* SIOCSIWSCAN */
4548 (iw_handler) NULL, /* SIOCGIWSCAN */
4549 (iw_handler) NULL, /* SIOCSIWESSID */
4550 (iw_handler) NULL, /* SIOCGIWESSID */
4551 (iw_handler) NULL, /* SIOCSIWNICKN */
4552 (iw_handler) NULL, /* SIOCGIWNICKN */
4553 (iw_handler) NULL, /* -- hole -- */
4554 (iw_handler) NULL, /* -- hole -- */
4555 (iw_handler) NULL, /* SIOCSIWRATE */
4556 (iw_handler) NULL, /* SIOCGIWRATE */
4557 (iw_handler) NULL, /* SIOCSIWRTS */
4558 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4559 (iw_handler) NULL, /* SIOCSIWFRAG */
4560 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4561 (iw_handler) NULL, /* SIOCSIWTXPOW */
4562 (iw_handler) NULL, /* SIOCGIWTXPOW */
4563 (iw_handler) NULL, /* SIOCSIWRETRY */
4564 (iw_handler) NULL, /* SIOCGIWRETRY */
4565 (iw_handler) NULL, /* SIOCSIWENCODE */
4566 (iw_handler) NULL, /* SIOCGIWENCODE */
4567 (iw_handler) NULL, /* SIOCSIWPOWER */
4568 (iw_handler) NULL, /* SIOCGIWPOWER */
4569 (iw_handler) NULL, /* -- hole -- */
4570 (iw_handler) NULL, /* -- hole -- */
4571 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4572 (iw_handler) NULL, /* SIOCGIWGENIE */
4573 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4574 (iw_handler) NULL, /* SIOCGIWAUTH */
4575 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4576 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4577 (iw_handler) NULL, /* SIOCSIWPMKSA */
4578};
4579
Jeff Johnson224f3702014-03-26 11:09:47 -07004580/*
4581 * Note that the following ioctls were defined with semantics which
4582 * cannot be handled by the "iwpriv" userspace application and hence
4583 * they are not included in the hostapd_private_args array
4584 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4585 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004586
4587static const struct iw_priv_args hostapd_private_args[] = {
4588 { QCSAP_IOCTL_SETPARAM,
4589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4590 { QCSAP_IOCTL_SETPARAM,
4591 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
4592 { QCSAP_PARAM_MAX_ASSOC,
4593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4594 { QCSAP_PARAM_HIDE_SSID,
4595 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004596 { QCSAP_PARAM_SET_MC_RATE,
4597 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 { QCSAP_IOCTL_GETPARAM,
4599 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4600 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4601 { QCSAP_IOCTL_GETPARAM, 0,
4602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4603 { QCSAP_PARAM_MAX_ASSOC, 0,
4604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004605 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4607 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304609 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4610 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 { QCSAP_PARAM_CLR_ACL, 0,
4612 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4613 { QCSAP_PARAM_ACL_MODE,
4614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 { QCSAP_IOCTL_GET_STAWPAIE,
4616 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4617 { QCSAP_IOCTL_SETWPAIE,
4618 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4619 { QCSAP_IOCTL_STOPBSS,
4620 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4621 { QCSAP_IOCTL_VERSION, 0,
4622 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004623 { QCSAP_IOCTL_GET_STA_INFO, 0,
4624 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004626 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004629 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304631 { QCSAP_IOCTL_AP_STATS, 0,
4632 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4634 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304635 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004636
4637 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4638 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4639 /* handlers for sub-ioctl */
4640 { WE_SET_WLAN_DBG,
4641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4642 0,
4643 "setwlandbg" },
4644
4645 /* handlers for main ioctl */
4646 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4647 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4648 0,
4649 "" },
4650
4651 /* handlers for sub-ioctl */
4652 { WE_LOG_DUMP_CMD,
4653 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4654 0,
4655 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 { WE_P2P_NOA_CMD,
4657 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4658 0,
4659 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004660 /* handlers for sub ioctl */
4661 {
4662 WE_MCC_CONFIG_CREDENTIAL,
4663 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4664 0,
4665 "setMccCrdnl" },
4666
4667 /* handlers for sub ioctl */
4668 {
4669 WE_MCC_CONFIG_PARAMS,
4670 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4671 0,
4672 "setMccConfig" },
4673
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 /* handlers for main ioctl */
4675 { QCSAP_IOCTL_MODIFY_ACL,
4676 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4677 0,
4678 "modify_acl" },
4679
4680 /* handlers for main ioctl */
4681 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4682 0,
4683 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4684 "getChannelList" },
4685
Jeff Johnsone7245742012-09-05 17:12:55 -07004686 /* handlers for main ioctl */
4687 { QCSAP_IOCTL_SET_TX_POWER,
4688 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4689 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304690 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004691
4692 /* handlers for main ioctl */
4693 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4694 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4695 0,
4696 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304697
4698 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4699 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4700 0,
4701 "dataSnapshot" },
4702
4703 /* handlers for main ioctl */
4704 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4705 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4706 0,
4707 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004708};
Jeff Johnsone7245742012-09-05 17:12:55 -07004709
Jeff Johnson295189b2012-06-20 16:38:30 -07004710static const iw_handler hostapd_private[] = {
4711 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4712 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4714 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4715 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4716 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4717 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4718 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4719 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4720 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4721 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304722 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4724 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4725 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4726 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004727 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004728 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4729 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004730 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304731 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304732 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Jeff Johnson295189b2012-06-20 16:38:30 -07004733};
4734const struct iw_handler_def hostapd_handler_def = {
4735 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4736 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4737 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4738 .standard = (iw_handler *)hostapd_handler,
4739 .private = (iw_handler *)hostapd_private,
4740 .private_args = hostapd_private_args,
4741 .get_wireless_stats = NULL,
4742};
4743#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4744struct net_device_ops net_ops_struct = {
4745 .ndo_open = hdd_hostapd_open,
4746 .ndo_stop = hdd_hostapd_stop,
4747 .ndo_uninit = hdd_hostapd_uninit,
4748 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4749 .ndo_tx_timeout = hdd_softap_tx_timeout,
4750 .ndo_get_stats = hdd_softap_stats,
4751 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4752 .ndo_do_ioctl = hdd_hostapd_ioctl,
4753 .ndo_change_mtu = hdd_hostapd_change_mtu,
4754 .ndo_select_queue = hdd_hostapd_select_queue,
4755 };
4756#endif
4757
4758int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4759{
4760 return VOS_STATUS_SUCCESS;
4761}
4762
4763void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4764{
4765#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4766 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4767#else
4768 pWlanHostapdDev->open = hdd_hostapd_open;
4769 pWlanHostapdDev->stop = hdd_hostapd_stop;
4770 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4771 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4772 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4773 pWlanHostapdDev->get_stats = hdd_softap_stats;
4774 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4775 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4776#endif
4777}
4778
4779VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304780{
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 hdd_hostapd_state_t * phostapdBuf;
4782 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004783 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004785#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004786 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4787 v_U16_t unsafeChannelCount;
4788#endif /* FEATURE_WLAN_CH_AVOID */
4789
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304790 if (pHddCtx->isLogpInProgress) {
4791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4792 "%s:LOGP in Progress. Ignore!!!",__func__);
4793 status = VOS_STATUS_E_FAILURE;
4794 }
4795
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304797 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304799
Nirav Shah7e3c8132015-06-22 23:51:42 +05304800 spin_lock_init(&pAdapter->sta_hash_lock);
4801 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4802
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004803 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4804
Leo Chang0b0e45a2013-12-15 15:18:55 -08004805#ifdef FEATURE_WLAN_CH_AVOID
4806 /* Get unsafe cahnnel list from cached location */
4807 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4808 sizeof(unsafeChannelList),
4809 &unsafeChannelCount);
4810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4811 "%s : Unsafe Channel count %d",
4812 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304813 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004814 unsafeChannelList,
4815 unsafeChannelCount);
4816#endif /* FEATURE_WLAN_CH_AVOID */
4817
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 // Zero the memory. This zeros the profile structure.
4819 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
4820
4821 // Set up the pointer to the Wireless Extensions state structure
4822 // NOP
4823 status = hdd_set_hostapd(pAdapter);
4824 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 return status;
4827 }
4828
4829 status = vos_event_init(&phostapdBuf->vosEvent);
4830 if (!VOS_IS_STATUS_SUCCESS(status))
4831 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 return status;
4834 }
4835
4836 init_completion(&pAdapter->session_close_comp_var);
4837 init_completion(&pAdapter->session_open_comp_var);
4838
4839 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4840
4841 // Register as a wireless device
4842 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4843
4844 //Initialize the data path module
4845 status = hdd_softap_init_tx_rx(pAdapter);
4846 if ( !VOS_IS_STATUS_SUCCESS( status ))
4847 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004848 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304850
4851 status = hdd_wmm_adapter_init( pAdapter );
4852 if (!VOS_IS_STATUS_SUCCESS(status))
4853 {
4854 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004855 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304856 status, status );
4857 goto error_wmm_init;
4858 }
4859
4860 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
4861
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304862 return status;
4863
4864error_wmm_init:
4865 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 EXIT();
4867 return status;
4868}
4869
4870hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4871{
4872 struct net_device *pWlanHostapdDev = NULL;
4873 hdd_adapter_t *pHostapdAdapter = NULL;
4874 v_CONTEXT_t pVosContext= NULL;
4875
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004877
4878 if (pWlanHostapdDev != NULL)
4879 {
4880 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4881
4882 //Init the net_device structure
4883 ether_setup(pWlanHostapdDev);
4884
4885 //Initialize the adapter context to zeros.
4886 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4887 pHostapdAdapter->dev = pWlanHostapdDev;
4888 pHostapdAdapter->pHddCtx = pHddCtx;
4889 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4890
4891 //Get the Global VOSS context.
4892 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4893 //Save the adapter context in global context for future.
4894 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4895
4896 //Init the net_device structure
4897 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4898
4899 hdd_set_ap_ops( pHostapdAdapter->dev );
4900
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4902 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4903
4904 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4905 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4906
4907 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4909 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4910 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
4911 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
4913 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05304914 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07004915#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4916 init_completion(&pHostapdAdapter->offchannel_tx_event);
4917#endif
4918
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4920 }
4921 return pHostapdAdapter;
4922}
4923
4924VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4925{
4926 struct net_device *dev = pAdapter->dev;
4927 VOS_STATUS status = VOS_STATUS_SUCCESS;
4928
4929 ENTER();
4930
4931 if( rtnl_lock_held )
4932 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004933 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 if( dev_alloc_name(dev, dev->name) < 0 )
4935 {
4936 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4937 return VOS_STATUS_E_FAILURE;
4938 }
4939 }
4940 if (register_netdevice(dev))
4941 {
4942 hddLog(VOS_TRACE_LEVEL_FATAL,
4943 "%s:Failed:register_netdevice", __func__);
4944 return VOS_STATUS_E_FAILURE;
4945 }
4946 }
4947 else
4948 {
4949 if (register_netdev(dev))
4950 {
4951 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
4952 return VOS_STATUS_E_FAILURE;
4953 }
4954 }
4955 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
4956
4957 EXIT();
4958 return status;
4959}
4960
c_hpothu002231a2015-02-05 14:58:51 +05304961VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07004962{
4963 ENTER();
4964
4965 hdd_softap_deinit_tx_rx(pAdapter);
4966
4967 /* if we are being called during driver unload, then the dev has already
4968 been invalidated. if we are being called at other times, then we can
4969 detatch the wireless device handlers */
4970 if (pAdapter->dev)
4971 {
c_hpothu002231a2015-02-05 14:58:51 +05304972 if (TRUE == rtnl_held)
4973 {
4974 pAdapter->dev->wireless_handlers = NULL;
4975 }
4976 else
4977 {
4978 rtnl_lock();
4979 pAdapter->dev->wireless_handlers = NULL;
4980 rtnl_unlock();
4981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 }
4983 EXIT();
4984 return 0;
4985}