blob: 9cf9f5da72859b56c15f969dd59e5d6615792616 [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 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530449 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
450 {
451 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
452 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700453
Jeff Johnson295189b2012-06-20 16:38:30 -0700454exit:
455 if (command)
456 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700457 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530459 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 return ret;
461}
462
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700463#ifdef CONFIG_COMPAT
464static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
465 struct ifreq *ifr)
466{
467 struct {
468 compat_uptr_t buf;
469 int used_len;
470 int total_len;
471 } compat_priv_data;
472 hdd_priv_data_t priv_data;
473 int ret = 0;
474
475 /*
476 * Note that pAdapter and ifr have already been verified by caller,
477 * and HDD context has also been validated
478 */
479 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
480 sizeof(compat_priv_data))) {
481 ret = -EFAULT;
482 goto exit;
483 }
484 priv_data.buf = compat_ptr(compat_priv_data.buf);
485 priv_data.used_len = compat_priv_data.used_len;
486 priv_data.total_len = compat_priv_data.total_len;
487 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
488 exit:
489 return ret;
490}
491#else /* CONFIG_COMPAT */
492static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
493 struct ifreq *ifr)
494{
495 /* will never be invoked */
496 return 0;
497}
498#endif /* CONFIG_COMPAT */
499
500static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
501{
502 hdd_priv_data_t priv_data;
503 int ret = 0;
504
505 /*
506 * Note that pAdapter and ifr have already been verified by caller,
507 * and HDD context has also been validated
508 */
509 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
510 ret = -EFAULT;
511 } else {
512 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
513 }
514 return ret;
515}
516
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530517static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700518 struct ifreq *ifr, int cmd)
519{
520 hdd_adapter_t *pAdapter;
521 hdd_context_t *pHddCtx;
522 int ret;
523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530524 ENTER();
525
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700526 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
527 if (NULL == pAdapter) {
528 hddLog(VOS_TRACE_LEVEL_ERROR,
529 "%s: HDD adapter context is Null", __func__);
530 ret = -ENODEV;
531 goto exit;
532 }
533 if (dev != pAdapter->dev) {
534 hddLog(VOS_TRACE_LEVEL_ERROR,
535 "%s: HDD adapter/dev inconsistency", __func__);
536 ret = -ENODEV;
537 goto exit;
538 }
539
540 if ((!ifr) || (!ifr->ifr_data)) {
541 ret = -EINVAL;
542 goto exit;
543 }
544
545 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
546 ret = wlan_hdd_validate_context(pHddCtx);
547 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700548 ret = -EBUSY;
549 goto exit;
550 }
551
552 switch (cmd) {
553 case (SIOCDEVPRIVATE + 1):
554 if (is_compat_task())
555 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
556 else
557 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
558 break;
559 default:
560 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
561 __func__, cmd);
562 ret = -EINVAL;
563 break;
564 }
565 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530566 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700567 return ret;
568}
569
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530570static int hdd_hostapd_ioctl(struct net_device *dev,
571 struct ifreq *ifr, int cmd)
572{
573 int ret;
574
575 vos_ssr_protect(__func__);
576 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
577 vos_ssr_unprotect(__func__);
578
579 return ret;
580}
581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582/**---------------------------------------------------------------------------
583
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530584 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 This function sets the user specified mac address using
586 the command ifconfig wlanX hw ether <mac adress>.
587
588 \param - dev - Pointer to the net device.
589 - addr - Pointer to the sockaddr.
590 \return - 0 for success, non zero for failure
591
592 --------------------------------------------------------------------------*/
593
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530594static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700595{
596 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530597 hdd_adapter_t *pAdapter;
598 hdd_context_t *pHddCtx;
599 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530600
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530602 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
603 if (NULL == pAdapter)
604 {
605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
606 "%s: Adapter is NULL",__func__);
607 return -EINVAL;
608 }
609 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
610 ret = wlan_hdd_validate_context(pHddCtx);
611 if (0 != ret)
612 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530613 return ret;
614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
616 EXIT();
617 return 0;
618}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530619
620static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
621{
622 int ret;
623
624 vos_ssr_protect(__func__);
625 ret = __hdd_hostapd_set_mac_address(dev, addr);
626 vos_ssr_unprotect(__func__);
627
628 return ret;
629}
630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
632{
633 struct net_device *dev = (struct net_device *)usrDataForCallback;
634 v_BYTE_t we_custom_event[64];
635 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530637 hdd_context_t *pHddCtx;
638#ifdef DISABLE_CONCURRENCY_AUTOSAVE
639 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 hdd_ap_ctx_t *pHddApCtx;
641#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
642
643 /* event_name space-delimiter driver_module_name */
644 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
645 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
646 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
647
648 ENTER();
649
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530650 pHostapdAdapter = netdev_priv(dev);
651 if ((NULL == pHostapdAdapter) ||
652 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
653 {
654 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
655 return;
656 }
657 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
658 if (0 != (wlan_hdd_validate_context(pHddCtx)))
659 {
660 return;
661 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530662#ifdef DISABLE_CONCURRENCY_AUTOSAVE
663 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530664 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 /*
666 This timer routine is going to be called only when AP
667 persona is up.
668 If there are concurrent sessions running we do not want
669 to shut down the Bss.Instead we run the timer again so
670 that if Autosave is enabled next time and other session
671 was down only then we bring down AP
672 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
674 vos_status = vos_timer_start(
675 &pHddApCtx->hdd_ap_inactivity_timer,
676 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
677 * 1000);
678 if (!VOS_IS_STATUS_SUCCESS(vos_status))
679 {
680 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
681 }
682 EXIT();
683 return;
684 }
685#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
686 memset(&we_custom_event, '\0', sizeof(we_custom_event));
687 memcpy(&we_custom_event, autoShutEvent, event_len);
688
689 memset(&wrqu, 0, sizeof(wrqu));
690 wrqu.data.length = event_len;
691
692 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
693 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
694
695 EXIT();
696}
697
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800698VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
699{
700 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
701 ptSapContext pSapCtx = NULL;
702 eHalStatus halStatus = eHAL_STATUS_FAILURE;
703 v_PVOID_t hHal = NULL;
704
705 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
706 "%s: UPDATE Beacon Params", __func__);
707
708 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
709 pSapCtx = VOS_GET_SAP_CB(pVosContext);
710 if ( NULL == pSapCtx )
711 {
712 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
713 "%s: Invalid SAP pointer from pvosGCtx", __func__);
714 return VOS_STATUS_E_FAULT;
715 }
716
717 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
718 if ( NULL == hHal ){
719 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
720 "%s: Invalid HAL pointer from pvosGCtx", __func__);
721 return VOS_STATUS_E_FAULT;
722 }
723 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
724 if(halStatus == eHAL_STATUS_FAILURE ){
725 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
726 "%s: Failed to update Beacon Params", __func__);
727 return VOS_STATUS_E_FAILURE;
728 }
729 }
730 return VOS_STATUS_SUCCESS;
731}
732
733void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
734{
735 v_U8_t staId = 0;
736 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530737 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
738 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800739
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530740 dev = (struct net_device *)usrDataForCallback;
741 pSapCtx = VOS_GET_SAP_CB(pVosContext);
742 if(pSapCtx == NULL){
743 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
744 FL("psapCtx is NULL"));
745 return;
746 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800747 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800748 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
749 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530750 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800751 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
752 {
753 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530754 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800755 }
756 }
757}
758
Agarwal Ashish8e538932014-12-24 18:12:52 +0530759static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800760{
761 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530762 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800763 VOS_STATUS status = VOS_STATUS_SUCCESS;
764 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530765
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800766 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530767
768 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
769 status = wlan_hdd_validate_context(pHddCtx);
770
771 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530772 return status;
773 }
774
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800775 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
776 {
777 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
778 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800780 }
781 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530782 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800783 }
784 EXIT();
785 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
786}
Jeff Johnson295189b2012-06-20 16:38:30 -0700787
788VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
789{
790 hdd_adapter_t *pHostapdAdapter;
791 hdd_ap_ctx_t *pHddApCtx;
792 hdd_hostapd_state_t *pHostapdState;
793 struct net_device *dev;
794 eSapHddEvent sapEvent;
795 union iwreq_data wrqu;
796 v_BYTE_t *we_custom_event_generic = NULL;
797 int we_event = 0;
798 int i = 0;
799 v_U8_t staId;
800 VOS_STATUS vos_status;
801 v_BOOL_t bWPSState;
802 v_BOOL_t bApActive = FALSE;
803 v_BOOL_t bAuthRequired = TRUE;
804 tpSap_AssocMacAddr pAssocStasArray = NULL;
805 char unknownSTAEvent[IW_CUSTOM_MAX+1];
806 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
807 v_BYTE_t we_custom_start_event[64];
808 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800809 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800810 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700811 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530812 v_CONTEXT_t pVosContext = NULL;
813 ptSapContext pSapCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700814
815 dev = (struct net_device *)usrDataForCallback;
816 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530817
818 if ((NULL == pHostapdAdapter) ||
819 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
820 {
821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
822 "invalid adapter or adapter has invalid magic");
823 return eHAL_STATUS_FAILURE;
824 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530825 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
826 pSapCtx = VOS_GET_SAP_CB(pVosContext);
827 if(pSapCtx == NULL){
828 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
829 FL("psapCtx is NULL"));
830 return eHAL_STATUS_FAILURE;
831 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
833 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
834 sapEvent = pSapEvent->sapHddEventCode;
835 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800836 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837
838 switch(sapEvent)
839 {
840 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800841 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
843 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
844 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
845
846 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
847 vos_status = vos_event_set(&pHostapdState->vosEvent);
848
849 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
850 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 goto stopbss;
853 }
854 else
855 {
856 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
857 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530858 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
859 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530860 {
c_hpothuffdb5272013-10-02 16:42:35 +0530861 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530862 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
863 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 }
865
866 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
867 {
868 // AP Inactivity timer init and start
869 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
870 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
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 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
875 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800876 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
878 }
879 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
880 pHostapdState->bssState = BSS_START;
881
882 // Send current operating channel of SoftAP to BTC-ES
883 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
884
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 //Check if there is any group key pending to set.
886 if( pHddApCtx->groupKey.keyLength )
887 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700888 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
890 &pHddApCtx->groupKey ) )
891 {
892 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
893 "%s: WLANSAP_SetKeySta failed", __func__);
894 }
895 pHddApCtx->groupKey.keyLength = 0;
896 }
897 else if ( pHddApCtx->wepKey[0].keyLength )
898 {
899 int i=0;
900 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
901 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700902 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
904 &pHddApCtx->wepKey[i] ) )
905 {
906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
907 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
908 }
909 pHddApCtx->wepKey[i].keyLength = 0;
910 }
911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
913 startBssEvent = "SOFTAP.enabled";
914 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
915 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
916 memset(&wrqu, 0, sizeof(wrqu));
917 wrqu.data.length = strlen(startBssEvent);
918 we_event = IWEVCUSTOM;
919 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700920 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 break; //Event will be sent after Switch-Case stmt
922
923 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800924 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
926
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700927 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700928 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700929
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530931
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530932 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530933 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530934 hddLog(LOG1,
935 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
936 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530937 }
938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 goto stopbss;
940 case eSAP_STA_SET_KEY_EVENT:
941 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800942 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
944 return VOS_STATUS_SUCCESS;
945 case eSAP_STA_DEL_KEY_EVENT:
946 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800947 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 return VOS_STATUS_SUCCESS;
949 case eSAP_STA_MIC_FAILURE_EVENT:
950 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 memset(&msg, '\0', sizeof(msg));
952 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800953 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800954 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700955 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 msg.flags = IW_MICFAILURE_GROUP;
957 else
958 msg.flags = IW_MICFAILURE_PAIRWISE;
959 memset(&wrqu, 0, sizeof(wrqu));
960 wrqu.data.length = sizeof(msg);
961 we_event = IWEVMICHAELMICFAILURE;
962 we_custom_event_generic = (v_BYTE_t *)&msg;
963 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 /* inform mic failure to nl80211 */
965 cfg80211_michael_mic_failure(dev,
966 pSapEvent->sapevt.
967 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700968 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 NL80211_KEYTYPE_GROUP :
970 NL80211_KEYTYPE_PAIRWISE),
971 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
972 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
973 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 break;
975
976 case eSAP_STA_ASSOC_EVENT:
977 case eSAP_STA_REASSOC_EVENT:
978 wrqu.addr.sa_family = ARPHRD_ETHER;
979 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800980 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800981 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 we_event = IWEVREGISTERED;
983
984 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
985
986 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
987 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
988 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
989 {
990 bAuthRequired = FALSE;
991 }
992
993 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
994 {
c_hpothuffdb5272013-10-02 16:42:35 +0530995 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 TRUE,
997 pHddApCtx->uPrivacy,
998 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
999 0,
1000 0,
1001 (v_MACADDR_t *)wrqu.addr.sa_data,
1002 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301003
1004 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1005 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1006 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 }
1008 else
1009 {
c_hpothuffdb5272013-10-02 16:42:35 +05301010 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 FALSE,
1012 pHddApCtx->uPrivacy,
1013 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1014 0,
1015 0,
1016 (v_MACADDR_t *)wrqu.addr.sa_data,
1017 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301018 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1019 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1020 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001021 }
1022
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301023 staId =
1024 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1025 if (VOS_IS_STATUS_SUCCESS(vos_status))
1026 {
1027
1028 pSapCtx->aStaInfo[staId].rate_flags =
1029 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1030 }
1031
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 // Stop AP inactivity timer
1033 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1034 {
1035 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1036 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001037 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001039#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001040 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1041 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301042 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1043 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001044 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301045 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1046 HDD_SAP_WAKE_LOCK_DURATION,
1047 WIFI_POWER_EVENT_WAKELOCK_SAP);
1048
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001049#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001050#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1051 {
1052 struct station_info staInfo;
1053 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1054
1055 memset(&staInfo, 0, sizeof(staInfo));
1056 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1057 {
1058 staInfo.assoc_req_ies =
1059 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1060 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001061#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001062 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 cfg80211_new_sta(dev,
1065 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1066 &staInfo, GFP_KERNEL);
1067 }
1068 else
1069 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001070 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 }
1072 }
1073#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001074 pScanInfo = &pHddCtx->scan_info;
1075 // Lets do abort scan to ensure smooth authentication for client
1076 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1077 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301078 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301079 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001081
1082 break;
1083 case eSAP_STA_DISASSOC_EVENT:
1084 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001085 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001086 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1088 hddLog(LOG1," User initiated disassociation");
1089 else
1090 hddLog(LOG1," MAC initiated disassociation");
1091 we_event = IWEVEXPIRED;
1092 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1093 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1094 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001095 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 -07001096 return VOS_STATUS_E_FAILURE;
1097 }
1098 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1099
1100 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1101 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301102 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 // Start AP inactivity timer if no stations associated with it
1104 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1105 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301106 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 {
1108 bApActive = TRUE;
1109 break;
1110 }
1111 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301112 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001113
1114 if (bApActive == FALSE)
1115 {
1116 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1117 {
1118 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1119 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001120 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 }
1122 else
1123 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1124 }
1125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001126#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1127 cfg80211_del_sta(dev,
1128 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1129 GFP_KERNEL);
1130#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001131 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301132 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1133 if (VOS_STATUS_SUCCESS != vos_status)
1134 {
1135 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1136 __func__, vos_status);
1137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 break;
1139 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1140 {
1141 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1142 union iwreq_data wreq;
1143
1144 down(&pHddApCtx->semWpsPBCOverlapInd);
1145 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1146
1147 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1148 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1149
1150 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001151 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 memset(&wreq, 0, sizeof(wreq));
1153 wreq.data.length = strlen(message); // This is length of message
1154 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1155
1156 return VOS_STATUS_SUCCESS;
1157 }
1158 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1159 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1160 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1161 { // List of associated stations
1162 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1163 {
1164 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1165 i+1,
1166 pAssocStasArray->assocId,
1167 pAssocStasArray->staId,
1168 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1169 pAssocStasArray++;
1170 }
1171 }
1172 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001173 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 case eSAP_INDICATE_MGMT_FRAME:
1176 hdd_indicateMgmtFrame( pHostapdAdapter,
1177 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1178 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1179 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301180 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 return VOS_STATUS_SUCCESS;
1182 case eSAP_REMAIN_CHAN_READY:
1183 hdd_remainChanReadyHandler( pHostapdAdapter );
1184 return VOS_STATUS_SUCCESS;
1185 case eSAP_SEND_ACTION_CNF:
1186 hdd_sendActionCnf( pHostapdAdapter,
1187 ( eSAP_STATUS_SUCCESS ==
1188 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1189 TRUE : FALSE );
1190 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 case eSAP_UNKNOWN_STA_JOIN:
1192 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1193 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1194 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1195 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1196 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1197 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1198 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1199 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1200 wrqu.data.pointer = unknownSTAEvent;
1201 wrqu.data.length = strlen(unknownSTAEvent);
1202 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301203 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 break;
1205
1206 case eSAP_MAX_ASSOC_EXCEEDED:
1207 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1208 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1209 " one or more devices to enable the new device connection",
1210 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1211 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1212 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1213 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1214 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1215 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1216 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1217 wrqu.data.pointer = maxAssocExceededEvent;
1218 wrqu.data.length = strlen(maxAssocExceededEvent);
1219 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001220 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 break;
1222 case eSAP_STA_ASSOC_IND:
1223 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001224
1225 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001226 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001227 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1228 return VOS_STATUS_SUCCESS;
1229
1230 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301231 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301232 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1233 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301234 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301235 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001236 return VOS_STATUS_SUCCESS;
1237
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001239 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 goto stopbss;
1241 return VOS_STATUS_SUCCESS;
1242 }
1243 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1244 return VOS_STATUS_SUCCESS;
1245
1246stopbss :
1247 {
1248 v_BYTE_t we_custom_event[64];
1249 char *stopBssEvent = "STOP-BSS.response";//17
1250 int event_len = strlen(stopBssEvent);
1251
1252 hddLog(LOG1, FL("BSS stop status = %s"),
1253 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1254 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1255
1256 /* Change the BSS state now since, as we are shutting things down,
1257 * we don't want interfaces to become re-enabled */
1258 pHostapdState->bssState = BSS_STOP;
1259
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301260 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1261 {
1262 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1263 {
1264 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1265 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1266 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1267 }
1268
1269 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1270 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1271 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1272 }
1273
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 /* Stop the pkts from n/w stack as we are going to free all of
1275 * the TX WMM queues for all STAID's */
1276 hdd_hostapd_stop(dev);
1277
1278 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301279 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1280 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1281 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001282
Amar Singhal37e6f052013-03-05 16:16:54 -08001283 /* once the event is set, structure dev/pHostapdAdapter should
1284 * not be touched since they are now subject to being deleted
1285 * by another thread */
1286 if (eSAP_STOP_BSS_EVENT == sapEvent)
1287 vos_event_set(&pHostapdState->vosEvent);
1288
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 /* notify userspace that the BSS has stopped */
1290 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1291 memcpy(&we_custom_event, stopBssEvent, event_len);
1292 memset(&wrqu, 0, sizeof(wrqu));
1293 wrqu.data.length = event_len;
1294 we_event = IWEVCUSTOM;
1295 we_custom_event_generic = we_custom_event;
1296 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001297 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 }
1299 return VOS_STATUS_SUCCESS;
1300}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001301
1302int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001304 eCsrEncryptionType *pEncryptType,
1305 eCsrEncryptionType *mcEncryptType,
1306 eCsrAuthType *pAuthType,
1307 v_BOOL_t *pMFPCapable,
1308 v_BOOL_t *pMFPRequired,
1309 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 u_int8_t *gen_ie )
1311{
1312 tDot11fIERSN dot11RSNIE;
1313 tDot11fIEWPA dot11WPAIE;
1314
1315 tANI_U8 *pRsnIe;
1316 tANI_U16 RSNIeLen;
1317
1318 if (NULL == halHandle)
1319 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001320 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 return -EINVAL;
1322 }
1323
1324 // Validity checks
1325 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1326 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1327 return -EINVAL;
1328 // Type check
1329 if ( gen_ie[0] == DOT11F_EID_RSN)
1330 {
1331 // Validity checks
1332 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1333 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1334 {
1335 return VOS_STATUS_E_FAILURE;
1336 }
1337 // Skip past the EID byte and length byte
1338 pRsnIe = gen_ie + 2;
1339 RSNIeLen = gen_ie_len - 2;
1340 // Unpack the RSN IE
1341 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1342 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1343 pRsnIe,
1344 RSNIeLen,
1345 &dot11RSNIE);
1346 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001347 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001348 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001349 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001350 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 /*Here we have followed the apple base code,
1352 but probably I suspect we can do something different*/
1353 //dot11RSNIE.akm_suite_count
1354 // Just translate the FIRST one
1355 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1356 //dot11RSNIE.pwise_cipher_suite_count
1357 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1358 //dot11RSNIE.gp_cipher_suite_count
1359 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1360 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001361 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1362 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001363
1364 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1365 } else
1366 if (gen_ie[0] == DOT11F_EID_WPA)
1367 {
1368 // Validity checks
1369 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1370 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1371 {
1372 return VOS_STATUS_E_FAILURE;
1373 }
1374 // Skip past the EID byte and length byte - and four byte WiFi OUI
1375 pRsnIe = gen_ie + 2 + 4;
1376 RSNIeLen = gen_ie_len - (2 + 4);
1377 // Unpack the WPA IE
1378 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1379 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1380 pRsnIe,
1381 RSNIeLen,
1382 &dot11WPAIE);
1383 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001384 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001385 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001386 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001387 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 //dot11WPAIE.auth_suite_count
1389 // Just translate the FIRST one
1390 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1391 //dot11WPAIE.unicast_cipher_count
1392 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1393 //dot11WPAIE.unicast_cipher_count
1394 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001395 *pMFPCapable = VOS_FALSE;
1396 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 }
1398 else
1399 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001400 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 return VOS_STATUS_E_FAILURE;
1402 }
1403 return VOS_STATUS_SUCCESS;
1404}
Leo Chang614d2072013-08-22 14:59:44 -07001405
Leo Chang0b0e45a2013-12-15 15:18:55 -08001406#ifdef FEATURE_WLAN_CH_AVOID
1407/**---------------------------------------------------------------------------
1408
1409 \brief hdd_hostapd_freq_to_chn() -
1410
1411 Input frequency translated into channel number
1412
1413 \param - freq input frequency with order of kHz
1414
1415 \return - corresponding channel number.
1416 incannot find correct channel number, return 0
1417
1418 --------------------------------------------------------------------------*/
1419v_U16_t hdd_hostapd_freq_to_chn
1420(
1421 v_U16_t freq
1422)
1423{
1424 int loop;
1425
1426 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1427 {
1428 if (rfChannels[loop].targetFreq == freq)
1429 {
1430 return rfChannels[loop].channelNum;
1431 }
1432 }
1433
1434 return (0);
1435}
1436
1437/*==========================================================================
1438 FUNCTION sapUpdateUnsafeChannelList
1439
1440 DESCRIPTION
1441 Function Undate unsafe channel list table
1442
1443 DEPENDENCIES
1444 NA.
1445
1446 PARAMETERS
1447
1448 IN
1449 pSapCtx : SAP context pointer, include unsafe channel list
1450
1451 RETURN VALUE
1452 NONE
1453============================================================================*/
1454void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1455 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1456{
1457 v_U16_t i, j;
1458
1459 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1460 sizeof(pHddCtx->unsafeChannelList));
1461 if (0 == unsafeChannelCount)
1462 {
1463 pHddCtx->unsafeChannelCount = 0;
1464 }
1465 else
1466 {
c_hpothu8de53e42014-08-22 15:00:37 +05301467 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1468 {
1469 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1470 FL("unsafeChannelCount%hd greater than %d"),
1471 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1472 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1473 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001474 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1475 unsafeChannelList,
1476 unsafeChannelCount * sizeof(tANI_U16));
1477 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1478 }
1479
1480 /* Flush, default set all channel safe */
1481 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1482 {
1483 safeChannels[i].isSafe = VOS_TRUE;
1484 }
1485
1486 /* Try to find unsafe channel */
1487 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1488 {
1489 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1490 {
1491 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1492 {
1493 /* Found unsafe channel, update it */
1494 safeChannels[j].isSafe = VOS_FALSE;
1495 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1496 "%s : CH %d is not safe",
1497 __func__, pHddCtx->unsafeChannelList[i]);
1498 break;
1499 }
1500 }
1501 }
1502
1503 return;
1504}
1505
1506/**---------------------------------------------------------------------------
1507
1508 \brief hdd_hostapd_ch_avoid_cb() -
1509
1510 Avoid channel notification from FW handler.
1511 FW will send un-safe channle list to avoid overwrapping.
1512 hostapd should not use notified channel
1513
1514 \param - pAdapter HDD adapter pointer
1515 indParam channel avoid notification parameter
1516
1517 \return - None
1518
1519 --------------------------------------------------------------------------*/
1520void hdd_hostapd_ch_avoid_cb
1521(
1522 void *pAdapter,
1523 void *indParam
1524)
1525{
1526 hdd_adapter_t *pHostapdAdapter = NULL;
1527 hdd_context_t *hddCtxt;
1528 tSirChAvoidIndType *chAvoidInd;
1529 v_U8_t rangeLoop;
1530 v_U16_t channelLoop;
1531 v_U16_t dupCheck;
1532 v_U16_t startChannel;
1533 v_U16_t endChannel;
1534 v_U16_t unsafeChannelCount = 0;
1535 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1536 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001537 tHddAvoidFreqList hddAvoidFreqList;
1538 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301539#ifdef WLAN_FEATURE_AP_HT40_24G
1540 ptSapContext pSapCtx = NULL;
1541 tHalHandle hHal;
1542 v_U8_t cbMode;
1543 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1544 v_U32_t delay;
1545#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001546
1547 /* Basic sanity */
1548 if ((NULL == pAdapter) || (NULL == indParam))
1549 {
1550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1551 "%s : Invalid arguments", __func__);
1552 return;
1553 }
1554
1555 hddCtxt = (hdd_context_t *)pAdapter;
1556 chAvoidInd = (tSirChAvoidIndType *)indParam;
1557 pVosContext = hddCtxt->pvosContext;
1558
1559 /* Make unsafe channel list */
1560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1561 "%s : band count %d",
1562 __func__, chAvoidInd->avoidRangeCount);
1563 vos_mem_zero((void *)unsafeChannelList,
1564 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1565 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1566 {
1567 startChannel = hdd_hostapd_freq_to_chn(
1568 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1569 endChannel = hdd_hostapd_freq_to_chn(
1570 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1572 "%s : start %d : %d, end %d : %d",
1573 __func__,
1574 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1575 startChannel,
1576 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1577 endChannel);
1578 for (channelLoop = startChannel;
1579 channelLoop < (endChannel + 1);
1580 channelLoop++)
1581 {
1582 /* Channel duplicate check routine */
1583 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1584 {
1585 if (unsafeChannelList[dupCheck] == channelLoop)
1586 {
1587 /* This channel is duplicated */
1588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1589 "%s : found duplicated channel %d",
1590 __func__, channelLoop);
1591 break;
1592 }
1593 }
1594 if (dupCheck == unsafeChannelCount)
1595 {
c_hpothu8de53e42014-08-22 15:00:37 +05301596 int ii;
1597 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1598 {
1599 if (channelLoop == safeChannels[ii].channelNumber)
1600 {
1601 unsafeChannelList[unsafeChannelCount] = channelLoop;
1602 unsafeChannelCount++;
1603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1604 "%s : unsafe channel %d, count %d",
1605 __func__,
1606 channelLoop, unsafeChannelCount);
1607 }
1608 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001609 }
1610 else
1611 {
1612 /* DUP, do nothing */
1613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1614 "%s : duplicated channel %d",
1615 __func__, channelLoop);
1616 }
1617 }
1618 }
1619 /* Update unsafe channel cache
1620 * WCN Platform Driver cache */
1621 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1622 unsafeChannelCount);
1623
1624 /* Store into local cache
1625 * Start with STA and later start SAP
1626 * in this scenario, local cache will be used */
1627 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1628 unsafeChannelList,
1629 unsafeChannelCount);
1630
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001631 /* generate vendor specific event */
1632 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1633 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1634 {
1635 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1636 chAvoidInd->avoidFreqRange[i].startFreq;
1637 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1638 chAvoidInd->avoidFreqRange[i].endFreq;
1639 }
1640 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1641
1642 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1643
Leo Chang0b0e45a2013-12-15 15:18:55 -08001644 /* Get SAP context first
1645 * SAP and P2PGO would not concurrent */
1646 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301647#ifdef WLAN_FEATURE_AP_HT40_24G
1648 if (NULL == pHostapdAdapter)
1649 {
1650 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1651 }
1652#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301653 if ((pHostapdAdapter) &&
1654 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1655 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001656 {
1657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1658 "%s : Current operation channel %d",
1659 __func__,
1660 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1661 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1662 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301663 if ((unsafeChannelList[channelLoop] ==
1664 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1665 {
1666 if ((AUTO_CHANNEL_SELECT ==
1667 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1668 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1669 {
1670 /* current operating channel is un-safe channel
1671 * restart driver */
1672 hdd_hostapd_stop(pHostapdAdapter->dev);
1673 /* On LE, this event is handled by wlan-services to
1674 * restart SAP. On android, this event would be
1675 * ignored.
1676 */
1677 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1678 NULL, 0);
1679 }
1680 return;
1681 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001682 }
1683 }
1684
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301685#ifdef WLAN_FEATURE_AP_HT40_24G
1686 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1687 {
1688 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1689
1690 if(pSapCtx == NULL)
1691 {
1692 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1693 FL("psapCtx is NULL"));
1694 return;
1695 }
1696
1697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1698 FL("SAP Secondary channel: %d "),
1699 pSapCtx->sap_sec_chan);
1700
1701 /* tHalHandle */
1702 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1703
1704 if (NULL == hHal)
1705 {
1706 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1707 FL("In invalid hHal"));
1708 return;
1709 }
1710
1711 cbMode = sme_GetChannelBondingMode24G(hHal);
1712
1713 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1714 FL("Selected Channel bonding : %d"), cbMode);
1715
1716 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1717 {
1718 int i;
1719 eHalStatus halStatus;
1720
1721 for (i = 0; i < unsafeChannelCount; i++)
1722 {
1723 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1724 {
1725 /* Current SAP Secondary channel is un-safe channel */
1726 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1727 FL("Move SAP from HT40 to HT20"));
1728
1729 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1730 PHY_SINGLE_CHANNEL_CENTERED);
1731
1732 if (halStatus == eHAL_STATUS_FAILURE)
1733 {
1734 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1735 FL("Failed to change HT20/40 mode"));
1736 return;
1737 }
1738
1739 /* Disable Channel Bonding for 2.4GHz */
1740 sme_UpdateChannelBondingMode24G(hHal,
1741 PHY_SINGLE_CHANNEL_CENTERED);
1742 return;
1743 }
1744 }
1745 }
1746
1747 if ((!pSapCtx->numHT40IntoSta)
1748 && (pHostapdAdapter)
1749 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1750 {
1751 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1752 * are Safe then start HT20/40 timer to Move SAP from HT20
1753 * to HT40.
1754 */
1755 if (((!unsafeChannelCount)
1756 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1757 {
1758 /* Stop Previous Running HT20/40 Timer & Start timer
1759 with (OBSS TransitionDelayFactor * obss interval)
1760 delay after time out move AP from HT20 -> HT40
1761 mode
1762 */
1763 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1764 {
1765 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1766 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1767 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1768 FL("Failed to Stop HT20/40 timer"));
1769 }
1770
1771 delay =
1772 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1773
1774 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1775 FL("Start HT20/40 transition timer (%d sec)"), delay);
1776
1777 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1778 (delay * 1000));
1779
1780 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1781 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1782 FL("Failed to Start HT20/40 timer"));
1783 }
1784 else
1785 {
1786 /* Stop HT20/40 Timer */
1787 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1788 {
1789 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1790 FL("Stop HT20/40 transition timer"));
1791 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1792 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1793 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1794 FL("Failed to Stop HT20/40 timer"));
1795 }
1796 }
1797 }
1798 }
1799#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001800 return;
1801}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001802#endif /* FEATURE_WLAN_CH_AVOID */
1803
Jeff Johnson295189b2012-06-20 16:38:30 -07001804int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301805static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 struct iw_request_info *info,
1807 union iwreq_data *wrqu, char *extra)
1808{
1809 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001810 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301811 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 int *value = (int *)extra;
1813 int sub_cmd = value[0];
1814 int set_value = value[1];
1815 eHalStatus status;
1816 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001817 v_CONTEXT_t pVosContext;
1818
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301819 ENTER();
1820
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301821 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001822 {
1823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301824 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001825 __func__);
1826 return -1;
1827 }
1828
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301829 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1830 ret = wlan_hdd_validate_context(pHddCtx);
1831 if (0 != ret)
1832 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301833 return -1;
1834 }
1835
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001836 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1837 if (!hHal)
1838 {
1839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1840 "%s: Hal ctx is null", __func__);
1841 return -1;
1842 }
1843
1844 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1845 if (!pVosContext)
1846 {
1847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1848 "%s: Vos ctx is null", __func__);
1849 return -1;
1850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
1852 switch(sub_cmd)
1853 {
1854
1855 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001856 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301858 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 }
1860 break;
1861
1862 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301863 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1865 {
1866 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1867 ret = -EINVAL;
1868 }
1869 else
1870 {
1871 WLANSAP_SetMode(pVosContext, set_value);
1872 }
1873 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301874
1875 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1876 if ((0 != set_value) && (1 != set_value))
1877 {
1878 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1879 ret = -EINVAL;
1880 }
1881 else
1882 {
1883 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1884 }
1885 break;
1886
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 case QCSAP_PARAM_MAX_ASSOC:
1888 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1889 {
1890 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1891 ret = -EINVAL;
1892 }
1893 else
1894 {
1895 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1896 {
1897 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1898 "Setting it to max allowed and continuing"),
1899 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1900 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1901 }
1902 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1903 set_value, NULL, eANI_BOOLEAN_FALSE);
1904 if ( status != eHAL_STATUS_SUCCESS )
1905 {
1906 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1907 status);
1908 ret = -EIO;
1909 }
1910 }
1911 break;
1912
1913 case QCSAP_PARAM_HIDE_SSID:
1914 {
1915 eHalStatus status = eHAL_STATUS_SUCCESS;
1916 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1917 if(eHAL_STATUS_SUCCESS != status)
1918 {
1919 hddLog(VOS_TRACE_LEVEL_ERROR,
1920 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001921 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 return status;
1923 }
1924 break;
1925 }
1926
Leo Chang614d2072013-08-22 14:59:44 -07001927 case QCSAP_PARAM_SET_MC_RATE:
1928 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001929 tSirRateUpdateInd *rateUpdate;
1930
1931 rateUpdate = (tSirRateUpdateInd *)
1932 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1933 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001934 {
1935 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001936 "%s: SET_MC_RATE indication alloc fail", __func__);
1937 ret = -1;
1938 break;
1939 }
1940 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1941
1942 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1943 /* Ignore unicast */
1944 rateUpdate->ucastDataRate = -1;
1945 rateUpdate->mcastDataRate24GHz = set_value;
1946 rateUpdate->mcastDataRate5GHz = set_value;
1947 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1948 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1949 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1950 if (eHAL_STATUS_SUCCESS != status)
1951 {
1952 hddLog(VOS_TRACE_LEVEL_ERROR,
1953 "%s: SET_MC_RATE failed", __func__);
1954 vos_mem_free(rateUpdate);
1955 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001956 }
1957 break;
1958 }
1959
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 default:
1961 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1962 sub_cmd, set_value);
1963 ret = -EINVAL;
1964 break;
1965 }
1966
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301967 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 return ret;
1969}
1970
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301971int
1972static iw_softap_setparam(struct net_device *dev,
1973 struct iw_request_info *info,
1974 union iwreq_data *wrqu, char *extra)
1975{
1976 int ret;
1977
1978 vos_ssr_protect(__func__);
1979 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1980 vos_ssr_unprotect(__func__);
1981
1982 return ret;
1983}
Jeff Johnson295189b2012-06-20 16:38:30 -07001984
1985int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301986static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 struct iw_request_info *info,
1988 union iwreq_data *wrqu, char *extra)
1989{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301990 hdd_adapter_t *pHostapdAdapter;
1991 tHalHandle hHal;
1992 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 int *value = (int *)extra;
1994 int sub_cmd = value[0];
1995 eHalStatus status;
1996 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301997 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301999 ENTER();
2000
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302001 pHostapdAdapter = (netdev_priv(dev));
2002 if (NULL == pHostapdAdapter)
2003 {
2004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2005 "%s: Adapter is NULL",__func__);
2006 return -EINVAL;
2007 }
2008 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2009 ret = wlan_hdd_validate_context(pHddCtx);
2010 if (0 != ret)
2011 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302012 return ret;
2013 }
2014 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2015 if (NULL == hHal)
2016 {
2017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2018 "%s: Hal Context is NULL",__func__);
2019 return -EINVAL;
2020 }
2021 pVosContext = pHddCtx->pvosContext;
2022 if (NULL == pVosContext)
2023 {
2024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2025 "%s: pVosContext Context is NULL",__func__);
2026 return -EINVAL;
2027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 switch (sub_cmd)
2029 {
2030 case QCSAP_PARAM_MAX_ASSOC:
2031 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2032 if (eHAL_STATUS_SUCCESS != status)
2033 {
c_hpothuffdb5272013-10-02 16:42:35 +05302034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2035 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 ret = -EIO;
2037 }
Girish Gowli385be612014-09-18 11:17:20 +05302038
2039#ifdef WLAN_SOFTAP_VSTA_FEATURE
2040 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2041 {
2042 if (*value > VSTA_NUM_ASSOC_STA)
2043 {
2044 *value = VSTA_NUM_ASSOC_STA;
2045 }
2046 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2047 (*value > (VSTA_NUM_ASSOC_STA -
2048 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2049 {
2050 *value = (VSTA_NUM_ASSOC_STA -
2051 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2052 }
2053 }
2054 else
2055#endif
2056 {
2057 if (*value > NUM_ASSOC_STA)
2058 {
2059 *value = NUM_ASSOC_STA;
2060 }
2061 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2062 (*value > (NUM_ASSOC_STA -
2063 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2064 {
2065 *value = (NUM_ASSOC_STA -
2066 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2067 }
2068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302070
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002072 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 {
c_hpothuffdb5272013-10-02 16:42:35 +05302074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2075 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302076 ret = -EIO;
2077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 *value = 0;
2079 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302080
Jeff Johnson43971f52012-07-17 12:26:56 -07002081 case QCSAP_PARAM_GET_WLAN_DBG:
2082 {
2083 vos_trace_display();
2084 *value = 0;
2085 break;
2086 }
2087
2088 case QCSAP_PARAM_AUTO_CHANNEL:
2089 {
2090 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2091 break;
2092 }
2093
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 default:
2095 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2096 ret = -EINVAL;
2097 break;
2098
2099 }
2100
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302101 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 return ret;
2103}
2104
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302105int
2106static iw_softap_getparam(struct net_device *dev,
2107 struct iw_request_info *info,
2108 union iwreq_data *wrqu, char *extra)
2109{
2110 int ret;
2111
2112 vos_ssr_protect(__func__);
2113 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2114 vos_ssr_unprotect(__func__);
2115
2116 return ret;
2117}
Jeff Johnson295189b2012-06-20 16:38:30 -07002118/* Usage:
2119 BLACK_LIST = 0
2120 WHITE_LIST = 1
2121 ADD MAC = 0
2122 REMOVE MAC = 1
2123
2124 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2125 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2126 while using this ioctl
2127
2128 Syntax:
2129 iwpriv softap.0 modify_acl
2130 <6 octet mac addr> <list type> <cmd type>
2131
2132 Examples:
2133 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2134 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2135 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2136 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2137*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302138int __iw_softap_modify_acl(struct net_device *dev,
2139 struct iw_request_info *info,
2140 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002141{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302142 hdd_adapter_t *pHostapdAdapter;
2143 v_CONTEXT_t pVosContext;
2144 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 v_BYTE_t *value = (v_BYTE_t*)extra;
2146 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2147 int listType, cmd, i;
2148 int ret = 0; /* success */
2149
2150 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302151 pHostapdAdapter = (netdev_priv(dev));
2152 if (NULL == pHostapdAdapter)
2153 {
2154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2155 "%s: Adapter is NULL",__func__);
2156 return -EINVAL;
2157 }
2158 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2159 ret = wlan_hdd_validate_context(pHddCtx);
2160 if (0 != ret)
2161 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302162 return ret;
2163 }
2164 pVosContext = pHddCtx->pvosContext;
2165 if (NULL == pVosContext)
2166 {
2167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2168 "%s: Vos Context is NULL",__func__);
2169 return -EINVAL;
2170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2172 {
2173 pPeerStaMac[i] = *(value+i);
2174 }
2175 listType = (int)(*(value+i));
2176 i++;
2177 cmd = (int)(*(value+i));
2178
Arif Hussain24bafea2013-11-15 15:10:03 -08002179 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2180 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2183 != VOS_STATUS_SUCCESS)
2184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002185 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 ret = -EIO;
2187 }
2188 EXIT();
2189 return ret;
2190}
2191
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302192int iw_softap_modify_acl(struct net_device *dev,
2193 struct iw_request_info *info,
2194 union iwreq_data *wrqu, char *extra)
2195{
2196 int ret;
2197
2198 vos_ssr_protect(__func__);
2199 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2200 vos_ssr_unprotect(__func__);
2201
2202 return ret;
2203}
2204
Jeff Johnson295189b2012-06-20 16:38:30 -07002205int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302206static __iw_softap_getchannel(struct net_device *dev,
2207 struct iw_request_info *info,
2208 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002209{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302210 hdd_adapter_t *pHostapdAdapter;
2211 hdd_context_t *pHddCtx;
2212 int ret = 0;
2213 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302214
2215 ENTER();
2216
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302217 pHostapdAdapter = (netdev_priv(dev));
2218 if (NULL == pHostapdAdapter)
2219 {
2220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2221 "%s: Adapter is NULL",__func__);
2222 return -EINVAL;
2223 }
2224 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2225 ret = wlan_hdd_validate_context(pHddCtx);
2226 if (0 != ret)
2227 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302228 return ret;
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302231 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002232
Jeff Johnson43971f52012-07-17 12:26:56 -07002233 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302234
2235 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 return 0;
2237}
2238
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302239
Jeff Johnsone7245742012-09-05 17:12:55 -07002240int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302241static iw_softap_getchannel(struct net_device *dev,
2242 struct iw_request_info *info,
2243 union iwreq_data *wrqu, char *extra)
2244{
2245 int ret;
2246
2247 vos_ssr_protect(__func__);
2248 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2249 vos_ssr_unprotect(__func__);
2250
2251 return ret;
2252}
2253
2254int
2255static __iw_softap_set_max_tx_power(struct net_device *dev,
2256 struct iw_request_info *info,
2257 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002258{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302259 hdd_adapter_t *pHostapdAdapter;
2260 tHalHandle hHal;
2261 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002262 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302263 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002264 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2265 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2266
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302267 ENTER();
2268
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302269 pHostapdAdapter = (netdev_priv(dev));
2270 if (NULL == pHostapdAdapter)
2271 {
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2273 "%s: Adapter is NULL",__func__);
2274 return -EINVAL;
2275 }
2276 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2277 ret = wlan_hdd_validate_context(pHddCtx);
2278 if (0 != ret)
2279 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302280 return ret;
2281 }
2282 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2283 if (NULL == hHal)
2284 {
2285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2286 "%s: Hal Context is NULL",__func__);
2287 return -EINVAL;
2288 }
schang86c22c42013-03-13 18:41:24 -07002289 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002290 return -ENOMEM;
2291
Leo Changd37675a2013-08-01 13:19:45 -07002292 /* Assign correct slef MAC address */
2293 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2294 VOS_MAC_ADDR_SIZE);
2295 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2296 VOS_MAC_ADDR_SIZE);
2297
schang86c22c42013-03-13 18:41:24 -07002298 set_value = value[0];
2299 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2300 {
2301 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002302 __func__);
schang86c22c42013-03-13 18:41:24 -07002303 return -EIO;
2304 }
2305
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302306 EXIT();
schang86c22c42013-03-13 18:41:24 -07002307 return 0;
2308}
2309
2310int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302311static iw_softap_set_max_tx_power(struct net_device *dev,
2312 struct iw_request_info *info,
2313 union iwreq_data *wrqu, char *extra)
2314{
2315 int ret;
2316
2317 vos_ssr_protect(__func__);
2318 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2319 vos_ssr_unprotect(__func__);
2320
2321 return ret;
2322}
2323
2324
2325int
2326static __iw_display_data_path_snapshot(struct net_device *dev,
2327 struct iw_request_info *info,
2328 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302329{
2330
2331 /* Function intitiating dumping states of
2332 * HDD(WMM Tx Queues)
2333 * TL State (with Per Client infor)
2334 * DXE Snapshot (Called at the end of TL Snapshot)
2335 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302336 hdd_adapter_t *pHostapdAdapter;
2337 hdd_context_t *pHddCtx;
2338 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302339
2340 ENTER();
2341
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302342 pHostapdAdapter = (netdev_priv(dev));
2343 if (NULL == pHostapdAdapter)
2344 {
2345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2346 "%s: Adapter is NULL",__func__);
2347 return -EINVAL;
2348 }
2349 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2350 ret = wlan_hdd_validate_context(pHddCtx);
2351 if (0 != ret)
2352 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302353 return ret;
2354 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302355 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302356 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302357
2358 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302359 return 0;
2360}
2361
2362int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302363static iw_display_data_path_snapshot(struct net_device *dev,
2364 struct iw_request_info *info,
2365 union iwreq_data *wrqu, char *extra)
2366{
2367 int ret;
2368
2369 vos_ssr_protect(__func__);
2370 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2371 vos_ssr_unprotect(__func__);
2372
2373 return ret;
2374}
2375
2376int
2377static __iw_softap_set_tx_power(struct net_device *dev,
2378 struct iw_request_info *info,
2379 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002380{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302381 hdd_adapter_t *pHostapdAdapter;
2382 hdd_context_t *pHddCtx;
2383 v_CONTEXT_t pVosContext;
2384 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002385 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302386 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002387 ptSapContext pSapCtx = NULL;
2388
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302389 ENTER();
2390
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302391 pHostapdAdapter = (netdev_priv(dev));
2392 if (NULL == pHostapdAdapter)
2393 {
2394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2395 "%s: Adapter is NULL",__func__);
2396 return -EINVAL;
2397 }
2398 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2399 ret = wlan_hdd_validate_context(pHddCtx);
2400 if (0 != ret)
2401 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302402 return ret;
2403 }
2404 pVosContext = pHddCtx->pvosContext;
2405 if (NULL == pVosContext)
2406 {
2407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2408 "%s: Vos Context is NULL",__func__);
2409 return -EINVAL;
2410 }
2411 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2412 if (NULL == hHal)
2413 {
2414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2415 "%s: Hal Context is NULL",__func__);
2416 return -EINVAL;
2417 }
schang86c22c42013-03-13 18:41:24 -07002418 if (NULL == value)
2419 return -ENOMEM;
2420
2421 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2422 if (NULL == pSapCtx)
2423 {
2424 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2425 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2426 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002427 }
2428
2429 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002430 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002431 {
schang86c22c42013-03-13 18:41:24 -07002432 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002433 __func__);
2434 return -EIO;
2435 }
2436
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302437 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002438 return 0;
2439}
2440
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302441int
2442static iw_softap_set_tx_power(struct net_device *dev,
2443 struct iw_request_info *info,
2444 union iwreq_data *wrqu, char *extra)
2445{
2446 int ret;
2447
2448 vos_ssr_protect(__func__);
2449 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2450 vos_ssr_unprotect(__func__);
2451
2452 return ret;
2453}
2454
Kiet Lambcf38522013-10-26 18:28:27 +05302455/**---------------------------------------------------------------------------
2456
2457 \brief iw_softap_set_trafficmonitor() -
2458 This function dynamically enable/disable traffic monitor functonality
2459 the command iwpriv wlanX setTrafficMon <value>.
2460
2461 \param - dev - Pointer to the net device.
2462 - addr - Pointer to the sockaddr.
2463 \return - 0 for success, non zero for failure
2464
2465 --------------------------------------------------------------------------*/
2466
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302467static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2468 struct iw_request_info *info,
2469 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302470{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302471 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302472 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302473 hdd_context_t *pHddCtx;
2474 int status;
2475
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302476 ENTER();
2477
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302478 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302479 if (NULL == pAdapter)
2480 {
2481 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2482 "%s: HDD adapter is Null", __func__);
2483 return -ENODEV;
2484 }
2485
2486 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2487
2488 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302489 if (0 != status)
2490 {
Kiet Lambcf38522013-10-26 18:28:27 +05302491 return status;
2492 }
2493
2494 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2495
2496 if (NULL == isSetTrafficMon)
2497 {
2498 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2499 "%s: Invalid SAP pointer from extra", __func__);
2500 return -ENOMEM;
2501 }
2502
2503 if (TRUE == *isSetTrafficMon)
2504 {
2505 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2506 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2507 {
2508 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2509 "%s: failed to Start Traffic Monitor timer ", __func__ );
2510 return -EIO;
2511 }
2512 }
2513 else if (FALSE == *isSetTrafficMon)
2514 {
2515 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2516 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2517 {
2518 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2519 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2520 return -EIO;
2521 }
2522
2523 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302524
2525 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302526 return 0;
2527}
2528
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302529static int iw_softap_set_trafficmonitor(struct net_device *dev,
2530 struct iw_request_info *info,
2531 union iwreq_data *wrqu, char *extra)
2532{
2533 int ret;
2534
2535 vos_ssr_protect(__func__);
2536 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2537 vos_ssr_unprotect(__func__);
2538
2539 return ret;
2540}
2541
Jeff Johnson295189b2012-06-20 16:38:30 -07002542#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2543
2544int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302545static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2546 struct iw_request_info *info,
2547 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002548{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302549 hdd_adapter_t *pHostapdAdapter;
2550 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302551 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002552 char *buf;
2553 int cnt = 0;
2554 int left;
2555 int ret = 0;
2556 /* maclist_index must be u32 to match userspace */
2557 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302558 v_CONTEXT_t pVosContext = NULL;
2559 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302561 ENTER();
2562
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302563 pHostapdAdapter = (netdev_priv(dev));
2564 if (NULL == pHostapdAdapter)
2565 {
2566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2567 "%s: Adapter is NULL",__func__);
2568 return -EINVAL;
2569 }
2570 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2571 ret = wlan_hdd_validate_context(pHddCtx);
2572 if (0 != ret)
2573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302574 return ret;
2575 }
2576
Jeff Johnson224f3702014-03-26 11:09:47 -07002577 /*
2578 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2579 * number, and even numbered iocts are supposed to have "set"
2580 * semantics. Hence the wireless extensions support in the kernel
2581 * won't correctly copy the result to userspace, so the ioctl
2582 * handler itself must copy the data. Output format is 32-bit
2583 * record length, followed by 0 or more 6-byte STA MAC addresses.
2584 *
2585 * Further note that due to the incorrect semantics, the "iwpriv"
2586 * userspace application is unable to correctly invoke this API,
2587 * hence it is not registered in the hostapd_private_args. This
2588 * API can only be invoked by directly invoking the ioctl() system
2589 * call.
2590 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002591
Jeff Johnson224f3702014-03-26 11:09:47 -07002592 /* make sure userspace allocated a reasonable buffer size */
2593 if (wrqu->data.length < sizeof(maclist_index)) {
2594 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2595 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302598 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2599 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2600 if(pSapCtx == NULL){
2601 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2602 FL("psapCtx is NULL"));
2603 return -EFAULT;
2604 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302605
2606 /* allocate local buffer to build the response */
2607 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2608 if (!buf) {
2609 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2610 return -ENOMEM;
2611 }
2612
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302613 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002614 /* start indexing beyond where the record count will be written */
2615 maclist_index = sizeof(maclist_index);
2616 left = wrqu->data.length - maclist_index;
2617
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302618 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002619 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2620 if ((pStaInfo[cnt].isUsed) &&
2621 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2622 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2623 VOS_MAC_ADDR_SIZE);
2624 maclist_index += VOS_MAC_ADDR_SIZE;
2625 left -= VOS_MAC_ADDR_SIZE;
2626 }
2627 cnt++;
2628 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302629 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002630
2631 *((u32 *)buf) = maclist_index;
2632 wrqu->data.length = maclist_index;
2633 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2634 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2635 ret = -EFAULT;
2636 }
2637 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302638
2639 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002640 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641}
2642
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302643int
2644static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2645 struct iw_request_info *info,
2646 union iwreq_data *wrqu, char *extra)
2647{
2648 int ret;
2649
2650 vos_ssr_protect(__func__);
2651 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2652 vos_ssr_unprotect(__func__);
2653
2654 return ret;
2655}
2656
Jeff Johnson295189b2012-06-20 16:38:30 -07002657/* Usage:
2658 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2659 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2660 while using this ioctl
2661
2662 Syntax:
2663 iwpriv softap.0 disassoc_sta <6 octet mac address>
2664
2665 e.g.
2666 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2667 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2668*/
2669
2670int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302671static __iw_softap_disassoc_sta(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002674{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302675 hdd_adapter_t *pHostapdAdapter;
2676 hdd_context_t *pHddCtx;
2677 v_U8_t *peerMacAddr;
2678 int ret = 0;
2679
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302681 pHostapdAdapter = (netdev_priv(dev));
2682 if (NULL == pHostapdAdapter)
2683 {
2684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2685 "%s: Adapter is NULL",__func__);
2686 return -EINVAL;
2687 }
2688 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2689 ret = wlan_hdd_validate_context(pHddCtx);
2690 if (0 != ret)
2691 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302692 return ret;
2693 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302694 /* iwpriv tool or framework calls this ioctl with
2695 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302697 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002698
Arif Hussain24bafea2013-11-15 15:10:03 -08002699 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2700 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2702 EXIT();
2703 return 0;
2704}
2705
2706int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302707static iw_softap_disassoc_sta(struct net_device *dev,
2708 struct iw_request_info *info,
2709 union iwreq_data *wrqu, char *extra)
2710{
2711 int ret;
2712
2713 vos_ssr_protect(__func__);
2714 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2715 vos_ssr_unprotect(__func__);
2716
2717 return ret;
2718}
2719
2720int
2721static __iw_softap_ap_stats(struct net_device *dev,
2722 struct iw_request_info *info,
2723 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002724{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302725 hdd_adapter_t *pHostapdAdapter;
2726 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 WLANTL_TRANSFER_STA_TYPE statBuffer;
2728 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302729 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002730
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302731 ENTER();
2732
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302733 pHostapdAdapter = (netdev_priv(dev));
2734 if (NULL == pHostapdAdapter)
2735 {
2736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2737 "%s: Adapter is NULL",__func__);
2738 return -EINVAL;
2739 }
2740 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2741 ret = wlan_hdd_validate_context(pHddCtx);
2742 if (0 != ret)
2743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302744 return ret;
2745 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002746 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002747 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2748 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002749
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302750 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002751 if(NULL == pstatbuf) {
2752 hddLog(LOG1, "unable to allocate memory");
2753 return -ENOMEM;
2754 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302755
2756 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002757 "RUF=%d RMF=%d RBF=%d "
2758 "RUB=%d RMB=%d RBB=%d "
2759 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302760 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002761 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2762 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2763 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2764 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2765 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2766 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002767
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302768 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002769 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2770 kfree(pstatbuf);
2771 return -EFAULT;
2772 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302773
2774 strlcpy(extra, pstatbuf, len);
2775 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002776 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302777
2778 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 return 0;
2780}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302781int
2782static __iw_softap_ap_get_stats(struct net_device *dev,
2783 struct iw_request_info *info,
2784 union iwreq_data *wrqu, char *extra)
2785{
2786 hdd_adapter_t *pAdapter;
2787 hdd_tx_rx_stats_t *pStats;
2788
2789 ENTER();
2790 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2791 if (NULL == pAdapter)
2792 {
2793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2794 "%s: Adapter is NULL",__func__);
2795 return -EINVAL;
2796 }
2797
2798 pStats = &pAdapter->hdd_stats.hddTxRxStats;
2799 snprintf(extra, QCSAP_MAX_STR_LEN,
2800 "\nTransmit"
2801 "\ncalled %u, dropped %u, backpressured %u, queued %u"
2802 "\n dropped BK %u, BE %u, VI %u, VO %u"
2803 "\n classified BK %u, BE %u, VI %u, VO %u"
2804 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
2805 "\n queued BK %u, BE %u, VI %u, VO %u"
2806 "\nfetched %u, empty %u, lowres %u, deqerr %u"
2807 "\ndequeued %u, depressured %u, deque-depressured %u,\
2808 completed %u, flushed %u"
2809 "\n fetched BK %u, BE %u, VI %u, VO %u"
2810 "\n dequeued BK %u, BE %u, VI %u, VO %u"
2811 "\n depressured BK %u, BE %u, VI %u, VO %u"
2812 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
2813 "\n flushed BK %u, BE %u, VI %u, VO %u"
2814 "\n\nReceive"
2815 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
2816 "\n\nResetsStats"
2817 "\n",
2818 pStats->txXmitCalled,
2819 pStats->txXmitDropped,
2820 pStats->txXmitBackPressured,
2821 pStats->txXmitQueued,
2822
2823 pStats->txXmitDroppedAC[WLANTL_AC_BK],
2824 pStats->txXmitDroppedAC[WLANTL_AC_BE],
2825 pStats->txXmitDroppedAC[WLANTL_AC_VI],
2826 pStats->txXmitDroppedAC[WLANTL_AC_VO],
2827
2828 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
2829 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
2830 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
2831 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
2832
2833 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
2834 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
2835 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
2836 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
2837
2838 pStats->txXmitQueuedAC[WLANTL_AC_BK],
2839 pStats->txXmitQueuedAC[WLANTL_AC_BE],
2840 pStats->txXmitQueuedAC[WLANTL_AC_VI],
2841 pStats->txXmitQueuedAC[WLANTL_AC_VO],
2842
2843 pStats->txFetched,
2844 pStats->txFetchEmpty,
2845 pStats->txFetchLowResources,
2846 pStats->txFetchDequeueError,
2847
2848 pStats->txFetchDequeued,
2849 pStats->txFetchDePressured,
2850 pStats->txDequeDePressured,
2851 pStats->txCompleted,
2852 pStats->txFlushed,
2853
2854 pStats->txFetchedAC[WLANTL_AC_BK],
2855 pStats->txFetchedAC[WLANTL_AC_BE],
2856 pStats->txFetchedAC[WLANTL_AC_VI],
2857 pStats->txFetchedAC[WLANTL_AC_VO],
2858
2859 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
2860 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
2861 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
2862 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
2863
2864 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
2865 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
2866 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
2867 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
2868
2869 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
2870 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
2871 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
2872 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
2873
2874 pStats->txFlushedAC[WLANTL_AC_BK],
2875 pStats->txFlushedAC[WLANTL_AC_BE],
2876 pStats->txFlushedAC[WLANTL_AC_VI],
2877 pStats->txFlushedAC[WLANTL_AC_VO],
2878
2879 pStats->rxChains,
2880 pStats->rxPackets,
2881 pStats->rxDropped,
2882 pStats->rxDelivered,
2883 pStats->rxRefused
2884 );
2885
2886 wrqu->data.length = strlen(extra) + 1;
2887
2888 return 0;
2889}
2890
2891int
2892static __iw_softap_ap_clear_stats(struct net_device *dev,
2893 struct iw_request_info *info,
2894 union iwreq_data *wrqu, char *extra)
2895{
2896 hdd_adapter_t *pAdapter;
2897
2898 ENTER();
2899
2900 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2901 if (NULL == pAdapter)
2902 {
2903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2904 "%s: Adapter is NULL",__func__);
2905 return -EINVAL;
2906 }
2907
2908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
2909 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
2910 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
2911 return 0;
2912}
2913
2914
2915int
2916static iw_softap_get_stats(struct net_device *dev,
2917 struct iw_request_info *info,
2918 union iwreq_data *wrqu, char *extra)
2919{
2920 int ret;
2921 vos_ssr_protect(__func__);
2922 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
2923 vos_ssr_unprotect(__func__);
2924 return ret;
2925}
2926
2927int
2928static iw_softap_clear_stats(struct net_device *dev,
2929 struct iw_request_info *info,
2930 union iwreq_data *wrqu, char *extra)
2931{
2932 int ret;
2933 vos_ssr_protect(__func__);
2934 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
2935 vos_ssr_unprotect(__func__);
2936 return ret;
2937}
Jeff Johnson295189b2012-06-20 16:38:30 -07002938
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302939int
2940static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
2943{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302944 int ret;
2945
2946 vos_ssr_protect(__func__);
2947 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2948 vos_ssr_unprotect(__func__);
2949
2950 return ret;
2951}
2952
2953static int __iw_softap_set_channel_range(struct net_device *dev,
2954 struct iw_request_info *info,
2955 union iwreq_data *wrqu, char *extra)
2956{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302957 hdd_adapter_t *pHostapdAdapter;
2958 tHalHandle hHal;
2959 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 int *value = (int *)extra;
2961 int startChannel = value[0];
2962 int endChannel = value[1];
2963 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002964 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 int ret = 0; /* success */
2966
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302967 ENTER();
2968
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302969 pHostapdAdapter = (netdev_priv(dev));
2970 if (NULL == pHostapdAdapter)
2971 {
2972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2973 "%s: Adapter is NULL",__func__);
2974 return -EINVAL;
2975 }
2976 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2977 ret = wlan_hdd_validate_context(pHddCtx);
2978 if (0 != ret)
2979 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302980 return ret;
2981 }
2982 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2983 if (NULL == hHal)
2984 {
2985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2986 "%s: Hal Context is NULL",__func__);
2987 return -EINVAL;
2988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2990 if(status != VOS_STATUS_SUCCESS)
2991 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002992 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 startChannel,endChannel, band);
2994 ret = -EINVAL;
2995 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08002996
2997 pHddCtx->is_dynamic_channel_range_set = 1;
2998
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302999 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 return ret;
3001}
3002
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303003static int iw_softap_set_channel_range(struct net_device *dev,
3004 struct iw_request_info *info,
3005 union iwreq_data *wrqu, char *extra)
3006{
3007 int ret;
3008
3009 vos_ssr_protect(__func__);
3010 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3011 vos_ssr_unprotect(__func__);
3012
3013 return ret;
3014}
3015
3016
3017int __iw_softap_get_channel_list(struct net_device *dev,
3018 struct iw_request_info *info,
3019 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003020{
3021 v_U32_t num_channels = 0;
3022 v_U8_t i = 0;
3023 v_U8_t bandStartChannel = RF_CHAN_1;
3024 v_U8_t bandEndChannel = RF_CHAN_165;
3025 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303026 hdd_adapter_t *pHostapdAdapter;
3027 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003030 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303031 hdd_context_t *pHddCtx;
3032 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303033
3034 ENTER();
3035
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303036 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3037 if (NULL == pHostapdAdapter)
3038 {
3039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3040 "%s: Adapter is NULL",__func__);
3041 return -EINVAL;
3042 }
3043 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3044 ret = wlan_hdd_validate_context(pHddCtx);
3045 if (0 != ret)
3046 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303047 return ret;
3048 }
3049 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3050 if (NULL == hHal)
3051 {
3052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3053 "%s: Hal Context is NULL",__func__);
3054 return -EINVAL;
3055 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003056 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3057 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003058 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003059 return -EIO;
3060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 wrqu->data.length = sizeof(tChannelListInfo);
3062 ENTER();
3063
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003064 if (eCSR_BAND_24 == curBand)
3065 {
3066 bandStartChannel = RF_CHAN_1;
3067 bandEndChannel = RF_CHAN_14;
3068 }
3069 else if (eCSR_BAND_5G == curBand)
3070 {
3071 bandStartChannel = RF_CHAN_36;
3072 bandEndChannel = RF_CHAN_165;
3073 }
3074
Arif Hussain6d2a3322013-11-17 19:50:10 -08003075 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303076 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003077 bandStartChannel, bandEndChannel );
3078
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3080 {
3081 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3082 {
3083 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3084 num_channels++;
3085 }
3086 }
3087
3088 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3089
3090 temp_num_channels = num_channels;
3091
3092 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3093 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303094 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003095 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 }
3097
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303098 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3099 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 {
3101 for(i = 0; i < temp_num_channels; i++)
3102 {
3103
3104 if((channel_list->channels[i] > 35) &&
3105 (channel_list->channels[i] < 49))
3106 {
3107 vos_mem_move(&channel_list->channels[i],
3108 &channel_list->channels[i+1],
3109 temp_num_channels - (i-1));
3110 num_channels--;
3111 temp_num_channels--;
3112 i--;
3113 }
3114 }
3115 }
3116
Arif Hussain6d2a3322013-11-17 19:50:10 -08003117 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003118
3119 if (num_channels > IW_MAX_FREQUENCIES)
3120 {
3121 num_channels = IW_MAX_FREQUENCIES;
3122 }
3123
3124 channel_list->num_channels = num_channels;
3125 EXIT();
3126
3127 return 0;
3128}
3129
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303130int iw_softap_get_channel_list(struct net_device *dev,
3131 struct iw_request_info *info,
3132 union iwreq_data *wrqu, char *extra)
3133{
3134 int ret;
3135
3136 vos_ssr_protect(__func__);
3137 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3138 vos_ssr_unprotect(__func__);
3139
3140 return ret;
3141}
3142
3143static
3144int __iw_get_genie(struct net_device *dev,
3145 struct iw_request_info *info,
3146 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003147{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303148 hdd_adapter_t *pHostapdAdapter;
3149 hdd_context_t *pHddCtx;
3150 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 eHalStatus status;
3152 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3153 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303154 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303155
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303157
3158 pHostapdAdapter = (netdev_priv(dev));
3159 if (NULL == pHostapdAdapter)
3160 {
3161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3162 "%s: Adapter is NULL",__func__);
3163 return -EINVAL;
3164 }
3165 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3166 ret = wlan_hdd_validate_context(pHddCtx);
3167 if (0 != ret)
3168 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303169 return ret;
3170 }
3171 pVosContext = pHddCtx->pvosContext;
3172 if (NULL == pVosContext)
3173 {
3174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3175 "%s: vos context is not valid ",__func__);
3176 return -EINVAL;
3177 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003178 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3180 status = WLANSap_getstationIE_information(pVosContext,
3181 &length,
3182 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003183 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3184 if (wrqu->data.length < length ||
3185 copy_to_user(wrqu->data.pointer,
3186 (v_VOID_t*)genIeBytes, length))
3187 {
3188 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3189 return -EFAULT;
3190 }
3191 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192
Arif Hussain6d2a3322013-11-17 19:50:10 -08003193 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003194
3195
3196 EXIT();
3197 return 0;
3198}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303199
3200static
3201int iw_get_genie(struct net_device *dev,
3202 struct iw_request_info *info,
3203 union iwreq_data *wrqu, char *extra)
3204{
3205 int ret;
3206
3207 vos_ssr_protect(__func__);
3208 ret = __iw_get_genie(dev, info, wrqu, extra);
3209 vos_ssr_unprotect(__func__);
3210
3211 return ret;
3212}
3213
3214static
3215int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3216 struct iw_request_info *info,
3217 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003218{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303219 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003220 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303221 hdd_ap_ctx_t *pHddApCtx;
3222 hdd_context_t *pHddCtx;
3223 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303224
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003226
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303227 pHostapdAdapter = (netdev_priv(dev));
3228 if (NULL == pHostapdAdapter)
3229 {
3230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3231 "%s: Adapter is NULL",__func__);
3232 return -EINVAL;
3233 }
3234 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3235 ret = wlan_hdd_validate_context(pHddCtx);
3236 if (0 != ret)
3237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303238 return ret;
3239 }
3240 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3241 if (NULL == pHddApCtx)
3242 {
3243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3244 "%s: AP context is NULL",__func__);
3245 return -EINVAL;
3246 }
3247
Arif Hussain6d2a3322013-11-17 19:50:10 -08003248 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003249 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3250
3251 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3252 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3253 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3254 WPSPBCProbeReqIEs.probeReqIELen);
3255 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3256 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3257 sizeof(v_MACADDR_t));
3258 if (copy_to_user(wrqu->data.pointer,
3259 (void *)&WPSPBCProbeReqIEs,
3260 sizeof(WPSPBCProbeReqIEs)))
3261 {
3262 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3263 return -EFAULT;
3264 }
3265 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003266 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003267 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 up(&pHddApCtx->semWpsPBCOverlapInd);
3269 EXIT();
3270 return 0;
3271}
3272
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303273static
3274int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3275 struct iw_request_info *info,
3276 union iwreq_data *wrqu, char *extra)
3277{
3278 int ret;
3279
3280 vos_ssr_protect(__func__);
3281 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3282 vos_ssr_unprotect(__func__);
3283
3284 return ret;
3285}
3286
Jeff Johnson295189b2012-06-20 16:38:30 -07003287/**---------------------------------------------------------------------------
3288
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303289 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 This function sets the auth type received from the wpa_supplicant.
3291
3292 \param - dev - Pointer to the net device.
3293 - info - Pointer to the iw_request_info.
3294 - wrqu - Pointer to the iwreq_data.
3295 - extra - Pointer to the data.
3296 \return - 0 for success, non zero for failure
3297
3298 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303299int __iw_set_auth_hostap(struct net_device *dev,
3300 struct iw_request_info *info,
3301 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003302{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303303 hdd_adapter_t *pAdapter;
3304 hdd_context_t *pHddCtx;
3305 hdd_wext_state_t *pWextState;
3306 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303307
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303309
3310 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3311 if (NULL == pAdapter)
3312 {
3313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3314 "%s: Adapter is NULL",__func__);
3315 return -EINVAL;
3316 }
3317
3318 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3319 ret = wlan_hdd_validate_context(pHddCtx);
3320 if (0 != ret)
3321 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303322 return ret;
3323 }
3324 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3325 if (NULL == pWextState)
3326 {
3327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3328 "%s: pWextState is NULL",__func__);
3329 return -EINVAL;
3330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 switch(wrqu->param.flags & IW_AUTH_INDEX)
3332 {
3333 case IW_AUTH_TKIP_COUNTERMEASURES:
3334 {
3335 if(wrqu->param.value) {
3336 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3337 "Counter Measure started %d", wrqu->param.value);
3338 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303339 }
3340 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3342 "Counter Measure stopped=%d", wrqu->param.value);
3343 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3344 }
3345
3346 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3347 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303350
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303352
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003353 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 wrqu->param.flags & IW_AUTH_INDEX);
3355 break;
3356 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303357
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 EXIT();
3359 return 0;
3360}
3361
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303362int iw_set_auth_hostap(struct net_device *dev,
3363 struct iw_request_info *info,
3364 union iwreq_data *wrqu,char *extra)
3365{
3366 int ret;
3367
3368 vos_ssr_protect(__func__);
3369 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3370 vos_ssr_unprotect(__func__);
3371
3372 return ret;
3373}
3374
3375static int __iw_set_ap_encodeext(struct net_device *dev,
3376 struct iw_request_info *info,
3377 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003378{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303379 hdd_adapter_t *pHostapdAdapter;
3380 v_CONTEXT_t pVosContext;
3381 hdd_context_t *pHddCtx;
3382 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003383 int retval = 0;
3384 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3386 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3387 int key_index;
3388 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303389 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003390// tCsrRoamRemoveKey RemoveKey;
3391 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303392
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303393 ENTER();
3394 pHostapdAdapter = (netdev_priv(dev));
3395 if (NULL == pHostapdAdapter)
3396 {
3397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3398 "%s: Adapter is NULL",__func__);
3399 return -EINVAL;
3400 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003401
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303402 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3403 retval = wlan_hdd_validate_context(pHddCtx);
3404 if (0 != retval)
3405 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303406 return retval;
3407 }
3408 pVosContext = pHddCtx->pvosContext;
3409 if (NULL == pVosContext)
3410 {
3411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3412 "%s: pVosContext is NULL",__func__);
3413 return -EINVAL;
3414 }
3415 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3416 if (NULL == pHddApCtx)
3417 {
3418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3419 "%s: AP Context is NULL",__func__);
3420 return -EINVAL;
3421 }
3422
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303424
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303426
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 /*Convert from 1-based to 0-based keying*/
3428 key_index--;
3429 }
3430 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303431#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 /*Set the encrytion type to NONE*/
3433#if 0
3434 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3435#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303436
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 RemoveKey.keyId = key_index;
3438 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3439 /*Key direction for group is RX only*/
3440 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3441 }
3442 else {
3443 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3444 }
3445 switch(ext->alg)
3446 {
3447 case IW_ENCODE_ALG_NONE:
3448 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3449 break;
3450 case IW_ENCODE_ALG_WEP:
3451 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3452 break;
3453 case IW_ENCODE_ALG_TKIP:
3454 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003455 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 case IW_ENCODE_ALG_CCMP:
3457 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3458 break;
3459 default:
3460 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3461 break;
3462 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003463 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 -07003464 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003466 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003468 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3469 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 {
3471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003472 __LINE__, vstatus );
3473 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003475#endif
3476 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003477
Jeff Johnson43971f52012-07-17 12:26:56 -07003478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003479
3480 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3481
3482 setKey.keyId = key_index;
3483 setKey.keyLength = ext->key_len;
3484
3485 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3486 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3487 }
3488
3489 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3490 /*Key direction for group is RX only*/
3491 setKey.keyDirection = eSIR_RX_ONLY;
3492 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3493 }
3494 else {
3495
3496 setKey.keyDirection = eSIR_TX_RX;
3497 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3498 }
3499 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3500 {
3501 setKey.keyDirection = eSIR_TX_DEFAULT;
3502 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3503 }
3504
3505 /*For supplicant pae role is zero*/
3506 setKey.paeRole = 0;
3507
3508 switch(ext->alg)
3509 {
3510 case IW_ENCODE_ALG_NONE:
3511 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3512 break;
3513
3514 case IW_ENCODE_ALG_WEP:
3515 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3516 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003517 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 break;
3519
3520 case IW_ENCODE_ALG_TKIP:
3521 {
3522 v_U8_t *pKey = &setKey.Key[0];
3523
3524 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3525
3526 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3527
3528 /*Supplicant sends the 32bytes key in this order
3529
3530 |--------------|----------|----------|
3531 | Tk1 |TX-MIC | RX Mic |
3532 |--------------|----------|----------|
3533 <---16bytes---><--8bytes--><--8bytes-->
3534
3535 */
3536 /*Sme expects the 32 bytes key to be in the below order
3537
3538 |--------------|----------|----------|
3539 | Tk1 |RX-MIC | TX Mic |
3540 |--------------|----------|----------|
3541 <---16bytes---><--8bytes--><--8bytes-->
3542 */
3543 /* Copy the Temporal Key 1 (TK1) */
3544 vos_mem_copy(pKey,ext->key,16);
3545
3546 /*Copy the rx mic first*/
3547 vos_mem_copy(&pKey[16],&ext->key[24],8);
3548
3549 /*Copy the tx mic */
3550 vos_mem_copy(&pKey[24],&ext->key[16],8);
3551
3552 }
3553 break;
3554
3555 case IW_ENCODE_ALG_CCMP:
3556 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3557 break;
3558
3559 default:
3560 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3561 break;
3562 }
3563
3564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303565 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 setKey.keyId);
3567 for(i=0; i< ext->key_len; i++)
3568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3569 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003570
3571 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3572 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 {
3574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003575 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3576 retval = -EINVAL;
3577 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303578
3579 EXIT();
3580 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003581}
Jeff Johnson43971f52012-07-17 12:26:56 -07003582
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303583static int iw_set_ap_encodeext(struct net_device *dev,
3584 struct iw_request_info *info,
3585 union iwreq_data *wrqu, char *extra)
3586{
3587 int ret;
3588
3589 vos_ssr_protect(__func__);
3590 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3591 vos_ssr_unprotect(__func__);
3592
3593 return ret;
3594}
Jeff Johnson43971f52012-07-17 12:26:56 -07003595
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303596static int __iw_set_ap_mlme(struct net_device *dev,
3597 struct iw_request_info *info,
3598 union iwreq_data *wrqu,
3599 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003600{
3601#if 0
3602 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3603 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3604
3605 ENTER();
3606
3607 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3608 switch (mlme->cmd) {
3609 case IW_MLME_DISASSOC:
3610 case IW_MLME_DEAUTH:
3611 hddLog(LOG1, "Station disassociate");
3612 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3613 {
3614 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3615
3616 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3617 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3618
3619 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3620
3621 //clear all the reason codes
3622 if (status != 0)
3623 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003624 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 }
3626
3627 netif_stop_queue(dev);
3628 netif_carrier_off(dev);
3629 }
3630 else
3631 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003632 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 -07003633 }
3634 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003635 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 return -EINVAL;
3637 }//end of switch
3638 EXIT();
3639#endif
3640 return 0;
3641// return status;
3642}
3643
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303644static int iw_set_ap_mlme(struct net_device *dev,
3645 struct iw_request_info *info,
3646 union iwreq_data *wrqu,
3647 char *extra)
3648{
3649 int ret;
3650
3651 vos_ssr_protect(__func__);
3652 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3653 vos_ssr_unprotect(__func__);
3654
3655 return ret;
3656}
3657
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303658static int __iw_get_ap_rts_threshold(struct net_device *dev,
3659 struct iw_request_info *info,
3660 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003661{
3662 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3663 v_U32_t status = 0;
3664
3665 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3666
3667 return status;
3668}
3669
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303670static int iw_get_ap_rts_threshold(struct net_device *dev,
3671 struct iw_request_info *info,
3672 union iwreq_data *wrqu, char *extra)
3673{
3674 int ret;
3675
3676 vos_ssr_protect(__func__);
3677 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3678 vos_ssr_unprotect(__func__);
3679
3680 return ret;
3681}
3682
3683static int __iw_get_ap_frag_threshold(struct net_device *dev,
3684 struct iw_request_info *info,
3685 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003686{
3687 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3688 v_U32_t status = 0;
3689
3690 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3691
3692 return status;
3693}
3694
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303695static int iw_get_ap_frag_threshold(struct net_device *dev,
3696 struct iw_request_info *info,
3697 union iwreq_data *wrqu, char *extra)
3698{
3699 int ret;
3700
3701 vos_ssr_protect(__func__);
3702 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3703 vos_ssr_unprotect(__func__);
3704
3705 return ret;
3706}
3707
3708static int __iw_get_ap_freq(struct net_device *dev,
3709 struct iw_request_info *info,
3710 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711{
Jeff Johnsone7245742012-09-05 17:12:55 -07003712 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303713 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 tHalHandle hHal;
3715 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303716 hdd_ap_ctx_t *pHddApCtx;
3717 hdd_context_t *pHddCtx;
3718 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003719
3720 ENTER();
3721
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303722 pHostapdAdapter = (netdev_priv(dev));
3723 if (NULL == pHostapdAdapter)
3724 {
3725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3726 "%s: Adapter is NULL",__func__);
3727 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303729 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3730 ret = wlan_hdd_validate_context(pHddCtx);
3731 if (0 != ret)
3732 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303733 return ret;
3734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303736 if (NULL == pHostapdState)
3737 {
3738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3739 "%s: pHostapdState is NULL",__func__);
3740 return -EINVAL;
3741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303743 if (NULL == hHal)
3744 {
3745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3746 "%s: Hal Context is NULL",__func__);
3747 return -EINVAL;
3748 }
3749 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3750 if (NULL == pHddApCtx)
3751 {
3752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3753 "%s: AP context is NULL",__func__);
3754 return -EINVAL;
3755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 if(pHostapdState->bssState == BSS_STOP )
3757 {
3758 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3759 != eHAL_STATUS_SUCCESS)
3760 {
c_hpothuffdb5272013-10-02 16:42:35 +05303761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3762 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 return -EIO;
3764 }
3765 else
3766 {
3767 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003768 if( TRUE == status)
3769 {
3770 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3771 * iwlist & iwconfig command shows frequency into proper
3772 * format (2.412 GHz instead of 246.2 MHz)*/
3773 fwrq->m = freq;
3774 fwrq->e = MHZ;
3775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 }
3777 }
3778 else
3779 {
3780 channel = pHddApCtx->operatingChannel;
3781 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003782 if( TRUE == status)
3783 {
3784 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3785 * iwlist & iwconfig command shows frequency into proper
3786 * format (2.412 GHz instead of 246.2 MHz)*/
3787 fwrq->m = freq;
3788 fwrq->e = MHZ;
3789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303791
3792 EXIT();
3793 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003794}
3795
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303796static int iw_get_ap_freq(struct net_device *dev,
3797 struct iw_request_info *info,
3798 struct iw_freq *fwrq, char *extra)
3799{
3800 int ret;
3801
3802 vos_ssr_protect(__func__);
3803 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3804 vos_ssr_unprotect(__func__);
3805
3806 return ret;
3807}
3808
3809static int __iw_get_mode(struct net_device *dev,
3810 struct iw_request_info *info,
3811 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303812{
3813 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303814 hdd_adapter_t *pAdapter;
3815 hdd_context_t *pHddCtx;
3816
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303817 ENTER();
3818
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303819 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3820 if (NULL == pAdapter)
3821 {
3822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3823 "%s: Adapter is NULL",__func__);
3824 return -EINVAL;
3825 }
3826 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3827 status = wlan_hdd_validate_context(pHddCtx);
3828 if (0 != status)
3829 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303830 return status;
3831 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303832
3833 wrqu->mode = IW_MODE_MASTER;
3834
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303835 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303836 return status;
3837}
3838
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303839static int iw_get_mode(struct net_device *dev,
3840 struct iw_request_info *info,
3841 union iwreq_data *wrqu, char *extra)
3842{
3843 int ret;
3844
3845 vos_ssr_protect(__func__);
3846 ret = __iw_get_mode(dev, info, wrqu, extra);
3847 vos_ssr_unprotect(__func__);
3848
3849 return ret;
3850}
3851
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303852static int __iw_softap_setwpsie(struct net_device *dev,
3853 struct iw_request_info *info,
3854 union iwreq_data *wrqu,
3855 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003856{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303857 hdd_adapter_t *pHostapdAdapter;
3858 hdd_context_t *pHddCtx;
3859 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 hdd_hostapd_state_t *pHostapdState;
3861 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003862 u_int8_t *wps_genie;
3863 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 u_int8_t *pos;
3865 tpSap_WPSIE pSap_WPSIe;
3866 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303867 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303868 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303869 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303870
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 ENTER();
3872
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303873 pHostapdAdapter = (netdev_priv(dev));
3874 if (NULL == pHostapdAdapter)
3875 {
3876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3877 "%s: Adapter is NULL",__func__);
3878 return -EINVAL;
3879 }
3880 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3881 ret = wlan_hdd_validate_context(pHddCtx);
3882 if (0 != ret)
3883 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303884 return ret;
3885 }
3886 pVosContext = pHddCtx->pvosContext;
3887 if (NULL == pVosContext)
3888 {
3889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3890 "%s: HDD context is not valid ",__func__);
3891 return -EINVAL;
3892 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303893 /* helper function to get iwreq_data with compat handling. */
3894 if (hdd_priv_get_data(&s_priv_data, wrqu))
3895 {
3896 return -EINVAL;
3897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898
Girish Gowli07c05ec2014-06-17 20:47:03 +05303899 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3900 {
3901 return -EINVAL;
3902 }
3903
3904 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3905 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003906
Girish Gowli86c471e2014-06-17 19:28:05 +05303907 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003908 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303909 hddLog(LOG1, "%s: failed to alloc memory "
3910 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003911 return -EFAULT;
3912 }
3913
Girish Gowli86c471e2014-06-17 19:28:05 +05303914 fwps_genie = wps_genie;
3915
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3917 if (NULL == pSap_WPSIe)
3918 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003919 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003920 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 return -ENOMEM;
3922 }
3923 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3924
Arif Hussain6d2a3322013-11-17 19:50:10 -08003925 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 -07003926 WPSIeType = wps_genie[0];
3927 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3928 {
3929 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3930 wps_genie = wps_genie + 1;
3931 switch ( wps_genie[0] )
3932 {
3933 case DOT11F_EID_WPA:
3934 if (wps_genie[1] < 2 + 4)
3935 {
3936 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003937 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 return -EINVAL;
3939 }
3940 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3941 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003942 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 pos = &wps_genie[6];
3944 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3945 {
3946 switch((u_int16_t)(*pos<<8) | *(pos+1))
3947 {
3948 case HDD_WPS_ELEM_VERSION:
3949 pos += 4;
3950 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003951 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3953 pos += 1;
3954 break;
3955
3956 case HDD_WPS_ELEM_WPS_STATE:
3957 pos +=4;
3958 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003959 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3961 pos += 1;
3962 break;
3963 case HDD_WPS_ELEM_APSETUPLOCK:
3964 pos += 4;
3965 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003966 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3968 pos += 1;
3969 break;
3970 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3971 pos += 4;
3972 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003973 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3975 pos += 1;
3976 break;
3977 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3978 pos += 4;
3979 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003980 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3982 pos += 2;
3983 break;
3984 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3985 pos += 4;
3986 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003987 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3989 pos += 2;
3990 break;
3991
3992 case HDD_WPS_ELEM_UUID_E:
3993 pos += 2;
3994 length = *pos<<8 | *(pos+1);
3995 pos += 2;
3996 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
3997 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
3998 pos += length;
3999 break;
4000 case HDD_WPS_ELEM_RF_BANDS:
4001 pos += 4;
4002 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004003 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
4005 pos += 1;
4006 break;
4007
4008 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004009 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004011 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 return -EINVAL;
4013 }
4014 }
4015 }
4016 else {
4017 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004018 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 }
4020 break;
4021
4022 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004023 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004025 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 return 0;
4027 }
4028 }
4029 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
4030 {
4031 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
4032 wps_genie = wps_genie + 1;
4033 switch ( wps_genie[0] )
4034 {
4035 case DOT11F_EID_WPA:
4036 if (wps_genie[1] < 2 + 4)
4037 {
4038 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004039 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 return -EINVAL;
4041 }
4042 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
4043 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004044 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 pos = &wps_genie[6];
4046 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
4047 {
4048 switch((u_int16_t)(*pos<<8) | *(pos+1))
4049 {
4050 case HDD_WPS_ELEM_VERSION:
4051 pos += 4;
4052 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004053 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
4055 pos += 1;
4056 break;
4057
4058 case HDD_WPS_ELEM_WPS_STATE:
4059 pos +=4;
4060 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004061 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
4063 pos += 1;
4064 break;
4065 case HDD_WPS_ELEM_APSETUPLOCK:
4066 pos += 4;
4067 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004068 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
4070 pos += 1;
4071 break;
4072 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4073 pos += 4;
4074 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004075 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
4077 pos += 1;
4078 break;
4079 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4080 pos += 4;
4081 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004082 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
4084 pos += 2;
4085 break;
4086 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4087 pos += 4;
4088 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004089 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
4091 pos += 2;
4092 break;
4093 case HDD_WPS_ELEM_RSP_TYPE:
4094 pos += 4;
4095 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004096 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
4098 pos += 1;
4099 break;
4100 case HDD_WPS_ELEM_UUID_E:
4101 pos += 2;
4102 length = *pos<<8 | *(pos+1);
4103 pos += 2;
4104 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
4105 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
4106 pos += length;
4107 break;
4108
4109 case HDD_WPS_ELEM_MANUFACTURER:
4110 pos += 2;
4111 length = *pos<<8 | *(pos+1);
4112 pos += 2;
4113 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
4114 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
4115 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
4116 pos += length;
4117 break;
4118
4119 case HDD_WPS_ELEM_MODEL_NAME:
4120 pos += 2;
4121 length = *pos<<8 | *(pos+1);
4122 pos += 2;
4123 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
4124 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
4125 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
4126 pos += length;
4127 break;
4128 case HDD_WPS_ELEM_MODEL_NUM:
4129 pos += 2;
4130 length = *pos<<8 | *(pos+1);
4131 pos += 2;
4132 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
4133 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
4134 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
4135 pos += length;
4136 break;
4137 case HDD_WPS_ELEM_SERIAL_NUM:
4138 pos += 2;
4139 length = *pos<<8 | *(pos+1);
4140 pos += 2;
4141 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
4142 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
4143 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
4144 pos += length;
4145 break;
4146 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
4147 pos += 4;
4148 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004149 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 pos += 2;
4151
4152 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004153 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 pos += 4;
4155 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004156 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 pos += 2;
4158 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
4159 break;
4160 case HDD_WPS_ELEM_DEVICE_NAME:
4161 pos += 2;
4162 length = *pos<<8 | *(pos+1);
4163 pos += 2;
4164 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4165 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4166 pos += length;
4167 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4168 break;
4169 case HDD_WPS_ELEM_CONFIG_METHODS:
4170 pos += 4;
4171 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004172 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 pos += 2;
4174 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4175 break;
4176
4177 case HDD_WPS_ELEM_RF_BANDS:
4178 pos += 4;
4179 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004180 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 pos += 1;
4182 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4183 break;
4184 } // switch
4185 }
4186 }
4187 else
4188 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004189 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 }
4191
4192 } // switch
4193 }
4194 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
4195 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4196 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4197 {
4198 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4199 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4200 WLANSAP_Update_WpsIe ( pVosContext );
4201 }
4202
4203 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004204 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 EXIT();
4206 return halStatus;
4207}
4208
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304209static int iw_softap_setwpsie(struct net_device *dev,
4210 struct iw_request_info *info,
4211 union iwreq_data *wrqu,
4212 char *extra)
4213{
4214 int ret;
4215
4216 vos_ssr_protect(__func__);
4217 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4218 vos_ssr_unprotect(__func__);
4219
4220 return ret;
4221}
4222
4223static int __iw_softap_stopbss(struct net_device *dev,
4224 struct iw_request_info *info,
4225 union iwreq_data *wrqu,
4226 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004227{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304228 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304230 hdd_context_t *pHddCtx = NULL;
4231
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304233 pHostapdAdapter = (netdev_priv(dev));
4234 if (NULL == pHostapdAdapter)
4235 {
4236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4237 "%s: Adapter is NULL",__func__);
4238 return -EINVAL;
4239 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304240 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4241 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304242 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304243 return status;
4244 }
4245
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304246 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 {
4248 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4249 {
4250 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4251
4252 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304253
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304255 {
4256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004257 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 VOS_ASSERT(0);
4259 }
4260 }
4261 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304262 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 }
4264 EXIT();
4265 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4266}
4267
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304268static int iw_softap_stopbss(struct net_device *dev,
4269 struct iw_request_info *info,
4270 union iwreq_data *wrqu,
4271 char *extra)
4272{
4273 int ret;
4274
4275 vos_ssr_protect(__func__);
4276 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4277 vos_ssr_unprotect(__func__);
4278
4279 return ret;
4280}
4281
4282static int __iw_softap_version(struct net_device *dev,
4283 struct iw_request_info *info,
4284 union iwreq_data *wrqu,
4285 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004286{
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304288 hdd_context_t *pHddCtx;
4289 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304290
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304292 pHostapdAdapter = (netdev_priv(dev));
4293 if (NULL == pHostapdAdapter)
4294 {
4295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4296 "%s: Adapter is NULL",__func__);
4297 return -EINVAL;
4298 }
4299 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4300 ret = wlan_hdd_validate_context(pHddCtx);
4301 if (0 != ret)
4302 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304303 return ret;
4304 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004305 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 return 0;
4308}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004309
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304310static int iw_softap_version(struct net_device *dev,
4311 struct iw_request_info *info,
4312 union iwreq_data *wrqu,
4313 char *extra)
4314{
4315 int ret;
4316
4317 vos_ssr_protect(__func__);
4318 ret = __iw_softap_version(dev, info, wrqu, extra);
4319 vos_ssr_unprotect(__func__);
4320
4321 return ret;
4322}
4323
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004324VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004325{
4326 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004327 int len = 0;
4328 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304329 v_CONTEXT_t pVosContext;
4330 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304331 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304332
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304333 ENTER();
4334
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304335 if (NULL == pAdapter)
4336 {
4337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4338 "%s: Adapter is NULL",__func__);
4339 return -EINVAL;
4340 }
4341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4342 if (0 != wlan_hdd_validate_context(pHddCtx))
4343 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304344 return VOS_STATUS_E_FAULT;
4345 }
4346 pVosContext = pHddCtx->pvosContext;
4347 if (NULL == pVosContext)
4348 {
4349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4350 "%s: VOS context is not valid",__func__);
4351 return VOS_STATUS_E_FAULT;
4352 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304353 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304354 if(pSapCtx == NULL)
4355 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304356 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4357 FL("psapCtx is NULL"));
4358 return VOS_STATUS_E_FAULT;
4359 }
4360
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004361 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004362 pBuf += len;
4363 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004364
4365 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4366 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304367 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004368 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004369 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304370 pSapCtx->aStaInfo[i].ucSTAId,
4371 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4372 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4373 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4374 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4375 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4376 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004377 pBuf += len;
4378 buf_len -= len;
4379 }
4380 if(WE_GET_STA_INFO_SIZE > buf_len)
4381 {
4382 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004383 }
4384 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304385 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004386 return VOS_STATUS_SUCCESS;
4387}
4388
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304389static int __iw_softap_get_sta_info(struct net_device *dev,
4390 struct iw_request_info *info,
4391 union iwreq_data *wrqu,
4392 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004393{
4394 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4395 VOS_STATUS status;
4396 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004397 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004398 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004399 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004400 return -EINVAL;
4401 }
4402 wrqu->data.length = strlen(extra);
4403 EXIT();
4404 return 0;
4405}
4406
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304407static int iw_softap_get_sta_info(struct net_device *dev,
4408 struct iw_request_info *info,
4409 union iwreq_data *wrqu,
4410 char *extra)
4411{
4412 int ret;
4413
4414 vos_ssr_protect(__func__);
4415 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4416 vos_ssr_unprotect(__func__);
4417
4418 return ret;
4419}
4420
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304421static int __iw_set_ap_genie(struct net_device *dev,
4422 struct iw_request_info *info,
4423 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004424{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304425
4426 hdd_adapter_t *pHostapdAdapter;
4427 hdd_context_t *pHddCtx;
4428 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004430 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304431 int ret = 0;
4432
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304434 pHostapdAdapter = (netdev_priv(dev));
4435 if (NULL == pHostapdAdapter)
4436 {
4437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4438 "%s: Adapter is NULL",__func__);
4439 return -EINVAL;
4440 }
4441 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4442 ret = wlan_hdd_validate_context(pHddCtx);
4443 if (0 != ret)
4444 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304445 return ret;
4446 }
4447 pVosContext = pHddCtx->pvosContext;
4448 if (NULL == pVosContext)
4449 {
4450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4451 "%s: VOS Context is NULL",__func__);
4452 return -EINVAL;
4453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 if(!wrqu->data.length)
4455 {
4456 EXIT();
4457 return 0;
4458 }
Arif Hussained667642013-10-27 23:01:14 -07004459
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304460 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304462 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 case DOT11F_EID_RSN:
4464 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4465 {
4466 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4467 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004470 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304472
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004474 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 halStatus = 0;
4476 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304477
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304479 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004480}
4481
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304482static int iw_set_ap_genie(struct net_device *dev,
4483 struct iw_request_info *info,
4484 union iwreq_data *wrqu, char *extra)
4485{
4486 int ret;
4487
4488 vos_ssr_protect(__func__);
4489 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4490 vos_ssr_unprotect(__func__);
4491
4492 return ret;
4493}
4494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4496{
4497 eHalStatus hstatus;
4498 long lrc;
4499 struct statsContext context;
4500
4501 if (NULL == pAdapter)
4502 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304503 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 return VOS_STATUS_E_FAULT;
4505 }
4506
4507 init_completion(&context.completion);
4508 context.pAdapter = pAdapter;
4509 context.magic = STATS_CONTEXT_MAGIC;
4510 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4511 eCSR_HDD,
4512 SME_GLOBAL_CLASSA_STATS,
4513 hdd_GetClassA_statisticsCB,
4514 0, // not periodic
4515 FALSE, //non-cached results
4516 staid,
4517 &context);
4518 if (eHAL_STATUS_SUCCESS != hstatus)
4519 {
4520 hddLog(VOS_TRACE_LEVEL_ERROR,
4521 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004522 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 }
4524 else
4525 {
4526 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4527 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 if (lrc <= 0)
4529 {
4530 hddLog(VOS_TRACE_LEVEL_ERROR,
4531 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004532 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 }
4534 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004535
4536 /* either we never sent a request, we sent a request and received a
4537 response or we sent a request and timed out. if we never sent a
4538 request or if we sent a request and got a response, we want to
4539 clear the magic out of paranoia. if we timed out there is a
4540 race condition such that the callback function could be
4541 executing at the same time we are. of primary concern is if the
4542 callback function had already verified the "magic" but had not
4543 yet set the completion variable when a timeout occurred. we
4544 serialize these activities by invalidating the magic while
4545 holding a shared spinlock which will cause us to block if the
4546 callback is currently executing */
4547 spin_lock(&hdd_context_lock);
4548 context.magic = 0;
4549 spin_unlock(&hdd_context_lock);
4550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 return VOS_STATUS_SUCCESS;
4552}
4553
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304554int __iw_get_softap_linkspeed(struct net_device *dev,
4555 struct iw_request_info *info,
4556 union iwreq_data *wrqu,
4557 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004558
4559{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304560 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304561 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004563 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304564 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304566 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004568 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304569 int rc, valid;
4570
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304571 ENTER();
4572
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304573 pHostapdAdapter = (netdev_priv(dev));
4574 if (NULL == pHostapdAdapter)
4575 {
4576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4577 "%s: Adapter is NULL",__func__);
4578 return -EINVAL;
4579 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304580 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304581 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304582 if (0 != valid)
4583 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304584 return valid;
4585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004586
Arif Hussain6d2a3322013-11-17 19:50:10 -08004587 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004588
4589 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004590 {
Arif Hussaina9571842014-01-15 16:43:41 -08004591 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4592 if (NULL == pmacAddress) {
4593 hddLog(LOG1, "unable to allocate memory");
4594 return -ENOMEM;
4595 }
4596 if (copy_from_user((void *)pmacAddress,
4597 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4598 {
4599 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4600 kfree(pmacAddress);
4601 return -EFAULT;
4602 }
4603 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4604
4605 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004606 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004607
4608 if (!VOS_IS_STATUS_SUCCESS(status ))
4609 {
4610 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4611 }
Arif Hussained667642013-10-27 23:01:14 -07004612 }
Kiet Lam61589852013-09-19 17:10:58 +05304613 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304614 * link speed for first connected client will be returned.
4615 */
Arif Hussaina9571842014-01-15 16:43:41 -08004616 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304617 {
4618 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4619 }
4620 else
4621 {
4622 status = hdd_softap_GetStaId(pHostapdAdapter,
4623 (v_MACADDR_t *)macAddress, (void *)(&staId));
4624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004625
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304626 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304628 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 link_speed = 0;
4630 }
4631 else
4632 {
4633 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304634
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 if (!VOS_IS_STATUS_SUCCESS(status ))
4636 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 return -EINVAL;
4639 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304640
4641 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4642 staId, &link_speed);
4643
4644 link_speed = link_speed / 10;
4645
4646 if (0 == link_speed)
4647 {
4648 /* The linkspeed returned by HAL is in units of 500kbps.
4649 * converting it to mbps.
4650 * This is required to support legacy firmware which does
4651 * not return link capacity.
4652 */
4653 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 }
4656
4657 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004658 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304659
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 if ((rc < 0) || (rc >= len))
4661 {
4662 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304663 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 return -EIO;
4665 }
4666
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304667 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 return 0;
4669}
4670
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304671int iw_get_softap_linkspeed(struct net_device *dev,
4672 struct iw_request_info *info,
4673 union iwreq_data *wrqu,
4674 char *extra)
4675{
4676 int ret;
4677
4678 vos_ssr_protect(__func__);
4679 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4680 vos_ssr_unprotect(__func__);
4681
4682 return ret;
4683}
4684
4685
Jeff Johnson295189b2012-06-20 16:38:30 -07004686static const iw_handler hostapd_handler[] =
4687{
4688 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4689 (iw_handler) NULL, /* SIOCGIWNAME */
4690 (iw_handler) NULL, /* SIOCSIWNWID */
4691 (iw_handler) NULL, /* SIOCGIWNWID */
4692 (iw_handler) NULL, /* SIOCSIWFREQ */
4693 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4694 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304695 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 (iw_handler) NULL, /* SIOCSIWSENS */
4697 (iw_handler) NULL, /* SIOCGIWSENS */
4698 (iw_handler) NULL, /* SIOCSIWRANGE */
4699 (iw_handler) NULL, /* SIOCGIWRANGE */
4700 (iw_handler) NULL, /* SIOCSIWPRIV */
4701 (iw_handler) NULL, /* SIOCGIWPRIV */
4702 (iw_handler) NULL, /* SIOCSIWSTATS */
4703 (iw_handler) NULL, /* SIOCGIWSTATS */
4704 (iw_handler) NULL, /* SIOCSIWSPY */
4705 (iw_handler) NULL, /* SIOCGIWSPY */
4706 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4707 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4708 (iw_handler) NULL, /* SIOCSIWAP */
4709 (iw_handler) NULL, /* SIOCGIWAP */
4710 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4711 (iw_handler) NULL, /* SIOCGIWAPLIST */
4712 (iw_handler) NULL, /* SIOCSIWSCAN */
4713 (iw_handler) NULL, /* SIOCGIWSCAN */
4714 (iw_handler) NULL, /* SIOCSIWESSID */
4715 (iw_handler) NULL, /* SIOCGIWESSID */
4716 (iw_handler) NULL, /* SIOCSIWNICKN */
4717 (iw_handler) NULL, /* SIOCGIWNICKN */
4718 (iw_handler) NULL, /* -- hole -- */
4719 (iw_handler) NULL, /* -- hole -- */
4720 (iw_handler) NULL, /* SIOCSIWRATE */
4721 (iw_handler) NULL, /* SIOCGIWRATE */
4722 (iw_handler) NULL, /* SIOCSIWRTS */
4723 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4724 (iw_handler) NULL, /* SIOCSIWFRAG */
4725 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4726 (iw_handler) NULL, /* SIOCSIWTXPOW */
4727 (iw_handler) NULL, /* SIOCGIWTXPOW */
4728 (iw_handler) NULL, /* SIOCSIWRETRY */
4729 (iw_handler) NULL, /* SIOCGIWRETRY */
4730 (iw_handler) NULL, /* SIOCSIWENCODE */
4731 (iw_handler) NULL, /* SIOCGIWENCODE */
4732 (iw_handler) NULL, /* SIOCSIWPOWER */
4733 (iw_handler) NULL, /* SIOCGIWPOWER */
4734 (iw_handler) NULL, /* -- hole -- */
4735 (iw_handler) NULL, /* -- hole -- */
4736 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4737 (iw_handler) NULL, /* SIOCGIWGENIE */
4738 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4739 (iw_handler) NULL, /* SIOCGIWAUTH */
4740 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4741 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4742 (iw_handler) NULL, /* SIOCSIWPMKSA */
4743};
4744
Jeff Johnson224f3702014-03-26 11:09:47 -07004745/*
4746 * Note that the following ioctls were defined with semantics which
4747 * cannot be handled by the "iwpriv" userspace application and hence
4748 * they are not included in the hostapd_private_args array
4749 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4750 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004751
4752static const struct iw_priv_args hostapd_private_args[] = {
4753 { QCSAP_IOCTL_SETPARAM,
4754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4755 { QCSAP_IOCTL_SETPARAM,
4756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
4757 { QCSAP_PARAM_MAX_ASSOC,
4758 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4759 { QCSAP_PARAM_HIDE_SSID,
4760 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004761 { QCSAP_PARAM_SET_MC_RATE,
4762 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 { QCSAP_IOCTL_GETPARAM,
4764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4766 { QCSAP_IOCTL_GETPARAM, 0,
4767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4768 { QCSAP_PARAM_MAX_ASSOC, 0,
4769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004770 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4772 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304774 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 { QCSAP_PARAM_CLR_ACL, 0,
4777 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4778 { QCSAP_PARAM_ACL_MODE,
4779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 { QCSAP_IOCTL_GET_STAWPAIE,
4781 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4782 { QCSAP_IOCTL_SETWPAIE,
4783 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4784 { QCSAP_IOCTL_STOPBSS,
4785 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4786 { QCSAP_IOCTL_VERSION, 0,
4787 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004788 { QCSAP_IOCTL_GET_STA_INFO, 0,
4789 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004791 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004793 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004794 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304796 { QCSAP_IOCTL_AP_STATS, 0,
4797 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304798 { QCSAP_IOCTL_GET_STATS, 0,
4799 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4800 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4802 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304803 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004804
4805 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4806 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4807 /* handlers for sub-ioctl */
4808 { WE_SET_WLAN_DBG,
4809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4810 0,
4811 "setwlandbg" },
4812
4813 /* handlers for main ioctl */
4814 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4815 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4816 0,
4817 "" },
4818
4819 /* handlers for sub-ioctl */
4820 { WE_LOG_DUMP_CMD,
4821 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4822 0,
4823 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 { WE_P2P_NOA_CMD,
4825 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4826 0,
4827 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004828 /* handlers for sub ioctl */
4829 {
4830 WE_MCC_CONFIG_CREDENTIAL,
4831 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4832 0,
4833 "setMccCrdnl" },
4834
4835 /* handlers for sub ioctl */
4836 {
4837 WE_MCC_CONFIG_PARAMS,
4838 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4839 0,
4840 "setMccConfig" },
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 /* handlers for main ioctl */
4843 { QCSAP_IOCTL_MODIFY_ACL,
4844 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4845 0,
4846 "modify_acl" },
4847
4848 /* handlers for main ioctl */
4849 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4850 0,
4851 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4852 "getChannelList" },
4853
Jeff Johnsone7245742012-09-05 17:12:55 -07004854 /* handlers for main ioctl */
4855 { QCSAP_IOCTL_SET_TX_POWER,
4856 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4857 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304858 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004859
4860 /* handlers for main ioctl */
4861 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4862 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4863 0,
4864 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304865
4866 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4867 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4868 0,
4869 "dataSnapshot" },
4870
4871 /* handlers for main ioctl */
4872 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4873 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4874 0,
4875 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004876};
Jeff Johnsone7245742012-09-05 17:12:55 -07004877
Jeff Johnson295189b2012-06-20 16:38:30 -07004878static const iw_handler hostapd_private[] = {
4879 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4880 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4882 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4883 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4884 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4885 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4886 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4887 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4888 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4889 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304890 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4892 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4893 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4894 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004895 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004896 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4897 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004898 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304899 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304900 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304901 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4902 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004903};
4904const struct iw_handler_def hostapd_handler_def = {
4905 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4906 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4907 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4908 .standard = (iw_handler *)hostapd_handler,
4909 .private = (iw_handler *)hostapd_private,
4910 .private_args = hostapd_private_args,
4911 .get_wireless_stats = NULL,
4912};
4913#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4914struct net_device_ops net_ops_struct = {
4915 .ndo_open = hdd_hostapd_open,
4916 .ndo_stop = hdd_hostapd_stop,
4917 .ndo_uninit = hdd_hostapd_uninit,
4918 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4919 .ndo_tx_timeout = hdd_softap_tx_timeout,
4920 .ndo_get_stats = hdd_softap_stats,
4921 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4922 .ndo_do_ioctl = hdd_hostapd_ioctl,
4923 .ndo_change_mtu = hdd_hostapd_change_mtu,
4924 .ndo_select_queue = hdd_hostapd_select_queue,
4925 };
4926#endif
4927
4928int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4929{
4930 return VOS_STATUS_SUCCESS;
4931}
4932
4933void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4934{
4935#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4936 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4937#else
4938 pWlanHostapdDev->open = hdd_hostapd_open;
4939 pWlanHostapdDev->stop = hdd_hostapd_stop;
4940 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4941 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4942 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4943 pWlanHostapdDev->get_stats = hdd_softap_stats;
4944 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4945 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4946#endif
4947}
4948
4949VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304950{
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 hdd_hostapd_state_t * phostapdBuf;
4952 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004953 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004955#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004956 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4957 v_U16_t unsafeChannelCount;
4958#endif /* FEATURE_WLAN_CH_AVOID */
4959
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304960 if (pHddCtx->isLogpInProgress) {
4961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4962 "%s:LOGP in Progress. Ignore!!!",__func__);
4963 status = VOS_STATUS_E_FAILURE;
4964 }
4965
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304967 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304969
Nirav Shah7e3c8132015-06-22 23:51:42 +05304970 spin_lock_init(&pAdapter->sta_hash_lock);
4971 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4972
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004973 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4974
Leo Chang0b0e45a2013-12-15 15:18:55 -08004975#ifdef FEATURE_WLAN_CH_AVOID
4976 /* Get unsafe cahnnel list from cached location */
4977 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4978 sizeof(unsafeChannelList),
4979 &unsafeChannelCount);
4980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4981 "%s : Unsafe Channel count %d",
4982 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304983 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004984 unsafeChannelList,
4985 unsafeChannelCount);
4986#endif /* FEATURE_WLAN_CH_AVOID */
4987
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 // Zero the memory. This zeros the profile structure.
4989 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
4990
4991 // Set up the pointer to the Wireless Extensions state structure
4992 // NOP
4993 status = hdd_set_hostapd(pAdapter);
4994 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 return status;
4997 }
4998
4999 status = vos_event_init(&phostapdBuf->vosEvent);
5000 if (!VOS_IS_STATUS_SUCCESS(status))
5001 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 return status;
5004 }
5005
5006 init_completion(&pAdapter->session_close_comp_var);
5007 init_completion(&pAdapter->session_open_comp_var);
5008
5009 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5010
5011 // Register as a wireless device
5012 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5013
5014 //Initialize the data path module
5015 status = hdd_softap_init_tx_rx(pAdapter);
5016 if ( !VOS_IS_STATUS_SUCCESS( status ))
5017 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005018 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305020
5021 status = hdd_wmm_adapter_init( pAdapter );
5022 if (!VOS_IS_STATUS_SUCCESS(status))
5023 {
5024 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005025 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305026 status, status );
5027 goto error_wmm_init;
5028 }
5029
5030 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5031
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305032 return status;
5033
5034error_wmm_init:
5035 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 EXIT();
5037 return status;
5038}
5039
5040hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5041{
5042 struct net_device *pWlanHostapdDev = NULL;
5043 hdd_adapter_t *pHostapdAdapter = NULL;
5044 v_CONTEXT_t pVosContext= NULL;
5045
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305046 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5047#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5048 NET_NAME_UNKNOWN,
5049#endif
5050 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 if (pWlanHostapdDev != NULL)
5052 {
5053 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5054
5055 //Init the net_device structure
5056 ether_setup(pWlanHostapdDev);
5057
5058 //Initialize the adapter context to zeros.
5059 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5060 pHostapdAdapter->dev = pWlanHostapdDev;
5061 pHostapdAdapter->pHddCtx = pHddCtx;
5062 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5063
5064 //Get the Global VOSS context.
5065 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5066 //Save the adapter context in global context for future.
5067 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5068
5069 //Init the net_device structure
5070 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5071
5072 hdd_set_ap_ops( pHostapdAdapter->dev );
5073
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5075 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5076
5077 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5078 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5079
5080 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5082 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5083 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
5084 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
5086 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05305087 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07005088#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5089 init_completion(&pHostapdAdapter->offchannel_tx_event);
5090#endif
5091
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5093 }
5094 return pHostapdAdapter;
5095}
5096
5097VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5098{
5099 struct net_device *dev = pAdapter->dev;
5100 VOS_STATUS status = VOS_STATUS_SUCCESS;
5101
5102 ENTER();
5103
5104 if( rtnl_lock_held )
5105 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005106 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 if( dev_alloc_name(dev, dev->name) < 0 )
5108 {
5109 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5110 return VOS_STATUS_E_FAILURE;
5111 }
5112 }
5113 if (register_netdevice(dev))
5114 {
5115 hddLog(VOS_TRACE_LEVEL_FATAL,
5116 "%s:Failed:register_netdevice", __func__);
5117 return VOS_STATUS_E_FAILURE;
5118 }
5119 }
5120 else
5121 {
5122 if (register_netdev(dev))
5123 {
5124 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5125 return VOS_STATUS_E_FAILURE;
5126 }
5127 }
5128 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5129
5130 EXIT();
5131 return status;
5132}
5133
c_hpothu002231a2015-02-05 14:58:51 +05305134VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005135{
5136 ENTER();
5137
5138 hdd_softap_deinit_tx_rx(pAdapter);
5139
5140 /* if we are being called during driver unload, then the dev has already
5141 been invalidated. if we are being called at other times, then we can
5142 detatch the wireless device handlers */
5143 if (pAdapter->dev)
5144 {
c_hpothu002231a2015-02-05 14:58:51 +05305145 if (TRUE == rtnl_held)
5146 {
5147 pAdapter->dev->wireless_handlers = NULL;
5148 }
5149 else
5150 {
5151 rtnl_lock();
5152 pAdapter->dev->wireless_handlers = NULL;
5153 rtnl_unlock();
5154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 }
5156 EXIT();
5157 return 0;
5158}