blob: 7a2894f302f7b66d1e28a520ca73247bc454594e [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 }
Leo Chang614d2072013-08-22 14:59:44 -07001959
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 default:
1961 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1962 sub_cmd, set_value);
1963 ret = -EINVAL;
1964 break;
1965 }
1966
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301967 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 return ret;
1969}
1970
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301971int
1972static iw_softap_setparam(struct net_device *dev,
1973 struct iw_request_info *info,
1974 union iwreq_data *wrqu, char *extra)
1975{
1976 int ret;
1977
1978 vos_ssr_protect(__func__);
1979 ret = __iw_softap_setparam(dev, info, wrqu, extra);
1980 vos_ssr_unprotect(__func__);
1981
1982 return ret;
1983}
Jeff Johnson295189b2012-06-20 16:38:30 -07001984
1985int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301986static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 struct iw_request_info *info,
1988 union iwreq_data *wrqu, char *extra)
1989{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301990 hdd_adapter_t *pHostapdAdapter;
1991 tHalHandle hHal;
1992 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 int *value = (int *)extra;
1994 int sub_cmd = value[0];
1995 eHalStatus status;
1996 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301997 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301999 ENTER();
2000
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302001 pHostapdAdapter = (netdev_priv(dev));
2002 if (NULL == pHostapdAdapter)
2003 {
2004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2005 "%s: Adapter is NULL",__func__);
2006 return -EINVAL;
2007 }
2008 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2009 ret = wlan_hdd_validate_context(pHddCtx);
2010 if (0 != ret)
2011 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302012 return ret;
2013 }
2014 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2015 if (NULL == hHal)
2016 {
2017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2018 "%s: Hal Context is NULL",__func__);
2019 return -EINVAL;
2020 }
2021 pVosContext = pHddCtx->pvosContext;
2022 if (NULL == pVosContext)
2023 {
2024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2025 "%s: pVosContext Context is NULL",__func__);
2026 return -EINVAL;
2027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 switch (sub_cmd)
2029 {
2030 case QCSAP_PARAM_MAX_ASSOC:
2031 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2032 if (eHAL_STATUS_SUCCESS != status)
2033 {
c_hpothuffdb5272013-10-02 16:42:35 +05302034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2035 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 ret = -EIO;
2037 }
Girish Gowli385be612014-09-18 11:17:20 +05302038
2039#ifdef WLAN_SOFTAP_VSTA_FEATURE
2040 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2041 {
2042 if (*value > VSTA_NUM_ASSOC_STA)
2043 {
2044 *value = VSTA_NUM_ASSOC_STA;
2045 }
2046 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2047 (*value > (VSTA_NUM_ASSOC_STA -
2048 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2049 {
2050 *value = (VSTA_NUM_ASSOC_STA -
2051 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2052 }
2053 }
2054 else
2055#endif
2056 {
2057 if (*value > NUM_ASSOC_STA)
2058 {
2059 *value = NUM_ASSOC_STA;
2060 }
2061 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2062 (*value > (NUM_ASSOC_STA -
2063 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2064 {
2065 *value = (NUM_ASSOC_STA -
2066 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2067 }
2068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302070
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002072 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 {
c_hpothuffdb5272013-10-02 16:42:35 +05302074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2075 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302076 ret = -EIO;
2077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 *value = 0;
2079 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302080
Jeff Johnson43971f52012-07-17 12:26:56 -07002081 case QCSAP_PARAM_GET_WLAN_DBG:
2082 {
2083 vos_trace_display();
2084 *value = 0;
2085 break;
2086 }
2087
2088 case QCSAP_PARAM_AUTO_CHANNEL:
2089 {
2090 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2091 break;
2092 }
2093
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 default:
2095 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2096 ret = -EINVAL;
2097 break;
2098
2099 }
2100
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302101 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 return ret;
2103}
2104
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302105int
2106static iw_softap_getparam(struct net_device *dev,
2107 struct iw_request_info *info,
2108 union iwreq_data *wrqu, char *extra)
2109{
2110 int ret;
2111
2112 vos_ssr_protect(__func__);
2113 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2114 vos_ssr_unprotect(__func__);
2115
2116 return ret;
2117}
Jeff Johnson295189b2012-06-20 16:38:30 -07002118/* Usage:
2119 BLACK_LIST = 0
2120 WHITE_LIST = 1
2121 ADD MAC = 0
2122 REMOVE MAC = 1
2123
2124 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2125 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2126 while using this ioctl
2127
2128 Syntax:
2129 iwpriv softap.0 modify_acl
2130 <6 octet mac addr> <list type> <cmd type>
2131
2132 Examples:
2133 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2134 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2135 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2136 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2137*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302138int __iw_softap_modify_acl(struct net_device *dev,
2139 struct iw_request_info *info,
2140 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002141{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302142 hdd_adapter_t *pHostapdAdapter;
2143 v_CONTEXT_t pVosContext;
2144 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 v_BYTE_t *value = (v_BYTE_t*)extra;
2146 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2147 int listType, cmd, i;
2148 int ret = 0; /* success */
2149
2150 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302151 pHostapdAdapter = (netdev_priv(dev));
2152 if (NULL == pHostapdAdapter)
2153 {
2154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2155 "%s: Adapter is NULL",__func__);
2156 return -EINVAL;
2157 }
2158 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2159 ret = wlan_hdd_validate_context(pHddCtx);
2160 if (0 != ret)
2161 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302162 return ret;
2163 }
2164 pVosContext = pHddCtx->pvosContext;
2165 if (NULL == pVosContext)
2166 {
2167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2168 "%s: Vos Context is NULL",__func__);
2169 return -EINVAL;
2170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2172 {
2173 pPeerStaMac[i] = *(value+i);
2174 }
2175 listType = (int)(*(value+i));
2176 i++;
2177 cmd = (int)(*(value+i));
2178
Arif Hussain24bafea2013-11-15 15:10:03 -08002179 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2180 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2183 != VOS_STATUS_SUCCESS)
2184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002185 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 ret = -EIO;
2187 }
2188 EXIT();
2189 return ret;
2190}
2191
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302192int iw_softap_modify_acl(struct net_device *dev,
2193 struct iw_request_info *info,
2194 union iwreq_data *wrqu, char *extra)
2195{
2196 int ret;
2197
2198 vos_ssr_protect(__func__);
2199 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2200 vos_ssr_unprotect(__func__);
2201
2202 return ret;
2203}
2204
Jeff Johnson295189b2012-06-20 16:38:30 -07002205int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302206static __iw_softap_getchannel(struct net_device *dev,
2207 struct iw_request_info *info,
2208 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002209{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302210 hdd_adapter_t *pHostapdAdapter;
2211 hdd_context_t *pHddCtx;
2212 int ret = 0;
2213 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302214
2215 ENTER();
2216
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302217 pHostapdAdapter = (netdev_priv(dev));
2218 if (NULL == pHostapdAdapter)
2219 {
2220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2221 "%s: Adapter is NULL",__func__);
2222 return -EINVAL;
2223 }
2224 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2225 ret = wlan_hdd_validate_context(pHddCtx);
2226 if (0 != ret)
2227 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302228 return ret;
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302231 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002232
Jeff Johnson43971f52012-07-17 12:26:56 -07002233 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302234
2235 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 return 0;
2237}
2238
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302239
Jeff Johnsone7245742012-09-05 17:12:55 -07002240int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302241static iw_softap_getchannel(struct net_device *dev,
2242 struct iw_request_info *info,
2243 union iwreq_data *wrqu, char *extra)
2244{
2245 int ret;
2246
2247 vos_ssr_protect(__func__);
2248 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2249 vos_ssr_unprotect(__func__);
2250
2251 return ret;
2252}
2253
2254int
2255static __iw_softap_set_max_tx_power(struct net_device *dev,
2256 struct iw_request_info *info,
2257 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002258{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302259 hdd_adapter_t *pHostapdAdapter;
2260 tHalHandle hHal;
2261 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002262 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302263 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002264 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2265 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2266
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302267 ENTER();
2268
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302269 pHostapdAdapter = (netdev_priv(dev));
2270 if (NULL == pHostapdAdapter)
2271 {
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2273 "%s: Adapter is NULL",__func__);
2274 return -EINVAL;
2275 }
2276 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2277 ret = wlan_hdd_validate_context(pHddCtx);
2278 if (0 != ret)
2279 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302280 return ret;
2281 }
2282 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2283 if (NULL == hHal)
2284 {
2285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2286 "%s: Hal Context is NULL",__func__);
2287 return -EINVAL;
2288 }
schang86c22c42013-03-13 18:41:24 -07002289 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002290 return -ENOMEM;
2291
Leo Changd37675a2013-08-01 13:19:45 -07002292 /* Assign correct slef MAC address */
2293 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2294 VOS_MAC_ADDR_SIZE);
2295 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2296 VOS_MAC_ADDR_SIZE);
2297
schang86c22c42013-03-13 18:41:24 -07002298 set_value = value[0];
2299 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2300 {
2301 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002302 __func__);
schang86c22c42013-03-13 18:41:24 -07002303 return -EIO;
2304 }
2305
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302306 EXIT();
schang86c22c42013-03-13 18:41:24 -07002307 return 0;
2308}
2309
2310int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302311static iw_softap_set_max_tx_power(struct net_device *dev,
2312 struct iw_request_info *info,
2313 union iwreq_data *wrqu, char *extra)
2314{
2315 int ret;
2316
2317 vos_ssr_protect(__func__);
2318 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2319 vos_ssr_unprotect(__func__);
2320
2321 return ret;
2322}
2323
2324
2325int
2326static __iw_display_data_path_snapshot(struct net_device *dev,
2327 struct iw_request_info *info,
2328 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302329{
2330
2331 /* Function intitiating dumping states of
2332 * HDD(WMM Tx Queues)
2333 * TL State (with Per Client infor)
2334 * DXE Snapshot (Called at the end of TL Snapshot)
2335 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302336 hdd_adapter_t *pHostapdAdapter;
2337 hdd_context_t *pHddCtx;
2338 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302339
2340 ENTER();
2341
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302342 pHostapdAdapter = (netdev_priv(dev));
2343 if (NULL == pHostapdAdapter)
2344 {
2345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2346 "%s: Adapter is NULL",__func__);
2347 return -EINVAL;
2348 }
2349 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2350 ret = wlan_hdd_validate_context(pHddCtx);
2351 if (0 != ret)
2352 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302353 return ret;
2354 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302355 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302356 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302357
2358 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302359 return 0;
2360}
2361
2362int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302363static iw_display_data_path_snapshot(struct net_device *dev,
2364 struct iw_request_info *info,
2365 union iwreq_data *wrqu, char *extra)
2366{
2367 int ret;
2368
2369 vos_ssr_protect(__func__);
2370 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2371 vos_ssr_unprotect(__func__);
2372
2373 return ret;
2374}
2375
2376int
2377static __iw_softap_set_tx_power(struct net_device *dev,
2378 struct iw_request_info *info,
2379 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002380{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302381 hdd_adapter_t *pHostapdAdapter;
2382 hdd_context_t *pHddCtx;
2383 v_CONTEXT_t pVosContext;
2384 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002385 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302386 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002387 ptSapContext pSapCtx = NULL;
2388
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302389 ENTER();
2390
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302391 pHostapdAdapter = (netdev_priv(dev));
2392 if (NULL == pHostapdAdapter)
2393 {
2394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2395 "%s: Adapter is NULL",__func__);
2396 return -EINVAL;
2397 }
2398 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2399 ret = wlan_hdd_validate_context(pHddCtx);
2400 if (0 != ret)
2401 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302402 return ret;
2403 }
2404 pVosContext = pHddCtx->pvosContext;
2405 if (NULL == pVosContext)
2406 {
2407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2408 "%s: Vos Context is NULL",__func__);
2409 return -EINVAL;
2410 }
2411 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2412 if (NULL == hHal)
2413 {
2414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2415 "%s: Hal Context is NULL",__func__);
2416 return -EINVAL;
2417 }
schang86c22c42013-03-13 18:41:24 -07002418 if (NULL == value)
2419 return -ENOMEM;
2420
2421 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2422 if (NULL == pSapCtx)
2423 {
2424 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2425 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2426 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002427 }
2428
2429 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002430 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002431 {
schang86c22c42013-03-13 18:41:24 -07002432 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002433 __func__);
2434 return -EIO;
2435 }
2436
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302437 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002438 return 0;
2439}
2440
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302441int
2442static iw_softap_set_tx_power(struct net_device *dev,
2443 struct iw_request_info *info,
2444 union iwreq_data *wrqu, char *extra)
2445{
2446 int ret;
2447
2448 vos_ssr_protect(__func__);
2449 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2450 vos_ssr_unprotect(__func__);
2451
2452 return ret;
2453}
2454
Kiet Lambcf38522013-10-26 18:28:27 +05302455/**---------------------------------------------------------------------------
2456
2457 \brief iw_softap_set_trafficmonitor() -
2458 This function dynamically enable/disable traffic monitor functonality
2459 the command iwpriv wlanX setTrafficMon <value>.
2460
2461 \param - dev - Pointer to the net device.
2462 - addr - Pointer to the sockaddr.
2463 \return - 0 for success, non zero for failure
2464
2465 --------------------------------------------------------------------------*/
2466
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302467static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2468 struct iw_request_info *info,
2469 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302470{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302471 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302472 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302473 hdd_context_t *pHddCtx;
2474 int status;
2475
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302476 ENTER();
2477
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302478 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302479 if (NULL == pAdapter)
2480 {
2481 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2482 "%s: HDD adapter is Null", __func__);
2483 return -ENODEV;
2484 }
2485
2486 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2487
2488 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302489 if (0 != status)
2490 {
Kiet Lambcf38522013-10-26 18:28:27 +05302491 return status;
2492 }
2493
2494 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2495
2496 if (NULL == isSetTrafficMon)
2497 {
2498 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2499 "%s: Invalid SAP pointer from extra", __func__);
2500 return -ENOMEM;
2501 }
2502
2503 if (TRUE == *isSetTrafficMon)
2504 {
2505 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2506 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2507 {
2508 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2509 "%s: failed to Start Traffic Monitor timer ", __func__ );
2510 return -EIO;
2511 }
2512 }
2513 else if (FALSE == *isSetTrafficMon)
2514 {
2515 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2516 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2517 {
2518 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2519 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2520 return -EIO;
2521 }
2522
2523 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302524
2525 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302526 return 0;
2527}
2528
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302529static int iw_softap_set_trafficmonitor(struct net_device *dev,
2530 struct iw_request_info *info,
2531 union iwreq_data *wrqu, char *extra)
2532{
2533 int ret;
2534
2535 vos_ssr_protect(__func__);
2536 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2537 vos_ssr_unprotect(__func__);
2538
2539 return ret;
2540}
2541
Jeff Johnson295189b2012-06-20 16:38:30 -07002542#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2543
2544int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302545static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2546 struct iw_request_info *info,
2547 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002548{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302549 hdd_adapter_t *pHostapdAdapter;
2550 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302551 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002552 char *buf;
2553 int cnt = 0;
2554 int left;
2555 int ret = 0;
2556 /* maclist_index must be u32 to match userspace */
2557 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302558 v_CONTEXT_t pVosContext = NULL;
2559 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302561 ENTER();
2562
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302563 pHostapdAdapter = (netdev_priv(dev));
2564 if (NULL == pHostapdAdapter)
2565 {
2566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2567 "%s: Adapter is NULL",__func__);
2568 return -EINVAL;
2569 }
2570 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2571 ret = wlan_hdd_validate_context(pHddCtx);
2572 if (0 != ret)
2573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302574 return ret;
2575 }
2576
Jeff Johnson224f3702014-03-26 11:09:47 -07002577 /*
2578 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2579 * number, and even numbered iocts are supposed to have "set"
2580 * semantics. Hence the wireless extensions support in the kernel
2581 * won't correctly copy the result to userspace, so the ioctl
2582 * handler itself must copy the data. Output format is 32-bit
2583 * record length, followed by 0 or more 6-byte STA MAC addresses.
2584 *
2585 * Further note that due to the incorrect semantics, the "iwpriv"
2586 * userspace application is unable to correctly invoke this API,
2587 * hence it is not registered in the hostapd_private_args. This
2588 * API can only be invoked by directly invoking the ioctl() system
2589 * call.
2590 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002591
Jeff Johnson224f3702014-03-26 11:09:47 -07002592 /* make sure userspace allocated a reasonable buffer size */
2593 if (wrqu->data.length < sizeof(maclist_index)) {
2594 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2595 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302598 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2599 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2600 if(pSapCtx == NULL){
2601 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2602 FL("psapCtx is NULL"));
2603 return -EFAULT;
2604 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302605
2606 /* allocate local buffer to build the response */
2607 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2608 if (!buf) {
2609 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2610 return -ENOMEM;
2611 }
2612
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302613 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002614 /* start indexing beyond where the record count will be written */
2615 maclist_index = sizeof(maclist_index);
2616 left = wrqu->data.length - maclist_index;
2617
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302618 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002619 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2620 if ((pStaInfo[cnt].isUsed) &&
2621 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2622 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2623 VOS_MAC_ADDR_SIZE);
2624 maclist_index += VOS_MAC_ADDR_SIZE;
2625 left -= VOS_MAC_ADDR_SIZE;
2626 }
2627 cnt++;
2628 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302629 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002630
2631 *((u32 *)buf) = maclist_index;
2632 wrqu->data.length = maclist_index;
2633 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2634 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2635 ret = -EFAULT;
2636 }
2637 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302638
2639 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002640 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641}
2642
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302643int
2644static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2645 struct iw_request_info *info,
2646 union iwreq_data *wrqu, char *extra)
2647{
2648 int ret;
2649
2650 vos_ssr_protect(__func__);
2651 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2652 vos_ssr_unprotect(__func__);
2653
2654 return ret;
2655}
2656
Jeff Johnson295189b2012-06-20 16:38:30 -07002657/* Usage:
2658 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2659 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2660 while using this ioctl
2661
2662 Syntax:
2663 iwpriv softap.0 disassoc_sta <6 octet mac address>
2664
2665 e.g.
2666 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2667 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2668*/
2669
2670int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302671static __iw_softap_disassoc_sta(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002674{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302675 hdd_adapter_t *pHostapdAdapter;
2676 hdd_context_t *pHddCtx;
2677 v_U8_t *peerMacAddr;
2678 int ret = 0;
2679
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302681
2682 if (!capable(CAP_NET_ADMIN)) {
2683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2684 FL("permission check failed"));
2685 return -EPERM;
2686 }
2687
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302688 pHostapdAdapter = (netdev_priv(dev));
2689 if (NULL == pHostapdAdapter)
2690 {
2691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2692 "%s: Adapter is NULL",__func__);
2693 return -EINVAL;
2694 }
2695 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2696 ret = wlan_hdd_validate_context(pHddCtx);
2697 if (0 != ret)
2698 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302699 return ret;
2700 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302701 /* iwpriv tool or framework calls this ioctl with
2702 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302704 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002705
Arif Hussain24bafea2013-11-15 15:10:03 -08002706 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2707 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2709 EXIT();
2710 return 0;
2711}
2712
2713int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302714static iw_softap_disassoc_sta(struct net_device *dev,
2715 struct iw_request_info *info,
2716 union iwreq_data *wrqu, char *extra)
2717{
2718 int ret;
2719
2720 vos_ssr_protect(__func__);
2721 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2722 vos_ssr_unprotect(__func__);
2723
2724 return ret;
2725}
2726
2727int
2728static __iw_softap_ap_stats(struct net_device *dev,
2729 struct iw_request_info *info,
2730 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002731{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302732 hdd_adapter_t *pHostapdAdapter;
2733 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 WLANTL_TRANSFER_STA_TYPE statBuffer;
2735 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302736 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002737
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302738 ENTER();
2739
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 pHostapdAdapter = (netdev_priv(dev));
2741 if (NULL == pHostapdAdapter)
2742 {
2743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2744 "%s: Adapter is NULL",__func__);
2745 return -EINVAL;
2746 }
2747 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2748 ret = wlan_hdd_validate_context(pHddCtx);
2749 if (0 != ret)
2750 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302751 return ret;
2752 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002753 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002754 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2755 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002756
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302757 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002758 if(NULL == pstatbuf) {
2759 hddLog(LOG1, "unable to allocate memory");
2760 return -ENOMEM;
2761 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302762
2763 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002764 "RUF=%d RMF=%d RBF=%d "
2765 "RUB=%d RMB=%d RBB=%d "
2766 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302767 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002768 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2769 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2770 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2771 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2772 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2773 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302775 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002776 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2777 kfree(pstatbuf);
2778 return -EFAULT;
2779 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302780
2781 strlcpy(extra, pstatbuf, len);
2782 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002783 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302784
2785 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 return 0;
2787}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302788int
2789static __iw_softap_ap_get_stats(struct net_device *dev,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra)
2792{
2793 hdd_adapter_t *pAdapter;
2794 hdd_tx_rx_stats_t *pStats;
2795
2796 ENTER();
2797 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2798 if (NULL == pAdapter)
2799 {
2800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2801 "%s: Adapter is NULL",__func__);
2802 return -EINVAL;
2803 }
2804
2805 pStats = &pAdapter->hdd_stats.hddTxRxStats;
2806 snprintf(extra, QCSAP_MAX_STR_LEN,
2807 "\nTransmit"
2808 "\ncalled %u, dropped %u, backpressured %u, queued %u"
2809 "\n dropped BK %u, BE %u, VI %u, VO %u"
2810 "\n classified BK %u, BE %u, VI %u, VO %u"
2811 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
2812 "\n queued BK %u, BE %u, VI %u, VO %u"
2813 "\nfetched %u, empty %u, lowres %u, deqerr %u"
2814 "\ndequeued %u, depressured %u, deque-depressured %u,\
2815 completed %u, flushed %u"
2816 "\n fetched BK %u, BE %u, VI %u, VO %u"
2817 "\n dequeued BK %u, BE %u, VI %u, VO %u"
2818 "\n depressured BK %u, BE %u, VI %u, VO %u"
2819 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
2820 "\n flushed BK %u, BE %u, VI %u, VO %u"
2821 "\n\nReceive"
2822 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
2823 "\n\nResetsStats"
2824 "\n",
2825 pStats->txXmitCalled,
2826 pStats->txXmitDropped,
2827 pStats->txXmitBackPressured,
2828 pStats->txXmitQueued,
2829
2830 pStats->txXmitDroppedAC[WLANTL_AC_BK],
2831 pStats->txXmitDroppedAC[WLANTL_AC_BE],
2832 pStats->txXmitDroppedAC[WLANTL_AC_VI],
2833 pStats->txXmitDroppedAC[WLANTL_AC_VO],
2834
2835 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
2836 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
2837 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
2838 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
2839
2840 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
2841 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
2842 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
2843 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
2844
2845 pStats->txXmitQueuedAC[WLANTL_AC_BK],
2846 pStats->txXmitQueuedAC[WLANTL_AC_BE],
2847 pStats->txXmitQueuedAC[WLANTL_AC_VI],
2848 pStats->txXmitQueuedAC[WLANTL_AC_VO],
2849
2850 pStats->txFetched,
2851 pStats->txFetchEmpty,
2852 pStats->txFetchLowResources,
2853 pStats->txFetchDequeueError,
2854
2855 pStats->txFetchDequeued,
2856 pStats->txFetchDePressured,
2857 pStats->txDequeDePressured,
2858 pStats->txCompleted,
2859 pStats->txFlushed,
2860
2861 pStats->txFetchedAC[WLANTL_AC_BK],
2862 pStats->txFetchedAC[WLANTL_AC_BE],
2863 pStats->txFetchedAC[WLANTL_AC_VI],
2864 pStats->txFetchedAC[WLANTL_AC_VO],
2865
2866 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
2867 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
2868 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
2869 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
2870
2871 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
2872 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
2873 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
2874 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
2875
2876 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
2877 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
2878 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
2879 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
2880
2881 pStats->txFlushedAC[WLANTL_AC_BK],
2882 pStats->txFlushedAC[WLANTL_AC_BE],
2883 pStats->txFlushedAC[WLANTL_AC_VI],
2884 pStats->txFlushedAC[WLANTL_AC_VO],
2885
2886 pStats->rxChains,
2887 pStats->rxPackets,
2888 pStats->rxDropped,
2889 pStats->rxDelivered,
2890 pStats->rxRefused
2891 );
2892
2893 wrqu->data.length = strlen(extra) + 1;
2894
2895 return 0;
2896}
2897
2898int
2899static __iw_softap_ap_clear_stats(struct net_device *dev,
2900 struct iw_request_info *info,
2901 union iwreq_data *wrqu, char *extra)
2902{
2903 hdd_adapter_t *pAdapter;
2904
2905 ENTER();
2906
2907 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2908 if (NULL == pAdapter)
2909 {
2910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2911 "%s: Adapter is NULL",__func__);
2912 return -EINVAL;
2913 }
2914
2915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
2916 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
2917 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
2918 return 0;
2919}
2920
2921
2922int
2923static iw_softap_get_stats(struct net_device *dev,
2924 struct iw_request_info *info,
2925 union iwreq_data *wrqu, char *extra)
2926{
2927 int ret;
2928 vos_ssr_protect(__func__);
2929 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
2930 vos_ssr_unprotect(__func__);
2931 return ret;
2932}
2933
2934int
2935static iw_softap_clear_stats(struct net_device *dev,
2936 struct iw_request_info *info,
2937 union iwreq_data *wrqu, char *extra)
2938{
2939 int ret;
2940 vos_ssr_protect(__func__);
2941 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
2942 vos_ssr_unprotect(__func__);
2943 return ret;
2944}
Jeff Johnson295189b2012-06-20 16:38:30 -07002945
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302946int
2947static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 struct iw_request_info *info,
2949 union iwreq_data *wrqu, char *extra)
2950{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302951 int ret;
2952
2953 vos_ssr_protect(__func__);
2954 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2955 vos_ssr_unprotect(__func__);
2956
2957 return ret;
2958}
2959
2960static int __iw_softap_set_channel_range(struct net_device *dev,
2961 struct iw_request_info *info,
2962 union iwreq_data *wrqu, char *extra)
2963{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302964 hdd_adapter_t *pHostapdAdapter;
2965 tHalHandle hHal;
2966 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 int *value = (int *)extra;
2968 int startChannel = value[0];
2969 int endChannel = value[1];
2970 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002971 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 int ret = 0; /* success */
2973
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302974 ENTER();
2975
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05302976 if (!capable(CAP_NET_ADMIN))
2977 {
2978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2979 FL("permission check failed"));
2980 return -EPERM;
2981 }
2982
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302983 pHostapdAdapter = (netdev_priv(dev));
2984 if (NULL == pHostapdAdapter)
2985 {
2986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2987 "%s: Adapter is NULL",__func__);
2988 return -EINVAL;
2989 }
2990 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2991 ret = wlan_hdd_validate_context(pHddCtx);
2992 if (0 != ret)
2993 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302994 return ret;
2995 }
2996 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2997 if (NULL == hHal)
2998 {
2999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3000 "%s: Hal Context is NULL",__func__);
3001 return -EINVAL;
3002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3004 if(status != VOS_STATUS_SUCCESS)
3005 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003006 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 startChannel,endChannel, band);
3008 ret = -EINVAL;
3009 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003010
3011 pHddCtx->is_dynamic_channel_range_set = 1;
3012
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303013 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 return ret;
3015}
3016
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303017static int iw_softap_set_channel_range(struct net_device *dev,
3018 struct iw_request_info *info,
3019 union iwreq_data *wrqu, char *extra)
3020{
3021 int ret;
3022
3023 vos_ssr_protect(__func__);
3024 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3025 vos_ssr_unprotect(__func__);
3026
3027 return ret;
3028}
3029
3030
3031int __iw_softap_get_channel_list(struct net_device *dev,
3032 struct iw_request_info *info,
3033 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003034{
3035 v_U32_t num_channels = 0;
3036 v_U8_t i = 0;
3037 v_U8_t bandStartChannel = RF_CHAN_1;
3038 v_U8_t bandEndChannel = RF_CHAN_165;
3039 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303040 hdd_adapter_t *pHostapdAdapter;
3041 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003044 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303045 hdd_context_t *pHddCtx;
3046 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303047
3048 ENTER();
3049
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303050 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3051 if (NULL == pHostapdAdapter)
3052 {
3053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3054 "%s: Adapter is NULL",__func__);
3055 return -EINVAL;
3056 }
3057 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3058 ret = wlan_hdd_validate_context(pHddCtx);
3059 if (0 != ret)
3060 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303061 return ret;
3062 }
3063 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3064 if (NULL == hHal)
3065 {
3066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3067 "%s: Hal Context is NULL",__func__);
3068 return -EINVAL;
3069 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003070 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3071 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003072 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003073 return -EIO;
3074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 wrqu->data.length = sizeof(tChannelListInfo);
3076 ENTER();
3077
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003078 if (eCSR_BAND_24 == curBand)
3079 {
3080 bandStartChannel = RF_CHAN_1;
3081 bandEndChannel = RF_CHAN_14;
3082 }
3083 else if (eCSR_BAND_5G == curBand)
3084 {
3085 bandStartChannel = RF_CHAN_36;
3086 bandEndChannel = RF_CHAN_165;
3087 }
3088
Arif Hussain6d2a3322013-11-17 19:50:10 -08003089 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303090 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003091 bandStartChannel, bandEndChannel );
3092
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3094 {
3095 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3096 {
3097 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3098 num_channels++;
3099 }
3100 }
3101
3102 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3103
3104 temp_num_channels = num_channels;
3105
3106 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3107 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303108 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003109 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 }
3111
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303112 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3113 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 {
3115 for(i = 0; i < temp_num_channels; i++)
3116 {
3117
3118 if((channel_list->channels[i] > 35) &&
3119 (channel_list->channels[i] < 49))
3120 {
3121 vos_mem_move(&channel_list->channels[i],
3122 &channel_list->channels[i+1],
3123 temp_num_channels - (i-1));
3124 num_channels--;
3125 temp_num_channels--;
3126 i--;
3127 }
3128 }
3129 }
3130
Arif Hussain6d2a3322013-11-17 19:50:10 -08003131 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003132
3133 if (num_channels > IW_MAX_FREQUENCIES)
3134 {
3135 num_channels = IW_MAX_FREQUENCIES;
3136 }
3137
3138 channel_list->num_channels = num_channels;
3139 EXIT();
3140
3141 return 0;
3142}
3143
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303144int iw_softap_get_channel_list(struct net_device *dev,
3145 struct iw_request_info *info,
3146 union iwreq_data *wrqu, char *extra)
3147{
3148 int ret;
3149
3150 vos_ssr_protect(__func__);
3151 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3152 vos_ssr_unprotect(__func__);
3153
3154 return ret;
3155}
3156
3157static
3158int __iw_get_genie(struct net_device *dev,
3159 struct iw_request_info *info,
3160 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003161{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303162 hdd_adapter_t *pHostapdAdapter;
3163 hdd_context_t *pHddCtx;
3164 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 eHalStatus status;
3166 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3167 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303168 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303169
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303171
3172 pHostapdAdapter = (netdev_priv(dev));
3173 if (NULL == pHostapdAdapter)
3174 {
3175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3176 "%s: Adapter is NULL",__func__);
3177 return -EINVAL;
3178 }
3179 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3180 ret = wlan_hdd_validate_context(pHddCtx);
3181 if (0 != ret)
3182 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303183 return ret;
3184 }
3185 pVosContext = pHddCtx->pvosContext;
3186 if (NULL == pVosContext)
3187 {
3188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3189 "%s: vos context is not valid ",__func__);
3190 return -EINVAL;
3191 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003192 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3194 status = WLANSap_getstationIE_information(pVosContext,
3195 &length,
3196 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003197 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3198 if (wrqu->data.length < length ||
3199 copy_to_user(wrqu->data.pointer,
3200 (v_VOID_t*)genIeBytes, length))
3201 {
3202 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3203 return -EFAULT;
3204 }
3205 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003206
Arif Hussain6d2a3322013-11-17 19:50:10 -08003207 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003208
3209
3210 EXIT();
3211 return 0;
3212}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303213
3214static
3215int iw_get_genie(struct net_device *dev,
3216 struct iw_request_info *info,
3217 union iwreq_data *wrqu, char *extra)
3218{
3219 int ret;
3220
3221 vos_ssr_protect(__func__);
3222 ret = __iw_get_genie(dev, info, wrqu, extra);
3223 vos_ssr_unprotect(__func__);
3224
3225 return ret;
3226}
3227
3228static
3229int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3230 struct iw_request_info *info,
3231 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003232{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303233 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003234 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303235 hdd_ap_ctx_t *pHddApCtx;
3236 hdd_context_t *pHddCtx;
3237 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303238
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003240
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303241 pHostapdAdapter = (netdev_priv(dev));
3242 if (NULL == pHostapdAdapter)
3243 {
3244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3245 "%s: Adapter is NULL",__func__);
3246 return -EINVAL;
3247 }
3248 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3249 ret = wlan_hdd_validate_context(pHddCtx);
3250 if (0 != ret)
3251 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303252 return ret;
3253 }
3254 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3255 if (NULL == pHddApCtx)
3256 {
3257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3258 "%s: AP context is NULL",__func__);
3259 return -EINVAL;
3260 }
3261
Arif Hussain6d2a3322013-11-17 19:50:10 -08003262 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003263 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3264
3265 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3266 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3267 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3268 WPSPBCProbeReqIEs.probeReqIELen);
3269 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3270 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3271 sizeof(v_MACADDR_t));
3272 if (copy_to_user(wrqu->data.pointer,
3273 (void *)&WPSPBCProbeReqIEs,
3274 sizeof(WPSPBCProbeReqIEs)))
3275 {
3276 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3277 return -EFAULT;
3278 }
3279 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003280 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003281 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 up(&pHddApCtx->semWpsPBCOverlapInd);
3283 EXIT();
3284 return 0;
3285}
3286
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303287static
3288int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3289 struct iw_request_info *info,
3290 union iwreq_data *wrqu, char *extra)
3291{
3292 int ret;
3293
3294 vos_ssr_protect(__func__);
3295 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3296 vos_ssr_unprotect(__func__);
3297
3298 return ret;
3299}
3300
Jeff Johnson295189b2012-06-20 16:38:30 -07003301/**---------------------------------------------------------------------------
3302
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303303 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 This function sets the auth type received from the wpa_supplicant.
3305
3306 \param - dev - Pointer to the net device.
3307 - info - Pointer to the iw_request_info.
3308 - wrqu - Pointer to the iwreq_data.
3309 - extra - Pointer to the data.
3310 \return - 0 for success, non zero for failure
3311
3312 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303313int __iw_set_auth_hostap(struct net_device *dev,
3314 struct iw_request_info *info,
3315 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003316{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303317 hdd_adapter_t *pAdapter;
3318 hdd_context_t *pHddCtx;
3319 hdd_wext_state_t *pWextState;
3320 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303321
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303323
3324 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3325 if (NULL == pAdapter)
3326 {
3327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3328 "%s: Adapter is NULL",__func__);
3329 return -EINVAL;
3330 }
3331
3332 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3333 ret = wlan_hdd_validate_context(pHddCtx);
3334 if (0 != ret)
3335 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303336 return ret;
3337 }
3338 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3339 if (NULL == pWextState)
3340 {
3341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3342 "%s: pWextState is NULL",__func__);
3343 return -EINVAL;
3344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 switch(wrqu->param.flags & IW_AUTH_INDEX)
3346 {
3347 case IW_AUTH_TKIP_COUNTERMEASURES:
3348 {
3349 if(wrqu->param.value) {
3350 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3351 "Counter Measure started %d", wrqu->param.value);
3352 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303353 }
3354 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3356 "Counter Measure stopped=%d", wrqu->param.value);
3357 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3358 }
3359
3360 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3361 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303364
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303366
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003367 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 wrqu->param.flags & IW_AUTH_INDEX);
3369 break;
3370 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303371
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 EXIT();
3373 return 0;
3374}
3375
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303376int iw_set_auth_hostap(struct net_device *dev,
3377 struct iw_request_info *info,
3378 union iwreq_data *wrqu,char *extra)
3379{
3380 int ret;
3381
3382 vos_ssr_protect(__func__);
3383 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3384 vos_ssr_unprotect(__func__);
3385
3386 return ret;
3387}
3388
3389static int __iw_set_ap_encodeext(struct net_device *dev,
3390 struct iw_request_info *info,
3391 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003392{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303393 hdd_adapter_t *pHostapdAdapter;
3394 v_CONTEXT_t pVosContext;
3395 hdd_context_t *pHddCtx;
3396 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003397 int retval = 0;
3398 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3400 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3401 int key_index;
3402 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303403 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003404// tCsrRoamRemoveKey RemoveKey;
3405 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303406
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303407 ENTER();
3408 pHostapdAdapter = (netdev_priv(dev));
3409 if (NULL == pHostapdAdapter)
3410 {
3411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3412 "%s: Adapter is NULL",__func__);
3413 return -EINVAL;
3414 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003415
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303416 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3417 retval = wlan_hdd_validate_context(pHddCtx);
3418 if (0 != retval)
3419 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303420 return retval;
3421 }
3422 pVosContext = pHddCtx->pvosContext;
3423 if (NULL == pVosContext)
3424 {
3425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3426 "%s: pVosContext is NULL",__func__);
3427 return -EINVAL;
3428 }
3429 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3430 if (NULL == pHddApCtx)
3431 {
3432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3433 "%s: AP Context is NULL",__func__);
3434 return -EINVAL;
3435 }
3436
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303438
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303440
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 /*Convert from 1-based to 0-based keying*/
3442 key_index--;
3443 }
3444 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303445#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 /*Set the encrytion type to NONE*/
3447#if 0
3448 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3449#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303450
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 RemoveKey.keyId = key_index;
3452 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3453 /*Key direction for group is RX only*/
3454 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3455 }
3456 else {
3457 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3458 }
3459 switch(ext->alg)
3460 {
3461 case IW_ENCODE_ALG_NONE:
3462 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3463 break;
3464 case IW_ENCODE_ALG_WEP:
3465 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3466 break;
3467 case IW_ENCODE_ALG_TKIP:
3468 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003469 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 case IW_ENCODE_ALG_CCMP:
3471 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3472 break;
3473 default:
3474 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3475 break;
3476 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003477 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 -07003478 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003480 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003482 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3483 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 {
3485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003486 __LINE__, vstatus );
3487 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003489#endif
3490 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003491
Jeff Johnson43971f52012-07-17 12:26:56 -07003492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003493
3494 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3495
3496 setKey.keyId = key_index;
3497 setKey.keyLength = ext->key_len;
3498
3499 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3500 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3501 }
3502
3503 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3504 /*Key direction for group is RX only*/
3505 setKey.keyDirection = eSIR_RX_ONLY;
3506 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3507 }
3508 else {
3509
3510 setKey.keyDirection = eSIR_TX_RX;
3511 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3512 }
3513 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3514 {
3515 setKey.keyDirection = eSIR_TX_DEFAULT;
3516 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3517 }
3518
3519 /*For supplicant pae role is zero*/
3520 setKey.paeRole = 0;
3521
3522 switch(ext->alg)
3523 {
3524 case IW_ENCODE_ALG_NONE:
3525 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3526 break;
3527
3528 case IW_ENCODE_ALG_WEP:
3529 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3530 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003531 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 break;
3533
3534 case IW_ENCODE_ALG_TKIP:
3535 {
3536 v_U8_t *pKey = &setKey.Key[0];
3537
3538 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3539
3540 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3541
3542 /*Supplicant sends the 32bytes key in this order
3543
3544 |--------------|----------|----------|
3545 | Tk1 |TX-MIC | RX Mic |
3546 |--------------|----------|----------|
3547 <---16bytes---><--8bytes--><--8bytes-->
3548
3549 */
3550 /*Sme expects the 32 bytes key to be in the below order
3551
3552 |--------------|----------|----------|
3553 | Tk1 |RX-MIC | TX Mic |
3554 |--------------|----------|----------|
3555 <---16bytes---><--8bytes--><--8bytes-->
3556 */
3557 /* Copy the Temporal Key 1 (TK1) */
3558 vos_mem_copy(pKey,ext->key,16);
3559
3560 /*Copy the rx mic first*/
3561 vos_mem_copy(&pKey[16],&ext->key[24],8);
3562
3563 /*Copy the tx mic */
3564 vos_mem_copy(&pKey[24],&ext->key[16],8);
3565
3566 }
3567 break;
3568
3569 case IW_ENCODE_ALG_CCMP:
3570 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3571 break;
3572
3573 default:
3574 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3575 break;
3576 }
3577
3578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303579 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 setKey.keyId);
3581 for(i=0; i< ext->key_len; i++)
3582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3583 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003584
3585 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3586 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 {
3588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003589 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3590 retval = -EINVAL;
3591 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303592
3593 EXIT();
3594 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003595}
Jeff Johnson43971f52012-07-17 12:26:56 -07003596
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303597static int iw_set_ap_encodeext(struct net_device *dev,
3598 struct iw_request_info *info,
3599 union iwreq_data *wrqu, char *extra)
3600{
3601 int ret;
3602
3603 vos_ssr_protect(__func__);
3604 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3605 vos_ssr_unprotect(__func__);
3606
3607 return ret;
3608}
Jeff Johnson43971f52012-07-17 12:26:56 -07003609
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303610static int __iw_set_ap_mlme(struct net_device *dev,
3611 struct iw_request_info *info,
3612 union iwreq_data *wrqu,
3613 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003614{
3615#if 0
3616 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3617 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3618
3619 ENTER();
3620
3621 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3622 switch (mlme->cmd) {
3623 case IW_MLME_DISASSOC:
3624 case IW_MLME_DEAUTH:
3625 hddLog(LOG1, "Station disassociate");
3626 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3627 {
3628 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3629
3630 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3631 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3632
3633 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3634
3635 //clear all the reason codes
3636 if (status != 0)
3637 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003638 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 }
3640
3641 netif_stop_queue(dev);
3642 netif_carrier_off(dev);
3643 }
3644 else
3645 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003646 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 -07003647 }
3648 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003649 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 return -EINVAL;
3651 }//end of switch
3652 EXIT();
3653#endif
3654 return 0;
3655// return status;
3656}
3657
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303658static int iw_set_ap_mlme(struct net_device *dev,
3659 struct iw_request_info *info,
3660 union iwreq_data *wrqu,
3661 char *extra)
3662{
3663 int ret;
3664
3665 vos_ssr_protect(__func__);
3666 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3667 vos_ssr_unprotect(__func__);
3668
3669 return ret;
3670}
3671
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303672static int __iw_get_ap_rts_threshold(struct net_device *dev,
3673 struct iw_request_info *info,
3674 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003675{
3676 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3677 v_U32_t status = 0;
3678
3679 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3680
3681 return status;
3682}
3683
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303684static int iw_get_ap_rts_threshold(struct net_device *dev,
3685 struct iw_request_info *info,
3686 union iwreq_data *wrqu, char *extra)
3687{
3688 int ret;
3689
3690 vos_ssr_protect(__func__);
3691 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3692 vos_ssr_unprotect(__func__);
3693
3694 return ret;
3695}
3696
3697static int __iw_get_ap_frag_threshold(struct net_device *dev,
3698 struct iw_request_info *info,
3699 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003700{
3701 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3702 v_U32_t status = 0;
3703
3704 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3705
3706 return status;
3707}
3708
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303709static int iw_get_ap_frag_threshold(struct net_device *dev,
3710 struct iw_request_info *info,
3711 union iwreq_data *wrqu, char *extra)
3712{
3713 int ret;
3714
3715 vos_ssr_protect(__func__);
3716 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3717 vos_ssr_unprotect(__func__);
3718
3719 return ret;
3720}
3721
3722static int __iw_get_ap_freq(struct net_device *dev,
3723 struct iw_request_info *info,
3724 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003725{
Jeff Johnsone7245742012-09-05 17:12:55 -07003726 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303727 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 tHalHandle hHal;
3729 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303730 hdd_ap_ctx_t *pHddApCtx;
3731 hdd_context_t *pHddCtx;
3732 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003733
3734 ENTER();
3735
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303736 pHostapdAdapter = (netdev_priv(dev));
3737 if (NULL == pHostapdAdapter)
3738 {
3739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3740 "%s: Adapter is NULL",__func__);
3741 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303743 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3744 ret = wlan_hdd_validate_context(pHddCtx);
3745 if (0 != ret)
3746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303747 return ret;
3748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303750 if (NULL == pHostapdState)
3751 {
3752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3753 "%s: pHostapdState is NULL",__func__);
3754 return -EINVAL;
3755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303757 if (NULL == hHal)
3758 {
3759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3760 "%s: Hal Context is NULL",__func__);
3761 return -EINVAL;
3762 }
3763 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3764 if (NULL == pHddApCtx)
3765 {
3766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3767 "%s: AP context is NULL",__func__);
3768 return -EINVAL;
3769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 if(pHostapdState->bssState == BSS_STOP )
3771 {
3772 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3773 != eHAL_STATUS_SUCCESS)
3774 {
c_hpothuffdb5272013-10-02 16:42:35 +05303775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3776 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 return -EIO;
3778 }
3779 else
3780 {
3781 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003782 if( TRUE == status)
3783 {
3784 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3785 * iwlist & iwconfig command shows frequency into proper
3786 * format (2.412 GHz instead of 246.2 MHz)*/
3787 fwrq->m = freq;
3788 fwrq->e = MHZ;
3789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 }
3791 }
3792 else
3793 {
3794 channel = pHddApCtx->operatingChannel;
3795 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003796 if( TRUE == status)
3797 {
3798 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3799 * iwlist & iwconfig command shows frequency into proper
3800 * format (2.412 GHz instead of 246.2 MHz)*/
3801 fwrq->m = freq;
3802 fwrq->e = MHZ;
3803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303805
3806 EXIT();
3807 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003808}
3809
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303810static int iw_get_ap_freq(struct net_device *dev,
3811 struct iw_request_info *info,
3812 struct iw_freq *fwrq, char *extra)
3813{
3814 int ret;
3815
3816 vos_ssr_protect(__func__);
3817 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3818 vos_ssr_unprotect(__func__);
3819
3820 return ret;
3821}
3822
3823static int __iw_get_mode(struct net_device *dev,
3824 struct iw_request_info *info,
3825 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303826{
3827 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303828 hdd_adapter_t *pAdapter;
3829 hdd_context_t *pHddCtx;
3830
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303831 ENTER();
3832
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303833 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3834 if (NULL == pAdapter)
3835 {
3836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3837 "%s: Adapter is NULL",__func__);
3838 return -EINVAL;
3839 }
3840 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3841 status = wlan_hdd_validate_context(pHddCtx);
3842 if (0 != status)
3843 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303844 return status;
3845 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303846
3847 wrqu->mode = IW_MODE_MASTER;
3848
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303849 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303850 return status;
3851}
3852
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303853static int iw_get_mode(struct net_device *dev,
3854 struct iw_request_info *info,
3855 union iwreq_data *wrqu, char *extra)
3856{
3857 int ret;
3858
3859 vos_ssr_protect(__func__);
3860 ret = __iw_get_mode(dev, info, wrqu, extra);
3861 vos_ssr_unprotect(__func__);
3862
3863 return ret;
3864}
3865
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303866static int __iw_softap_setwpsie(struct net_device *dev,
3867 struct iw_request_info *info,
3868 union iwreq_data *wrqu,
3869 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003870{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303871 hdd_adapter_t *pHostapdAdapter;
3872 hdd_context_t *pHddCtx;
3873 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 hdd_hostapd_state_t *pHostapdState;
3875 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003876 u_int8_t *wps_genie;
3877 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 u_int8_t *pos;
3879 tpSap_WPSIE pSap_WPSIe;
3880 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303881 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303882 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303883 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303884
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 ENTER();
3886
Hanumantha Reddy Pothulac9b12d92015-10-27 22:55:07 +05303887 if (!capable(CAP_NET_ADMIN))
3888 {
3889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3890 FL("permission check failed"));
3891 return -EPERM;
3892 }
3893
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303894 pHostapdAdapter = (netdev_priv(dev));
3895 if (NULL == pHostapdAdapter)
3896 {
3897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3898 "%s: Adapter is NULL",__func__);
3899 return -EINVAL;
3900 }
3901 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3902 ret = wlan_hdd_validate_context(pHddCtx);
3903 if (0 != ret)
3904 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303905 return ret;
3906 }
3907 pVosContext = pHddCtx->pvosContext;
3908 if (NULL == pVosContext)
3909 {
3910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3911 "%s: HDD context is not valid ",__func__);
3912 return -EINVAL;
3913 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303914 /* helper function to get iwreq_data with compat handling. */
3915 if (hdd_priv_get_data(&s_priv_data, wrqu))
3916 {
3917 return -EINVAL;
3918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003919
Girish Gowli07c05ec2014-06-17 20:47:03 +05303920 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3921 {
3922 return -EINVAL;
3923 }
3924
3925 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3926 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003927
Girish Gowli86c471e2014-06-17 19:28:05 +05303928 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003929 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303930 hddLog(LOG1, "%s: failed to alloc memory "
3931 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003932 return -EFAULT;
3933 }
3934
Girish Gowli86c471e2014-06-17 19:28:05 +05303935 fwps_genie = wps_genie;
3936
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3938 if (NULL == pSap_WPSIe)
3939 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003940 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003941 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 return -ENOMEM;
3943 }
3944 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3945
Arif Hussain6d2a3322013-11-17 19:50:10 -08003946 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 -07003947 WPSIeType = wps_genie[0];
3948 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3949 {
3950 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3951 wps_genie = wps_genie + 1;
3952 switch ( wps_genie[0] )
3953 {
3954 case DOT11F_EID_WPA:
3955 if (wps_genie[1] < 2 + 4)
3956 {
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05303957 ret = -EINVAL;
3958 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 }
3960 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3961 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003962 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 pos = &wps_genie[6];
3964 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3965 {
3966 switch((u_int16_t)(*pos<<8) | *(pos+1))
3967 {
3968 case HDD_WPS_ELEM_VERSION:
3969 pos += 4;
3970 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003971 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3973 pos += 1;
3974 break;
3975
3976 case HDD_WPS_ELEM_WPS_STATE:
3977 pos +=4;
3978 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003979 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
3981 pos += 1;
3982 break;
3983 case HDD_WPS_ELEM_APSETUPLOCK:
3984 pos += 4;
3985 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003986 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
3988 pos += 1;
3989 break;
3990 case HDD_WPS_ELEM_SELECTEDREGISTRA:
3991 pos += 4;
3992 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003993 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
3995 pos += 1;
3996 break;
3997 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
3998 pos += 4;
3999 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004000 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
4002 pos += 2;
4003 break;
4004 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4005 pos += 4;
4006 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004007 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
4009 pos += 2;
4010 break;
4011
4012 case HDD_WPS_ELEM_UUID_E:
4013 pos += 2;
4014 length = *pos<<8 | *(pos+1);
4015 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304016 if (length > sizeof(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E))
4017 {
4018 ret = -EINVAL;
4019 goto exit;
4020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
4022 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
4023 pos += length;
4024 break;
4025 case HDD_WPS_ELEM_RF_BANDS:
4026 pos += 4;
4027 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004028 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
4030 pos += 1;
4031 break;
4032
4033 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004034 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304035 ret = -EINVAL;
4036 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 }
4038 }
4039 }
4040 else {
4041 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004042 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 }
4044 break;
4045
4046 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004047 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304048 ret = -EINVAL;
4049 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 }
4051 }
4052 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
4053 {
4054 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
4055 wps_genie = wps_genie + 1;
4056 switch ( wps_genie[0] )
4057 {
4058 case DOT11F_EID_WPA:
4059 if (wps_genie[1] < 2 + 4)
4060 {
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304061 ret = -EINVAL;
4062 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 }
4064 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
4065 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004066 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 pos = &wps_genie[6];
4068 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
4069 {
4070 switch((u_int16_t)(*pos<<8) | *(pos+1))
4071 {
4072 case HDD_WPS_ELEM_VERSION:
4073 pos += 4;
4074 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004075 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
4077 pos += 1;
4078 break;
4079
4080 case HDD_WPS_ELEM_WPS_STATE:
4081 pos +=4;
4082 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004083 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
4085 pos += 1;
4086 break;
4087 case HDD_WPS_ELEM_APSETUPLOCK:
4088 pos += 4;
4089 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004090 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
4092 pos += 1;
4093 break;
4094 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4095 pos += 4;
4096 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004097 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
4099 pos += 1;
4100 break;
4101 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4102 pos += 4;
4103 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004104 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
4106 pos += 2;
4107 break;
4108 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4109 pos += 4;
4110 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004111 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
4113 pos += 2;
4114 break;
4115 case HDD_WPS_ELEM_RSP_TYPE:
4116 pos += 4;
4117 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004118 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
4120 pos += 1;
4121 break;
4122 case HDD_WPS_ELEM_UUID_E:
4123 pos += 2;
4124 length = *pos<<8 | *(pos+1);
4125 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304126 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E)))
4127 {
4128 ret = -EINVAL;
4129 goto exit;
4130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
4132 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
4133 pos += length;
4134 break;
4135
4136 case HDD_WPS_ELEM_MANUFACTURER:
4137 pos += 2;
4138 length = *pos<<8 | *(pos+1);
4139 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304140 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name)))
4141 {
4142 ret = -EINVAL;
4143 goto exit;
4144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
4146 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
4147 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
4148 pos += length;
4149 break;
4150
4151 case HDD_WPS_ELEM_MODEL_NAME:
4152 pos += 2;
4153 length = *pos<<8 | *(pos+1);
4154 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304155 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text)))
4156 {
4157 ret = -EINVAL;
4158 goto exit;
4159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
4161 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
4162 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
4163 pos += length;
4164 break;
4165 case HDD_WPS_ELEM_MODEL_NUM:
4166 pos += 2;
4167 length = *pos<<8 | *(pos+1);
4168 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304169 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text)))
4170 {
4171 ret = -EINVAL;
4172 goto exit;
4173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
4175 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
4176 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
4177 pos += length;
4178 break;
4179 case HDD_WPS_ELEM_SERIAL_NUM:
4180 pos += 2;
4181 length = *pos<<8 | *(pos+1);
4182 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304183 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text)))
4184 {
4185 ret = -EINVAL;
4186 goto exit;
4187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
4189 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
4190 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
4191 pos += length;
4192 break;
4193 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
4194 pos += 4;
4195 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004196 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 pos += 2;
4198
4199 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004200 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 pos += 4;
4202 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004203 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 pos += 2;
4205 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
4206 break;
4207 case HDD_WPS_ELEM_DEVICE_NAME:
4208 pos += 2;
4209 length = *pos<<8 | *(pos+1);
4210 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304211 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text)))
4212 {
4213 ret = -EINVAL;
4214 goto exit;
4215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4217 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4218 pos += length;
4219 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4220 break;
4221 case HDD_WPS_ELEM_CONFIG_METHODS:
4222 pos += 4;
4223 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004224 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 pos += 2;
4226 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4227 break;
4228
4229 case HDD_WPS_ELEM_RF_BANDS:
4230 pos += 4;
4231 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004232 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 pos += 1;
4234 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4235 break;
4236 } // switch
4237 }
4238 }
4239 else
4240 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004241 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 }
4243
4244 } // switch
4245 }
4246 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304247 if (halStatus != eHAL_STATUS_SUCCESS)
4248 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4250 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4251 {
4252 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4253 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4254 WLANSAP_Update_WpsIe ( pVosContext );
4255 }
4256
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304257exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004259 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 EXIT();
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304261 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07004262}
4263
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304264static int iw_softap_setwpsie(struct net_device *dev,
4265 struct iw_request_info *info,
4266 union iwreq_data *wrqu,
4267 char *extra)
4268{
4269 int ret;
4270
4271 vos_ssr_protect(__func__);
4272 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4273 vos_ssr_unprotect(__func__);
4274
4275 return ret;
4276}
4277
4278static int __iw_softap_stopbss(struct net_device *dev,
4279 struct iw_request_info *info,
4280 union iwreq_data *wrqu,
4281 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004282{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304283 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304285 hdd_context_t *pHddCtx = NULL;
4286
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304288 pHostapdAdapter = (netdev_priv(dev));
4289 if (NULL == pHostapdAdapter)
4290 {
4291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4292 "%s: Adapter is NULL",__func__);
4293 return -EINVAL;
4294 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304295 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4296 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304297 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304298 return status;
4299 }
4300
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304301 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 {
4303 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4304 {
4305 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4306
4307 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304308
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304310 {
4311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004312 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 VOS_ASSERT(0);
4314 }
4315 }
4316 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304317 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 }
4319 EXIT();
4320 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4321}
4322
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304323static int iw_softap_stopbss(struct net_device *dev,
4324 struct iw_request_info *info,
4325 union iwreq_data *wrqu,
4326 char *extra)
4327{
4328 int ret;
4329
4330 vos_ssr_protect(__func__);
4331 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4332 vos_ssr_unprotect(__func__);
4333
4334 return ret;
4335}
4336
4337static int __iw_softap_version(struct net_device *dev,
4338 struct iw_request_info *info,
4339 union iwreq_data *wrqu,
4340 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004341{
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304343 hdd_context_t *pHddCtx;
4344 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304347 pHostapdAdapter = (netdev_priv(dev));
4348 if (NULL == pHostapdAdapter)
4349 {
4350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4351 "%s: Adapter is NULL",__func__);
4352 return -EINVAL;
4353 }
4354 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4355 ret = wlan_hdd_validate_context(pHddCtx);
4356 if (0 != ret)
4357 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304358 return ret;
4359 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004360 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 return 0;
4363}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004364
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304365static int iw_softap_version(struct net_device *dev,
4366 struct iw_request_info *info,
4367 union iwreq_data *wrqu,
4368 char *extra)
4369{
4370 int ret;
4371
4372 vos_ssr_protect(__func__);
4373 ret = __iw_softap_version(dev, info, wrqu, extra);
4374 vos_ssr_unprotect(__func__);
4375
4376 return ret;
4377}
4378
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004379VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004380{
4381 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004382 int len = 0;
4383 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304384 v_CONTEXT_t pVosContext;
4385 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304386 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304387
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304388 ENTER();
4389
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304390 if (NULL == pAdapter)
4391 {
4392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4393 "%s: Adapter is NULL",__func__);
4394 return -EINVAL;
4395 }
4396 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4397 if (0 != wlan_hdd_validate_context(pHddCtx))
4398 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304399 return VOS_STATUS_E_FAULT;
4400 }
4401 pVosContext = pHddCtx->pvosContext;
4402 if (NULL == pVosContext)
4403 {
4404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4405 "%s: VOS context is not valid",__func__);
4406 return VOS_STATUS_E_FAULT;
4407 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304408 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304409 if(pSapCtx == NULL)
4410 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304411 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4412 FL("psapCtx is NULL"));
4413 return VOS_STATUS_E_FAULT;
4414 }
4415
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004416 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004417 pBuf += len;
4418 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004419
4420 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4421 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304422 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004423 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004424 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304425 pSapCtx->aStaInfo[i].ucSTAId,
4426 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4427 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4428 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4429 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4430 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4431 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004432 pBuf += len;
4433 buf_len -= len;
4434 }
4435 if(WE_GET_STA_INFO_SIZE > buf_len)
4436 {
4437 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004438 }
4439 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304440 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004441 return VOS_STATUS_SUCCESS;
4442}
4443
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304444static int __iw_softap_get_sta_info(struct net_device *dev,
4445 struct iw_request_info *info,
4446 union iwreq_data *wrqu,
4447 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004448{
4449 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4450 VOS_STATUS status;
4451 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004452 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004453 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004454 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004455 return -EINVAL;
4456 }
4457 wrqu->data.length = strlen(extra);
4458 EXIT();
4459 return 0;
4460}
4461
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304462static int iw_softap_get_sta_info(struct net_device *dev,
4463 struct iw_request_info *info,
4464 union iwreq_data *wrqu,
4465 char *extra)
4466{
4467 int ret;
4468
4469 vos_ssr_protect(__func__);
4470 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4471 vos_ssr_unprotect(__func__);
4472
4473 return ret;
4474}
4475
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304476static int __iw_set_ap_genie(struct net_device *dev,
4477 struct iw_request_info *info,
4478 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004479{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304480
4481 hdd_adapter_t *pHostapdAdapter;
4482 hdd_context_t *pHddCtx;
4483 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004485 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304486 int ret = 0;
4487
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304489 pHostapdAdapter = (netdev_priv(dev));
4490 if (NULL == pHostapdAdapter)
4491 {
4492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4493 "%s: Adapter is NULL",__func__);
4494 return -EINVAL;
4495 }
4496 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4497 ret = wlan_hdd_validate_context(pHddCtx);
4498 if (0 != ret)
4499 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304500 return ret;
4501 }
4502 pVosContext = pHddCtx->pvosContext;
4503 if (NULL == pVosContext)
4504 {
4505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4506 "%s: VOS Context is NULL",__func__);
4507 return -EINVAL;
4508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 if(!wrqu->data.length)
4510 {
4511 EXIT();
4512 return 0;
4513 }
Arif Hussained667642013-10-27 23:01:14 -07004514
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304515 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304517 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 case DOT11F_EID_RSN:
4519 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4520 {
4521 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4522 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004525 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004529 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 halStatus = 0;
4531 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304532
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304534 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004535}
4536
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304537static int iw_set_ap_genie(struct net_device *dev,
4538 struct iw_request_info *info,
4539 union iwreq_data *wrqu, char *extra)
4540{
4541 int ret;
4542
4543 vos_ssr_protect(__func__);
4544 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4545 vos_ssr_unprotect(__func__);
4546
4547 return ret;
4548}
4549
Jeff Johnson295189b2012-06-20 16:38:30 -07004550static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4551{
4552 eHalStatus hstatus;
4553 long lrc;
4554 struct statsContext context;
4555
4556 if (NULL == pAdapter)
4557 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304558 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 return VOS_STATUS_E_FAULT;
4560 }
4561
4562 init_completion(&context.completion);
4563 context.pAdapter = pAdapter;
4564 context.magic = STATS_CONTEXT_MAGIC;
4565 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4566 eCSR_HDD,
4567 SME_GLOBAL_CLASSA_STATS,
4568 hdd_GetClassA_statisticsCB,
4569 0, // not periodic
4570 FALSE, //non-cached results
4571 staid,
4572 &context);
4573 if (eHAL_STATUS_SUCCESS != hstatus)
4574 {
4575 hddLog(VOS_TRACE_LEVEL_ERROR,
4576 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004577 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 }
4579 else
4580 {
4581 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4582 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 if (lrc <= 0)
4584 {
4585 hddLog(VOS_TRACE_LEVEL_ERROR,
4586 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004587 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 }
4589 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004590
4591 /* either we never sent a request, we sent a request and received a
4592 response or we sent a request and timed out. if we never sent a
4593 request or if we sent a request and got a response, we want to
4594 clear the magic out of paranoia. if we timed out there is a
4595 race condition such that the callback function could be
4596 executing at the same time we are. of primary concern is if the
4597 callback function had already verified the "magic" but had not
4598 yet set the completion variable when a timeout occurred. we
4599 serialize these activities by invalidating the magic while
4600 holding a shared spinlock which will cause us to block if the
4601 callback is currently executing */
4602 spin_lock(&hdd_context_lock);
4603 context.magic = 0;
4604 spin_unlock(&hdd_context_lock);
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 return VOS_STATUS_SUCCESS;
4607}
4608
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304609int __iw_get_softap_linkspeed(struct net_device *dev,
4610 struct iw_request_info *info,
4611 union iwreq_data *wrqu,
4612 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004613
4614{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304616 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004618 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304619 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304621 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004623 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304624 int rc, valid;
4625
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304626 ENTER();
4627
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304628 pHostapdAdapter = (netdev_priv(dev));
4629 if (NULL == pHostapdAdapter)
4630 {
4631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4632 "%s: Adapter is NULL",__func__);
4633 return -EINVAL;
4634 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304635 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304636 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304637 if (0 != valid)
4638 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304639 return valid;
4640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004641
Arif Hussain6d2a3322013-11-17 19:50:10 -08004642 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004643
4644 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004645 {
Arif Hussaina9571842014-01-15 16:43:41 -08004646 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4647 if (NULL == pmacAddress) {
4648 hddLog(LOG1, "unable to allocate memory");
4649 return -ENOMEM;
4650 }
4651 if (copy_from_user((void *)pmacAddress,
4652 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4653 {
4654 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4655 kfree(pmacAddress);
4656 return -EFAULT;
4657 }
4658 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4659
4660 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004661 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004662
4663 if (!VOS_IS_STATUS_SUCCESS(status ))
4664 {
4665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4666 }
Arif Hussained667642013-10-27 23:01:14 -07004667 }
Kiet Lam61589852013-09-19 17:10:58 +05304668 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304669 * link speed for first connected client will be returned.
4670 */
Arif Hussaina9571842014-01-15 16:43:41 -08004671 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304672 {
4673 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4674 }
4675 else
4676 {
4677 status = hdd_softap_GetStaId(pHostapdAdapter,
4678 (v_MACADDR_t *)macAddress, (void *)(&staId));
4679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004680
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304681 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304683 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 link_speed = 0;
4685 }
4686 else
4687 {
4688 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304689
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 if (!VOS_IS_STATUS_SUCCESS(status ))
4691 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 return -EINVAL;
4694 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304695
4696 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4697 staId, &link_speed);
4698
4699 link_speed = link_speed / 10;
4700
4701 if (0 == link_speed)
4702 {
4703 /* The linkspeed returned by HAL is in units of 500kbps.
4704 * converting it to mbps.
4705 * This is required to support legacy firmware which does
4706 * not return link capacity.
4707 */
4708 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 }
4711
4712 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004713 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304714
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 if ((rc < 0) || (rc >= len))
4716 {
4717 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304718 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 return -EIO;
4720 }
4721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304722 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 return 0;
4724}
4725
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304726int iw_get_softap_linkspeed(struct net_device *dev,
4727 struct iw_request_info *info,
4728 union iwreq_data *wrqu,
4729 char *extra)
4730{
4731 int ret;
4732
4733 vos_ssr_protect(__func__);
4734 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4735 vos_ssr_unprotect(__func__);
4736
4737 return ret;
4738}
4739
4740
Jeff Johnson295189b2012-06-20 16:38:30 -07004741static const iw_handler hostapd_handler[] =
4742{
4743 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4744 (iw_handler) NULL, /* SIOCGIWNAME */
4745 (iw_handler) NULL, /* SIOCSIWNWID */
4746 (iw_handler) NULL, /* SIOCGIWNWID */
4747 (iw_handler) NULL, /* SIOCSIWFREQ */
4748 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4749 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304750 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 (iw_handler) NULL, /* SIOCSIWSENS */
4752 (iw_handler) NULL, /* SIOCGIWSENS */
4753 (iw_handler) NULL, /* SIOCSIWRANGE */
4754 (iw_handler) NULL, /* SIOCGIWRANGE */
4755 (iw_handler) NULL, /* SIOCSIWPRIV */
4756 (iw_handler) NULL, /* SIOCGIWPRIV */
4757 (iw_handler) NULL, /* SIOCSIWSTATS */
4758 (iw_handler) NULL, /* SIOCGIWSTATS */
4759 (iw_handler) NULL, /* SIOCSIWSPY */
4760 (iw_handler) NULL, /* SIOCGIWSPY */
4761 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4762 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4763 (iw_handler) NULL, /* SIOCSIWAP */
4764 (iw_handler) NULL, /* SIOCGIWAP */
4765 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4766 (iw_handler) NULL, /* SIOCGIWAPLIST */
4767 (iw_handler) NULL, /* SIOCSIWSCAN */
4768 (iw_handler) NULL, /* SIOCGIWSCAN */
4769 (iw_handler) NULL, /* SIOCSIWESSID */
4770 (iw_handler) NULL, /* SIOCGIWESSID */
4771 (iw_handler) NULL, /* SIOCSIWNICKN */
4772 (iw_handler) NULL, /* SIOCGIWNICKN */
4773 (iw_handler) NULL, /* -- hole -- */
4774 (iw_handler) NULL, /* -- hole -- */
4775 (iw_handler) NULL, /* SIOCSIWRATE */
4776 (iw_handler) NULL, /* SIOCGIWRATE */
4777 (iw_handler) NULL, /* SIOCSIWRTS */
4778 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4779 (iw_handler) NULL, /* SIOCSIWFRAG */
4780 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4781 (iw_handler) NULL, /* SIOCSIWTXPOW */
4782 (iw_handler) NULL, /* SIOCGIWTXPOW */
4783 (iw_handler) NULL, /* SIOCSIWRETRY */
4784 (iw_handler) NULL, /* SIOCGIWRETRY */
4785 (iw_handler) NULL, /* SIOCSIWENCODE */
4786 (iw_handler) NULL, /* SIOCGIWENCODE */
4787 (iw_handler) NULL, /* SIOCSIWPOWER */
4788 (iw_handler) NULL, /* SIOCGIWPOWER */
4789 (iw_handler) NULL, /* -- hole -- */
4790 (iw_handler) NULL, /* -- hole -- */
4791 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4792 (iw_handler) NULL, /* SIOCGIWGENIE */
4793 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4794 (iw_handler) NULL, /* SIOCGIWAUTH */
4795 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4796 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4797 (iw_handler) NULL, /* SIOCSIWPMKSA */
4798};
4799
Jeff Johnson224f3702014-03-26 11:09:47 -07004800/*
4801 * Note that the following ioctls were defined with semantics which
4802 * cannot be handled by the "iwpriv" userspace application and hence
4803 * they are not included in the hostapd_private_args array
4804 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4805 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004806
4807static const struct iw_priv_args hostapd_private_args[] = {
4808 { QCSAP_IOCTL_SETPARAM,
4809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4810 { QCSAP_IOCTL_SETPARAM,
4811 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304812 { QCSAP_PARAM_GET_FRAME_LOGS,
4813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 { QCSAP_PARAM_MAX_ASSOC,
4815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4816 { QCSAP_PARAM_HIDE_SSID,
4817 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004818 { QCSAP_PARAM_SET_MC_RATE,
4819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 { QCSAP_IOCTL_GETPARAM,
4821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4822 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4823 { QCSAP_IOCTL_GETPARAM, 0,
4824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4825 { QCSAP_PARAM_MAX_ASSOC, 0,
4826 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004827 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4829 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4830 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304831 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 { QCSAP_PARAM_CLR_ACL, 0,
4834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4835 { QCSAP_PARAM_ACL_MODE,
4836 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 { QCSAP_IOCTL_GET_STAWPAIE,
4838 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4839 { QCSAP_IOCTL_SETWPAIE,
4840 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4841 { QCSAP_IOCTL_STOPBSS,
4842 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4843 { QCSAP_IOCTL_VERSION, 0,
4844 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004845 { QCSAP_IOCTL_GET_STA_INFO, 0,
4846 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004848 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004851 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304853 { QCSAP_IOCTL_AP_STATS, 0,
4854 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304855 { QCSAP_IOCTL_GET_STATS, 0,
4856 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4857 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4859 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304860 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004861
4862 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4864 /* handlers for sub-ioctl */
4865 { WE_SET_WLAN_DBG,
4866 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4867 0,
4868 "setwlandbg" },
4869
4870 /* handlers for main ioctl */
4871 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4872 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4873 0,
4874 "" },
4875
4876 /* handlers for sub-ioctl */
4877 { WE_LOG_DUMP_CMD,
4878 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4879 0,
4880 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 { WE_P2P_NOA_CMD,
4882 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4883 0,
4884 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004885 /* handlers for sub ioctl */
4886 {
4887 WE_MCC_CONFIG_CREDENTIAL,
4888 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4889 0,
4890 "setMccCrdnl" },
4891
4892 /* handlers for sub ioctl */
4893 {
4894 WE_MCC_CONFIG_PARAMS,
4895 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4896 0,
4897 "setMccConfig" },
4898
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 /* handlers for main ioctl */
4900 { QCSAP_IOCTL_MODIFY_ACL,
4901 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4902 0,
4903 "modify_acl" },
4904
4905 /* handlers for main ioctl */
4906 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4907 0,
4908 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4909 "getChannelList" },
4910
Jeff Johnsone7245742012-09-05 17:12:55 -07004911 /* handlers for main ioctl */
4912 { QCSAP_IOCTL_SET_TX_POWER,
4913 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4914 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304915 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004916
4917 /* handlers for main ioctl */
4918 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4919 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4920 0,
4921 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304922
4923 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4924 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4925 0,
4926 "dataSnapshot" },
4927
4928 /* handlers for main ioctl */
4929 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4930 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4931 0,
4932 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004933};
Jeff Johnsone7245742012-09-05 17:12:55 -07004934
Jeff Johnson295189b2012-06-20 16:38:30 -07004935static const iw_handler hostapd_private[] = {
4936 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4937 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4939 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4940 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4941 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4942 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4943 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4944 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4945 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4946 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304947 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4949 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4950 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4951 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004952 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004953 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4954 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004955 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304956 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304957 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304958 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4959 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004960};
4961const struct iw_handler_def hostapd_handler_def = {
4962 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4963 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4964 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4965 .standard = (iw_handler *)hostapd_handler,
4966 .private = (iw_handler *)hostapd_private,
4967 .private_args = hostapd_private_args,
4968 .get_wireless_stats = NULL,
4969};
4970#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4971struct net_device_ops net_ops_struct = {
4972 .ndo_open = hdd_hostapd_open,
4973 .ndo_stop = hdd_hostapd_stop,
4974 .ndo_uninit = hdd_hostapd_uninit,
4975 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4976 .ndo_tx_timeout = hdd_softap_tx_timeout,
4977 .ndo_get_stats = hdd_softap_stats,
4978 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4979 .ndo_do_ioctl = hdd_hostapd_ioctl,
4980 .ndo_change_mtu = hdd_hostapd_change_mtu,
4981 .ndo_select_queue = hdd_hostapd_select_queue,
4982 };
4983#endif
4984
4985int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4986{
4987 return VOS_STATUS_SUCCESS;
4988}
4989
4990void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4991{
4992#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4993 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4994#else
4995 pWlanHostapdDev->open = hdd_hostapd_open;
4996 pWlanHostapdDev->stop = hdd_hostapd_stop;
4997 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4998 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4999 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5000 pWlanHostapdDev->get_stats = hdd_softap_stats;
5001 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5002 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5003#endif
5004}
5005
5006VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305007{
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 hdd_hostapd_state_t * phostapdBuf;
5009 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005010 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005012#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005013 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5014 v_U16_t unsafeChannelCount;
5015#endif /* FEATURE_WLAN_CH_AVOID */
5016
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305017 if (pHddCtx->isLogpInProgress) {
5018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5019 "%s:LOGP in Progress. Ignore!!!",__func__);
5020 status = VOS_STATUS_E_FAILURE;
5021 }
5022
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305024 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305026
Nirav Shah7e3c8132015-06-22 23:51:42 +05305027 spin_lock_init(&pAdapter->sta_hash_lock);
5028 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5029
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005030 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5031
Leo Chang0b0e45a2013-12-15 15:18:55 -08005032#ifdef FEATURE_WLAN_CH_AVOID
5033 /* Get unsafe cahnnel list from cached location */
5034 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5035 sizeof(unsafeChannelList),
5036 &unsafeChannelCount);
5037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5038 "%s : Unsafe Channel count %d",
5039 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305040 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005041 unsafeChannelList,
5042 unsafeChannelCount);
5043#endif /* FEATURE_WLAN_CH_AVOID */
5044
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 // Zero the memory. This zeros the profile structure.
5046 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
5047
5048 // Set up the pointer to the Wireless Extensions state structure
5049 // NOP
5050 status = hdd_set_hostapd(pAdapter);
5051 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 return status;
5054 }
5055
5056 status = vos_event_init(&phostapdBuf->vosEvent);
5057 if (!VOS_IS_STATUS_SUCCESS(status))
5058 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 return status;
5061 }
5062
Jeff Johnson295189b2012-06-20 16:38:30 -07005063
5064 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5065
5066 // Register as a wireless device
5067 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5068
5069 //Initialize the data path module
5070 status = hdd_softap_init_tx_rx(pAdapter);
5071 if ( !VOS_IS_STATUS_SUCCESS( status ))
5072 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005073 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305075
5076 status = hdd_wmm_adapter_init( pAdapter );
5077 if (!VOS_IS_STATUS_SUCCESS(status))
5078 {
5079 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005080 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305081 status, status );
5082 goto error_wmm_init;
5083 }
5084
5085 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5086
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305087 return status;
5088
5089error_wmm_init:
5090 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 EXIT();
5092 return status;
5093}
5094
5095hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5096{
5097 struct net_device *pWlanHostapdDev = NULL;
5098 hdd_adapter_t *pHostapdAdapter = NULL;
5099 v_CONTEXT_t pVosContext= NULL;
5100
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305101 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5102#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5103 NET_NAME_UNKNOWN,
5104#endif
5105 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 if (pWlanHostapdDev != NULL)
5107 {
5108 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5109
5110 //Init the net_device structure
5111 ether_setup(pWlanHostapdDev);
5112
5113 //Initialize the adapter context to zeros.
5114 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5115 pHostapdAdapter->dev = pWlanHostapdDev;
5116 pHostapdAdapter->pHddCtx = pHddCtx;
5117 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5118
5119 //Get the Global VOSS context.
5120 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5121 //Save the adapter context in global context for future.
5122 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5123
5124 //Init the net_device structure
5125 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5126
5127 hdd_set_ap_ops( pHostapdAdapter->dev );
5128
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5130 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5131
5132 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5133 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5134
5135 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5137 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5138 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005139
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5141 }
5142 return pHostapdAdapter;
5143}
5144
5145VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5146{
5147 struct net_device *dev = pAdapter->dev;
5148 VOS_STATUS status = VOS_STATUS_SUCCESS;
5149
5150 ENTER();
5151
5152 if( rtnl_lock_held )
5153 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005154 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 if( dev_alloc_name(dev, dev->name) < 0 )
5156 {
5157 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5158 return VOS_STATUS_E_FAILURE;
5159 }
5160 }
5161 if (register_netdevice(dev))
5162 {
5163 hddLog(VOS_TRACE_LEVEL_FATAL,
5164 "%s:Failed:register_netdevice", __func__);
5165 return VOS_STATUS_E_FAILURE;
5166 }
5167 }
5168 else
5169 {
5170 if (register_netdev(dev))
5171 {
5172 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5173 return VOS_STATUS_E_FAILURE;
5174 }
5175 }
5176 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5177
5178 EXIT();
5179 return status;
5180}
5181
c_hpothu002231a2015-02-05 14:58:51 +05305182VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005183{
5184 ENTER();
5185
5186 hdd_softap_deinit_tx_rx(pAdapter);
5187
5188 /* if we are being called during driver unload, then the dev has already
5189 been invalidated. if we are being called at other times, then we can
5190 detatch the wireless device handlers */
5191 if (pAdapter->dev)
5192 {
c_hpothu002231a2015-02-05 14:58:51 +05305193 if (TRUE == rtnl_held)
5194 {
5195 pAdapter->dev->wireless_handlers = NULL;
5196 }
5197 else
5198 {
5199 rtnl_lock();
5200 pAdapter->dev->wireless_handlers = NULL;
5201 rtnl_unlock();
5202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005203 }
5204 EXIT();
5205 return 0;
5206}