blob: f4eac7eacd9d50be21e8261e1f9ecb05b36bdac9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070082
Leo Chang0b0e45a2013-12-15 15:18:55 -080083#ifdef FEATURE_WLAN_CH_AVOID
84#include "wcnss_wlan.h"
85#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080089
Jeff Johnson295189b2012-06-20 16:38:30 -070090#define IS_UP(_dev) \
91 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
92#define IS_UP_AUTO(_ic) \
93 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
94#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070095#define WE_GET_STA_INFO_SIZE 30
96/* WEXT limition: MAX allowed buf len for any *
97 * IW_PRIV_TYPE_CHAR is 2Kbytes *
98 */
99#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700100
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530101#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700102
Leo Chang0b0e45a2013-12-15 15:18:55 -0800103#ifdef FEATURE_WLAN_CH_AVOID
104/* Channle/Freqency table */
105extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
106safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
107{
108 /*CH , SAFE, default safe */
109 {1 , VOS_TRUE}, //RF_CHAN_1,
110 {2 , VOS_TRUE}, //RF_CHAN_2,
111 {3 , VOS_TRUE}, //RF_CHAN_3,
112 {4 , VOS_TRUE}, //RF_CHAN_4,
113 {5 , VOS_TRUE}, //RF_CHAN_5,
114 {6 , VOS_TRUE}, //RF_CHAN_6,
115 {7 , VOS_TRUE}, //RF_CHAN_7,
116 {8 , VOS_TRUE}, //RF_CHAN_8,
117 {9 , VOS_TRUE}, //RF_CHAN_9,
118 {10 , VOS_TRUE}, //RF_CHAN_10,
119 {11 , VOS_TRUE}, //RF_CHAN_11,
120 {12 , VOS_TRUE}, //RF_CHAN_12,
121 {13 , VOS_TRUE}, //RF_CHAN_13,
122 {14 , VOS_TRUE}, //RF_CHAN_14,
123 {240, VOS_TRUE}, //RF_CHAN_240,
124 {244, VOS_TRUE}, //RF_CHAN_244,
125 {248, VOS_TRUE}, //RF_CHAN_248,
126 {252, VOS_TRUE}, //RF_CHAN_252,
127 {208, VOS_TRUE}, //RF_CHAN_208,
128 {212, VOS_TRUE}, //RF_CHAN_212,
129 {216, VOS_TRUE}, //RF_CHAN_216,
130 {36 , VOS_TRUE}, //RF_CHAN_36,
131 {40 , VOS_TRUE}, //RF_CHAN_40,
132 {44 , VOS_TRUE}, //RF_CHAN_44,
133 {48 , VOS_TRUE}, //RF_CHAN_48,
134 {52 , VOS_TRUE}, //RF_CHAN_52,
135 {56 , VOS_TRUE}, //RF_CHAN_56,
136 {60 , VOS_TRUE}, //RF_CHAN_60,
137 {64 , VOS_TRUE}, //RF_CHAN_64,
138 {100, VOS_TRUE}, //RF_CHAN_100,
139 {104, VOS_TRUE}, //RF_CHAN_104,
140 {108, VOS_TRUE}, //RF_CHAN_108,
141 {112, VOS_TRUE}, //RF_CHAN_112,
142 {116, VOS_TRUE}, //RF_CHAN_116,
143 {120, VOS_TRUE}, //RF_CHAN_120,
144 {124, VOS_TRUE}, //RF_CHAN_124,
145 {128, VOS_TRUE}, //RF_CHAN_128,
146 {132, VOS_TRUE}, //RF_CHAN_132,
147 {136, VOS_TRUE}, //RF_CHAN_136,
148 {140, VOS_TRUE}, //RF_CHAN_140,
149 {149, VOS_TRUE}, //RF_CHAN_149,
150 {153, VOS_TRUE}, //RF_CHAN_153,
151 {157, VOS_TRUE}, //RF_CHAN_157,
152 {161, VOS_TRUE}, //RF_CHAN_161,
153 {165, VOS_TRUE}, //RF_CHAN_165,
154};
155#endif /* FEATURE_WLAN_CH_AVOID */
156
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530157/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 * Function definitions
159 *-------------------------------------------------------------------------*/
160/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530161
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530162 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 This is called in response to ifconfig up
165
166 \param - dev Pointer to net_device structure
167
168 \return - 0 for success non-zero for failure
169
170 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530171int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700172{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
174
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 ENTER();
176
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530177 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
178 {
179 //WMM_INIT OR BSS_START not completed
180 hddLog( LOGW, "Ignore hostadp open request");
181 EXIT();
182 return 0;
183 }
184
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530185 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
186 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 //Turn ON carrier state
188 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530189 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530190 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530192
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 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) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530224 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 //Stop all tx queues
226 netif_tx_disable(dev);
227
228 //Turn OFF carrier state
229 netif_carrier_off(dev);
230 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700231
232 EXIT();
233 return 0;
234}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530235
236int hdd_hostapd_stop (struct net_device *dev)
237{
238 int ret;
239
240 vos_ssr_protect(__func__);
241 ret = __hdd_hostapd_stop(dev);
242 vos_ssr_unprotect(__func__);
243
244 return ret;
245}
246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247/**---------------------------------------------------------------------------
248
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530249 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251 This is called during the netdev unregister to uninitialize all data
252associated with the device
253
254 \param - dev Pointer to net_device structure
255
256 \return - void
257
258 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530259static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700260{
261 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530262 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264 ENTER();
265
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530266 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 hddLog(VOS_TRACE_LEVEL_ERROR,
269 FL("Invalid magic"));
270 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530272 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
273 if (NULL == pHddCtx)
274 {
275 hddLog(VOS_TRACE_LEVEL_ERROR,
276 FL("NULL pHddCtx"));
277 return;
278 }
279
280 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
281
282 /* after uninit our adapter structure will no longer be valid */
283 pHostapdAdapter->dev = NULL;
284 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700285
286 EXIT();
287}
288
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530289static void hdd_hostapd_uninit (struct net_device *dev)
290{
291 vos_ssr_protect(__func__);
292 __hdd_hostapd_uninit(dev);
293 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530295 return;
296}
Jeff Johnson295189b2012-06-20 16:38:30 -0700297/**============================================================================
298 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
299 transmitting packets. There are 2 versions of this function. One that uses
300 locked queue and other that uses lockless queues. Both have been retained to
301 do some performance testing
302 @param skb : [in] pointer to OS packet (sk_buff)
303 @param dev : [in] pointer to Libra network device
304
305 @return : NET_XMIT_DROP if packets are dropped
306 : NET_XMIT_SUCCESS if packet is enqueued succesfully
307 ===========================================================================*/
308int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
309{
310 return 0;
311}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530312
313int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700314{
315 return 0;
316}
317
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530318int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
319{
320 int ret;
321 vos_ssr_protect(__func__);
322 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
323 vos_ssr_unprotect(__func__);
324
325 return ret;
326}
327
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700328static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
329 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700330{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700331 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530332 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
333 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700334 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530335 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 /*
337 * Note that valid pointers are provided by caller
338 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700339
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530340 ENTER();
341
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700342 if (priv_data->total_len <= 0 ||
343 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
344 {
345 /* below we allocate one more byte for command buffer.
346 * To avoid addition overflow total_len should be
347 * smaller than INT_MAX. */
348 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
349 __func__, priv_data->total_len);
350 ret = -EFAULT;
351 goto exit;
352 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530353 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530354 if (0 != status)
355 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 return status;
357 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700359 /* Allocate +1 for '\0' */
360 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
361 if (!command)
362 {
363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
364 ret = -ENOMEM;
365 goto exit;
366 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700367
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700368 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
369 {
370 ret = -EFAULT;
371 goto exit;
372 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800373
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700374 /* Make sure the command is NUL-terminated */
375 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700377 hddLog(VOS_TRACE_LEVEL_INFO,
378 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700380 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
381 {
382 hdd_setP2pNoa(pAdapter->dev, command);
383 }
384 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
385 {
386 hdd_setP2pOpps(pAdapter->dev, command);
387 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800388#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700389 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
390 {
391 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
392 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800393#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700394 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
395 {
396 /*
397 * command should be a string having format
398 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
399 */
400 hddLog(VOS_TRACE_LEVEL_INFO,
401 "%s: Received Command to Set Preferred Channels for SAP",
402 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800403
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700404 ret = sapSetPreferredChannel(command);
405 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530406 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
407 {
408 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
409 tANI_U8 filterType = 0;
410 tANI_U8 *value;
411 value = command + 9;
412
413 /* Convert the value from ascii to integer */
414 ret = kstrtou8(value, 10, &filterType);
415 if (ret < 0)
416 {
417 /* If the input value is greater than max value of datatype,
418 * then also kstrtou8 fails
419 */
420 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
421 "%s: kstrtou8 failed range ", __func__);
422 ret = -EINVAL;
423 goto exit;
424 }
425 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
426 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
427 {
428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
429 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
430 " 2-Sink ", __func__);
431 ret = -EINVAL;
432 goto exit;
433 }
434 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
435 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530436 pScanInfo = &pHddCtx->scan_info;
437 if (filterType && pScanInfo != NULL &&
438 pHddCtx->scan_info.mScanPending)
439 {
440 /*Miracast Session started. Abort Scan */
441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
442 "%s, Aborting Scan For Miracast",__func__);
443 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
444 eCSR_SCAN_ABORT_DEFAULT);
445 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530446 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
447 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
448 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700449
Jeff Johnson295189b2012-06-20 16:38:30 -0700450exit:
451 if (command)
452 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700453 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530455 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 return ret;
457}
458
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700459#ifdef CONFIG_COMPAT
460static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
461 struct ifreq *ifr)
462{
463 struct {
464 compat_uptr_t buf;
465 int used_len;
466 int total_len;
467 } compat_priv_data;
468 hdd_priv_data_t priv_data;
469 int ret = 0;
470
471 /*
472 * Note that pAdapter and ifr have already been verified by caller,
473 * and HDD context has also been validated
474 */
475 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
476 sizeof(compat_priv_data))) {
477 ret = -EFAULT;
478 goto exit;
479 }
480 priv_data.buf = compat_ptr(compat_priv_data.buf);
481 priv_data.used_len = compat_priv_data.used_len;
482 priv_data.total_len = compat_priv_data.total_len;
483 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
484 exit:
485 return ret;
486}
487#else /* CONFIG_COMPAT */
488static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
489 struct ifreq *ifr)
490{
491 /* will never be invoked */
492 return 0;
493}
494#endif /* CONFIG_COMPAT */
495
496static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
497{
498 hdd_priv_data_t priv_data;
499 int ret = 0;
500
501 /*
502 * Note that pAdapter and ifr have already been verified by caller,
503 * and HDD context has also been validated
504 */
505 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
506 ret = -EFAULT;
507 } else {
508 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
509 }
510 return ret;
511}
512
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530513static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700514 struct ifreq *ifr, int cmd)
515{
516 hdd_adapter_t *pAdapter;
517 hdd_context_t *pHddCtx;
518 int ret;
519
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530520 ENTER();
521
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700522 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
523 if (NULL == pAdapter) {
524 hddLog(VOS_TRACE_LEVEL_ERROR,
525 "%s: HDD adapter context is Null", __func__);
526 ret = -ENODEV;
527 goto exit;
528 }
529 if (dev != pAdapter->dev) {
530 hddLog(VOS_TRACE_LEVEL_ERROR,
531 "%s: HDD adapter/dev inconsistency", __func__);
532 ret = -ENODEV;
533 goto exit;
534 }
535
536 if ((!ifr) || (!ifr->ifr_data)) {
537 ret = -EINVAL;
538 goto exit;
539 }
540
541 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
542 ret = wlan_hdd_validate_context(pHddCtx);
543 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700544 ret = -EBUSY;
545 goto exit;
546 }
547
548 switch (cmd) {
549 case (SIOCDEVPRIVATE + 1):
550 if (is_compat_task())
551 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
552 else
553 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
554 break;
555 default:
556 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
557 __func__, cmd);
558 ret = -EINVAL;
559 break;
560 }
561 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530562 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700563 return ret;
564}
565
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530566static int hdd_hostapd_ioctl(struct net_device *dev,
567 struct ifreq *ifr, int cmd)
568{
569 int ret;
570
571 vos_ssr_protect(__func__);
572 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
573 vos_ssr_unprotect(__func__);
574
575 return ret;
576}
577
Jeff Johnson295189b2012-06-20 16:38:30 -0700578/**---------------------------------------------------------------------------
579
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530580 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 This function sets the user specified mac address using
582 the command ifconfig wlanX hw ether <mac adress>.
583
584 \param - dev - Pointer to the net device.
585 - addr - Pointer to the sockaddr.
586 \return - 0 for success, non zero for failure
587
588 --------------------------------------------------------------------------*/
589
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530590static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700591{
592 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530593 hdd_adapter_t *pAdapter;
594 hdd_context_t *pHddCtx;
595 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530596
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530598 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
599 if (NULL == pAdapter)
600 {
601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
602 "%s: Adapter is NULL",__func__);
603 return -EINVAL;
604 }
605 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
606 ret = wlan_hdd_validate_context(pHddCtx);
607 if (0 != ret)
608 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530609 return ret;
610 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
612 EXIT();
613 return 0;
614}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530615
616static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
617{
618 int ret;
619
620 vos_ssr_protect(__func__);
621 ret = __hdd_hostapd_set_mac_address(dev, addr);
622 vos_ssr_unprotect(__func__);
623
624 return ret;
625}
626
Jeff Johnson295189b2012-06-20 16:38:30 -0700627void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
628{
629 struct net_device *dev = (struct net_device *)usrDataForCallback;
630 v_BYTE_t we_custom_event[64];
631 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530633 hdd_context_t *pHddCtx;
634#ifdef DISABLE_CONCURRENCY_AUTOSAVE
635 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 hdd_ap_ctx_t *pHddApCtx;
637#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
638
639 /* event_name space-delimiter driver_module_name */
640 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
641 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
642 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
643
644 ENTER();
645
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530646 pHostapdAdapter = netdev_priv(dev);
647 if ((NULL == pHostapdAdapter) ||
648 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
649 {
650 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
651 return;
652 }
653 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
654 if (0 != (wlan_hdd_validate_context(pHddCtx)))
655 {
656 return;
657 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530658#ifdef DISABLE_CONCURRENCY_AUTOSAVE
659 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530660 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 /*
662 This timer routine is going to be called only when AP
663 persona is up.
664 If there are concurrent sessions running we do not want
665 to shut down the Bss.Instead we run the timer again so
666 that if Autosave is enabled next time and other session
667 was down only then we bring down AP
668 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
670 vos_status = vos_timer_start(
671 &pHddApCtx->hdd_ap_inactivity_timer,
672 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
673 * 1000);
674 if (!VOS_IS_STATUS_SUCCESS(vos_status))
675 {
676 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
677 }
678 EXIT();
679 return;
680 }
681#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
682 memset(&we_custom_event, '\0', sizeof(we_custom_event));
683 memcpy(&we_custom_event, autoShutEvent, event_len);
684
685 memset(&wrqu, 0, sizeof(wrqu));
686 wrqu.data.length = event_len;
687
688 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
689 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
690
691 EXIT();
692}
693
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800694VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
695{
696 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
697 ptSapContext pSapCtx = NULL;
698 eHalStatus halStatus = eHAL_STATUS_FAILURE;
699 v_PVOID_t hHal = NULL;
700
701 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
702 "%s: UPDATE Beacon Params", __func__);
703
704 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
705 pSapCtx = VOS_GET_SAP_CB(pVosContext);
706 if ( NULL == pSapCtx )
707 {
708 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
709 "%s: Invalid SAP pointer from pvosGCtx", __func__);
710 return VOS_STATUS_E_FAULT;
711 }
712
713 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
714 if ( NULL == hHal ){
715 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
716 "%s: Invalid HAL pointer from pvosGCtx", __func__);
717 return VOS_STATUS_E_FAULT;
718 }
719 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
720 if(halStatus == eHAL_STATUS_FAILURE ){
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Failed to update Beacon Params", __func__);
723 return VOS_STATUS_E_FAILURE;
724 }
725 }
726 return VOS_STATUS_SUCCESS;
727}
728
729void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
730{
731 v_U8_t staId = 0;
732 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530733 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
734 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800735
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530736 dev = (struct net_device *)usrDataForCallback;
737 pSapCtx = VOS_GET_SAP_CB(pVosContext);
738 if(pSapCtx == NULL){
739 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
740 FL("psapCtx is NULL"));
741 return;
742 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800743 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800744 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
745 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530746 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800747 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
748 {
749 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530750 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800751 }
752 }
753}
754
Agarwal Ashish8e538932014-12-24 18:12:52 +0530755static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800756{
757 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530758 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800759 VOS_STATUS status = VOS_STATUS_SUCCESS;
760 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530761
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530763
764 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
765 status = wlan_hdd_validate_context(pHddCtx);
766
767 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530768 return status;
769 }
770
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800771 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
772 {
773 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
774 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800776 }
777 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530778 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800779 }
780 EXIT();
781 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
782}
Jeff Johnson295189b2012-06-20 16:38:30 -0700783
784VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
785{
786 hdd_adapter_t *pHostapdAdapter;
787 hdd_ap_ctx_t *pHddApCtx;
788 hdd_hostapd_state_t *pHostapdState;
789 struct net_device *dev;
790 eSapHddEvent sapEvent;
791 union iwreq_data wrqu;
792 v_BYTE_t *we_custom_event_generic = NULL;
793 int we_event = 0;
794 int i = 0;
795 v_U8_t staId;
796 VOS_STATUS vos_status;
797 v_BOOL_t bWPSState;
798 v_BOOL_t bApActive = FALSE;
799 v_BOOL_t bAuthRequired = TRUE;
800 tpSap_AssocMacAddr pAssocStasArray = NULL;
801 char unknownSTAEvent[IW_CUSTOM_MAX+1];
802 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
803 v_BYTE_t we_custom_start_event[64];
804 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800805 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800806 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700807 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530808 v_CONTEXT_t pVosContext = NULL;
809 ptSapContext pSapCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700810
811 dev = (struct net_device *)usrDataForCallback;
812 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530813
814 if ((NULL == pHostapdAdapter) ||
815 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
816 {
817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
818 "invalid adapter or adapter has invalid magic");
819 return eHAL_STATUS_FAILURE;
820 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530821 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
822 pSapCtx = VOS_GET_SAP_CB(pVosContext);
823 if(pSapCtx == NULL){
824 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
825 FL("psapCtx is NULL"));
826 return eHAL_STATUS_FAILURE;
827 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
829 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
830 sapEvent = pSapEvent->sapHddEventCode;
831 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800832 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700833
834 switch(sapEvent)
835 {
836 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800837 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
839 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
840 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
841
842 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
843 vos_status = vos_event_set(&pHostapdState->vosEvent);
844
845 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 goto stopbss;
849 }
850 else
851 {
852 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
853 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530854 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
855 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530856 {
c_hpothuffdb5272013-10-02 16:42:35 +0530857 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530858 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
859 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 }
861
862 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
863 {
864 // AP Inactivity timer init and start
865 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
866 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
867 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800868 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700869
870 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
871 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800872 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700873
874 }
875 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
876 pHostapdState->bssState = BSS_START;
877
878 // Send current operating channel of SoftAP to BTC-ES
879 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
880
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 //Check if there is any group key pending to set.
882 if( pHddApCtx->groupKey.keyLength )
883 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700884 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
886 &pHddApCtx->groupKey ) )
887 {
888 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
889 "%s: WLANSAP_SetKeySta failed", __func__);
890 }
891 pHddApCtx->groupKey.keyLength = 0;
892 }
893 else if ( pHddApCtx->wepKey[0].keyLength )
894 {
895 int i=0;
896 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
897 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700898 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
900 &pHddApCtx->wepKey[i] ) )
901 {
902 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
903 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
904 }
905 pHddApCtx->wepKey[i].keyLength = 0;
906 }
907 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
909 startBssEvent = "SOFTAP.enabled";
910 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
911 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
912 memset(&wrqu, 0, sizeof(wrqu));
913 wrqu.data.length = strlen(startBssEvent);
914 we_event = IWEVCUSTOM;
915 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700916 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 break; //Event will be sent after Switch-Case stmt
918
919 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800920 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
922
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700923 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700924 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530927
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530928 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530929 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530930 hddLog(LOG1,
931 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
932 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530933 }
934
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 goto stopbss;
936 case eSAP_STA_SET_KEY_EVENT:
937 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800938 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
940 return VOS_STATUS_SUCCESS;
941 case eSAP_STA_DEL_KEY_EVENT:
942 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800943 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 return VOS_STATUS_SUCCESS;
945 case eSAP_STA_MIC_FAILURE_EVENT:
946 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 memset(&msg, '\0', sizeof(msg));
948 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800949 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800950 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700951 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 msg.flags = IW_MICFAILURE_GROUP;
953 else
954 msg.flags = IW_MICFAILURE_PAIRWISE;
955 memset(&wrqu, 0, sizeof(wrqu));
956 wrqu.data.length = sizeof(msg);
957 we_event = IWEVMICHAELMICFAILURE;
958 we_custom_event_generic = (v_BYTE_t *)&msg;
959 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 /* inform mic failure to nl80211 */
961 cfg80211_michael_mic_failure(dev,
962 pSapEvent->sapevt.
963 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700964 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 NL80211_KEYTYPE_GROUP :
966 NL80211_KEYTYPE_PAIRWISE),
967 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
968 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
969 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 break;
971
972 case eSAP_STA_ASSOC_EVENT:
973 case eSAP_STA_REASSOC_EVENT:
974 wrqu.addr.sa_family = ARPHRD_ETHER;
975 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800976 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800977 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 we_event = IWEVREGISTERED;
979
980 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
981
982 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
983 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
984 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
985 {
986 bAuthRequired = FALSE;
987 }
988
989 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
990 {
c_hpothuffdb5272013-10-02 16:42:35 +0530991 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 TRUE,
993 pHddApCtx->uPrivacy,
994 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
995 0,
996 0,
997 (v_MACADDR_t *)wrqu.addr.sa_data,
998 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +0530999
1000 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1001 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1002 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 }
1004 else
1005 {
c_hpothuffdb5272013-10-02 16:42:35 +05301006 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 FALSE,
1008 pHddApCtx->uPrivacy,
1009 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1010 0,
1011 0,
1012 (v_MACADDR_t *)wrqu.addr.sa_data,
1013 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301014 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1015 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1016 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001017 }
1018
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 // Stop AP inactivity timer
1020 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1021 {
1022 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1023 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001024 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001026#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001027 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1028 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301029 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1030 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001031 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301032 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1033 HDD_SAP_WAKE_LOCK_DURATION,
1034 WIFI_POWER_EVENT_WAKELOCK_SAP);
1035
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001036#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001037#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1038 {
1039 struct station_info staInfo;
1040 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1041
1042 memset(&staInfo, 0, sizeof(staInfo));
1043 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1044 {
1045 staInfo.assoc_req_ies =
1046 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1047 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001048#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001049 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1050#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 cfg80211_new_sta(dev,
1052 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1053 &staInfo, GFP_KERNEL);
1054 }
1055 else
1056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001057 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 }
1059 }
1060#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001061 pScanInfo = &pHddCtx->scan_info;
1062 // Lets do abort scan to ensure smooth authentication for client
1063 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1064 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301065 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301066 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069 break;
1070 case eSAP_STA_DISASSOC_EVENT:
1071 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001072 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001073 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1075 hddLog(LOG1," User initiated disassociation");
1076 else
1077 hddLog(LOG1," MAC initiated disassociation");
1078 we_event = IWEVEXPIRED;
1079 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1080 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1081 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001082 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 -07001083 return VOS_STATUS_E_FAILURE;
1084 }
1085 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1086
1087 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1088 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301089 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 // Start AP inactivity timer if no stations associated with it
1091 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1092 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301093 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 {
1095 bApActive = TRUE;
1096 break;
1097 }
1098 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301099 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
1101 if (bApActive == FALSE)
1102 {
1103 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1104 {
1105 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1106 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001107 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 }
1109 else
1110 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1111 }
1112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001113#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1114 cfg80211_del_sta(dev,
1115 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1116 GFP_KERNEL);
1117#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001118 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301119 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1120 if (VOS_STATUS_SUCCESS != vos_status)
1121 {
1122 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1123 __func__, vos_status);
1124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 break;
1126 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1127 {
1128 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1129 union iwreq_data wreq;
1130
1131 down(&pHddApCtx->semWpsPBCOverlapInd);
1132 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1133
1134 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1135 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1136
1137 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001138 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 memset(&wreq, 0, sizeof(wreq));
1140 wreq.data.length = strlen(message); // This is length of message
1141 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1142
1143 return VOS_STATUS_SUCCESS;
1144 }
1145 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1146 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1147 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1148 { // List of associated stations
1149 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1150 {
1151 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1152 i+1,
1153 pAssocStasArray->assocId,
1154 pAssocStasArray->staId,
1155 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1156 pAssocStasArray++;
1157 }
1158 }
1159 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001160 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 case eSAP_INDICATE_MGMT_FRAME:
1163 hdd_indicateMgmtFrame( pHostapdAdapter,
1164 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1165 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1166 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301167 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 return VOS_STATUS_SUCCESS;
1169 case eSAP_REMAIN_CHAN_READY:
1170 hdd_remainChanReadyHandler( pHostapdAdapter );
1171 return VOS_STATUS_SUCCESS;
1172 case eSAP_SEND_ACTION_CNF:
1173 hdd_sendActionCnf( pHostapdAdapter,
1174 ( eSAP_STATUS_SUCCESS ==
1175 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1176 TRUE : FALSE );
1177 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 case eSAP_UNKNOWN_STA_JOIN:
1179 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1180 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1181 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1182 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1183 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1184 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1185 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1186 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1187 wrqu.data.pointer = unknownSTAEvent;
1188 wrqu.data.length = strlen(unknownSTAEvent);
1189 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301190 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 break;
1192
1193 case eSAP_MAX_ASSOC_EXCEEDED:
1194 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1195 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1196 " one or more devices to enable the new device connection",
1197 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1198 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1199 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1200 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1201 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1202 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1203 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1204 wrqu.data.pointer = maxAssocExceededEvent;
1205 wrqu.data.length = strlen(maxAssocExceededEvent);
1206 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001207 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 break;
1209 case eSAP_STA_ASSOC_IND:
1210 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001211
1212 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001213 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001214 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1215 return VOS_STATUS_SUCCESS;
1216
1217 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301218 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301219 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1220 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301221 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301222 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001223 return VOS_STATUS_SUCCESS;
1224
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001226 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 goto stopbss;
1228 return VOS_STATUS_SUCCESS;
1229 }
1230 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1231 return VOS_STATUS_SUCCESS;
1232
1233stopbss :
1234 {
1235 v_BYTE_t we_custom_event[64];
1236 char *stopBssEvent = "STOP-BSS.response";//17
1237 int event_len = strlen(stopBssEvent);
1238
1239 hddLog(LOG1, FL("BSS stop status = %s"),
1240 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1241 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1242
1243 /* Change the BSS state now since, as we are shutting things down,
1244 * we don't want interfaces to become re-enabled */
1245 pHostapdState->bssState = BSS_STOP;
1246
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301247 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1248 {
1249 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1250 {
1251 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1252 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1253 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1254 }
1255
1256 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1257 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1258 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1259 }
1260
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 /* Stop the pkts from n/w stack as we are going to free all of
1262 * the TX WMM queues for all STAID's */
1263 hdd_hostapd_stop(dev);
1264
1265 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301266 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1267 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1268 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
Amar Singhal37e6f052013-03-05 16:16:54 -08001270 /* once the event is set, structure dev/pHostapdAdapter should
1271 * not be touched since they are now subject to being deleted
1272 * by another thread */
1273 if (eSAP_STOP_BSS_EVENT == sapEvent)
1274 vos_event_set(&pHostapdState->vosEvent);
1275
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 /* notify userspace that the BSS has stopped */
1277 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1278 memcpy(&we_custom_event, stopBssEvent, event_len);
1279 memset(&wrqu, 0, sizeof(wrqu));
1280 wrqu.data.length = event_len;
1281 we_event = IWEVCUSTOM;
1282 we_custom_event_generic = we_custom_event;
1283 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001284 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 }
1286 return VOS_STATUS_SUCCESS;
1287}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001288
1289int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001291 eCsrEncryptionType *pEncryptType,
1292 eCsrEncryptionType *mcEncryptType,
1293 eCsrAuthType *pAuthType,
1294 v_BOOL_t *pMFPCapable,
1295 v_BOOL_t *pMFPRequired,
1296 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 u_int8_t *gen_ie )
1298{
1299 tDot11fIERSN dot11RSNIE;
1300 tDot11fIEWPA dot11WPAIE;
1301
1302 tANI_U8 *pRsnIe;
1303 tANI_U16 RSNIeLen;
1304
1305 if (NULL == halHandle)
1306 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001307 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 return -EINVAL;
1309 }
1310
1311 // Validity checks
1312 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1313 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1314 return -EINVAL;
1315 // Type check
1316 if ( gen_ie[0] == DOT11F_EID_RSN)
1317 {
1318 // Validity checks
1319 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1320 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1321 {
1322 return VOS_STATUS_E_FAILURE;
1323 }
1324 // Skip past the EID byte and length byte
1325 pRsnIe = gen_ie + 2;
1326 RSNIeLen = gen_ie_len - 2;
1327 // Unpack the RSN IE
1328 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1329 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1330 pRsnIe,
1331 RSNIeLen,
1332 &dot11RSNIE);
1333 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001334 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001335 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001336 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001337 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 /*Here we have followed the apple base code,
1339 but probably I suspect we can do something different*/
1340 //dot11RSNIE.akm_suite_count
1341 // Just translate the FIRST one
1342 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1343 //dot11RSNIE.pwise_cipher_suite_count
1344 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1345 //dot11RSNIE.gp_cipher_suite_count
1346 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1347 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001348 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1349 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001350
1351 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1352 } else
1353 if (gen_ie[0] == DOT11F_EID_WPA)
1354 {
1355 // Validity checks
1356 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1357 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1358 {
1359 return VOS_STATUS_E_FAILURE;
1360 }
1361 // Skip past the EID byte and length byte - and four byte WiFi OUI
1362 pRsnIe = gen_ie + 2 + 4;
1363 RSNIeLen = gen_ie_len - (2 + 4);
1364 // Unpack the WPA IE
1365 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1366 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1367 pRsnIe,
1368 RSNIeLen,
1369 &dot11WPAIE);
1370 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001371 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001372 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001373 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001374 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 //dot11WPAIE.auth_suite_count
1376 // Just translate the FIRST one
1377 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1378 //dot11WPAIE.unicast_cipher_count
1379 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1380 //dot11WPAIE.unicast_cipher_count
1381 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001382 *pMFPCapable = VOS_FALSE;
1383 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 }
1385 else
1386 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001387 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 return VOS_STATUS_E_FAILURE;
1389 }
1390 return VOS_STATUS_SUCCESS;
1391}
Leo Chang614d2072013-08-22 14:59:44 -07001392
Leo Chang0b0e45a2013-12-15 15:18:55 -08001393#ifdef FEATURE_WLAN_CH_AVOID
1394/**---------------------------------------------------------------------------
1395
1396 \brief hdd_hostapd_freq_to_chn() -
1397
1398 Input frequency translated into channel number
1399
1400 \param - freq input frequency with order of kHz
1401
1402 \return - corresponding channel number.
1403 incannot find correct channel number, return 0
1404
1405 --------------------------------------------------------------------------*/
1406v_U16_t hdd_hostapd_freq_to_chn
1407(
1408 v_U16_t freq
1409)
1410{
1411 int loop;
1412
1413 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1414 {
1415 if (rfChannels[loop].targetFreq == freq)
1416 {
1417 return rfChannels[loop].channelNum;
1418 }
1419 }
1420
1421 return (0);
1422}
1423
1424/*==========================================================================
1425 FUNCTION sapUpdateUnsafeChannelList
1426
1427 DESCRIPTION
1428 Function Undate unsafe channel list table
1429
1430 DEPENDENCIES
1431 NA.
1432
1433 PARAMETERS
1434
1435 IN
1436 pSapCtx : SAP context pointer, include unsafe channel list
1437
1438 RETURN VALUE
1439 NONE
1440============================================================================*/
1441void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1442 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1443{
1444 v_U16_t i, j;
1445
1446 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1447 sizeof(pHddCtx->unsafeChannelList));
1448 if (0 == unsafeChannelCount)
1449 {
1450 pHddCtx->unsafeChannelCount = 0;
1451 }
1452 else
1453 {
c_hpothu8de53e42014-08-22 15:00:37 +05301454 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1455 {
1456 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1457 FL("unsafeChannelCount%hd greater than %d"),
1458 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1459 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1460 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001461 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1462 unsafeChannelList,
1463 unsafeChannelCount * sizeof(tANI_U16));
1464 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1465 }
1466
1467 /* Flush, default set all channel safe */
1468 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1469 {
1470 safeChannels[i].isSafe = VOS_TRUE;
1471 }
1472
1473 /* Try to find unsafe channel */
1474 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1475 {
1476 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1477 {
1478 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1479 {
1480 /* Found unsafe channel, update it */
1481 safeChannels[j].isSafe = VOS_FALSE;
1482 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1483 "%s : CH %d is not safe",
1484 __func__, pHddCtx->unsafeChannelList[i]);
1485 break;
1486 }
1487 }
1488 }
1489
1490 return;
1491}
1492
1493/**---------------------------------------------------------------------------
1494
1495 \brief hdd_hostapd_ch_avoid_cb() -
1496
1497 Avoid channel notification from FW handler.
1498 FW will send un-safe channle list to avoid overwrapping.
1499 hostapd should not use notified channel
1500
1501 \param - pAdapter HDD adapter pointer
1502 indParam channel avoid notification parameter
1503
1504 \return - None
1505
1506 --------------------------------------------------------------------------*/
1507void hdd_hostapd_ch_avoid_cb
1508(
1509 void *pAdapter,
1510 void *indParam
1511)
1512{
1513 hdd_adapter_t *pHostapdAdapter = NULL;
1514 hdd_context_t *hddCtxt;
1515 tSirChAvoidIndType *chAvoidInd;
1516 v_U8_t rangeLoop;
1517 v_U16_t channelLoop;
1518 v_U16_t dupCheck;
1519 v_U16_t startChannel;
1520 v_U16_t endChannel;
1521 v_U16_t unsafeChannelCount = 0;
1522 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1523 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001524 tHddAvoidFreqList hddAvoidFreqList;
1525 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301526#ifdef WLAN_FEATURE_AP_HT40_24G
1527 ptSapContext pSapCtx = NULL;
1528 tHalHandle hHal;
1529 v_U8_t cbMode;
1530 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1531 v_U32_t delay;
1532#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001533
1534 /* Basic sanity */
1535 if ((NULL == pAdapter) || (NULL == indParam))
1536 {
1537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1538 "%s : Invalid arguments", __func__);
1539 return;
1540 }
1541
1542 hddCtxt = (hdd_context_t *)pAdapter;
1543 chAvoidInd = (tSirChAvoidIndType *)indParam;
1544 pVosContext = hddCtxt->pvosContext;
1545
1546 /* Make unsafe channel list */
1547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1548 "%s : band count %d",
1549 __func__, chAvoidInd->avoidRangeCount);
1550 vos_mem_zero((void *)unsafeChannelList,
1551 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1552 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1553 {
1554 startChannel = hdd_hostapd_freq_to_chn(
1555 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1556 endChannel = hdd_hostapd_freq_to_chn(
1557 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1559 "%s : start %d : %d, end %d : %d",
1560 __func__,
1561 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1562 startChannel,
1563 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1564 endChannel);
1565 for (channelLoop = startChannel;
1566 channelLoop < (endChannel + 1);
1567 channelLoop++)
1568 {
1569 /* Channel duplicate check routine */
1570 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1571 {
1572 if (unsafeChannelList[dupCheck] == channelLoop)
1573 {
1574 /* This channel is duplicated */
1575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1576 "%s : found duplicated channel %d",
1577 __func__, channelLoop);
1578 break;
1579 }
1580 }
1581 if (dupCheck == unsafeChannelCount)
1582 {
c_hpothu8de53e42014-08-22 15:00:37 +05301583 int ii;
1584 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1585 {
1586 if (channelLoop == safeChannels[ii].channelNumber)
1587 {
1588 unsafeChannelList[unsafeChannelCount] = channelLoop;
1589 unsafeChannelCount++;
1590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1591 "%s : unsafe channel %d, count %d",
1592 __func__,
1593 channelLoop, unsafeChannelCount);
1594 }
1595 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001596 }
1597 else
1598 {
1599 /* DUP, do nothing */
1600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1601 "%s : duplicated channel %d",
1602 __func__, channelLoop);
1603 }
1604 }
1605 }
1606 /* Update unsafe channel cache
1607 * WCN Platform Driver cache */
1608 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1609 unsafeChannelCount);
1610
1611 /* Store into local cache
1612 * Start with STA and later start SAP
1613 * in this scenario, local cache will be used */
1614 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1615 unsafeChannelList,
1616 unsafeChannelCount);
1617
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001618 /* generate vendor specific event */
1619 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1620 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1621 {
1622 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1623 chAvoidInd->avoidFreqRange[i].startFreq;
1624 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1625 chAvoidInd->avoidFreqRange[i].endFreq;
1626 }
1627 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1628
1629 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1630
Leo Chang0b0e45a2013-12-15 15:18:55 -08001631 /* Get SAP context first
1632 * SAP and P2PGO would not concurrent */
1633 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301634#ifdef WLAN_FEATURE_AP_HT40_24G
1635 if (NULL == pHostapdAdapter)
1636 {
1637 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1638 }
1639#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301640 if ((pHostapdAdapter) &&
1641 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1642 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001643 {
1644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1645 "%s : Current operation channel %d",
1646 __func__,
1647 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1648 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1649 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301650 if ((unsafeChannelList[channelLoop] ==
1651 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1652 {
1653 if ((AUTO_CHANNEL_SELECT ==
1654 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1655 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1656 {
1657 /* current operating channel is un-safe channel
1658 * restart driver */
1659 hdd_hostapd_stop(pHostapdAdapter->dev);
1660 /* On LE, this event is handled by wlan-services to
1661 * restart SAP. On android, this event would be
1662 * ignored.
1663 */
1664 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1665 NULL, 0);
1666 }
1667 return;
1668 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001669 }
1670 }
1671
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301672#ifdef WLAN_FEATURE_AP_HT40_24G
1673 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1674 {
1675 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1676
1677 if(pSapCtx == NULL)
1678 {
1679 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1680 FL("psapCtx is NULL"));
1681 return;
1682 }
1683
1684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1685 FL("SAP Secondary channel: %d "),
1686 pSapCtx->sap_sec_chan);
1687
1688 /* tHalHandle */
1689 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1690
1691 if (NULL == hHal)
1692 {
1693 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1694 FL("In invalid hHal"));
1695 return;
1696 }
1697
1698 cbMode = sme_GetChannelBondingMode24G(hHal);
1699
1700 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1701 FL("Selected Channel bonding : %d"), cbMode);
1702
1703 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1704 {
1705 int i;
1706 eHalStatus halStatus;
1707
1708 for (i = 0; i < unsafeChannelCount; i++)
1709 {
1710 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1711 {
1712 /* Current SAP Secondary channel is un-safe channel */
1713 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1714 FL("Move SAP from HT40 to HT20"));
1715
1716 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1717 PHY_SINGLE_CHANNEL_CENTERED);
1718
1719 if (halStatus == eHAL_STATUS_FAILURE)
1720 {
1721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1722 FL("Failed to change HT20/40 mode"));
1723 return;
1724 }
1725
1726 /* Disable Channel Bonding for 2.4GHz */
1727 sme_UpdateChannelBondingMode24G(hHal,
1728 PHY_SINGLE_CHANNEL_CENTERED);
1729 return;
1730 }
1731 }
1732 }
1733
1734 if ((!pSapCtx->numHT40IntoSta)
1735 && (pHostapdAdapter)
1736 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1737 {
1738 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1739 * are Safe then start HT20/40 timer to Move SAP from HT20
1740 * to HT40.
1741 */
1742 if (((!unsafeChannelCount)
1743 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1744 {
1745 /* Stop Previous Running HT20/40 Timer & Start timer
1746 with (OBSS TransitionDelayFactor * obss interval)
1747 delay after time out move AP from HT20 -> HT40
1748 mode
1749 */
1750 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1751 {
1752 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1753 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1754 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1755 FL("Failed to Stop HT20/40 timer"));
1756 }
1757
1758 delay =
1759 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1760
1761 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1762 FL("Start HT20/40 transition timer (%d sec)"), delay);
1763
1764 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1765 (delay * 1000));
1766
1767 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1768 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1769 FL("Failed to Start HT20/40 timer"));
1770 }
1771 else
1772 {
1773 /* Stop HT20/40 Timer */
1774 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1775 {
1776 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1777 FL("Stop HT20/40 transition timer"));
1778 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1779 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1780 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1781 FL("Failed to Stop HT20/40 timer"));
1782 }
1783 }
1784 }
1785 }
1786#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001787 return;
1788}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001789#endif /* FEATURE_WLAN_CH_AVOID */
1790
Jeff Johnson295189b2012-06-20 16:38:30 -07001791int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301792static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 struct iw_request_info *info,
1794 union iwreq_data *wrqu, char *extra)
1795{
1796 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001797 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301798 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 int *value = (int *)extra;
1800 int sub_cmd = value[0];
1801 int set_value = value[1];
1802 eHalStatus status;
1803 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001804 v_CONTEXT_t pVosContext;
1805
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301806 ENTER();
1807
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301808 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001809 {
1810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301811 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001812 __func__);
1813 return -1;
1814 }
1815
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301816 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1817 ret = wlan_hdd_validate_context(pHddCtx);
1818 if (0 != ret)
1819 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301820 return -1;
1821 }
1822
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001823 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1824 if (!hHal)
1825 {
1826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1827 "%s: Hal ctx is null", __func__);
1828 return -1;
1829 }
1830
1831 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1832 if (!pVosContext)
1833 {
1834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1835 "%s: Vos ctx is null", __func__);
1836 return -1;
1837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001838
1839 switch(sub_cmd)
1840 {
1841
1842 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001843 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001844 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301845 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 }
1847 break;
1848
1849 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301850 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1852 {
1853 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1854 ret = -EINVAL;
1855 }
1856 else
1857 {
1858 WLANSAP_SetMode(pVosContext, set_value);
1859 }
1860 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301861
1862 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1863 if ((0 != set_value) && (1 != set_value))
1864 {
1865 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1866 ret = -EINVAL;
1867 }
1868 else
1869 {
1870 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1871 }
1872 break;
1873
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 case QCSAP_PARAM_MAX_ASSOC:
1875 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1876 {
1877 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1878 ret = -EINVAL;
1879 }
1880 else
1881 {
1882 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1883 {
1884 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1885 "Setting it to max allowed and continuing"),
1886 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1887 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1888 }
1889 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1890 set_value, NULL, eANI_BOOLEAN_FALSE);
1891 if ( status != eHAL_STATUS_SUCCESS )
1892 {
1893 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1894 status);
1895 ret = -EIO;
1896 }
1897 }
1898 break;
1899
1900 case QCSAP_PARAM_HIDE_SSID:
1901 {
1902 eHalStatus status = eHAL_STATUS_SUCCESS;
1903 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1904 if(eHAL_STATUS_SUCCESS != status)
1905 {
1906 hddLog(VOS_TRACE_LEVEL_ERROR,
1907 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001908 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 return status;
1910 }
1911 break;
1912 }
1913
Leo Chang614d2072013-08-22 14:59:44 -07001914 case QCSAP_PARAM_SET_MC_RATE:
1915 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001916 tSirRateUpdateInd *rateUpdate;
1917
1918 rateUpdate = (tSirRateUpdateInd *)
1919 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1920 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001921 {
1922 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001923 "%s: SET_MC_RATE indication alloc fail", __func__);
1924 ret = -1;
1925 break;
1926 }
1927 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1928
1929 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1930 /* Ignore unicast */
1931 rateUpdate->ucastDataRate = -1;
1932 rateUpdate->mcastDataRate24GHz = set_value;
1933 rateUpdate->mcastDataRate5GHz = set_value;
1934 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1935 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1936 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1937 if (eHAL_STATUS_SUCCESS != status)
1938 {
1939 hddLog(VOS_TRACE_LEVEL_ERROR,
1940 "%s: SET_MC_RATE failed", __func__);
1941 vos_mem_free(rateUpdate);
1942 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001943 }
1944 break;
1945 }
1946
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 default:
1948 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1949 sub_cmd, set_value);
1950 ret = -EINVAL;
1951 break;
1952 }
1953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301954 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 return ret;
1956}
1957
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301958int
1959static iw_softap_setparam(struct net_device *dev,
1960 struct iw_request_info *info,
1961 union iwreq_data *wrqu, char *extra)
1962{
1963 int ret;
1964
1965 vos_ssr_protect(__func__);
1966 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1967 vos_ssr_unprotect(__func__);
1968
1969 return ret;
1970}
Jeff Johnson295189b2012-06-20 16:38:30 -07001971
1972int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301973static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 struct iw_request_info *info,
1975 union iwreq_data *wrqu, char *extra)
1976{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301977 hdd_adapter_t *pHostapdAdapter;
1978 tHalHandle hHal;
1979 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 int *value = (int *)extra;
1981 int sub_cmd = value[0];
1982 eHalStatus status;
1983 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301984 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001985
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301986 ENTER();
1987
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301988 pHostapdAdapter = (netdev_priv(dev));
1989 if (NULL == pHostapdAdapter)
1990 {
1991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1992 "%s: Adapter is NULL",__func__);
1993 return -EINVAL;
1994 }
1995 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1996 ret = wlan_hdd_validate_context(pHddCtx);
1997 if (0 != ret)
1998 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301999 return ret;
2000 }
2001 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2002 if (NULL == hHal)
2003 {
2004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2005 "%s: Hal Context is NULL",__func__);
2006 return -EINVAL;
2007 }
2008 pVosContext = pHddCtx->pvosContext;
2009 if (NULL == pVosContext)
2010 {
2011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2012 "%s: pVosContext Context is NULL",__func__);
2013 return -EINVAL;
2014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 switch (sub_cmd)
2016 {
2017 case QCSAP_PARAM_MAX_ASSOC:
2018 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2019 if (eHAL_STATUS_SUCCESS != status)
2020 {
c_hpothuffdb5272013-10-02 16:42:35 +05302021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2022 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 ret = -EIO;
2024 }
Girish Gowli385be612014-09-18 11:17:20 +05302025
2026#ifdef WLAN_SOFTAP_VSTA_FEATURE
2027 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2028 {
2029 if (*value > VSTA_NUM_ASSOC_STA)
2030 {
2031 *value = VSTA_NUM_ASSOC_STA;
2032 }
2033 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2034 (*value > (VSTA_NUM_ASSOC_STA -
2035 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2036 {
2037 *value = (VSTA_NUM_ASSOC_STA -
2038 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2039 }
2040 }
2041 else
2042#endif
2043 {
2044 if (*value > NUM_ASSOC_STA)
2045 {
2046 *value = NUM_ASSOC_STA;
2047 }
2048 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2049 (*value > (NUM_ASSOC_STA -
2050 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2051 {
2052 *value = (NUM_ASSOC_STA -
2053 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2054 }
2055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302057
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002059 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 {
c_hpothuffdb5272013-10-02 16:42:35 +05302061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2062 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302063 ret = -EIO;
2064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 *value = 0;
2066 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302067
Jeff Johnson43971f52012-07-17 12:26:56 -07002068 case QCSAP_PARAM_GET_WLAN_DBG:
2069 {
2070 vos_trace_display();
2071 *value = 0;
2072 break;
2073 }
2074
2075 case QCSAP_PARAM_AUTO_CHANNEL:
2076 {
2077 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2078 break;
2079 }
2080
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 default:
2082 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2083 ret = -EINVAL;
2084 break;
2085
2086 }
2087
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302088 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 return ret;
2090}
2091
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302092int
2093static iw_softap_getparam(struct net_device *dev,
2094 struct iw_request_info *info,
2095 union iwreq_data *wrqu, char *extra)
2096{
2097 int ret;
2098
2099 vos_ssr_protect(__func__);
2100 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2101 vos_ssr_unprotect(__func__);
2102
2103 return ret;
2104}
Jeff Johnson295189b2012-06-20 16:38:30 -07002105/* Usage:
2106 BLACK_LIST = 0
2107 WHITE_LIST = 1
2108 ADD MAC = 0
2109 REMOVE MAC = 1
2110
2111 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2112 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2113 while using this ioctl
2114
2115 Syntax:
2116 iwpriv softap.0 modify_acl
2117 <6 octet mac addr> <list type> <cmd type>
2118
2119 Examples:
2120 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2121 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2122 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2123 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2124*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302125int __iw_softap_modify_acl(struct net_device *dev,
2126 struct iw_request_info *info,
2127 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002128{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302129 hdd_adapter_t *pHostapdAdapter;
2130 v_CONTEXT_t pVosContext;
2131 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 v_BYTE_t *value = (v_BYTE_t*)extra;
2133 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2134 int listType, cmd, i;
2135 int ret = 0; /* success */
2136
2137 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302138 pHostapdAdapter = (netdev_priv(dev));
2139 if (NULL == pHostapdAdapter)
2140 {
2141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2142 "%s: Adapter is NULL",__func__);
2143 return -EINVAL;
2144 }
2145 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2146 ret = wlan_hdd_validate_context(pHddCtx);
2147 if (0 != ret)
2148 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302149 return ret;
2150 }
2151 pVosContext = pHddCtx->pvosContext;
2152 if (NULL == pVosContext)
2153 {
2154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2155 "%s: Vos Context is NULL",__func__);
2156 return -EINVAL;
2157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2159 {
2160 pPeerStaMac[i] = *(value+i);
2161 }
2162 listType = (int)(*(value+i));
2163 i++;
2164 cmd = (int)(*(value+i));
2165
Arif Hussain24bafea2013-11-15 15:10:03 -08002166 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2167 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002168
2169 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2170 != VOS_STATUS_SUCCESS)
2171 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002172 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 ret = -EIO;
2174 }
2175 EXIT();
2176 return ret;
2177}
2178
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302179int iw_softap_modify_acl(struct net_device *dev,
2180 struct iw_request_info *info,
2181 union iwreq_data *wrqu, char *extra)
2182{
2183 int ret;
2184
2185 vos_ssr_protect(__func__);
2186 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2187 vos_ssr_unprotect(__func__);
2188
2189 return ret;
2190}
2191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302193static __iw_softap_getchannel(struct net_device *dev,
2194 struct iw_request_info *info,
2195 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002196{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302197 hdd_adapter_t *pHostapdAdapter;
2198 hdd_context_t *pHddCtx;
2199 int ret = 0;
2200 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302201
2202 ENTER();
2203
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302204 pHostapdAdapter = (netdev_priv(dev));
2205 if (NULL == pHostapdAdapter)
2206 {
2207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2208 "%s: Adapter is NULL",__func__);
2209 return -EINVAL;
2210 }
2211 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2212 ret = wlan_hdd_validate_context(pHddCtx);
2213 if (0 != ret)
2214 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302215 return ret;
2216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002217
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302218 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219
Jeff Johnson43971f52012-07-17 12:26:56 -07002220 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302221
2222 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 return 0;
2224}
2225
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302226
Jeff Johnsone7245742012-09-05 17:12:55 -07002227int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302228static iw_softap_getchannel(struct net_device *dev,
2229 struct iw_request_info *info,
2230 union iwreq_data *wrqu, char *extra)
2231{
2232 int ret;
2233
2234 vos_ssr_protect(__func__);
2235 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2236 vos_ssr_unprotect(__func__);
2237
2238 return ret;
2239}
2240
2241int
2242static __iw_softap_set_max_tx_power(struct net_device *dev,
2243 struct iw_request_info *info,
2244 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002245{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302246 hdd_adapter_t *pHostapdAdapter;
2247 tHalHandle hHal;
2248 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002249 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302250 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002251 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2252 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2253
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302254 ENTER();
2255
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302256 pHostapdAdapter = (netdev_priv(dev));
2257 if (NULL == pHostapdAdapter)
2258 {
2259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2260 "%s: Adapter is NULL",__func__);
2261 return -EINVAL;
2262 }
2263 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2264 ret = wlan_hdd_validate_context(pHddCtx);
2265 if (0 != ret)
2266 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302267 return ret;
2268 }
2269 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2270 if (NULL == hHal)
2271 {
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2273 "%s: Hal Context is NULL",__func__);
2274 return -EINVAL;
2275 }
schang86c22c42013-03-13 18:41:24 -07002276 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002277 return -ENOMEM;
2278
Leo Changd37675a2013-08-01 13:19:45 -07002279 /* Assign correct slef MAC address */
2280 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2281 VOS_MAC_ADDR_SIZE);
2282 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2283 VOS_MAC_ADDR_SIZE);
2284
schang86c22c42013-03-13 18:41:24 -07002285 set_value = value[0];
2286 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2287 {
2288 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002289 __func__);
schang86c22c42013-03-13 18:41:24 -07002290 return -EIO;
2291 }
2292
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302293 EXIT();
schang86c22c42013-03-13 18:41:24 -07002294 return 0;
2295}
2296
2297int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302298static iw_softap_set_max_tx_power(struct net_device *dev,
2299 struct iw_request_info *info,
2300 union iwreq_data *wrqu, char *extra)
2301{
2302 int ret;
2303
2304 vos_ssr_protect(__func__);
2305 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2306 vos_ssr_unprotect(__func__);
2307
2308 return ret;
2309}
2310
2311
2312int
2313static __iw_display_data_path_snapshot(struct net_device *dev,
2314 struct iw_request_info *info,
2315 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302316{
2317
2318 /* Function intitiating dumping states of
2319 * HDD(WMM Tx Queues)
2320 * TL State (with Per Client infor)
2321 * DXE Snapshot (Called at the end of TL Snapshot)
2322 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302323 hdd_adapter_t *pHostapdAdapter;
2324 hdd_context_t *pHddCtx;
2325 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302326
2327 ENTER();
2328
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302329 pHostapdAdapter = (netdev_priv(dev));
2330 if (NULL == pHostapdAdapter)
2331 {
2332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2333 "%s: Adapter is NULL",__func__);
2334 return -EINVAL;
2335 }
2336 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2337 ret = wlan_hdd_validate_context(pHddCtx);
2338 if (0 != ret)
2339 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302340 return ret;
2341 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302342 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302343 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302344
2345 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302346 return 0;
2347}
2348
2349int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302350static iw_display_data_path_snapshot(struct net_device *dev,
2351 struct iw_request_info *info,
2352 union iwreq_data *wrqu, char *extra)
2353{
2354 int ret;
2355
2356 vos_ssr_protect(__func__);
2357 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2358 vos_ssr_unprotect(__func__);
2359
2360 return ret;
2361}
2362
2363int
2364static __iw_softap_set_tx_power(struct net_device *dev,
2365 struct iw_request_info *info,
2366 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002367{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302368 hdd_adapter_t *pHostapdAdapter;
2369 hdd_context_t *pHddCtx;
2370 v_CONTEXT_t pVosContext;
2371 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002372 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302373 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002374 ptSapContext pSapCtx = NULL;
2375
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302376 ENTER();
2377
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302378 pHostapdAdapter = (netdev_priv(dev));
2379 if (NULL == pHostapdAdapter)
2380 {
2381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2382 "%s: Adapter is NULL",__func__);
2383 return -EINVAL;
2384 }
2385 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2386 ret = wlan_hdd_validate_context(pHddCtx);
2387 if (0 != ret)
2388 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302389 return ret;
2390 }
2391 pVosContext = pHddCtx->pvosContext;
2392 if (NULL == pVosContext)
2393 {
2394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2395 "%s: Vos Context is NULL",__func__);
2396 return -EINVAL;
2397 }
2398 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2399 if (NULL == hHal)
2400 {
2401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2402 "%s: Hal Context is NULL",__func__);
2403 return -EINVAL;
2404 }
schang86c22c42013-03-13 18:41:24 -07002405 if (NULL == value)
2406 return -ENOMEM;
2407
2408 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2409 if (NULL == pSapCtx)
2410 {
2411 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2412 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2413 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002414 }
2415
2416 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002417 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002418 {
schang86c22c42013-03-13 18:41:24 -07002419 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002420 __func__);
2421 return -EIO;
2422 }
2423
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302424 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002425 return 0;
2426}
2427
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302428int
2429static iw_softap_set_tx_power(struct net_device *dev,
2430 struct iw_request_info *info,
2431 union iwreq_data *wrqu, char *extra)
2432{
2433 int ret;
2434
2435 vos_ssr_protect(__func__);
2436 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2437 vos_ssr_unprotect(__func__);
2438
2439 return ret;
2440}
2441
Kiet Lambcf38522013-10-26 18:28:27 +05302442/**---------------------------------------------------------------------------
2443
2444 \brief iw_softap_set_trafficmonitor() -
2445 This function dynamically enable/disable traffic monitor functonality
2446 the command iwpriv wlanX setTrafficMon <value>.
2447
2448 \param - dev - Pointer to the net device.
2449 - addr - Pointer to the sockaddr.
2450 \return - 0 for success, non zero for failure
2451
2452 --------------------------------------------------------------------------*/
2453
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302454static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2455 struct iw_request_info *info,
2456 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302457{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302458 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302459 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302460 hdd_context_t *pHddCtx;
2461 int status;
2462
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302463 ENTER();
2464
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302465 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302466 if (NULL == pAdapter)
2467 {
2468 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2469 "%s: HDD adapter is Null", __func__);
2470 return -ENODEV;
2471 }
2472
2473 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2474
2475 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302476 if (0 != status)
2477 {
Kiet Lambcf38522013-10-26 18:28:27 +05302478 return status;
2479 }
2480
2481 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2482
2483 if (NULL == isSetTrafficMon)
2484 {
2485 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2486 "%s: Invalid SAP pointer from extra", __func__);
2487 return -ENOMEM;
2488 }
2489
2490 if (TRUE == *isSetTrafficMon)
2491 {
2492 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2493 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2494 {
2495 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2496 "%s: failed to Start Traffic Monitor timer ", __func__ );
2497 return -EIO;
2498 }
2499 }
2500 else if (FALSE == *isSetTrafficMon)
2501 {
2502 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2503 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2504 {
2505 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2506 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2507 return -EIO;
2508 }
2509
2510 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302511
2512 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302513 return 0;
2514}
2515
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302516static int iw_softap_set_trafficmonitor(struct net_device *dev,
2517 struct iw_request_info *info,
2518 union iwreq_data *wrqu, char *extra)
2519{
2520 int ret;
2521
2522 vos_ssr_protect(__func__);
2523 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2524 vos_ssr_unprotect(__func__);
2525
2526 return ret;
2527}
2528
Jeff Johnson295189b2012-06-20 16:38:30 -07002529#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2530
2531int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302532static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2533 struct iw_request_info *info,
2534 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002535{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302536 hdd_adapter_t *pHostapdAdapter;
2537 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302538 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002539 char *buf;
2540 int cnt = 0;
2541 int left;
2542 int ret = 0;
2543 /* maclist_index must be u32 to match userspace */
2544 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302545 v_CONTEXT_t pVosContext = NULL;
2546 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302547
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302548 ENTER();
2549
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302550 pHostapdAdapter = (netdev_priv(dev));
2551 if (NULL == pHostapdAdapter)
2552 {
2553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2554 "%s: Adapter is NULL",__func__);
2555 return -EINVAL;
2556 }
2557 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2558 ret = wlan_hdd_validate_context(pHddCtx);
2559 if (0 != ret)
2560 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302561 return ret;
2562 }
2563
Jeff Johnson224f3702014-03-26 11:09:47 -07002564 /*
2565 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2566 * number, and even numbered iocts are supposed to have "set"
2567 * semantics. Hence the wireless extensions support in the kernel
2568 * won't correctly copy the result to userspace, so the ioctl
2569 * handler itself must copy the data. Output format is 32-bit
2570 * record length, followed by 0 or more 6-byte STA MAC addresses.
2571 *
2572 * Further note that due to the incorrect semantics, the "iwpriv"
2573 * userspace application is unable to correctly invoke this API,
2574 * hence it is not registered in the hostapd_private_args. This
2575 * API can only be invoked by directly invoking the ioctl() system
2576 * call.
2577 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002578
Jeff Johnson224f3702014-03-26 11:09:47 -07002579 /* make sure userspace allocated a reasonable buffer size */
2580 if (wrqu->data.length < sizeof(maclist_index)) {
2581 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2582 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302585 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2586 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2587 if(pSapCtx == NULL){
2588 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2589 FL("psapCtx is NULL"));
2590 return -EFAULT;
2591 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302592
2593 /* allocate local buffer to build the response */
2594 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2595 if (!buf) {
2596 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2597 return -ENOMEM;
2598 }
2599
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302600 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002601 /* start indexing beyond where the record count will be written */
2602 maclist_index = sizeof(maclist_index);
2603 left = wrqu->data.length - maclist_index;
2604
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302605 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002606 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2607 if ((pStaInfo[cnt].isUsed) &&
2608 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2609 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2610 VOS_MAC_ADDR_SIZE);
2611 maclist_index += VOS_MAC_ADDR_SIZE;
2612 left -= VOS_MAC_ADDR_SIZE;
2613 }
2614 cnt++;
2615 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302616 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002617
2618 *((u32 *)buf) = maclist_index;
2619 wrqu->data.length = maclist_index;
2620 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2621 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2622 ret = -EFAULT;
2623 }
2624 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302625
2626 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002627 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002628}
2629
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302630int
2631static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2632 struct iw_request_info *info,
2633 union iwreq_data *wrqu, char *extra)
2634{
2635 int ret;
2636
2637 vos_ssr_protect(__func__);
2638 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2639 vos_ssr_unprotect(__func__);
2640
2641 return ret;
2642}
2643
Jeff Johnson295189b2012-06-20 16:38:30 -07002644/* Usage:
2645 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2646 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2647 while using this ioctl
2648
2649 Syntax:
2650 iwpriv softap.0 disassoc_sta <6 octet mac address>
2651
2652 e.g.
2653 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2654 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2655*/
2656
2657int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302658static __iw_softap_disassoc_sta(struct net_device *dev,
2659 struct iw_request_info *info,
2660 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002661{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302662 hdd_adapter_t *pHostapdAdapter;
2663 hdd_context_t *pHddCtx;
2664 v_U8_t *peerMacAddr;
2665 int ret = 0;
2666
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302668 pHostapdAdapter = (netdev_priv(dev));
2669 if (NULL == pHostapdAdapter)
2670 {
2671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2672 "%s: Adapter is NULL",__func__);
2673 return -EINVAL;
2674 }
2675 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2676 ret = wlan_hdd_validate_context(pHddCtx);
2677 if (0 != ret)
2678 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302679 return ret;
2680 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302681 /* iwpriv tool or framework calls this ioctl with
2682 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302684 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002685
Arif Hussain24bafea2013-11-15 15:10:03 -08002686 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2687 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2689 EXIT();
2690 return 0;
2691}
2692
2693int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302694static iw_softap_disassoc_sta(struct net_device *dev,
2695 struct iw_request_info *info,
2696 union iwreq_data *wrqu, char *extra)
2697{
2698 int ret;
2699
2700 vos_ssr_protect(__func__);
2701 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2702 vos_ssr_unprotect(__func__);
2703
2704 return ret;
2705}
2706
2707int
2708static __iw_softap_ap_stats(struct net_device *dev,
2709 struct iw_request_info *info,
2710 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002711{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302712 hdd_adapter_t *pHostapdAdapter;
2713 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 WLANTL_TRANSFER_STA_TYPE statBuffer;
2715 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302716 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302718 ENTER();
2719
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302720 pHostapdAdapter = (netdev_priv(dev));
2721 if (NULL == pHostapdAdapter)
2722 {
2723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2724 "%s: Adapter is NULL",__func__);
2725 return -EINVAL;
2726 }
2727 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2728 ret = wlan_hdd_validate_context(pHddCtx);
2729 if (0 != ret)
2730 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302731 return ret;
2732 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002733 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002734 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2735 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002736
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302737 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002738 if(NULL == pstatbuf) {
2739 hddLog(LOG1, "unable to allocate memory");
2740 return -ENOMEM;
2741 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302742
2743 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002744 "RUF=%d RMF=%d RBF=%d "
2745 "RUB=%d RMB=%d RBB=%d "
2746 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302747 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002748 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2749 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2750 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2751 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2752 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2753 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002754
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302755 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002756 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2757 kfree(pstatbuf);
2758 return -EFAULT;
2759 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302760
2761 strlcpy(extra, pstatbuf, len);
2762 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002763 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302764
2765 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 return 0;
2767}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302768int
2769static __iw_softap_ap_get_stats(struct net_device *dev,
2770 struct iw_request_info *info,
2771 union iwreq_data *wrqu, char *extra)
2772{
2773 hdd_adapter_t *pAdapter;
2774 hdd_tx_rx_stats_t *pStats;
2775
2776 ENTER();
2777 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2778 if (NULL == pAdapter)
2779 {
2780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2781 "%s: Adapter is NULL",__func__);
2782 return -EINVAL;
2783 }
2784
2785 pStats = &pAdapter->hdd_stats.hddTxRxStats;
2786 snprintf(extra, QCSAP_MAX_STR_LEN,
2787 "\nTransmit"
2788 "\ncalled %u, dropped %u, backpressured %u, queued %u"
2789 "\n dropped BK %u, BE %u, VI %u, VO %u"
2790 "\n classified BK %u, BE %u, VI %u, VO %u"
2791 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
2792 "\n queued BK %u, BE %u, VI %u, VO %u"
2793 "\nfetched %u, empty %u, lowres %u, deqerr %u"
2794 "\ndequeued %u, depressured %u, deque-depressured %u,\
2795 completed %u, flushed %u"
2796 "\n fetched BK %u, BE %u, VI %u, VO %u"
2797 "\n dequeued BK %u, BE %u, VI %u, VO %u"
2798 "\n depressured BK %u, BE %u, VI %u, VO %u"
2799 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
2800 "\n flushed BK %u, BE %u, VI %u, VO %u"
2801 "\n\nReceive"
2802 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
2803 "\n\nResetsStats"
2804 "\n",
2805 pStats->txXmitCalled,
2806 pStats->txXmitDropped,
2807 pStats->txXmitBackPressured,
2808 pStats->txXmitQueued,
2809
2810 pStats->txXmitDroppedAC[WLANTL_AC_BK],
2811 pStats->txXmitDroppedAC[WLANTL_AC_BE],
2812 pStats->txXmitDroppedAC[WLANTL_AC_VI],
2813 pStats->txXmitDroppedAC[WLANTL_AC_VO],
2814
2815 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
2816 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
2817 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
2818 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
2819
2820 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
2821 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
2822 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
2823 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
2824
2825 pStats->txXmitQueuedAC[WLANTL_AC_BK],
2826 pStats->txXmitQueuedAC[WLANTL_AC_BE],
2827 pStats->txXmitQueuedAC[WLANTL_AC_VI],
2828 pStats->txXmitQueuedAC[WLANTL_AC_VO],
2829
2830 pStats->txFetched,
2831 pStats->txFetchEmpty,
2832 pStats->txFetchLowResources,
2833 pStats->txFetchDequeueError,
2834
2835 pStats->txFetchDequeued,
2836 pStats->txFetchDePressured,
2837 pStats->txDequeDePressured,
2838 pStats->txCompleted,
2839 pStats->txFlushed,
2840
2841 pStats->txFetchedAC[WLANTL_AC_BK],
2842 pStats->txFetchedAC[WLANTL_AC_BE],
2843 pStats->txFetchedAC[WLANTL_AC_VI],
2844 pStats->txFetchedAC[WLANTL_AC_VO],
2845
2846 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
2847 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
2848 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
2849 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
2850
2851 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
2852 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
2853 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
2854 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
2855
2856 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
2857 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
2858 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
2859 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
2860
2861 pStats->txFlushedAC[WLANTL_AC_BK],
2862 pStats->txFlushedAC[WLANTL_AC_BE],
2863 pStats->txFlushedAC[WLANTL_AC_VI],
2864 pStats->txFlushedAC[WLANTL_AC_VO],
2865
2866 pStats->rxChains,
2867 pStats->rxPackets,
2868 pStats->rxDropped,
2869 pStats->rxDelivered,
2870 pStats->rxRefused
2871 );
2872
2873 wrqu->data.length = strlen(extra) + 1;
2874
2875 return 0;
2876}
2877
2878int
2879static __iw_softap_ap_clear_stats(struct net_device *dev,
2880 struct iw_request_info *info,
2881 union iwreq_data *wrqu, char *extra)
2882{
2883 hdd_adapter_t *pAdapter;
2884
2885 ENTER();
2886
2887 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2888 if (NULL == pAdapter)
2889 {
2890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2891 "%s: Adapter is NULL",__func__);
2892 return -EINVAL;
2893 }
2894
2895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
2896 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
2897 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
2898 return 0;
2899}
2900
2901
2902int
2903static iw_softap_get_stats(struct net_device *dev,
2904 struct iw_request_info *info,
2905 union iwreq_data *wrqu, char *extra)
2906{
2907 int ret;
2908 vos_ssr_protect(__func__);
2909 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
2910 vos_ssr_unprotect(__func__);
2911 return ret;
2912}
2913
2914int
2915static iw_softap_clear_stats(struct net_device *dev,
2916 struct iw_request_info *info,
2917 union iwreq_data *wrqu, char *extra)
2918{
2919 int ret;
2920 vos_ssr_protect(__func__);
2921 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
2922 vos_ssr_unprotect(__func__);
2923 return ret;
2924}
Jeff Johnson295189b2012-06-20 16:38:30 -07002925
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302926int
2927static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 struct iw_request_info *info,
2929 union iwreq_data *wrqu, char *extra)
2930{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302931 int ret;
2932
2933 vos_ssr_protect(__func__);
2934 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2935 vos_ssr_unprotect(__func__);
2936
2937 return ret;
2938}
2939
2940static int __iw_softap_set_channel_range(struct net_device *dev,
2941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
2943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302944 hdd_adapter_t *pHostapdAdapter;
2945 tHalHandle hHal;
2946 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 int *value = (int *)extra;
2948 int startChannel = value[0];
2949 int endChannel = value[1];
2950 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002951 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 int ret = 0; /* success */
2953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302954 ENTER();
2955
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302956 pHostapdAdapter = (netdev_priv(dev));
2957 if (NULL == pHostapdAdapter)
2958 {
2959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2960 "%s: Adapter is NULL",__func__);
2961 return -EINVAL;
2962 }
2963 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2964 ret = wlan_hdd_validate_context(pHddCtx);
2965 if (0 != ret)
2966 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302967 return ret;
2968 }
2969 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2970 if (NULL == hHal)
2971 {
2972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2973 "%s: Hal Context is NULL",__func__);
2974 return -EINVAL;
2975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2977 if(status != VOS_STATUS_SUCCESS)
2978 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002979 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 startChannel,endChannel, band);
2981 ret = -EINVAL;
2982 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002983
2984 pHddCtx->is_dynamic_channel_range_set = 1;
2985
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302986 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 return ret;
2988}
2989
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302990static int iw_softap_set_channel_range(struct net_device *dev,
2991 struct iw_request_info *info,
2992 union iwreq_data *wrqu, char *extra)
2993{
2994 int ret;
2995
2996 vos_ssr_protect(__func__);
2997 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
2998 vos_ssr_unprotect(__func__);
2999
3000 return ret;
3001}
3002
3003
3004int __iw_softap_get_channel_list(struct net_device *dev,
3005 struct iw_request_info *info,
3006 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003007{
3008 v_U32_t num_channels = 0;
3009 v_U8_t i = 0;
3010 v_U8_t bandStartChannel = RF_CHAN_1;
3011 v_U8_t bandEndChannel = RF_CHAN_165;
3012 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303013 hdd_adapter_t *pHostapdAdapter;
3014 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003017 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303018 hdd_context_t *pHddCtx;
3019 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303020
3021 ENTER();
3022
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303023 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3024 if (NULL == pHostapdAdapter)
3025 {
3026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3027 "%s: Adapter is NULL",__func__);
3028 return -EINVAL;
3029 }
3030 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3031 ret = wlan_hdd_validate_context(pHddCtx);
3032 if (0 != ret)
3033 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303034 return ret;
3035 }
3036 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3037 if (NULL == hHal)
3038 {
3039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3040 "%s: Hal Context is NULL",__func__);
3041 return -EINVAL;
3042 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003043 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3044 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003045 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003046 return -EIO;
3047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 wrqu->data.length = sizeof(tChannelListInfo);
3049 ENTER();
3050
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003051 if (eCSR_BAND_24 == curBand)
3052 {
3053 bandStartChannel = RF_CHAN_1;
3054 bandEndChannel = RF_CHAN_14;
3055 }
3056 else if (eCSR_BAND_5G == curBand)
3057 {
3058 bandStartChannel = RF_CHAN_36;
3059 bandEndChannel = RF_CHAN_165;
3060 }
3061
Arif Hussain6d2a3322013-11-17 19:50:10 -08003062 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303063 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003064 bandStartChannel, bandEndChannel );
3065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3067 {
3068 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3069 {
3070 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3071 num_channels++;
3072 }
3073 }
3074
3075 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3076
3077 temp_num_channels = num_channels;
3078
3079 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3080 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303081 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003082 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 }
3084
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303085 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3086 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 {
3088 for(i = 0; i < temp_num_channels; i++)
3089 {
3090
3091 if((channel_list->channels[i] > 35) &&
3092 (channel_list->channels[i] < 49))
3093 {
3094 vos_mem_move(&channel_list->channels[i],
3095 &channel_list->channels[i+1],
3096 temp_num_channels - (i-1));
3097 num_channels--;
3098 temp_num_channels--;
3099 i--;
3100 }
3101 }
3102 }
3103
Arif Hussain6d2a3322013-11-17 19:50:10 -08003104 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003105
3106 if (num_channels > IW_MAX_FREQUENCIES)
3107 {
3108 num_channels = IW_MAX_FREQUENCIES;
3109 }
3110
3111 channel_list->num_channels = num_channels;
3112 EXIT();
3113
3114 return 0;
3115}
3116
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303117int iw_softap_get_channel_list(struct net_device *dev,
3118 struct iw_request_info *info,
3119 union iwreq_data *wrqu, char *extra)
3120{
3121 int ret;
3122
3123 vos_ssr_protect(__func__);
3124 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3125 vos_ssr_unprotect(__func__);
3126
3127 return ret;
3128}
3129
3130static
3131int __iw_get_genie(struct net_device *dev,
3132 struct iw_request_info *info,
3133 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003134{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303135 hdd_adapter_t *pHostapdAdapter;
3136 hdd_context_t *pHddCtx;
3137 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 eHalStatus status;
3139 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3140 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303141 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303142
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303144
3145 pHostapdAdapter = (netdev_priv(dev));
3146 if (NULL == pHostapdAdapter)
3147 {
3148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3149 "%s: Adapter is NULL",__func__);
3150 return -EINVAL;
3151 }
3152 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3153 ret = wlan_hdd_validate_context(pHddCtx);
3154 if (0 != ret)
3155 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303156 return ret;
3157 }
3158 pVosContext = pHddCtx->pvosContext;
3159 if (NULL == pVosContext)
3160 {
3161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3162 "%s: vos context is not valid ",__func__);
3163 return -EINVAL;
3164 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003165 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3167 status = WLANSap_getstationIE_information(pVosContext,
3168 &length,
3169 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003170 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3171 if (wrqu->data.length < length ||
3172 copy_to_user(wrqu->data.pointer,
3173 (v_VOID_t*)genIeBytes, length))
3174 {
3175 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3176 return -EFAULT;
3177 }
3178 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003179
Arif Hussain6d2a3322013-11-17 19:50:10 -08003180 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003181
3182
3183 EXIT();
3184 return 0;
3185}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303186
3187static
3188int iw_get_genie(struct net_device *dev,
3189 struct iw_request_info *info,
3190 union iwreq_data *wrqu, char *extra)
3191{
3192 int ret;
3193
3194 vos_ssr_protect(__func__);
3195 ret = __iw_get_genie(dev, info, wrqu, extra);
3196 vos_ssr_unprotect(__func__);
3197
3198 return ret;
3199}
3200
3201static
3202int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3203 struct iw_request_info *info,
3204 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003205{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303206 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003207 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303208 hdd_ap_ctx_t *pHddApCtx;
3209 hdd_context_t *pHddCtx;
3210 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303211
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003213
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303214 pHostapdAdapter = (netdev_priv(dev));
3215 if (NULL == pHostapdAdapter)
3216 {
3217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3218 "%s: Adapter is NULL",__func__);
3219 return -EINVAL;
3220 }
3221 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3222 ret = wlan_hdd_validate_context(pHddCtx);
3223 if (0 != ret)
3224 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303225 return ret;
3226 }
3227 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3228 if (NULL == pHddApCtx)
3229 {
3230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3231 "%s: AP context is NULL",__func__);
3232 return -EINVAL;
3233 }
3234
Arif Hussain6d2a3322013-11-17 19:50:10 -08003235 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003236 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3237
3238 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3239 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3240 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3241 WPSPBCProbeReqIEs.probeReqIELen);
3242 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3243 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3244 sizeof(v_MACADDR_t));
3245 if (copy_to_user(wrqu->data.pointer,
3246 (void *)&WPSPBCProbeReqIEs,
3247 sizeof(WPSPBCProbeReqIEs)))
3248 {
3249 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3250 return -EFAULT;
3251 }
3252 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003253 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003254 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 up(&pHddApCtx->semWpsPBCOverlapInd);
3256 EXIT();
3257 return 0;
3258}
3259
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303260static
3261int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3262 struct iw_request_info *info,
3263 union iwreq_data *wrqu, char *extra)
3264{
3265 int ret;
3266
3267 vos_ssr_protect(__func__);
3268 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3269 vos_ssr_unprotect(__func__);
3270
3271 return ret;
3272}
3273
Jeff Johnson295189b2012-06-20 16:38:30 -07003274/**---------------------------------------------------------------------------
3275
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303276 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 This function sets the auth type received from the wpa_supplicant.
3278
3279 \param - dev - Pointer to the net device.
3280 - info - Pointer to the iw_request_info.
3281 - wrqu - Pointer to the iwreq_data.
3282 - extra - Pointer to the data.
3283 \return - 0 for success, non zero for failure
3284
3285 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303286int __iw_set_auth_hostap(struct net_device *dev,
3287 struct iw_request_info *info,
3288 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003289{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303290 hdd_adapter_t *pAdapter;
3291 hdd_context_t *pHddCtx;
3292 hdd_wext_state_t *pWextState;
3293 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303294
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303296
3297 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3298 if (NULL == pAdapter)
3299 {
3300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3301 "%s: Adapter is NULL",__func__);
3302 return -EINVAL;
3303 }
3304
3305 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3306 ret = wlan_hdd_validate_context(pHddCtx);
3307 if (0 != ret)
3308 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303309 return ret;
3310 }
3311 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3312 if (NULL == pWextState)
3313 {
3314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3315 "%s: pWextState is NULL",__func__);
3316 return -EINVAL;
3317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 switch(wrqu->param.flags & IW_AUTH_INDEX)
3319 {
3320 case IW_AUTH_TKIP_COUNTERMEASURES:
3321 {
3322 if(wrqu->param.value) {
3323 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3324 "Counter Measure started %d", wrqu->param.value);
3325 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303326 }
3327 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3329 "Counter Measure stopped=%d", wrqu->param.value);
3330 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3331 }
3332
3333 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3334 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303337
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303339
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003340 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 wrqu->param.flags & IW_AUTH_INDEX);
3342 break;
3343 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303344
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 EXIT();
3346 return 0;
3347}
3348
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303349int iw_set_auth_hostap(struct net_device *dev,
3350 struct iw_request_info *info,
3351 union iwreq_data *wrqu,char *extra)
3352{
3353 int ret;
3354
3355 vos_ssr_protect(__func__);
3356 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3357 vos_ssr_unprotect(__func__);
3358
3359 return ret;
3360}
3361
3362static int __iw_set_ap_encodeext(struct net_device *dev,
3363 struct iw_request_info *info,
3364 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003365{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303366 hdd_adapter_t *pHostapdAdapter;
3367 v_CONTEXT_t pVosContext;
3368 hdd_context_t *pHddCtx;
3369 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003370 int retval = 0;
3371 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3373 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3374 int key_index;
3375 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303376 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003377// tCsrRoamRemoveKey RemoveKey;
3378 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303379
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303380 ENTER();
3381 pHostapdAdapter = (netdev_priv(dev));
3382 if (NULL == pHostapdAdapter)
3383 {
3384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3385 "%s: Adapter is NULL",__func__);
3386 return -EINVAL;
3387 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003388
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303389 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3390 retval = wlan_hdd_validate_context(pHddCtx);
3391 if (0 != retval)
3392 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303393 return retval;
3394 }
3395 pVosContext = pHddCtx->pvosContext;
3396 if (NULL == pVosContext)
3397 {
3398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3399 "%s: pVosContext is NULL",__func__);
3400 return -EINVAL;
3401 }
3402 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3403 if (NULL == pHddApCtx)
3404 {
3405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3406 "%s: AP Context is NULL",__func__);
3407 return -EINVAL;
3408 }
3409
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303411
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303413
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 /*Convert from 1-based to 0-based keying*/
3415 key_index--;
3416 }
3417 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303418#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 /*Set the encrytion type to NONE*/
3420#if 0
3421 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3422#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303423
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 RemoveKey.keyId = key_index;
3425 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3426 /*Key direction for group is RX only*/
3427 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3428 }
3429 else {
3430 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3431 }
3432 switch(ext->alg)
3433 {
3434 case IW_ENCODE_ALG_NONE:
3435 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3436 break;
3437 case IW_ENCODE_ALG_WEP:
3438 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3439 break;
3440 case IW_ENCODE_ALG_TKIP:
3441 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003442 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 case IW_ENCODE_ALG_CCMP:
3444 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3445 break;
3446 default:
3447 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3448 break;
3449 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003450 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 -07003451 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003453 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003455 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3456 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 {
3458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003459 __LINE__, vstatus );
3460 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003462#endif
3463 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003464
Jeff Johnson43971f52012-07-17 12:26:56 -07003465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003466
3467 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3468
3469 setKey.keyId = key_index;
3470 setKey.keyLength = ext->key_len;
3471
3472 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3473 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3474 }
3475
3476 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3477 /*Key direction for group is RX only*/
3478 setKey.keyDirection = eSIR_RX_ONLY;
3479 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3480 }
3481 else {
3482
3483 setKey.keyDirection = eSIR_TX_RX;
3484 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3485 }
3486 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3487 {
3488 setKey.keyDirection = eSIR_TX_DEFAULT;
3489 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3490 }
3491
3492 /*For supplicant pae role is zero*/
3493 setKey.paeRole = 0;
3494
3495 switch(ext->alg)
3496 {
3497 case IW_ENCODE_ALG_NONE:
3498 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3499 break;
3500
3501 case IW_ENCODE_ALG_WEP:
3502 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3503 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003504 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 break;
3506
3507 case IW_ENCODE_ALG_TKIP:
3508 {
3509 v_U8_t *pKey = &setKey.Key[0];
3510
3511 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3512
3513 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3514
3515 /*Supplicant sends the 32bytes key in this order
3516
3517 |--------------|----------|----------|
3518 | Tk1 |TX-MIC | RX Mic |
3519 |--------------|----------|----------|
3520 <---16bytes---><--8bytes--><--8bytes-->
3521
3522 */
3523 /*Sme expects the 32 bytes key to be in the below order
3524
3525 |--------------|----------|----------|
3526 | Tk1 |RX-MIC | TX Mic |
3527 |--------------|----------|----------|
3528 <---16bytes---><--8bytes--><--8bytes-->
3529 */
3530 /* Copy the Temporal Key 1 (TK1) */
3531 vos_mem_copy(pKey,ext->key,16);
3532
3533 /*Copy the rx mic first*/
3534 vos_mem_copy(&pKey[16],&ext->key[24],8);
3535
3536 /*Copy the tx mic */
3537 vos_mem_copy(&pKey[24],&ext->key[16],8);
3538
3539 }
3540 break;
3541
3542 case IW_ENCODE_ALG_CCMP:
3543 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3544 break;
3545
3546 default:
3547 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3548 break;
3549 }
3550
3551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303552 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 setKey.keyId);
3554 for(i=0; i< ext->key_len; i++)
3555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3556 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003557
3558 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3559 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 {
3561 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003562 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3563 retval = -EINVAL;
3564 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303565
3566 EXIT();
3567 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003568}
Jeff Johnson43971f52012-07-17 12:26:56 -07003569
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303570static int iw_set_ap_encodeext(struct net_device *dev,
3571 struct iw_request_info *info,
3572 union iwreq_data *wrqu, char *extra)
3573{
3574 int ret;
3575
3576 vos_ssr_protect(__func__);
3577 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3578 vos_ssr_unprotect(__func__);
3579
3580 return ret;
3581}
Jeff Johnson43971f52012-07-17 12:26:56 -07003582
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303583static int __iw_set_ap_mlme(struct net_device *dev,
3584 struct iw_request_info *info,
3585 union iwreq_data *wrqu,
3586 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003587{
3588#if 0
3589 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3590 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3591
3592 ENTER();
3593
3594 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3595 switch (mlme->cmd) {
3596 case IW_MLME_DISASSOC:
3597 case IW_MLME_DEAUTH:
3598 hddLog(LOG1, "Station disassociate");
3599 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3600 {
3601 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3602
3603 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3604 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3605
3606 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3607
3608 //clear all the reason codes
3609 if (status != 0)
3610 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003611 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 }
3613
3614 netif_stop_queue(dev);
3615 netif_carrier_off(dev);
3616 }
3617 else
3618 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003619 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 -07003620 }
3621 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003622 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 return -EINVAL;
3624 }//end of switch
3625 EXIT();
3626#endif
3627 return 0;
3628// return status;
3629}
3630
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303631static int iw_set_ap_mlme(struct net_device *dev,
3632 struct iw_request_info *info,
3633 union iwreq_data *wrqu,
3634 char *extra)
3635{
3636 int ret;
3637
3638 vos_ssr_protect(__func__);
3639 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3640 vos_ssr_unprotect(__func__);
3641
3642 return ret;
3643}
3644
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303645static int __iw_get_ap_rts_threshold(struct net_device *dev,
3646 struct iw_request_info *info,
3647 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003648{
3649 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3650 v_U32_t status = 0;
3651
3652 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3653
3654 return status;
3655}
3656
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303657static int iw_get_ap_rts_threshold(struct net_device *dev,
3658 struct iw_request_info *info,
3659 union iwreq_data *wrqu, char *extra)
3660{
3661 int ret;
3662
3663 vos_ssr_protect(__func__);
3664 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3665 vos_ssr_unprotect(__func__);
3666
3667 return ret;
3668}
3669
3670static int __iw_get_ap_frag_threshold(struct net_device *dev,
3671 struct iw_request_info *info,
3672 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003673{
3674 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3675 v_U32_t status = 0;
3676
3677 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3678
3679 return status;
3680}
3681
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303682static int iw_get_ap_frag_threshold(struct net_device *dev,
3683 struct iw_request_info *info,
3684 union iwreq_data *wrqu, char *extra)
3685{
3686 int ret;
3687
3688 vos_ssr_protect(__func__);
3689 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3690 vos_ssr_unprotect(__func__);
3691
3692 return ret;
3693}
3694
3695static int __iw_get_ap_freq(struct net_device *dev,
3696 struct iw_request_info *info,
3697 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698{
Jeff Johnsone7245742012-09-05 17:12:55 -07003699 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303700 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 tHalHandle hHal;
3702 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303703 hdd_ap_ctx_t *pHddApCtx;
3704 hdd_context_t *pHddCtx;
3705 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003706
3707 ENTER();
3708
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303709 pHostapdAdapter = (netdev_priv(dev));
3710 if (NULL == pHostapdAdapter)
3711 {
3712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3713 "%s: Adapter is NULL",__func__);
3714 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303716 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3717 ret = wlan_hdd_validate_context(pHddCtx);
3718 if (0 != ret)
3719 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303720 return ret;
3721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303723 if (NULL == pHostapdState)
3724 {
3725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3726 "%s: pHostapdState is NULL",__func__);
3727 return -EINVAL;
3728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303730 if (NULL == hHal)
3731 {
3732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3733 "%s: Hal Context is NULL",__func__);
3734 return -EINVAL;
3735 }
3736 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3737 if (NULL == pHddApCtx)
3738 {
3739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3740 "%s: AP context is NULL",__func__);
3741 return -EINVAL;
3742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 if(pHostapdState->bssState == BSS_STOP )
3744 {
3745 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3746 != eHAL_STATUS_SUCCESS)
3747 {
c_hpothuffdb5272013-10-02 16:42:35 +05303748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3749 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 return -EIO;
3751 }
3752 else
3753 {
3754 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003755 if( TRUE == status)
3756 {
3757 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3758 * iwlist & iwconfig command shows frequency into proper
3759 * format (2.412 GHz instead of 246.2 MHz)*/
3760 fwrq->m = freq;
3761 fwrq->e = MHZ;
3762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 }
3764 }
3765 else
3766 {
3767 channel = pHddApCtx->operatingChannel;
3768 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003769 if( TRUE == status)
3770 {
3771 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3772 * iwlist & iwconfig command shows frequency into proper
3773 * format (2.412 GHz instead of 246.2 MHz)*/
3774 fwrq->m = freq;
3775 fwrq->e = MHZ;
3776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303778
3779 EXIT();
3780 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003781}
3782
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303783static int iw_get_ap_freq(struct net_device *dev,
3784 struct iw_request_info *info,
3785 struct iw_freq *fwrq, char *extra)
3786{
3787 int ret;
3788
3789 vos_ssr_protect(__func__);
3790 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3791 vos_ssr_unprotect(__func__);
3792
3793 return ret;
3794}
3795
3796static int __iw_get_mode(struct net_device *dev,
3797 struct iw_request_info *info,
3798 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303799{
3800 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303801 hdd_adapter_t *pAdapter;
3802 hdd_context_t *pHddCtx;
3803
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303804 ENTER();
3805
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303806 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3807 if (NULL == pAdapter)
3808 {
3809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3810 "%s: Adapter is NULL",__func__);
3811 return -EINVAL;
3812 }
3813 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3814 status = wlan_hdd_validate_context(pHddCtx);
3815 if (0 != status)
3816 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303817 return status;
3818 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303819
3820 wrqu->mode = IW_MODE_MASTER;
3821
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303822 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303823 return status;
3824}
3825
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303826static int iw_get_mode(struct net_device *dev,
3827 struct iw_request_info *info,
3828 union iwreq_data *wrqu, char *extra)
3829{
3830 int ret;
3831
3832 vos_ssr_protect(__func__);
3833 ret = __iw_get_mode(dev, info, wrqu, extra);
3834 vos_ssr_unprotect(__func__);
3835
3836 return ret;
3837}
3838
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303839static int __iw_softap_setwpsie(struct net_device *dev,
3840 struct iw_request_info *info,
3841 union iwreq_data *wrqu,
3842 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003843{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303844 hdd_adapter_t *pHostapdAdapter;
3845 hdd_context_t *pHddCtx;
3846 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 hdd_hostapd_state_t *pHostapdState;
3848 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003849 u_int8_t *wps_genie;
3850 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 u_int8_t *pos;
3852 tpSap_WPSIE pSap_WPSIe;
3853 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303854 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303855 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303856 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303857
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 ENTER();
3859
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303860 pHostapdAdapter = (netdev_priv(dev));
3861 if (NULL == pHostapdAdapter)
3862 {
3863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3864 "%s: Adapter is NULL",__func__);
3865 return -EINVAL;
3866 }
3867 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3868 ret = wlan_hdd_validate_context(pHddCtx);
3869 if (0 != ret)
3870 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303871 return ret;
3872 }
3873 pVosContext = pHddCtx->pvosContext;
3874 if (NULL == pVosContext)
3875 {
3876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3877 "%s: HDD context is not valid ",__func__);
3878 return -EINVAL;
3879 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303880 /* helper function to get iwreq_data with compat handling. */
3881 if (hdd_priv_get_data(&s_priv_data, wrqu))
3882 {
3883 return -EINVAL;
3884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003885
Girish Gowli07c05ec2014-06-17 20:47:03 +05303886 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3887 {
3888 return -EINVAL;
3889 }
3890
3891 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3892 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003893
Girish Gowli86c471e2014-06-17 19:28:05 +05303894 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003895 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303896 hddLog(LOG1, "%s: failed to alloc memory "
3897 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003898 return -EFAULT;
3899 }
3900
Girish Gowli86c471e2014-06-17 19:28:05 +05303901 fwps_genie = wps_genie;
3902
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3904 if (NULL == pSap_WPSIe)
3905 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003906 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003907 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 return -ENOMEM;
3909 }
3910 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3911
Arif Hussain6d2a3322013-11-17 19:50:10 -08003912 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 -07003913 WPSIeType = wps_genie[0];
3914 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3915 {
3916 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3917 wps_genie = wps_genie + 1;
3918 switch ( wps_genie[0] )
3919 {
3920 case DOT11F_EID_WPA:
3921 if (wps_genie[1] < 2 + 4)
3922 {
3923 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003924 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 return -EINVAL;
3926 }
3927 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3928 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003929 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 pos = &wps_genie[6];
3931 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3932 {
3933 switch((u_int16_t)(*pos<<8) | *(pos+1))
3934 {
3935 case HDD_WPS_ELEM_VERSION:
3936 pos += 4;
3937 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003938 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3940 pos += 1;
3941 break;
3942
3943 case HDD_WPS_ELEM_WPS_STATE:
3944 pos +=4;
3945 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003946 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3948 pos += 1;
3949 break;
3950 case HDD_WPS_ELEM_APSETUPLOCK:
3951 pos += 4;
3952 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003953 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3955 pos += 1;
3956 break;
3957 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3958 pos += 4;
3959 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003960 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3962 pos += 1;
3963 break;
3964 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3965 pos += 4;
3966 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003967 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3969 pos += 2;
3970 break;
3971 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3972 pos += 4;
3973 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003974 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3976 pos += 2;
3977 break;
3978
3979 case HDD_WPS_ELEM_UUID_E:
3980 pos += 2;
3981 length = *pos<<8 | *(pos+1);
3982 pos += 2;
3983 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3984 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3985 pos += length;
3986 break;
3987 case HDD_WPS_ELEM_RF_BANDS:
3988 pos += 4;
3989 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003990 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
3992 pos += 1;
3993 break;
3994
3995 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003996 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003998 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 return -EINVAL;
4000 }
4001 }
4002 }
4003 else {
4004 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004005 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 }
4007 break;
4008
4009 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004010 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004012 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 return 0;
4014 }
4015 }
4016 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
4017 {
4018 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
4019 wps_genie = wps_genie + 1;
4020 switch ( wps_genie[0] )
4021 {
4022 case DOT11F_EID_WPA:
4023 if (wps_genie[1] < 2 + 4)
4024 {
4025 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004026 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 return -EINVAL;
4028 }
4029 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
4030 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004031 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 pos = &wps_genie[6];
4033 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
4034 {
4035 switch((u_int16_t)(*pos<<8) | *(pos+1))
4036 {
4037 case HDD_WPS_ELEM_VERSION:
4038 pos += 4;
4039 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004040 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
4042 pos += 1;
4043 break;
4044
4045 case HDD_WPS_ELEM_WPS_STATE:
4046 pos +=4;
4047 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004048 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
4050 pos += 1;
4051 break;
4052 case HDD_WPS_ELEM_APSETUPLOCK:
4053 pos += 4;
4054 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004055 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
4057 pos += 1;
4058 break;
4059 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4060 pos += 4;
4061 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004062 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
4064 pos += 1;
4065 break;
4066 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4067 pos += 4;
4068 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004069 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
4071 pos += 2;
4072 break;
4073 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4074 pos += 4;
4075 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004076 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
4078 pos += 2;
4079 break;
4080 case HDD_WPS_ELEM_RSP_TYPE:
4081 pos += 4;
4082 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004083 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
4085 pos += 1;
4086 break;
4087 case HDD_WPS_ELEM_UUID_E:
4088 pos += 2;
4089 length = *pos<<8 | *(pos+1);
4090 pos += 2;
4091 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
4092 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
4093 pos += length;
4094 break;
4095
4096 case HDD_WPS_ELEM_MANUFACTURER:
4097 pos += 2;
4098 length = *pos<<8 | *(pos+1);
4099 pos += 2;
4100 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
4101 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
4102 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
4103 pos += length;
4104 break;
4105
4106 case HDD_WPS_ELEM_MODEL_NAME:
4107 pos += 2;
4108 length = *pos<<8 | *(pos+1);
4109 pos += 2;
4110 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
4111 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
4112 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
4113 pos += length;
4114 break;
4115 case HDD_WPS_ELEM_MODEL_NUM:
4116 pos += 2;
4117 length = *pos<<8 | *(pos+1);
4118 pos += 2;
4119 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
4120 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
4121 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
4122 pos += length;
4123 break;
4124 case HDD_WPS_ELEM_SERIAL_NUM:
4125 pos += 2;
4126 length = *pos<<8 | *(pos+1);
4127 pos += 2;
4128 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
4129 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
4130 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
4131 pos += length;
4132 break;
4133 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
4134 pos += 4;
4135 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004136 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 pos += 2;
4138
4139 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004140 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 pos += 4;
4142 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004143 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 pos += 2;
4145 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
4146 break;
4147 case HDD_WPS_ELEM_DEVICE_NAME:
4148 pos += 2;
4149 length = *pos<<8 | *(pos+1);
4150 pos += 2;
4151 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4152 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4153 pos += length;
4154 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4155 break;
4156 case HDD_WPS_ELEM_CONFIG_METHODS:
4157 pos += 4;
4158 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004159 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 pos += 2;
4161 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4162 break;
4163
4164 case HDD_WPS_ELEM_RF_BANDS:
4165 pos += 4;
4166 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004167 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 pos += 1;
4169 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4170 break;
4171 } // switch
4172 }
4173 }
4174 else
4175 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004176 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 }
4178
4179 } // switch
4180 }
4181 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
4182 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4183 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4184 {
4185 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4186 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4187 WLANSAP_Update_WpsIe ( pVosContext );
4188 }
4189
4190 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004191 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 EXIT();
4193 return halStatus;
4194}
4195
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304196static int iw_softap_setwpsie(struct net_device *dev,
4197 struct iw_request_info *info,
4198 union iwreq_data *wrqu,
4199 char *extra)
4200{
4201 int ret;
4202
4203 vos_ssr_protect(__func__);
4204 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4205 vos_ssr_unprotect(__func__);
4206
4207 return ret;
4208}
4209
4210static int __iw_softap_stopbss(struct net_device *dev,
4211 struct iw_request_info *info,
4212 union iwreq_data *wrqu,
4213 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004214{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304215 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304217 hdd_context_t *pHddCtx = NULL;
4218
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304220 pHostapdAdapter = (netdev_priv(dev));
4221 if (NULL == pHostapdAdapter)
4222 {
4223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4224 "%s: Adapter is NULL",__func__);
4225 return -EINVAL;
4226 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304227 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4228 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304229 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304230 return status;
4231 }
4232
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304233 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 {
4235 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4236 {
4237 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4238
4239 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304240
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304242 {
4243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004244 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 VOS_ASSERT(0);
4246 }
4247 }
4248 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304249 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 }
4251 EXIT();
4252 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4253}
4254
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304255static int iw_softap_stopbss(struct net_device *dev,
4256 struct iw_request_info *info,
4257 union iwreq_data *wrqu,
4258 char *extra)
4259{
4260 int ret;
4261
4262 vos_ssr_protect(__func__);
4263 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4264 vos_ssr_unprotect(__func__);
4265
4266 return ret;
4267}
4268
4269static int __iw_softap_version(struct net_device *dev,
4270 struct iw_request_info *info,
4271 union iwreq_data *wrqu,
4272 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004273{
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304275 hdd_context_t *pHddCtx;
4276 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304277
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304279 pHostapdAdapter = (netdev_priv(dev));
4280 if (NULL == pHostapdAdapter)
4281 {
4282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4283 "%s: Adapter is NULL",__func__);
4284 return -EINVAL;
4285 }
4286 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4287 ret = wlan_hdd_validate_context(pHddCtx);
4288 if (0 != ret)
4289 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304290 return ret;
4291 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004292 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 return 0;
4295}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004296
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304297static int iw_softap_version(struct net_device *dev,
4298 struct iw_request_info *info,
4299 union iwreq_data *wrqu,
4300 char *extra)
4301{
4302 int ret;
4303
4304 vos_ssr_protect(__func__);
4305 ret = __iw_softap_version(dev, info, wrqu, extra);
4306 vos_ssr_unprotect(__func__);
4307
4308 return ret;
4309}
4310
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004311VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004312{
4313 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004314 int len = 0;
4315 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304316 v_CONTEXT_t pVosContext;
4317 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304318 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304319
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304320 ENTER();
4321
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304322 if (NULL == pAdapter)
4323 {
4324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4325 "%s: Adapter is NULL",__func__);
4326 return -EINVAL;
4327 }
4328 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4329 if (0 != wlan_hdd_validate_context(pHddCtx))
4330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304331 return VOS_STATUS_E_FAULT;
4332 }
4333 pVosContext = pHddCtx->pvosContext;
4334 if (NULL == pVosContext)
4335 {
4336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4337 "%s: VOS context is not valid",__func__);
4338 return VOS_STATUS_E_FAULT;
4339 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304340 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304341 if(pSapCtx == NULL)
4342 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304343 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4344 FL("psapCtx is NULL"));
4345 return VOS_STATUS_E_FAULT;
4346 }
4347
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004348 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004349 pBuf += len;
4350 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004351
4352 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4353 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304354 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004355 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004356 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304357 pSapCtx->aStaInfo[i].ucSTAId,
4358 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4359 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4360 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4361 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4362 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4363 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004364 pBuf += len;
4365 buf_len -= len;
4366 }
4367 if(WE_GET_STA_INFO_SIZE > buf_len)
4368 {
4369 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004370 }
4371 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304372 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004373 return VOS_STATUS_SUCCESS;
4374}
4375
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304376static int __iw_softap_get_sta_info(struct net_device *dev,
4377 struct iw_request_info *info,
4378 union iwreq_data *wrqu,
4379 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004380{
4381 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4382 VOS_STATUS status;
4383 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004384 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004385 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004386 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004387 return -EINVAL;
4388 }
4389 wrqu->data.length = strlen(extra);
4390 EXIT();
4391 return 0;
4392}
4393
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304394static int iw_softap_get_sta_info(struct net_device *dev,
4395 struct iw_request_info *info,
4396 union iwreq_data *wrqu,
4397 char *extra)
4398{
4399 int ret;
4400
4401 vos_ssr_protect(__func__);
4402 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4403 vos_ssr_unprotect(__func__);
4404
4405 return ret;
4406}
4407
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304408static int __iw_set_ap_genie(struct net_device *dev,
4409 struct iw_request_info *info,
4410 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004411{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304412
4413 hdd_adapter_t *pHostapdAdapter;
4414 hdd_context_t *pHddCtx;
4415 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004417 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304418 int ret = 0;
4419
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304421 pHostapdAdapter = (netdev_priv(dev));
4422 if (NULL == pHostapdAdapter)
4423 {
4424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4425 "%s: Adapter is NULL",__func__);
4426 return -EINVAL;
4427 }
4428 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4429 ret = wlan_hdd_validate_context(pHddCtx);
4430 if (0 != ret)
4431 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304432 return ret;
4433 }
4434 pVosContext = pHddCtx->pvosContext;
4435 if (NULL == pVosContext)
4436 {
4437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4438 "%s: VOS Context is NULL",__func__);
4439 return -EINVAL;
4440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 if(!wrqu->data.length)
4442 {
4443 EXIT();
4444 return 0;
4445 }
Arif Hussained667642013-10-27 23:01:14 -07004446
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304447 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304449 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 case DOT11F_EID_RSN:
4451 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4452 {
4453 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4454 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004457 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004461 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 halStatus = 0;
4463 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304464
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304466 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467}
4468
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304469static int iw_set_ap_genie(struct net_device *dev,
4470 struct iw_request_info *info,
4471 union iwreq_data *wrqu, char *extra)
4472{
4473 int ret;
4474
4475 vos_ssr_protect(__func__);
4476 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4477 vos_ssr_unprotect(__func__);
4478
4479 return ret;
4480}
4481
Jeff Johnson295189b2012-06-20 16:38:30 -07004482static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4483{
4484 eHalStatus hstatus;
4485 long lrc;
4486 struct statsContext context;
4487
4488 if (NULL == pAdapter)
4489 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304490 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 return VOS_STATUS_E_FAULT;
4492 }
4493
4494 init_completion(&context.completion);
4495 context.pAdapter = pAdapter;
4496 context.magic = STATS_CONTEXT_MAGIC;
4497 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4498 eCSR_HDD,
4499 SME_GLOBAL_CLASSA_STATS,
4500 hdd_GetClassA_statisticsCB,
4501 0, // not periodic
4502 FALSE, //non-cached results
4503 staid,
4504 &context);
4505 if (eHAL_STATUS_SUCCESS != hstatus)
4506 {
4507 hddLog(VOS_TRACE_LEVEL_ERROR,
4508 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004509 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 }
4511 else
4512 {
4513 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4514 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 if (lrc <= 0)
4516 {
4517 hddLog(VOS_TRACE_LEVEL_ERROR,
4518 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004519 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 }
4521 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004522
4523 /* either we never sent a request, we sent a request and received a
4524 response or we sent a request and timed out. if we never sent a
4525 request or if we sent a request and got a response, we want to
4526 clear the magic out of paranoia. if we timed out there is a
4527 race condition such that the callback function could be
4528 executing at the same time we are. of primary concern is if the
4529 callback function had already verified the "magic" but had not
4530 yet set the completion variable when a timeout occurred. we
4531 serialize these activities by invalidating the magic while
4532 holding a shared spinlock which will cause us to block if the
4533 callback is currently executing */
4534 spin_lock(&hdd_context_lock);
4535 context.magic = 0;
4536 spin_unlock(&hdd_context_lock);
4537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 return VOS_STATUS_SUCCESS;
4539}
4540
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304541int __iw_get_softap_linkspeed(struct net_device *dev,
4542 struct iw_request_info *info,
4543 union iwreq_data *wrqu,
4544 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004545
4546{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304547 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304548 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004550 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304551 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304553 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004555 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304556 int rc, valid;
4557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304558 ENTER();
4559
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304560 pHostapdAdapter = (netdev_priv(dev));
4561 if (NULL == pHostapdAdapter)
4562 {
4563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4564 "%s: Adapter is NULL",__func__);
4565 return -EINVAL;
4566 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304567 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304568 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304569 if (0 != valid)
4570 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304571 return valid;
4572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004573
Arif Hussain6d2a3322013-11-17 19:50:10 -08004574 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004575
4576 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004577 {
Arif Hussaina9571842014-01-15 16:43:41 -08004578 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4579 if (NULL == pmacAddress) {
4580 hddLog(LOG1, "unable to allocate memory");
4581 return -ENOMEM;
4582 }
4583 if (copy_from_user((void *)pmacAddress,
4584 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4585 {
4586 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4587 kfree(pmacAddress);
4588 return -EFAULT;
4589 }
4590 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4591
4592 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004593 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004594
4595 if (!VOS_IS_STATUS_SUCCESS(status ))
4596 {
4597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4598 }
Arif Hussained667642013-10-27 23:01:14 -07004599 }
Kiet Lam61589852013-09-19 17:10:58 +05304600 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304601 * link speed for first connected client will be returned.
4602 */
Arif Hussaina9571842014-01-15 16:43:41 -08004603 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304604 {
4605 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4606 }
4607 else
4608 {
4609 status = hdd_softap_GetStaId(pHostapdAdapter,
4610 (v_MACADDR_t *)macAddress, (void *)(&staId));
4611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004612
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304613 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304615 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 link_speed = 0;
4617 }
4618 else
4619 {
4620 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304621
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 if (!VOS_IS_STATUS_SUCCESS(status ))
4623 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304624 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 return -EINVAL;
4626 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304627
4628 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4629 staId, &link_speed);
4630
4631 link_speed = link_speed / 10;
4632
4633 if (0 == link_speed)
4634 {
4635 /* The linkspeed returned by HAL is in units of 500kbps.
4636 * converting it to mbps.
4637 * This is required to support legacy firmware which does
4638 * not return link capacity.
4639 */
4640 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 }
4643
4644 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004645 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304646
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 if ((rc < 0) || (rc >= len))
4648 {
4649 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304650 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 return -EIO;
4652 }
4653
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304654 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 return 0;
4656}
4657
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304658int iw_get_softap_linkspeed(struct net_device *dev,
4659 struct iw_request_info *info,
4660 union iwreq_data *wrqu,
4661 char *extra)
4662{
4663 int ret;
4664
4665 vos_ssr_protect(__func__);
4666 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4667 vos_ssr_unprotect(__func__);
4668
4669 return ret;
4670}
4671
4672
Jeff Johnson295189b2012-06-20 16:38:30 -07004673static const iw_handler hostapd_handler[] =
4674{
4675 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4676 (iw_handler) NULL, /* SIOCGIWNAME */
4677 (iw_handler) NULL, /* SIOCSIWNWID */
4678 (iw_handler) NULL, /* SIOCGIWNWID */
4679 (iw_handler) NULL, /* SIOCSIWFREQ */
4680 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4681 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304682 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 (iw_handler) NULL, /* SIOCSIWSENS */
4684 (iw_handler) NULL, /* SIOCGIWSENS */
4685 (iw_handler) NULL, /* SIOCSIWRANGE */
4686 (iw_handler) NULL, /* SIOCGIWRANGE */
4687 (iw_handler) NULL, /* SIOCSIWPRIV */
4688 (iw_handler) NULL, /* SIOCGIWPRIV */
4689 (iw_handler) NULL, /* SIOCSIWSTATS */
4690 (iw_handler) NULL, /* SIOCGIWSTATS */
4691 (iw_handler) NULL, /* SIOCSIWSPY */
4692 (iw_handler) NULL, /* SIOCGIWSPY */
4693 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4694 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4695 (iw_handler) NULL, /* SIOCSIWAP */
4696 (iw_handler) NULL, /* SIOCGIWAP */
4697 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4698 (iw_handler) NULL, /* SIOCGIWAPLIST */
4699 (iw_handler) NULL, /* SIOCSIWSCAN */
4700 (iw_handler) NULL, /* SIOCGIWSCAN */
4701 (iw_handler) NULL, /* SIOCSIWESSID */
4702 (iw_handler) NULL, /* SIOCGIWESSID */
4703 (iw_handler) NULL, /* SIOCSIWNICKN */
4704 (iw_handler) NULL, /* SIOCGIWNICKN */
4705 (iw_handler) NULL, /* -- hole -- */
4706 (iw_handler) NULL, /* -- hole -- */
4707 (iw_handler) NULL, /* SIOCSIWRATE */
4708 (iw_handler) NULL, /* SIOCGIWRATE */
4709 (iw_handler) NULL, /* SIOCSIWRTS */
4710 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4711 (iw_handler) NULL, /* SIOCSIWFRAG */
4712 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4713 (iw_handler) NULL, /* SIOCSIWTXPOW */
4714 (iw_handler) NULL, /* SIOCGIWTXPOW */
4715 (iw_handler) NULL, /* SIOCSIWRETRY */
4716 (iw_handler) NULL, /* SIOCGIWRETRY */
4717 (iw_handler) NULL, /* SIOCSIWENCODE */
4718 (iw_handler) NULL, /* SIOCGIWENCODE */
4719 (iw_handler) NULL, /* SIOCSIWPOWER */
4720 (iw_handler) NULL, /* SIOCGIWPOWER */
4721 (iw_handler) NULL, /* -- hole -- */
4722 (iw_handler) NULL, /* -- hole -- */
4723 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4724 (iw_handler) NULL, /* SIOCGIWGENIE */
4725 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4726 (iw_handler) NULL, /* SIOCGIWAUTH */
4727 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4728 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4729 (iw_handler) NULL, /* SIOCSIWPMKSA */
4730};
4731
Jeff Johnson224f3702014-03-26 11:09:47 -07004732/*
4733 * Note that the following ioctls were defined with semantics which
4734 * cannot be handled by the "iwpriv" userspace application and hence
4735 * they are not included in the hostapd_private_args array
4736 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4737 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004738
4739static const struct iw_priv_args hostapd_private_args[] = {
4740 { QCSAP_IOCTL_SETPARAM,
4741 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4742 { QCSAP_IOCTL_SETPARAM,
4743 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
4744 { QCSAP_PARAM_MAX_ASSOC,
4745 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4746 { QCSAP_PARAM_HIDE_SSID,
4747 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004748 { QCSAP_PARAM_SET_MC_RATE,
4749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 { QCSAP_IOCTL_GETPARAM,
4751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4752 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4753 { QCSAP_IOCTL_GETPARAM, 0,
4754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4755 { QCSAP_PARAM_MAX_ASSOC, 0,
4756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004757 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4758 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4759 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4760 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304761 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4762 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 { QCSAP_PARAM_CLR_ACL, 0,
4764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4765 { QCSAP_PARAM_ACL_MODE,
4766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 { QCSAP_IOCTL_GET_STAWPAIE,
4768 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4769 { QCSAP_IOCTL_SETWPAIE,
4770 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4771 { QCSAP_IOCTL_STOPBSS,
4772 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4773 { QCSAP_IOCTL_VERSION, 0,
4774 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004775 { QCSAP_IOCTL_GET_STA_INFO, 0,
4776 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004778 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004781 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304783 { QCSAP_IOCTL_AP_STATS, 0,
4784 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304785 { QCSAP_IOCTL_GET_STATS, 0,
4786 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4787 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4789 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304790 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004791
4792 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4793 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4794 /* handlers for sub-ioctl */
4795 { WE_SET_WLAN_DBG,
4796 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4797 0,
4798 "setwlandbg" },
4799
4800 /* handlers for main ioctl */
4801 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4802 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4803 0,
4804 "" },
4805
4806 /* handlers for sub-ioctl */
4807 { WE_LOG_DUMP_CMD,
4808 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4809 0,
4810 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 { WE_P2P_NOA_CMD,
4812 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4813 0,
4814 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004815 /* handlers for sub ioctl */
4816 {
4817 WE_MCC_CONFIG_CREDENTIAL,
4818 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4819 0,
4820 "setMccCrdnl" },
4821
4822 /* handlers for sub ioctl */
4823 {
4824 WE_MCC_CONFIG_PARAMS,
4825 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4826 0,
4827 "setMccConfig" },
4828
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 /* handlers for main ioctl */
4830 { QCSAP_IOCTL_MODIFY_ACL,
4831 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4832 0,
4833 "modify_acl" },
4834
4835 /* handlers for main ioctl */
4836 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4837 0,
4838 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4839 "getChannelList" },
4840
Jeff Johnsone7245742012-09-05 17:12:55 -07004841 /* handlers for main ioctl */
4842 { QCSAP_IOCTL_SET_TX_POWER,
4843 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4844 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304845 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004846
4847 /* handlers for main ioctl */
4848 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4849 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4850 0,
4851 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304852
4853 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4854 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4855 0,
4856 "dataSnapshot" },
4857
4858 /* handlers for main ioctl */
4859 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4860 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4861 0,
4862 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004863};
Jeff Johnsone7245742012-09-05 17:12:55 -07004864
Jeff Johnson295189b2012-06-20 16:38:30 -07004865static const iw_handler hostapd_private[] = {
4866 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4867 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4869 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4870 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4871 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4872 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4873 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4874 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4875 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4876 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304877 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4879 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4880 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4881 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004882 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004883 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4884 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004885 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304886 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304887 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304888 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4889 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004890};
4891const struct iw_handler_def hostapd_handler_def = {
4892 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4893 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4894 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4895 .standard = (iw_handler *)hostapd_handler,
4896 .private = (iw_handler *)hostapd_private,
4897 .private_args = hostapd_private_args,
4898 .get_wireless_stats = NULL,
4899};
4900#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4901struct net_device_ops net_ops_struct = {
4902 .ndo_open = hdd_hostapd_open,
4903 .ndo_stop = hdd_hostapd_stop,
4904 .ndo_uninit = hdd_hostapd_uninit,
4905 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4906 .ndo_tx_timeout = hdd_softap_tx_timeout,
4907 .ndo_get_stats = hdd_softap_stats,
4908 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4909 .ndo_do_ioctl = hdd_hostapd_ioctl,
4910 .ndo_change_mtu = hdd_hostapd_change_mtu,
4911 .ndo_select_queue = hdd_hostapd_select_queue,
4912 };
4913#endif
4914
4915int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4916{
4917 return VOS_STATUS_SUCCESS;
4918}
4919
4920void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4921{
4922#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4923 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4924#else
4925 pWlanHostapdDev->open = hdd_hostapd_open;
4926 pWlanHostapdDev->stop = hdd_hostapd_stop;
4927 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4928 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4929 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4930 pWlanHostapdDev->get_stats = hdd_softap_stats;
4931 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4932 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4933#endif
4934}
4935
4936VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304937{
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 hdd_hostapd_state_t * phostapdBuf;
4939 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004940 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004942#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004943 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4944 v_U16_t unsafeChannelCount;
4945#endif /* FEATURE_WLAN_CH_AVOID */
4946
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304947 if (pHddCtx->isLogpInProgress) {
4948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4949 "%s:LOGP in Progress. Ignore!!!",__func__);
4950 status = VOS_STATUS_E_FAILURE;
4951 }
4952
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304954 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304956
Nirav Shah7e3c8132015-06-22 23:51:42 +05304957 spin_lock_init(&pAdapter->sta_hash_lock);
4958 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4959
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004960 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4961
Leo Chang0b0e45a2013-12-15 15:18:55 -08004962#ifdef FEATURE_WLAN_CH_AVOID
4963 /* Get unsafe cahnnel list from cached location */
4964 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4965 sizeof(unsafeChannelList),
4966 &unsafeChannelCount);
4967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4968 "%s : Unsafe Channel count %d",
4969 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304970 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004971 unsafeChannelList,
4972 unsafeChannelCount);
4973#endif /* FEATURE_WLAN_CH_AVOID */
4974
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 // Zero the memory. This zeros the profile structure.
4976 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
4977
4978 // Set up the pointer to the Wireless Extensions state structure
4979 // NOP
4980 status = hdd_set_hostapd(pAdapter);
4981 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 return status;
4984 }
4985
4986 status = vos_event_init(&phostapdBuf->vosEvent);
4987 if (!VOS_IS_STATUS_SUCCESS(status))
4988 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 return status;
4991 }
4992
4993 init_completion(&pAdapter->session_close_comp_var);
4994 init_completion(&pAdapter->session_open_comp_var);
4995
4996 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4997
4998 // Register as a wireless device
4999 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5000
5001 //Initialize the data path module
5002 status = hdd_softap_init_tx_rx(pAdapter);
5003 if ( !VOS_IS_STATUS_SUCCESS( status ))
5004 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005005 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305007
5008 status = hdd_wmm_adapter_init( pAdapter );
5009 if (!VOS_IS_STATUS_SUCCESS(status))
5010 {
5011 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005012 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305013 status, status );
5014 goto error_wmm_init;
5015 }
5016
5017 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5018
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305019 return status;
5020
5021error_wmm_init:
5022 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 EXIT();
5024 return status;
5025}
5026
5027hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5028{
5029 struct net_device *pWlanHostapdDev = NULL;
5030 hdd_adapter_t *pHostapdAdapter = NULL;
5031 v_CONTEXT_t pVosContext= NULL;
5032
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305033 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5034#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5035 NET_NAME_UNKNOWN,
5036#endif
5037 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 if (pWlanHostapdDev != NULL)
5039 {
5040 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5041
5042 //Init the net_device structure
5043 ether_setup(pWlanHostapdDev);
5044
5045 //Initialize the adapter context to zeros.
5046 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5047 pHostapdAdapter->dev = pWlanHostapdDev;
5048 pHostapdAdapter->pHddCtx = pHddCtx;
5049 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5050
5051 //Get the Global VOSS context.
5052 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5053 //Save the adapter context in global context for future.
5054 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5055
5056 //Init the net_device structure
5057 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5058
5059 hdd_set_ap_ops( pHostapdAdapter->dev );
5060
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5062 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5063
5064 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5065 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5066
5067 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5069 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5070 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
5071 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
5073 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05305074 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07005075#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5076 init_completion(&pHostapdAdapter->offchannel_tx_event);
5077#endif
5078
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5080 }
5081 return pHostapdAdapter;
5082}
5083
5084VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5085{
5086 struct net_device *dev = pAdapter->dev;
5087 VOS_STATUS status = VOS_STATUS_SUCCESS;
5088
5089 ENTER();
5090
5091 if( rtnl_lock_held )
5092 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005093 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 if( dev_alloc_name(dev, dev->name) < 0 )
5095 {
5096 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5097 return VOS_STATUS_E_FAILURE;
5098 }
5099 }
5100 if (register_netdevice(dev))
5101 {
5102 hddLog(VOS_TRACE_LEVEL_FATAL,
5103 "%s:Failed:register_netdevice", __func__);
5104 return VOS_STATUS_E_FAILURE;
5105 }
5106 }
5107 else
5108 {
5109 if (register_netdev(dev))
5110 {
5111 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5112 return VOS_STATUS_E_FAILURE;
5113 }
5114 }
5115 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5116
5117 EXIT();
5118 return status;
5119}
5120
c_hpothu002231a2015-02-05 14:58:51 +05305121VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005122{
5123 ENTER();
5124
5125 hdd_softap_deinit_tx_rx(pAdapter);
5126
5127 /* if we are being called during driver unload, then the dev has already
5128 been invalidated. if we are being called at other times, then we can
5129 detatch the wireless device handlers */
5130 if (pAdapter->dev)
5131 {
c_hpothu002231a2015-02-05 14:58:51 +05305132 if (TRUE == rtnl_held)
5133 {
5134 pAdapter->dev->wireless_handlers = NULL;
5135 }
5136 else
5137 {
5138 rtnl_lock();
5139 pAdapter->dev->wireless_handlers = NULL;
5140 rtnl_unlock();
5141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 }
5143 EXIT();
5144 return 0;
5145}