blob: 0cccd49b67c2b00f366f56a8badca48d08785270 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
33 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
34
35 Qualcomm Confidential and Proprietary.
36
37 ========================================================================*/
38/**=========================================================================
39 EDIT HISTORY FOR FILE
40
41
42 This section contains comments describing changes made to the module.
43 Notice that changes are listed in reverse chronological order.
44
45 $Header:$ $DateTime: $ $Author: $
46
47
48 when who what, where, why
49 -------- --- --------------------------------------------------------
50 04/5/09 Shailender Created module.
51 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
52 ==========================================================================*/
53/*--------------------------------------------------------------------------
54 Include Files
55 ------------------------------------------------------------------------*/
56
57#include <linux/version.h>
58#include <linux/module.h>
59#include <linux/kernel.h>
60#include <linux/init.h>
61#include <linux/wireless.h>
62#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070063#include <linux/compat.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070064#include <vos_api.h>
65#include <vos_sched.h>
66#include <linux/etherdevice.h>
67#include <wlan_hdd_includes.h>
68#include <qc_sap_ioctl.h>
69#include <wlan_hdd_hostapd.h>
70#include <sapApi.h>
71#include <sapInternal.h>
72#include <wlan_qct_tl.h>
73#include <wlan_hdd_softap_tx_rx.h>
74#include <wlan_hdd_main.h>
75#include <linux/netdevice.h>
76#include <linux/mmc/sdio_func.h>
77#include "wlan_nlink_common.h"
78#include "wlan_btc_svc.h"
79#include <bap_hdd_main.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070080#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070081#include "cfgApi.h"
82#include "wniCfgAp.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070083
Leo Chang0b0e45a2013-12-15 15:18:55 -080084#ifdef FEATURE_WLAN_CH_AVOID
85#include "wcnss_wlan.h"
86#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053087#include "wlan_hdd_trace.h"
88#include "vos_types.h"
89#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080090
Jeff Johnson295189b2012-06-20 16:38:30 -070091#define IS_UP(_dev) \
92 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
93#define IS_UP_AUTO(_ic) \
94 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
95#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070096#define WE_GET_STA_INFO_SIZE 30
97/* WEXT limition: MAX allowed buf len for any *
98 * IW_PRIV_TYPE_CHAR is 2Kbytes *
99 */
100#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700101
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530102#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700103
Leo Chang0b0e45a2013-12-15 15:18:55 -0800104#ifdef FEATURE_WLAN_CH_AVOID
105/* Channle/Freqency table */
106extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
107safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
108{
109 /*CH , SAFE, default safe */
110 {1 , VOS_TRUE}, //RF_CHAN_1,
111 {2 , VOS_TRUE}, //RF_CHAN_2,
112 {3 , VOS_TRUE}, //RF_CHAN_3,
113 {4 , VOS_TRUE}, //RF_CHAN_4,
114 {5 , VOS_TRUE}, //RF_CHAN_5,
115 {6 , VOS_TRUE}, //RF_CHAN_6,
116 {7 , VOS_TRUE}, //RF_CHAN_7,
117 {8 , VOS_TRUE}, //RF_CHAN_8,
118 {9 , VOS_TRUE}, //RF_CHAN_9,
119 {10 , VOS_TRUE}, //RF_CHAN_10,
120 {11 , VOS_TRUE}, //RF_CHAN_11,
121 {12 , VOS_TRUE}, //RF_CHAN_12,
122 {13 , VOS_TRUE}, //RF_CHAN_13,
123 {14 , VOS_TRUE}, //RF_CHAN_14,
124 {240, VOS_TRUE}, //RF_CHAN_240,
125 {244, VOS_TRUE}, //RF_CHAN_244,
126 {248, VOS_TRUE}, //RF_CHAN_248,
127 {252, VOS_TRUE}, //RF_CHAN_252,
128 {208, VOS_TRUE}, //RF_CHAN_208,
129 {212, VOS_TRUE}, //RF_CHAN_212,
130 {216, VOS_TRUE}, //RF_CHAN_216,
131 {36 , VOS_TRUE}, //RF_CHAN_36,
132 {40 , VOS_TRUE}, //RF_CHAN_40,
133 {44 , VOS_TRUE}, //RF_CHAN_44,
134 {48 , VOS_TRUE}, //RF_CHAN_48,
135 {52 , VOS_TRUE}, //RF_CHAN_52,
136 {56 , VOS_TRUE}, //RF_CHAN_56,
137 {60 , VOS_TRUE}, //RF_CHAN_60,
138 {64 , VOS_TRUE}, //RF_CHAN_64,
139 {100, VOS_TRUE}, //RF_CHAN_100,
140 {104, VOS_TRUE}, //RF_CHAN_104,
141 {108, VOS_TRUE}, //RF_CHAN_108,
142 {112, VOS_TRUE}, //RF_CHAN_112,
143 {116, VOS_TRUE}, //RF_CHAN_116,
144 {120, VOS_TRUE}, //RF_CHAN_120,
145 {124, VOS_TRUE}, //RF_CHAN_124,
146 {128, VOS_TRUE}, //RF_CHAN_128,
147 {132, VOS_TRUE}, //RF_CHAN_132,
148 {136, VOS_TRUE}, //RF_CHAN_136,
149 {140, VOS_TRUE}, //RF_CHAN_140,
150 {149, VOS_TRUE}, //RF_CHAN_149,
151 {153, VOS_TRUE}, //RF_CHAN_153,
152 {157, VOS_TRUE}, //RF_CHAN_157,
153 {161, VOS_TRUE}, //RF_CHAN_161,
154 {165, VOS_TRUE}, //RF_CHAN_165,
155};
156#endif /* FEATURE_WLAN_CH_AVOID */
157
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530158/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 * Function definitions
160 *-------------------------------------------------------------------------*/
161/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530162
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530163 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530164
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 This is called in response to ifconfig up
166
167 \param - dev Pointer to net_device structure
168
169 \return - 0 for success non-zero for failure
170
171 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530172int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700173{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530174 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
175
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 ENTER();
177
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530178 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
179 {
180 //WMM_INIT OR BSS_START not completed
181 hddLog( LOGW, "Ignore hostadp open request");
182 EXIT();
183 return 0;
184 }
185
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530186 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
187 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 //Turn ON carrier state
189 netif_carrier_on(dev);
190 //Enable all Tx queues
191 netif_tx_start_all_queues(dev);
192
193 EXIT();
194 return 0;
195}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530196
197int hdd_hostapd_open (struct net_device *dev)
198{
199 int ret;
200
201 vos_ssr_protect(__func__);
202 ret = __hdd_hostapd_open(dev);
203 vos_ssr_unprotect(__func__);
204
205 return ret;
206}
207
Jeff Johnson295189b2012-06-20 16:38:30 -0700208/**---------------------------------------------------------------------------
209
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530210 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212 This is called in response to ifconfig down
213
214 \param - dev Pointer to net_device structure
215
216 \return - 0 for success non-zero for failure
217
218 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530219int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700220{
221 ENTER();
222
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530223 if(NULL != dev) {
224 //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);
261
262 ENTER();
263
264 if (pHostapdAdapter && pHostapdAdapter->pHddCtx)
265 {
266 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter);
267
268 /* after uninit our adapter structure will no longer be valid */
269 pHostapdAdapter->dev = NULL;
270 }
271
272 EXIT();
273}
274
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530275static void hdd_hostapd_uninit (struct net_device *dev)
276{
277 vos_ssr_protect(__func__);
278 __hdd_hostapd_uninit(dev);
279 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700280
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530281 return;
282}
Jeff Johnson295189b2012-06-20 16:38:30 -0700283/**============================================================================
284 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
285 transmitting packets. There are 2 versions of this function. One that uses
286 locked queue and other that uses lockless queues. Both have been retained to
287 do some performance testing
288 @param skb : [in] pointer to OS packet (sk_buff)
289 @param dev : [in] pointer to Libra network device
290
291 @return : NET_XMIT_DROP if packets are dropped
292 : NET_XMIT_SUCCESS if packet is enqueued succesfully
293 ===========================================================================*/
294int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
295{
296 return 0;
297}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530298
299int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700300{
301 return 0;
302}
303
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530304int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
305{
306 int ret;
307 vos_ssr_protect(__func__);
308 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
309 vos_ssr_unprotect(__func__);
310
311 return ret;
312}
313
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700314static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
315 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700316{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700317 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530318 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
319 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700320 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530321 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700322 /*
323 * Note that valid pointers are provided by caller
324 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700325
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700326 if (priv_data->total_len <= 0 ||
327 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
328 {
329 /* below we allocate one more byte for command buffer.
330 * To avoid addition overflow total_len should be
331 * smaller than INT_MAX. */
332 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
333 __func__, priv_data->total_len);
334 ret = -EFAULT;
335 goto exit;
336 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530337 status = wlan_hdd_validate_context(pHddCtx);
338
339 if (0 != status)
340 {
341 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
342 "%s: HDD context is not valid", __func__);
343 return status;
344 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700345
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700346 /* Allocate +1 for '\0' */
347 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
348 if (!command)
349 {
350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
351 ret = -ENOMEM;
352 goto exit;
353 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700354
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700355 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
356 {
357 ret = -EFAULT;
358 goto exit;
359 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800360
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700361 /* Make sure the command is NUL-terminated */
362 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700363
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700364 hddLog(VOS_TRACE_LEVEL_INFO,
365 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700367 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
368 {
369 hdd_setP2pNoa(pAdapter->dev, command);
370 }
371 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
372 {
373 hdd_setP2pOpps(pAdapter->dev, command);
374 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800375#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
377 {
378 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
379 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800380#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700381 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
382 {
383 /*
384 * command should be a string having format
385 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
386 */
387 hddLog(VOS_TRACE_LEVEL_INFO,
388 "%s: Received Command to Set Preferred Channels for SAP",
389 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800390
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700391 ret = sapSetPreferredChannel(command);
392 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530393 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
394 {
395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
396 tANI_U8 filterType = 0;
397 tANI_U8 *value;
398 value = command + 9;
399
400 /* Convert the value from ascii to integer */
401 ret = kstrtou8(value, 10, &filterType);
402 if (ret < 0)
403 {
404 /* If the input value is greater than max value of datatype,
405 * then also kstrtou8 fails
406 */
407 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
408 "%s: kstrtou8 failed range ", __func__);
409 ret = -EINVAL;
410 goto exit;
411 }
412 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
413 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
414 {
415 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
416 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
417 " 2-Sink ", __func__);
418 ret = -EINVAL;
419 goto exit;
420 }
421 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
422 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530423 pScanInfo = &pHddCtx->scan_info;
424 if (filterType && pScanInfo != NULL &&
425 pHddCtx->scan_info.mScanPending)
426 {
427 /*Miracast Session started. Abort Scan */
428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
429 "%s, Aborting Scan For Miracast",__func__);
430 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
431 eCSR_SCAN_ABORT_DEFAULT);
432 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530433 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
434 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
435 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700436
Jeff Johnson295189b2012-06-20 16:38:30 -0700437exit:
438 if (command)
439 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700440 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 }
442 return ret;
443}
444
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700445#ifdef CONFIG_COMPAT
446static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
447 struct ifreq *ifr)
448{
449 struct {
450 compat_uptr_t buf;
451 int used_len;
452 int total_len;
453 } compat_priv_data;
454 hdd_priv_data_t priv_data;
455 int ret = 0;
456
457 /*
458 * Note that pAdapter and ifr have already been verified by caller,
459 * and HDD context has also been validated
460 */
461 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
462 sizeof(compat_priv_data))) {
463 ret = -EFAULT;
464 goto exit;
465 }
466 priv_data.buf = compat_ptr(compat_priv_data.buf);
467 priv_data.used_len = compat_priv_data.used_len;
468 priv_data.total_len = compat_priv_data.total_len;
469 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
470 exit:
471 return ret;
472}
473#else /* CONFIG_COMPAT */
474static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
475 struct ifreq *ifr)
476{
477 /* will never be invoked */
478 return 0;
479}
480#endif /* CONFIG_COMPAT */
481
482static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
483{
484 hdd_priv_data_t priv_data;
485 int ret = 0;
486
487 /*
488 * Note that pAdapter and ifr have already been verified by caller,
489 * and HDD context has also been validated
490 */
491 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
492 ret = -EFAULT;
493 } else {
494 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
495 }
496 return ret;
497}
498
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530499static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700500 struct ifreq *ifr, int cmd)
501{
502 hdd_adapter_t *pAdapter;
503 hdd_context_t *pHddCtx;
504 int ret;
505
506 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
507 if (NULL == pAdapter) {
508 hddLog(VOS_TRACE_LEVEL_ERROR,
509 "%s: HDD adapter context is Null", __func__);
510 ret = -ENODEV;
511 goto exit;
512 }
513 if (dev != pAdapter->dev) {
514 hddLog(VOS_TRACE_LEVEL_ERROR,
515 "%s: HDD adapter/dev inconsistency", __func__);
516 ret = -ENODEV;
517 goto exit;
518 }
519
520 if ((!ifr) || (!ifr->ifr_data)) {
521 ret = -EINVAL;
522 goto exit;
523 }
524
525 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
526 ret = wlan_hdd_validate_context(pHddCtx);
527 if (ret) {
528 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: invalid context", __func__);
529 ret = -EBUSY;
530 goto exit;
531 }
532
533 switch (cmd) {
534 case (SIOCDEVPRIVATE + 1):
535 if (is_compat_task())
536 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
537 else
538 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
539 break;
540 default:
541 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
542 __func__, cmd);
543 ret = -EINVAL;
544 break;
545 }
546 exit:
547 return ret;
548}
549
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530550static int hdd_hostapd_ioctl(struct net_device *dev,
551 struct ifreq *ifr, int cmd)
552{
553 int ret;
554
555 vos_ssr_protect(__func__);
556 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
557 vos_ssr_unprotect(__func__);
558
559 return ret;
560}
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562/**---------------------------------------------------------------------------
563
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530564 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 This function sets the user specified mac address using
566 the command ifconfig wlanX hw ether <mac adress>.
567
568 \param - dev - Pointer to the net device.
569 - addr - Pointer to the sockaddr.
570 \return - 0 for success, non zero for failure
571
572 --------------------------------------------------------------------------*/
573
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530574static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700575{
576 struct sockaddr *psta_mac_addr = addr;
577 ENTER();
578 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
579 EXIT();
580 return 0;
581}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530582
583static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
584{
585 int ret;
586
587 vos_ssr_protect(__func__);
588 ret = __hdd_hostapd_set_mac_address(dev, addr);
589 vos_ssr_unprotect(__func__);
590
591 return ret;
592}
593
Jeff Johnson295189b2012-06-20 16:38:30 -0700594void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
595{
596 struct net_device *dev = (struct net_device *)usrDataForCallback;
597 v_BYTE_t we_custom_event[64];
598 union iwreq_data wrqu;
599#ifdef DISABLE_CONCURRENCY_AUTOSAVE
600 VOS_STATUS vos_status;
601 hdd_adapter_t *pHostapdAdapter;
602 hdd_ap_ctx_t *pHddApCtx;
603#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
604
605 /* event_name space-delimiter driver_module_name */
606 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
607 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
608 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
609
610 ENTER();
611
Agarwal Ashish51325b52014-06-16 16:50:49 +0530612#ifdef DISABLE_CONCURRENCY_AUTOSAVE
613 if (vos_concurrent_open_sessions_running())
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 {
615 /*
616 This timer routine is going to be called only when AP
617 persona is up.
618 If there are concurrent sessions running we do not want
619 to shut down the Bss.Instead we run the timer again so
620 that if Autosave is enabled next time and other session
621 was down only then we bring down AP
622 */
623 pHostapdAdapter = netdev_priv(dev);
624 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
625 vos_status = vos_timer_start(
626 &pHddApCtx->hdd_ap_inactivity_timer,
627 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
628 * 1000);
629 if (!VOS_IS_STATUS_SUCCESS(vos_status))
630 {
631 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
632 }
633 EXIT();
634 return;
635 }
636#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
637 memset(&we_custom_event, '\0', sizeof(we_custom_event));
638 memcpy(&we_custom_event, autoShutEvent, event_len);
639
640 memset(&wrqu, 0, sizeof(wrqu));
641 wrqu.data.length = event_len;
642
643 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
644 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
645
646 EXIT();
647}
648
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800649VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
650{
651 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
652 ptSapContext pSapCtx = NULL;
653 eHalStatus halStatus = eHAL_STATUS_FAILURE;
654 v_PVOID_t hHal = NULL;
655
656 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
657 "%s: UPDATE Beacon Params", __func__);
658
659 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
660 pSapCtx = VOS_GET_SAP_CB(pVosContext);
661 if ( NULL == pSapCtx )
662 {
663 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
664 "%s: Invalid SAP pointer from pvosGCtx", __func__);
665 return VOS_STATUS_E_FAULT;
666 }
667
668 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
669 if ( NULL == hHal ){
670 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
671 "%s: Invalid HAL pointer from pvosGCtx", __func__);
672 return VOS_STATUS_E_FAULT;
673 }
674 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
675 if(halStatus == eHAL_STATUS_FAILURE ){
676 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
677 "%s: Failed to update Beacon Params", __func__);
678 return VOS_STATUS_E_FAILURE;
679 }
680 }
681 return VOS_STATUS_SUCCESS;
682}
683
684void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
685{
686 v_U8_t staId = 0;
687 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530688 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
689 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800690
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530691 dev = (struct net_device *)usrDataForCallback;
692 pSapCtx = VOS_GET_SAP_CB(pVosContext);
693 if(pSapCtx == NULL){
694 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
695 FL("psapCtx is NULL"));
696 return;
697 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800698 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800699 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
700 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530701 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800702 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
703 {
704 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530705 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800706 }
707 }
708}
709
710static int hdd_stop_p2p_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
711{
712 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530713 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800714 VOS_STATUS status = VOS_STATUS_SUCCESS;
715 dev = (struct net_device *)usrDataForCallback;
716 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530717
718 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
719 status = wlan_hdd_validate_context(pHddCtx);
720
721 if (0 != status) {
722 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
723 return status;
724 }
725
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800726 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
727 {
728 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
729 {
730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting P2P link!!!!!!"));
731 }
732 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530733 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800734 }
735 EXIT();
736 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
737}
Jeff Johnson295189b2012-06-20 16:38:30 -0700738
739VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
740{
741 hdd_adapter_t *pHostapdAdapter;
742 hdd_ap_ctx_t *pHddApCtx;
743 hdd_hostapd_state_t *pHostapdState;
744 struct net_device *dev;
745 eSapHddEvent sapEvent;
746 union iwreq_data wrqu;
747 v_BYTE_t *we_custom_event_generic = NULL;
748 int we_event = 0;
749 int i = 0;
750 v_U8_t staId;
751 VOS_STATUS vos_status;
752 v_BOOL_t bWPSState;
753 v_BOOL_t bApActive = FALSE;
754 v_BOOL_t bAuthRequired = TRUE;
755 tpSap_AssocMacAddr pAssocStasArray = NULL;
756 char unknownSTAEvent[IW_CUSTOM_MAX+1];
757 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
758 v_BYTE_t we_custom_start_event[64];
759 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800760 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800761 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700762 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530763 v_CONTEXT_t pVosContext = NULL;
764 ptSapContext pSapCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700765
766 dev = (struct net_device *)usrDataForCallback;
767 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530768
769 if ((NULL == pHostapdAdapter) ||
770 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
771 {
772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
773 "invalid adapter or adapter has invalid magic");
774 return eHAL_STATUS_FAILURE;
775 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530776 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
777 pSapCtx = VOS_GET_SAP_CB(pVosContext);
778 if(pSapCtx == NULL){
779 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
780 FL("psapCtx is NULL"));
781 return eHAL_STATUS_FAILURE;
782 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
784 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
785 sapEvent = pSapEvent->sapHddEventCode;
786 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800787 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
789 switch(sapEvent)
790 {
791 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800792 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
794 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
795 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
796
797 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
798 vos_status = vos_event_set(&pHostapdState->vosEvent);
799
800 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
801 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 goto stopbss;
804 }
805 else
806 {
807 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
808 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530809 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
810 if (!VOS_IS_STATUS_SUCCESS(vos_status))
811 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813
814 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
815 {
816 // AP Inactivity timer init and start
817 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
818 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
819 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800820 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700821
822 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
823 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800824 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
826 }
827 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
828 pHostapdState->bssState = BSS_START;
829
830 // Send current operating channel of SoftAP to BTC-ES
831 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
832
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 //Check if there is any group key pending to set.
834 if( pHddApCtx->groupKey.keyLength )
835 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700836 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
838 &pHddApCtx->groupKey ) )
839 {
840 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
841 "%s: WLANSAP_SetKeySta failed", __func__);
842 }
843 pHddApCtx->groupKey.keyLength = 0;
844 }
845 else if ( pHddApCtx->wepKey[0].keyLength )
846 {
847 int i=0;
848 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
849 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700850 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
852 &pHddApCtx->wepKey[i] ) )
853 {
854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
855 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
856 }
857 pHddApCtx->wepKey[i].keyLength = 0;
858 }
859 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
861 startBssEvent = "SOFTAP.enabled";
862 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
863 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
864 memset(&wrqu, 0, sizeof(wrqu));
865 wrqu.data.length = strlen(startBssEvent);
866 we_event = IWEVCUSTOM;
867 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700868 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 break; //Event will be sent after Switch-Case stmt
870
871 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800872 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
874
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700875 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700876 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700877
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 goto stopbss;
880 case eSAP_STA_SET_KEY_EVENT:
881 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800882 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
884 return VOS_STATUS_SUCCESS;
885 case eSAP_STA_DEL_KEY_EVENT:
886 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800887 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 return VOS_STATUS_SUCCESS;
889 case eSAP_STA_MIC_FAILURE_EVENT:
890 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 memset(&msg, '\0', sizeof(msg));
892 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800893 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800894 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700895 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 msg.flags = IW_MICFAILURE_GROUP;
897 else
898 msg.flags = IW_MICFAILURE_PAIRWISE;
899 memset(&wrqu, 0, sizeof(wrqu));
900 wrqu.data.length = sizeof(msg);
901 we_event = IWEVMICHAELMICFAILURE;
902 we_custom_event_generic = (v_BYTE_t *)&msg;
903 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* inform mic failure to nl80211 */
905 cfg80211_michael_mic_failure(dev,
906 pSapEvent->sapevt.
907 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700908 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 NL80211_KEYTYPE_GROUP :
910 NL80211_KEYTYPE_PAIRWISE),
911 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
912 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
913 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 break;
915
916 case eSAP_STA_ASSOC_EVENT:
917 case eSAP_STA_REASSOC_EVENT:
918 wrqu.addr.sa_family = ARPHRD_ETHER;
919 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800920 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800921 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 we_event = IWEVREGISTERED;
923
924 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
925
926 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
927 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
928 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
929 {
930 bAuthRequired = FALSE;
931 }
932
933 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
934 {
c_hpothuffdb5272013-10-02 16:42:35 +0530935 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 TRUE,
937 pHddApCtx->uPrivacy,
938 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
939 0,
940 0,
941 (v_MACADDR_t *)wrqu.addr.sa_data,
942 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +0530943
944 if (!VOS_IS_STATUS_SUCCESS(vos_status))
945 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
946 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 }
948 else
949 {
c_hpothuffdb5272013-10-02 16:42:35 +0530950 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 FALSE,
952 pHddApCtx->uPrivacy,
953 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
954 0,
955 0,
956 (v_MACADDR_t *)wrqu.addr.sa_data,
957 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +0530958 if (!VOS_IS_STATUS_SUCCESS(vos_status))
959 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
960 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -0700961 }
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 // Stop AP inactivity timer
964 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
965 {
966 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
967 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800968 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800970#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800971 if (wake_lock_active(&pHddCtx->sap_wake_lock))
972 {
973 wake_unlock(&pHddCtx->sap_wake_lock);
974 }
Amar Singhal6144c002013-05-03 16:11:42 -0700975 wake_lock_timeout(&pHddCtx->sap_wake_lock, msecs_to_jiffies(HDD_SAP_WAKE_LOCK_DURATION));
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800976#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700977#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
978 {
979 struct station_info staInfo;
980 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
981
982 memset(&staInfo, 0, sizeof(staInfo));
983 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
984 {
985 staInfo.assoc_req_ies =
986 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
987 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700988#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700989 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 cfg80211_new_sta(dev,
992 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
993 &staInfo, GFP_KERNEL);
994 }
995 else
996 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800997 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 }
999 }
1000#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001001 pScanInfo = &pHddCtx->scan_info;
1002 // Lets do abort scan to ensure smooth authentication for client
1003 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1004 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301005 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301006 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001008
1009 break;
1010 case eSAP_STA_DISASSOC_EVENT:
1011 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001012 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001013 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1015 hddLog(LOG1," User initiated disassociation");
1016 else
1017 hddLog(LOG1," MAC initiated disassociation");
1018 we_event = IWEVEXPIRED;
1019 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1020 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1021 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001022 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 -07001023 return VOS_STATUS_E_FAILURE;
1024 }
1025 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1026
1027 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1028 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301029 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 // Start AP inactivity timer if no stations associated with it
1031 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1032 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301033 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 {
1035 bApActive = TRUE;
1036 break;
1037 }
1038 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301039 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001040
1041 if (bApActive == FALSE)
1042 {
1043 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1044 {
1045 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1046 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001047 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 }
1049 else
1050 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1051 }
1052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001053#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1054 cfg80211_del_sta(dev,
1055 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1056 GFP_KERNEL);
1057#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001058 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301059 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1060 if (VOS_STATUS_SUCCESS != vos_status)
1061 {
1062 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1063 __func__, vos_status);
1064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 break;
1066 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1067 {
1068 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1069 union iwreq_data wreq;
1070
1071 down(&pHddApCtx->semWpsPBCOverlapInd);
1072 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1073
1074 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1075 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1076
1077 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001078 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 memset(&wreq, 0, sizeof(wreq));
1080 wreq.data.length = strlen(message); // This is length of message
1081 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1082
1083 return VOS_STATUS_SUCCESS;
1084 }
1085 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1086 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1087 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1088 { // List of associated stations
1089 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1090 {
1091 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1092 i+1,
1093 pAssocStasArray->assocId,
1094 pAssocStasArray->staId,
1095 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1096 pAssocStasArray++;
1097 }
1098 }
1099 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001100 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 case eSAP_INDICATE_MGMT_FRAME:
1103 hdd_indicateMgmtFrame( pHostapdAdapter,
1104 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1105 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1106 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301107 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 return VOS_STATUS_SUCCESS;
1109 case eSAP_REMAIN_CHAN_READY:
1110 hdd_remainChanReadyHandler( pHostapdAdapter );
1111 return VOS_STATUS_SUCCESS;
1112 case eSAP_SEND_ACTION_CNF:
1113 hdd_sendActionCnf( pHostapdAdapter,
1114 ( eSAP_STATUS_SUCCESS ==
1115 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1116 TRUE : FALSE );
1117 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 case eSAP_UNKNOWN_STA_JOIN:
1119 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1120 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1121 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1122 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1123 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1124 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1125 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1126 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1127 wrqu.data.pointer = unknownSTAEvent;
1128 wrqu.data.length = strlen(unknownSTAEvent);
1129 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301130 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 break;
1132
1133 case eSAP_MAX_ASSOC_EXCEEDED:
1134 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1135 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1136 " one or more devices to enable the new device connection",
1137 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1138 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1139 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1140 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1141 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1142 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1143 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1144 wrqu.data.pointer = maxAssocExceededEvent;
1145 wrqu.data.length = strlen(maxAssocExceededEvent);
1146 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001147 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 break;
1149 case eSAP_STA_ASSOC_IND:
1150 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001151
1152 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001153 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001154 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1155 return VOS_STATUS_SUCCESS;
1156
1157 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
c_hpothuffdb5272013-10-02 16:42:35 +05301158 vos_status = hdd_stop_p2p_link(pHostapdAdapter, usrDataForCallback);
1159 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1160 {
1161 hddLog(LOGW, FL("hdd_stop_p2p_link failed %d"), vos_status);
1162 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001163 return VOS_STATUS_SUCCESS;
1164
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001166 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 goto stopbss;
1168 return VOS_STATUS_SUCCESS;
1169 }
1170 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1171 return VOS_STATUS_SUCCESS;
1172
1173stopbss :
1174 {
1175 v_BYTE_t we_custom_event[64];
1176 char *stopBssEvent = "STOP-BSS.response";//17
1177 int event_len = strlen(stopBssEvent);
1178
1179 hddLog(LOG1, FL("BSS stop status = %s"),
1180 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1181 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1182
1183 /* Change the BSS state now since, as we are shutting things down,
1184 * we don't want interfaces to become re-enabled */
1185 pHostapdState->bssState = BSS_STOP;
1186
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301187 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1188 {
1189 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1190 {
1191 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1192 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1193 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1194 }
1195
1196 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1197 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1198 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1199 }
1200
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 /* Stop the pkts from n/w stack as we are going to free all of
1202 * the TX WMM queues for all STAID's */
1203 hdd_hostapd_stop(dev);
1204
1205 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301206 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1207 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1208 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
Amar Singhal37e6f052013-03-05 16:16:54 -08001210 /* once the event is set, structure dev/pHostapdAdapter should
1211 * not be touched since they are now subject to being deleted
1212 * by another thread */
1213 if (eSAP_STOP_BSS_EVENT == sapEvent)
1214 vos_event_set(&pHostapdState->vosEvent);
1215
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 /* notify userspace that the BSS has stopped */
1217 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1218 memcpy(&we_custom_event, stopBssEvent, event_len);
1219 memset(&wrqu, 0, sizeof(wrqu));
1220 wrqu.data.length = event_len;
1221 we_event = IWEVCUSTOM;
1222 we_custom_event_generic = we_custom_event;
1223 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001224 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 }
1226 return VOS_STATUS_SUCCESS;
1227}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001228
1229int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001231 eCsrEncryptionType *pEncryptType,
1232 eCsrEncryptionType *mcEncryptType,
1233 eCsrAuthType *pAuthType,
1234 v_BOOL_t *pMFPCapable,
1235 v_BOOL_t *pMFPRequired,
1236 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 u_int8_t *gen_ie )
1238{
1239 tDot11fIERSN dot11RSNIE;
1240 tDot11fIEWPA dot11WPAIE;
1241
1242 tANI_U8 *pRsnIe;
1243 tANI_U16 RSNIeLen;
1244
1245 if (NULL == halHandle)
1246 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001247 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 return -EINVAL;
1249 }
1250
1251 // Validity checks
1252 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1253 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1254 return -EINVAL;
1255 // Type check
1256 if ( gen_ie[0] == DOT11F_EID_RSN)
1257 {
1258 // Validity checks
1259 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1260 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1261 {
1262 return VOS_STATUS_E_FAILURE;
1263 }
1264 // Skip past the EID byte and length byte
1265 pRsnIe = gen_ie + 2;
1266 RSNIeLen = gen_ie_len - 2;
1267 // Unpack the RSN IE
1268 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1269 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1270 pRsnIe,
1271 RSNIeLen,
1272 &dot11RSNIE);
1273 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001274 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001275 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001276 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001277 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 /*Here we have followed the apple base code,
1279 but probably I suspect we can do something different*/
1280 //dot11RSNIE.akm_suite_count
1281 // Just translate the FIRST one
1282 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1283 //dot11RSNIE.pwise_cipher_suite_count
1284 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1285 //dot11RSNIE.gp_cipher_suite_count
1286 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1287 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001288 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1289 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290
1291 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1292 } else
1293 if (gen_ie[0] == DOT11F_EID_WPA)
1294 {
1295 // Validity checks
1296 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1297 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1298 {
1299 return VOS_STATUS_E_FAILURE;
1300 }
1301 // Skip past the EID byte and length byte - and four byte WiFi OUI
1302 pRsnIe = gen_ie + 2 + 4;
1303 RSNIeLen = gen_ie_len - (2 + 4);
1304 // Unpack the WPA IE
1305 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1306 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1307 pRsnIe,
1308 RSNIeLen,
1309 &dot11WPAIE);
1310 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001311 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001312 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001313 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001314 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 //dot11WPAIE.auth_suite_count
1316 // Just translate the FIRST one
1317 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1318 //dot11WPAIE.unicast_cipher_count
1319 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1320 //dot11WPAIE.unicast_cipher_count
1321 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001322 *pMFPCapable = VOS_FALSE;
1323 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 }
1325 else
1326 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001327 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 return VOS_STATUS_E_FAILURE;
1329 }
1330 return VOS_STATUS_SUCCESS;
1331}
Leo Chang614d2072013-08-22 14:59:44 -07001332
Leo Chang0b0e45a2013-12-15 15:18:55 -08001333#ifdef FEATURE_WLAN_CH_AVOID
1334/**---------------------------------------------------------------------------
1335
1336 \brief hdd_hostapd_freq_to_chn() -
1337
1338 Input frequency translated into channel number
1339
1340 \param - freq input frequency with order of kHz
1341
1342 \return - corresponding channel number.
1343 incannot find correct channel number, return 0
1344
1345 --------------------------------------------------------------------------*/
1346v_U16_t hdd_hostapd_freq_to_chn
1347(
1348 v_U16_t freq
1349)
1350{
1351 int loop;
1352
1353 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1354 {
1355 if (rfChannels[loop].targetFreq == freq)
1356 {
1357 return rfChannels[loop].channelNum;
1358 }
1359 }
1360
1361 return (0);
1362}
1363
1364/*==========================================================================
1365 FUNCTION sapUpdateUnsafeChannelList
1366
1367 DESCRIPTION
1368 Function Undate unsafe channel list table
1369
1370 DEPENDENCIES
1371 NA.
1372
1373 PARAMETERS
1374
1375 IN
1376 pSapCtx : SAP context pointer, include unsafe channel list
1377
1378 RETURN VALUE
1379 NONE
1380============================================================================*/
1381void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1382 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1383{
1384 v_U16_t i, j;
1385
1386 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1387 sizeof(pHddCtx->unsafeChannelList));
1388 if (0 == unsafeChannelCount)
1389 {
1390 pHddCtx->unsafeChannelCount = 0;
1391 }
1392 else
1393 {
c_hpothu8de53e42014-08-22 15:00:37 +05301394 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1395 {
1396 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1397 FL("unsafeChannelCount%hd greater than %d"),
1398 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1399 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1400 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001401 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1402 unsafeChannelList,
1403 unsafeChannelCount * sizeof(tANI_U16));
1404 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1405 }
1406
1407 /* Flush, default set all channel safe */
1408 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1409 {
1410 safeChannels[i].isSafe = VOS_TRUE;
1411 }
1412
1413 /* Try to find unsafe channel */
1414 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1415 {
1416 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1417 {
1418 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1419 {
1420 /* Found unsafe channel, update it */
1421 safeChannels[j].isSafe = VOS_FALSE;
1422 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1423 "%s : CH %d is not safe",
1424 __func__, pHddCtx->unsafeChannelList[i]);
1425 break;
1426 }
1427 }
1428 }
1429
1430 return;
1431}
1432
1433/**---------------------------------------------------------------------------
1434
1435 \brief hdd_hostapd_ch_avoid_cb() -
1436
1437 Avoid channel notification from FW handler.
1438 FW will send un-safe channle list to avoid overwrapping.
1439 hostapd should not use notified channel
1440
1441 \param - pAdapter HDD adapter pointer
1442 indParam channel avoid notification parameter
1443
1444 \return - None
1445
1446 --------------------------------------------------------------------------*/
1447void hdd_hostapd_ch_avoid_cb
1448(
1449 void *pAdapter,
1450 void *indParam
1451)
1452{
1453 hdd_adapter_t *pHostapdAdapter = NULL;
1454 hdd_context_t *hddCtxt;
1455 tSirChAvoidIndType *chAvoidInd;
1456 v_U8_t rangeLoop;
1457 v_U16_t channelLoop;
1458 v_U16_t dupCheck;
1459 v_U16_t startChannel;
1460 v_U16_t endChannel;
1461 v_U16_t unsafeChannelCount = 0;
1462 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1463 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001464 tHddAvoidFreqList hddAvoidFreqList;
1465 tANI_U32 i;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001466
1467 /* Basic sanity */
1468 if ((NULL == pAdapter) || (NULL == indParam))
1469 {
1470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1471 "%s : Invalid arguments", __func__);
1472 return;
1473 }
1474
1475 hddCtxt = (hdd_context_t *)pAdapter;
1476 chAvoidInd = (tSirChAvoidIndType *)indParam;
1477 pVosContext = hddCtxt->pvosContext;
1478
1479 /* Make unsafe channel list */
1480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1481 "%s : band count %d",
1482 __func__, chAvoidInd->avoidRangeCount);
1483 vos_mem_zero((void *)unsafeChannelList,
1484 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1485 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1486 {
1487 startChannel = hdd_hostapd_freq_to_chn(
1488 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1489 endChannel = hdd_hostapd_freq_to_chn(
1490 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1492 "%s : start %d : %d, end %d : %d",
1493 __func__,
1494 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1495 startChannel,
1496 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1497 endChannel);
1498 for (channelLoop = startChannel;
1499 channelLoop < (endChannel + 1);
1500 channelLoop++)
1501 {
1502 /* Channel duplicate check routine */
1503 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1504 {
1505 if (unsafeChannelList[dupCheck] == channelLoop)
1506 {
1507 /* This channel is duplicated */
1508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1509 "%s : found duplicated channel %d",
1510 __func__, channelLoop);
1511 break;
1512 }
1513 }
1514 if (dupCheck == unsafeChannelCount)
1515 {
c_hpothu8de53e42014-08-22 15:00:37 +05301516 int ii;
1517 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1518 {
1519 if (channelLoop == safeChannels[ii].channelNumber)
1520 {
1521 unsafeChannelList[unsafeChannelCount] = channelLoop;
1522 unsafeChannelCount++;
1523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1524 "%s : unsafe channel %d, count %d",
1525 __func__,
1526 channelLoop, unsafeChannelCount);
1527 }
1528 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001529 }
1530 else
1531 {
1532 /* DUP, do nothing */
1533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1534 "%s : duplicated channel %d",
1535 __func__, channelLoop);
1536 }
1537 }
1538 }
1539 /* Update unsafe channel cache
1540 * WCN Platform Driver cache */
1541 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1542 unsafeChannelCount);
1543
1544 /* Store into local cache
1545 * Start with STA and later start SAP
1546 * in this scenario, local cache will be used */
1547 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1548 unsafeChannelList,
1549 unsafeChannelCount);
1550
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001551 /* generate vendor specific event */
1552 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1553 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1554 {
1555 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1556 chAvoidInd->avoidFreqRange[i].startFreq;
1557 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1558 chAvoidInd->avoidFreqRange[i].endFreq;
1559 }
1560 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1561
1562 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1563
Leo Chang0b0e45a2013-12-15 15:18:55 -08001564 /* Get SAP context first
1565 * SAP and P2PGO would not concurrent */
1566 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301567 if ((pHostapdAdapter) &&
1568 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1569 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001570 {
1571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1572 "%s : Current operation channel %d",
1573 __func__,
1574 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1575 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1576 {
1577 if (((unsafeChannelList[channelLoop] ==
1578 pHostapdAdapter->sessionCtx.ap.operatingChannel)) &&
1579 (AUTO_CHANNEL_SELECT ==
1580 pHostapdAdapter->sessionCtx.ap.sapConfig.channel))
1581 {
1582 /* current operating channel is un-safe channel
1583 * restart driver */
1584 hdd_hostapd_stop(pHostapdAdapter->dev);
Neelansh Mittaledafed22014-09-04 18:54:39 +05301585 /* On LE, this event is handled by wlan-services to restart SAP.
1586 On android, this event would be ignored. */
1587 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND, NULL, 0);
Leo Chang0b0e45a2013-12-15 15:18:55 -08001588 break;
1589 }
1590 }
1591 }
1592
1593 return;
1594}
1595
1596#endif /* FEATURE_WLAN_CH_AVOID */
1597
Jeff Johnson295189b2012-06-20 16:38:30 -07001598int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301599static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 struct iw_request_info *info,
1601 union iwreq_data *wrqu, char *extra)
1602{
1603 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001604 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 int *value = (int *)extra;
1606 int sub_cmd = value[0];
1607 int set_value = value[1];
1608 eHalStatus status;
1609 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001610 v_CONTEXT_t pVosContext;
1611
1612 if (!pHostapdAdapter || !pHostapdAdapter->pHddCtx)
1613 {
1614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1615 "%s: either hostapd Adapter is null or HDD ctx is null",
1616 __func__);
1617 return -1;
1618 }
1619
1620 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1621 if (!hHal)
1622 {
1623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1624 "%s: Hal ctx is null", __func__);
1625 return -1;
1626 }
1627
1628 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1629 if (!pVosContext)
1630 {
1631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1632 "%s: Vos ctx is null", __func__);
1633 return -1;
1634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001635
1636 switch(sub_cmd)
1637 {
1638
1639 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001640 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 {
1642 ret = -EIO;
1643 }
1644 break;
1645
1646 case QCSAP_PARAM_ACL_MODE:
1647 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
1648 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1649 {
1650 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1651 ret = -EINVAL;
1652 }
1653 else
1654 {
1655 WLANSAP_SetMode(pVosContext, set_value);
1656 }
1657 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301658
1659 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1660 if ((0 != set_value) && (1 != set_value))
1661 {
1662 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1663 ret = -EINVAL;
1664 }
1665 else
1666 {
1667 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1668 }
1669 break;
1670
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 case QCSAP_PARAM_MAX_ASSOC:
1672 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1673 {
1674 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1675 ret = -EINVAL;
1676 }
1677 else
1678 {
1679 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1680 {
1681 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1682 "Setting it to max allowed and continuing"),
1683 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1684 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1685 }
1686 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1687 set_value, NULL, eANI_BOOLEAN_FALSE);
1688 if ( status != eHAL_STATUS_SUCCESS )
1689 {
1690 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1691 status);
1692 ret = -EIO;
1693 }
1694 }
1695 break;
1696
1697 case QCSAP_PARAM_HIDE_SSID:
1698 {
1699 eHalStatus status = eHAL_STATUS_SUCCESS;
1700 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1701 if(eHAL_STATUS_SUCCESS != status)
1702 {
1703 hddLog(VOS_TRACE_LEVEL_ERROR,
1704 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001705 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 return status;
1707 }
1708 break;
1709 }
1710
Leo Chang614d2072013-08-22 14:59:44 -07001711 case QCSAP_PARAM_SET_MC_RATE:
1712 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001713 tSirRateUpdateInd *rateUpdate;
1714
1715 rateUpdate = (tSirRateUpdateInd *)
1716 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1717 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001718 {
1719 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001720 "%s: SET_MC_RATE indication alloc fail", __func__);
1721 ret = -1;
1722 break;
1723 }
1724 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1725
1726 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1727 /* Ignore unicast */
1728 rateUpdate->ucastDataRate = -1;
1729 rateUpdate->mcastDataRate24GHz = set_value;
1730 rateUpdate->mcastDataRate5GHz = set_value;
1731 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1732 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1733 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1734 if (eHAL_STATUS_SUCCESS != status)
1735 {
1736 hddLog(VOS_TRACE_LEVEL_ERROR,
1737 "%s: SET_MC_RATE failed", __func__);
1738 vos_mem_free(rateUpdate);
1739 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001740 }
1741 break;
1742 }
1743
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 default:
1745 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1746 sub_cmd, set_value);
1747 ret = -EINVAL;
1748 break;
1749 }
1750
1751 return ret;
1752}
1753
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301754int
1755static iw_softap_setparam(struct net_device *dev,
1756 struct iw_request_info *info,
1757 union iwreq_data *wrqu, char *extra)
1758{
1759 int ret;
1760
1761 vos_ssr_protect(__func__);
1762 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1763 vos_ssr_unprotect(__func__);
1764
1765 return ret;
1766}
Jeff Johnson295189b2012-06-20 16:38:30 -07001767
1768int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301769static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 struct iw_request_info *info,
1771 union iwreq_data *wrqu, char *extra)
1772{
1773 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1774 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Girish Gowli385be612014-09-18 11:17:20 +05301775 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 int *value = (int *)extra;
1777 int sub_cmd = value[0];
1778 eHalStatus status;
1779 int ret = 0; /* success */
1780 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1781
1782 switch (sub_cmd)
1783 {
1784 case QCSAP_PARAM_MAX_ASSOC:
1785 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
1786 if (eHAL_STATUS_SUCCESS != status)
1787 {
c_hpothuffdb5272013-10-02 16:42:35 +05301788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1789 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 ret = -EIO;
1791 }
Girish Gowli385be612014-09-18 11:17:20 +05301792
1793#ifdef WLAN_SOFTAP_VSTA_FEATURE
1794 if (pHddCtx->cfg_ini->fEnableVSTASupport)
1795 {
1796 if (*value > VSTA_NUM_ASSOC_STA)
1797 {
1798 *value = VSTA_NUM_ASSOC_STA;
1799 }
1800 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
1801 (*value > (VSTA_NUM_ASSOC_STA -
1802 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
1803 {
1804 *value = (VSTA_NUM_ASSOC_STA -
1805 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
1806 }
1807 }
1808 else
1809#endif
1810 {
1811 if (*value > NUM_ASSOC_STA)
1812 {
1813 *value = NUM_ASSOC_STA;
1814 }
1815 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
1816 (*value > (NUM_ASSOC_STA -
1817 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
1818 {
1819 *value = (NUM_ASSOC_STA -
1820 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
1821 }
1822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 break;
1824
1825 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001826 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 {
c_hpothuffdb5272013-10-02 16:42:35 +05301828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1829 FL("WLANSAP_ClearACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 ret = -EIO;
1831 }
1832 *value = 0;
1833 break;
1834
Jeff Johnson43971f52012-07-17 12:26:56 -07001835 case QCSAP_PARAM_GET_WLAN_DBG:
1836 {
1837 vos_trace_display();
1838 *value = 0;
1839 break;
1840 }
1841
1842 case QCSAP_PARAM_AUTO_CHANNEL:
1843 {
1844 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
1845 break;
1846 }
1847
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 default:
1849 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
1850 ret = -EINVAL;
1851 break;
1852
1853 }
1854
1855 return ret;
1856}
1857
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301858int
1859static iw_softap_getparam(struct net_device *dev,
1860 struct iw_request_info *info,
1861 union iwreq_data *wrqu, char *extra)
1862{
1863 int ret;
1864
1865 vos_ssr_protect(__func__);
1866 ret = __iw_softap_getparam(dev, info, wrqu, extra);
1867 vos_ssr_unprotect(__func__);
1868
1869 return ret;
1870}
Jeff Johnson295189b2012-06-20 16:38:30 -07001871/* Usage:
1872 BLACK_LIST = 0
1873 WHITE_LIST = 1
1874 ADD MAC = 0
1875 REMOVE MAC = 1
1876
1877 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
1878 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
1879 while using this ioctl
1880
1881 Syntax:
1882 iwpriv softap.0 modify_acl
1883 <6 octet mac addr> <list type> <cmd type>
1884
1885 Examples:
1886 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
1887 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
1888 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
1889 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
1890*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301891int __iw_softap_modify_acl(struct net_device *dev,
1892 struct iw_request_info *info,
1893 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001894{
1895 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1896 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1897 v_BYTE_t *value = (v_BYTE_t*)extra;
1898 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
1899 int listType, cmd, i;
1900 int ret = 0; /* success */
1901
1902 ENTER();
1903 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
1904 {
1905 pPeerStaMac[i] = *(value+i);
1906 }
1907 listType = (int)(*(value+i));
1908 i++;
1909 cmd = (int)(*(value+i));
1910
Arif Hussain24bafea2013-11-15 15:10:03 -08001911 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
1912 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07001913
1914 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
1915 != VOS_STATUS_SUCCESS)
1916 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001917 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 ret = -EIO;
1919 }
1920 EXIT();
1921 return ret;
1922}
1923
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301924int iw_softap_modify_acl(struct net_device *dev,
1925 struct iw_request_info *info,
1926 union iwreq_data *wrqu, char *extra)
1927{
1928 int ret;
1929
1930 vos_ssr_protect(__func__);
1931 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
1932 vos_ssr_unprotect(__func__);
1933
1934 return ret;
1935}
1936
Jeff Johnson295189b2012-06-20 16:38:30 -07001937int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301938static __iw_softap_getchannel(struct net_device *dev,
1939 struct iw_request_info *info,
1940 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001941{
1942 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1943
Jeff Johnson43971f52012-07-17 12:26:56 -07001944 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07001945
Jeff Johnson43971f52012-07-17 12:26:56 -07001946 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 return 0;
1948}
1949
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301950
Jeff Johnsone7245742012-09-05 17:12:55 -07001951int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301952static iw_softap_getchannel(struct net_device *dev,
1953 struct iw_request_info *info,
1954 union iwreq_data *wrqu, char *extra)
1955{
1956 int ret;
1957
1958 vos_ssr_protect(__func__);
1959 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
1960 vos_ssr_unprotect(__func__);
1961
1962 return ret;
1963}
1964
1965int
1966static __iw_softap_set_max_tx_power(struct net_device *dev,
1967 struct iw_request_info *info,
1968 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07001969{
1970 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1971 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
schang86c22c42013-03-13 18:41:24 -07001972 int *value = (int *)extra;
Jeff Johnsone7245742012-09-05 17:12:55 -07001973 int set_value;
1974 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
1975 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
1976
schang86c22c42013-03-13 18:41:24 -07001977 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07001978 return -ENOMEM;
1979
Leo Changd37675a2013-08-01 13:19:45 -07001980 /* Assign correct slef MAC address */
1981 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
1982 VOS_MAC_ADDR_SIZE);
1983 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
1984 VOS_MAC_ADDR_SIZE);
1985
schang86c22c42013-03-13 18:41:24 -07001986 set_value = value[0];
1987 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
1988 {
1989 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001990 __func__);
schang86c22c42013-03-13 18:41:24 -07001991 return -EIO;
1992 }
1993
1994 return 0;
1995}
1996
1997int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301998static iw_softap_set_max_tx_power(struct net_device *dev,
1999 struct iw_request_info *info,
2000 union iwreq_data *wrqu, char *extra)
2001{
2002 int ret;
2003
2004 vos_ssr_protect(__func__);
2005 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2006 vos_ssr_unprotect(__func__);
2007
2008 return ret;
2009}
2010
2011
2012int
2013static __iw_display_data_path_snapshot(struct net_device *dev,
2014 struct iw_request_info *info,
2015 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302016{
2017
2018 /* Function intitiating dumping states of
2019 * HDD(WMM Tx Queues)
2020 * TL State (with Per Client infor)
2021 * DXE Snapshot (Called at the end of TL Snapshot)
2022 */
2023 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2024 hddLog(LOGE, "%s: called for SAP",__func__);
2025 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302026 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302027 return 0;
2028}
2029
2030int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302031static iw_display_data_path_snapshot(struct net_device *dev,
2032 struct iw_request_info *info,
2033 union iwreq_data *wrqu, char *extra)
2034{
2035 int ret;
2036
2037 vos_ssr_protect(__func__);
2038 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2039 vos_ssr_unprotect(__func__);
2040
2041 return ret;
2042}
2043
2044int
2045static __iw_softap_set_tx_power(struct net_device *dev,
2046 struct iw_request_info *info,
2047 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002048{
2049 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2050 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2051 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2052 int *value = (int *)extra;
2053 int set_value;
2054 ptSapContext pSapCtx = NULL;
2055
2056 if (NULL == value)
2057 return -ENOMEM;
2058
2059 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2060 if (NULL == pSapCtx)
2061 {
2062 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2063 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2064 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002065 }
2066
2067 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002068 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002069 {
schang86c22c42013-03-13 18:41:24 -07002070 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002071 __func__);
2072 return -EIO;
2073 }
2074
2075 return 0;
2076}
2077
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302078int
2079static iw_softap_set_tx_power(struct net_device *dev,
2080 struct iw_request_info *info,
2081 union iwreq_data *wrqu, char *extra)
2082{
2083 int ret;
2084
2085 vos_ssr_protect(__func__);
2086 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2087 vos_ssr_unprotect(__func__);
2088
2089 return ret;
2090}
2091
Kiet Lambcf38522013-10-26 18:28:27 +05302092/**---------------------------------------------------------------------------
2093
2094 \brief iw_softap_set_trafficmonitor() -
2095 This function dynamically enable/disable traffic monitor functonality
2096 the command iwpriv wlanX setTrafficMon <value>.
2097
2098 \param - dev - Pointer to the net device.
2099 - addr - Pointer to the sockaddr.
2100 \return - 0 for success, non zero for failure
2101
2102 --------------------------------------------------------------------------*/
2103
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302104static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2105 struct iw_request_info *info,
2106 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302107{
2108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302109 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302110 hdd_context_t *pHddCtx;
2111 int status;
2112
2113 if (NULL == pAdapter)
2114 {
2115 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2116 "%s: HDD adapter is Null", __func__);
2117 return -ENODEV;
2118 }
2119
2120 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2121
2122 status = wlan_hdd_validate_context(pHddCtx);
2123
2124 if (0 != status)
2125 {
2126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2127 "%s: HDD context is not valid", __func__);
2128 return status;
2129 }
2130
2131 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2132
2133 if (NULL == isSetTrafficMon)
2134 {
2135 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2136 "%s: Invalid SAP pointer from extra", __func__);
2137 return -ENOMEM;
2138 }
2139
2140 if (TRUE == *isSetTrafficMon)
2141 {
2142 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2143 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2144 {
2145 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2146 "%s: failed to Start Traffic Monitor timer ", __func__ );
2147 return -EIO;
2148 }
2149 }
2150 else if (FALSE == *isSetTrafficMon)
2151 {
2152 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2153 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2154 {
2155 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2156 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2157 return -EIO;
2158 }
2159
2160 }
2161 return 0;
2162}
2163
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302164static int iw_softap_set_trafficmonitor(struct net_device *dev,
2165 struct iw_request_info *info,
2166 union iwreq_data *wrqu, char *extra)
2167{
2168 int ret;
2169
2170 vos_ssr_protect(__func__);
2171 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2172 vos_ssr_unprotect(__func__);
2173
2174 return ret;
2175}
2176
Jeff Johnson295189b2012-06-20 16:38:30 -07002177#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2178
2179int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302180static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2181 struct iw_request_info *info,
2182 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002183{
2184 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302185 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002186 char *buf;
2187 int cnt = 0;
2188 int left;
2189 int ret = 0;
2190 /* maclist_index must be u32 to match userspace */
2191 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302192 v_CONTEXT_t pVosContext = NULL;
2193 ptSapContext pSapCtx = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002194 /*
2195 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2196 * number, and even numbered iocts are supposed to have "set"
2197 * semantics. Hence the wireless extensions support in the kernel
2198 * won't correctly copy the result to userspace, so the ioctl
2199 * handler itself must copy the data. Output format is 32-bit
2200 * record length, followed by 0 or more 6-byte STA MAC addresses.
2201 *
2202 * Further note that due to the incorrect semantics, the "iwpriv"
2203 * userspace application is unable to correctly invoke this API,
2204 * hence it is not registered in the hostapd_private_args. This
2205 * API can only be invoked by directly invoking the ioctl() system
2206 * call.
2207 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002208
Jeff Johnson224f3702014-03-26 11:09:47 -07002209 /* make sure userspace allocated a reasonable buffer size */
2210 if (wrqu->data.length < sizeof(maclist_index)) {
2211 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2212 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002214
Jeff Johnson224f3702014-03-26 11:09:47 -07002215 /* allocate local buffer to build the response */
2216 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2217 if (!buf) {
2218 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2219 return -ENOMEM;
2220 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302221 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2222 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2223 if(pSapCtx == NULL){
2224 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2225 FL("psapCtx is NULL"));
2226 return -EFAULT;
2227 }
2228 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002229 /* start indexing beyond where the record count will be written */
2230 maclist_index = sizeof(maclist_index);
2231 left = wrqu->data.length - maclist_index;
2232
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302233 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002234 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2235 if ((pStaInfo[cnt].isUsed) &&
2236 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2237 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2238 VOS_MAC_ADDR_SIZE);
2239 maclist_index += VOS_MAC_ADDR_SIZE;
2240 left -= VOS_MAC_ADDR_SIZE;
2241 }
2242 cnt++;
2243 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302244 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002245
2246 *((u32 *)buf) = maclist_index;
2247 wrqu->data.length = maclist_index;
2248 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2249 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2250 ret = -EFAULT;
2251 }
2252 kfree(buf);
2253 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002254}
2255
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302256int
2257static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2258 struct iw_request_info *info,
2259 union iwreq_data *wrqu, char *extra)
2260{
2261 int ret;
2262
2263 vos_ssr_protect(__func__);
2264 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2265 vos_ssr_unprotect(__func__);
2266
2267 return ret;
2268}
2269
Jeff Johnson295189b2012-06-20 16:38:30 -07002270/* Usage:
2271 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2272 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2273 while using this ioctl
2274
2275 Syntax:
2276 iwpriv softap.0 disassoc_sta <6 octet mac address>
2277
2278 e.g.
2279 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2280 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2281*/
2282
2283int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302284static __iw_softap_disassoc_sta(struct net_device *dev,
2285 struct iw_request_info *info,
2286 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002287{
2288 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2289 v_U8_t *peerMacAddr;
2290
2291 ENTER();
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302292 /* iwpriv tool or framework calls this ioctl with
2293 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302295 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002296
Arif Hussain24bafea2013-11-15 15:10:03 -08002297 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2298 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2300 EXIT();
2301 return 0;
2302}
2303
2304int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302305static iw_softap_disassoc_sta(struct net_device *dev,
2306 struct iw_request_info *info,
2307 union iwreq_data *wrqu, char *extra)
2308{
2309 int ret;
2310
2311 vos_ssr_protect(__func__);
2312 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2313 vos_ssr_unprotect(__func__);
2314
2315 return ret;
2316}
2317
2318int
2319static __iw_softap_ap_stats(struct net_device *dev,
2320 struct iw_request_info *info,
2321 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002322{
2323 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2324 WLANTL_TRANSFER_STA_TYPE statBuffer;
2325 char *pstatbuf;
Girish Gowlif3769802014-06-16 21:17:16 +05302326 int len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002327
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002328 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002329 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2330 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302332 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002333 if(NULL == pstatbuf) {
2334 hddLog(LOG1, "unable to allocate memory");
2335 return -ENOMEM;
2336 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302337
2338 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002339 "RUF=%d RMF=%d RBF=%d "
2340 "RUB=%d RMB=%d RBB=%d "
2341 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302342 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002343 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2344 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2345 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2346 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2347 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2348 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002349
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302350 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002351 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2352 kfree(pstatbuf);
2353 return -EFAULT;
2354 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302355
2356 strlcpy(extra, pstatbuf, len);
2357 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002358 kfree(pstatbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 return 0;
2360}
2361
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302362int
2363static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 struct iw_request_info *info,
2365 union iwreq_data *wrqu, char *extra)
2366{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302367 int ret;
2368
2369 vos_ssr_protect(__func__);
2370 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2371 vos_ssr_unprotect(__func__);
2372
2373 return ret;
2374}
2375
2376static int __iw_softap_set_channel_range(struct net_device *dev,
2377 struct iw_request_info *info,
2378 union iwreq_data *wrqu, char *extra)
2379{
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2381 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002382 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
2384 int *value = (int *)extra;
2385 int startChannel = value[0];
2386 int endChannel = value[1];
2387 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002388 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 int ret = 0; /* success */
2390
2391 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2392 if(status != VOS_STATUS_SUCCESS)
2393 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002394 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 startChannel,endChannel, band);
2396 ret = -EINVAL;
2397 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002398
2399 pHddCtx->is_dynamic_channel_range_set = 1;
2400
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 return ret;
2402}
2403
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302404static int iw_softap_set_channel_range(struct net_device *dev,
2405 struct iw_request_info *info,
2406 union iwreq_data *wrqu, char *extra)
2407{
2408 int ret;
2409
2410 vos_ssr_protect(__func__);
2411 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
2412 vos_ssr_unprotect(__func__);
2413
2414 return ret;
2415}
2416
2417
2418int __iw_softap_get_channel_list(struct net_device *dev,
2419 struct iw_request_info *info,
2420 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002421{
2422 v_U32_t num_channels = 0;
2423 v_U8_t i = 0;
2424 v_U8_t bandStartChannel = RF_CHAN_1;
2425 v_U8_t bandEndChannel = RF_CHAN_165;
2426 v_U32_t temp_num_channels = 0;
2427 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2428 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2429 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002431 eCsrBand curBand = eCSR_BAND_ALL;
Agarwal Ashish7b557c02014-07-02 12:32:39 +05302432 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002433
2434 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
2435 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002436 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002437 return -EIO;
2438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 wrqu->data.length = sizeof(tChannelListInfo);
2440 ENTER();
2441
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002442 if (eCSR_BAND_24 == curBand)
2443 {
2444 bandStartChannel = RF_CHAN_1;
2445 bandEndChannel = RF_CHAN_14;
2446 }
2447 else if (eCSR_BAND_5G == curBand)
2448 {
2449 bandStartChannel = RF_CHAN_36;
2450 bandEndChannel = RF_CHAN_165;
2451 }
2452
Arif Hussain6d2a3322013-11-17 19:50:10 -08002453 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05302454 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07002455 bandStartChannel, bandEndChannel );
2456
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 for( i = bandStartChannel; i <= bandEndChannel; i++ )
2458 {
2459 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
2460 {
2461 channel_list->channels[num_channels] = rfChannels[i].channelNum;
2462 num_channels++;
2463 }
2464 }
2465
2466 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
2467
2468 temp_num_channels = num_channels;
2469
2470 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
2471 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05302472 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08002473 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 }
2475
Agarwal Ashish7b557c02014-07-02 12:32:39 +05302476 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
2477 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 {
2479 for(i = 0; i < temp_num_channels; i++)
2480 {
2481
2482 if((channel_list->channels[i] > 35) &&
2483 (channel_list->channels[i] < 49))
2484 {
2485 vos_mem_move(&channel_list->channels[i],
2486 &channel_list->channels[i+1],
2487 temp_num_channels - (i-1));
2488 num_channels--;
2489 temp_num_channels--;
2490 i--;
2491 }
2492 }
2493 }
2494
Arif Hussain6d2a3322013-11-17 19:50:10 -08002495 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002496
2497 if (num_channels > IW_MAX_FREQUENCIES)
2498 {
2499 num_channels = IW_MAX_FREQUENCIES;
2500 }
2501
2502 channel_list->num_channels = num_channels;
2503 EXIT();
2504
2505 return 0;
2506}
2507
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302508int iw_softap_get_channel_list(struct net_device *dev,
2509 struct iw_request_info *info,
2510 union iwreq_data *wrqu, char *extra)
2511{
2512 int ret;
2513
2514 vos_ssr_protect(__func__);
2515 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
2516 vos_ssr_unprotect(__func__);
2517
2518 return ret;
2519}
2520
2521static
2522int __iw_get_genie(struct net_device *dev,
2523 struct iw_request_info *info,
2524 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002525{
2526 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2527 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2528 eHalStatus status;
2529 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2530 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2531 ENTER();
Arif Hussain6d2a3322013-11-17 19:50:10 -08002532 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2534 status = WLANSap_getstationIE_information(pVosContext,
2535 &length,
2536 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07002537 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2538 if (wrqu->data.length < length ||
2539 copy_to_user(wrqu->data.pointer,
2540 (v_VOID_t*)genIeBytes, length))
2541 {
2542 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2543 return -EFAULT;
2544 }
2545 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002546
Arif Hussain6d2a3322013-11-17 19:50:10 -08002547 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002548
2549
2550 EXIT();
2551 return 0;
2552}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302553
2554static
2555int iw_get_genie(struct net_device *dev,
2556 struct iw_request_info *info,
2557 union iwreq_data *wrqu, char *extra)
2558{
2559 int ret;
2560
2561 vos_ssr_protect(__func__);
2562 ret = __iw_get_genie(dev, info, wrqu, extra);
2563 vos_ssr_unprotect(__func__);
2564
2565 return ret;
2566}
2567
2568static
2569int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
2570 struct iw_request_info *info,
2571 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002572{
2573 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07002574 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
2576 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07002577
Arif Hussain6d2a3322013-11-17 19:50:10 -08002578 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07002579 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
2580
2581 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
2582 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
2583 pHddApCtx->WPSPBCProbeReq.probeReqIE,
2584 WPSPBCProbeReqIEs.probeReqIELen);
2585 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
2586 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
2587 sizeof(v_MACADDR_t));
2588 if (copy_to_user(wrqu->data.pointer,
2589 (void *)&WPSPBCProbeReqIEs,
2590 sizeof(WPSPBCProbeReqIEs)))
2591 {
2592 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2593 return -EFAULT;
2594 }
2595 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002596 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07002597 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 up(&pHddApCtx->semWpsPBCOverlapInd);
2599 EXIT();
2600 return 0;
2601}
2602
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302603static
2604int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
2605 struct iw_request_info *info,
2606 union iwreq_data *wrqu, char *extra)
2607{
2608 int ret;
2609
2610 vos_ssr_protect(__func__);
2611 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
2612 vos_ssr_unprotect(__func__);
2613
2614 return ret;
2615}
2616
Jeff Johnson295189b2012-06-20 16:38:30 -07002617/**---------------------------------------------------------------------------
2618
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302619 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 This function sets the auth type received from the wpa_supplicant.
2621
2622 \param - dev - Pointer to the net device.
2623 - info - Pointer to the iw_request_info.
2624 - wrqu - Pointer to the iwreq_data.
2625 - extra - Pointer to the data.
2626 \return - 0 for success, non zero for failure
2627
2628 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302629int __iw_set_auth_hostap(struct net_device *dev,
2630 struct iw_request_info *info,
2631 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002632{
2633 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2634 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2635
2636 ENTER();
2637 switch(wrqu->param.flags & IW_AUTH_INDEX)
2638 {
2639 case IW_AUTH_TKIP_COUNTERMEASURES:
2640 {
2641 if(wrqu->param.value) {
2642 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2643 "Counter Measure started %d", wrqu->param.value);
2644 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
2645 }
2646 else {
2647 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2648 "Counter Measure stopped=%d", wrqu->param.value);
2649 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
2650 }
2651
2652 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
2653 wrqu->param.value);
2654 }
2655 break;
2656
2657 default:
2658
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002659 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 wrqu->param.flags & IW_AUTH_INDEX);
2661 break;
2662 }
2663
2664 EXIT();
2665 return 0;
2666}
2667
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302668int iw_set_auth_hostap(struct net_device *dev,
2669 struct iw_request_info *info,
2670 union iwreq_data *wrqu,char *extra)
2671{
2672 int ret;
2673
2674 vos_ssr_protect(__func__);
2675 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
2676 vos_ssr_unprotect(__func__);
2677
2678 return ret;
2679}
2680
2681static int __iw_set_ap_encodeext(struct net_device *dev,
2682 struct iw_request_info *info,
2683 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002684{
2685 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2686 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2687 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson43971f52012-07-17 12:26:56 -07002688 int retval = 0;
2689 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
2691 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2692 int key_index;
2693 struct iw_point *encoding = &wrqu->encoding;
2694 tCsrRoamSetKey setKey;
2695// tCsrRoamRemoveKey RemoveKey;
2696 int i;
Jeff Johnson43971f52012-07-17 12:26:56 -07002697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 ENTER();
2699
2700 key_index = encoding->flags & IW_ENCODE_INDEX;
2701
2702 if(key_index > 0) {
2703
2704 /*Convert from 1-based to 0-based keying*/
2705 key_index--;
2706 }
2707 if(!ext->key_len) {
2708#if 0
2709 /*Set the encrytion type to NONE*/
2710#if 0
2711 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2712#endif
2713
2714 RemoveKey.keyId = key_index;
2715 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2716 /*Key direction for group is RX only*/
2717 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2718 }
2719 else {
2720 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2721 }
2722 switch(ext->alg)
2723 {
2724 case IW_ENCODE_ALG_NONE:
2725 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2726 break;
2727 case IW_ENCODE_ALG_WEP:
2728 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2729 break;
2730 case IW_ENCODE_ALG_TKIP:
2731 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07002732 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 case IW_ENCODE_ALG_CCMP:
2734 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
2735 break;
2736 default:
2737 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2738 break;
2739 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08002740 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 -07002741 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002743 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 );
Jeff Johnson43971f52012-07-17 12:26:56 -07002745 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
2746 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 {
2748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07002749 __LINE__, vstatus );
2750 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002752#endif
2753 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002754
Jeff Johnson43971f52012-07-17 12:26:56 -07002755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002756
2757 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2758
2759 setKey.keyId = key_index;
2760 setKey.keyLength = ext->key_len;
2761
2762 if(ext->key_len <= CSR_MAX_KEY_LEN) {
2763 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
2764 }
2765
2766 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2767 /*Key direction for group is RX only*/
2768 setKey.keyDirection = eSIR_RX_ONLY;
2769 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2770 }
2771 else {
2772
2773 setKey.keyDirection = eSIR_TX_RX;
2774 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2775 }
2776 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2777 {
2778 setKey.keyDirection = eSIR_TX_DEFAULT;
2779 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2780 }
2781
2782 /*For supplicant pae role is zero*/
2783 setKey.paeRole = 0;
2784
2785 switch(ext->alg)
2786 {
2787 case IW_ENCODE_ALG_NONE:
2788 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2789 break;
2790
2791 case IW_ENCODE_ALG_WEP:
2792 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2793 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002794 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 break;
2796
2797 case IW_ENCODE_ALG_TKIP:
2798 {
2799 v_U8_t *pKey = &setKey.Key[0];
2800
2801 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
2802
2803 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
2804
2805 /*Supplicant sends the 32bytes key in this order
2806
2807 |--------------|----------|----------|
2808 | Tk1 |TX-MIC | RX Mic |
2809 |--------------|----------|----------|
2810 <---16bytes---><--8bytes--><--8bytes-->
2811
2812 */
2813 /*Sme expects the 32 bytes key to be in the below order
2814
2815 |--------------|----------|----------|
2816 | Tk1 |RX-MIC | TX Mic |
2817 |--------------|----------|----------|
2818 <---16bytes---><--8bytes--><--8bytes-->
2819 */
2820 /* Copy the Temporal Key 1 (TK1) */
2821 vos_mem_copy(pKey,ext->key,16);
2822
2823 /*Copy the rx mic first*/
2824 vos_mem_copy(&pKey[16],&ext->key[24],8);
2825
2826 /*Copy the tx mic */
2827 vos_mem_copy(&pKey[24],&ext->key[16],8);
2828
2829 }
2830 break;
2831
2832 case IW_ENCODE_ALG_CCMP:
2833 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
2834 break;
2835
2836 default:
2837 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2838 break;
2839 }
2840
2841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302842 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 setKey.keyId);
2844 for(i=0; i< ext->key_len; i++)
2845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2846 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07002847
2848 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
2849 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 {
2851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07002852 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
2853 retval = -EINVAL;
2854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002855
Jeff Johnson43971f52012-07-17 12:26:56 -07002856 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002857}
Jeff Johnson43971f52012-07-17 12:26:56 -07002858
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302859static int iw_set_ap_encodeext(struct net_device *dev,
2860 struct iw_request_info *info,
2861 union iwreq_data *wrqu, char *extra)
2862{
2863 int ret;
2864
2865 vos_ssr_protect(__func__);
2866 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
2867 vos_ssr_unprotect(__func__);
2868
2869 return ret;
2870}
Jeff Johnson43971f52012-07-17 12:26:56 -07002871
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302872static int __iw_set_ap_mlme(struct net_device *dev,
2873 struct iw_request_info *info,
2874 union iwreq_data *wrqu,
2875 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002876{
2877#if 0
2878 hdd_adapter_t *pAdapter = (netdev_priv(dev));
2879 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2880
2881 ENTER();
2882
2883 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
2884 switch (mlme->cmd) {
2885 case IW_MLME_DISASSOC:
2886 case IW_MLME_DEAUTH:
2887 hddLog(LOG1, "Station disassociate");
2888 if( pAdapter->conn_info.connState == eConnectionState_Associated )
2889 {
2890 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
2891
2892 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
2893 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
2894
2895 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
2896
2897 //clear all the reason codes
2898 if (status != 0)
2899 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002900 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 }
2902
2903 netif_stop_queue(dev);
2904 netif_carrier_off(dev);
2905 }
2906 else
2907 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002908 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 -07002909 }
2910 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08002911 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 return -EINVAL;
2913 }//end of switch
2914 EXIT();
2915#endif
2916 return 0;
2917// return status;
2918}
2919
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302920static int iw_set_ap_mlme(struct net_device *dev,
2921 struct iw_request_info *info,
2922 union iwreq_data *wrqu,
2923 char *extra)
2924{
2925 int ret;
2926
2927 vos_ssr_protect(__func__);
2928 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
2929 vos_ssr_unprotect(__func__);
2930
2931 return ret;
2932}
2933
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302934static int __iw_get_ap_rts_threshold(struct net_device *dev,
2935 struct iw_request_info *info,
2936 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002937{
2938 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2939 v_U32_t status = 0;
2940
2941 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
2942
2943 return status;
2944}
2945
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302946static int iw_get_ap_rts_threshold(struct net_device *dev,
2947 struct iw_request_info *info,
2948 union iwreq_data *wrqu, char *extra)
2949{
2950 int ret;
2951
2952 vos_ssr_protect(__func__);
2953 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
2954 vos_ssr_unprotect(__func__);
2955
2956 return ret;
2957}
2958
2959static int __iw_get_ap_frag_threshold(struct net_device *dev,
2960 struct iw_request_info *info,
2961 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002962{
2963 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2964 v_U32_t status = 0;
2965
2966 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
2967
2968 return status;
2969}
2970
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05302971static int iw_get_ap_frag_threshold(struct net_device *dev,
2972 struct iw_request_info *info,
2973 union iwreq_data *wrqu, char *extra)
2974{
2975 int ret;
2976
2977 vos_ssr_protect(__func__);
2978 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
2979 vos_ssr_unprotect(__func__);
2980
2981 return ret;
2982}
2983
2984static int __iw_get_ap_freq(struct net_device *dev,
2985 struct iw_request_info *info,
2986 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002987{
Jeff Johnsone7245742012-09-05 17:12:55 -07002988 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2990 tHalHandle hHal;
2991 hdd_hostapd_state_t *pHostapdState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002992 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002993
2994 ENTER();
2995
2996 if ((WLAN_HDD_GET_CTX(pHostapdAdapter))->isLogpInProgress) {
2997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2998 "%s:LOGP in Progress. Ignore!!!",__func__);
2999 return status;
3000 }
3001
3002 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3003 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3004
3005 if(pHostapdState->bssState == BSS_STOP )
3006 {
3007 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3008 != eHAL_STATUS_SUCCESS)
3009 {
c_hpothuffdb5272013-10-02 16:42:35 +05303010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3011 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 return -EIO;
3013 }
3014 else
3015 {
3016 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003017 if( TRUE == status)
3018 {
3019 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3020 * iwlist & iwconfig command shows frequency into proper
3021 * format (2.412 GHz instead of 246.2 MHz)*/
3022 fwrq->m = freq;
3023 fwrq->e = MHZ;
3024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 }
3026 }
3027 else
3028 {
3029 channel = pHddApCtx->operatingChannel;
3030 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003031 if( TRUE == status)
3032 {
3033 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3034 * iwlist & iwconfig command shows frequency into proper
3035 * format (2.412 GHz instead of 246.2 MHz)*/
3036 fwrq->m = freq;
3037 fwrq->e = MHZ;
3038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003040 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003041}
3042
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303043static int iw_get_ap_freq(struct net_device *dev,
3044 struct iw_request_info *info,
3045 struct iw_freq *fwrq, char *extra)
3046{
3047 int ret;
3048
3049 vos_ssr_protect(__func__);
3050 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3051 vos_ssr_unprotect(__func__);
3052
3053 return ret;
3054}
3055
3056static int __iw_get_mode(struct net_device *dev,
3057 struct iw_request_info *info,
3058 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303059{
3060 int status = 0;
3061
3062 wrqu->mode = IW_MODE_MASTER;
3063
3064 return status;
3065}
3066
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303067static int iw_get_mode(struct net_device *dev,
3068 struct iw_request_info *info,
3069 union iwreq_data *wrqu, char *extra)
3070{
3071 int ret;
3072
3073 vos_ssr_protect(__func__);
3074 ret = __iw_get_mode(dev, info, wrqu, extra);
3075 vos_ssr_unprotect(__func__);
3076
3077 return ret;
3078}
3079
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303080static int __iw_softap_setwpsie(struct net_device *dev,
3081 struct iw_request_info *info,
3082 union iwreq_data *wrqu,
3083 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003084{
3085 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3086 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3087 hdd_hostapd_state_t *pHostapdState;
3088 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003089 u_int8_t *wps_genie;
3090 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 u_int8_t *pos;
3092 tpSap_WPSIE pSap_WPSIe;
3093 u_int8_t WPSIeType;
3094 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303095 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 ENTER();
3097
Girish Gowli07c05ec2014-06-17 20:47:03 +05303098 /* helper function to get iwreq_data with compat handling. */
3099 if (hdd_priv_get_data(&s_priv_data, wrqu))
3100 {
3101 return -EINVAL;
3102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003103
Girish Gowli07c05ec2014-06-17 20:47:03 +05303104 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3105 {
3106 return -EINVAL;
3107 }
3108
3109 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3110 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003111
Girish Gowli86c471e2014-06-17 19:28:05 +05303112 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003113 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303114 hddLog(LOG1, "%s: failed to alloc memory "
3115 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003116 return -EFAULT;
3117 }
3118
Girish Gowli86c471e2014-06-17 19:28:05 +05303119 fwps_genie = wps_genie;
3120
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3122 if (NULL == pSap_WPSIe)
3123 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003124 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003125 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 return -ENOMEM;
3127 }
3128 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3129
Arif Hussain6d2a3322013-11-17 19:50:10 -08003130 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 -07003131 WPSIeType = wps_genie[0];
3132 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3133 {
3134 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3135 wps_genie = wps_genie + 1;
3136 switch ( wps_genie[0] )
3137 {
3138 case DOT11F_EID_WPA:
3139 if (wps_genie[1] < 2 + 4)
3140 {
3141 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003142 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 return -EINVAL;
3144 }
3145 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3146 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003147 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 pos = &wps_genie[6];
3149 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3150 {
3151 switch((u_int16_t)(*pos<<8) | *(pos+1))
3152 {
3153 case HDD_WPS_ELEM_VERSION:
3154 pos += 4;
3155 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003156 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3158 pos += 1;
3159 break;
3160
3161 case HDD_WPS_ELEM_WPS_STATE:
3162 pos +=4;
3163 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003164 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3166 pos += 1;
3167 break;
3168 case HDD_WPS_ELEM_APSETUPLOCK:
3169 pos += 4;
3170 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003171 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3173 pos += 1;
3174 break;
3175 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3176 pos += 4;
3177 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003178 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3180 pos += 1;
3181 break;
3182 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3183 pos += 4;
3184 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003185 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3187 pos += 2;
3188 break;
3189 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3190 pos += 4;
3191 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003192 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3194 pos += 2;
3195 break;
3196
3197 case HDD_WPS_ELEM_UUID_E:
3198 pos += 2;
3199 length = *pos<<8 | *(pos+1);
3200 pos += 2;
3201 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3202 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3203 pos += length;
3204 break;
3205 case HDD_WPS_ELEM_RF_BANDS:
3206 pos += 4;
3207 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003208 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3210 pos += 1;
3211 break;
3212
3213 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003214 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003216 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 return -EINVAL;
3218 }
3219 }
3220 }
3221 else {
3222 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003223 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 }
3225 break;
3226
3227 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003228 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003230 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 return 0;
3232 }
3233 }
3234 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
3235 {
3236 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
3237 wps_genie = wps_genie + 1;
3238 switch ( wps_genie[0] )
3239 {
3240 case DOT11F_EID_WPA:
3241 if (wps_genie[1] < 2 + 4)
3242 {
3243 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003244 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 return -EINVAL;
3246 }
3247 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3248 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003249 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 pos = &wps_genie[6];
3251 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3252 {
3253 switch((u_int16_t)(*pos<<8) | *(pos+1))
3254 {
3255 case HDD_WPS_ELEM_VERSION:
3256 pos += 4;
3257 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003258 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
3260 pos += 1;
3261 break;
3262
3263 case HDD_WPS_ELEM_WPS_STATE:
3264 pos +=4;
3265 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003266 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
3268 pos += 1;
3269 break;
3270 case HDD_WPS_ELEM_APSETUPLOCK:
3271 pos += 4;
3272 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003273 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
3275 pos += 1;
3276 break;
3277 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3278 pos += 4;
3279 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003280 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
3282 pos += 1;
3283 break;
3284 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3285 pos += 4;
3286 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003287 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
3289 pos += 2;
3290 break;
3291 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3292 pos += 4;
3293 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003294 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
3296 pos += 2;
3297 break;
3298 case HDD_WPS_ELEM_RSP_TYPE:
3299 pos += 4;
3300 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003301 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
3303 pos += 1;
3304 break;
3305 case HDD_WPS_ELEM_UUID_E:
3306 pos += 2;
3307 length = *pos<<8 | *(pos+1);
3308 pos += 2;
3309 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
3310 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
3311 pos += length;
3312 break;
3313
3314 case HDD_WPS_ELEM_MANUFACTURER:
3315 pos += 2;
3316 length = *pos<<8 | *(pos+1);
3317 pos += 2;
3318 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
3319 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
3320 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
3321 pos += length;
3322 break;
3323
3324 case HDD_WPS_ELEM_MODEL_NAME:
3325 pos += 2;
3326 length = *pos<<8 | *(pos+1);
3327 pos += 2;
3328 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
3329 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
3330 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
3331 pos += length;
3332 break;
3333 case HDD_WPS_ELEM_MODEL_NUM:
3334 pos += 2;
3335 length = *pos<<8 | *(pos+1);
3336 pos += 2;
3337 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
3338 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
3339 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
3340 pos += length;
3341 break;
3342 case HDD_WPS_ELEM_SERIAL_NUM:
3343 pos += 2;
3344 length = *pos<<8 | *(pos+1);
3345 pos += 2;
3346 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
3347 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
3348 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
3349 pos += length;
3350 break;
3351 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
3352 pos += 4;
3353 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003354 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 pos += 2;
3356
3357 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003358 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 pos += 4;
3360 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003361 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 pos += 2;
3363 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
3364 break;
3365 case HDD_WPS_ELEM_DEVICE_NAME:
3366 pos += 2;
3367 length = *pos<<8 | *(pos+1);
3368 pos += 2;
3369 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
3370 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
3371 pos += length;
3372 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
3373 break;
3374 case HDD_WPS_ELEM_CONFIG_METHODS:
3375 pos += 4;
3376 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003377 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 pos += 2;
3379 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
3380 break;
3381
3382 case HDD_WPS_ELEM_RF_BANDS:
3383 pos += 4;
3384 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003385 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 pos += 1;
3387 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
3388 break;
3389 } // switch
3390 }
3391 }
3392 else
3393 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003394 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 }
3396
3397 } // switch
3398 }
3399 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
3400 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3401 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
3402 {
3403 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3404 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
3405 WLANSAP_Update_WpsIe ( pVosContext );
3406 }
3407
3408 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003409 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 EXIT();
3411 return halStatus;
3412}
3413
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303414static int iw_softap_setwpsie(struct net_device *dev,
3415 struct iw_request_info *info,
3416 union iwreq_data *wrqu,
3417 char *extra)
3418{
3419 int ret;
3420
3421 vos_ssr_protect(__func__);
3422 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
3423 vos_ssr_unprotect(__func__);
3424
3425 return ret;
3426}
3427
3428static int __iw_softap_stopbss(struct net_device *dev,
3429 struct iw_request_info *info,
3430 union iwreq_data *wrqu,
3431 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003432{
3433 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3434 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05303435 hdd_context_t *pHddCtx = NULL;
3436
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +05303438
3439 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3440 status = wlan_hdd_validate_context(pHddCtx);
3441
3442 if (0 != status) {
3443 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
3444 return status;
3445 }
3446
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
3448 {
3449 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
3450 {
3451 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3452
3453 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
3454
3455 if (!VOS_IS_STATUS_SUCCESS(status))
3456 {
3457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003458 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 VOS_ASSERT(0);
3460 }
3461 }
3462 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05303463 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 }
3465 EXIT();
3466 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
3467}
3468
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303469static int iw_softap_stopbss(struct net_device *dev,
3470 struct iw_request_info *info,
3471 union iwreq_data *wrqu,
3472 char *extra)
3473{
3474 int ret;
3475
3476 vos_ssr_protect(__func__);
3477 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
3478 vos_ssr_unprotect(__func__);
3479
3480 return ret;
3481}
3482
3483static int __iw_softap_version(struct net_device *dev,
3484 struct iw_request_info *info,
3485 union iwreq_data *wrqu,
3486 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003487{
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003489
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 ENTER();
Jeff Johnson4824d4c2013-02-12 14:23:57 -08003491 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 return 0;
3494}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003495
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303496static int iw_softap_version(struct net_device *dev,
3497 struct iw_request_info *info,
3498 union iwreq_data *wrqu,
3499 char *extra)
3500{
3501 int ret;
3502
3503 vos_ssr_protect(__func__);
3504 ret = __iw_softap_version(dev, info, wrqu, extra);
3505 vos_ssr_unprotect(__func__);
3506
3507 return ret;
3508}
3509
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003510VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003511{
3512 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003513 int len = 0;
3514 const char sta_info_header[] = "staId staAddress\n";
3515
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303516 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
3517 ptSapContext pSapCtx = NULL;
3518 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3519 if(pSapCtx == NULL){
3520 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3521 FL("psapCtx is NULL"));
3522 return VOS_STATUS_E_FAULT;
3523 }
3524
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003525 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003526 pBuf += len;
3527 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003528
3529 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
3530 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303531 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003532 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08003533 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303534 pSapCtx->aStaInfo[i].ucSTAId,
3535 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
3536 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
3537 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
3538 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
3539 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
3540 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07003541 pBuf += len;
3542 buf_len -= len;
3543 }
3544 if(WE_GET_STA_INFO_SIZE > buf_len)
3545 {
3546 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003547 }
3548 }
3549 return VOS_STATUS_SUCCESS;
3550}
3551
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303552static int __iw_softap_get_sta_info(struct net_device *dev,
3553 struct iw_request_info *info,
3554 union iwreq_data *wrqu,
3555 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003556{
3557 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3558 VOS_STATUS status;
3559 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07003560 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003561 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003563 return -EINVAL;
3564 }
3565 wrqu->data.length = strlen(extra);
3566 EXIT();
3567 return 0;
3568}
3569
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303570static int iw_softap_get_sta_info(struct net_device *dev,
3571 struct iw_request_info *info,
3572 union iwreq_data *wrqu,
3573 char *extra)
3574{
3575 int ret;
3576
3577 vos_ssr_protect(__func__);
3578 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
3579 vos_ssr_unprotect(__func__);
3580
3581 return ret;
3582}
3583
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303584static int __iw_set_ap_genie(struct net_device *dev,
3585 struct iw_request_info *info,
3586 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003587{
3588
3589 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3590 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3591 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003592 u_int8_t *genie = (u_int8_t *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003593
3594 ENTER();
3595
3596 if(!wrqu->data.length)
3597 {
3598 EXIT();
3599 return 0;
3600 }
Arif Hussained667642013-10-27 23:01:14 -07003601
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 switch (genie[0])
3603 {
3604 case DOT11F_EID_WPA:
3605 case DOT11F_EID_RSN:
3606 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
3607 {
3608 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
3609 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
3610 }
3611 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07003612 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 break;
3614
3615 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003616 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 halStatus = 0;
3618 }
3619
3620 EXIT();
3621 return halStatus;
3622}
3623
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303624static int iw_set_ap_genie(struct net_device *dev,
3625 struct iw_request_info *info,
3626 union iwreq_data *wrqu, char *extra)
3627{
3628 int ret;
3629
3630 vos_ssr_protect(__func__);
3631 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
3632 vos_ssr_unprotect(__func__);
3633
3634 return ret;
3635}
3636
Jeff Johnson295189b2012-06-20 16:38:30 -07003637static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
3638{
3639 eHalStatus hstatus;
3640 long lrc;
3641 struct statsContext context;
3642
3643 if (NULL == pAdapter)
3644 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303645 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 return VOS_STATUS_E_FAULT;
3647 }
3648
3649 init_completion(&context.completion);
3650 context.pAdapter = pAdapter;
3651 context.magic = STATS_CONTEXT_MAGIC;
3652 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3653 eCSR_HDD,
3654 SME_GLOBAL_CLASSA_STATS,
3655 hdd_GetClassA_statisticsCB,
3656 0, // not periodic
3657 FALSE, //non-cached results
3658 staid,
3659 &context);
3660 if (eHAL_STATUS_SUCCESS != hstatus)
3661 {
3662 hddLog(VOS_TRACE_LEVEL_ERROR,
3663 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003664 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 }
3666 else
3667 {
3668 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3669 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 if (lrc <= 0)
3671 {
3672 hddLog(VOS_TRACE_LEVEL_ERROR,
3673 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003674 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 }
3676 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003677
3678 /* either we never sent a request, we sent a request and received a
3679 response or we sent a request and timed out. if we never sent a
3680 request or if we sent a request and got a response, we want to
3681 clear the magic out of paranoia. if we timed out there is a
3682 race condition such that the callback function could be
3683 executing at the same time we are. of primary concern is if the
3684 callback function had already verified the "magic" but had not
3685 yet set the completion variable when a timeout occurred. we
3686 serialize these activities by invalidating the magic while
3687 holding a shared spinlock which will cause us to block if the
3688 callback is currently executing */
3689 spin_lock(&hdd_context_lock);
3690 context.magic = 0;
3691 spin_unlock(&hdd_context_lock);
3692
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 return VOS_STATUS_SUCCESS;
3694}
3695
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303696int __iw_get_softap_linkspeed(struct net_device *dev,
3697 struct iw_request_info *info,
3698 union iwreq_data *wrqu,
3699 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003700
3701{
3702 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303703 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07003705 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303706 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303708 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08003710 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303711 int rc, valid;
3712
3713 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3714
3715 valid = wlan_hdd_validate_context(pHddCtx);
3716
3717 if (0 != valid)
3718 {
3719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context not valid"));
3720 return valid;
3721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003722
Arif Hussain6d2a3322013-11-17 19:50:10 -08003723 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08003724
3725 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07003726 {
Arif Hussaina9571842014-01-15 16:43:41 -08003727 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
3728 if (NULL == pmacAddress) {
3729 hddLog(LOG1, "unable to allocate memory");
3730 return -ENOMEM;
3731 }
3732 if (copy_from_user((void *)pmacAddress,
3733 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
3734 {
3735 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3736 kfree(pmacAddress);
3737 return -EFAULT;
3738 }
3739 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
3740
3741 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07003742 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08003743
3744 if (!VOS_IS_STATUS_SUCCESS(status ))
3745 {
3746 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
3747 }
Arif Hussained667642013-10-27 23:01:14 -07003748 }
Kiet Lam61589852013-09-19 17:10:58 +05303749 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303750 * link speed for first connected client will be returned.
3751 */
Arif Hussaina9571842014-01-15 16:43:41 -08003752 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05303753 {
3754 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
3755 }
3756 else
3757 {
3758 status = hdd_softap_GetStaId(pHostapdAdapter,
3759 (v_MACADDR_t *)macAddress, (void *)(&staId));
3760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003761
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303762 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 link_speed = 0;
3766 }
3767 else
3768 {
3769 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303770
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 if (!VOS_IS_STATUS_SUCCESS(status ))
3772 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 return -EINVAL;
3775 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303776
3777 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
3778 staId, &link_speed);
3779
3780 link_speed = link_speed / 10;
3781
3782 if (0 == link_speed)
3783 {
3784 /* The linkspeed returned by HAL is in units of 500kbps.
3785 * converting it to mbps.
3786 * This is required to support legacy firmware which does
3787 * not return link capacity.
3788 */
3789 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 }
3792
3793 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07003794 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 if ((rc < 0) || (rc >= len))
3797 {
3798 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303799 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 return -EIO;
3801 }
3802
3803 return 0;
3804}
3805
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303806int iw_get_softap_linkspeed(struct net_device *dev,
3807 struct iw_request_info *info,
3808 union iwreq_data *wrqu,
3809 char *extra)
3810{
3811 int ret;
3812
3813 vos_ssr_protect(__func__);
3814 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
3815 vos_ssr_unprotect(__func__);
3816
3817 return ret;
3818}
3819
3820
Jeff Johnson295189b2012-06-20 16:38:30 -07003821static const iw_handler hostapd_handler[] =
3822{
3823 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3824 (iw_handler) NULL, /* SIOCGIWNAME */
3825 (iw_handler) NULL, /* SIOCSIWNWID */
3826 (iw_handler) NULL, /* SIOCGIWNWID */
3827 (iw_handler) NULL, /* SIOCSIWFREQ */
3828 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
3829 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303830 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 (iw_handler) NULL, /* SIOCSIWSENS */
3832 (iw_handler) NULL, /* SIOCGIWSENS */
3833 (iw_handler) NULL, /* SIOCSIWRANGE */
3834 (iw_handler) NULL, /* SIOCGIWRANGE */
3835 (iw_handler) NULL, /* SIOCSIWPRIV */
3836 (iw_handler) NULL, /* SIOCGIWPRIV */
3837 (iw_handler) NULL, /* SIOCSIWSTATS */
3838 (iw_handler) NULL, /* SIOCGIWSTATS */
3839 (iw_handler) NULL, /* SIOCSIWSPY */
3840 (iw_handler) NULL, /* SIOCGIWSPY */
3841 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3842 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3843 (iw_handler) NULL, /* SIOCSIWAP */
3844 (iw_handler) NULL, /* SIOCGIWAP */
3845 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
3846 (iw_handler) NULL, /* SIOCGIWAPLIST */
3847 (iw_handler) NULL, /* SIOCSIWSCAN */
3848 (iw_handler) NULL, /* SIOCGIWSCAN */
3849 (iw_handler) NULL, /* SIOCSIWESSID */
3850 (iw_handler) NULL, /* SIOCGIWESSID */
3851 (iw_handler) NULL, /* SIOCSIWNICKN */
3852 (iw_handler) NULL, /* SIOCGIWNICKN */
3853 (iw_handler) NULL, /* -- hole -- */
3854 (iw_handler) NULL, /* -- hole -- */
3855 (iw_handler) NULL, /* SIOCSIWRATE */
3856 (iw_handler) NULL, /* SIOCGIWRATE */
3857 (iw_handler) NULL, /* SIOCSIWRTS */
3858 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
3859 (iw_handler) NULL, /* SIOCSIWFRAG */
3860 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
3861 (iw_handler) NULL, /* SIOCSIWTXPOW */
3862 (iw_handler) NULL, /* SIOCGIWTXPOW */
3863 (iw_handler) NULL, /* SIOCSIWRETRY */
3864 (iw_handler) NULL, /* SIOCGIWRETRY */
3865 (iw_handler) NULL, /* SIOCSIWENCODE */
3866 (iw_handler) NULL, /* SIOCGIWENCODE */
3867 (iw_handler) NULL, /* SIOCSIWPOWER */
3868 (iw_handler) NULL, /* SIOCGIWPOWER */
3869 (iw_handler) NULL, /* -- hole -- */
3870 (iw_handler) NULL, /* -- hole -- */
3871 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
3872 (iw_handler) NULL, /* SIOCGIWGENIE */
3873 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
3874 (iw_handler) NULL, /* SIOCGIWAUTH */
3875 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
3876 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
3877 (iw_handler) NULL, /* SIOCSIWPMKSA */
3878};
3879
Jeff Johnson224f3702014-03-26 11:09:47 -07003880/*
3881 * Note that the following ioctls were defined with semantics which
3882 * cannot be handled by the "iwpriv" userspace application and hence
3883 * they are not included in the hostapd_private_args array
3884 * QCSAP_IOCTL_ASSOC_STA_MACADDR
3885 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003886
3887static const struct iw_priv_args hostapd_private_args[] = {
3888 { QCSAP_IOCTL_SETPARAM,
3889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
3890 { QCSAP_IOCTL_SETPARAM,
3891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
3892 { QCSAP_PARAM_MAX_ASSOC,
3893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
3894 { QCSAP_PARAM_HIDE_SSID,
3895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07003896 { QCSAP_PARAM_SET_MC_RATE,
3897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 { QCSAP_IOCTL_GETPARAM,
3899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
3901 { QCSAP_IOCTL_GETPARAM, 0,
3902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
3903 { QCSAP_PARAM_MAX_ASSOC, 0,
3904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07003905 { QCSAP_PARAM_GET_WLAN_DBG, 0,
3906 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
3907 { QCSAP_PARAM_AUTO_CHANNEL, 0,
3908 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05303909 { QCSAP_PARAM_SET_AUTO_CHANNEL,
3910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 { QCSAP_PARAM_CLR_ACL, 0,
3912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
3913 { QCSAP_PARAM_ACL_MODE,
3914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 { QCSAP_IOCTL_GET_STAWPAIE,
3916 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
3917 { QCSAP_IOCTL_SETWPAIE,
3918 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
3919 { QCSAP_IOCTL_STOPBSS,
3920 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
3921 { QCSAP_IOCTL_VERSION, 0,
3922 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003923 { QCSAP_IOCTL_GET_STA_INFO, 0,
3924 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08003926 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07003928 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07003929 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05303931 { QCSAP_IOCTL_AP_STATS, 0,
3932 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
3934 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303935 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003936
3937 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
3938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
3939 /* handlers for sub-ioctl */
3940 { WE_SET_WLAN_DBG,
3941 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
3942 0,
3943 "setwlandbg" },
3944
3945 /* handlers for main ioctl */
3946 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
3947 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3948 0,
3949 "" },
3950
3951 /* handlers for sub-ioctl */
3952 { WE_LOG_DUMP_CMD,
3953 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3954 0,
3955 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 { WE_P2P_NOA_CMD,
3957 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3958 0,
3959 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08003960 /* handlers for sub ioctl */
3961 {
3962 WE_MCC_CONFIG_CREDENTIAL,
3963 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3964 0,
3965 "setMccCrdnl" },
3966
3967 /* handlers for sub ioctl */
3968 {
3969 WE_MCC_CONFIG_PARAMS,
3970 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3971 0,
3972 "setMccConfig" },
3973
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 /* handlers for main ioctl */
3975 { QCSAP_IOCTL_MODIFY_ACL,
3976 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
3977 0,
3978 "modify_acl" },
3979
3980 /* handlers for main ioctl */
3981 { QCSAP_IOCTL_GET_CHANNEL_LIST,
3982 0,
3983 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
3984 "getChannelList" },
3985
Jeff Johnsone7245742012-09-05 17:12:55 -07003986 /* handlers for main ioctl */
3987 { QCSAP_IOCTL_SET_TX_POWER,
3988 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3989 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05303990 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07003991
3992 /* handlers for main ioctl */
3993 { QCSAP_IOCTL_SET_MAX_TX_POWER,
3994 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3995 0,
3996 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05303997
3998 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
3999 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4000 0,
4001 "dataSnapshot" },
4002
4003 /* handlers for main ioctl */
4004 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4005 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4006 0,
4007 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004008};
Jeff Johnsone7245742012-09-05 17:12:55 -07004009
Jeff Johnson295189b2012-06-20 16:38:30 -07004010static const iw_handler hostapd_private[] = {
4011 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4012 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4014 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4015 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4016 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4017 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4018 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4019 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4020 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4021 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304022 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4024 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4025 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4026 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004027 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004028 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4029 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004030 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304031 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304032 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Jeff Johnson295189b2012-06-20 16:38:30 -07004033};
4034const struct iw_handler_def hostapd_handler_def = {
4035 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4036 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4037 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4038 .standard = (iw_handler *)hostapd_handler,
4039 .private = (iw_handler *)hostapd_private,
4040 .private_args = hostapd_private_args,
4041 .get_wireless_stats = NULL,
4042};
4043#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4044struct net_device_ops net_ops_struct = {
4045 .ndo_open = hdd_hostapd_open,
4046 .ndo_stop = hdd_hostapd_stop,
4047 .ndo_uninit = hdd_hostapd_uninit,
4048 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4049 .ndo_tx_timeout = hdd_softap_tx_timeout,
4050 .ndo_get_stats = hdd_softap_stats,
4051 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4052 .ndo_do_ioctl = hdd_hostapd_ioctl,
4053 .ndo_change_mtu = hdd_hostapd_change_mtu,
4054 .ndo_select_queue = hdd_hostapd_select_queue,
4055 };
4056#endif
4057
4058int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4059{
4060 return VOS_STATUS_SUCCESS;
4061}
4062
4063void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4064{
4065#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4066 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4067#else
4068 pWlanHostapdDev->open = hdd_hostapd_open;
4069 pWlanHostapdDev->stop = hdd_hostapd_stop;
4070 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4071 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4072 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4073 pWlanHostapdDev->get_stats = hdd_softap_stats;
4074 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4075 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4076#endif
4077}
4078
4079VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
4080{
4081 hdd_hostapd_state_t * phostapdBuf;
4082 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004083 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004085#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004086 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4087 v_U16_t unsafeChannelCount;
4088#endif /* FEATURE_WLAN_CH_AVOID */
4089
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 ENTER();
4091 // Allocate the Wireless Extensions state structure
4092 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
4093
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004094 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4095
Leo Chang0b0e45a2013-12-15 15:18:55 -08004096#ifdef FEATURE_WLAN_CH_AVOID
4097 /* Get unsafe cahnnel list from cached location */
4098 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4099 sizeof(unsafeChannelList),
4100 &unsafeChannelCount);
4101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4102 "%s : Unsafe Channel count %d",
4103 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304104 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004105 unsafeChannelList,
4106 unsafeChannelCount);
4107#endif /* FEATURE_WLAN_CH_AVOID */
4108
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 // Zero the memory. This zeros the profile structure.
4110 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
4111
4112 // Set up the pointer to the Wireless Extensions state structure
4113 // NOP
4114 status = hdd_set_hostapd(pAdapter);
4115 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 return status;
4118 }
4119
4120 status = vos_event_init(&phostapdBuf->vosEvent);
4121 if (!VOS_IS_STATUS_SUCCESS(status))
4122 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 return status;
4125 }
4126
4127 init_completion(&pAdapter->session_close_comp_var);
4128 init_completion(&pAdapter->session_open_comp_var);
4129
4130 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4131
4132 // Register as a wireless device
4133 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4134
4135 //Initialize the data path module
4136 status = hdd_softap_init_tx_rx(pAdapter);
4137 if ( !VOS_IS_STATUS_SUCCESS( status ))
4138 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004139 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304141
4142 status = hdd_wmm_adapter_init( pAdapter );
4143 if (!VOS_IS_STATUS_SUCCESS(status))
4144 {
4145 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004146 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304147 status, status );
4148 goto error_wmm_init;
4149 }
4150
4151 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
4152
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304154
4155 return status;
4156
4157error_wmm_init:
4158 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 EXIT();
4160 return status;
4161}
4162
4163hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4164{
4165 struct net_device *pWlanHostapdDev = NULL;
4166 hdd_adapter_t *pHostapdAdapter = NULL;
4167 v_CONTEXT_t pVosContext= NULL;
4168
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004170
4171 if (pWlanHostapdDev != NULL)
4172 {
4173 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4174
4175 //Init the net_device structure
4176 ether_setup(pWlanHostapdDev);
4177
4178 //Initialize the adapter context to zeros.
4179 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4180 pHostapdAdapter->dev = pWlanHostapdDev;
4181 pHostapdAdapter->pHddCtx = pHddCtx;
4182 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4183
4184 //Get the Global VOSS context.
4185 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4186 //Save the adapter context in global context for future.
4187 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4188
4189 //Init the net_device structure
4190 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4191
4192 hdd_set_ap_ops( pHostapdAdapter->dev );
4193
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4195 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4196
4197 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4198 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4199
4200 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4202 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4203 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
4204 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
4206 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05304207 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
4209 init_completion(&pHostapdAdapter->offchannel_tx_event);
4210#endif
4211
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4213 }
4214 return pHostapdAdapter;
4215}
4216
4217VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4218{
4219 struct net_device *dev = pAdapter->dev;
4220 VOS_STATUS status = VOS_STATUS_SUCCESS;
4221
4222 ENTER();
4223
4224 if( rtnl_lock_held )
4225 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004226 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 if( dev_alloc_name(dev, dev->name) < 0 )
4228 {
4229 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4230 return VOS_STATUS_E_FAILURE;
4231 }
4232 }
4233 if (register_netdevice(dev))
4234 {
4235 hddLog(VOS_TRACE_LEVEL_FATAL,
4236 "%s:Failed:register_netdevice", __func__);
4237 return VOS_STATUS_E_FAILURE;
4238 }
4239 }
4240 else
4241 {
4242 if (register_netdev(dev))
4243 {
4244 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
4245 return VOS_STATUS_E_FAILURE;
4246 }
4247 }
4248 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
4249
4250 EXIT();
4251 return status;
4252}
4253
4254VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter)
4255{
4256 ENTER();
4257
4258 hdd_softap_deinit_tx_rx(pAdapter);
4259
4260 /* if we are being called during driver unload, then the dev has already
4261 been invalidated. if we are being called at other times, then we can
4262 detatch the wireless device handlers */
4263 if (pAdapter->dev)
4264 {
4265 pAdapter->dev->wireless_handlers = NULL;
4266 }
4267 EXIT();
4268 return 0;
4269}