blob: ff0418d30975065142b2f9651b4df9b83edd6c5f [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 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05301959 case QCSAP_PARAM_GET_FRAME_LOGS:
1960 {
1961 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
1962 != VOS_STATUS_SUCCESS)
1963 {
1964 ret = -EINVAL;
1965 }
1966 break;
1967 }
Leo Chang614d2072013-08-22 14:59:44 -07001968
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 default:
1970 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1971 sub_cmd, set_value);
1972 ret = -EINVAL;
1973 break;
1974 }
1975
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301976 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 return ret;
1978}
1979
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301980int
1981static iw_softap_setparam(struct net_device *dev,
1982 struct iw_request_info *info,
1983 union iwreq_data *wrqu, char *extra)
1984{
1985 int ret;
1986
1987 vos_ssr_protect(__func__);
1988 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1989 vos_ssr_unprotect(__func__);
1990
1991 return ret;
1992}
Jeff Johnson295189b2012-06-20 16:38:30 -07001993
1994int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301995static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001996 struct iw_request_info *info,
1997 union iwreq_data *wrqu, char *extra)
1998{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301999 hdd_adapter_t *pHostapdAdapter;
2000 tHalHandle hHal;
2001 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 int *value = (int *)extra;
2003 int sub_cmd = value[0];
2004 eHalStatus status;
2005 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302006 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002007
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302008 ENTER();
2009
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302010 pHostapdAdapter = (netdev_priv(dev));
2011 if (NULL == pHostapdAdapter)
2012 {
2013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2014 "%s: Adapter is NULL",__func__);
2015 return -EINVAL;
2016 }
2017 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2018 ret = wlan_hdd_validate_context(pHddCtx);
2019 if (0 != ret)
2020 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302021 return ret;
2022 }
2023 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2024 if (NULL == hHal)
2025 {
2026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2027 "%s: Hal Context is NULL",__func__);
2028 return -EINVAL;
2029 }
2030 pVosContext = pHddCtx->pvosContext;
2031 if (NULL == pVosContext)
2032 {
2033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2034 "%s: pVosContext Context is NULL",__func__);
2035 return -EINVAL;
2036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 switch (sub_cmd)
2038 {
2039 case QCSAP_PARAM_MAX_ASSOC:
2040 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2041 if (eHAL_STATUS_SUCCESS != status)
2042 {
c_hpothuffdb5272013-10-02 16:42:35 +05302043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2044 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 ret = -EIO;
2046 }
Girish Gowli385be612014-09-18 11:17:20 +05302047
2048#ifdef WLAN_SOFTAP_VSTA_FEATURE
2049 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2050 {
2051 if (*value > VSTA_NUM_ASSOC_STA)
2052 {
2053 *value = VSTA_NUM_ASSOC_STA;
2054 }
2055 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2056 (*value > (VSTA_NUM_ASSOC_STA -
2057 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2058 {
2059 *value = (VSTA_NUM_ASSOC_STA -
2060 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2061 }
2062 }
2063 else
2064#endif
2065 {
2066 if (*value > NUM_ASSOC_STA)
2067 {
2068 *value = NUM_ASSOC_STA;
2069 }
2070 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2071 (*value > (NUM_ASSOC_STA -
2072 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2073 {
2074 *value = (NUM_ASSOC_STA -
2075 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2076 }
2077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302079
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002081 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 {
c_hpothuffdb5272013-10-02 16:42:35 +05302083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2084 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302085 ret = -EIO;
2086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 *value = 0;
2088 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302089
Jeff Johnson43971f52012-07-17 12:26:56 -07002090 case QCSAP_PARAM_GET_WLAN_DBG:
2091 {
2092 vos_trace_display();
2093 *value = 0;
2094 break;
2095 }
2096
2097 case QCSAP_PARAM_AUTO_CHANNEL:
2098 {
2099 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2100 break;
2101 }
2102
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 default:
2104 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2105 ret = -EINVAL;
2106 break;
2107
2108 }
2109
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302110 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 return ret;
2112}
2113
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302114int
2115static iw_softap_getparam(struct net_device *dev,
2116 struct iw_request_info *info,
2117 union iwreq_data *wrqu, char *extra)
2118{
2119 int ret;
2120
2121 vos_ssr_protect(__func__);
2122 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2123 vos_ssr_unprotect(__func__);
2124
2125 return ret;
2126}
Jeff Johnson295189b2012-06-20 16:38:30 -07002127/* Usage:
2128 BLACK_LIST = 0
2129 WHITE_LIST = 1
2130 ADD MAC = 0
2131 REMOVE MAC = 1
2132
2133 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2134 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2135 while using this ioctl
2136
2137 Syntax:
2138 iwpriv softap.0 modify_acl
2139 <6 octet mac addr> <list type> <cmd type>
2140
2141 Examples:
2142 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2143 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2144 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2145 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2146*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302147int __iw_softap_modify_acl(struct net_device *dev,
2148 struct iw_request_info *info,
2149 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002150{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302151 hdd_adapter_t *pHostapdAdapter;
2152 v_CONTEXT_t pVosContext;
2153 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 v_BYTE_t *value = (v_BYTE_t*)extra;
2155 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2156 int listType, cmd, i;
2157 int ret = 0; /* success */
2158
2159 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302160 pHostapdAdapter = (netdev_priv(dev));
2161 if (NULL == pHostapdAdapter)
2162 {
2163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2164 "%s: Adapter is NULL",__func__);
2165 return -EINVAL;
2166 }
2167 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2168 ret = wlan_hdd_validate_context(pHddCtx);
2169 if (0 != ret)
2170 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302171 return ret;
2172 }
2173 pVosContext = pHddCtx->pvosContext;
2174 if (NULL == pVosContext)
2175 {
2176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2177 "%s: Vos Context is NULL",__func__);
2178 return -EINVAL;
2179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2181 {
2182 pPeerStaMac[i] = *(value+i);
2183 }
2184 listType = (int)(*(value+i));
2185 i++;
2186 cmd = (int)(*(value+i));
2187
Arif Hussain24bafea2013-11-15 15:10:03 -08002188 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2189 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002190
2191 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2192 != VOS_STATUS_SUCCESS)
2193 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002194 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 ret = -EIO;
2196 }
2197 EXIT();
2198 return ret;
2199}
2200
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302201int iw_softap_modify_acl(struct net_device *dev,
2202 struct iw_request_info *info,
2203 union iwreq_data *wrqu, char *extra)
2204{
2205 int ret;
2206
2207 vos_ssr_protect(__func__);
2208 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2209 vos_ssr_unprotect(__func__);
2210
2211 return ret;
2212}
2213
Jeff Johnson295189b2012-06-20 16:38:30 -07002214int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302215static __iw_softap_getchannel(struct net_device *dev,
2216 struct iw_request_info *info,
2217 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002218{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302219 hdd_adapter_t *pHostapdAdapter;
2220 hdd_context_t *pHddCtx;
2221 int ret = 0;
2222 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302223
2224 ENTER();
2225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302226 pHostapdAdapter = (netdev_priv(dev));
2227 if (NULL == pHostapdAdapter)
2228 {
2229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2230 "%s: Adapter is NULL",__func__);
2231 return -EINVAL;
2232 }
2233 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2234 ret = wlan_hdd_validate_context(pHddCtx);
2235 if (0 != ret)
2236 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302237 return ret;
2238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302240 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002241
Jeff Johnson43971f52012-07-17 12:26:56 -07002242 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302243
2244 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 return 0;
2246}
2247
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302248
Jeff Johnsone7245742012-09-05 17:12:55 -07002249int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302250static iw_softap_getchannel(struct net_device *dev,
2251 struct iw_request_info *info,
2252 union iwreq_data *wrqu, char *extra)
2253{
2254 int ret;
2255
2256 vos_ssr_protect(__func__);
2257 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2258 vos_ssr_unprotect(__func__);
2259
2260 return ret;
2261}
2262
2263int
2264static __iw_softap_set_max_tx_power(struct net_device *dev,
2265 struct iw_request_info *info,
2266 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002267{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302268 hdd_adapter_t *pHostapdAdapter;
2269 tHalHandle hHal;
2270 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002271 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302272 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002273 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2274 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2275
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302276 ENTER();
2277
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302278 pHostapdAdapter = (netdev_priv(dev));
2279 if (NULL == pHostapdAdapter)
2280 {
2281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2282 "%s: Adapter is NULL",__func__);
2283 return -EINVAL;
2284 }
2285 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2286 ret = wlan_hdd_validate_context(pHddCtx);
2287 if (0 != ret)
2288 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302289 return ret;
2290 }
2291 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2292 if (NULL == hHal)
2293 {
2294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2295 "%s: Hal Context is NULL",__func__);
2296 return -EINVAL;
2297 }
schang86c22c42013-03-13 18:41:24 -07002298 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002299 return -ENOMEM;
2300
Leo Changd37675a2013-08-01 13:19:45 -07002301 /* Assign correct slef MAC address */
2302 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2303 VOS_MAC_ADDR_SIZE);
2304 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2305 VOS_MAC_ADDR_SIZE);
2306
schang86c22c42013-03-13 18:41:24 -07002307 set_value = value[0];
2308 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2309 {
2310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002311 __func__);
schang86c22c42013-03-13 18:41:24 -07002312 return -EIO;
2313 }
2314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302315 EXIT();
schang86c22c42013-03-13 18:41:24 -07002316 return 0;
2317}
2318
2319int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302320static iw_softap_set_max_tx_power(struct net_device *dev,
2321 struct iw_request_info *info,
2322 union iwreq_data *wrqu, char *extra)
2323{
2324 int ret;
2325
2326 vos_ssr_protect(__func__);
2327 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2328 vos_ssr_unprotect(__func__);
2329
2330 return ret;
2331}
2332
2333
2334int
2335static __iw_display_data_path_snapshot(struct net_device *dev,
2336 struct iw_request_info *info,
2337 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302338{
2339
2340 /* Function intitiating dumping states of
2341 * HDD(WMM Tx Queues)
2342 * TL State (with Per Client infor)
2343 * DXE Snapshot (Called at the end of TL Snapshot)
2344 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302345 hdd_adapter_t *pHostapdAdapter;
2346 hdd_context_t *pHddCtx;
2347 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302348
2349 ENTER();
2350
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302351 pHostapdAdapter = (netdev_priv(dev));
2352 if (NULL == pHostapdAdapter)
2353 {
2354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2355 "%s: Adapter is NULL",__func__);
2356 return -EINVAL;
2357 }
2358 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2359 ret = wlan_hdd_validate_context(pHddCtx);
2360 if (0 != ret)
2361 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302362 return ret;
2363 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302364 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302365 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302366
2367 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302368 return 0;
2369}
2370
2371int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302372static iw_display_data_path_snapshot(struct net_device *dev,
2373 struct iw_request_info *info,
2374 union iwreq_data *wrqu, char *extra)
2375{
2376 int ret;
2377
2378 vos_ssr_protect(__func__);
2379 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2380 vos_ssr_unprotect(__func__);
2381
2382 return ret;
2383}
2384
2385int
2386static __iw_softap_set_tx_power(struct net_device *dev,
2387 struct iw_request_info *info,
2388 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002389{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302390 hdd_adapter_t *pHostapdAdapter;
2391 hdd_context_t *pHddCtx;
2392 v_CONTEXT_t pVosContext;
2393 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002394 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302395 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002396 ptSapContext pSapCtx = NULL;
2397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302398 ENTER();
2399
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302400 pHostapdAdapter = (netdev_priv(dev));
2401 if (NULL == pHostapdAdapter)
2402 {
2403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2404 "%s: Adapter is NULL",__func__);
2405 return -EINVAL;
2406 }
2407 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2408 ret = wlan_hdd_validate_context(pHddCtx);
2409 if (0 != ret)
2410 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302411 return ret;
2412 }
2413 pVosContext = pHddCtx->pvosContext;
2414 if (NULL == pVosContext)
2415 {
2416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2417 "%s: Vos Context is NULL",__func__);
2418 return -EINVAL;
2419 }
2420 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2421 if (NULL == hHal)
2422 {
2423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2424 "%s: Hal Context is NULL",__func__);
2425 return -EINVAL;
2426 }
schang86c22c42013-03-13 18:41:24 -07002427 if (NULL == value)
2428 return -ENOMEM;
2429
2430 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2431 if (NULL == pSapCtx)
2432 {
2433 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2434 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2435 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002436 }
2437
2438 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002439 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002440 {
schang86c22c42013-03-13 18:41:24 -07002441 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002442 __func__);
2443 return -EIO;
2444 }
2445
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302446 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002447 return 0;
2448}
2449
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302450int
2451static iw_softap_set_tx_power(struct net_device *dev,
2452 struct iw_request_info *info,
2453 union iwreq_data *wrqu, char *extra)
2454{
2455 int ret;
2456
2457 vos_ssr_protect(__func__);
2458 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2459 vos_ssr_unprotect(__func__);
2460
2461 return ret;
2462}
2463
Kiet Lambcf38522013-10-26 18:28:27 +05302464/**---------------------------------------------------------------------------
2465
2466 \brief iw_softap_set_trafficmonitor() -
2467 This function dynamically enable/disable traffic monitor functonality
2468 the command iwpriv wlanX setTrafficMon <value>.
2469
2470 \param - dev - Pointer to the net device.
2471 - addr - Pointer to the sockaddr.
2472 \return - 0 for success, non zero for failure
2473
2474 --------------------------------------------------------------------------*/
2475
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302476static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2477 struct iw_request_info *info,
2478 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302479{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302480 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302481 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302482 hdd_context_t *pHddCtx;
2483 int status;
2484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302485 ENTER();
2486
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302487 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302488 if (NULL == pAdapter)
2489 {
2490 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2491 "%s: HDD adapter is Null", __func__);
2492 return -ENODEV;
2493 }
2494
2495 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2496
2497 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302498 if (0 != status)
2499 {
Kiet Lambcf38522013-10-26 18:28:27 +05302500 return status;
2501 }
2502
2503 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2504
2505 if (NULL == isSetTrafficMon)
2506 {
2507 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2508 "%s: Invalid SAP pointer from extra", __func__);
2509 return -ENOMEM;
2510 }
2511
2512 if (TRUE == *isSetTrafficMon)
2513 {
2514 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2515 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2516 {
2517 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2518 "%s: failed to Start Traffic Monitor timer ", __func__ );
2519 return -EIO;
2520 }
2521 }
2522 else if (FALSE == *isSetTrafficMon)
2523 {
2524 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2525 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2526 {
2527 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2528 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2529 return -EIO;
2530 }
2531
2532 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302533
2534 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302535 return 0;
2536}
2537
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302538static int iw_softap_set_trafficmonitor(struct net_device *dev,
2539 struct iw_request_info *info,
2540 union iwreq_data *wrqu, char *extra)
2541{
2542 int ret;
2543
2544 vos_ssr_protect(__func__);
2545 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2546 vos_ssr_unprotect(__func__);
2547
2548 return ret;
2549}
2550
Jeff Johnson295189b2012-06-20 16:38:30 -07002551#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2552
2553int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302554static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2555 struct iw_request_info *info,
2556 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002557{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302558 hdd_adapter_t *pHostapdAdapter;
2559 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302560 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002561 char *buf;
2562 int cnt = 0;
2563 int left;
2564 int ret = 0;
2565 /* maclist_index must be u32 to match userspace */
2566 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302567 v_CONTEXT_t pVosContext = NULL;
2568 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302569
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302570 ENTER();
2571
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302572 pHostapdAdapter = (netdev_priv(dev));
2573 if (NULL == pHostapdAdapter)
2574 {
2575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2576 "%s: Adapter is NULL",__func__);
2577 return -EINVAL;
2578 }
2579 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2580 ret = wlan_hdd_validate_context(pHddCtx);
2581 if (0 != ret)
2582 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302583 return ret;
2584 }
2585
Jeff Johnson224f3702014-03-26 11:09:47 -07002586 /*
2587 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2588 * number, and even numbered iocts are supposed to have "set"
2589 * semantics. Hence the wireless extensions support in the kernel
2590 * won't correctly copy the result to userspace, so the ioctl
2591 * handler itself must copy the data. Output format is 32-bit
2592 * record length, followed by 0 or more 6-byte STA MAC addresses.
2593 *
2594 * Further note that due to the incorrect semantics, the "iwpriv"
2595 * userspace application is unable to correctly invoke this API,
2596 * hence it is not registered in the hostapd_private_args. This
2597 * API can only be invoked by directly invoking the ioctl() system
2598 * call.
2599 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002600
Jeff Johnson224f3702014-03-26 11:09:47 -07002601 /* make sure userspace allocated a reasonable buffer size */
2602 if (wrqu->data.length < sizeof(maclist_index)) {
2603 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2604 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302607 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2608 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2609 if(pSapCtx == NULL){
2610 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2611 FL("psapCtx is NULL"));
2612 return -EFAULT;
2613 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302614
2615 /* allocate local buffer to build the response */
2616 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2617 if (!buf) {
2618 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2619 return -ENOMEM;
2620 }
2621
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302622 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002623 /* start indexing beyond where the record count will be written */
2624 maclist_index = sizeof(maclist_index);
2625 left = wrqu->data.length - maclist_index;
2626
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302627 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002628 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2629 if ((pStaInfo[cnt].isUsed) &&
2630 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2631 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2632 VOS_MAC_ADDR_SIZE);
2633 maclist_index += VOS_MAC_ADDR_SIZE;
2634 left -= VOS_MAC_ADDR_SIZE;
2635 }
2636 cnt++;
2637 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302638 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002639
2640 *((u32 *)buf) = maclist_index;
2641 wrqu->data.length = maclist_index;
2642 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2643 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2644 ret = -EFAULT;
2645 }
2646 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302647
2648 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002649 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002650}
2651
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302652int
2653static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2654 struct iw_request_info *info,
2655 union iwreq_data *wrqu, char *extra)
2656{
2657 int ret;
2658
2659 vos_ssr_protect(__func__);
2660 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2661 vos_ssr_unprotect(__func__);
2662
2663 return ret;
2664}
2665
Jeff Johnson295189b2012-06-20 16:38:30 -07002666/* Usage:
2667 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2668 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2669 while using this ioctl
2670
2671 Syntax:
2672 iwpriv softap.0 disassoc_sta <6 octet mac address>
2673
2674 e.g.
2675 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2676 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2677*/
2678
2679int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302680static __iw_softap_disassoc_sta(struct net_device *dev,
2681 struct iw_request_info *info,
2682 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002683{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302684 hdd_adapter_t *pHostapdAdapter;
2685 hdd_context_t *pHddCtx;
2686 v_U8_t *peerMacAddr;
2687 int ret = 0;
2688
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302690 pHostapdAdapter = (netdev_priv(dev));
2691 if (NULL == pHostapdAdapter)
2692 {
2693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2694 "%s: Adapter is NULL",__func__);
2695 return -EINVAL;
2696 }
2697 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2698 ret = wlan_hdd_validate_context(pHddCtx);
2699 if (0 != ret)
2700 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302701 return ret;
2702 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302703 /* iwpriv tool or framework calls this ioctl with
2704 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302706 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707
Arif Hussain24bafea2013-11-15 15:10:03 -08002708 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2709 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2711 EXIT();
2712 return 0;
2713}
2714
2715int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302716static iw_softap_disassoc_sta(struct net_device *dev,
2717 struct iw_request_info *info,
2718 union iwreq_data *wrqu, char *extra)
2719{
2720 int ret;
2721
2722 vos_ssr_protect(__func__);
2723 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2724 vos_ssr_unprotect(__func__);
2725
2726 return ret;
2727}
2728
2729int
2730static __iw_softap_ap_stats(struct net_device *dev,
2731 struct iw_request_info *info,
2732 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002733{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302734 hdd_adapter_t *pHostapdAdapter;
2735 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 WLANTL_TRANSFER_STA_TYPE statBuffer;
2737 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302738 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302740 ENTER();
2741
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302742 pHostapdAdapter = (netdev_priv(dev));
2743 if (NULL == pHostapdAdapter)
2744 {
2745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2746 "%s: Adapter is NULL",__func__);
2747 return -EINVAL;
2748 }
2749 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2750 ret = wlan_hdd_validate_context(pHddCtx);
2751 if (0 != ret)
2752 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302753 return ret;
2754 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002755 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002756 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2757 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002758
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302759 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002760 if(NULL == pstatbuf) {
2761 hddLog(LOG1, "unable to allocate memory");
2762 return -ENOMEM;
2763 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302764
2765 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002766 "RUF=%d RMF=%d RBF=%d "
2767 "RUB=%d RMB=%d RBB=%d "
2768 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302769 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002770 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2771 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2772 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2773 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2774 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2775 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002776
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302777 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002778 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2779 kfree(pstatbuf);
2780 return -EFAULT;
2781 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302782
2783 strlcpy(extra, pstatbuf, len);
2784 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002785 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302786
2787 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 return 0;
2789}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302790int
2791static __iw_softap_ap_get_stats(struct net_device *dev,
2792 struct iw_request_info *info,
2793 union iwreq_data *wrqu, char *extra)
2794{
2795 hdd_adapter_t *pAdapter;
2796 hdd_tx_rx_stats_t *pStats;
2797
2798 ENTER();
2799 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2800 if (NULL == pAdapter)
2801 {
2802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2803 "%s: Adapter is NULL",__func__);
2804 return -EINVAL;
2805 }
2806
2807 pStats = &pAdapter->hdd_stats.hddTxRxStats;
2808 snprintf(extra, QCSAP_MAX_STR_LEN,
2809 "\nTransmit"
2810 "\ncalled %u, dropped %u, backpressured %u, queued %u"
2811 "\n dropped BK %u, BE %u, VI %u, VO %u"
2812 "\n classified BK %u, BE %u, VI %u, VO %u"
2813 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
2814 "\n queued BK %u, BE %u, VI %u, VO %u"
2815 "\nfetched %u, empty %u, lowres %u, deqerr %u"
2816 "\ndequeued %u, depressured %u, deque-depressured %u,\
2817 completed %u, flushed %u"
2818 "\n fetched BK %u, BE %u, VI %u, VO %u"
2819 "\n dequeued BK %u, BE %u, VI %u, VO %u"
2820 "\n depressured BK %u, BE %u, VI %u, VO %u"
2821 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
2822 "\n flushed BK %u, BE %u, VI %u, VO %u"
2823 "\n\nReceive"
2824 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
2825 "\n\nResetsStats"
2826 "\n",
2827 pStats->txXmitCalled,
2828 pStats->txXmitDropped,
2829 pStats->txXmitBackPressured,
2830 pStats->txXmitQueued,
2831
2832 pStats->txXmitDroppedAC[WLANTL_AC_BK],
2833 pStats->txXmitDroppedAC[WLANTL_AC_BE],
2834 pStats->txXmitDroppedAC[WLANTL_AC_VI],
2835 pStats->txXmitDroppedAC[WLANTL_AC_VO],
2836
2837 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
2838 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
2839 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
2840 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
2841
2842 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
2843 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
2844 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
2845 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
2846
2847 pStats->txXmitQueuedAC[WLANTL_AC_BK],
2848 pStats->txXmitQueuedAC[WLANTL_AC_BE],
2849 pStats->txXmitQueuedAC[WLANTL_AC_VI],
2850 pStats->txXmitQueuedAC[WLANTL_AC_VO],
2851
2852 pStats->txFetched,
2853 pStats->txFetchEmpty,
2854 pStats->txFetchLowResources,
2855 pStats->txFetchDequeueError,
2856
2857 pStats->txFetchDequeued,
2858 pStats->txFetchDePressured,
2859 pStats->txDequeDePressured,
2860 pStats->txCompleted,
2861 pStats->txFlushed,
2862
2863 pStats->txFetchedAC[WLANTL_AC_BK],
2864 pStats->txFetchedAC[WLANTL_AC_BE],
2865 pStats->txFetchedAC[WLANTL_AC_VI],
2866 pStats->txFetchedAC[WLANTL_AC_VO],
2867
2868 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
2869 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
2870 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
2871 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
2872
2873 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
2874 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
2875 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
2876 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
2877
2878 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
2879 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
2880 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
2881 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
2882
2883 pStats->txFlushedAC[WLANTL_AC_BK],
2884 pStats->txFlushedAC[WLANTL_AC_BE],
2885 pStats->txFlushedAC[WLANTL_AC_VI],
2886 pStats->txFlushedAC[WLANTL_AC_VO],
2887
2888 pStats->rxChains,
2889 pStats->rxPackets,
2890 pStats->rxDropped,
2891 pStats->rxDelivered,
2892 pStats->rxRefused
2893 );
2894
2895 wrqu->data.length = strlen(extra) + 1;
2896
2897 return 0;
2898}
2899
2900int
2901static __iw_softap_ap_clear_stats(struct net_device *dev,
2902 struct iw_request_info *info,
2903 union iwreq_data *wrqu, char *extra)
2904{
2905 hdd_adapter_t *pAdapter;
2906
2907 ENTER();
2908
2909 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2910 if (NULL == pAdapter)
2911 {
2912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2913 "%s: Adapter is NULL",__func__);
2914 return -EINVAL;
2915 }
2916
2917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
2918 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
2919 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
2920 return 0;
2921}
2922
2923
2924int
2925static iw_softap_get_stats(struct net_device *dev,
2926 struct iw_request_info *info,
2927 union iwreq_data *wrqu, char *extra)
2928{
2929 int ret;
2930 vos_ssr_protect(__func__);
2931 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
2932 vos_ssr_unprotect(__func__);
2933 return ret;
2934}
2935
2936int
2937static iw_softap_clear_stats(struct net_device *dev,
2938 struct iw_request_info *info,
2939 union iwreq_data *wrqu, char *extra)
2940{
2941 int ret;
2942 vos_ssr_protect(__func__);
2943 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
2944 vos_ssr_unprotect(__func__);
2945 return ret;
2946}
Jeff Johnson295189b2012-06-20 16:38:30 -07002947
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302948int
2949static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 struct iw_request_info *info,
2951 union iwreq_data *wrqu, char *extra)
2952{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302953 int ret;
2954
2955 vos_ssr_protect(__func__);
2956 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2957 vos_ssr_unprotect(__func__);
2958
2959 return ret;
2960}
2961
2962static int __iw_softap_set_channel_range(struct net_device *dev,
2963 struct iw_request_info *info,
2964 union iwreq_data *wrqu, char *extra)
2965{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302966 hdd_adapter_t *pHostapdAdapter;
2967 tHalHandle hHal;
2968 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 int *value = (int *)extra;
2970 int startChannel = value[0];
2971 int endChannel = value[1];
2972 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002973 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 int ret = 0; /* success */
2975
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302976 ENTER();
2977
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302978 pHostapdAdapter = (netdev_priv(dev));
2979 if (NULL == pHostapdAdapter)
2980 {
2981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2982 "%s: Adapter is NULL",__func__);
2983 return -EINVAL;
2984 }
2985 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2986 ret = wlan_hdd_validate_context(pHddCtx);
2987 if (0 != ret)
2988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302989 return ret;
2990 }
2991 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2992 if (NULL == hHal)
2993 {
2994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2995 "%s: Hal Context is NULL",__func__);
2996 return -EINVAL;
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
2999 if(status != VOS_STATUS_SUCCESS)
3000 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003001 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 startChannel,endChannel, band);
3003 ret = -EINVAL;
3004 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003005
3006 pHddCtx->is_dynamic_channel_range_set = 1;
3007
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303008 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 return ret;
3010}
3011
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303012static int iw_softap_set_channel_range(struct net_device *dev,
3013 struct iw_request_info *info,
3014 union iwreq_data *wrqu, char *extra)
3015{
3016 int ret;
3017
3018 vos_ssr_protect(__func__);
3019 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3020 vos_ssr_unprotect(__func__);
3021
3022 return ret;
3023}
3024
3025
3026int __iw_softap_get_channel_list(struct net_device *dev,
3027 struct iw_request_info *info,
3028 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003029{
3030 v_U32_t num_channels = 0;
3031 v_U8_t i = 0;
3032 v_U8_t bandStartChannel = RF_CHAN_1;
3033 v_U8_t bandEndChannel = RF_CHAN_165;
3034 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303035 hdd_adapter_t *pHostapdAdapter;
3036 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003039 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303040 hdd_context_t *pHddCtx;
3041 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303042
3043 ENTER();
3044
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303045 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3046 if (NULL == pHostapdAdapter)
3047 {
3048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3049 "%s: Adapter is NULL",__func__);
3050 return -EINVAL;
3051 }
3052 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3053 ret = wlan_hdd_validate_context(pHddCtx);
3054 if (0 != ret)
3055 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303056 return ret;
3057 }
3058 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3059 if (NULL == hHal)
3060 {
3061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3062 "%s: Hal Context is NULL",__func__);
3063 return -EINVAL;
3064 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003065 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3066 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003067 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003068 return -EIO;
3069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 wrqu->data.length = sizeof(tChannelListInfo);
3071 ENTER();
3072
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003073 if (eCSR_BAND_24 == curBand)
3074 {
3075 bandStartChannel = RF_CHAN_1;
3076 bandEndChannel = RF_CHAN_14;
3077 }
3078 else if (eCSR_BAND_5G == curBand)
3079 {
3080 bandStartChannel = RF_CHAN_36;
3081 bandEndChannel = RF_CHAN_165;
3082 }
3083
Arif Hussain6d2a3322013-11-17 19:50:10 -08003084 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303085 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003086 bandStartChannel, bandEndChannel );
3087
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3089 {
3090 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3091 {
3092 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3093 num_channels++;
3094 }
3095 }
3096
3097 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3098
3099 temp_num_channels = num_channels;
3100
3101 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3102 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303103 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003104 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 }
3106
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303107 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3108 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 {
3110 for(i = 0; i < temp_num_channels; i++)
3111 {
3112
3113 if((channel_list->channels[i] > 35) &&
3114 (channel_list->channels[i] < 49))
3115 {
3116 vos_mem_move(&channel_list->channels[i],
3117 &channel_list->channels[i+1],
3118 temp_num_channels - (i-1));
3119 num_channels--;
3120 temp_num_channels--;
3121 i--;
3122 }
3123 }
3124 }
3125
Arif Hussain6d2a3322013-11-17 19:50:10 -08003126 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003127
3128 if (num_channels > IW_MAX_FREQUENCIES)
3129 {
3130 num_channels = IW_MAX_FREQUENCIES;
3131 }
3132
3133 channel_list->num_channels = num_channels;
3134 EXIT();
3135
3136 return 0;
3137}
3138
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303139int iw_softap_get_channel_list(struct net_device *dev,
3140 struct iw_request_info *info,
3141 union iwreq_data *wrqu, char *extra)
3142{
3143 int ret;
3144
3145 vos_ssr_protect(__func__);
3146 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3147 vos_ssr_unprotect(__func__);
3148
3149 return ret;
3150}
3151
3152static
3153int __iw_get_genie(struct net_device *dev,
3154 struct iw_request_info *info,
3155 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003156{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303157 hdd_adapter_t *pHostapdAdapter;
3158 hdd_context_t *pHddCtx;
3159 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 eHalStatus status;
3161 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3162 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303163 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303164
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303166
3167 pHostapdAdapter = (netdev_priv(dev));
3168 if (NULL == pHostapdAdapter)
3169 {
3170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3171 "%s: Adapter is NULL",__func__);
3172 return -EINVAL;
3173 }
3174 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3175 ret = wlan_hdd_validate_context(pHddCtx);
3176 if (0 != ret)
3177 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303178 return ret;
3179 }
3180 pVosContext = pHddCtx->pvosContext;
3181 if (NULL == pVosContext)
3182 {
3183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3184 "%s: vos context is not valid ",__func__);
3185 return -EINVAL;
3186 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003187 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3189 status = WLANSap_getstationIE_information(pVosContext,
3190 &length,
3191 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003192 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3193 if (wrqu->data.length < length ||
3194 copy_to_user(wrqu->data.pointer,
3195 (v_VOID_t*)genIeBytes, length))
3196 {
3197 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3198 return -EFAULT;
3199 }
3200 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003201
Arif Hussain6d2a3322013-11-17 19:50:10 -08003202 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003203
3204
3205 EXIT();
3206 return 0;
3207}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303208
3209static
3210int iw_get_genie(struct net_device *dev,
3211 struct iw_request_info *info,
3212 union iwreq_data *wrqu, char *extra)
3213{
3214 int ret;
3215
3216 vos_ssr_protect(__func__);
3217 ret = __iw_get_genie(dev, info, wrqu, extra);
3218 vos_ssr_unprotect(__func__);
3219
3220 return ret;
3221}
3222
3223static
3224int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3225 struct iw_request_info *info,
3226 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003227{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303228 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003229 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303230 hdd_ap_ctx_t *pHddApCtx;
3231 hdd_context_t *pHddCtx;
3232 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303233
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003235
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303236 pHostapdAdapter = (netdev_priv(dev));
3237 if (NULL == pHostapdAdapter)
3238 {
3239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3240 "%s: Adapter is NULL",__func__);
3241 return -EINVAL;
3242 }
3243 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3244 ret = wlan_hdd_validate_context(pHddCtx);
3245 if (0 != ret)
3246 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303247 return ret;
3248 }
3249 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3250 if (NULL == pHddApCtx)
3251 {
3252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3253 "%s: AP context is NULL",__func__);
3254 return -EINVAL;
3255 }
3256
Arif Hussain6d2a3322013-11-17 19:50:10 -08003257 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003258 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3259
3260 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3261 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3262 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3263 WPSPBCProbeReqIEs.probeReqIELen);
3264 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3265 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3266 sizeof(v_MACADDR_t));
3267 if (copy_to_user(wrqu->data.pointer,
3268 (void *)&WPSPBCProbeReqIEs,
3269 sizeof(WPSPBCProbeReqIEs)))
3270 {
3271 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3272 return -EFAULT;
3273 }
3274 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003275 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003276 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 up(&pHddApCtx->semWpsPBCOverlapInd);
3278 EXIT();
3279 return 0;
3280}
3281
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303282static
3283int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3284 struct iw_request_info *info,
3285 union iwreq_data *wrqu, char *extra)
3286{
3287 int ret;
3288
3289 vos_ssr_protect(__func__);
3290 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3291 vos_ssr_unprotect(__func__);
3292
3293 return ret;
3294}
3295
Jeff Johnson295189b2012-06-20 16:38:30 -07003296/**---------------------------------------------------------------------------
3297
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303298 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 This function sets the auth type received from the wpa_supplicant.
3300
3301 \param - dev - Pointer to the net device.
3302 - info - Pointer to the iw_request_info.
3303 - wrqu - Pointer to the iwreq_data.
3304 - extra - Pointer to the data.
3305 \return - 0 for success, non zero for failure
3306
3307 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303308int __iw_set_auth_hostap(struct net_device *dev,
3309 struct iw_request_info *info,
3310 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003311{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303312 hdd_adapter_t *pAdapter;
3313 hdd_context_t *pHddCtx;
3314 hdd_wext_state_t *pWextState;
3315 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303316
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303318
3319 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3320 if (NULL == pAdapter)
3321 {
3322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3323 "%s: Adapter is NULL",__func__);
3324 return -EINVAL;
3325 }
3326
3327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3328 ret = wlan_hdd_validate_context(pHddCtx);
3329 if (0 != ret)
3330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303331 return ret;
3332 }
3333 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3334 if (NULL == pWextState)
3335 {
3336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3337 "%s: pWextState is NULL",__func__);
3338 return -EINVAL;
3339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 switch(wrqu->param.flags & IW_AUTH_INDEX)
3341 {
3342 case IW_AUTH_TKIP_COUNTERMEASURES:
3343 {
3344 if(wrqu->param.value) {
3345 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3346 "Counter Measure started %d", wrqu->param.value);
3347 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303348 }
3349 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3351 "Counter Measure stopped=%d", wrqu->param.value);
3352 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3353 }
3354
3355 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3356 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303359
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303361
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003362 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 wrqu->param.flags & IW_AUTH_INDEX);
3364 break;
3365 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303366
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 EXIT();
3368 return 0;
3369}
3370
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303371int iw_set_auth_hostap(struct net_device *dev,
3372 struct iw_request_info *info,
3373 union iwreq_data *wrqu,char *extra)
3374{
3375 int ret;
3376
3377 vos_ssr_protect(__func__);
3378 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3379 vos_ssr_unprotect(__func__);
3380
3381 return ret;
3382}
3383
3384static int __iw_set_ap_encodeext(struct net_device *dev,
3385 struct iw_request_info *info,
3386 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003387{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303388 hdd_adapter_t *pHostapdAdapter;
3389 v_CONTEXT_t pVosContext;
3390 hdd_context_t *pHddCtx;
3391 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003392 int retval = 0;
3393 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3395 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3396 int key_index;
3397 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303398 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003399// tCsrRoamRemoveKey RemoveKey;
3400 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303401
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303402 ENTER();
3403 pHostapdAdapter = (netdev_priv(dev));
3404 if (NULL == pHostapdAdapter)
3405 {
3406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3407 "%s: Adapter is NULL",__func__);
3408 return -EINVAL;
3409 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003410
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303411 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3412 retval = wlan_hdd_validate_context(pHddCtx);
3413 if (0 != retval)
3414 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303415 return retval;
3416 }
3417 pVosContext = pHddCtx->pvosContext;
3418 if (NULL == pVosContext)
3419 {
3420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3421 "%s: pVosContext is NULL",__func__);
3422 return -EINVAL;
3423 }
3424 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3425 if (NULL == pHddApCtx)
3426 {
3427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3428 "%s: AP Context is NULL",__func__);
3429 return -EINVAL;
3430 }
3431
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303433
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303435
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 /*Convert from 1-based to 0-based keying*/
3437 key_index--;
3438 }
3439 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303440#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 /*Set the encrytion type to NONE*/
3442#if 0
3443 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3444#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303445
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 RemoveKey.keyId = key_index;
3447 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3448 /*Key direction for group is RX only*/
3449 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3450 }
3451 else {
3452 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3453 }
3454 switch(ext->alg)
3455 {
3456 case IW_ENCODE_ALG_NONE:
3457 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3458 break;
3459 case IW_ENCODE_ALG_WEP:
3460 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3461 break;
3462 case IW_ENCODE_ALG_TKIP:
3463 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003464 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 case IW_ENCODE_ALG_CCMP:
3466 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3467 break;
3468 default:
3469 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3470 break;
3471 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003472 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 -07003473 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003475 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003477 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3478 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 {
3480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003481 __LINE__, vstatus );
3482 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003484#endif
3485 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003486
Jeff Johnson43971f52012-07-17 12:26:56 -07003487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003488
3489 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3490
3491 setKey.keyId = key_index;
3492 setKey.keyLength = ext->key_len;
3493
3494 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3495 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3496 }
3497
3498 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3499 /*Key direction for group is RX only*/
3500 setKey.keyDirection = eSIR_RX_ONLY;
3501 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3502 }
3503 else {
3504
3505 setKey.keyDirection = eSIR_TX_RX;
3506 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3507 }
3508 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3509 {
3510 setKey.keyDirection = eSIR_TX_DEFAULT;
3511 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3512 }
3513
3514 /*For supplicant pae role is zero*/
3515 setKey.paeRole = 0;
3516
3517 switch(ext->alg)
3518 {
3519 case IW_ENCODE_ALG_NONE:
3520 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3521 break;
3522
3523 case IW_ENCODE_ALG_WEP:
3524 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3525 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003526 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 break;
3528
3529 case IW_ENCODE_ALG_TKIP:
3530 {
3531 v_U8_t *pKey = &setKey.Key[0];
3532
3533 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3534
3535 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3536
3537 /*Supplicant sends the 32bytes key in this order
3538
3539 |--------------|----------|----------|
3540 | Tk1 |TX-MIC | RX Mic |
3541 |--------------|----------|----------|
3542 <---16bytes---><--8bytes--><--8bytes-->
3543
3544 */
3545 /*Sme expects the 32 bytes key to be in the below order
3546
3547 |--------------|----------|----------|
3548 | Tk1 |RX-MIC | TX Mic |
3549 |--------------|----------|----------|
3550 <---16bytes---><--8bytes--><--8bytes-->
3551 */
3552 /* Copy the Temporal Key 1 (TK1) */
3553 vos_mem_copy(pKey,ext->key,16);
3554
3555 /*Copy the rx mic first*/
3556 vos_mem_copy(&pKey[16],&ext->key[24],8);
3557
3558 /*Copy the tx mic */
3559 vos_mem_copy(&pKey[24],&ext->key[16],8);
3560
3561 }
3562 break;
3563
3564 case IW_ENCODE_ALG_CCMP:
3565 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3566 break;
3567
3568 default:
3569 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3570 break;
3571 }
3572
3573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303574 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 setKey.keyId);
3576 for(i=0; i< ext->key_len; i++)
3577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3578 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003579
3580 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3581 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 {
3583 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003584 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3585 retval = -EINVAL;
3586 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303587
3588 EXIT();
3589 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003590}
Jeff Johnson43971f52012-07-17 12:26:56 -07003591
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303592static int iw_set_ap_encodeext(struct net_device *dev,
3593 struct iw_request_info *info,
3594 union iwreq_data *wrqu, char *extra)
3595{
3596 int ret;
3597
3598 vos_ssr_protect(__func__);
3599 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3600 vos_ssr_unprotect(__func__);
3601
3602 return ret;
3603}
Jeff Johnson43971f52012-07-17 12:26:56 -07003604
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303605static int __iw_set_ap_mlme(struct net_device *dev,
3606 struct iw_request_info *info,
3607 union iwreq_data *wrqu,
3608 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003609{
3610#if 0
3611 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3612 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3613
3614 ENTER();
3615
3616 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3617 switch (mlme->cmd) {
3618 case IW_MLME_DISASSOC:
3619 case IW_MLME_DEAUTH:
3620 hddLog(LOG1, "Station disassociate");
3621 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3622 {
3623 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3624
3625 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3626 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3627
3628 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3629
3630 //clear all the reason codes
3631 if (status != 0)
3632 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003633 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 }
3635
3636 netif_stop_queue(dev);
3637 netif_carrier_off(dev);
3638 }
3639 else
3640 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003641 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 -07003642 }
3643 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003644 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 return -EINVAL;
3646 }//end of switch
3647 EXIT();
3648#endif
3649 return 0;
3650// return status;
3651}
3652
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303653static int iw_set_ap_mlme(struct net_device *dev,
3654 struct iw_request_info *info,
3655 union iwreq_data *wrqu,
3656 char *extra)
3657{
3658 int ret;
3659
3660 vos_ssr_protect(__func__);
3661 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3662 vos_ssr_unprotect(__func__);
3663
3664 return ret;
3665}
3666
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303667static int __iw_get_ap_rts_threshold(struct net_device *dev,
3668 struct iw_request_info *info,
3669 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003670{
3671 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3672 v_U32_t status = 0;
3673
3674 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3675
3676 return status;
3677}
3678
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303679static int iw_get_ap_rts_threshold(struct net_device *dev,
3680 struct iw_request_info *info,
3681 union iwreq_data *wrqu, char *extra)
3682{
3683 int ret;
3684
3685 vos_ssr_protect(__func__);
3686 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3687 vos_ssr_unprotect(__func__);
3688
3689 return ret;
3690}
3691
3692static int __iw_get_ap_frag_threshold(struct net_device *dev,
3693 struct iw_request_info *info,
3694 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003695{
3696 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3697 v_U32_t status = 0;
3698
3699 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3700
3701 return status;
3702}
3703
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303704static int iw_get_ap_frag_threshold(struct net_device *dev,
3705 struct iw_request_info *info,
3706 union iwreq_data *wrqu, char *extra)
3707{
3708 int ret;
3709
3710 vos_ssr_protect(__func__);
3711 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3712 vos_ssr_unprotect(__func__);
3713
3714 return ret;
3715}
3716
3717static int __iw_get_ap_freq(struct net_device *dev,
3718 struct iw_request_info *info,
3719 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003720{
Jeff Johnsone7245742012-09-05 17:12:55 -07003721 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303722 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 tHalHandle hHal;
3724 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303725 hdd_ap_ctx_t *pHddApCtx;
3726 hdd_context_t *pHddCtx;
3727 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003728
3729 ENTER();
3730
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303731 pHostapdAdapter = (netdev_priv(dev));
3732 if (NULL == pHostapdAdapter)
3733 {
3734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3735 "%s: Adapter is NULL",__func__);
3736 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303738 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3739 ret = wlan_hdd_validate_context(pHddCtx);
3740 if (0 != ret)
3741 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303742 return ret;
3743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303745 if (NULL == pHostapdState)
3746 {
3747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3748 "%s: pHostapdState is NULL",__func__);
3749 return -EINVAL;
3750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303752 if (NULL == hHal)
3753 {
3754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3755 "%s: Hal Context is NULL",__func__);
3756 return -EINVAL;
3757 }
3758 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3759 if (NULL == pHddApCtx)
3760 {
3761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3762 "%s: AP context is NULL",__func__);
3763 return -EINVAL;
3764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 if(pHostapdState->bssState == BSS_STOP )
3766 {
3767 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3768 != eHAL_STATUS_SUCCESS)
3769 {
c_hpothuffdb5272013-10-02 16:42:35 +05303770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3771 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 return -EIO;
3773 }
3774 else
3775 {
3776 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003777 if( TRUE == status)
3778 {
3779 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3780 * iwlist & iwconfig command shows frequency into proper
3781 * format (2.412 GHz instead of 246.2 MHz)*/
3782 fwrq->m = freq;
3783 fwrq->e = MHZ;
3784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 }
3786 }
3787 else
3788 {
3789 channel = pHddApCtx->operatingChannel;
3790 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003791 if( TRUE == status)
3792 {
3793 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3794 * iwlist & iwconfig command shows frequency into proper
3795 * format (2.412 GHz instead of 246.2 MHz)*/
3796 fwrq->m = freq;
3797 fwrq->e = MHZ;
3798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303800
3801 EXIT();
3802 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003803}
3804
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303805static int iw_get_ap_freq(struct net_device *dev,
3806 struct iw_request_info *info,
3807 struct iw_freq *fwrq, char *extra)
3808{
3809 int ret;
3810
3811 vos_ssr_protect(__func__);
3812 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3813 vos_ssr_unprotect(__func__);
3814
3815 return ret;
3816}
3817
3818static int __iw_get_mode(struct net_device *dev,
3819 struct iw_request_info *info,
3820 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303821{
3822 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303823 hdd_adapter_t *pAdapter;
3824 hdd_context_t *pHddCtx;
3825
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303826 ENTER();
3827
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303828 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3829 if (NULL == pAdapter)
3830 {
3831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3832 "%s: Adapter is NULL",__func__);
3833 return -EINVAL;
3834 }
3835 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3836 status = wlan_hdd_validate_context(pHddCtx);
3837 if (0 != status)
3838 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303839 return status;
3840 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303841
3842 wrqu->mode = IW_MODE_MASTER;
3843
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303844 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303845 return status;
3846}
3847
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303848static int iw_get_mode(struct net_device *dev,
3849 struct iw_request_info *info,
3850 union iwreq_data *wrqu, char *extra)
3851{
3852 int ret;
3853
3854 vos_ssr_protect(__func__);
3855 ret = __iw_get_mode(dev, info, wrqu, extra);
3856 vos_ssr_unprotect(__func__);
3857
3858 return ret;
3859}
3860
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303861static int __iw_softap_setwpsie(struct net_device *dev,
3862 struct iw_request_info *info,
3863 union iwreq_data *wrqu,
3864 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003865{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303866 hdd_adapter_t *pHostapdAdapter;
3867 hdd_context_t *pHddCtx;
3868 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 hdd_hostapd_state_t *pHostapdState;
3870 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003871 u_int8_t *wps_genie;
3872 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 u_int8_t *pos;
3874 tpSap_WPSIE pSap_WPSIe;
3875 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303876 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303877 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303878 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303879
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 ENTER();
3881
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303882 pHostapdAdapter = (netdev_priv(dev));
3883 if (NULL == pHostapdAdapter)
3884 {
3885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3886 "%s: Adapter is NULL",__func__);
3887 return -EINVAL;
3888 }
3889 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3890 ret = wlan_hdd_validate_context(pHddCtx);
3891 if (0 != ret)
3892 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303893 return ret;
3894 }
3895 pVosContext = pHddCtx->pvosContext;
3896 if (NULL == pVosContext)
3897 {
3898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3899 "%s: HDD context is not valid ",__func__);
3900 return -EINVAL;
3901 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303902 /* helper function to get iwreq_data with compat handling. */
3903 if (hdd_priv_get_data(&s_priv_data, wrqu))
3904 {
3905 return -EINVAL;
3906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003907
Girish Gowli07c05ec2014-06-17 20:47:03 +05303908 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3909 {
3910 return -EINVAL;
3911 }
3912
3913 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3914 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003915
Girish Gowli86c471e2014-06-17 19:28:05 +05303916 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003917 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303918 hddLog(LOG1, "%s: failed to alloc memory "
3919 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003920 return -EFAULT;
3921 }
3922
Girish Gowli86c471e2014-06-17 19:28:05 +05303923 fwps_genie = wps_genie;
3924
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3926 if (NULL == pSap_WPSIe)
3927 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003928 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003929 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 return -ENOMEM;
3931 }
3932 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3933
Arif Hussain6d2a3322013-11-17 19:50:10 -08003934 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 -07003935 WPSIeType = wps_genie[0];
3936 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3937 {
3938 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3939 wps_genie = wps_genie + 1;
3940 switch ( wps_genie[0] )
3941 {
3942 case DOT11F_EID_WPA:
3943 if (wps_genie[1] < 2 + 4)
3944 {
3945 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07003946 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 return -EINVAL;
3948 }
3949 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3950 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003951 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 pos = &wps_genie[6];
3953 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3954 {
3955 switch((u_int16_t)(*pos<<8) | *(pos+1))
3956 {
3957 case HDD_WPS_ELEM_VERSION:
3958 pos += 4;
3959 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003960 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3962 pos += 1;
3963 break;
3964
3965 case HDD_WPS_ELEM_WPS_STATE:
3966 pos +=4;
3967 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003968 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3970 pos += 1;
3971 break;
3972 case HDD_WPS_ELEM_APSETUPLOCK:
3973 pos += 4;
3974 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003975 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3977 pos += 1;
3978 break;
3979 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3980 pos += 4;
3981 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003982 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3984 pos += 1;
3985 break;
3986 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3987 pos += 4;
3988 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003989 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
3991 pos += 2;
3992 break;
3993 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
3994 pos += 4;
3995 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003996 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
3998 pos += 2;
3999 break;
4000
4001 case HDD_WPS_ELEM_UUID_E:
4002 pos += 2;
4003 length = *pos<<8 | *(pos+1);
4004 pos += 2;
4005 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
4006 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
4007 pos += length;
4008 break;
4009 case HDD_WPS_ELEM_RF_BANDS:
4010 pos += 4;
4011 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004012 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
4014 pos += 1;
4015 break;
4016
4017 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004018 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004020 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 return -EINVAL;
4022 }
4023 }
4024 }
4025 else {
4026 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004027 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029 break;
4030
4031 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004032 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004034 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 return 0;
4036 }
4037 }
4038 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
4039 {
4040 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
4041 wps_genie = wps_genie + 1;
4042 switch ( wps_genie[0] )
4043 {
4044 case DOT11F_EID_WPA:
4045 if (wps_genie[1] < 2 + 4)
4046 {
4047 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004048 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 return -EINVAL;
4050 }
4051 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
4052 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004053 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 pos = &wps_genie[6];
4055 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
4056 {
4057 switch((u_int16_t)(*pos<<8) | *(pos+1))
4058 {
4059 case HDD_WPS_ELEM_VERSION:
4060 pos += 4;
4061 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004062 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
4064 pos += 1;
4065 break;
4066
4067 case HDD_WPS_ELEM_WPS_STATE:
4068 pos +=4;
4069 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004070 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
4072 pos += 1;
4073 break;
4074 case HDD_WPS_ELEM_APSETUPLOCK:
4075 pos += 4;
4076 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004077 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
4079 pos += 1;
4080 break;
4081 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4082 pos += 4;
4083 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004084 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
4086 pos += 1;
4087 break;
4088 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4089 pos += 4;
4090 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004091 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
4093 pos += 2;
4094 break;
4095 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4096 pos += 4;
4097 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004098 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
4100 pos += 2;
4101 break;
4102 case HDD_WPS_ELEM_RSP_TYPE:
4103 pos += 4;
4104 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004105 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
4107 pos += 1;
4108 break;
4109 case HDD_WPS_ELEM_UUID_E:
4110 pos += 2;
4111 length = *pos<<8 | *(pos+1);
4112 pos += 2;
4113 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
4114 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
4115 pos += length;
4116 break;
4117
4118 case HDD_WPS_ELEM_MANUFACTURER:
4119 pos += 2;
4120 length = *pos<<8 | *(pos+1);
4121 pos += 2;
4122 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
4123 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
4124 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
4125 pos += length;
4126 break;
4127
4128 case HDD_WPS_ELEM_MODEL_NAME:
4129 pos += 2;
4130 length = *pos<<8 | *(pos+1);
4131 pos += 2;
4132 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
4133 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
4134 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
4135 pos += length;
4136 break;
4137 case HDD_WPS_ELEM_MODEL_NUM:
4138 pos += 2;
4139 length = *pos<<8 | *(pos+1);
4140 pos += 2;
4141 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
4142 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
4143 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
4144 pos += length;
4145 break;
4146 case HDD_WPS_ELEM_SERIAL_NUM:
4147 pos += 2;
4148 length = *pos<<8 | *(pos+1);
4149 pos += 2;
4150 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
4151 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
4152 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
4153 pos += length;
4154 break;
4155 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
4156 pos += 4;
4157 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004158 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 pos += 2;
4160
4161 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004162 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 pos += 4;
4164 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004165 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 pos += 2;
4167 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
4168 break;
4169 case HDD_WPS_ELEM_DEVICE_NAME:
4170 pos += 2;
4171 length = *pos<<8 | *(pos+1);
4172 pos += 2;
4173 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4174 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4175 pos += length;
4176 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4177 break;
4178 case HDD_WPS_ELEM_CONFIG_METHODS:
4179 pos += 4;
4180 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004181 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 pos += 2;
4183 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4184 break;
4185
4186 case HDD_WPS_ELEM_RF_BANDS:
4187 pos += 4;
4188 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004189 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 pos += 1;
4191 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4192 break;
4193 } // switch
4194 }
4195 }
4196 else
4197 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004198 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 }
4200
4201 } // switch
4202 }
4203 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
4204 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4205 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4206 {
4207 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4208 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4209 WLANSAP_Update_WpsIe ( pVosContext );
4210 }
4211
4212 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004213 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 EXIT();
4215 return halStatus;
4216}
4217
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304218static int iw_softap_setwpsie(struct net_device *dev,
4219 struct iw_request_info *info,
4220 union iwreq_data *wrqu,
4221 char *extra)
4222{
4223 int ret;
4224
4225 vos_ssr_protect(__func__);
4226 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4227 vos_ssr_unprotect(__func__);
4228
4229 return ret;
4230}
4231
4232static int __iw_softap_stopbss(struct net_device *dev,
4233 struct iw_request_info *info,
4234 union iwreq_data *wrqu,
4235 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004236{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304237 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304239 hdd_context_t *pHddCtx = NULL;
4240
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304242 pHostapdAdapter = (netdev_priv(dev));
4243 if (NULL == pHostapdAdapter)
4244 {
4245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4246 "%s: Adapter is NULL",__func__);
4247 return -EINVAL;
4248 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304249 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4250 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304251 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304252 return status;
4253 }
4254
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304255 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 {
4257 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4258 {
4259 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4260
4261 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304262
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304264 {
4265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004266 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 VOS_ASSERT(0);
4268 }
4269 }
4270 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304271 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 }
4273 EXIT();
4274 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4275}
4276
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304277static int iw_softap_stopbss(struct net_device *dev,
4278 struct iw_request_info *info,
4279 union iwreq_data *wrqu,
4280 char *extra)
4281{
4282 int ret;
4283
4284 vos_ssr_protect(__func__);
4285 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4286 vos_ssr_unprotect(__func__);
4287
4288 return ret;
4289}
4290
4291static int __iw_softap_version(struct net_device *dev,
4292 struct iw_request_info *info,
4293 union iwreq_data *wrqu,
4294 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004295{
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304297 hdd_context_t *pHddCtx;
4298 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304299
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304301 pHostapdAdapter = (netdev_priv(dev));
4302 if (NULL == pHostapdAdapter)
4303 {
4304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4305 "%s: Adapter is NULL",__func__);
4306 return -EINVAL;
4307 }
4308 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4309 ret = wlan_hdd_validate_context(pHddCtx);
4310 if (0 != ret)
4311 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304312 return ret;
4313 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004314 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 return 0;
4317}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004318
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304319static int iw_softap_version(struct net_device *dev,
4320 struct iw_request_info *info,
4321 union iwreq_data *wrqu,
4322 char *extra)
4323{
4324 int ret;
4325
4326 vos_ssr_protect(__func__);
4327 ret = __iw_softap_version(dev, info, wrqu, extra);
4328 vos_ssr_unprotect(__func__);
4329
4330 return ret;
4331}
4332
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004333VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004334{
4335 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004336 int len = 0;
4337 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304338 v_CONTEXT_t pVosContext;
4339 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304340 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304342 ENTER();
4343
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304344 if (NULL == pAdapter)
4345 {
4346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4347 "%s: Adapter is NULL",__func__);
4348 return -EINVAL;
4349 }
4350 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4351 if (0 != wlan_hdd_validate_context(pHddCtx))
4352 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304353 return VOS_STATUS_E_FAULT;
4354 }
4355 pVosContext = pHddCtx->pvosContext;
4356 if (NULL == pVosContext)
4357 {
4358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4359 "%s: VOS context is not valid",__func__);
4360 return VOS_STATUS_E_FAULT;
4361 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304362 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304363 if(pSapCtx == NULL)
4364 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304365 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4366 FL("psapCtx is NULL"));
4367 return VOS_STATUS_E_FAULT;
4368 }
4369
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004370 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004371 pBuf += len;
4372 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004373
4374 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4375 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304376 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004377 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004378 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304379 pSapCtx->aStaInfo[i].ucSTAId,
4380 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4381 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4382 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4383 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4384 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4385 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004386 pBuf += len;
4387 buf_len -= len;
4388 }
4389 if(WE_GET_STA_INFO_SIZE > buf_len)
4390 {
4391 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004392 }
4393 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304394 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004395 return VOS_STATUS_SUCCESS;
4396}
4397
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304398static int __iw_softap_get_sta_info(struct net_device *dev,
4399 struct iw_request_info *info,
4400 union iwreq_data *wrqu,
4401 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004402{
4403 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4404 VOS_STATUS status;
4405 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004406 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004407 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004408 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004409 return -EINVAL;
4410 }
4411 wrqu->data.length = strlen(extra);
4412 EXIT();
4413 return 0;
4414}
4415
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304416static int iw_softap_get_sta_info(struct net_device *dev,
4417 struct iw_request_info *info,
4418 union iwreq_data *wrqu,
4419 char *extra)
4420{
4421 int ret;
4422
4423 vos_ssr_protect(__func__);
4424 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4425 vos_ssr_unprotect(__func__);
4426
4427 return ret;
4428}
4429
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304430static int __iw_set_ap_genie(struct net_device *dev,
4431 struct iw_request_info *info,
4432 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004433{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304434
4435 hdd_adapter_t *pHostapdAdapter;
4436 hdd_context_t *pHddCtx;
4437 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004439 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304440 int ret = 0;
4441
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304443 pHostapdAdapter = (netdev_priv(dev));
4444 if (NULL == pHostapdAdapter)
4445 {
4446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4447 "%s: Adapter is NULL",__func__);
4448 return -EINVAL;
4449 }
4450 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4451 ret = wlan_hdd_validate_context(pHddCtx);
4452 if (0 != ret)
4453 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304454 return ret;
4455 }
4456 pVosContext = pHddCtx->pvosContext;
4457 if (NULL == pVosContext)
4458 {
4459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4460 "%s: VOS Context is NULL",__func__);
4461 return -EINVAL;
4462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 if(!wrqu->data.length)
4464 {
4465 EXIT();
4466 return 0;
4467 }
Arif Hussained667642013-10-27 23:01:14 -07004468
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304469 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304471 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 case DOT11F_EID_RSN:
4473 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4474 {
4475 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4476 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004479 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304481
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004483 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 halStatus = 0;
4485 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304486
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304488 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004489}
4490
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304491static int iw_set_ap_genie(struct net_device *dev,
4492 struct iw_request_info *info,
4493 union iwreq_data *wrqu, char *extra)
4494{
4495 int ret;
4496
4497 vos_ssr_protect(__func__);
4498 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4499 vos_ssr_unprotect(__func__);
4500
4501 return ret;
4502}
4503
Jeff Johnson295189b2012-06-20 16:38:30 -07004504static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4505{
4506 eHalStatus hstatus;
4507 long lrc;
4508 struct statsContext context;
4509
4510 if (NULL == pAdapter)
4511 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304512 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 return VOS_STATUS_E_FAULT;
4514 }
4515
4516 init_completion(&context.completion);
4517 context.pAdapter = pAdapter;
4518 context.magic = STATS_CONTEXT_MAGIC;
4519 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4520 eCSR_HDD,
4521 SME_GLOBAL_CLASSA_STATS,
4522 hdd_GetClassA_statisticsCB,
4523 0, // not periodic
4524 FALSE, //non-cached results
4525 staid,
4526 &context);
4527 if (eHAL_STATUS_SUCCESS != hstatus)
4528 {
4529 hddLog(VOS_TRACE_LEVEL_ERROR,
4530 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004531 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 }
4533 else
4534 {
4535 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4536 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 if (lrc <= 0)
4538 {
4539 hddLog(VOS_TRACE_LEVEL_ERROR,
4540 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004541 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 }
4543 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004544
4545 /* either we never sent a request, we sent a request and received a
4546 response or we sent a request and timed out. if we never sent a
4547 request or if we sent a request and got a response, we want to
4548 clear the magic out of paranoia. if we timed out there is a
4549 race condition such that the callback function could be
4550 executing at the same time we are. of primary concern is if the
4551 callback function had already verified the "magic" but had not
4552 yet set the completion variable when a timeout occurred. we
4553 serialize these activities by invalidating the magic while
4554 holding a shared spinlock which will cause us to block if the
4555 callback is currently executing */
4556 spin_lock(&hdd_context_lock);
4557 context.magic = 0;
4558 spin_unlock(&hdd_context_lock);
4559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 return VOS_STATUS_SUCCESS;
4561}
4562
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304563int __iw_get_softap_linkspeed(struct net_device *dev,
4564 struct iw_request_info *info,
4565 union iwreq_data *wrqu,
4566 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004567
4568{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304569 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304570 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004572 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304573 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304575 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004577 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304578 int rc, valid;
4579
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304580 ENTER();
4581
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304582 pHostapdAdapter = (netdev_priv(dev));
4583 if (NULL == pHostapdAdapter)
4584 {
4585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4586 "%s: Adapter is NULL",__func__);
4587 return -EINVAL;
4588 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304589 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304590 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304591 if (0 != valid)
4592 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304593 return valid;
4594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004595
Arif Hussain6d2a3322013-11-17 19:50:10 -08004596 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004597
4598 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004599 {
Arif Hussaina9571842014-01-15 16:43:41 -08004600 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4601 if (NULL == pmacAddress) {
4602 hddLog(LOG1, "unable to allocate memory");
4603 return -ENOMEM;
4604 }
4605 if (copy_from_user((void *)pmacAddress,
4606 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4607 {
4608 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4609 kfree(pmacAddress);
4610 return -EFAULT;
4611 }
4612 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4613
4614 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004615 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004616
4617 if (!VOS_IS_STATUS_SUCCESS(status ))
4618 {
4619 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4620 }
Arif Hussained667642013-10-27 23:01:14 -07004621 }
Kiet Lam61589852013-09-19 17:10:58 +05304622 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304623 * link speed for first connected client will be returned.
4624 */
Arif Hussaina9571842014-01-15 16:43:41 -08004625 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304626 {
4627 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4628 }
4629 else
4630 {
4631 status = hdd_softap_GetStaId(pHostapdAdapter,
4632 (v_MACADDR_t *)macAddress, (void *)(&staId));
4633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004634
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304635 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 link_speed = 0;
4639 }
4640 else
4641 {
4642 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304643
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 if (!VOS_IS_STATUS_SUCCESS(status ))
4645 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304646 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 return -EINVAL;
4648 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304649
4650 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4651 staId, &link_speed);
4652
4653 link_speed = link_speed / 10;
4654
4655 if (0 == link_speed)
4656 {
4657 /* The linkspeed returned by HAL is in units of 500kbps.
4658 * converting it to mbps.
4659 * This is required to support legacy firmware which does
4660 * not return link capacity.
4661 */
4662 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 }
4665
4666 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004667 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304668
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 if ((rc < 0) || (rc >= len))
4670 {
4671 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304672 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 return -EIO;
4674 }
4675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304676 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 return 0;
4678}
4679
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304680int iw_get_softap_linkspeed(struct net_device *dev,
4681 struct iw_request_info *info,
4682 union iwreq_data *wrqu,
4683 char *extra)
4684{
4685 int ret;
4686
4687 vos_ssr_protect(__func__);
4688 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4689 vos_ssr_unprotect(__func__);
4690
4691 return ret;
4692}
4693
4694
Jeff Johnson295189b2012-06-20 16:38:30 -07004695static const iw_handler hostapd_handler[] =
4696{
4697 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4698 (iw_handler) NULL, /* SIOCGIWNAME */
4699 (iw_handler) NULL, /* SIOCSIWNWID */
4700 (iw_handler) NULL, /* SIOCGIWNWID */
4701 (iw_handler) NULL, /* SIOCSIWFREQ */
4702 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4703 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304704 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 (iw_handler) NULL, /* SIOCSIWSENS */
4706 (iw_handler) NULL, /* SIOCGIWSENS */
4707 (iw_handler) NULL, /* SIOCSIWRANGE */
4708 (iw_handler) NULL, /* SIOCGIWRANGE */
4709 (iw_handler) NULL, /* SIOCSIWPRIV */
4710 (iw_handler) NULL, /* SIOCGIWPRIV */
4711 (iw_handler) NULL, /* SIOCSIWSTATS */
4712 (iw_handler) NULL, /* SIOCGIWSTATS */
4713 (iw_handler) NULL, /* SIOCSIWSPY */
4714 (iw_handler) NULL, /* SIOCGIWSPY */
4715 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4716 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4717 (iw_handler) NULL, /* SIOCSIWAP */
4718 (iw_handler) NULL, /* SIOCGIWAP */
4719 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4720 (iw_handler) NULL, /* SIOCGIWAPLIST */
4721 (iw_handler) NULL, /* SIOCSIWSCAN */
4722 (iw_handler) NULL, /* SIOCGIWSCAN */
4723 (iw_handler) NULL, /* SIOCSIWESSID */
4724 (iw_handler) NULL, /* SIOCGIWESSID */
4725 (iw_handler) NULL, /* SIOCSIWNICKN */
4726 (iw_handler) NULL, /* SIOCGIWNICKN */
4727 (iw_handler) NULL, /* -- hole -- */
4728 (iw_handler) NULL, /* -- hole -- */
4729 (iw_handler) NULL, /* SIOCSIWRATE */
4730 (iw_handler) NULL, /* SIOCGIWRATE */
4731 (iw_handler) NULL, /* SIOCSIWRTS */
4732 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4733 (iw_handler) NULL, /* SIOCSIWFRAG */
4734 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4735 (iw_handler) NULL, /* SIOCSIWTXPOW */
4736 (iw_handler) NULL, /* SIOCGIWTXPOW */
4737 (iw_handler) NULL, /* SIOCSIWRETRY */
4738 (iw_handler) NULL, /* SIOCGIWRETRY */
4739 (iw_handler) NULL, /* SIOCSIWENCODE */
4740 (iw_handler) NULL, /* SIOCGIWENCODE */
4741 (iw_handler) NULL, /* SIOCSIWPOWER */
4742 (iw_handler) NULL, /* SIOCGIWPOWER */
4743 (iw_handler) NULL, /* -- hole -- */
4744 (iw_handler) NULL, /* -- hole -- */
4745 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4746 (iw_handler) NULL, /* SIOCGIWGENIE */
4747 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4748 (iw_handler) NULL, /* SIOCGIWAUTH */
4749 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4750 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4751 (iw_handler) NULL, /* SIOCSIWPMKSA */
4752};
4753
Jeff Johnson224f3702014-03-26 11:09:47 -07004754/*
4755 * Note that the following ioctls were defined with semantics which
4756 * cannot be handled by the "iwpriv" userspace application and hence
4757 * they are not included in the hostapd_private_args array
4758 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4759 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004760
4761static const struct iw_priv_args hostapd_private_args[] = {
4762 { QCSAP_IOCTL_SETPARAM,
4763 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4764 { QCSAP_IOCTL_SETPARAM,
4765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304766 { QCSAP_PARAM_GET_FRAME_LOGS,
4767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 { QCSAP_PARAM_MAX_ASSOC,
4769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4770 { QCSAP_PARAM_HIDE_SSID,
4771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004772 { QCSAP_PARAM_SET_MC_RATE,
4773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 { QCSAP_IOCTL_GETPARAM,
4775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4777 { QCSAP_IOCTL_GETPARAM, 0,
4778 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4779 { QCSAP_PARAM_MAX_ASSOC, 0,
4780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004781 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4782 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4783 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304785 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 { QCSAP_PARAM_CLR_ACL, 0,
4788 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4789 { QCSAP_PARAM_ACL_MODE,
4790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 { QCSAP_IOCTL_GET_STAWPAIE,
4792 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4793 { QCSAP_IOCTL_SETWPAIE,
4794 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4795 { QCSAP_IOCTL_STOPBSS,
4796 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4797 { QCSAP_IOCTL_VERSION, 0,
4798 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004799 { QCSAP_IOCTL_GET_STA_INFO, 0,
4800 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004802 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004804 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004805 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304807 { QCSAP_IOCTL_AP_STATS, 0,
4808 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304809 { QCSAP_IOCTL_GET_STATS, 0,
4810 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4811 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4813 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304814 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004815
4816 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4817 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4818 /* handlers for sub-ioctl */
4819 { WE_SET_WLAN_DBG,
4820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4821 0,
4822 "setwlandbg" },
4823
4824 /* handlers for main ioctl */
4825 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4826 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4827 0,
4828 "" },
4829
4830 /* handlers for sub-ioctl */
4831 { WE_LOG_DUMP_CMD,
4832 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4833 0,
4834 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 { WE_P2P_NOA_CMD,
4836 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4837 0,
4838 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004839 /* handlers for sub ioctl */
4840 {
4841 WE_MCC_CONFIG_CREDENTIAL,
4842 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4843 0,
4844 "setMccCrdnl" },
4845
4846 /* handlers for sub ioctl */
4847 {
4848 WE_MCC_CONFIG_PARAMS,
4849 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4850 0,
4851 "setMccConfig" },
4852
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 /* handlers for main ioctl */
4854 { QCSAP_IOCTL_MODIFY_ACL,
4855 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4856 0,
4857 "modify_acl" },
4858
4859 /* handlers for main ioctl */
4860 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4861 0,
4862 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4863 "getChannelList" },
4864
Jeff Johnsone7245742012-09-05 17:12:55 -07004865 /* handlers for main ioctl */
4866 { QCSAP_IOCTL_SET_TX_POWER,
4867 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4868 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304869 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004870
4871 /* handlers for main ioctl */
4872 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4873 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4874 0,
4875 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304876
4877 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4878 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4879 0,
4880 "dataSnapshot" },
4881
4882 /* handlers for main ioctl */
4883 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4884 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4885 0,
4886 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004887};
Jeff Johnsone7245742012-09-05 17:12:55 -07004888
Jeff Johnson295189b2012-06-20 16:38:30 -07004889static const iw_handler hostapd_private[] = {
4890 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4891 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4893 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4894 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4895 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4896 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4897 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4898 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4899 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4900 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304901 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4903 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4904 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4905 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004906 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004907 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4908 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004909 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304910 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304911 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304912 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4913 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004914};
4915const struct iw_handler_def hostapd_handler_def = {
4916 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4917 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4918 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4919 .standard = (iw_handler *)hostapd_handler,
4920 .private = (iw_handler *)hostapd_private,
4921 .private_args = hostapd_private_args,
4922 .get_wireless_stats = NULL,
4923};
4924#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4925struct net_device_ops net_ops_struct = {
4926 .ndo_open = hdd_hostapd_open,
4927 .ndo_stop = hdd_hostapd_stop,
4928 .ndo_uninit = hdd_hostapd_uninit,
4929 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4930 .ndo_tx_timeout = hdd_softap_tx_timeout,
4931 .ndo_get_stats = hdd_softap_stats,
4932 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4933 .ndo_do_ioctl = hdd_hostapd_ioctl,
4934 .ndo_change_mtu = hdd_hostapd_change_mtu,
4935 .ndo_select_queue = hdd_hostapd_select_queue,
4936 };
4937#endif
4938
4939int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4940{
4941 return VOS_STATUS_SUCCESS;
4942}
4943
4944void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4945{
4946#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4947 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4948#else
4949 pWlanHostapdDev->open = hdd_hostapd_open;
4950 pWlanHostapdDev->stop = hdd_hostapd_stop;
4951 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4952 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4953 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4954 pWlanHostapdDev->get_stats = hdd_softap_stats;
4955 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4956 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4957#endif
4958}
4959
4960VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304961{
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 hdd_hostapd_state_t * phostapdBuf;
4963 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004964 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004966#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004967 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4968 v_U16_t unsafeChannelCount;
4969#endif /* FEATURE_WLAN_CH_AVOID */
4970
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304971 if (pHddCtx->isLogpInProgress) {
4972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4973 "%s:LOGP in Progress. Ignore!!!",__func__);
4974 status = VOS_STATUS_E_FAILURE;
4975 }
4976
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304978 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304980
Nirav Shah7e3c8132015-06-22 23:51:42 +05304981 spin_lock_init(&pAdapter->sta_hash_lock);
4982 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4983
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004984 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4985
Leo Chang0b0e45a2013-12-15 15:18:55 -08004986#ifdef FEATURE_WLAN_CH_AVOID
4987 /* Get unsafe cahnnel list from cached location */
4988 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4989 sizeof(unsafeChannelList),
4990 &unsafeChannelCount);
4991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4992 "%s : Unsafe Channel count %d",
4993 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304994 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004995 unsafeChannelList,
4996 unsafeChannelCount);
4997#endif /* FEATURE_WLAN_CH_AVOID */
4998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 // Zero the memory. This zeros the profile structure.
5000 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
5001
5002 // Set up the pointer to the Wireless Extensions state structure
5003 // NOP
5004 status = hdd_set_hostapd(pAdapter);
5005 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 return status;
5008 }
5009
5010 status = vos_event_init(&phostapdBuf->vosEvent);
5011 if (!VOS_IS_STATUS_SUCCESS(status))
5012 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 return status;
5015 }
5016
5017 init_completion(&pAdapter->session_close_comp_var);
5018 init_completion(&pAdapter->session_open_comp_var);
5019
5020 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5021
5022 // Register as a wireless device
5023 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5024
5025 //Initialize the data path module
5026 status = hdd_softap_init_tx_rx(pAdapter);
5027 if ( !VOS_IS_STATUS_SUCCESS( status ))
5028 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005029 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305031
5032 status = hdd_wmm_adapter_init( pAdapter );
5033 if (!VOS_IS_STATUS_SUCCESS(status))
5034 {
5035 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005036 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305037 status, status );
5038 goto error_wmm_init;
5039 }
5040
5041 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5042
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305043 return status;
5044
5045error_wmm_init:
5046 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 EXIT();
5048 return status;
5049}
5050
5051hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5052{
5053 struct net_device *pWlanHostapdDev = NULL;
5054 hdd_adapter_t *pHostapdAdapter = NULL;
5055 v_CONTEXT_t pVosContext= NULL;
5056
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305057 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5058#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5059 NET_NAME_UNKNOWN,
5060#endif
5061 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 if (pWlanHostapdDev != NULL)
5063 {
5064 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5065
5066 //Init the net_device structure
5067 ether_setup(pWlanHostapdDev);
5068
5069 //Initialize the adapter context to zeros.
5070 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5071 pHostapdAdapter->dev = pWlanHostapdDev;
5072 pHostapdAdapter->pHddCtx = pHddCtx;
5073 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5074
5075 //Get the Global VOSS context.
5076 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5077 //Save the adapter context in global context for future.
5078 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5079
5080 //Init the net_device structure
5081 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5082
5083 hdd_set_ap_ops( pHostapdAdapter->dev );
5084
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5086 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5087
5088 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5089 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5090
5091 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5093 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5094 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
5095 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
5097 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
Mahesh A Saptasagar60de76d2014-04-25 18:37:08 +05305098 init_completion(&pHostapdAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07005099#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5100 init_completion(&pHostapdAdapter->offchannel_tx_event);
5101#endif
5102
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5104 }
5105 return pHostapdAdapter;
5106}
5107
5108VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5109{
5110 struct net_device *dev = pAdapter->dev;
5111 VOS_STATUS status = VOS_STATUS_SUCCESS;
5112
5113 ENTER();
5114
5115 if( rtnl_lock_held )
5116 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005117 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 if( dev_alloc_name(dev, dev->name) < 0 )
5119 {
5120 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5121 return VOS_STATUS_E_FAILURE;
5122 }
5123 }
5124 if (register_netdevice(dev))
5125 {
5126 hddLog(VOS_TRACE_LEVEL_FATAL,
5127 "%s:Failed:register_netdevice", __func__);
5128 return VOS_STATUS_E_FAILURE;
5129 }
5130 }
5131 else
5132 {
5133 if (register_netdev(dev))
5134 {
5135 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5136 return VOS_STATUS_E_FAILURE;
5137 }
5138 }
5139 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5140
5141 EXIT();
5142 return status;
5143}
5144
c_hpothu002231a2015-02-05 14:58:51 +05305145VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005146{
5147 ENTER();
5148
5149 hdd_softap_deinit_tx_rx(pAdapter);
5150
5151 /* if we are being called during driver unload, then the dev has already
5152 been invalidated. if we are being called at other times, then we can
5153 detatch the wireless device handlers */
5154 if (pAdapter->dev)
5155 {
c_hpothu002231a2015-02-05 14:58:51 +05305156 if (TRUE == rtnl_held)
5157 {
5158 pAdapter->dev->wireless_handlers = NULL;
5159 }
5160 else
5161 {
5162 rtnl_lock();
5163 pAdapter->dev->wireless_handlers = NULL;
5164 rtnl_unlock();
5165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 }
5167 EXIT();
5168 return 0;
5169}