blob: 03889a4b6c49bdbccd4e24e519debf21a4f15e05 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh57a31542016-01-04 21:01:43 +05302 * Copyright (c) 2012-2016 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;
Deepthi Gowried085092015-10-20 19:30:52 +0530814 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -0700815
816 dev = (struct net_device *)usrDataForCallback;
817 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530818
819 if ((NULL == pHostapdAdapter) ||
820 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
821 {
822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
823 "invalid adapter or adapter has invalid magic");
824 return eHAL_STATUS_FAILURE;
825 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530826 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
827 pSapCtx = VOS_GET_SAP_CB(pVosContext);
828 if(pSapCtx == NULL){
829 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
830 FL("psapCtx is NULL"));
831 return eHAL_STATUS_FAILURE;
832 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
834 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
835 sapEvent = pSapEvent->sapHddEventCode;
836 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800837 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +0530838 cfg_param = pHddCtx->cfg_ini;
839
Jeff Johnson295189b2012-06-20 16:38:30 -0700840
841 switch(sapEvent)
842 {
843 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800844 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
846 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
847 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
848
849 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
850 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +0530851
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +0530853 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 goto stopbss;
856 }
857 else
Deepthi Gowried085092015-10-20 19:30:52 +0530858 {
859 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
860 {
861 if ((cfg_param->dynSplitscan) &&
862 (!pHddCtx->issplitscan_enabled))
863 {
864 pHddCtx->issplitscan_enabled = TRUE;
865 sme_enable_disable_split_scan(
866 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
867 cfg_param->nNumStaChanCombinedConc,
868 cfg_param->nNumP2PChanCombinedConc);
869 }
870 }
871
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
873 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530874 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
875 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530876 {
c_hpothuffdb5272013-10-02 16:42:35 +0530877 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530878 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
879 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 }
Deepthi Gowried085092015-10-20 19:30:52 +0530881
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
883 {
884 // AP Inactivity timer init and start
885 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
886 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
887 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800888 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700889
890 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
891 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800892 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700893
894 }
895 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
896 pHostapdState->bssState = BSS_START;
897
898 // Send current operating channel of SoftAP to BTC-ES
899 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 //Check if there is any group key pending to set.
902 if( pHddApCtx->groupKey.keyLength )
903 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700904 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
906 &pHddApCtx->groupKey ) )
907 {
908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
909 "%s: WLANSAP_SetKeySta failed", __func__);
910 }
911 pHddApCtx->groupKey.keyLength = 0;
912 }
913 else if ( pHddApCtx->wepKey[0].keyLength )
914 {
915 int i=0;
916 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
917 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700918 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
920 &pHddApCtx->wepKey[i] ) )
921 {
922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
923 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
924 }
925 pHddApCtx->wepKey[i].keyLength = 0;
926 }
927 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
929 startBssEvent = "SOFTAP.enabled";
930 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
931 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
932 memset(&wrqu, 0, sizeof(wrqu));
933 wrqu.data.length = strlen(startBssEvent);
934 we_event = IWEVCUSTOM;
935 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700936 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 break; //Event will be sent after Switch-Case stmt
938
939 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800940 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
942
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700943 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700944 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700945
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530947
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530948 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530949 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530950 hddLog(LOG1,
951 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
952 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530953 }
954
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 goto stopbss;
956 case eSAP_STA_SET_KEY_EVENT:
957 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800958 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
960 return VOS_STATUS_SUCCESS;
961 case eSAP_STA_DEL_KEY_EVENT:
962 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800963 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 return VOS_STATUS_SUCCESS;
965 case eSAP_STA_MIC_FAILURE_EVENT:
966 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 memset(&msg, '\0', sizeof(msg));
968 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800969 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800970 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700971 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 msg.flags = IW_MICFAILURE_GROUP;
973 else
974 msg.flags = IW_MICFAILURE_PAIRWISE;
975 memset(&wrqu, 0, sizeof(wrqu));
976 wrqu.data.length = sizeof(msg);
977 we_event = IWEVMICHAELMICFAILURE;
978 we_custom_event_generic = (v_BYTE_t *)&msg;
979 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 /* inform mic failure to nl80211 */
981 cfg80211_michael_mic_failure(dev,
982 pSapEvent->sapevt.
983 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700984 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 NL80211_KEYTYPE_GROUP :
986 NL80211_KEYTYPE_PAIRWISE),
987 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
988 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
989 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 break;
991
992 case eSAP_STA_ASSOC_EVENT:
993 case eSAP_STA_REASSOC_EVENT:
994 wrqu.addr.sa_family = ARPHRD_ETHER;
995 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800996 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800997 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 we_event = IWEVREGISTERED;
999
1000 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1001
1002 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1003 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1004 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1005 {
1006 bAuthRequired = FALSE;
1007 }
1008
1009 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
1010 {
c_hpothuffdb5272013-10-02 16:42:35 +05301011 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 TRUE,
1013 pHddApCtx->uPrivacy,
1014 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1015 0,
1016 0,
1017 (v_MACADDR_t *)wrqu.addr.sa_data,
1018 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301019
1020 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1021 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1022 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 }
1024 else
1025 {
c_hpothuffdb5272013-10-02 16:42:35 +05301026 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 FALSE,
1028 pHddApCtx->uPrivacy,
1029 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1030 0,
1031 0,
1032 (v_MACADDR_t *)wrqu.addr.sa_data,
1033 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301034 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1035 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1036 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001037 }
1038
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301039 staId =
1040 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1041 if (VOS_IS_STATUS_SUCCESS(vos_status))
1042 {
1043
1044 pSapCtx->aStaInfo[staId].rate_flags =
1045 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1046 }
1047
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 // Stop AP inactivity timer
1049 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1050 {
1051 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1052 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001053 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001055#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001056 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1057 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301058 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1059 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001060 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301061 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1062 HDD_SAP_WAKE_LOCK_DURATION,
1063 WIFI_POWER_EVENT_WAKELOCK_SAP);
1064
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001065#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001066#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1067 {
1068 struct station_info staInfo;
1069 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1070
1071 memset(&staInfo, 0, sizeof(staInfo));
1072 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1073 {
1074 staInfo.assoc_req_ies =
1075 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1076 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001077#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001078 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1079#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 cfg80211_new_sta(dev,
1081 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1082 &staInfo, GFP_KERNEL);
1083 }
1084 else
1085 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001086 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 }
1088 }
1089#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301090 hdd_manage_delack_timer(pHddCtx);
1091
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001092 pScanInfo = &pHddCtx->scan_info;
1093 // Lets do abort scan to ensure smooth authentication for client
1094 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1095 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301096 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301097 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001099
1100 break;
1101 case eSAP_STA_DISASSOC_EVENT:
1102 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001103 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001104 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1106 hddLog(LOG1," User initiated disassociation");
1107 else
1108 hddLog(LOG1," MAC initiated disassociation");
1109 we_event = IWEVEXPIRED;
1110 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1111 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1112 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001113 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 -07001114 return VOS_STATUS_E_FAILURE;
1115 }
1116 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1117
1118 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1119 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301120 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 // Start AP inactivity timer if no stations associated with it
1122 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1123 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301124 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 {
1126 bApActive = TRUE;
1127 break;
1128 }
1129 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301130 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001131
1132 if (bApActive == FALSE)
1133 {
1134 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1135 {
1136 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1137 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001138 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 }
1140 else
1141 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1142 }
1143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001144#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1145 cfg80211_del_sta(dev,
1146 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1147 GFP_KERNEL);
1148#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001149 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301150 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1151 if (VOS_STATUS_SUCCESS != vos_status)
1152 {
1153 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1154 __func__, vos_status);
1155 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301156 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 break;
1158 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1159 {
1160 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1161 union iwreq_data wreq;
1162
1163 down(&pHddApCtx->semWpsPBCOverlapInd);
1164 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1165
1166 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1167 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1168
1169 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001170 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 memset(&wreq, 0, sizeof(wreq));
1172 wreq.data.length = strlen(message); // This is length of message
1173 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1174
1175 return VOS_STATUS_SUCCESS;
1176 }
1177 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1178 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1179 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1180 { // List of associated stations
1181 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1182 {
1183 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1184 i+1,
1185 pAssocStasArray->assocId,
1186 pAssocStasArray->staId,
1187 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1188 pAssocStasArray++;
1189 }
1190 }
1191 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001192 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 case eSAP_REMAIN_CHAN_READY:
1195 hdd_remainChanReadyHandler( pHostapdAdapter );
1196 return VOS_STATUS_SUCCESS;
1197 case eSAP_SEND_ACTION_CNF:
1198 hdd_sendActionCnf( pHostapdAdapter,
1199 ( eSAP_STATUS_SUCCESS ==
1200 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1201 TRUE : FALSE );
1202 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 case eSAP_UNKNOWN_STA_JOIN:
1204 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1205 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1206 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1207 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1208 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1209 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1210 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1211 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1212 wrqu.data.pointer = unknownSTAEvent;
1213 wrqu.data.length = strlen(unknownSTAEvent);
1214 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301215 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 break;
1217
1218 case eSAP_MAX_ASSOC_EXCEEDED:
1219 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1220 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1221 " one or more devices to enable the new device connection",
1222 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1223 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1224 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1225 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1226 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1227 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1228 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1229 wrqu.data.pointer = maxAssocExceededEvent;
1230 wrqu.data.length = strlen(maxAssocExceededEvent);
1231 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001232 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 break;
1234 case eSAP_STA_ASSOC_IND:
1235 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001236
1237 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001238 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001239 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1240 return VOS_STATUS_SUCCESS;
1241
1242 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301243 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301244 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1245 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301246 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301247 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001248 return VOS_STATUS_SUCCESS;
1249
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001251 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 goto stopbss;
1253 return VOS_STATUS_SUCCESS;
1254 }
1255 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1256 return VOS_STATUS_SUCCESS;
1257
1258stopbss :
1259 {
1260 v_BYTE_t we_custom_event[64];
1261 char *stopBssEvent = "STOP-BSS.response";//17
1262 int event_len = strlen(stopBssEvent);
1263
1264 hddLog(LOG1, FL("BSS stop status = %s"),
1265 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1266 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1267
1268 /* Change the BSS state now since, as we are shutting things down,
1269 * we don't want interfaces to become re-enabled */
1270 pHostapdState->bssState = BSS_STOP;
1271
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301272 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1273 {
1274 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1275 {
1276 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1277 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1278 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1279 }
1280
1281 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1282 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1283 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1284 }
1285
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 /* Stop the pkts from n/w stack as we are going to free all of
1287 * the TX WMM queues for all STAID's */
1288 hdd_hostapd_stop(dev);
1289
1290 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301291 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1292 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1293 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294
Amar Singhal37e6f052013-03-05 16:16:54 -08001295 /* once the event is set, structure dev/pHostapdAdapter should
1296 * not be touched since they are now subject to being deleted
1297 * by another thread */
1298 if (eSAP_STOP_BSS_EVENT == sapEvent)
1299 vos_event_set(&pHostapdState->vosEvent);
1300
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 /* notify userspace that the BSS has stopped */
1302 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1303 memcpy(&we_custom_event, stopBssEvent, event_len);
1304 memset(&wrqu, 0, sizeof(wrqu));
1305 wrqu.data.length = event_len;
1306 we_event = IWEVCUSTOM;
1307 we_custom_event_generic = we_custom_event;
1308 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001309 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 }
1311 return VOS_STATUS_SUCCESS;
1312}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001313
1314int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001316 eCsrEncryptionType *pEncryptType,
1317 eCsrEncryptionType *mcEncryptType,
1318 eCsrAuthType *pAuthType,
1319 v_BOOL_t *pMFPCapable,
1320 v_BOOL_t *pMFPRequired,
1321 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 u_int8_t *gen_ie )
1323{
1324 tDot11fIERSN dot11RSNIE;
1325 tDot11fIEWPA dot11WPAIE;
1326
1327 tANI_U8 *pRsnIe;
1328 tANI_U16 RSNIeLen;
1329
1330 if (NULL == halHandle)
1331 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001332 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 return -EINVAL;
1334 }
1335
1336 // Validity checks
1337 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1338 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1339 return -EINVAL;
1340 // Type check
1341 if ( gen_ie[0] == DOT11F_EID_RSN)
1342 {
1343 // Validity checks
1344 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1345 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1346 {
1347 return VOS_STATUS_E_FAILURE;
1348 }
1349 // Skip past the EID byte and length byte
1350 pRsnIe = gen_ie + 2;
1351 RSNIeLen = gen_ie_len - 2;
1352 // Unpack the RSN IE
1353 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1354 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1355 pRsnIe,
1356 RSNIeLen,
1357 &dot11RSNIE);
1358 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001359 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001360 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001361 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001362 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 /*Here we have followed the apple base code,
1364 but probably I suspect we can do something different*/
1365 //dot11RSNIE.akm_suite_count
1366 // Just translate the FIRST one
1367 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1368 //dot11RSNIE.pwise_cipher_suite_count
1369 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1370 //dot11RSNIE.gp_cipher_suite_count
1371 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1372 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001373 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1374 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375
1376 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1377 } else
1378 if (gen_ie[0] == DOT11F_EID_WPA)
1379 {
1380 // Validity checks
1381 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1382 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1383 {
1384 return VOS_STATUS_E_FAILURE;
1385 }
1386 // Skip past the EID byte and length byte - and four byte WiFi OUI
1387 pRsnIe = gen_ie + 2 + 4;
1388 RSNIeLen = gen_ie_len - (2 + 4);
1389 // Unpack the WPA IE
1390 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1391 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1392 pRsnIe,
1393 RSNIeLen,
1394 &dot11WPAIE);
1395 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001396 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001397 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001398 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001399 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 //dot11WPAIE.auth_suite_count
1401 // Just translate the FIRST one
1402 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1403 //dot11WPAIE.unicast_cipher_count
1404 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1405 //dot11WPAIE.unicast_cipher_count
1406 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001407 *pMFPCapable = VOS_FALSE;
1408 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 }
1410 else
1411 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001412 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 return VOS_STATUS_E_FAILURE;
1414 }
1415 return VOS_STATUS_SUCCESS;
1416}
Leo Chang614d2072013-08-22 14:59:44 -07001417
Leo Chang0b0e45a2013-12-15 15:18:55 -08001418#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001419
1420/*==========================================================================
1421 FUNCTION sapUpdateUnsafeChannelList
1422
1423 DESCRIPTION
1424 Function Undate unsafe channel list table
1425
1426 DEPENDENCIES
1427 NA.
1428
1429 PARAMETERS
1430
1431 IN
1432 pSapCtx : SAP context pointer, include unsafe channel list
1433
1434 RETURN VALUE
1435 NONE
1436============================================================================*/
1437void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1438 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1439{
1440 v_U16_t i, j;
1441
1442 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1443 sizeof(pHddCtx->unsafeChannelList));
1444 if (0 == unsafeChannelCount)
1445 {
1446 pHddCtx->unsafeChannelCount = 0;
1447 }
1448 else
1449 {
c_hpothu8de53e42014-08-22 15:00:37 +05301450 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1451 {
1452 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1453 FL("unsafeChannelCount%hd greater than %d"),
1454 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1455 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1456 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001457 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1458 unsafeChannelList,
1459 unsafeChannelCount * sizeof(tANI_U16));
1460 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1461 }
1462
1463 /* Flush, default set all channel safe */
1464 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1465 {
1466 safeChannels[i].isSafe = VOS_TRUE;
1467 }
1468
1469 /* Try to find unsafe channel */
1470 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1471 {
1472 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1473 {
1474 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1475 {
1476 /* Found unsafe channel, update it */
1477 safeChannels[j].isSafe = VOS_FALSE;
1478 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1479 "%s : CH %d is not safe",
1480 __func__, pHddCtx->unsafeChannelList[i]);
1481 break;
1482 }
1483 }
1484 }
1485
1486 return;
1487}
1488
1489/**---------------------------------------------------------------------------
1490
1491 \brief hdd_hostapd_ch_avoid_cb() -
1492
1493 Avoid channel notification from FW handler.
1494 FW will send un-safe channle list to avoid overwrapping.
1495 hostapd should not use notified channel
1496
1497 \param - pAdapter HDD adapter pointer
1498 indParam channel avoid notification parameter
1499
1500 \return - None
1501
1502 --------------------------------------------------------------------------*/
1503void hdd_hostapd_ch_avoid_cb
1504(
1505 void *pAdapter,
1506 void *indParam
1507)
1508{
1509 hdd_adapter_t *pHostapdAdapter = NULL;
1510 hdd_context_t *hddCtxt;
1511 tSirChAvoidIndType *chAvoidInd;
1512 v_U8_t rangeLoop;
1513 v_U16_t channelLoop;
1514 v_U16_t dupCheck;
1515 v_U16_t startChannel;
1516 v_U16_t endChannel;
1517 v_U16_t unsafeChannelCount = 0;
1518 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1519 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001520 tHddAvoidFreqList hddAvoidFreqList;
1521 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301522#ifdef WLAN_FEATURE_AP_HT40_24G
1523 ptSapContext pSapCtx = NULL;
1524 tHalHandle hHal;
1525 v_U8_t cbMode;
1526 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1527 v_U32_t delay;
1528#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001529
1530 /* Basic sanity */
1531 if ((NULL == pAdapter) || (NULL == indParam))
1532 {
1533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1534 "%s : Invalid arguments", __func__);
1535 return;
1536 }
1537
1538 hddCtxt = (hdd_context_t *)pAdapter;
1539 chAvoidInd = (tSirChAvoidIndType *)indParam;
1540 pVosContext = hddCtxt->pvosContext;
1541
1542 /* Make unsafe channel list */
1543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1544 "%s : band count %d",
1545 __func__, chAvoidInd->avoidRangeCount);
1546 vos_mem_zero((void *)unsafeChannelList,
1547 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1548 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1549 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301550 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1551 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1552 break;
1553 }
1554 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001555 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301556 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001557 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1559 "%s : start %d : %d, end %d : %d",
1560 __func__,
1561 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1562 startChannel,
1563 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1564 endChannel);
1565 for (channelLoop = startChannel;
1566 channelLoop < (endChannel + 1);
1567 channelLoop++)
1568 {
1569 /* Channel duplicate check routine */
1570 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1571 {
1572 if (unsafeChannelList[dupCheck] == channelLoop)
1573 {
1574 /* This channel is duplicated */
1575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1576 "%s : found duplicated channel %d",
1577 __func__, channelLoop);
1578 break;
1579 }
1580 }
1581 if (dupCheck == unsafeChannelCount)
1582 {
c_hpothu8de53e42014-08-22 15:00:37 +05301583 int ii;
1584 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1585 {
1586 if (channelLoop == safeChannels[ii].channelNumber)
1587 {
1588 unsafeChannelList[unsafeChannelCount] = channelLoop;
1589 unsafeChannelCount++;
1590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1591 "%s : unsafe channel %d, count %d",
1592 __func__,
1593 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301594 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1595 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1596 break;
1597 }
c_hpothu8de53e42014-08-22 15:00:37 +05301598 }
1599 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001600 }
1601 else
1602 {
1603 /* DUP, do nothing */
1604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1605 "%s : duplicated channel %d",
1606 __func__, channelLoop);
1607 }
1608 }
1609 }
1610 /* Update unsafe channel cache
1611 * WCN Platform Driver cache */
1612 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1613 unsafeChannelCount);
1614
1615 /* Store into local cache
1616 * Start with STA and later start SAP
1617 * in this scenario, local cache will be used */
1618 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1619 unsafeChannelList,
1620 unsafeChannelCount);
1621
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001622 /* generate vendor specific event */
1623 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1624 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1625 {
1626 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1627 chAvoidInd->avoidFreqRange[i].startFreq;
1628 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1629 chAvoidInd->avoidFreqRange[i].endFreq;
1630 }
1631 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1632
1633 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1634
Leo Chang0b0e45a2013-12-15 15:18:55 -08001635 /* Get SAP context first
1636 * SAP and P2PGO would not concurrent */
1637 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301638#ifdef WLAN_FEATURE_AP_HT40_24G
1639 if (NULL == pHostapdAdapter)
1640 {
1641 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1642 }
1643#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301644 if ((pHostapdAdapter) &&
1645 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1646 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001647 {
1648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1649 "%s : Current operation channel %d",
1650 __func__,
1651 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1652 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1653 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301654 if ((unsafeChannelList[channelLoop] ==
1655 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1656 {
1657 if ((AUTO_CHANNEL_SELECT ==
1658 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1659 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1660 {
1661 /* current operating channel is un-safe channel
1662 * restart driver */
1663 hdd_hostapd_stop(pHostapdAdapter->dev);
1664 /* On LE, this event is handled by wlan-services to
1665 * restart SAP. On android, this event would be
1666 * ignored.
1667 */
1668 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1669 NULL, 0);
1670 }
1671 return;
1672 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001673 }
1674 }
1675
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301676#ifdef WLAN_FEATURE_AP_HT40_24G
1677 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1678 {
1679 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1680
1681 if(pSapCtx == NULL)
1682 {
1683 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1684 FL("psapCtx is NULL"));
1685 return;
1686 }
1687
1688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1689 FL("SAP Secondary channel: %d "),
1690 pSapCtx->sap_sec_chan);
1691
1692 /* tHalHandle */
1693 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1694
1695 if (NULL == hHal)
1696 {
1697 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1698 FL("In invalid hHal"));
1699 return;
1700 }
1701
1702 cbMode = sme_GetChannelBondingMode24G(hHal);
1703
1704 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1705 FL("Selected Channel bonding : %d"), cbMode);
1706
1707 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1708 {
1709 int i;
1710 eHalStatus halStatus;
1711
1712 for (i = 0; i < unsafeChannelCount; i++)
1713 {
1714 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1715 {
1716 /* Current SAP Secondary channel is un-safe channel */
1717 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1718 FL("Move SAP from HT40 to HT20"));
1719
1720 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1721 PHY_SINGLE_CHANNEL_CENTERED);
1722
1723 if (halStatus == eHAL_STATUS_FAILURE)
1724 {
1725 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1726 FL("Failed to change HT20/40 mode"));
1727 return;
1728 }
1729
1730 /* Disable Channel Bonding for 2.4GHz */
1731 sme_UpdateChannelBondingMode24G(hHal,
1732 PHY_SINGLE_CHANNEL_CENTERED);
1733 return;
1734 }
1735 }
1736 }
1737
1738 if ((!pSapCtx->numHT40IntoSta)
1739 && (pHostapdAdapter)
1740 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1741 {
1742 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1743 * are Safe then start HT20/40 timer to Move SAP from HT20
1744 * to HT40.
1745 */
1746 if (((!unsafeChannelCount)
1747 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1748 {
1749 /* Stop Previous Running HT20/40 Timer & Start timer
1750 with (OBSS TransitionDelayFactor * obss interval)
1751 delay after time out move AP from HT20 -> HT40
1752 mode
1753 */
1754 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1755 {
1756 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1757 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1758 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1759 FL("Failed to Stop HT20/40 timer"));
1760 }
1761
1762 delay =
1763 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1764
1765 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1766 FL("Start HT20/40 transition timer (%d sec)"), delay);
1767
1768 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1769 (delay * 1000));
1770
1771 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1772 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1773 FL("Failed to Start HT20/40 timer"));
1774 }
1775 else
1776 {
1777 /* Stop HT20/40 Timer */
1778 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1779 {
1780 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1781 FL("Stop HT20/40 transition timer"));
1782 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1783 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1784 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1785 FL("Failed to Stop HT20/40 timer"));
1786 }
1787 }
1788 }
1789 }
1790#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001791 return;
1792}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001793#endif /* FEATURE_WLAN_CH_AVOID */
1794
Jeff Johnson295189b2012-06-20 16:38:30 -07001795int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301796static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 struct iw_request_info *info,
1798 union iwreq_data *wrqu, char *extra)
1799{
1800 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001801 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301802 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 int *value = (int *)extra;
1804 int sub_cmd = value[0];
1805 int set_value = value[1];
1806 eHalStatus status;
1807 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001808 v_CONTEXT_t pVosContext;
1809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301810 ENTER();
1811
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301812 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001813 {
1814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301815 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001816 __func__);
1817 return -1;
1818 }
1819
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301820 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1821 ret = wlan_hdd_validate_context(pHddCtx);
1822 if (0 != ret)
1823 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301824 return -1;
1825 }
1826
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001827 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1828 if (!hHal)
1829 {
1830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1831 "%s: Hal ctx is null", __func__);
1832 return -1;
1833 }
1834
1835 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1836 if (!pVosContext)
1837 {
1838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1839 "%s: Vos ctx is null", __func__);
1840 return -1;
1841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001842
1843 switch(sub_cmd)
1844 {
1845
1846 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001847 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301849 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 }
1851 break;
1852
1853 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301854 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1856 {
1857 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1858 ret = -EINVAL;
1859 }
1860 else
1861 {
1862 WLANSAP_SetMode(pVosContext, set_value);
1863 }
1864 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301865
1866 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1867 if ((0 != set_value) && (1 != set_value))
1868 {
1869 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1870 ret = -EINVAL;
1871 }
1872 else
1873 {
1874 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1875 }
1876 break;
1877
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 case QCSAP_PARAM_MAX_ASSOC:
1879 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1880 {
1881 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1882 ret = -EINVAL;
1883 }
1884 else
1885 {
1886 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1887 {
1888 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1889 "Setting it to max allowed and continuing"),
1890 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1891 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1892 }
1893 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1894 set_value, NULL, eANI_BOOLEAN_FALSE);
1895 if ( status != eHAL_STATUS_SUCCESS )
1896 {
1897 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1898 status);
1899 ret = -EIO;
1900 }
1901 }
1902 break;
1903
1904 case QCSAP_PARAM_HIDE_SSID:
1905 {
1906 eHalStatus status = eHAL_STATUS_SUCCESS;
1907 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1908 if(eHAL_STATUS_SUCCESS != status)
1909 {
1910 hddLog(VOS_TRACE_LEVEL_ERROR,
1911 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001912 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 return status;
1914 }
1915 break;
1916 }
1917
Leo Chang614d2072013-08-22 14:59:44 -07001918 case QCSAP_PARAM_SET_MC_RATE:
1919 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001920 tSirRateUpdateInd *rateUpdate;
1921
1922 rateUpdate = (tSirRateUpdateInd *)
1923 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1924 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001925 {
1926 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001927 "%s: SET_MC_RATE indication alloc fail", __func__);
1928 ret = -1;
1929 break;
1930 }
1931 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1932
1933 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1934 /* Ignore unicast */
1935 rateUpdate->ucastDataRate = -1;
1936 rateUpdate->mcastDataRate24GHz = set_value;
1937 rateUpdate->mcastDataRate5GHz = set_value;
1938 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1939 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1940 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1941 if (eHAL_STATUS_SUCCESS != status)
1942 {
1943 hddLog(VOS_TRACE_LEVEL_ERROR,
1944 "%s: SET_MC_RATE failed", __func__);
1945 vos_mem_free(rateUpdate);
1946 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001947 }
1948 break;
1949 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05301950 case QCSAP_PARAM_GET_FRAME_LOGS:
1951 {
1952 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
1953 != VOS_STATUS_SUCCESS)
1954 {
1955 ret = -EINVAL;
1956 }
1957 break;
1958 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05301959 case QCSAP_PARAM_SET_PROXIMITY:
1960 {
1961 ret = wlan_hdd_set_proximity(set_value);
1962 break;
1963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 default:
1965 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1966 sub_cmd, set_value);
1967 ret = -EINVAL;
1968 break;
1969 }
1970
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301971 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 return ret;
1973}
1974
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301975int
1976static iw_softap_setparam(struct net_device *dev,
1977 struct iw_request_info *info,
1978 union iwreq_data *wrqu, char *extra)
1979{
1980 int ret;
1981
1982 vos_ssr_protect(__func__);
1983 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1984 vos_ssr_unprotect(__func__);
1985
1986 return ret;
1987}
Jeff Johnson295189b2012-06-20 16:38:30 -07001988
1989int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301990static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 struct iw_request_info *info,
1992 union iwreq_data *wrqu, char *extra)
1993{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301994 hdd_adapter_t *pHostapdAdapter;
1995 tHalHandle hHal;
1996 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 int *value = (int *)extra;
1998 int sub_cmd = value[0];
1999 eHalStatus status;
2000 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302001 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002002
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302003 ENTER();
2004
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302005 pHostapdAdapter = (netdev_priv(dev));
2006 if (NULL == pHostapdAdapter)
2007 {
2008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2009 "%s: Adapter is NULL",__func__);
2010 return -EINVAL;
2011 }
2012 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2013 ret = wlan_hdd_validate_context(pHddCtx);
2014 if (0 != ret)
2015 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302016 return ret;
2017 }
2018 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2019 if (NULL == hHal)
2020 {
2021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2022 "%s: Hal Context is NULL",__func__);
2023 return -EINVAL;
2024 }
2025 pVosContext = pHddCtx->pvosContext;
2026 if (NULL == pVosContext)
2027 {
2028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2029 "%s: pVosContext Context is NULL",__func__);
2030 return -EINVAL;
2031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 switch (sub_cmd)
2033 {
2034 case QCSAP_PARAM_MAX_ASSOC:
2035 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2036 if (eHAL_STATUS_SUCCESS != status)
2037 {
c_hpothuffdb5272013-10-02 16:42:35 +05302038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2039 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 ret = -EIO;
2041 }
Girish Gowli385be612014-09-18 11:17:20 +05302042
2043#ifdef WLAN_SOFTAP_VSTA_FEATURE
2044 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2045 {
2046 if (*value > VSTA_NUM_ASSOC_STA)
2047 {
2048 *value = VSTA_NUM_ASSOC_STA;
2049 }
2050 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2051 (*value > (VSTA_NUM_ASSOC_STA -
2052 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2053 {
2054 *value = (VSTA_NUM_ASSOC_STA -
2055 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2056 }
2057 }
2058 else
2059#endif
2060 {
2061 if (*value > NUM_ASSOC_STA)
2062 {
2063 *value = NUM_ASSOC_STA;
2064 }
2065 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2066 (*value > (NUM_ASSOC_STA -
2067 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2068 {
2069 *value = (NUM_ASSOC_STA -
2070 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2071 }
2072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302074
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002076 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 {
c_hpothuffdb5272013-10-02 16:42:35 +05302078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2079 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302080 ret = -EIO;
2081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 *value = 0;
2083 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302084
Jeff Johnson43971f52012-07-17 12:26:56 -07002085 case QCSAP_PARAM_GET_WLAN_DBG:
2086 {
2087 vos_trace_display();
2088 *value = 0;
2089 break;
2090 }
2091
2092 case QCSAP_PARAM_AUTO_CHANNEL:
2093 {
2094 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2095 break;
2096 }
2097
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 default:
2099 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2100 ret = -EINVAL;
2101 break;
2102
2103 }
2104
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302105 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 return ret;
2107}
2108
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302109int
2110static iw_softap_getparam(struct net_device *dev,
2111 struct iw_request_info *info,
2112 union iwreq_data *wrqu, char *extra)
2113{
2114 int ret;
2115
2116 vos_ssr_protect(__func__);
2117 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2118 vos_ssr_unprotect(__func__);
2119
2120 return ret;
2121}
Jeff Johnson295189b2012-06-20 16:38:30 -07002122/* Usage:
2123 BLACK_LIST = 0
2124 WHITE_LIST = 1
2125 ADD MAC = 0
2126 REMOVE MAC = 1
2127
2128 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2129 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2130 while using this ioctl
2131
2132 Syntax:
2133 iwpriv softap.0 modify_acl
2134 <6 octet mac addr> <list type> <cmd type>
2135
2136 Examples:
2137 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2138 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2139 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2140 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2141*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302142int __iw_softap_modify_acl(struct net_device *dev,
2143 struct iw_request_info *info,
2144 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002145{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302146 hdd_adapter_t *pHostapdAdapter;
2147 v_CONTEXT_t pVosContext;
2148 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 v_BYTE_t *value = (v_BYTE_t*)extra;
2150 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2151 int listType, cmd, i;
2152 int ret = 0; /* success */
2153
2154 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302155 pHostapdAdapter = (netdev_priv(dev));
2156 if (NULL == pHostapdAdapter)
2157 {
2158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2159 "%s: Adapter is NULL",__func__);
2160 return -EINVAL;
2161 }
2162 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2163 ret = wlan_hdd_validate_context(pHddCtx);
2164 if (0 != ret)
2165 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302166 return ret;
2167 }
2168 pVosContext = pHddCtx->pvosContext;
2169 if (NULL == pVosContext)
2170 {
2171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2172 "%s: Vos Context is NULL",__func__);
2173 return -EINVAL;
2174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2176 {
2177 pPeerStaMac[i] = *(value+i);
2178 }
2179 listType = (int)(*(value+i));
2180 i++;
2181 cmd = (int)(*(value+i));
2182
Arif Hussain24bafea2013-11-15 15:10:03 -08002183 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2184 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002185
2186 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2187 != VOS_STATUS_SUCCESS)
2188 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002189 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 ret = -EIO;
2191 }
2192 EXIT();
2193 return ret;
2194}
2195
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302196int iw_softap_modify_acl(struct net_device *dev,
2197 struct iw_request_info *info,
2198 union iwreq_data *wrqu, char *extra)
2199{
2200 int ret;
2201
2202 vos_ssr_protect(__func__);
2203 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2204 vos_ssr_unprotect(__func__);
2205
2206 return ret;
2207}
2208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302210static __iw_softap_getchannel(struct net_device *dev,
2211 struct iw_request_info *info,
2212 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002213{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302214 hdd_adapter_t *pHostapdAdapter;
2215 hdd_context_t *pHddCtx;
2216 int ret = 0;
2217 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302218
2219 ENTER();
2220
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302221 pHostapdAdapter = (netdev_priv(dev));
2222 if (NULL == pHostapdAdapter)
2223 {
2224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2225 "%s: Adapter is NULL",__func__);
2226 return -EINVAL;
2227 }
2228 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2229 ret = wlan_hdd_validate_context(pHddCtx);
2230 if (0 != ret)
2231 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302232 return ret;
2233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002234
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302235 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002236
Jeff Johnson43971f52012-07-17 12:26:56 -07002237 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302238
2239 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 return 0;
2241}
2242
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302243
Jeff Johnsone7245742012-09-05 17:12:55 -07002244int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302245static iw_softap_getchannel(struct net_device *dev,
2246 struct iw_request_info *info,
2247 union iwreq_data *wrqu, char *extra)
2248{
2249 int ret;
2250
2251 vos_ssr_protect(__func__);
2252 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2253 vos_ssr_unprotect(__func__);
2254
2255 return ret;
2256}
2257
2258int
2259static __iw_softap_set_max_tx_power(struct net_device *dev,
2260 struct iw_request_info *info,
2261 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002262{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302263 hdd_adapter_t *pHostapdAdapter;
2264 tHalHandle hHal;
2265 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002266 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302267 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002268 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2269 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2270
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302271 ENTER();
2272
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302273 pHostapdAdapter = (netdev_priv(dev));
2274 if (NULL == pHostapdAdapter)
2275 {
2276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2277 "%s: Adapter is NULL",__func__);
2278 return -EINVAL;
2279 }
2280 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2281 ret = wlan_hdd_validate_context(pHddCtx);
2282 if (0 != ret)
2283 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302284 return ret;
2285 }
2286 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2287 if (NULL == hHal)
2288 {
2289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2290 "%s: Hal Context is NULL",__func__);
2291 return -EINVAL;
2292 }
schang86c22c42013-03-13 18:41:24 -07002293 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002294 return -ENOMEM;
2295
Leo Changd37675a2013-08-01 13:19:45 -07002296 /* Assign correct slef MAC address */
2297 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2298 VOS_MAC_ADDR_SIZE);
2299 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2300 VOS_MAC_ADDR_SIZE);
2301
schang86c22c42013-03-13 18:41:24 -07002302 set_value = value[0];
2303 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2304 {
2305 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002306 __func__);
schang86c22c42013-03-13 18:41:24 -07002307 return -EIO;
2308 }
2309
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302310 EXIT();
schang86c22c42013-03-13 18:41:24 -07002311 return 0;
2312}
2313
2314int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302315static iw_softap_set_max_tx_power(struct net_device *dev,
2316 struct iw_request_info *info,
2317 union iwreq_data *wrqu, char *extra)
2318{
2319 int ret;
2320
2321 vos_ssr_protect(__func__);
2322 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2323 vos_ssr_unprotect(__func__);
2324
2325 return ret;
2326}
2327
2328
2329int
2330static __iw_display_data_path_snapshot(struct net_device *dev,
2331 struct iw_request_info *info,
2332 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302333{
2334
2335 /* Function intitiating dumping states of
2336 * HDD(WMM Tx Queues)
2337 * TL State (with Per Client infor)
2338 * DXE Snapshot (Called at the end of TL Snapshot)
2339 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302340 hdd_adapter_t *pHostapdAdapter;
2341 hdd_context_t *pHddCtx;
2342 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302343
2344 ENTER();
2345
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 pHostapdAdapter = (netdev_priv(dev));
2347 if (NULL == pHostapdAdapter)
2348 {
2349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2350 "%s: Adapter is NULL",__func__);
2351 return -EINVAL;
2352 }
2353 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2354 ret = wlan_hdd_validate_context(pHddCtx);
2355 if (0 != ret)
2356 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302357 return ret;
2358 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302359 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302360 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302361
2362 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302363 return 0;
2364}
2365
2366int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302367static iw_display_data_path_snapshot(struct net_device *dev,
2368 struct iw_request_info *info,
2369 union iwreq_data *wrqu, char *extra)
2370{
2371 int ret;
2372
2373 vos_ssr_protect(__func__);
2374 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2375 vos_ssr_unprotect(__func__);
2376
2377 return ret;
2378}
2379
2380int
2381static __iw_softap_set_tx_power(struct net_device *dev,
2382 struct iw_request_info *info,
2383 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002384{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302385 hdd_adapter_t *pHostapdAdapter;
2386 hdd_context_t *pHddCtx;
2387 v_CONTEXT_t pVosContext;
2388 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002389 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302390 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002391 ptSapContext pSapCtx = NULL;
2392
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302393 ENTER();
2394
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302395 pHostapdAdapter = (netdev_priv(dev));
2396 if (NULL == pHostapdAdapter)
2397 {
2398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2399 "%s: Adapter is NULL",__func__);
2400 return -EINVAL;
2401 }
2402 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2403 ret = wlan_hdd_validate_context(pHddCtx);
2404 if (0 != ret)
2405 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302406 return ret;
2407 }
2408 pVosContext = pHddCtx->pvosContext;
2409 if (NULL == pVosContext)
2410 {
2411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2412 "%s: Vos Context is NULL",__func__);
2413 return -EINVAL;
2414 }
2415 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2416 if (NULL == hHal)
2417 {
2418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2419 "%s: Hal Context is NULL",__func__);
2420 return -EINVAL;
2421 }
schang86c22c42013-03-13 18:41:24 -07002422 if (NULL == value)
2423 return -ENOMEM;
2424
2425 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2426 if (NULL == pSapCtx)
2427 {
2428 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2429 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2430 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002431 }
2432
2433 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002434 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002435 {
schang86c22c42013-03-13 18:41:24 -07002436 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002437 __func__);
2438 return -EIO;
2439 }
2440
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302441 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002442 return 0;
2443}
2444
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302445int
2446static iw_softap_set_tx_power(struct net_device *dev,
2447 struct iw_request_info *info,
2448 union iwreq_data *wrqu, char *extra)
2449{
2450 int ret;
2451
2452 vos_ssr_protect(__func__);
2453 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2454 vos_ssr_unprotect(__func__);
2455
2456 return ret;
2457}
2458
Kiet Lambcf38522013-10-26 18:28:27 +05302459/**---------------------------------------------------------------------------
2460
2461 \brief iw_softap_set_trafficmonitor() -
2462 This function dynamically enable/disable traffic monitor functonality
2463 the command iwpriv wlanX setTrafficMon <value>.
2464
2465 \param - dev - Pointer to the net device.
2466 - addr - Pointer to the sockaddr.
2467 \return - 0 for success, non zero for failure
2468
2469 --------------------------------------------------------------------------*/
2470
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302471static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2472 struct iw_request_info *info,
2473 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302474{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302475 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302476 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302477 hdd_context_t *pHddCtx;
2478 int status;
2479
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302480 ENTER();
2481
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302482 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302483 if (NULL == pAdapter)
2484 {
2485 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2486 "%s: HDD adapter is Null", __func__);
2487 return -ENODEV;
2488 }
2489
2490 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2491
2492 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302493 if (0 != status)
2494 {
Kiet Lambcf38522013-10-26 18:28:27 +05302495 return status;
2496 }
2497
2498 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2499
2500 if (NULL == isSetTrafficMon)
2501 {
2502 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2503 "%s: Invalid SAP pointer from extra", __func__);
2504 return -ENOMEM;
2505 }
2506
2507 if (TRUE == *isSetTrafficMon)
2508 {
2509 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2510 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2511 {
2512 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2513 "%s: failed to Start Traffic Monitor timer ", __func__ );
2514 return -EIO;
2515 }
2516 }
2517 else if (FALSE == *isSetTrafficMon)
2518 {
2519 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2520 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2521 {
2522 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2523 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2524 return -EIO;
2525 }
2526
2527 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302528
2529 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302530 return 0;
2531}
2532
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302533static int iw_softap_set_trafficmonitor(struct net_device *dev,
2534 struct iw_request_info *info,
2535 union iwreq_data *wrqu, char *extra)
2536{
2537 int ret;
2538
2539 vos_ssr_protect(__func__);
2540 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2541 vos_ssr_unprotect(__func__);
2542
2543 return ret;
2544}
2545
Jeff Johnson295189b2012-06-20 16:38:30 -07002546#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2547
2548int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302549static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2550 struct iw_request_info *info,
2551 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002552{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302553 hdd_adapter_t *pHostapdAdapter;
2554 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302555 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002556 char *buf;
2557 int cnt = 0;
2558 int left;
2559 int ret = 0;
2560 /* maclist_index must be u32 to match userspace */
2561 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302562 v_CONTEXT_t pVosContext = NULL;
2563 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302564
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302565 ENTER();
2566
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302567 pHostapdAdapter = (netdev_priv(dev));
2568 if (NULL == pHostapdAdapter)
2569 {
2570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2571 "%s: Adapter is NULL",__func__);
2572 return -EINVAL;
2573 }
2574 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2575 ret = wlan_hdd_validate_context(pHddCtx);
2576 if (0 != ret)
2577 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302578 return ret;
2579 }
2580
Jeff Johnson224f3702014-03-26 11:09:47 -07002581 /*
2582 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2583 * number, and even numbered iocts are supposed to have "set"
2584 * semantics. Hence the wireless extensions support in the kernel
2585 * won't correctly copy the result to userspace, so the ioctl
2586 * handler itself must copy the data. Output format is 32-bit
2587 * record length, followed by 0 or more 6-byte STA MAC addresses.
2588 *
2589 * Further note that due to the incorrect semantics, the "iwpriv"
2590 * userspace application is unable to correctly invoke this API,
2591 * hence it is not registered in the hostapd_private_args. This
2592 * API can only be invoked by directly invoking the ioctl() system
2593 * call.
2594 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002595
Jeff Johnson224f3702014-03-26 11:09:47 -07002596 /* make sure userspace allocated a reasonable buffer size */
2597 if (wrqu->data.length < sizeof(maclist_index)) {
2598 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2599 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002601
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302602 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2603 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2604 if(pSapCtx == NULL){
2605 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2606 FL("psapCtx is NULL"));
2607 return -EFAULT;
2608 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302609
2610 /* allocate local buffer to build the response */
2611 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2612 if (!buf) {
2613 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2614 return -ENOMEM;
2615 }
2616
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302617 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002618 /* start indexing beyond where the record count will be written */
2619 maclist_index = sizeof(maclist_index);
2620 left = wrqu->data.length - maclist_index;
2621
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302622 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002623 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2624 if ((pStaInfo[cnt].isUsed) &&
2625 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2626 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2627 VOS_MAC_ADDR_SIZE);
2628 maclist_index += VOS_MAC_ADDR_SIZE;
2629 left -= VOS_MAC_ADDR_SIZE;
2630 }
2631 cnt++;
2632 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302633 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002634
2635 *((u32 *)buf) = maclist_index;
2636 wrqu->data.length = maclist_index;
2637 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2638 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2639 ret = -EFAULT;
2640 }
2641 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302642
2643 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002644 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645}
2646
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302647int
2648static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2649 struct iw_request_info *info,
2650 union iwreq_data *wrqu, char *extra)
2651{
2652 int ret;
2653
2654 vos_ssr_protect(__func__);
2655 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2656 vos_ssr_unprotect(__func__);
2657
2658 return ret;
2659}
2660
Jeff Johnson295189b2012-06-20 16:38:30 -07002661/* Usage:
2662 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2663 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2664 while using this ioctl
2665
2666 Syntax:
2667 iwpriv softap.0 disassoc_sta <6 octet mac address>
2668
2669 e.g.
2670 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2671 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2672*/
2673
2674int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302675static __iw_softap_disassoc_sta(struct net_device *dev,
2676 struct iw_request_info *info,
2677 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002678{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302679 hdd_adapter_t *pHostapdAdapter;
2680 hdd_context_t *pHddCtx;
2681 v_U8_t *peerMacAddr;
2682 int ret = 0;
2683
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302685
2686 if (!capable(CAP_NET_ADMIN)) {
2687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2688 FL("permission check failed"));
2689 return -EPERM;
2690 }
2691
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302692 pHostapdAdapter = (netdev_priv(dev));
2693 if (NULL == pHostapdAdapter)
2694 {
2695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2696 "%s: Adapter is NULL",__func__);
2697 return -EINVAL;
2698 }
2699 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2700 ret = wlan_hdd_validate_context(pHddCtx);
2701 if (0 != ret)
2702 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302703 return ret;
2704 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302705 /* iwpriv tool or framework calls this ioctl with
2706 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302708 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002709
Arif Hussain24bafea2013-11-15 15:10:03 -08002710 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2711 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2713 EXIT();
2714 return 0;
2715}
2716
2717int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302718static iw_softap_disassoc_sta(struct net_device *dev,
2719 struct iw_request_info *info,
2720 union iwreq_data *wrqu, char *extra)
2721{
2722 int ret;
2723
2724 vos_ssr_protect(__func__);
2725 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2726 vos_ssr_unprotect(__func__);
2727
2728 return ret;
2729}
2730
2731int
2732static __iw_softap_ap_stats(struct net_device *dev,
2733 struct iw_request_info *info,
2734 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002735{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302736 hdd_adapter_t *pHostapdAdapter;
2737 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 WLANTL_TRANSFER_STA_TYPE statBuffer;
2739 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302742 ENTER();
2743
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302744 pHostapdAdapter = (netdev_priv(dev));
2745 if (NULL == pHostapdAdapter)
2746 {
2747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2748 "%s: Adapter is NULL",__func__);
2749 return -EINVAL;
2750 }
2751 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2752 ret = wlan_hdd_validate_context(pHddCtx);
2753 if (0 != ret)
2754 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302755 return ret;
2756 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002757 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002758 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2759 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002760
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302761 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002762 if(NULL == pstatbuf) {
2763 hddLog(LOG1, "unable to allocate memory");
2764 return -ENOMEM;
2765 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302766
2767 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002768 "RUF=%d RMF=%d RBF=%d "
2769 "RUB=%d RMB=%d RBB=%d "
2770 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302771 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002772 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2773 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2774 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2775 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2776 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2777 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002778
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302779 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002780 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2781 kfree(pstatbuf);
2782 return -EFAULT;
2783 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302784
2785 strlcpy(extra, pstatbuf, len);
2786 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002787 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302788
2789 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 return 0;
2791}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302792int
2793static __iw_softap_ap_get_stats(struct net_device *dev,
2794 struct iw_request_info *info,
2795 union iwreq_data *wrqu, char *extra)
2796{
2797 hdd_adapter_t *pAdapter;
2798 hdd_tx_rx_stats_t *pStats;
2799
2800 ENTER();
2801 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2802 if (NULL == pAdapter)
2803 {
2804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2805 "%s: Adapter is NULL",__func__);
2806 return -EINVAL;
2807 }
2808
2809 pStats = &pAdapter->hdd_stats.hddTxRxStats;
2810 snprintf(extra, QCSAP_MAX_STR_LEN,
2811 "\nTransmit"
2812 "\ncalled %u, dropped %u, backpressured %u, queued %u"
2813 "\n dropped BK %u, BE %u, VI %u, VO %u"
2814 "\n classified BK %u, BE %u, VI %u, VO %u"
2815 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
2816 "\n queued BK %u, BE %u, VI %u, VO %u"
2817 "\nfetched %u, empty %u, lowres %u, deqerr %u"
2818 "\ndequeued %u, depressured %u, deque-depressured %u,\
2819 completed %u, flushed %u"
2820 "\n fetched BK %u, BE %u, VI %u, VO %u"
2821 "\n dequeued BK %u, BE %u, VI %u, VO %u"
2822 "\n depressured BK %u, BE %u, VI %u, VO %u"
2823 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
2824 "\n flushed BK %u, BE %u, VI %u, VO %u"
2825 "\n\nReceive"
2826 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
2827 "\n\nResetsStats"
2828 "\n",
2829 pStats->txXmitCalled,
2830 pStats->txXmitDropped,
2831 pStats->txXmitBackPressured,
2832 pStats->txXmitQueued,
2833
2834 pStats->txXmitDroppedAC[WLANTL_AC_BK],
2835 pStats->txXmitDroppedAC[WLANTL_AC_BE],
2836 pStats->txXmitDroppedAC[WLANTL_AC_VI],
2837 pStats->txXmitDroppedAC[WLANTL_AC_VO],
2838
2839 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
2840 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
2841 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
2842 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
2843
2844 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
2845 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
2846 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
2847 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
2848
2849 pStats->txXmitQueuedAC[WLANTL_AC_BK],
2850 pStats->txXmitQueuedAC[WLANTL_AC_BE],
2851 pStats->txXmitQueuedAC[WLANTL_AC_VI],
2852 pStats->txXmitQueuedAC[WLANTL_AC_VO],
2853
2854 pStats->txFetched,
2855 pStats->txFetchEmpty,
2856 pStats->txFetchLowResources,
2857 pStats->txFetchDequeueError,
2858
2859 pStats->txFetchDequeued,
2860 pStats->txFetchDePressured,
2861 pStats->txDequeDePressured,
2862 pStats->txCompleted,
2863 pStats->txFlushed,
2864
2865 pStats->txFetchedAC[WLANTL_AC_BK],
2866 pStats->txFetchedAC[WLANTL_AC_BE],
2867 pStats->txFetchedAC[WLANTL_AC_VI],
2868 pStats->txFetchedAC[WLANTL_AC_VO],
2869
2870 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
2871 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
2872 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
2873 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
2874
2875 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
2876 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
2877 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
2878 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
2879
2880 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
2881 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
2882 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
2883 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
2884
2885 pStats->txFlushedAC[WLANTL_AC_BK],
2886 pStats->txFlushedAC[WLANTL_AC_BE],
2887 pStats->txFlushedAC[WLANTL_AC_VI],
2888 pStats->txFlushedAC[WLANTL_AC_VO],
2889
2890 pStats->rxChains,
2891 pStats->rxPackets,
2892 pStats->rxDropped,
2893 pStats->rxDelivered,
2894 pStats->rxRefused
2895 );
2896
2897 wrqu->data.length = strlen(extra) + 1;
2898
2899 return 0;
2900}
2901
2902int
2903static __iw_softap_ap_clear_stats(struct net_device *dev,
2904 struct iw_request_info *info,
2905 union iwreq_data *wrqu, char *extra)
2906{
2907 hdd_adapter_t *pAdapter;
2908
2909 ENTER();
2910
2911 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2912 if (NULL == pAdapter)
2913 {
2914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2915 "%s: Adapter is NULL",__func__);
2916 return -EINVAL;
2917 }
2918
2919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
2920 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
2921 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
2922 return 0;
2923}
2924
2925
2926int
2927static iw_softap_get_stats(struct net_device *dev,
2928 struct iw_request_info *info,
2929 union iwreq_data *wrqu, char *extra)
2930{
2931 int ret;
2932 vos_ssr_protect(__func__);
2933 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
2934 vos_ssr_unprotect(__func__);
2935 return ret;
2936}
2937
2938int
2939static iw_softap_clear_stats(struct net_device *dev,
2940 struct iw_request_info *info,
2941 union iwreq_data *wrqu, char *extra)
2942{
2943 int ret;
2944 vos_ssr_protect(__func__);
2945 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
2946 vos_ssr_unprotect(__func__);
2947 return ret;
2948}
Jeff Johnson295189b2012-06-20 16:38:30 -07002949
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302950int
2951static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 struct iw_request_info *info,
2953 union iwreq_data *wrqu, char *extra)
2954{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302955 int ret;
2956
2957 vos_ssr_protect(__func__);
2958 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2959 vos_ssr_unprotect(__func__);
2960
2961 return ret;
2962}
2963
2964static int __iw_softap_set_channel_range(struct net_device *dev,
2965 struct iw_request_info *info,
2966 union iwreq_data *wrqu, char *extra)
2967{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302968 hdd_adapter_t *pHostapdAdapter;
2969 tHalHandle hHal;
2970 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 int *value = (int *)extra;
2972 int startChannel = value[0];
2973 int endChannel = value[1];
2974 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002975 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 int ret = 0; /* success */
2977
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302978 ENTER();
2979
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05302980 if (!capable(CAP_NET_ADMIN))
2981 {
2982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2983 FL("permission check failed"));
2984 return -EPERM;
2985 }
2986
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302987 pHostapdAdapter = (netdev_priv(dev));
2988 if (NULL == pHostapdAdapter)
2989 {
2990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2991 "%s: Adapter is NULL",__func__);
2992 return -EINVAL;
2993 }
2994 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2995 ret = wlan_hdd_validate_context(pHddCtx);
2996 if (0 != ret)
2997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302998 return ret;
2999 }
3000 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3001 if (NULL == hHal)
3002 {
3003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3004 "%s: Hal Context is NULL",__func__);
3005 return -EINVAL;
3006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3008 if(status != VOS_STATUS_SUCCESS)
3009 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003010 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 startChannel,endChannel, band);
3012 ret = -EINVAL;
3013 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003014
3015 pHddCtx->is_dynamic_channel_range_set = 1;
3016
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303017 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 return ret;
3019}
3020
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303021static int iw_softap_set_channel_range(struct net_device *dev,
3022 struct iw_request_info *info,
3023 union iwreq_data *wrqu, char *extra)
3024{
3025 int ret;
3026
3027 vos_ssr_protect(__func__);
3028 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3029 vos_ssr_unprotect(__func__);
3030
3031 return ret;
3032}
3033
3034
3035int __iw_softap_get_channel_list(struct net_device *dev,
3036 struct iw_request_info *info,
3037 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003038{
3039 v_U32_t num_channels = 0;
3040 v_U8_t i = 0;
3041 v_U8_t bandStartChannel = RF_CHAN_1;
3042 v_U8_t bandEndChannel = RF_CHAN_165;
3043 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303044 hdd_adapter_t *pHostapdAdapter;
3045 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003048 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303049 hdd_context_t *pHddCtx;
3050 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303051
3052 ENTER();
3053
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303054 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3055 if (NULL == pHostapdAdapter)
3056 {
3057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3058 "%s: Adapter is NULL",__func__);
3059 return -EINVAL;
3060 }
3061 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3062 ret = wlan_hdd_validate_context(pHddCtx);
3063 if (0 != ret)
3064 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303065 return ret;
3066 }
3067 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3068 if (NULL == hHal)
3069 {
3070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3071 "%s: Hal Context is NULL",__func__);
3072 return -EINVAL;
3073 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003074 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3075 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003076 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003077 return -EIO;
3078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 wrqu->data.length = sizeof(tChannelListInfo);
3080 ENTER();
3081
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003082 if (eCSR_BAND_24 == curBand)
3083 {
3084 bandStartChannel = RF_CHAN_1;
3085 bandEndChannel = RF_CHAN_14;
3086 }
3087 else if (eCSR_BAND_5G == curBand)
3088 {
3089 bandStartChannel = RF_CHAN_36;
3090 bandEndChannel = RF_CHAN_165;
3091 }
3092
Arif Hussain6d2a3322013-11-17 19:50:10 -08003093 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303094 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003095 bandStartChannel, bandEndChannel );
3096
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3098 {
3099 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3100 {
3101 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3102 num_channels++;
3103 }
3104 }
3105
3106 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3107
3108 temp_num_channels = num_channels;
3109
3110 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3111 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303112 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003113 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 }
3115
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303116 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3117 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 {
3119 for(i = 0; i < temp_num_channels; i++)
3120 {
3121
3122 if((channel_list->channels[i] > 35) &&
3123 (channel_list->channels[i] < 49))
3124 {
3125 vos_mem_move(&channel_list->channels[i],
3126 &channel_list->channels[i+1],
3127 temp_num_channels - (i-1));
3128 num_channels--;
3129 temp_num_channels--;
3130 i--;
3131 }
3132 }
3133 }
3134
Arif Hussain6d2a3322013-11-17 19:50:10 -08003135 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003136
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 channel_list->num_channels = num_channels;
3138 EXIT();
3139
3140 return 0;
3141}
3142
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303143int iw_softap_get_channel_list(struct net_device *dev,
3144 struct iw_request_info *info,
3145 union iwreq_data *wrqu, char *extra)
3146{
3147 int ret;
3148
3149 vos_ssr_protect(__func__);
3150 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3151 vos_ssr_unprotect(__func__);
3152
3153 return ret;
3154}
3155
3156static
3157int __iw_get_genie(struct net_device *dev,
3158 struct iw_request_info *info,
3159 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003160{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303161 hdd_adapter_t *pHostapdAdapter;
3162 hdd_context_t *pHddCtx;
3163 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 eHalStatus status;
3165 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3166 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303167 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303168
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303170
3171 pHostapdAdapter = (netdev_priv(dev));
3172 if (NULL == pHostapdAdapter)
3173 {
3174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3175 "%s: Adapter is NULL",__func__);
3176 return -EINVAL;
3177 }
3178 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3179 ret = wlan_hdd_validate_context(pHddCtx);
3180 if (0 != ret)
3181 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303182 return ret;
3183 }
3184 pVosContext = pHddCtx->pvosContext;
3185 if (NULL == pVosContext)
3186 {
3187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3188 "%s: vos context is not valid ",__func__);
3189 return -EINVAL;
3190 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003191 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3193 status = WLANSap_getstationIE_information(pVosContext,
3194 &length,
3195 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003196 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3197 if (wrqu->data.length < length ||
3198 copy_to_user(wrqu->data.pointer,
3199 (v_VOID_t*)genIeBytes, length))
3200 {
3201 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3202 return -EFAULT;
3203 }
3204 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205
Arif Hussain6d2a3322013-11-17 19:50:10 -08003206 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003207
3208
3209 EXIT();
3210 return 0;
3211}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303212
3213static
3214int iw_get_genie(struct net_device *dev,
3215 struct iw_request_info *info,
3216 union iwreq_data *wrqu, char *extra)
3217{
3218 int ret;
3219
3220 vos_ssr_protect(__func__);
3221 ret = __iw_get_genie(dev, info, wrqu, extra);
3222 vos_ssr_unprotect(__func__);
3223
3224 return ret;
3225}
3226
3227static
3228int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3229 struct iw_request_info *info,
3230 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003231{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303232 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003233 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303234 hdd_ap_ctx_t *pHddApCtx;
3235 hdd_context_t *pHddCtx;
3236 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303237
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003239
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303240 pHostapdAdapter = (netdev_priv(dev));
3241 if (NULL == pHostapdAdapter)
3242 {
3243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3244 "%s: Adapter is NULL",__func__);
3245 return -EINVAL;
3246 }
3247 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3248 ret = wlan_hdd_validate_context(pHddCtx);
3249 if (0 != ret)
3250 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303251 return ret;
3252 }
3253 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3254 if (NULL == pHddApCtx)
3255 {
3256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3257 "%s: AP context is NULL",__func__);
3258 return -EINVAL;
3259 }
3260
Arif Hussain6d2a3322013-11-17 19:50:10 -08003261 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003262 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3263
3264 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3265 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3266 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3267 WPSPBCProbeReqIEs.probeReqIELen);
3268 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3269 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3270 sizeof(v_MACADDR_t));
3271 if (copy_to_user(wrqu->data.pointer,
3272 (void *)&WPSPBCProbeReqIEs,
3273 sizeof(WPSPBCProbeReqIEs)))
3274 {
3275 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3276 return -EFAULT;
3277 }
3278 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003279 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003280 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 up(&pHddApCtx->semWpsPBCOverlapInd);
3282 EXIT();
3283 return 0;
3284}
3285
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303286static
3287int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3288 struct iw_request_info *info,
3289 union iwreq_data *wrqu, char *extra)
3290{
3291 int ret;
3292
3293 vos_ssr_protect(__func__);
3294 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3295 vos_ssr_unprotect(__func__);
3296
3297 return ret;
3298}
3299
Jeff Johnson295189b2012-06-20 16:38:30 -07003300/**---------------------------------------------------------------------------
3301
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303302 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 This function sets the auth type received from the wpa_supplicant.
3304
3305 \param - dev - Pointer to the net device.
3306 - info - Pointer to the iw_request_info.
3307 - wrqu - Pointer to the iwreq_data.
3308 - extra - Pointer to the data.
3309 \return - 0 for success, non zero for failure
3310
3311 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303312int __iw_set_auth_hostap(struct net_device *dev,
3313 struct iw_request_info *info,
3314 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003315{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303316 hdd_adapter_t *pAdapter;
3317 hdd_context_t *pHddCtx;
3318 hdd_wext_state_t *pWextState;
3319 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303320
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303322
3323 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3324 if (NULL == pAdapter)
3325 {
3326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3327 "%s: Adapter is NULL",__func__);
3328 return -EINVAL;
3329 }
3330
3331 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3332 ret = wlan_hdd_validate_context(pHddCtx);
3333 if (0 != ret)
3334 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303335 return ret;
3336 }
3337 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3338 if (NULL == pWextState)
3339 {
3340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3341 "%s: pWextState is NULL",__func__);
3342 return -EINVAL;
3343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 switch(wrqu->param.flags & IW_AUTH_INDEX)
3345 {
3346 case IW_AUTH_TKIP_COUNTERMEASURES:
3347 {
3348 if(wrqu->param.value) {
3349 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3350 "Counter Measure started %d", wrqu->param.value);
3351 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303352 }
3353 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3355 "Counter Measure stopped=%d", wrqu->param.value);
3356 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3357 }
3358
3359 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3360 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303365
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003366 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 wrqu->param.flags & IW_AUTH_INDEX);
3368 break;
3369 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303370
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 EXIT();
3372 return 0;
3373}
3374
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303375int iw_set_auth_hostap(struct net_device *dev,
3376 struct iw_request_info *info,
3377 union iwreq_data *wrqu,char *extra)
3378{
3379 int ret;
3380
3381 vos_ssr_protect(__func__);
3382 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3383 vos_ssr_unprotect(__func__);
3384
3385 return ret;
3386}
3387
3388static int __iw_set_ap_encodeext(struct net_device *dev,
3389 struct iw_request_info *info,
3390 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003391{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303392 hdd_adapter_t *pHostapdAdapter;
3393 v_CONTEXT_t pVosContext;
3394 hdd_context_t *pHddCtx;
3395 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003396 int retval = 0;
3397 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3399 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3400 int key_index;
3401 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303402 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003403// tCsrRoamRemoveKey RemoveKey;
3404 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303405
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303406 ENTER();
3407 pHostapdAdapter = (netdev_priv(dev));
3408 if (NULL == pHostapdAdapter)
3409 {
3410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3411 "%s: Adapter is NULL",__func__);
3412 return -EINVAL;
3413 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003414
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303415 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3416 retval = wlan_hdd_validate_context(pHddCtx);
3417 if (0 != retval)
3418 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303419 return retval;
3420 }
3421 pVosContext = pHddCtx->pvosContext;
3422 if (NULL == pVosContext)
3423 {
3424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3425 "%s: pVosContext is NULL",__func__);
3426 return -EINVAL;
3427 }
3428 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3429 if (NULL == pHddApCtx)
3430 {
3431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3432 "%s: AP Context is NULL",__func__);
3433 return -EINVAL;
3434 }
3435
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303437
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 /*Convert from 1-based to 0-based keying*/
3441 key_index--;
3442 }
3443 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303444#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 /*Set the encrytion type to NONE*/
3446#if 0
3447 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3448#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 RemoveKey.keyId = key_index;
3451 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3452 /*Key direction for group is RX only*/
3453 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3454 }
3455 else {
3456 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3457 }
3458 switch(ext->alg)
3459 {
3460 case IW_ENCODE_ALG_NONE:
3461 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3462 break;
3463 case IW_ENCODE_ALG_WEP:
3464 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3465 break;
3466 case IW_ENCODE_ALG_TKIP:
3467 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 case IW_ENCODE_ALG_CCMP:
3470 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3471 break;
3472 default:
3473 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3474 break;
3475 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003476 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 -07003477 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003479 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003481 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3482 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 {
3484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003485 __LINE__, vstatus );
3486 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003488#endif
3489 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003490
Jeff Johnson43971f52012-07-17 12:26:56 -07003491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003492
3493 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3494
3495 setKey.keyId = key_index;
3496 setKey.keyLength = ext->key_len;
3497
3498 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3499 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3500 }
3501
3502 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3503 /*Key direction for group is RX only*/
3504 setKey.keyDirection = eSIR_RX_ONLY;
3505 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3506 }
3507 else {
3508
3509 setKey.keyDirection = eSIR_TX_RX;
3510 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3511 }
3512 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3513 {
3514 setKey.keyDirection = eSIR_TX_DEFAULT;
3515 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3516 }
3517
3518 /*For supplicant pae role is zero*/
3519 setKey.paeRole = 0;
3520
3521 switch(ext->alg)
3522 {
3523 case IW_ENCODE_ALG_NONE:
3524 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3525 break;
3526
3527 case IW_ENCODE_ALG_WEP:
3528 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3529 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003530 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 break;
3532
3533 case IW_ENCODE_ALG_TKIP:
3534 {
3535 v_U8_t *pKey = &setKey.Key[0];
3536
3537 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3538
3539 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3540
3541 /*Supplicant sends the 32bytes key in this order
3542
3543 |--------------|----------|----------|
3544 | Tk1 |TX-MIC | RX Mic |
3545 |--------------|----------|----------|
3546 <---16bytes---><--8bytes--><--8bytes-->
3547
3548 */
3549 /*Sme expects the 32 bytes key to be in the below order
3550
3551 |--------------|----------|----------|
3552 | Tk1 |RX-MIC | TX Mic |
3553 |--------------|----------|----------|
3554 <---16bytes---><--8bytes--><--8bytes-->
3555 */
3556 /* Copy the Temporal Key 1 (TK1) */
3557 vos_mem_copy(pKey,ext->key,16);
3558
3559 /*Copy the rx mic first*/
3560 vos_mem_copy(&pKey[16],&ext->key[24],8);
3561
3562 /*Copy the tx mic */
3563 vos_mem_copy(&pKey[24],&ext->key[16],8);
3564
3565 }
3566 break;
3567
3568 case IW_ENCODE_ALG_CCMP:
3569 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3570 break;
3571
3572 default:
3573 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3574 break;
3575 }
3576
3577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303578 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 setKey.keyId);
3580 for(i=0; i< ext->key_len; i++)
3581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3582 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003583
3584 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3585 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 {
3587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003588 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3589 retval = -EINVAL;
3590 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303591
3592 EXIT();
3593 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003594}
Jeff Johnson43971f52012-07-17 12:26:56 -07003595
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303596static int iw_set_ap_encodeext(struct net_device *dev,
3597 struct iw_request_info *info,
3598 union iwreq_data *wrqu, char *extra)
3599{
3600 int ret;
3601
3602 vos_ssr_protect(__func__);
3603 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3604 vos_ssr_unprotect(__func__);
3605
3606 return ret;
3607}
Jeff Johnson43971f52012-07-17 12:26:56 -07003608
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303609static int __iw_set_ap_mlme(struct net_device *dev,
3610 struct iw_request_info *info,
3611 union iwreq_data *wrqu,
3612 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003613{
3614#if 0
3615 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3616 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3617
3618 ENTER();
3619
3620 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3621 switch (mlme->cmd) {
3622 case IW_MLME_DISASSOC:
3623 case IW_MLME_DEAUTH:
3624 hddLog(LOG1, "Station disassociate");
3625 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3626 {
3627 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3628
3629 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3630 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3631
3632 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3633
3634 //clear all the reason codes
3635 if (status != 0)
3636 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003637 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 }
3639
3640 netif_stop_queue(dev);
3641 netif_carrier_off(dev);
3642 }
3643 else
3644 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003645 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 -07003646 }
3647 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003648 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 return -EINVAL;
3650 }//end of switch
3651 EXIT();
3652#endif
3653 return 0;
3654// return status;
3655}
3656
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303657static int iw_set_ap_mlme(struct net_device *dev,
3658 struct iw_request_info *info,
3659 union iwreq_data *wrqu,
3660 char *extra)
3661{
3662 int ret;
3663
3664 vos_ssr_protect(__func__);
3665 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3666 vos_ssr_unprotect(__func__);
3667
3668 return ret;
3669}
3670
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303671static int __iw_get_ap_rts_threshold(struct net_device *dev,
3672 struct iw_request_info *info,
3673 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003674{
3675 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3676 v_U32_t status = 0;
3677
3678 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3679
3680 return status;
3681}
3682
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303683static int iw_get_ap_rts_threshold(struct net_device *dev,
3684 struct iw_request_info *info,
3685 union iwreq_data *wrqu, char *extra)
3686{
3687 int ret;
3688
3689 vos_ssr_protect(__func__);
3690 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3691 vos_ssr_unprotect(__func__);
3692
3693 return ret;
3694}
3695
3696static int __iw_get_ap_frag_threshold(struct net_device *dev,
3697 struct iw_request_info *info,
3698 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003699{
3700 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3701 v_U32_t status = 0;
3702
3703 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3704
3705 return status;
3706}
3707
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303708static int iw_get_ap_frag_threshold(struct net_device *dev,
3709 struct iw_request_info *info,
3710 union iwreq_data *wrqu, char *extra)
3711{
3712 int ret;
3713
3714 vos_ssr_protect(__func__);
3715 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3716 vos_ssr_unprotect(__func__);
3717
3718 return ret;
3719}
3720
3721static int __iw_get_ap_freq(struct net_device *dev,
3722 struct iw_request_info *info,
3723 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003724{
Jeff Johnsone7245742012-09-05 17:12:55 -07003725 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303726 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 tHalHandle hHal;
3728 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303729 hdd_ap_ctx_t *pHddApCtx;
3730 hdd_context_t *pHddCtx;
3731 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003732
3733 ENTER();
3734
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303735 pHostapdAdapter = (netdev_priv(dev));
3736 if (NULL == pHostapdAdapter)
3737 {
3738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3739 "%s: Adapter is NULL",__func__);
3740 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303742 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3743 ret = wlan_hdd_validate_context(pHddCtx);
3744 if (0 != ret)
3745 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303746 return ret;
3747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303749 if (NULL == pHostapdState)
3750 {
3751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3752 "%s: pHostapdState is NULL",__func__);
3753 return -EINVAL;
3754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303756 if (NULL == hHal)
3757 {
3758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3759 "%s: Hal Context is NULL",__func__);
3760 return -EINVAL;
3761 }
3762 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3763 if (NULL == pHddApCtx)
3764 {
3765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3766 "%s: AP context is NULL",__func__);
3767 return -EINVAL;
3768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 if(pHostapdState->bssState == BSS_STOP )
3770 {
3771 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3772 != eHAL_STATUS_SUCCESS)
3773 {
c_hpothuffdb5272013-10-02 16:42:35 +05303774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3775 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 return -EIO;
3777 }
3778 else
3779 {
3780 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003781 if( TRUE == status)
3782 {
3783 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3784 * iwlist & iwconfig command shows frequency into proper
3785 * format (2.412 GHz instead of 246.2 MHz)*/
3786 fwrq->m = freq;
3787 fwrq->e = MHZ;
3788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 }
3790 }
3791 else
3792 {
3793 channel = pHddApCtx->operatingChannel;
3794 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003795 if( TRUE == status)
3796 {
3797 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3798 * iwlist & iwconfig command shows frequency into proper
3799 * format (2.412 GHz instead of 246.2 MHz)*/
3800 fwrq->m = freq;
3801 fwrq->e = MHZ;
3802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303804
3805 EXIT();
3806 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003807}
3808
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303809static int iw_get_ap_freq(struct net_device *dev,
3810 struct iw_request_info *info,
3811 struct iw_freq *fwrq, char *extra)
3812{
3813 int ret;
3814
3815 vos_ssr_protect(__func__);
3816 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3817 vos_ssr_unprotect(__func__);
3818
3819 return ret;
3820}
3821
3822static int __iw_get_mode(struct net_device *dev,
3823 struct iw_request_info *info,
3824 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303825{
3826 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303827 hdd_adapter_t *pAdapter;
3828 hdd_context_t *pHddCtx;
3829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303830 ENTER();
3831
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303832 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3833 if (NULL == pAdapter)
3834 {
3835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3836 "%s: Adapter is NULL",__func__);
3837 return -EINVAL;
3838 }
3839 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3840 status = wlan_hdd_validate_context(pHddCtx);
3841 if (0 != status)
3842 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303843 return status;
3844 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303845
3846 wrqu->mode = IW_MODE_MASTER;
3847
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303848 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303849 return status;
3850}
3851
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303852static int iw_get_mode(struct net_device *dev,
3853 struct iw_request_info *info,
3854 union iwreq_data *wrqu, char *extra)
3855{
3856 int ret;
3857
3858 vos_ssr_protect(__func__);
3859 ret = __iw_get_mode(dev, info, wrqu, extra);
3860 vos_ssr_unprotect(__func__);
3861
3862 return ret;
3863}
3864
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303865static int __iw_softap_setwpsie(struct net_device *dev,
3866 struct iw_request_info *info,
3867 union iwreq_data *wrqu,
3868 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003869{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303870 hdd_adapter_t *pHostapdAdapter;
3871 hdd_context_t *pHddCtx;
3872 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 hdd_hostapd_state_t *pHostapdState;
3874 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003875 u_int8_t *wps_genie;
3876 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 u_int8_t *pos;
3878 tpSap_WPSIE pSap_WPSIe;
3879 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303880 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303881 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303882 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303883
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 ENTER();
3885
Hanumantha Reddy Pothulac9b12d92015-10-27 22:55:07 +05303886 if (!capable(CAP_NET_ADMIN))
3887 {
3888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3889 FL("permission check failed"));
3890 return -EPERM;
3891 }
3892
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303893 pHostapdAdapter = (netdev_priv(dev));
3894 if (NULL == pHostapdAdapter)
3895 {
3896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3897 "%s: Adapter is NULL",__func__);
3898 return -EINVAL;
3899 }
3900 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3901 ret = wlan_hdd_validate_context(pHddCtx);
3902 if (0 != ret)
3903 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303904 return ret;
3905 }
3906 pVosContext = pHddCtx->pvosContext;
3907 if (NULL == pVosContext)
3908 {
3909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3910 "%s: HDD context is not valid ",__func__);
3911 return -EINVAL;
3912 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303913 /* helper function to get iwreq_data with compat handling. */
3914 if (hdd_priv_get_data(&s_priv_data, wrqu))
3915 {
3916 return -EINVAL;
3917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003918
Girish Gowli07c05ec2014-06-17 20:47:03 +05303919 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3920 {
3921 return -EINVAL;
3922 }
3923
3924 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3925 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003926
Girish Gowli86c471e2014-06-17 19:28:05 +05303927 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003928 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303929 hddLog(LOG1, "%s: failed to alloc memory "
3930 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003931 return -EFAULT;
3932 }
3933
Girish Gowli86c471e2014-06-17 19:28:05 +05303934 fwps_genie = wps_genie;
3935
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3937 if (NULL == pSap_WPSIe)
3938 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003939 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003940 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 return -ENOMEM;
3942 }
3943 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3944
Arif Hussain6d2a3322013-11-17 19:50:10 -08003945 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 -07003946 WPSIeType = wps_genie[0];
3947 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3948 {
3949 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3950 wps_genie = wps_genie + 1;
3951 switch ( wps_genie[0] )
3952 {
3953 case DOT11F_EID_WPA:
3954 if (wps_genie[1] < 2 + 4)
3955 {
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05303956 ret = -EINVAL;
3957 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 }
3959 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3960 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003961 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 pos = &wps_genie[6];
3963 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3964 {
3965 switch((u_int16_t)(*pos<<8) | *(pos+1))
3966 {
3967 case HDD_WPS_ELEM_VERSION:
3968 pos += 4;
3969 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003970 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3972 pos += 1;
3973 break;
3974
3975 case HDD_WPS_ELEM_WPS_STATE:
3976 pos +=4;
3977 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003978 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3980 pos += 1;
3981 break;
3982 case HDD_WPS_ELEM_APSETUPLOCK:
3983 pos += 4;
3984 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003985 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3987 pos += 1;
3988 break;
3989 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3990 pos += 4;
3991 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003992 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3994 pos += 1;
3995 break;
3996 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3997 pos += 4;
3998 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003999 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
4001 pos += 2;
4002 break;
4003 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4004 pos += 4;
4005 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004006 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
4008 pos += 2;
4009 break;
4010
4011 case HDD_WPS_ELEM_UUID_E:
4012 pos += 2;
4013 length = *pos<<8 | *(pos+1);
4014 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304015 if (length > sizeof(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E))
4016 {
4017 ret = -EINVAL;
4018 goto exit;
4019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
4021 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
4022 pos += length;
4023 break;
4024 case HDD_WPS_ELEM_RF_BANDS:
4025 pos += 4;
4026 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004027 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
4029 pos += 1;
4030 break;
4031
4032 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004033 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304034 ret = -EINVAL;
4035 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 }
4037 }
4038 }
4039 else {
4040 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004041 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 }
4043 break;
4044
4045 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004046 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304047 ret = -EINVAL;
4048 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 }
4050 }
4051 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
4052 {
4053 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
4054 wps_genie = wps_genie + 1;
4055 switch ( wps_genie[0] )
4056 {
4057 case DOT11F_EID_WPA:
4058 if (wps_genie[1] < 2 + 4)
4059 {
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304060 ret = -EINVAL;
4061 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
4063 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
4064 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004065 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 pos = &wps_genie[6];
4067 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
4068 {
4069 switch((u_int16_t)(*pos<<8) | *(pos+1))
4070 {
4071 case HDD_WPS_ELEM_VERSION:
4072 pos += 4;
4073 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004074 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
4076 pos += 1;
4077 break;
4078
4079 case HDD_WPS_ELEM_WPS_STATE:
4080 pos +=4;
4081 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004082 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
4084 pos += 1;
4085 break;
4086 case HDD_WPS_ELEM_APSETUPLOCK:
4087 pos += 4;
4088 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004089 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
4091 pos += 1;
4092 break;
4093 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4094 pos += 4;
4095 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004096 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
4098 pos += 1;
4099 break;
4100 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4101 pos += 4;
4102 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004103 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
4105 pos += 2;
4106 break;
4107 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4108 pos += 4;
4109 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004110 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
4112 pos += 2;
4113 break;
4114 case HDD_WPS_ELEM_RSP_TYPE:
4115 pos += 4;
4116 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004117 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
4119 pos += 1;
4120 break;
4121 case HDD_WPS_ELEM_UUID_E:
4122 pos += 2;
4123 length = *pos<<8 | *(pos+1);
4124 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304125 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E)))
4126 {
4127 ret = -EINVAL;
4128 goto exit;
4129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
4131 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
4132 pos += length;
4133 break;
4134
4135 case HDD_WPS_ELEM_MANUFACTURER:
4136 pos += 2;
4137 length = *pos<<8 | *(pos+1);
4138 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304139 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name)))
4140 {
4141 ret = -EINVAL;
4142 goto exit;
4143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
4145 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
4146 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
4147 pos += length;
4148 break;
4149
4150 case HDD_WPS_ELEM_MODEL_NAME:
4151 pos += 2;
4152 length = *pos<<8 | *(pos+1);
4153 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304154 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text)))
4155 {
4156 ret = -EINVAL;
4157 goto exit;
4158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
4160 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
4161 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
4162 pos += length;
4163 break;
4164 case HDD_WPS_ELEM_MODEL_NUM:
4165 pos += 2;
4166 length = *pos<<8 | *(pos+1);
4167 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304168 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text)))
4169 {
4170 ret = -EINVAL;
4171 goto exit;
4172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
4174 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
4175 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
4176 pos += length;
4177 break;
4178 case HDD_WPS_ELEM_SERIAL_NUM:
4179 pos += 2;
4180 length = *pos<<8 | *(pos+1);
4181 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304182 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text)))
4183 {
4184 ret = -EINVAL;
4185 goto exit;
4186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
4188 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
4189 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
4190 pos += length;
4191 break;
4192 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
4193 pos += 4;
4194 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004195 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 pos += 2;
4197
4198 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004199 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 pos += 4;
4201 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004202 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 pos += 2;
4204 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
4205 break;
4206 case HDD_WPS_ELEM_DEVICE_NAME:
4207 pos += 2;
4208 length = *pos<<8 | *(pos+1);
4209 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304210 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text)))
4211 {
4212 ret = -EINVAL;
4213 goto exit;
4214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4216 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4217 pos += length;
4218 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4219 break;
4220 case HDD_WPS_ELEM_CONFIG_METHODS:
4221 pos += 4;
4222 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004223 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 pos += 2;
4225 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4226 break;
4227
4228 case HDD_WPS_ELEM_RF_BANDS:
4229 pos += 4;
4230 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004231 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 pos += 1;
4233 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4234 break;
4235 } // switch
4236 }
4237 }
4238 else
4239 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004240 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 }
4242
4243 } // switch
4244 }
4245 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304246 if (halStatus != eHAL_STATUS_SUCCESS)
4247 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4249 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4250 {
4251 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4252 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4253 WLANSAP_Update_WpsIe ( pVosContext );
4254 }
4255
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304256exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004258 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 EXIT();
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304260 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07004261}
4262
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304263static int iw_softap_setwpsie(struct net_device *dev,
4264 struct iw_request_info *info,
4265 union iwreq_data *wrqu,
4266 char *extra)
4267{
4268 int ret;
4269
4270 vos_ssr_protect(__func__);
4271 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4272 vos_ssr_unprotect(__func__);
4273
4274 return ret;
4275}
4276
4277static int __iw_softap_stopbss(struct net_device *dev,
4278 struct iw_request_info *info,
4279 union iwreq_data *wrqu,
4280 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004281{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304282 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304284 hdd_context_t *pHddCtx = NULL;
4285
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304287 pHostapdAdapter = (netdev_priv(dev));
4288 if (NULL == pHostapdAdapter)
4289 {
4290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4291 "%s: Adapter is NULL",__func__);
4292 return -EINVAL;
4293 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304294 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4295 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304296 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304297 return status;
4298 }
4299
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304300 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 {
4302 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4303 {
4304 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4305
4306 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304307
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304309 {
4310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004311 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 VOS_ASSERT(0);
4313 }
4314 }
4315 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304316 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 }
4318 EXIT();
4319 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4320}
4321
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304322static int iw_softap_stopbss(struct net_device *dev,
4323 struct iw_request_info *info,
4324 union iwreq_data *wrqu,
4325 char *extra)
4326{
4327 int ret;
4328
4329 vos_ssr_protect(__func__);
4330 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4331 vos_ssr_unprotect(__func__);
4332
4333 return ret;
4334}
4335
4336static int __iw_softap_version(struct net_device *dev,
4337 struct iw_request_info *info,
4338 union iwreq_data *wrqu,
4339 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004340{
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304342 hdd_context_t *pHddCtx;
4343 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304344
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304346 pHostapdAdapter = (netdev_priv(dev));
4347 if (NULL == pHostapdAdapter)
4348 {
4349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4350 "%s: Adapter is NULL",__func__);
4351 return -EINVAL;
4352 }
4353 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4354 ret = wlan_hdd_validate_context(pHddCtx);
4355 if (0 != ret)
4356 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304357 return ret;
4358 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004359 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 return 0;
4362}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004363
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304364static int iw_softap_version(struct net_device *dev,
4365 struct iw_request_info *info,
4366 union iwreq_data *wrqu,
4367 char *extra)
4368{
4369 int ret;
4370
4371 vos_ssr_protect(__func__);
4372 ret = __iw_softap_version(dev, info, wrqu, extra);
4373 vos_ssr_unprotect(__func__);
4374
4375 return ret;
4376}
4377
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304378int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004379{
4380 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004381 int len = 0;
4382 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304383 v_CONTEXT_t pVosContext;
4384 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304385 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304386
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304387 ENTER();
4388
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304389 if (NULL == pAdapter)
4390 {
4391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4392 "%s: Adapter is NULL",__func__);
4393 return -EINVAL;
4394 }
4395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4396 if (0 != wlan_hdd_validate_context(pHddCtx))
4397 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304398 return VOS_STATUS_E_FAULT;
4399 }
4400 pVosContext = pHddCtx->pvosContext;
4401 if (NULL == pVosContext)
4402 {
4403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4404 "%s: VOS context is not valid",__func__);
4405 return VOS_STATUS_E_FAULT;
4406 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304407 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304408 if(pSapCtx == NULL)
4409 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304410 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4411 FL("psapCtx is NULL"));
4412 return VOS_STATUS_E_FAULT;
4413 }
4414
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304415 len = snprintf(pBuf, buf_len, sta_info_header);
4416 if (len >= buf_len) {
4417 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4418 return -E2BIG;
4419 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004420 pBuf += len;
4421 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004422
4423 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4424 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304425 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004426 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004427 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304428 pSapCtx->aStaInfo[i].ucSTAId,
4429 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4430 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4431 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4432 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4433 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4434 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304435 if (len >= buf_len) {
4436 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4437 return -E2BIG;
4438 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004439 pBuf += len;
4440 buf_len -= len;
4441 }
4442 if(WE_GET_STA_INFO_SIZE > buf_len)
4443 {
4444 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004445 }
4446 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304447 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304448 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004449}
4450
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304451static int __iw_softap_get_sta_info(struct net_device *dev,
4452 struct iw_request_info *info,
4453 union iwreq_data *wrqu,
4454 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004455{
4456 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304457 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004458 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304459 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4460 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004461 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304462 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004463 }
4464 wrqu->data.length = strlen(extra);
4465 EXIT();
4466 return 0;
4467}
4468
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304469static int iw_softap_get_sta_info(struct net_device *dev,
4470 struct iw_request_info *info,
4471 union iwreq_data *wrqu,
4472 char *extra)
4473{
4474 int ret;
4475
4476 vos_ssr_protect(__func__);
4477 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4478 vos_ssr_unprotect(__func__);
4479
4480 return ret;
4481}
4482
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304483static int __iw_set_ap_genie(struct net_device *dev,
4484 struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004486{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304487
4488 hdd_adapter_t *pHostapdAdapter;
4489 hdd_context_t *pHddCtx;
4490 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004492 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304493 int ret = 0;
4494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304496 pHostapdAdapter = (netdev_priv(dev));
4497 if (NULL == pHostapdAdapter)
4498 {
4499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4500 "%s: Adapter is NULL",__func__);
4501 return -EINVAL;
4502 }
4503 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4504 ret = wlan_hdd_validate_context(pHddCtx);
4505 if (0 != ret)
4506 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304507 return ret;
4508 }
4509 pVosContext = pHddCtx->pvosContext;
4510 if (NULL == pVosContext)
4511 {
4512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4513 "%s: VOS Context is NULL",__func__);
4514 return -EINVAL;
4515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 if(!wrqu->data.length)
4517 {
4518 EXIT();
4519 return 0;
4520 }
Arif Hussained667642013-10-27 23:01:14 -07004521
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304522 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304524 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 case DOT11F_EID_RSN:
4526 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4527 {
4528 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4529 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004532 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304534
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004536 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 halStatus = 0;
4538 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304539
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304541 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004542}
4543
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304544static int iw_set_ap_genie(struct net_device *dev,
4545 struct iw_request_info *info,
4546 union iwreq_data *wrqu, char *extra)
4547{
4548 int ret;
4549
4550 vos_ssr_protect(__func__);
4551 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4552 vos_ssr_unprotect(__func__);
4553
4554 return ret;
4555}
4556
Jeff Johnson295189b2012-06-20 16:38:30 -07004557static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4558{
4559 eHalStatus hstatus;
4560 long lrc;
4561 struct statsContext context;
4562
4563 if (NULL == pAdapter)
4564 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304565 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 return VOS_STATUS_E_FAULT;
4567 }
4568
4569 init_completion(&context.completion);
4570 context.pAdapter = pAdapter;
4571 context.magic = STATS_CONTEXT_MAGIC;
4572 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4573 eCSR_HDD,
4574 SME_GLOBAL_CLASSA_STATS,
4575 hdd_GetClassA_statisticsCB,
4576 0, // not periodic
4577 FALSE, //non-cached results
4578 staid,
4579 &context);
4580 if (eHAL_STATUS_SUCCESS != hstatus)
4581 {
4582 hddLog(VOS_TRACE_LEVEL_ERROR,
4583 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004584 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 }
4586 else
4587 {
4588 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4589 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 if (lrc <= 0)
4591 {
4592 hddLog(VOS_TRACE_LEVEL_ERROR,
4593 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004594 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 }
4596 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004597
4598 /* either we never sent a request, we sent a request and received a
4599 response or we sent a request and timed out. if we never sent a
4600 request or if we sent a request and got a response, we want to
4601 clear the magic out of paranoia. if we timed out there is a
4602 race condition such that the callback function could be
4603 executing at the same time we are. of primary concern is if the
4604 callback function had already verified the "magic" but had not
4605 yet set the completion variable when a timeout occurred. we
4606 serialize these activities by invalidating the magic while
4607 holding a shared spinlock which will cause us to block if the
4608 callback is currently executing */
4609 spin_lock(&hdd_context_lock);
4610 context.magic = 0;
4611 spin_unlock(&hdd_context_lock);
4612
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 return VOS_STATUS_SUCCESS;
4614}
4615
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304616int __iw_get_softap_linkspeed(struct net_device *dev,
4617 struct iw_request_info *info,
4618 union iwreq_data *wrqu,
4619 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004620
4621{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304622 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304623 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004625 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304626 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304628 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004630 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304631 int rc, valid;
4632
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304633 ENTER();
4634
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304635 pHostapdAdapter = (netdev_priv(dev));
4636 if (NULL == pHostapdAdapter)
4637 {
4638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4639 "%s: Adapter is NULL",__func__);
4640 return -EINVAL;
4641 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304642 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304643 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304644 if (0 != valid)
4645 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304646 return valid;
4647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004648
Arif Hussain6d2a3322013-11-17 19:50:10 -08004649 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004650
4651 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004652 {
Arif Hussaina9571842014-01-15 16:43:41 -08004653 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4654 if (NULL == pmacAddress) {
4655 hddLog(LOG1, "unable to allocate memory");
4656 return -ENOMEM;
4657 }
4658 if (copy_from_user((void *)pmacAddress,
4659 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4660 {
4661 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4662 kfree(pmacAddress);
4663 return -EFAULT;
4664 }
Manjeet Singha3739742016-05-03 16:21:46 +05304665 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004666
4667 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004668 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004669
4670 if (!VOS_IS_STATUS_SUCCESS(status ))
4671 {
4672 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4673 }
Arif Hussained667642013-10-27 23:01:14 -07004674 }
Kiet Lam61589852013-09-19 17:10:58 +05304675 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304676 * link speed for first connected client will be returned.
4677 */
Arif Hussaina9571842014-01-15 16:43:41 -08004678 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304679 {
4680 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4681 }
4682 else
4683 {
4684 status = hdd_softap_GetStaId(pHostapdAdapter,
4685 (v_MACADDR_t *)macAddress, (void *)(&staId));
4686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004687
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304688 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 link_speed = 0;
4692 }
4693 else
4694 {
4695 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304696
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 if (!VOS_IS_STATUS_SUCCESS(status ))
4698 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 return -EINVAL;
4701 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304702
4703 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4704 staId, &link_speed);
4705
4706 link_speed = link_speed / 10;
4707
4708 if (0 == link_speed)
4709 {
4710 /* The linkspeed returned by HAL is in units of 500kbps.
4711 * converting it to mbps.
4712 * This is required to support legacy firmware which does
4713 * not return link capacity.
4714 */
4715 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 }
4718
4719 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004720 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304721
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 if ((rc < 0) || (rc >= len))
4723 {
4724 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304725 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 return -EIO;
4727 }
4728
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304729 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 return 0;
4731}
4732
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304733int iw_get_softap_linkspeed(struct net_device *dev,
4734 struct iw_request_info *info,
4735 union iwreq_data *wrqu,
4736 char *extra)
4737{
4738 int ret;
4739
4740 vos_ssr_protect(__func__);
4741 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4742 vos_ssr_unprotect(__func__);
4743
4744 return ret;
4745}
4746
4747
Jeff Johnson295189b2012-06-20 16:38:30 -07004748static const iw_handler hostapd_handler[] =
4749{
4750 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4751 (iw_handler) NULL, /* SIOCGIWNAME */
4752 (iw_handler) NULL, /* SIOCSIWNWID */
4753 (iw_handler) NULL, /* SIOCGIWNWID */
4754 (iw_handler) NULL, /* SIOCSIWFREQ */
4755 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4756 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304757 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 (iw_handler) NULL, /* SIOCSIWSENS */
4759 (iw_handler) NULL, /* SIOCGIWSENS */
4760 (iw_handler) NULL, /* SIOCSIWRANGE */
4761 (iw_handler) NULL, /* SIOCGIWRANGE */
4762 (iw_handler) NULL, /* SIOCSIWPRIV */
4763 (iw_handler) NULL, /* SIOCGIWPRIV */
4764 (iw_handler) NULL, /* SIOCSIWSTATS */
4765 (iw_handler) NULL, /* SIOCGIWSTATS */
4766 (iw_handler) NULL, /* SIOCSIWSPY */
4767 (iw_handler) NULL, /* SIOCGIWSPY */
4768 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4769 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4770 (iw_handler) NULL, /* SIOCSIWAP */
4771 (iw_handler) NULL, /* SIOCGIWAP */
4772 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4773 (iw_handler) NULL, /* SIOCGIWAPLIST */
4774 (iw_handler) NULL, /* SIOCSIWSCAN */
4775 (iw_handler) NULL, /* SIOCGIWSCAN */
4776 (iw_handler) NULL, /* SIOCSIWESSID */
4777 (iw_handler) NULL, /* SIOCGIWESSID */
4778 (iw_handler) NULL, /* SIOCSIWNICKN */
4779 (iw_handler) NULL, /* SIOCGIWNICKN */
4780 (iw_handler) NULL, /* -- hole -- */
4781 (iw_handler) NULL, /* -- hole -- */
4782 (iw_handler) NULL, /* SIOCSIWRATE */
4783 (iw_handler) NULL, /* SIOCGIWRATE */
4784 (iw_handler) NULL, /* SIOCSIWRTS */
4785 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4786 (iw_handler) NULL, /* SIOCSIWFRAG */
4787 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4788 (iw_handler) NULL, /* SIOCSIWTXPOW */
4789 (iw_handler) NULL, /* SIOCGIWTXPOW */
4790 (iw_handler) NULL, /* SIOCSIWRETRY */
4791 (iw_handler) NULL, /* SIOCGIWRETRY */
4792 (iw_handler) NULL, /* SIOCSIWENCODE */
4793 (iw_handler) NULL, /* SIOCGIWENCODE */
4794 (iw_handler) NULL, /* SIOCSIWPOWER */
4795 (iw_handler) NULL, /* SIOCGIWPOWER */
4796 (iw_handler) NULL, /* -- hole -- */
4797 (iw_handler) NULL, /* -- hole -- */
4798 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4799 (iw_handler) NULL, /* SIOCGIWGENIE */
4800 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4801 (iw_handler) NULL, /* SIOCGIWAUTH */
4802 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4803 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4804 (iw_handler) NULL, /* SIOCSIWPMKSA */
4805};
4806
Jeff Johnson224f3702014-03-26 11:09:47 -07004807/*
4808 * Note that the following ioctls were defined with semantics which
4809 * cannot be handled by the "iwpriv" userspace application and hence
4810 * they are not included in the hostapd_private_args array
4811 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4812 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004813
4814static const struct iw_priv_args hostapd_private_args[] = {
4815 { QCSAP_IOCTL_SETPARAM,
4816 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4817 { QCSAP_IOCTL_SETPARAM,
4818 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304819 { QCSAP_PARAM_GET_FRAME_LOGS,
4820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 { QCSAP_PARAM_MAX_ASSOC,
4822 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4823 { QCSAP_PARAM_HIDE_SSID,
4824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004825 { QCSAP_PARAM_SET_MC_RATE,
4826 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304827 { QCSAP_PARAM_SET_PROXIMITY,
4828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 { QCSAP_IOCTL_GETPARAM,
4830 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4831 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4832 { QCSAP_IOCTL_GETPARAM, 0,
4833 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4834 { QCSAP_PARAM_MAX_ASSOC, 0,
4835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004836 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4837 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4838 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304840 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 { QCSAP_PARAM_CLR_ACL, 0,
4843 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4844 { QCSAP_PARAM_ACL_MODE,
4845 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 { QCSAP_IOCTL_GET_STAWPAIE,
4847 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4848 { QCSAP_IOCTL_SETWPAIE,
4849 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4850 { QCSAP_IOCTL_STOPBSS,
4851 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4852 { QCSAP_IOCTL_VERSION, 0,
4853 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004854 { QCSAP_IOCTL_GET_STA_INFO, 0,
4855 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004857 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004860 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304862 { QCSAP_IOCTL_AP_STATS, 0,
4863 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304864 { QCSAP_IOCTL_GET_STATS, 0,
4865 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4866 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4868 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304869 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004870
4871 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4873 /* handlers for sub-ioctl */
4874 { WE_SET_WLAN_DBG,
4875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4876 0,
4877 "setwlandbg" },
4878
4879 /* handlers for main ioctl */
4880 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4881 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4882 0,
4883 "" },
4884
4885 /* handlers for sub-ioctl */
4886 { WE_LOG_DUMP_CMD,
4887 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4888 0,
4889 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 { WE_P2P_NOA_CMD,
4891 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4892 0,
4893 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004894 /* handlers for sub ioctl */
4895 {
4896 WE_MCC_CONFIG_CREDENTIAL,
4897 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4898 0,
4899 "setMccCrdnl" },
4900
4901 /* handlers for sub ioctl */
4902 {
4903 WE_MCC_CONFIG_PARAMS,
4904 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4905 0,
4906 "setMccConfig" },
4907
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 /* handlers for main ioctl */
4909 { QCSAP_IOCTL_MODIFY_ACL,
4910 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4911 0,
4912 "modify_acl" },
4913
4914 /* handlers for main ioctl */
4915 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4916 0,
4917 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4918 "getChannelList" },
4919
Jeff Johnsone7245742012-09-05 17:12:55 -07004920 /* handlers for main ioctl */
4921 { QCSAP_IOCTL_SET_TX_POWER,
4922 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4923 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304924 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004925
4926 /* handlers for main ioctl */
4927 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4928 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4929 0,
4930 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304931
4932 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4933 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4934 0,
4935 "dataSnapshot" },
4936
4937 /* handlers for main ioctl */
4938 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4939 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4940 0,
4941 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004942};
Jeff Johnsone7245742012-09-05 17:12:55 -07004943
Jeff Johnson295189b2012-06-20 16:38:30 -07004944static const iw_handler hostapd_private[] = {
4945 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4946 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4948 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4949 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4950 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4951 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4952 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4953 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4954 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4955 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304956 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4958 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4959 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4960 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004961 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004962 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4963 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004964 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304965 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304966 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304967 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4968 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004969};
4970const struct iw_handler_def hostapd_handler_def = {
4971 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4972 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4973 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4974 .standard = (iw_handler *)hostapd_handler,
4975 .private = (iw_handler *)hostapd_private,
4976 .private_args = hostapd_private_args,
4977 .get_wireless_stats = NULL,
4978};
4979#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4980struct net_device_ops net_ops_struct = {
4981 .ndo_open = hdd_hostapd_open,
4982 .ndo_stop = hdd_hostapd_stop,
4983 .ndo_uninit = hdd_hostapd_uninit,
4984 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4985 .ndo_tx_timeout = hdd_softap_tx_timeout,
4986 .ndo_get_stats = hdd_softap_stats,
4987 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4988 .ndo_do_ioctl = hdd_hostapd_ioctl,
4989 .ndo_change_mtu = hdd_hostapd_change_mtu,
4990 .ndo_select_queue = hdd_hostapd_select_queue,
4991 };
4992#endif
4993
4994int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4995{
4996 return VOS_STATUS_SUCCESS;
4997}
4998
4999void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5000{
5001#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5002 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5003#else
5004 pWlanHostapdDev->open = hdd_hostapd_open;
5005 pWlanHostapdDev->stop = hdd_hostapd_stop;
5006 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5007 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5008 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5009 pWlanHostapdDev->get_stats = hdd_softap_stats;
5010 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5011 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5012#endif
5013}
5014
5015VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305016{
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 hdd_hostapd_state_t * phostapdBuf;
5018 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005019 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005021#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005022 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5023 v_U16_t unsafeChannelCount;
5024#endif /* FEATURE_WLAN_CH_AVOID */
5025
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305026 if (pHddCtx->isLogpInProgress) {
5027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5028 "%s:LOGP in Progress. Ignore!!!",__func__);
5029 status = VOS_STATUS_E_FAILURE;
5030 }
5031
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305033 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305035
Nirav Shah7e3c8132015-06-22 23:51:42 +05305036 spin_lock_init(&pAdapter->sta_hash_lock);
5037 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5038
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005039 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5040
Leo Chang0b0e45a2013-12-15 15:18:55 -08005041#ifdef FEATURE_WLAN_CH_AVOID
5042 /* Get unsafe cahnnel list from cached location */
5043 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5044 sizeof(unsafeChannelList),
5045 &unsafeChannelCount);
5046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5047 "%s : Unsafe Channel count %d",
5048 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305049 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005050 unsafeChannelList,
5051 unsafeChannelCount);
5052#endif /* FEATURE_WLAN_CH_AVOID */
5053
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 // Zero the memory. This zeros the profile structure.
5055 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
5056
5057 // Set up the pointer to the Wireless Extensions state structure
5058 // NOP
5059 status = hdd_set_hostapd(pAdapter);
5060 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 return status;
5063 }
5064
5065 status = vos_event_init(&phostapdBuf->vosEvent);
5066 if (!VOS_IS_STATUS_SUCCESS(status))
5067 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 return status;
5070 }
5071
Jeff Johnson295189b2012-06-20 16:38:30 -07005072
5073 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5074
5075 // Register as a wireless device
5076 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5077
5078 //Initialize the data path module
5079 status = hdd_softap_init_tx_rx(pAdapter);
5080 if ( !VOS_IS_STATUS_SUCCESS( status ))
5081 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005082 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305084
5085 status = hdd_wmm_adapter_init( pAdapter );
5086 if (!VOS_IS_STATUS_SUCCESS(status))
5087 {
5088 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005089 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305090 status, status );
5091 goto error_wmm_init;
5092 }
5093
5094 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5095
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305096 return status;
5097
5098error_wmm_init:
5099 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 EXIT();
5101 return status;
5102}
5103
5104hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5105{
5106 struct net_device *pWlanHostapdDev = NULL;
5107 hdd_adapter_t *pHostapdAdapter = NULL;
5108 v_CONTEXT_t pVosContext= NULL;
5109
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305110 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5111#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5112 NET_NAME_UNKNOWN,
5113#endif
5114 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 if (pWlanHostapdDev != NULL)
5116 {
5117 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5118
5119 //Init the net_device structure
5120 ether_setup(pWlanHostapdDev);
5121
5122 //Initialize the adapter context to zeros.
5123 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5124 pHostapdAdapter->dev = pWlanHostapdDev;
5125 pHostapdAdapter->pHddCtx = pHddCtx;
5126 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5127
5128 //Get the Global VOSS context.
5129 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5130 //Save the adapter context in global context for future.
5131 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5132
5133 //Init the net_device structure
5134 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5135
5136 hdd_set_ap_ops( pHostapdAdapter->dev );
5137
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5139 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5140
5141 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5142 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5143
5144 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5146 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5147 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005148
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5150 }
5151 return pHostapdAdapter;
5152}
5153
5154VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5155{
5156 struct net_device *dev = pAdapter->dev;
5157 VOS_STATUS status = VOS_STATUS_SUCCESS;
5158
5159 ENTER();
5160
5161 if( rtnl_lock_held )
5162 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005163 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 if( dev_alloc_name(dev, dev->name) < 0 )
5165 {
5166 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5167 return VOS_STATUS_E_FAILURE;
5168 }
5169 }
5170 if (register_netdevice(dev))
5171 {
5172 hddLog(VOS_TRACE_LEVEL_FATAL,
5173 "%s:Failed:register_netdevice", __func__);
5174 return VOS_STATUS_E_FAILURE;
5175 }
5176 }
5177 else
5178 {
5179 if (register_netdev(dev))
5180 {
5181 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5182 return VOS_STATUS_E_FAILURE;
5183 }
5184 }
5185 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5186
5187 EXIT();
5188 return status;
5189}
5190
c_hpothu002231a2015-02-05 14:58:51 +05305191VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005192{
5193 ENTER();
5194
5195 hdd_softap_deinit_tx_rx(pAdapter);
5196
5197 /* if we are being called during driver unload, then the dev has already
5198 been invalidated. if we are being called at other times, then we can
5199 detatch the wireless device handlers */
5200 if (pAdapter->dev)
5201 {
c_hpothu002231a2015-02-05 14:58:51 +05305202 if (TRUE == rtnl_held)
5203 {
5204 pAdapter->dev->wireless_handlers = NULL;
5205 }
5206 else
5207 {
5208 rtnl_lock();
5209 pAdapter->dev->wireless_handlers = NULL;
5210 rtnl_unlock();
5211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 }
5213 EXIT();
5214 return 0;
5215}