blob: b924613b750bb34ba6dff2eac0d8bdff11e8acaf [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070082
Leo Chang0b0e45a2013-12-15 15:18:55 -080083#ifdef FEATURE_WLAN_CH_AVOID
84#include "wcnss_wlan.h"
85#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080089
Jeff Johnson295189b2012-06-20 16:38:30 -070090#define IS_UP(_dev) \
91 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
92#define IS_UP_AUTO(_ic) \
93 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
94#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070095#define WE_GET_STA_INFO_SIZE 30
96/* WEXT limition: MAX allowed buf len for any *
97 * IW_PRIV_TYPE_CHAR is 2Kbytes *
98 */
99#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700100
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530101#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700102
Leo Chang0b0e45a2013-12-15 15:18:55 -0800103#ifdef FEATURE_WLAN_CH_AVOID
104/* Channle/Freqency table */
105extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
106safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
107{
108 /*CH , SAFE, default safe */
109 {1 , VOS_TRUE}, //RF_CHAN_1,
110 {2 , VOS_TRUE}, //RF_CHAN_2,
111 {3 , VOS_TRUE}, //RF_CHAN_3,
112 {4 , VOS_TRUE}, //RF_CHAN_4,
113 {5 , VOS_TRUE}, //RF_CHAN_5,
114 {6 , VOS_TRUE}, //RF_CHAN_6,
115 {7 , VOS_TRUE}, //RF_CHAN_7,
116 {8 , VOS_TRUE}, //RF_CHAN_8,
117 {9 , VOS_TRUE}, //RF_CHAN_9,
118 {10 , VOS_TRUE}, //RF_CHAN_10,
119 {11 , VOS_TRUE}, //RF_CHAN_11,
120 {12 , VOS_TRUE}, //RF_CHAN_12,
121 {13 , VOS_TRUE}, //RF_CHAN_13,
122 {14 , VOS_TRUE}, //RF_CHAN_14,
123 {240, VOS_TRUE}, //RF_CHAN_240,
124 {244, VOS_TRUE}, //RF_CHAN_244,
125 {248, VOS_TRUE}, //RF_CHAN_248,
126 {252, VOS_TRUE}, //RF_CHAN_252,
127 {208, VOS_TRUE}, //RF_CHAN_208,
128 {212, VOS_TRUE}, //RF_CHAN_212,
129 {216, VOS_TRUE}, //RF_CHAN_216,
130 {36 , VOS_TRUE}, //RF_CHAN_36,
131 {40 , VOS_TRUE}, //RF_CHAN_40,
132 {44 , VOS_TRUE}, //RF_CHAN_44,
133 {48 , VOS_TRUE}, //RF_CHAN_48,
134 {52 , VOS_TRUE}, //RF_CHAN_52,
135 {56 , VOS_TRUE}, //RF_CHAN_56,
136 {60 , VOS_TRUE}, //RF_CHAN_60,
137 {64 , VOS_TRUE}, //RF_CHAN_64,
138 {100, VOS_TRUE}, //RF_CHAN_100,
139 {104, VOS_TRUE}, //RF_CHAN_104,
140 {108, VOS_TRUE}, //RF_CHAN_108,
141 {112, VOS_TRUE}, //RF_CHAN_112,
142 {116, VOS_TRUE}, //RF_CHAN_116,
143 {120, VOS_TRUE}, //RF_CHAN_120,
144 {124, VOS_TRUE}, //RF_CHAN_124,
145 {128, VOS_TRUE}, //RF_CHAN_128,
146 {132, VOS_TRUE}, //RF_CHAN_132,
147 {136, VOS_TRUE}, //RF_CHAN_136,
148 {140, VOS_TRUE}, //RF_CHAN_140,
149 {149, VOS_TRUE}, //RF_CHAN_149,
150 {153, VOS_TRUE}, //RF_CHAN_153,
151 {157, VOS_TRUE}, //RF_CHAN_157,
152 {161, VOS_TRUE}, //RF_CHAN_161,
153 {165, VOS_TRUE}, //RF_CHAN_165,
154};
155#endif /* FEATURE_WLAN_CH_AVOID */
156
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530157/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 * Function definitions
159 *-------------------------------------------------------------------------*/
160/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530161
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530162 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 This is called in response to ifconfig up
165
166 \param - dev Pointer to net_device structure
167
168 \return - 0 for success non-zero for failure
169
170 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530171int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700172{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
174
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 ENTER();
176
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530177 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
178 {
179 //WMM_INIT OR BSS_START not completed
180 hddLog( LOGW, "Ignore hostadp open request");
181 EXIT();
182 return 0;
183 }
184
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530185 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
186 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 //Turn ON carrier state
188 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530189 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530190 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530192
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 EXIT();
194 return 0;
195}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530196
197int hdd_hostapd_open (struct net_device *dev)
198{
199 int ret;
200
201 vos_ssr_protect(__func__);
202 ret = __hdd_hostapd_open(dev);
203 vos_ssr_unprotect(__func__);
204
205 return ret;
206}
207
Jeff Johnson295189b2012-06-20 16:38:30 -0700208/**---------------------------------------------------------------------------
209
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530210 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212 This is called in response to ifconfig down
213
214 \param - dev Pointer to net_device structure
215
216 \return - 0 for success non-zero for failure
217
218 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530219int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700220{
221 ENTER();
222
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530223 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530224 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 //Stop all tx queues
226 netif_tx_disable(dev);
227
228 //Turn OFF carrier state
229 netif_carrier_off(dev);
230 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700231
232 EXIT();
233 return 0;
234}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530235
236int hdd_hostapd_stop (struct net_device *dev)
237{
238 int ret;
239
240 vos_ssr_protect(__func__);
241 ret = __hdd_hostapd_stop(dev);
242 vos_ssr_unprotect(__func__);
243
244 return ret;
245}
246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247/**---------------------------------------------------------------------------
248
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530249 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700250
251 This is called during the netdev unregister to uninitialize all data
252associated with the device
253
254 \param - dev Pointer to net_device structure
255
256 \return - void
257
258 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530259static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700260{
261 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530262 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264 ENTER();
265
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530266 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 hddLog(VOS_TRACE_LEVEL_ERROR,
269 FL("Invalid magic"));
270 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530272 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
273 if (NULL == pHddCtx)
274 {
275 hddLog(VOS_TRACE_LEVEL_ERROR,
276 FL("NULL pHddCtx"));
277 return;
278 }
279
280 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
281
282 /* after uninit our adapter structure will no longer be valid */
283 pHostapdAdapter->dev = NULL;
284 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700285
286 EXIT();
287}
288
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530289static void hdd_hostapd_uninit (struct net_device *dev)
290{
291 vos_ssr_protect(__func__);
292 __hdd_hostapd_uninit(dev);
293 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530295 return;
296}
Jeff Johnson295189b2012-06-20 16:38:30 -0700297/**============================================================================
298 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
299 transmitting packets. There are 2 versions of this function. One that uses
300 locked queue and other that uses lockless queues. Both have been retained to
301 do some performance testing
302 @param skb : [in] pointer to OS packet (sk_buff)
303 @param dev : [in] pointer to Libra network device
304
305 @return : NET_XMIT_DROP if packets are dropped
306 : NET_XMIT_SUCCESS if packet is enqueued succesfully
307 ===========================================================================*/
308int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
309{
310 return 0;
311}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530312
313int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700314{
315 return 0;
316}
317
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530318int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
319{
320 int ret;
321 vos_ssr_protect(__func__);
322 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
323 vos_ssr_unprotect(__func__);
324
325 return ret;
326}
327
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700328static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
329 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700330{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700331 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530332 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
333 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700334 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530335 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 /*
337 * Note that valid pointers are provided by caller
338 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700339
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530340 ENTER();
341
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700342 if (priv_data->total_len <= 0 ||
343 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
344 {
345 /* below we allocate one more byte for command buffer.
346 * To avoid addition overflow total_len should be
347 * smaller than INT_MAX. */
348 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
349 __func__, priv_data->total_len);
350 ret = -EFAULT;
351 goto exit;
352 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530353 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530354 if (0 != status)
355 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 return status;
357 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700359 /* Allocate +1 for '\0' */
360 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
361 if (!command)
362 {
363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
364 ret = -ENOMEM;
365 goto exit;
366 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700367
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700368 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
369 {
370 ret = -EFAULT;
371 goto exit;
372 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800373
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700374 /* Make sure the command is NUL-terminated */
375 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700377 hddLog(VOS_TRACE_LEVEL_INFO,
378 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700380 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
381 {
382 hdd_setP2pNoa(pAdapter->dev, command);
383 }
384 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
385 {
386 hdd_setP2pOpps(pAdapter->dev, command);
387 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800388#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700389 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
390 {
391 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
392 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800393#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700394 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
395 {
396 /*
397 * command should be a string having format
398 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
399 */
400 hddLog(VOS_TRACE_LEVEL_INFO,
401 "%s: Received Command to Set Preferred Channels for SAP",
402 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800403
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700404 ret = sapSetPreferredChannel(command);
405 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530406 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
407 {
408 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
409 tANI_U8 filterType = 0;
410 tANI_U8 *value;
411 value = command + 9;
412
413 /* Convert the value from ascii to integer */
414 ret = kstrtou8(value, 10, &filterType);
415 if (ret < 0)
416 {
417 /* If the input value is greater than max value of datatype,
418 * then also kstrtou8 fails
419 */
420 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
421 "%s: kstrtou8 failed range ", __func__);
422 ret = -EINVAL;
423 goto exit;
424 }
425 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
426 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
427 {
428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
429 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
430 " 2-Sink ", __func__);
431 ret = -EINVAL;
432 goto exit;
433 }
434 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
435 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530436 pScanInfo = &pHddCtx->scan_info;
437 if (filterType && pScanInfo != NULL &&
438 pHddCtx->scan_info.mScanPending)
439 {
440 /*Miracast Session started. Abort Scan */
441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
442 "%s, Aborting Scan For Miracast",__func__);
443 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
444 eCSR_SCAN_ABORT_DEFAULT);
445 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530446 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
447 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
448 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530449 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
450 {
451 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
452 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700453
Jeff Johnson295189b2012-06-20 16:38:30 -0700454exit:
455 if (command)
456 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700457 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530459 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 return ret;
461}
462
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700463#ifdef CONFIG_COMPAT
464static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
465 struct ifreq *ifr)
466{
467 struct {
468 compat_uptr_t buf;
469 int used_len;
470 int total_len;
471 } compat_priv_data;
472 hdd_priv_data_t priv_data;
473 int ret = 0;
474
475 /*
476 * Note that pAdapter and ifr have already been verified by caller,
477 * and HDD context has also been validated
478 */
479 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
480 sizeof(compat_priv_data))) {
481 ret = -EFAULT;
482 goto exit;
483 }
484 priv_data.buf = compat_ptr(compat_priv_data.buf);
485 priv_data.used_len = compat_priv_data.used_len;
486 priv_data.total_len = compat_priv_data.total_len;
487 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
488 exit:
489 return ret;
490}
491#else /* CONFIG_COMPAT */
492static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
493 struct ifreq *ifr)
494{
495 /* will never be invoked */
496 return 0;
497}
498#endif /* CONFIG_COMPAT */
499
500static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
501{
502 hdd_priv_data_t priv_data;
503 int ret = 0;
504
505 /*
506 * Note that pAdapter and ifr have already been verified by caller,
507 * and HDD context has also been validated
508 */
509 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
510 ret = -EFAULT;
511 } else {
512 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
513 }
514 return ret;
515}
516
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530517static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700518 struct ifreq *ifr, int cmd)
519{
520 hdd_adapter_t *pAdapter;
521 hdd_context_t *pHddCtx;
522 int ret;
523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530524 ENTER();
525
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700526 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
527 if (NULL == pAdapter) {
528 hddLog(VOS_TRACE_LEVEL_ERROR,
529 "%s: HDD adapter context is Null", __func__);
530 ret = -ENODEV;
531 goto exit;
532 }
533 if (dev != pAdapter->dev) {
534 hddLog(VOS_TRACE_LEVEL_ERROR,
535 "%s: HDD adapter/dev inconsistency", __func__);
536 ret = -ENODEV;
537 goto exit;
538 }
539
540 if ((!ifr) || (!ifr->ifr_data)) {
541 ret = -EINVAL;
542 goto exit;
543 }
544
545 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
546 ret = wlan_hdd_validate_context(pHddCtx);
547 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700548 ret = -EBUSY;
549 goto exit;
550 }
551
552 switch (cmd) {
553 case (SIOCDEVPRIVATE + 1):
554 if (is_compat_task())
555 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
556 else
557 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
558 break;
559 default:
560 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
561 __func__, cmd);
562 ret = -EINVAL;
563 break;
564 }
565 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530566 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700567 return ret;
568}
569
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530570static int hdd_hostapd_ioctl(struct net_device *dev,
571 struct ifreq *ifr, int cmd)
572{
573 int ret;
574
575 vos_ssr_protect(__func__);
576 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
577 vos_ssr_unprotect(__func__);
578
579 return ret;
580}
581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582/**---------------------------------------------------------------------------
583
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530584 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 This function sets the user specified mac address using
586 the command ifconfig wlanX hw ether <mac adress>.
587
588 \param - dev - Pointer to the net device.
589 - addr - Pointer to the sockaddr.
590 \return - 0 for success, non zero for failure
591
592 --------------------------------------------------------------------------*/
593
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530594static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700595{
596 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530597 hdd_adapter_t *pAdapter;
598 hdd_context_t *pHddCtx;
599 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530600
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530602 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
603 if (NULL == pAdapter)
604 {
605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
606 "%s: Adapter is NULL",__func__);
607 return -EINVAL;
608 }
609 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
610 ret = wlan_hdd_validate_context(pHddCtx);
611 if (0 != ret)
612 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530613 return ret;
614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
616 EXIT();
617 return 0;
618}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530619
620static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
621{
622 int ret;
623
624 vos_ssr_protect(__func__);
625 ret = __hdd_hostapd_set_mac_address(dev, addr);
626 vos_ssr_unprotect(__func__);
627
628 return ret;
629}
630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
632{
633 struct net_device *dev = (struct net_device *)usrDataForCallback;
634 v_BYTE_t we_custom_event[64];
635 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530637 hdd_context_t *pHddCtx;
638#ifdef DISABLE_CONCURRENCY_AUTOSAVE
639 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 hdd_ap_ctx_t *pHddApCtx;
641#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
642
643 /* event_name space-delimiter driver_module_name */
644 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
645 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
646 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
647
648 ENTER();
649
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530650 pHostapdAdapter = netdev_priv(dev);
651 if ((NULL == pHostapdAdapter) ||
652 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
653 {
654 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
655 return;
656 }
657 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
658 if (0 != (wlan_hdd_validate_context(pHddCtx)))
659 {
660 return;
661 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530662#ifdef DISABLE_CONCURRENCY_AUTOSAVE
663 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530664 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 /*
666 This timer routine is going to be called only when AP
667 persona is up.
668 If there are concurrent sessions running we do not want
669 to shut down the Bss.Instead we run the timer again so
670 that if Autosave is enabled next time and other session
671 was down only then we bring down AP
672 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
674 vos_status = vos_timer_start(
675 &pHddApCtx->hdd_ap_inactivity_timer,
676 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
677 * 1000);
678 if (!VOS_IS_STATUS_SUCCESS(vos_status))
679 {
680 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
681 }
682 EXIT();
683 return;
684 }
685#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
686 memset(&we_custom_event, '\0', sizeof(we_custom_event));
687 memcpy(&we_custom_event, autoShutEvent, event_len);
688
689 memset(&wrqu, 0, sizeof(wrqu));
690 wrqu.data.length = event_len;
691
692 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
693 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
694
695 EXIT();
696}
697
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800698VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
699{
700 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
701 ptSapContext pSapCtx = NULL;
702 eHalStatus halStatus = eHAL_STATUS_FAILURE;
703 v_PVOID_t hHal = NULL;
704
705 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
706 "%s: UPDATE Beacon Params", __func__);
707
708 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
709 pSapCtx = VOS_GET_SAP_CB(pVosContext);
710 if ( NULL == pSapCtx )
711 {
712 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
713 "%s: Invalid SAP pointer from pvosGCtx", __func__);
714 return VOS_STATUS_E_FAULT;
715 }
716
717 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
718 if ( NULL == hHal ){
719 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
720 "%s: Invalid HAL pointer from pvosGCtx", __func__);
721 return VOS_STATUS_E_FAULT;
722 }
723 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
724 if(halStatus == eHAL_STATUS_FAILURE ){
725 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
726 "%s: Failed to update Beacon Params", __func__);
727 return VOS_STATUS_E_FAILURE;
728 }
729 }
730 return VOS_STATUS_SUCCESS;
731}
732
733void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
734{
735 v_U8_t staId = 0;
736 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530737 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
738 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800739
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530740 dev = (struct net_device *)usrDataForCallback;
741 pSapCtx = VOS_GET_SAP_CB(pVosContext);
742 if(pSapCtx == NULL){
743 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
744 FL("psapCtx is NULL"));
745 return;
746 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800747 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800748 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
749 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530750 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800751 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
752 {
753 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530754 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800755 }
756 }
757}
758
Agarwal Ashish8e538932014-12-24 18:12:52 +0530759static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800760{
761 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530762 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800763 VOS_STATUS status = VOS_STATUS_SUCCESS;
764 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530765
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800766 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530767
768 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
769 status = wlan_hdd_validate_context(pHddCtx);
770
771 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530772 return status;
773 }
774
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800775 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
776 {
777 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
778 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800780 }
781 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530782 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800783 }
784 EXIT();
785 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
786}
Jeff Johnson295189b2012-06-20 16:38:30 -0700787
788VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
789{
790 hdd_adapter_t *pHostapdAdapter;
791 hdd_ap_ctx_t *pHddApCtx;
792 hdd_hostapd_state_t *pHostapdState;
793 struct net_device *dev;
794 eSapHddEvent sapEvent;
795 union iwreq_data wrqu;
796 v_BYTE_t *we_custom_event_generic = NULL;
797 int we_event = 0;
798 int i = 0;
799 v_U8_t staId;
800 VOS_STATUS vos_status;
801 v_BOOL_t bWPSState;
802 v_BOOL_t bApActive = FALSE;
803 v_BOOL_t bAuthRequired = TRUE;
804 tpSap_AssocMacAddr pAssocStasArray = NULL;
805 char unknownSTAEvent[IW_CUSTOM_MAX+1];
806 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
807 v_BYTE_t we_custom_start_event[64];
808 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800809 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800810 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700811 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530812 v_CONTEXT_t pVosContext = NULL;
813 ptSapContext pSapCtx = NULL;
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
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001090 pScanInfo = &pHddCtx->scan_info;
1091 // Lets do abort scan to ensure smooth authentication for client
1092 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1093 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301094 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301095 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
1098 break;
1099 case eSAP_STA_DISASSOC_EVENT:
1100 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001101 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001102 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1104 hddLog(LOG1," User initiated disassociation");
1105 else
1106 hddLog(LOG1," MAC initiated disassociation");
1107 we_event = IWEVEXPIRED;
1108 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1109 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1110 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001111 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 -07001112 return VOS_STATUS_E_FAILURE;
1113 }
1114 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1115
1116 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1117 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301118 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 // Start AP inactivity timer if no stations associated with it
1120 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1121 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301122 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 {
1124 bApActive = TRUE;
1125 break;
1126 }
1127 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301128 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001129
1130 if (bApActive == FALSE)
1131 {
1132 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1133 {
1134 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1135 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001136 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 }
1138 else
1139 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1140 }
1141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001142#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1143 cfg80211_del_sta(dev,
1144 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1145 GFP_KERNEL);
1146#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001147 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301148 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1149 if (VOS_STATUS_SUCCESS != vos_status)
1150 {
1151 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1152 __func__, vos_status);
1153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 break;
1155 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1156 {
1157 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1158 union iwreq_data wreq;
1159
1160 down(&pHddApCtx->semWpsPBCOverlapInd);
1161 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1162
1163 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1164 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1165
1166 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001167 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 memset(&wreq, 0, sizeof(wreq));
1169 wreq.data.length = strlen(message); // This is length of message
1170 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1171
1172 return VOS_STATUS_SUCCESS;
1173 }
1174 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1175 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1176 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1177 { // List of associated stations
1178 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1179 {
1180 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1181 i+1,
1182 pAssocStasArray->assocId,
1183 pAssocStasArray->staId,
1184 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1185 pAssocStasArray++;
1186 }
1187 }
1188 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001189 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 case eSAP_INDICATE_MGMT_FRAME:
1192 hdd_indicateMgmtFrame( pHostapdAdapter,
1193 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
1194 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
1195 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05301196 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 return VOS_STATUS_SUCCESS;
1198 case eSAP_REMAIN_CHAN_READY:
1199 hdd_remainChanReadyHandler( pHostapdAdapter );
1200 return VOS_STATUS_SUCCESS;
1201 case eSAP_SEND_ACTION_CNF:
1202 hdd_sendActionCnf( pHostapdAdapter,
1203 ( eSAP_STATUS_SUCCESS ==
1204 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1205 TRUE : FALSE );
1206 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 case eSAP_UNKNOWN_STA_JOIN:
1208 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1209 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1210 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1211 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1212 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1213 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1214 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1215 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1216 wrqu.data.pointer = unknownSTAEvent;
1217 wrqu.data.length = strlen(unknownSTAEvent);
1218 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301219 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 break;
1221
1222 case eSAP_MAX_ASSOC_EXCEEDED:
1223 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1224 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1225 " one or more devices to enable the new device connection",
1226 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1227 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1228 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1229 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1230 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1231 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1232 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1233 wrqu.data.pointer = maxAssocExceededEvent;
1234 wrqu.data.length = strlen(maxAssocExceededEvent);
1235 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001236 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 break;
1238 case eSAP_STA_ASSOC_IND:
1239 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001240
1241 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001242 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001243 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1244 return VOS_STATUS_SUCCESS;
1245
1246 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301247 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301248 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1249 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301250 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301251 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001252 return VOS_STATUS_SUCCESS;
1253
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001255 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 goto stopbss;
1257 return VOS_STATUS_SUCCESS;
1258 }
1259 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1260 return VOS_STATUS_SUCCESS;
1261
1262stopbss :
1263 {
1264 v_BYTE_t we_custom_event[64];
1265 char *stopBssEvent = "STOP-BSS.response";//17
1266 int event_len = strlen(stopBssEvent);
1267
1268 hddLog(LOG1, FL("BSS stop status = %s"),
1269 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1270 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1271
1272 /* Change the BSS state now since, as we are shutting things down,
1273 * we don't want interfaces to become re-enabled */
1274 pHostapdState->bssState = BSS_STOP;
1275
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301276 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1277 {
1278 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1279 {
1280 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1281 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1282 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1283 }
1284
1285 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1286 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1287 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1288 }
1289
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 /* Stop the pkts from n/w stack as we are going to free all of
1291 * the TX WMM queues for all STAID's */
1292 hdd_hostapd_stop(dev);
1293
1294 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301295 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1296 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1297 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001298
Amar Singhal37e6f052013-03-05 16:16:54 -08001299 /* once the event is set, structure dev/pHostapdAdapter should
1300 * not be touched since they are now subject to being deleted
1301 * by another thread */
1302 if (eSAP_STOP_BSS_EVENT == sapEvent)
1303 vos_event_set(&pHostapdState->vosEvent);
1304
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 /* notify userspace that the BSS has stopped */
1306 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1307 memcpy(&we_custom_event, stopBssEvent, event_len);
1308 memset(&wrqu, 0, sizeof(wrqu));
1309 wrqu.data.length = event_len;
1310 we_event = IWEVCUSTOM;
1311 we_custom_event_generic = we_custom_event;
1312 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001313 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 }
1315 return VOS_STATUS_SUCCESS;
1316}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001317
1318int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001320 eCsrEncryptionType *pEncryptType,
1321 eCsrEncryptionType *mcEncryptType,
1322 eCsrAuthType *pAuthType,
1323 v_BOOL_t *pMFPCapable,
1324 v_BOOL_t *pMFPRequired,
1325 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 u_int8_t *gen_ie )
1327{
1328 tDot11fIERSN dot11RSNIE;
1329 tDot11fIEWPA dot11WPAIE;
1330
1331 tANI_U8 *pRsnIe;
1332 tANI_U16 RSNIeLen;
1333
1334 if (NULL == halHandle)
1335 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001336 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 return -EINVAL;
1338 }
1339
1340 // Validity checks
1341 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1342 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1343 return -EINVAL;
1344 // Type check
1345 if ( gen_ie[0] == DOT11F_EID_RSN)
1346 {
1347 // Validity checks
1348 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1349 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1350 {
1351 return VOS_STATUS_E_FAILURE;
1352 }
1353 // Skip past the EID byte and length byte
1354 pRsnIe = gen_ie + 2;
1355 RSNIeLen = gen_ie_len - 2;
1356 // Unpack the RSN IE
1357 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1358 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1359 pRsnIe,
1360 RSNIeLen,
1361 &dot11RSNIE);
1362 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001363 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001364 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001365 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001366 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 /*Here we have followed the apple base code,
1368 but probably I suspect we can do something different*/
1369 //dot11RSNIE.akm_suite_count
1370 // Just translate the FIRST one
1371 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1372 //dot11RSNIE.pwise_cipher_suite_count
1373 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1374 //dot11RSNIE.gp_cipher_suite_count
1375 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1376 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001377 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1378 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001379
1380 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1381 } else
1382 if (gen_ie[0] == DOT11F_EID_WPA)
1383 {
1384 // Validity checks
1385 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1386 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1387 {
1388 return VOS_STATUS_E_FAILURE;
1389 }
1390 // Skip past the EID byte and length byte - and four byte WiFi OUI
1391 pRsnIe = gen_ie + 2 + 4;
1392 RSNIeLen = gen_ie_len - (2 + 4);
1393 // Unpack the WPA IE
1394 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1395 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1396 pRsnIe,
1397 RSNIeLen,
1398 &dot11WPAIE);
1399 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001400 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001401 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001402 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001403 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 //dot11WPAIE.auth_suite_count
1405 // Just translate the FIRST one
1406 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1407 //dot11WPAIE.unicast_cipher_count
1408 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1409 //dot11WPAIE.unicast_cipher_count
1410 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001411 *pMFPCapable = VOS_FALSE;
1412 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 }
1414 else
1415 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001416 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 return VOS_STATUS_E_FAILURE;
1418 }
1419 return VOS_STATUS_SUCCESS;
1420}
Leo Chang614d2072013-08-22 14:59:44 -07001421
Leo Chang0b0e45a2013-12-15 15:18:55 -08001422#ifdef FEATURE_WLAN_CH_AVOID
1423/**---------------------------------------------------------------------------
1424
1425 \brief hdd_hostapd_freq_to_chn() -
1426
1427 Input frequency translated into channel number
1428
1429 \param - freq input frequency with order of kHz
1430
1431 \return - corresponding channel number.
1432 incannot find correct channel number, return 0
1433
1434 --------------------------------------------------------------------------*/
1435v_U16_t hdd_hostapd_freq_to_chn
1436(
1437 v_U16_t freq
1438)
1439{
1440 int loop;
1441
1442 for (loop = 0; loop < NUM_20MHZ_RF_CHANNELS; loop++)
1443 {
1444 if (rfChannels[loop].targetFreq == freq)
1445 {
1446 return rfChannels[loop].channelNum;
1447 }
1448 }
1449
1450 return (0);
1451}
1452
1453/*==========================================================================
1454 FUNCTION sapUpdateUnsafeChannelList
1455
1456 DESCRIPTION
1457 Function Undate unsafe channel list table
1458
1459 DEPENDENCIES
1460 NA.
1461
1462 PARAMETERS
1463
1464 IN
1465 pSapCtx : SAP context pointer, include unsafe channel list
1466
1467 RETURN VALUE
1468 NONE
1469============================================================================*/
1470void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1471 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1472{
1473 v_U16_t i, j;
1474
1475 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1476 sizeof(pHddCtx->unsafeChannelList));
1477 if (0 == unsafeChannelCount)
1478 {
1479 pHddCtx->unsafeChannelCount = 0;
1480 }
1481 else
1482 {
c_hpothu8de53e42014-08-22 15:00:37 +05301483 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1484 {
1485 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1486 FL("unsafeChannelCount%hd greater than %d"),
1487 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1488 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1489 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001490 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1491 unsafeChannelList,
1492 unsafeChannelCount * sizeof(tANI_U16));
1493 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1494 }
1495
1496 /* Flush, default set all channel safe */
1497 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1498 {
1499 safeChannels[i].isSafe = VOS_TRUE;
1500 }
1501
1502 /* Try to find unsafe channel */
1503 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1504 {
1505 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1506 {
1507 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1508 {
1509 /* Found unsafe channel, update it */
1510 safeChannels[j].isSafe = VOS_FALSE;
1511 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1512 "%s : CH %d is not safe",
1513 __func__, pHddCtx->unsafeChannelList[i]);
1514 break;
1515 }
1516 }
1517 }
1518
1519 return;
1520}
1521
1522/**---------------------------------------------------------------------------
1523
1524 \brief hdd_hostapd_ch_avoid_cb() -
1525
1526 Avoid channel notification from FW handler.
1527 FW will send un-safe channle list to avoid overwrapping.
1528 hostapd should not use notified channel
1529
1530 \param - pAdapter HDD adapter pointer
1531 indParam channel avoid notification parameter
1532
1533 \return - None
1534
1535 --------------------------------------------------------------------------*/
1536void hdd_hostapd_ch_avoid_cb
1537(
1538 void *pAdapter,
1539 void *indParam
1540)
1541{
1542 hdd_adapter_t *pHostapdAdapter = NULL;
1543 hdd_context_t *hddCtxt;
1544 tSirChAvoidIndType *chAvoidInd;
1545 v_U8_t rangeLoop;
1546 v_U16_t channelLoop;
1547 v_U16_t dupCheck;
1548 v_U16_t startChannel;
1549 v_U16_t endChannel;
1550 v_U16_t unsafeChannelCount = 0;
1551 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1552 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001553 tHddAvoidFreqList hddAvoidFreqList;
1554 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301555#ifdef WLAN_FEATURE_AP_HT40_24G
1556 ptSapContext pSapCtx = NULL;
1557 tHalHandle hHal;
1558 v_U8_t cbMode;
1559 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1560 v_U32_t delay;
1561#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001562
1563 /* Basic sanity */
1564 if ((NULL == pAdapter) || (NULL == indParam))
1565 {
1566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1567 "%s : Invalid arguments", __func__);
1568 return;
1569 }
1570
1571 hddCtxt = (hdd_context_t *)pAdapter;
1572 chAvoidInd = (tSirChAvoidIndType *)indParam;
1573 pVosContext = hddCtxt->pvosContext;
1574
1575 /* Make unsafe channel list */
1576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1577 "%s : band count %d",
1578 __func__, chAvoidInd->avoidRangeCount);
1579 vos_mem_zero((void *)unsafeChannelList,
1580 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1581 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1582 {
1583 startChannel = hdd_hostapd_freq_to_chn(
1584 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
1585 endChannel = hdd_hostapd_freq_to_chn(
1586 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1588 "%s : start %d : %d, end %d : %d",
1589 __func__,
1590 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1591 startChannel,
1592 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1593 endChannel);
1594 for (channelLoop = startChannel;
1595 channelLoop < (endChannel + 1);
1596 channelLoop++)
1597 {
1598 /* Channel duplicate check routine */
1599 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1600 {
1601 if (unsafeChannelList[dupCheck] == channelLoop)
1602 {
1603 /* This channel is duplicated */
1604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1605 "%s : found duplicated channel %d",
1606 __func__, channelLoop);
1607 break;
1608 }
1609 }
1610 if (dupCheck == unsafeChannelCount)
1611 {
c_hpothu8de53e42014-08-22 15:00:37 +05301612 int ii;
1613 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1614 {
1615 if (channelLoop == safeChannels[ii].channelNumber)
1616 {
1617 unsafeChannelList[unsafeChannelCount] = channelLoop;
1618 unsafeChannelCount++;
1619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1620 "%s : unsafe channel %d, count %d",
1621 __func__,
1622 channelLoop, unsafeChannelCount);
1623 }
1624 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001625 }
1626 else
1627 {
1628 /* DUP, do nothing */
1629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1630 "%s : duplicated channel %d",
1631 __func__, channelLoop);
1632 }
1633 }
1634 }
1635 /* Update unsafe channel cache
1636 * WCN Platform Driver cache */
1637 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1638 unsafeChannelCount);
1639
1640 /* Store into local cache
1641 * Start with STA and later start SAP
1642 * in this scenario, local cache will be used */
1643 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1644 unsafeChannelList,
1645 unsafeChannelCount);
1646
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001647 /* generate vendor specific event */
1648 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1649 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1650 {
1651 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1652 chAvoidInd->avoidFreqRange[i].startFreq;
1653 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1654 chAvoidInd->avoidFreqRange[i].endFreq;
1655 }
1656 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1657
1658 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1659
Leo Chang0b0e45a2013-12-15 15:18:55 -08001660 /* Get SAP context first
1661 * SAP and P2PGO would not concurrent */
1662 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301663#ifdef WLAN_FEATURE_AP_HT40_24G
1664 if (NULL == pHostapdAdapter)
1665 {
1666 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1667 }
1668#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301669 if ((pHostapdAdapter) &&
1670 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1671 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001672 {
1673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1674 "%s : Current operation channel %d",
1675 __func__,
1676 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1677 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1678 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301679 if ((unsafeChannelList[channelLoop] ==
1680 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1681 {
1682 if ((AUTO_CHANNEL_SELECT ==
1683 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1684 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1685 {
1686 /* current operating channel is un-safe channel
1687 * restart driver */
1688 hdd_hostapd_stop(pHostapdAdapter->dev);
1689 /* On LE, this event is handled by wlan-services to
1690 * restart SAP. On android, this event would be
1691 * ignored.
1692 */
1693 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1694 NULL, 0);
1695 }
1696 return;
1697 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001698 }
1699 }
1700
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301701#ifdef WLAN_FEATURE_AP_HT40_24G
1702 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1703 {
1704 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1705
1706 if(pSapCtx == NULL)
1707 {
1708 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1709 FL("psapCtx is NULL"));
1710 return;
1711 }
1712
1713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1714 FL("SAP Secondary channel: %d "),
1715 pSapCtx->sap_sec_chan);
1716
1717 /* tHalHandle */
1718 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1719
1720 if (NULL == hHal)
1721 {
1722 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1723 FL("In invalid hHal"));
1724 return;
1725 }
1726
1727 cbMode = sme_GetChannelBondingMode24G(hHal);
1728
1729 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1730 FL("Selected Channel bonding : %d"), cbMode);
1731
1732 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1733 {
1734 int i;
1735 eHalStatus halStatus;
1736
1737 for (i = 0; i < unsafeChannelCount; i++)
1738 {
1739 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1740 {
1741 /* Current SAP Secondary channel is un-safe channel */
1742 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1743 FL("Move SAP from HT40 to HT20"));
1744
1745 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1746 PHY_SINGLE_CHANNEL_CENTERED);
1747
1748 if (halStatus == eHAL_STATUS_FAILURE)
1749 {
1750 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1751 FL("Failed to change HT20/40 mode"));
1752 return;
1753 }
1754
1755 /* Disable Channel Bonding for 2.4GHz */
1756 sme_UpdateChannelBondingMode24G(hHal,
1757 PHY_SINGLE_CHANNEL_CENTERED);
1758 return;
1759 }
1760 }
1761 }
1762
1763 if ((!pSapCtx->numHT40IntoSta)
1764 && (pHostapdAdapter)
1765 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1766 {
1767 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1768 * are Safe then start HT20/40 timer to Move SAP from HT20
1769 * to HT40.
1770 */
1771 if (((!unsafeChannelCount)
1772 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1773 {
1774 /* Stop Previous Running HT20/40 Timer & Start timer
1775 with (OBSS TransitionDelayFactor * obss interval)
1776 delay after time out move AP from HT20 -> HT40
1777 mode
1778 */
1779 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1780 {
1781 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1782 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1783 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1784 FL("Failed to Stop HT20/40 timer"));
1785 }
1786
1787 delay =
1788 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1789
1790 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1791 FL("Start HT20/40 transition timer (%d sec)"), delay);
1792
1793 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1794 (delay * 1000));
1795
1796 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1797 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1798 FL("Failed to Start HT20/40 timer"));
1799 }
1800 else
1801 {
1802 /* Stop HT20/40 Timer */
1803 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1804 {
1805 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1806 FL("Stop HT20/40 transition timer"));
1807 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1808 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1809 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1810 FL("Failed to Stop HT20/40 timer"));
1811 }
1812 }
1813 }
1814 }
1815#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001816 return;
1817}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001818#endif /* FEATURE_WLAN_CH_AVOID */
1819
Jeff Johnson295189b2012-06-20 16:38:30 -07001820int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301821static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 struct iw_request_info *info,
1823 union iwreq_data *wrqu, char *extra)
1824{
1825 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001826 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301827 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 int *value = (int *)extra;
1829 int sub_cmd = value[0];
1830 int set_value = value[1];
1831 eHalStatus status;
1832 int ret = 0; /* success */
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001833 v_CONTEXT_t pVosContext;
1834
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301835 ENTER();
1836
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301837 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001838 {
1839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301840 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001841 __func__);
1842 return -1;
1843 }
1844
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301845 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1846 ret = wlan_hdd_validate_context(pHddCtx);
1847 if (0 != ret)
1848 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301849 return -1;
1850 }
1851
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001852 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1853 if (!hHal)
1854 {
1855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1856 "%s: Hal ctx is null", __func__);
1857 return -1;
1858 }
1859
1860 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1861 if (!pVosContext)
1862 {
1863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1864 "%s: Vos ctx is null", __func__);
1865 return -1;
1866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001867
1868 switch(sub_cmd)
1869 {
1870
1871 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001872 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301874 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 }
1876 break;
1877
1878 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301879 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1881 {
1882 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1883 ret = -EINVAL;
1884 }
1885 else
1886 {
1887 WLANSAP_SetMode(pVosContext, set_value);
1888 }
1889 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301890
1891 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1892 if ((0 != set_value) && (1 != set_value))
1893 {
1894 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1895 ret = -EINVAL;
1896 }
1897 else
1898 {
1899 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1900 }
1901 break;
1902
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 case QCSAP_PARAM_MAX_ASSOC:
1904 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1905 {
1906 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1907 ret = -EINVAL;
1908 }
1909 else
1910 {
1911 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1912 {
1913 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1914 "Setting it to max allowed and continuing"),
1915 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1916 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1917 }
1918 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1919 set_value, NULL, eANI_BOOLEAN_FALSE);
1920 if ( status != eHAL_STATUS_SUCCESS )
1921 {
1922 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1923 status);
1924 ret = -EIO;
1925 }
1926 }
1927 break;
1928
1929 case QCSAP_PARAM_HIDE_SSID:
1930 {
1931 eHalStatus status = eHAL_STATUS_SUCCESS;
1932 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1933 if(eHAL_STATUS_SUCCESS != status)
1934 {
1935 hddLog(VOS_TRACE_LEVEL_ERROR,
1936 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001937 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 return status;
1939 }
1940 break;
1941 }
1942
Leo Chang614d2072013-08-22 14:59:44 -07001943 case QCSAP_PARAM_SET_MC_RATE:
1944 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001945 tSirRateUpdateInd *rateUpdate;
1946
1947 rateUpdate = (tSirRateUpdateInd *)
1948 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1949 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001950 {
1951 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001952 "%s: SET_MC_RATE indication alloc fail", __func__);
1953 ret = -1;
1954 break;
1955 }
1956 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1957
1958 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1959 /* Ignore unicast */
1960 rateUpdate->ucastDataRate = -1;
1961 rateUpdate->mcastDataRate24GHz = set_value;
1962 rateUpdate->mcastDataRate5GHz = set_value;
1963 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1964 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1965 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1966 if (eHAL_STATUS_SUCCESS != status)
1967 {
1968 hddLog(VOS_TRACE_LEVEL_ERROR,
1969 "%s: SET_MC_RATE failed", __func__);
1970 vos_mem_free(rateUpdate);
1971 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001972 }
1973 break;
1974 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05301975 case QCSAP_PARAM_GET_FRAME_LOGS:
1976 {
1977 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
1978 != VOS_STATUS_SUCCESS)
1979 {
1980 ret = -EINVAL;
1981 }
1982 break;
1983 }
Leo Chang614d2072013-08-22 14:59:44 -07001984
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 default:
1986 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1987 sub_cmd, set_value);
1988 ret = -EINVAL;
1989 break;
1990 }
1991
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301992 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 return ret;
1994}
1995
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301996int
1997static iw_softap_setparam(struct net_device *dev,
1998 struct iw_request_info *info,
1999 union iwreq_data *wrqu, char *extra)
2000{
2001 int ret;
2002
2003 vos_ssr_protect(__func__);
2004 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2005 vos_ssr_unprotect(__func__);
2006
2007 return ret;
2008}
Jeff Johnson295189b2012-06-20 16:38:30 -07002009
2010int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302011static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 struct iw_request_info *info,
2013 union iwreq_data *wrqu, char *extra)
2014{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302015 hdd_adapter_t *pHostapdAdapter;
2016 tHalHandle hHal;
2017 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 int *value = (int *)extra;
2019 int sub_cmd = value[0];
2020 eHalStatus status;
2021 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302022 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002023
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302024 ENTER();
2025
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302026 pHostapdAdapter = (netdev_priv(dev));
2027 if (NULL == pHostapdAdapter)
2028 {
2029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2030 "%s: Adapter is NULL",__func__);
2031 return -EINVAL;
2032 }
2033 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2034 ret = wlan_hdd_validate_context(pHddCtx);
2035 if (0 != ret)
2036 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302037 return ret;
2038 }
2039 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2040 if (NULL == hHal)
2041 {
2042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2043 "%s: Hal Context is NULL",__func__);
2044 return -EINVAL;
2045 }
2046 pVosContext = pHddCtx->pvosContext;
2047 if (NULL == pVosContext)
2048 {
2049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2050 "%s: pVosContext Context is NULL",__func__);
2051 return -EINVAL;
2052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 switch (sub_cmd)
2054 {
2055 case QCSAP_PARAM_MAX_ASSOC:
2056 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2057 if (eHAL_STATUS_SUCCESS != status)
2058 {
c_hpothuffdb5272013-10-02 16:42:35 +05302059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2060 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 ret = -EIO;
2062 }
Girish Gowli385be612014-09-18 11:17:20 +05302063
2064#ifdef WLAN_SOFTAP_VSTA_FEATURE
2065 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2066 {
2067 if (*value > VSTA_NUM_ASSOC_STA)
2068 {
2069 *value = VSTA_NUM_ASSOC_STA;
2070 }
2071 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2072 (*value > (VSTA_NUM_ASSOC_STA -
2073 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2074 {
2075 *value = (VSTA_NUM_ASSOC_STA -
2076 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2077 }
2078 }
2079 else
2080#endif
2081 {
2082 if (*value > NUM_ASSOC_STA)
2083 {
2084 *value = NUM_ASSOC_STA;
2085 }
2086 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2087 (*value > (NUM_ASSOC_STA -
2088 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2089 {
2090 *value = (NUM_ASSOC_STA -
2091 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2092 }
2093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002097 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 {
c_hpothuffdb5272013-10-02 16:42:35 +05302099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2100 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302101 ret = -EIO;
2102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 *value = 0;
2104 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302105
Jeff Johnson43971f52012-07-17 12:26:56 -07002106 case QCSAP_PARAM_GET_WLAN_DBG:
2107 {
2108 vos_trace_display();
2109 *value = 0;
2110 break;
2111 }
2112
2113 case QCSAP_PARAM_AUTO_CHANNEL:
2114 {
2115 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2116 break;
2117 }
2118
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 default:
2120 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2121 ret = -EINVAL;
2122 break;
2123
2124 }
2125
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302126 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 return ret;
2128}
2129
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302130int
2131static iw_softap_getparam(struct net_device *dev,
2132 struct iw_request_info *info,
2133 union iwreq_data *wrqu, char *extra)
2134{
2135 int ret;
2136
2137 vos_ssr_protect(__func__);
2138 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2139 vos_ssr_unprotect(__func__);
2140
2141 return ret;
2142}
Jeff Johnson295189b2012-06-20 16:38:30 -07002143/* Usage:
2144 BLACK_LIST = 0
2145 WHITE_LIST = 1
2146 ADD MAC = 0
2147 REMOVE MAC = 1
2148
2149 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2150 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2151 while using this ioctl
2152
2153 Syntax:
2154 iwpriv softap.0 modify_acl
2155 <6 octet mac addr> <list type> <cmd type>
2156
2157 Examples:
2158 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2159 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2160 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2161 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2162*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302163int __iw_softap_modify_acl(struct net_device *dev,
2164 struct iw_request_info *info,
2165 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002166{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302167 hdd_adapter_t *pHostapdAdapter;
2168 v_CONTEXT_t pVosContext;
2169 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 v_BYTE_t *value = (v_BYTE_t*)extra;
2171 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2172 int listType, cmd, i;
2173 int ret = 0; /* success */
2174
2175 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302176 pHostapdAdapter = (netdev_priv(dev));
2177 if (NULL == pHostapdAdapter)
2178 {
2179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2180 "%s: Adapter is NULL",__func__);
2181 return -EINVAL;
2182 }
2183 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2184 ret = wlan_hdd_validate_context(pHddCtx);
2185 if (0 != ret)
2186 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302187 return ret;
2188 }
2189 pVosContext = pHddCtx->pvosContext;
2190 if (NULL == pVosContext)
2191 {
2192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2193 "%s: Vos Context is NULL",__func__);
2194 return -EINVAL;
2195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2197 {
2198 pPeerStaMac[i] = *(value+i);
2199 }
2200 listType = (int)(*(value+i));
2201 i++;
2202 cmd = (int)(*(value+i));
2203
Arif Hussain24bafea2013-11-15 15:10:03 -08002204 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2205 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002206
2207 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2208 != VOS_STATUS_SUCCESS)
2209 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002210 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 ret = -EIO;
2212 }
2213 EXIT();
2214 return ret;
2215}
2216
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302217int iw_softap_modify_acl(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu, char *extra)
2220{
2221 int ret;
2222
2223 vos_ssr_protect(__func__);
2224 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2225 vos_ssr_unprotect(__func__);
2226
2227 return ret;
2228}
2229
Jeff Johnson295189b2012-06-20 16:38:30 -07002230int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302231static __iw_softap_getchannel(struct net_device *dev,
2232 struct iw_request_info *info,
2233 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002234{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302235 hdd_adapter_t *pHostapdAdapter;
2236 hdd_context_t *pHddCtx;
2237 int ret = 0;
2238 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302239
2240 ENTER();
2241
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302242 pHostapdAdapter = (netdev_priv(dev));
2243 if (NULL == pHostapdAdapter)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2246 "%s: Adapter is NULL",__func__);
2247 return -EINVAL;
2248 }
2249 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2250 ret = wlan_hdd_validate_context(pHddCtx);
2251 if (0 != ret)
2252 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302253 return ret;
2254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002255
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302256 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
Jeff Johnson43971f52012-07-17 12:26:56 -07002258 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302259
2260 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 return 0;
2262}
2263
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302264
Jeff Johnsone7245742012-09-05 17:12:55 -07002265int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302266static iw_softap_getchannel(struct net_device *dev,
2267 struct iw_request_info *info,
2268 union iwreq_data *wrqu, char *extra)
2269{
2270 int ret;
2271
2272 vos_ssr_protect(__func__);
2273 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2274 vos_ssr_unprotect(__func__);
2275
2276 return ret;
2277}
2278
2279int
2280static __iw_softap_set_max_tx_power(struct net_device *dev,
2281 struct iw_request_info *info,
2282 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002283{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302284 hdd_adapter_t *pHostapdAdapter;
2285 tHalHandle hHal;
2286 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002287 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302288 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002289 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2290 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2291
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302292 ENTER();
2293
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302294 pHostapdAdapter = (netdev_priv(dev));
2295 if (NULL == pHostapdAdapter)
2296 {
2297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2298 "%s: Adapter is NULL",__func__);
2299 return -EINVAL;
2300 }
2301 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2302 ret = wlan_hdd_validate_context(pHddCtx);
2303 if (0 != ret)
2304 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302305 return ret;
2306 }
2307 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2308 if (NULL == hHal)
2309 {
2310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2311 "%s: Hal Context is NULL",__func__);
2312 return -EINVAL;
2313 }
schang86c22c42013-03-13 18:41:24 -07002314 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002315 return -ENOMEM;
2316
Leo Changd37675a2013-08-01 13:19:45 -07002317 /* Assign correct slef MAC address */
2318 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2319 VOS_MAC_ADDR_SIZE);
2320 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2321 VOS_MAC_ADDR_SIZE);
2322
schang86c22c42013-03-13 18:41:24 -07002323 set_value = value[0];
2324 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2325 {
2326 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002327 __func__);
schang86c22c42013-03-13 18:41:24 -07002328 return -EIO;
2329 }
2330
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302331 EXIT();
schang86c22c42013-03-13 18:41:24 -07002332 return 0;
2333}
2334
2335int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302336static iw_softap_set_max_tx_power(struct net_device *dev,
2337 struct iw_request_info *info,
2338 union iwreq_data *wrqu, char *extra)
2339{
2340 int ret;
2341
2342 vos_ssr_protect(__func__);
2343 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2344 vos_ssr_unprotect(__func__);
2345
2346 return ret;
2347}
2348
2349
2350int
2351static __iw_display_data_path_snapshot(struct net_device *dev,
2352 struct iw_request_info *info,
2353 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302354{
2355
2356 /* Function intitiating dumping states of
2357 * HDD(WMM Tx Queues)
2358 * TL State (with Per Client infor)
2359 * DXE Snapshot (Called at the end of TL Snapshot)
2360 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302361 hdd_adapter_t *pHostapdAdapter;
2362 hdd_context_t *pHddCtx;
2363 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302364
2365 ENTER();
2366
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302367 pHostapdAdapter = (netdev_priv(dev));
2368 if (NULL == pHostapdAdapter)
2369 {
2370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2371 "%s: Adapter is NULL",__func__);
2372 return -EINVAL;
2373 }
2374 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2375 ret = wlan_hdd_validate_context(pHddCtx);
2376 if (0 != ret)
2377 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302378 return ret;
2379 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302380 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302381 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302382
2383 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302384 return 0;
2385}
2386
2387int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302388static iw_display_data_path_snapshot(struct net_device *dev,
2389 struct iw_request_info *info,
2390 union iwreq_data *wrqu, char *extra)
2391{
2392 int ret;
2393
2394 vos_ssr_protect(__func__);
2395 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2396 vos_ssr_unprotect(__func__);
2397
2398 return ret;
2399}
2400
2401int
2402static __iw_softap_set_tx_power(struct net_device *dev,
2403 struct iw_request_info *info,
2404 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002405{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302406 hdd_adapter_t *pHostapdAdapter;
2407 hdd_context_t *pHddCtx;
2408 v_CONTEXT_t pVosContext;
2409 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002410 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302411 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002412 ptSapContext pSapCtx = NULL;
2413
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302414 ENTER();
2415
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302416 pHostapdAdapter = (netdev_priv(dev));
2417 if (NULL == pHostapdAdapter)
2418 {
2419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2420 "%s: Adapter is NULL",__func__);
2421 return -EINVAL;
2422 }
2423 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2424 ret = wlan_hdd_validate_context(pHddCtx);
2425 if (0 != ret)
2426 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302427 return ret;
2428 }
2429 pVosContext = pHddCtx->pvosContext;
2430 if (NULL == pVosContext)
2431 {
2432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2433 "%s: Vos Context is NULL",__func__);
2434 return -EINVAL;
2435 }
2436 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2437 if (NULL == hHal)
2438 {
2439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2440 "%s: Hal Context is NULL",__func__);
2441 return -EINVAL;
2442 }
schang86c22c42013-03-13 18:41:24 -07002443 if (NULL == value)
2444 return -ENOMEM;
2445
2446 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2447 if (NULL == pSapCtx)
2448 {
2449 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2450 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2451 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002452 }
2453
2454 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002455 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002456 {
schang86c22c42013-03-13 18:41:24 -07002457 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002458 __func__);
2459 return -EIO;
2460 }
2461
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302462 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002463 return 0;
2464}
2465
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302466int
2467static iw_softap_set_tx_power(struct net_device *dev,
2468 struct iw_request_info *info,
2469 union iwreq_data *wrqu, char *extra)
2470{
2471 int ret;
2472
2473 vos_ssr_protect(__func__);
2474 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2475 vos_ssr_unprotect(__func__);
2476
2477 return ret;
2478}
2479
Kiet Lambcf38522013-10-26 18:28:27 +05302480/**---------------------------------------------------------------------------
2481
2482 \brief iw_softap_set_trafficmonitor() -
2483 This function dynamically enable/disable traffic monitor functonality
2484 the command iwpriv wlanX setTrafficMon <value>.
2485
2486 \param - dev - Pointer to the net device.
2487 - addr - Pointer to the sockaddr.
2488 \return - 0 for success, non zero for failure
2489
2490 --------------------------------------------------------------------------*/
2491
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302492static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2493 struct iw_request_info *info,
2494 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302495{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302496 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302497 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302498 hdd_context_t *pHddCtx;
2499 int status;
2500
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302501 ENTER();
2502
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302503 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302504 if (NULL == pAdapter)
2505 {
2506 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2507 "%s: HDD adapter is Null", __func__);
2508 return -ENODEV;
2509 }
2510
2511 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2512
2513 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302514 if (0 != status)
2515 {
Kiet Lambcf38522013-10-26 18:28:27 +05302516 return status;
2517 }
2518
2519 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2520
2521 if (NULL == isSetTrafficMon)
2522 {
2523 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2524 "%s: Invalid SAP pointer from extra", __func__);
2525 return -ENOMEM;
2526 }
2527
2528 if (TRUE == *isSetTrafficMon)
2529 {
2530 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2531 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2532 {
2533 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2534 "%s: failed to Start Traffic Monitor timer ", __func__ );
2535 return -EIO;
2536 }
2537 }
2538 else if (FALSE == *isSetTrafficMon)
2539 {
2540 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2541 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2542 {
2543 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2544 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2545 return -EIO;
2546 }
2547
2548 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302549
2550 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302551 return 0;
2552}
2553
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302554static int iw_softap_set_trafficmonitor(struct net_device *dev,
2555 struct iw_request_info *info,
2556 union iwreq_data *wrqu, char *extra)
2557{
2558 int ret;
2559
2560 vos_ssr_protect(__func__);
2561 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2562 vos_ssr_unprotect(__func__);
2563
2564 return ret;
2565}
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2568
2569int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302570static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2571 struct iw_request_info *info,
2572 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002573{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302574 hdd_adapter_t *pHostapdAdapter;
2575 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302576 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002577 char *buf;
2578 int cnt = 0;
2579 int left;
2580 int ret = 0;
2581 /* maclist_index must be u32 to match userspace */
2582 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302583 v_CONTEXT_t pVosContext = NULL;
2584 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302585
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302586 ENTER();
2587
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302588 pHostapdAdapter = (netdev_priv(dev));
2589 if (NULL == pHostapdAdapter)
2590 {
2591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2592 "%s: Adapter is NULL",__func__);
2593 return -EINVAL;
2594 }
2595 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2596 ret = wlan_hdd_validate_context(pHddCtx);
2597 if (0 != ret)
2598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302599 return ret;
2600 }
2601
Jeff Johnson224f3702014-03-26 11:09:47 -07002602 /*
2603 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2604 * number, and even numbered iocts are supposed to have "set"
2605 * semantics. Hence the wireless extensions support in the kernel
2606 * won't correctly copy the result to userspace, so the ioctl
2607 * handler itself must copy the data. Output format is 32-bit
2608 * record length, followed by 0 or more 6-byte STA MAC addresses.
2609 *
2610 * Further note that due to the incorrect semantics, the "iwpriv"
2611 * userspace application is unable to correctly invoke this API,
2612 * hence it is not registered in the hostapd_private_args. This
2613 * API can only be invoked by directly invoking the ioctl() system
2614 * call.
2615 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002616
Jeff Johnson224f3702014-03-26 11:09:47 -07002617 /* make sure userspace allocated a reasonable buffer size */
2618 if (wrqu->data.length < sizeof(maclist_index)) {
2619 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2620 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002622
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302623 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2624 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2625 if(pSapCtx == NULL){
2626 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2627 FL("psapCtx is NULL"));
2628 return -EFAULT;
2629 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302630
2631 /* allocate local buffer to build the response */
2632 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2633 if (!buf) {
2634 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2635 return -ENOMEM;
2636 }
2637
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302638 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002639 /* start indexing beyond where the record count will be written */
2640 maclist_index = sizeof(maclist_index);
2641 left = wrqu->data.length - maclist_index;
2642
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302643 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002644 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2645 if ((pStaInfo[cnt].isUsed) &&
2646 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2647 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2648 VOS_MAC_ADDR_SIZE);
2649 maclist_index += VOS_MAC_ADDR_SIZE;
2650 left -= VOS_MAC_ADDR_SIZE;
2651 }
2652 cnt++;
2653 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302654 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002655
2656 *((u32 *)buf) = maclist_index;
2657 wrqu->data.length = maclist_index;
2658 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2659 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2660 ret = -EFAULT;
2661 }
2662 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302663
2664 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002665 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002666}
2667
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302668int
2669static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
2672{
2673 int ret;
2674
2675 vos_ssr_protect(__func__);
2676 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2677 vos_ssr_unprotect(__func__);
2678
2679 return ret;
2680}
2681
Jeff Johnson295189b2012-06-20 16:38:30 -07002682/* Usage:
2683 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2684 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2685 while using this ioctl
2686
2687 Syntax:
2688 iwpriv softap.0 disassoc_sta <6 octet mac address>
2689
2690 e.g.
2691 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2692 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2693*/
2694
2695int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302696static __iw_softap_disassoc_sta(struct net_device *dev,
2697 struct iw_request_info *info,
2698 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002699{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302700 hdd_adapter_t *pHostapdAdapter;
2701 hdd_context_t *pHddCtx;
2702 v_U8_t *peerMacAddr;
2703 int ret = 0;
2704
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302706
2707 if (!capable(CAP_NET_ADMIN)) {
2708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2709 FL("permission check failed"));
2710 return -EPERM;
2711 }
2712
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302713 pHostapdAdapter = (netdev_priv(dev));
2714 if (NULL == pHostapdAdapter)
2715 {
2716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2717 "%s: Adapter is NULL",__func__);
2718 return -EINVAL;
2719 }
2720 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2721 ret = wlan_hdd_validate_context(pHddCtx);
2722 if (0 != ret)
2723 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302724 return ret;
2725 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302726 /* iwpriv tool or framework calls this ioctl with
2727 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302729 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002730
Arif Hussain24bafea2013-11-15 15:10:03 -08002731 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2732 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2734 EXIT();
2735 return 0;
2736}
2737
2738int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302739static iw_softap_disassoc_sta(struct net_device *dev,
2740 struct iw_request_info *info,
2741 union iwreq_data *wrqu, char *extra)
2742{
2743 int ret;
2744
2745 vos_ssr_protect(__func__);
2746 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2747 vos_ssr_unprotect(__func__);
2748
2749 return ret;
2750}
2751
2752int
2753static __iw_softap_ap_stats(struct net_device *dev,
2754 struct iw_request_info *info,
2755 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002756{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302757 hdd_adapter_t *pHostapdAdapter;
2758 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 WLANTL_TRANSFER_STA_TYPE statBuffer;
2760 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302761 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002762
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302763 ENTER();
2764
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302765 pHostapdAdapter = (netdev_priv(dev));
2766 if (NULL == pHostapdAdapter)
2767 {
2768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2769 "%s: Adapter is NULL",__func__);
2770 return -EINVAL;
2771 }
2772 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2773 ret = wlan_hdd_validate_context(pHddCtx);
2774 if (0 != ret)
2775 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302776 return ret;
2777 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002778 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002779 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2780 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002781
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302782 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002783 if(NULL == pstatbuf) {
2784 hddLog(LOG1, "unable to allocate memory");
2785 return -ENOMEM;
2786 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302787
2788 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002789 "RUF=%d RMF=%d RBF=%d "
2790 "RUB=%d RMB=%d RBB=%d "
2791 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302792 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002793 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2794 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2795 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2796 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2797 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2798 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002799
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302800 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002801 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2802 kfree(pstatbuf);
2803 return -EFAULT;
2804 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302805
2806 strlcpy(extra, pstatbuf, len);
2807 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002808 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302809
2810 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 return 0;
2812}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302813int
2814static __iw_softap_ap_get_stats(struct net_device *dev,
2815 struct iw_request_info *info,
2816 union iwreq_data *wrqu, char *extra)
2817{
2818 hdd_adapter_t *pAdapter;
2819 hdd_tx_rx_stats_t *pStats;
2820
2821 ENTER();
2822 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2823 if (NULL == pAdapter)
2824 {
2825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2826 "%s: Adapter is NULL",__func__);
2827 return -EINVAL;
2828 }
2829
2830 pStats = &pAdapter->hdd_stats.hddTxRxStats;
2831 snprintf(extra, QCSAP_MAX_STR_LEN,
2832 "\nTransmit"
2833 "\ncalled %u, dropped %u, backpressured %u, queued %u"
2834 "\n dropped BK %u, BE %u, VI %u, VO %u"
2835 "\n classified BK %u, BE %u, VI %u, VO %u"
2836 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
2837 "\n queued BK %u, BE %u, VI %u, VO %u"
2838 "\nfetched %u, empty %u, lowres %u, deqerr %u"
2839 "\ndequeued %u, depressured %u, deque-depressured %u,\
2840 completed %u, flushed %u"
2841 "\n fetched BK %u, BE %u, VI %u, VO %u"
2842 "\n dequeued BK %u, BE %u, VI %u, VO %u"
2843 "\n depressured BK %u, BE %u, VI %u, VO %u"
2844 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
2845 "\n flushed BK %u, BE %u, VI %u, VO %u"
2846 "\n\nReceive"
2847 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
2848 "\n\nResetsStats"
2849 "\n",
2850 pStats->txXmitCalled,
2851 pStats->txXmitDropped,
2852 pStats->txXmitBackPressured,
2853 pStats->txXmitQueued,
2854
2855 pStats->txXmitDroppedAC[WLANTL_AC_BK],
2856 pStats->txXmitDroppedAC[WLANTL_AC_BE],
2857 pStats->txXmitDroppedAC[WLANTL_AC_VI],
2858 pStats->txXmitDroppedAC[WLANTL_AC_VO],
2859
2860 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
2861 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
2862 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
2863 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
2864
2865 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
2866 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
2867 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
2868 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
2869
2870 pStats->txXmitQueuedAC[WLANTL_AC_BK],
2871 pStats->txXmitQueuedAC[WLANTL_AC_BE],
2872 pStats->txXmitQueuedAC[WLANTL_AC_VI],
2873 pStats->txXmitQueuedAC[WLANTL_AC_VO],
2874
2875 pStats->txFetched,
2876 pStats->txFetchEmpty,
2877 pStats->txFetchLowResources,
2878 pStats->txFetchDequeueError,
2879
2880 pStats->txFetchDequeued,
2881 pStats->txFetchDePressured,
2882 pStats->txDequeDePressured,
2883 pStats->txCompleted,
2884 pStats->txFlushed,
2885
2886 pStats->txFetchedAC[WLANTL_AC_BK],
2887 pStats->txFetchedAC[WLANTL_AC_BE],
2888 pStats->txFetchedAC[WLANTL_AC_VI],
2889 pStats->txFetchedAC[WLANTL_AC_VO],
2890
2891 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
2892 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
2893 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
2894 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
2895
2896 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
2897 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
2898 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
2899 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
2900
2901 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
2902 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
2903 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
2904 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
2905
2906 pStats->txFlushedAC[WLANTL_AC_BK],
2907 pStats->txFlushedAC[WLANTL_AC_BE],
2908 pStats->txFlushedAC[WLANTL_AC_VI],
2909 pStats->txFlushedAC[WLANTL_AC_VO],
2910
2911 pStats->rxChains,
2912 pStats->rxPackets,
2913 pStats->rxDropped,
2914 pStats->rxDelivered,
2915 pStats->rxRefused
2916 );
2917
2918 wrqu->data.length = strlen(extra) + 1;
2919
2920 return 0;
2921}
2922
2923int
2924static __iw_softap_ap_clear_stats(struct net_device *dev,
2925 struct iw_request_info *info,
2926 union iwreq_data *wrqu, char *extra)
2927{
2928 hdd_adapter_t *pAdapter;
2929
2930 ENTER();
2931
2932 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2933 if (NULL == pAdapter)
2934 {
2935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2936 "%s: Adapter is NULL",__func__);
2937 return -EINVAL;
2938 }
2939
2940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
2941 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
2942 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
2943 return 0;
2944}
2945
2946
2947int
2948static iw_softap_get_stats(struct net_device *dev,
2949 struct iw_request_info *info,
2950 union iwreq_data *wrqu, char *extra)
2951{
2952 int ret;
2953 vos_ssr_protect(__func__);
2954 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
2955 vos_ssr_unprotect(__func__);
2956 return ret;
2957}
2958
2959int
2960static iw_softap_clear_stats(struct net_device *dev,
2961 struct iw_request_info *info,
2962 union iwreq_data *wrqu, char *extra)
2963{
2964 int ret;
2965 vos_ssr_protect(__func__);
2966 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
2967 vos_ssr_unprotect(__func__);
2968 return ret;
2969}
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302971int
2972static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 struct iw_request_info *info,
2974 union iwreq_data *wrqu, char *extra)
2975{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302976 int ret;
2977
2978 vos_ssr_protect(__func__);
2979 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
2980 vos_ssr_unprotect(__func__);
2981
2982 return ret;
2983}
2984
2985static int __iw_softap_set_channel_range(struct net_device *dev,
2986 struct iw_request_info *info,
2987 union iwreq_data *wrqu, char *extra)
2988{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302989 hdd_adapter_t *pHostapdAdapter;
2990 tHalHandle hHal;
2991 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 int *value = (int *)extra;
2993 int startChannel = value[0];
2994 int endChannel = value[1];
2995 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07002996 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 int ret = 0; /* success */
2998
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302999 ENTER();
3000
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303001 if (!capable(CAP_NET_ADMIN))
3002 {
3003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3004 FL("permission check failed"));
3005 return -EPERM;
3006 }
3007
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303008 pHostapdAdapter = (netdev_priv(dev));
3009 if (NULL == pHostapdAdapter)
3010 {
3011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3012 "%s: Adapter is NULL",__func__);
3013 return -EINVAL;
3014 }
3015 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3016 ret = wlan_hdd_validate_context(pHddCtx);
3017 if (0 != ret)
3018 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303019 return ret;
3020 }
3021 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3022 if (NULL == hHal)
3023 {
3024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3025 "%s: Hal Context is NULL",__func__);
3026 return -EINVAL;
3027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3029 if(status != VOS_STATUS_SUCCESS)
3030 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003031 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 startChannel,endChannel, band);
3033 ret = -EINVAL;
3034 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003035
3036 pHddCtx->is_dynamic_channel_range_set = 1;
3037
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303038 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 return ret;
3040}
3041
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303042static int iw_softap_set_channel_range(struct net_device *dev,
3043 struct iw_request_info *info,
3044 union iwreq_data *wrqu, char *extra)
3045{
3046 int ret;
3047
3048 vos_ssr_protect(__func__);
3049 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3050 vos_ssr_unprotect(__func__);
3051
3052 return ret;
3053}
3054
3055
3056int __iw_softap_get_channel_list(struct net_device *dev,
3057 struct iw_request_info *info,
3058 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003059{
3060 v_U32_t num_channels = 0;
3061 v_U8_t i = 0;
3062 v_U8_t bandStartChannel = RF_CHAN_1;
3063 v_U8_t bandEndChannel = RF_CHAN_165;
3064 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303065 hdd_adapter_t *pHostapdAdapter;
3066 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003069 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303070 hdd_context_t *pHddCtx;
3071 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303072
3073 ENTER();
3074
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303075 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3076 if (NULL == pHostapdAdapter)
3077 {
3078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3079 "%s: Adapter is NULL",__func__);
3080 return -EINVAL;
3081 }
3082 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3083 ret = wlan_hdd_validate_context(pHddCtx);
3084 if (0 != ret)
3085 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303086 return ret;
3087 }
3088 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3089 if (NULL == hHal)
3090 {
3091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3092 "%s: Hal Context is NULL",__func__);
3093 return -EINVAL;
3094 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003095 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3096 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003097 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003098 return -EIO;
3099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 wrqu->data.length = sizeof(tChannelListInfo);
3101 ENTER();
3102
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003103 if (eCSR_BAND_24 == curBand)
3104 {
3105 bandStartChannel = RF_CHAN_1;
3106 bandEndChannel = RF_CHAN_14;
3107 }
3108 else if (eCSR_BAND_5G == curBand)
3109 {
3110 bandStartChannel = RF_CHAN_36;
3111 bandEndChannel = RF_CHAN_165;
3112 }
3113
Arif Hussain6d2a3322013-11-17 19:50:10 -08003114 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303115 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003116 bandStartChannel, bandEndChannel );
3117
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3119 {
3120 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3121 {
3122 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3123 num_channels++;
3124 }
3125 }
3126
3127 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3128
3129 temp_num_channels = num_channels;
3130
3131 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3132 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303133 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003134 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303137 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3138 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 {
3140 for(i = 0; i < temp_num_channels; i++)
3141 {
3142
3143 if((channel_list->channels[i] > 35) &&
3144 (channel_list->channels[i] < 49))
3145 {
3146 vos_mem_move(&channel_list->channels[i],
3147 &channel_list->channels[i+1],
3148 temp_num_channels - (i-1));
3149 num_channels--;
3150 temp_num_channels--;
3151 i--;
3152 }
3153 }
3154 }
3155
Arif Hussain6d2a3322013-11-17 19:50:10 -08003156 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157
3158 if (num_channels > IW_MAX_FREQUENCIES)
3159 {
3160 num_channels = IW_MAX_FREQUENCIES;
3161 }
3162
3163 channel_list->num_channels = num_channels;
3164 EXIT();
3165
3166 return 0;
3167}
3168
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303169int iw_softap_get_channel_list(struct net_device *dev,
3170 struct iw_request_info *info,
3171 union iwreq_data *wrqu, char *extra)
3172{
3173 int ret;
3174
3175 vos_ssr_protect(__func__);
3176 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3177 vos_ssr_unprotect(__func__);
3178
3179 return ret;
3180}
3181
3182static
3183int __iw_get_genie(struct net_device *dev,
3184 struct iw_request_info *info,
3185 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003186{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303187 hdd_adapter_t *pHostapdAdapter;
3188 hdd_context_t *pHddCtx;
3189 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 eHalStatus status;
3191 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3192 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303193 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303194
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303196
3197 pHostapdAdapter = (netdev_priv(dev));
3198 if (NULL == pHostapdAdapter)
3199 {
3200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3201 "%s: Adapter is NULL",__func__);
3202 return -EINVAL;
3203 }
3204 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3205 ret = wlan_hdd_validate_context(pHddCtx);
3206 if (0 != ret)
3207 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303208 return ret;
3209 }
3210 pVosContext = pHddCtx->pvosContext;
3211 if (NULL == pVosContext)
3212 {
3213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3214 "%s: vos context is not valid ",__func__);
3215 return -EINVAL;
3216 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003217 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3219 status = WLANSap_getstationIE_information(pVosContext,
3220 &length,
3221 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07003222 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
3223 if (wrqu->data.length < length ||
3224 copy_to_user(wrqu->data.pointer,
3225 (v_VOID_t*)genIeBytes, length))
3226 {
3227 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3228 return -EFAULT;
3229 }
3230 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07003231
Arif Hussain6d2a3322013-11-17 19:50:10 -08003232 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234
3235 EXIT();
3236 return 0;
3237}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303238
3239static
3240int iw_get_genie(struct net_device *dev,
3241 struct iw_request_info *info,
3242 union iwreq_data *wrqu, char *extra)
3243{
3244 int ret;
3245
3246 vos_ssr_protect(__func__);
3247 ret = __iw_get_genie(dev, info, wrqu, extra);
3248 vos_ssr_unprotect(__func__);
3249
3250 return ret;
3251}
3252
3253static
3254int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3255 struct iw_request_info *info,
3256 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003257{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303258 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003259 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303260 hdd_ap_ctx_t *pHddApCtx;
3261 hdd_context_t *pHddCtx;
3262 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303263
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003265
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303266 pHostapdAdapter = (netdev_priv(dev));
3267 if (NULL == pHostapdAdapter)
3268 {
3269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3270 "%s: Adapter is NULL",__func__);
3271 return -EINVAL;
3272 }
3273 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3274 ret = wlan_hdd_validate_context(pHddCtx);
3275 if (0 != ret)
3276 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303277 return ret;
3278 }
3279 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3280 if (NULL == pHddApCtx)
3281 {
3282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3283 "%s: AP context is NULL",__func__);
3284 return -EINVAL;
3285 }
3286
Arif Hussain6d2a3322013-11-17 19:50:10 -08003287 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003288 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3289
3290 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3291 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3292 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3293 WPSPBCProbeReqIEs.probeReqIELen);
3294 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3295 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3296 sizeof(v_MACADDR_t));
3297 if (copy_to_user(wrqu->data.pointer,
3298 (void *)&WPSPBCProbeReqIEs,
3299 sizeof(WPSPBCProbeReqIEs)))
3300 {
3301 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3302 return -EFAULT;
3303 }
3304 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003305 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003306 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 up(&pHddApCtx->semWpsPBCOverlapInd);
3308 EXIT();
3309 return 0;
3310}
3311
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303312static
3313int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3314 struct iw_request_info *info,
3315 union iwreq_data *wrqu, char *extra)
3316{
3317 int ret;
3318
3319 vos_ssr_protect(__func__);
3320 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3321 vos_ssr_unprotect(__func__);
3322
3323 return ret;
3324}
3325
Jeff Johnson295189b2012-06-20 16:38:30 -07003326/**---------------------------------------------------------------------------
3327
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303328 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 This function sets the auth type received from the wpa_supplicant.
3330
3331 \param - dev - Pointer to the net device.
3332 - info - Pointer to the iw_request_info.
3333 - wrqu - Pointer to the iwreq_data.
3334 - extra - Pointer to the data.
3335 \return - 0 for success, non zero for failure
3336
3337 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303338int __iw_set_auth_hostap(struct net_device *dev,
3339 struct iw_request_info *info,
3340 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003341{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303342 hdd_adapter_t *pAdapter;
3343 hdd_context_t *pHddCtx;
3344 hdd_wext_state_t *pWextState;
3345 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303346
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303348
3349 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3350 if (NULL == pAdapter)
3351 {
3352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3353 "%s: Adapter is NULL",__func__);
3354 return -EINVAL;
3355 }
3356
3357 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3358 ret = wlan_hdd_validate_context(pHddCtx);
3359 if (0 != ret)
3360 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303361 return ret;
3362 }
3363 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3364 if (NULL == pWextState)
3365 {
3366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3367 "%s: pWextState is NULL",__func__);
3368 return -EINVAL;
3369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 switch(wrqu->param.flags & IW_AUTH_INDEX)
3371 {
3372 case IW_AUTH_TKIP_COUNTERMEASURES:
3373 {
3374 if(wrqu->param.value) {
3375 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3376 "Counter Measure started %d", wrqu->param.value);
3377 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303378 }
3379 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3381 "Counter Measure stopped=%d", wrqu->param.value);
3382 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3383 }
3384
3385 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3386 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303389
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303391
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003392 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 wrqu->param.flags & IW_AUTH_INDEX);
3394 break;
3395 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303396
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 EXIT();
3398 return 0;
3399}
3400
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303401int iw_set_auth_hostap(struct net_device *dev,
3402 struct iw_request_info *info,
3403 union iwreq_data *wrqu,char *extra)
3404{
3405 int ret;
3406
3407 vos_ssr_protect(__func__);
3408 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3409 vos_ssr_unprotect(__func__);
3410
3411 return ret;
3412}
3413
3414static int __iw_set_ap_encodeext(struct net_device *dev,
3415 struct iw_request_info *info,
3416 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003417{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303418 hdd_adapter_t *pHostapdAdapter;
3419 v_CONTEXT_t pVosContext;
3420 hdd_context_t *pHddCtx;
3421 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003422 int retval = 0;
3423 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3425 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3426 int key_index;
3427 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303428 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003429// tCsrRoamRemoveKey RemoveKey;
3430 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303431
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303432 ENTER();
3433 pHostapdAdapter = (netdev_priv(dev));
3434 if (NULL == pHostapdAdapter)
3435 {
3436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3437 "%s: Adapter is NULL",__func__);
3438 return -EINVAL;
3439 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003440
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303441 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3442 retval = wlan_hdd_validate_context(pHddCtx);
3443 if (0 != retval)
3444 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303445 return retval;
3446 }
3447 pVosContext = pHddCtx->pvosContext;
3448 if (NULL == pVosContext)
3449 {
3450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3451 "%s: pVosContext is NULL",__func__);
3452 return -EINVAL;
3453 }
3454 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3455 if (NULL == pHddApCtx)
3456 {
3457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3458 "%s: AP Context is NULL",__func__);
3459 return -EINVAL;
3460 }
3461
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303463
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303465
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 /*Convert from 1-based to 0-based keying*/
3467 key_index--;
3468 }
3469 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303470#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 /*Set the encrytion type to NONE*/
3472#if 0
3473 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3474#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303475
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 RemoveKey.keyId = key_index;
3477 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3478 /*Key direction for group is RX only*/
3479 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3480 }
3481 else {
3482 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3483 }
3484 switch(ext->alg)
3485 {
3486 case IW_ENCODE_ALG_NONE:
3487 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3488 break;
3489 case IW_ENCODE_ALG_WEP:
3490 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3491 break;
3492 case IW_ENCODE_ALG_TKIP:
3493 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 case IW_ENCODE_ALG_CCMP:
3496 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3497 break;
3498 default:
3499 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3500 break;
3501 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003502 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 -07003503 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003505 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003507 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3508 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 {
3510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003511 __LINE__, vstatus );
3512 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003514#endif
3515 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003516
Jeff Johnson43971f52012-07-17 12:26:56 -07003517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003518
3519 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3520
3521 setKey.keyId = key_index;
3522 setKey.keyLength = ext->key_len;
3523
3524 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3525 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3526 }
3527
3528 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3529 /*Key direction for group is RX only*/
3530 setKey.keyDirection = eSIR_RX_ONLY;
3531 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3532 }
3533 else {
3534
3535 setKey.keyDirection = eSIR_TX_RX;
3536 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3537 }
3538 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3539 {
3540 setKey.keyDirection = eSIR_TX_DEFAULT;
3541 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3542 }
3543
3544 /*For supplicant pae role is zero*/
3545 setKey.paeRole = 0;
3546
3547 switch(ext->alg)
3548 {
3549 case IW_ENCODE_ALG_NONE:
3550 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3551 break;
3552
3553 case IW_ENCODE_ALG_WEP:
3554 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3555 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003556 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 break;
3558
3559 case IW_ENCODE_ALG_TKIP:
3560 {
3561 v_U8_t *pKey = &setKey.Key[0];
3562
3563 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3564
3565 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3566
3567 /*Supplicant sends the 32bytes key in this order
3568
3569 |--------------|----------|----------|
3570 | Tk1 |TX-MIC | RX Mic |
3571 |--------------|----------|----------|
3572 <---16bytes---><--8bytes--><--8bytes-->
3573
3574 */
3575 /*Sme expects the 32 bytes key to be in the below order
3576
3577 |--------------|----------|----------|
3578 | Tk1 |RX-MIC | TX Mic |
3579 |--------------|----------|----------|
3580 <---16bytes---><--8bytes--><--8bytes-->
3581 */
3582 /* Copy the Temporal Key 1 (TK1) */
3583 vos_mem_copy(pKey,ext->key,16);
3584
3585 /*Copy the rx mic first*/
3586 vos_mem_copy(&pKey[16],&ext->key[24],8);
3587
3588 /*Copy the tx mic */
3589 vos_mem_copy(&pKey[24],&ext->key[16],8);
3590
3591 }
3592 break;
3593
3594 case IW_ENCODE_ALG_CCMP:
3595 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3596 break;
3597
3598 default:
3599 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3600 break;
3601 }
3602
3603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303604 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 setKey.keyId);
3606 for(i=0; i< ext->key_len; i++)
3607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3608 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003609
3610 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3611 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 {
3613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003614 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3615 retval = -EINVAL;
3616 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303617
3618 EXIT();
3619 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003620}
Jeff Johnson43971f52012-07-17 12:26:56 -07003621
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303622static int iw_set_ap_encodeext(struct net_device *dev,
3623 struct iw_request_info *info,
3624 union iwreq_data *wrqu, char *extra)
3625{
3626 int ret;
3627
3628 vos_ssr_protect(__func__);
3629 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3630 vos_ssr_unprotect(__func__);
3631
3632 return ret;
3633}
Jeff Johnson43971f52012-07-17 12:26:56 -07003634
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303635static int __iw_set_ap_mlme(struct net_device *dev,
3636 struct iw_request_info *info,
3637 union iwreq_data *wrqu,
3638 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003639{
3640#if 0
3641 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3642 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3643
3644 ENTER();
3645
3646 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3647 switch (mlme->cmd) {
3648 case IW_MLME_DISASSOC:
3649 case IW_MLME_DEAUTH:
3650 hddLog(LOG1, "Station disassociate");
3651 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3652 {
3653 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3654
3655 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3656 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3657
3658 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3659
3660 //clear all the reason codes
3661 if (status != 0)
3662 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003663 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 }
3665
3666 netif_stop_queue(dev);
3667 netif_carrier_off(dev);
3668 }
3669 else
3670 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003671 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 -07003672 }
3673 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003674 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 return -EINVAL;
3676 }//end of switch
3677 EXIT();
3678#endif
3679 return 0;
3680// return status;
3681}
3682
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303683static int iw_set_ap_mlme(struct net_device *dev,
3684 struct iw_request_info *info,
3685 union iwreq_data *wrqu,
3686 char *extra)
3687{
3688 int ret;
3689
3690 vos_ssr_protect(__func__);
3691 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3692 vos_ssr_unprotect(__func__);
3693
3694 return ret;
3695}
3696
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303697static int __iw_get_ap_rts_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_rts_threshold(pHostapdAdapter, wrqu);
3705
3706 return status;
3707}
3708
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303709static int iw_get_ap_rts_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_rts_threshold(dev, info, wrqu, extra);
3717 vos_ssr_unprotect(__func__);
3718
3719 return ret;
3720}
3721
3722static int __iw_get_ap_frag_threshold(struct net_device *dev,
3723 struct iw_request_info *info,
3724 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003725{
3726 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3727 v_U32_t status = 0;
3728
3729 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3730
3731 return status;
3732}
3733
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303734static int iw_get_ap_frag_threshold(struct net_device *dev,
3735 struct iw_request_info *info,
3736 union iwreq_data *wrqu, char *extra)
3737{
3738 int ret;
3739
3740 vos_ssr_protect(__func__);
3741 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3742 vos_ssr_unprotect(__func__);
3743
3744 return ret;
3745}
3746
3747static int __iw_get_ap_freq(struct net_device *dev,
3748 struct iw_request_info *info,
3749 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003750{
Jeff Johnsone7245742012-09-05 17:12:55 -07003751 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303752 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 tHalHandle hHal;
3754 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303755 hdd_ap_ctx_t *pHddApCtx;
3756 hdd_context_t *pHddCtx;
3757 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003758
3759 ENTER();
3760
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303761 pHostapdAdapter = (netdev_priv(dev));
3762 if (NULL == pHostapdAdapter)
3763 {
3764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3765 "%s: Adapter is NULL",__func__);
3766 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303768 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3769 ret = wlan_hdd_validate_context(pHddCtx);
3770 if (0 != ret)
3771 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303772 return ret;
3773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303775 if (NULL == pHostapdState)
3776 {
3777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3778 "%s: pHostapdState is NULL",__func__);
3779 return -EINVAL;
3780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303782 if (NULL == hHal)
3783 {
3784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3785 "%s: Hal Context is NULL",__func__);
3786 return -EINVAL;
3787 }
3788 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3789 if (NULL == pHddApCtx)
3790 {
3791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3792 "%s: AP context is NULL",__func__);
3793 return -EINVAL;
3794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 if(pHostapdState->bssState == BSS_STOP )
3796 {
3797 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3798 != eHAL_STATUS_SUCCESS)
3799 {
c_hpothuffdb5272013-10-02 16:42:35 +05303800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3801 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 return -EIO;
3803 }
3804 else
3805 {
3806 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003807 if( TRUE == status)
3808 {
3809 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3810 * iwlist & iwconfig command shows frequency into proper
3811 * format (2.412 GHz instead of 246.2 MHz)*/
3812 fwrq->m = freq;
3813 fwrq->e = MHZ;
3814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 }
3816 }
3817 else
3818 {
3819 channel = pHddApCtx->operatingChannel;
3820 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003821 if( TRUE == status)
3822 {
3823 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3824 * iwlist & iwconfig command shows frequency into proper
3825 * format (2.412 GHz instead of 246.2 MHz)*/
3826 fwrq->m = freq;
3827 fwrq->e = MHZ;
3828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303830
3831 EXIT();
3832 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003833}
3834
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303835static int iw_get_ap_freq(struct net_device *dev,
3836 struct iw_request_info *info,
3837 struct iw_freq *fwrq, char *extra)
3838{
3839 int ret;
3840
3841 vos_ssr_protect(__func__);
3842 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
3843 vos_ssr_unprotect(__func__);
3844
3845 return ret;
3846}
3847
3848static int __iw_get_mode(struct net_device *dev,
3849 struct iw_request_info *info,
3850 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303851{
3852 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303853 hdd_adapter_t *pAdapter;
3854 hdd_context_t *pHddCtx;
3855
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303856 ENTER();
3857
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303858 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3859 if (NULL == pAdapter)
3860 {
3861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3862 "%s: Adapter is NULL",__func__);
3863 return -EINVAL;
3864 }
3865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3866 status = wlan_hdd_validate_context(pHddCtx);
3867 if (0 != status)
3868 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303869 return status;
3870 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303871
3872 wrqu->mode = IW_MODE_MASTER;
3873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303874 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05303875 return status;
3876}
3877
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303878static int iw_get_mode(struct net_device *dev,
3879 struct iw_request_info *info,
3880 union iwreq_data *wrqu, char *extra)
3881{
3882 int ret;
3883
3884 vos_ssr_protect(__func__);
3885 ret = __iw_get_mode(dev, info, wrqu, extra);
3886 vos_ssr_unprotect(__func__);
3887
3888 return ret;
3889}
3890
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303891static int __iw_softap_setwpsie(struct net_device *dev,
3892 struct iw_request_info *info,
3893 union iwreq_data *wrqu,
3894 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003895{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303896 hdd_adapter_t *pHostapdAdapter;
3897 hdd_context_t *pHddCtx;
3898 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 hdd_hostapd_state_t *pHostapdState;
3900 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07003901 u_int8_t *wps_genie;
3902 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 u_int8_t *pos;
3904 tpSap_WPSIE pSap_WPSIe;
3905 u_int8_t WPSIeType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303906 u_int16_t length;
Girish Gowli07c05ec2014-06-17 20:47:03 +05303907 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303908 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303909
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 ENTER();
3911
Hanumantha Reddy Pothulac9b12d92015-10-27 22:55:07 +05303912 if (!capable(CAP_NET_ADMIN))
3913 {
3914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3915 FL("permission check failed"));
3916 return -EPERM;
3917 }
3918
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303919 pHostapdAdapter = (netdev_priv(dev));
3920 if (NULL == pHostapdAdapter)
3921 {
3922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3923 "%s: Adapter is NULL",__func__);
3924 return -EINVAL;
3925 }
3926 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3927 ret = wlan_hdd_validate_context(pHddCtx);
3928 if (0 != ret)
3929 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303930 return ret;
3931 }
3932 pVosContext = pHddCtx->pvosContext;
3933 if (NULL == pVosContext)
3934 {
3935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3936 "%s: HDD context is not valid ",__func__);
3937 return -EINVAL;
3938 }
Girish Gowli07c05ec2014-06-17 20:47:03 +05303939 /* helper function to get iwreq_data with compat handling. */
3940 if (hdd_priv_get_data(&s_priv_data, wrqu))
3941 {
3942 return -EINVAL;
3943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003944
Girish Gowli07c05ec2014-06-17 20:47:03 +05303945 if ((NULL == s_priv_data.pointer) || (s_priv_data.length < QCSAP_MAX_WSC_IE))
3946 {
3947 return -EINVAL;
3948 }
3949
3950 wps_genie = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
3951 s_priv_data.length);
Arif Hussained667642013-10-27 23:01:14 -07003952
Girish Gowli86c471e2014-06-17 19:28:05 +05303953 if(NULL == wps_genie)
Arif Hussained667642013-10-27 23:01:14 -07003954 {
Girish Gowli86c471e2014-06-17 19:28:05 +05303955 hddLog(LOG1, "%s: failed to alloc memory "
3956 "and copy data from user buffer", __func__);
Arif Hussained667642013-10-27 23:01:14 -07003957 return -EFAULT;
3958 }
3959
Girish Gowli86c471e2014-06-17 19:28:05 +05303960 fwps_genie = wps_genie;
3961
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
3963 if (NULL == pSap_WPSIe)
3964 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003965 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07003966 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 return -ENOMEM;
3968 }
3969 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
3970
Arif Hussain6d2a3322013-11-17 19:50:10 -08003971 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 -07003972 WPSIeType = wps_genie[0];
3973 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
3974 {
3975 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
3976 wps_genie = wps_genie + 1;
3977 switch ( wps_genie[0] )
3978 {
3979 case DOT11F_EID_WPA:
3980 if (wps_genie[1] < 2 + 4)
3981 {
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05303982 ret = -EINVAL;
3983 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 }
3985 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
3986 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003987 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 pos = &wps_genie[6];
3989 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
3990 {
3991 switch((u_int16_t)(*pos<<8) | *(pos+1))
3992 {
3993 case HDD_WPS_ELEM_VERSION:
3994 pos += 4;
3995 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003996 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
3998 pos += 1;
3999 break;
4000
4001 case HDD_WPS_ELEM_WPS_STATE:
4002 pos +=4;
4003 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004004 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
4006 pos += 1;
4007 break;
4008 case HDD_WPS_ELEM_APSETUPLOCK:
4009 pos += 4;
4010 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004011 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
4013 pos += 1;
4014 break;
4015 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4016 pos += 4;
4017 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004018 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
4020 pos += 1;
4021 break;
4022 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4023 pos += 4;
4024 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004025 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
4027 pos += 2;
4028 break;
4029 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4030 pos += 4;
4031 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004032 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
4034 pos += 2;
4035 break;
4036
4037 case HDD_WPS_ELEM_UUID_E:
4038 pos += 2;
4039 length = *pos<<8 | *(pos+1);
4040 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304041 if (length > sizeof(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E))
4042 {
4043 ret = -EINVAL;
4044 goto exit;
4045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
4047 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
4048 pos += length;
4049 break;
4050 case HDD_WPS_ELEM_RF_BANDS:
4051 pos += 4;
4052 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004053 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
4055 pos += 1;
4056 break;
4057
4058 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004059 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304060 ret = -EINVAL;
4061 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
4063 }
4064 }
4065 else {
4066 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004067 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 }
4069 break;
4070
4071 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004072 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304073 ret = -EINVAL;
4074 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 }
4076 }
4077 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
4078 {
4079 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
4080 wps_genie = wps_genie + 1;
4081 switch ( wps_genie[0] )
4082 {
4083 case DOT11F_EID_WPA:
4084 if (wps_genie[1] < 2 + 4)
4085 {
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304086 ret = -EINVAL;
4087 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 }
4089 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
4090 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004091 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 pos = &wps_genie[6];
4093 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
4094 {
4095 switch((u_int16_t)(*pos<<8) | *(pos+1))
4096 {
4097 case HDD_WPS_ELEM_VERSION:
4098 pos += 4;
4099 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004100 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
4102 pos += 1;
4103 break;
4104
4105 case HDD_WPS_ELEM_WPS_STATE:
4106 pos +=4;
4107 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004108 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
4110 pos += 1;
4111 break;
4112 case HDD_WPS_ELEM_APSETUPLOCK:
4113 pos += 4;
4114 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004115 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
4117 pos += 1;
4118 break;
4119 case HDD_WPS_ELEM_SELECTEDREGISTRA:
4120 pos += 4;
4121 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004122 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
4124 pos += 1;
4125 break;
4126 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
4127 pos += 4;
4128 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004129 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
4131 pos += 2;
4132 break;
4133 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
4134 pos += 4;
4135 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004136 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
4138 pos += 2;
4139 break;
4140 case HDD_WPS_ELEM_RSP_TYPE:
4141 pos += 4;
4142 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004143 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
4145 pos += 1;
4146 break;
4147 case HDD_WPS_ELEM_UUID_E:
4148 pos += 2;
4149 length = *pos<<8 | *(pos+1);
4150 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304151 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E)))
4152 {
4153 ret = -EINVAL;
4154 goto exit;
4155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
4157 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
4158 pos += length;
4159 break;
4160
4161 case HDD_WPS_ELEM_MANUFACTURER:
4162 pos += 2;
4163 length = *pos<<8 | *(pos+1);
4164 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304165 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name)))
4166 {
4167 ret = -EINVAL;
4168 goto exit;
4169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
4171 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
4172 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
4173 pos += length;
4174 break;
4175
4176 case HDD_WPS_ELEM_MODEL_NAME:
4177 pos += 2;
4178 length = *pos<<8 | *(pos+1);
4179 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304180 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text)))
4181 {
4182 ret = -EINVAL;
4183 goto exit;
4184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
4186 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
4187 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
4188 pos += length;
4189 break;
4190 case HDD_WPS_ELEM_MODEL_NUM:
4191 pos += 2;
4192 length = *pos<<8 | *(pos+1);
4193 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304194 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text)))
4195 {
4196 ret = -EINVAL;
4197 goto exit;
4198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
4200 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
4201 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
4202 pos += length;
4203 break;
4204 case HDD_WPS_ELEM_SERIAL_NUM:
4205 pos += 2;
4206 length = *pos<<8 | *(pos+1);
4207 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304208 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text)))
4209 {
4210 ret = -EINVAL;
4211 goto exit;
4212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
4214 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
4215 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
4216 pos += length;
4217 break;
4218 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
4219 pos += 4;
4220 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004221 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 pos += 2;
4223
4224 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004225 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 pos += 4;
4227 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004228 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 pos += 2;
4230 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
4231 break;
4232 case HDD_WPS_ELEM_DEVICE_NAME:
4233 pos += 2;
4234 length = *pos<<8 | *(pos+1);
4235 pos += 2;
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304236 if (length > (sizeof(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text)))
4237 {
4238 ret = -EINVAL;
4239 goto exit;
4240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
4242 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
4243 pos += length;
4244 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
4245 break;
4246 case HDD_WPS_ELEM_CONFIG_METHODS:
4247 pos += 4;
4248 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004249 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 pos += 2;
4251 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
4252 break;
4253
4254 case HDD_WPS_ELEM_RF_BANDS:
4255 pos += 4;
4256 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004257 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 pos += 1;
4259 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
4260 break;
4261 } // switch
4262 }
4263 }
4264 else
4265 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004266 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 }
4268
4269 } // switch
4270 }
4271 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304272 if (halStatus != eHAL_STATUS_SUCCESS)
4273 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4275 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
4276 {
4277 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4278 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
4279 WLANSAP_Update_WpsIe ( pVosContext );
4280 }
4281
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304282exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07004284 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 EXIT();
Mahesh A Saptasagar606babd2015-10-27 15:13:46 +05304286 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07004287}
4288
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304289static int iw_softap_setwpsie(struct net_device *dev,
4290 struct iw_request_info *info,
4291 union iwreq_data *wrqu,
4292 char *extra)
4293{
4294 int ret;
4295
4296 vos_ssr_protect(__func__);
4297 ret = __iw_softap_setwpsie(dev, info, wrqu, extra);
4298 vos_ssr_unprotect(__func__);
4299
4300 return ret;
4301}
4302
4303static int __iw_softap_stopbss(struct net_device *dev,
4304 struct iw_request_info *info,
4305 union iwreq_data *wrqu,
4306 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004307{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304308 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304310 hdd_context_t *pHddCtx = NULL;
4311
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304313 pHostapdAdapter = (netdev_priv(dev));
4314 if (NULL == pHostapdAdapter)
4315 {
4316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4317 "%s: Adapter is NULL",__func__);
4318 return -EINVAL;
4319 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304320 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4321 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304322 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304323 return status;
4324 }
4325
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304326 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 {
4328 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4329 {
4330 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4331
4332 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304333
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304335 {
4336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004337 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 VOS_ASSERT(0);
4339 }
4340 }
4341 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304342 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 }
4344 EXIT();
4345 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4346}
4347
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304348static int iw_softap_stopbss(struct net_device *dev,
4349 struct iw_request_info *info,
4350 union iwreq_data *wrqu,
4351 char *extra)
4352{
4353 int ret;
4354
4355 vos_ssr_protect(__func__);
4356 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4357 vos_ssr_unprotect(__func__);
4358
4359 return ret;
4360}
4361
4362static int __iw_softap_version(struct net_device *dev,
4363 struct iw_request_info *info,
4364 union iwreq_data *wrqu,
4365 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004366{
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304368 hdd_context_t *pHddCtx;
4369 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304372 pHostapdAdapter = (netdev_priv(dev));
4373 if (NULL == pHostapdAdapter)
4374 {
4375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4376 "%s: Adapter is NULL",__func__);
4377 return -EINVAL;
4378 }
4379 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4380 ret = wlan_hdd_validate_context(pHddCtx);
4381 if (0 != ret)
4382 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304383 return ret;
4384 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004385 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 return 0;
4388}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004389
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304390static int iw_softap_version(struct net_device *dev,
4391 struct iw_request_info *info,
4392 union iwreq_data *wrqu,
4393 char *extra)
4394{
4395 int ret;
4396
4397 vos_ssr_protect(__func__);
4398 ret = __iw_softap_version(dev, info, wrqu, extra);
4399 vos_ssr_unprotect(__func__);
4400
4401 return ret;
4402}
4403
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004404VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004405{
4406 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004407 int len = 0;
4408 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304409 v_CONTEXT_t pVosContext;
4410 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304411 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304412
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304413 ENTER();
4414
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304415 if (NULL == pAdapter)
4416 {
4417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4418 "%s: Adapter is NULL",__func__);
4419 return -EINVAL;
4420 }
4421 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4422 if (0 != wlan_hdd_validate_context(pHddCtx))
4423 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304424 return VOS_STATUS_E_FAULT;
4425 }
4426 pVosContext = pHddCtx->pvosContext;
4427 if (NULL == pVosContext)
4428 {
4429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4430 "%s: VOS context is not valid",__func__);
4431 return VOS_STATUS_E_FAULT;
4432 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304433 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304434 if(pSapCtx == NULL)
4435 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304436 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4437 FL("psapCtx is NULL"));
4438 return VOS_STATUS_E_FAULT;
4439 }
4440
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004441 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004442 pBuf += len;
4443 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004444
4445 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4446 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304447 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004448 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004449 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304450 pSapCtx->aStaInfo[i].ucSTAId,
4451 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4452 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4453 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4454 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4455 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4456 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004457 pBuf += len;
4458 buf_len -= len;
4459 }
4460 if(WE_GET_STA_INFO_SIZE > buf_len)
4461 {
4462 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004463 }
4464 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304465 EXIT();
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004466 return VOS_STATUS_SUCCESS;
4467}
4468
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304469static int __iw_softap_get_sta_info(struct net_device *dev,
4470 struct iw_request_info *info,
4471 union iwreq_data *wrqu,
4472 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004473{
4474 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4475 VOS_STATUS status;
4476 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07004477 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004478 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004479 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004480 return -EINVAL;
4481 }
4482 wrqu->data.length = strlen(extra);
4483 EXIT();
4484 return 0;
4485}
4486
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304487static int iw_softap_get_sta_info(struct net_device *dev,
4488 struct iw_request_info *info,
4489 union iwreq_data *wrqu,
4490 char *extra)
4491{
4492 int ret;
4493
4494 vos_ssr_protect(__func__);
4495 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4496 vos_ssr_unprotect(__func__);
4497
4498 return ret;
4499}
4500
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304501static int __iw_set_ap_genie(struct net_device *dev,
4502 struct iw_request_info *info,
4503 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004504{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304505
4506 hdd_adapter_t *pHostapdAdapter;
4507 hdd_context_t *pHddCtx;
4508 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004510 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304511 int ret = 0;
4512
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304514 pHostapdAdapter = (netdev_priv(dev));
4515 if (NULL == pHostapdAdapter)
4516 {
4517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4518 "%s: Adapter is NULL",__func__);
4519 return -EINVAL;
4520 }
4521 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4522 ret = wlan_hdd_validate_context(pHddCtx);
4523 if (0 != ret)
4524 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304525 return ret;
4526 }
4527 pVosContext = pHddCtx->pvosContext;
4528 if (NULL == pVosContext)
4529 {
4530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4531 "%s: VOS Context is NULL",__func__);
4532 return -EINVAL;
4533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 if(!wrqu->data.length)
4535 {
4536 EXIT();
4537 return 0;
4538 }
Arif Hussained667642013-10-27 23:01:14 -07004539
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304540 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304542 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 case DOT11F_EID_RSN:
4544 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4545 {
4546 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4547 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004550 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304552
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004554 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 halStatus = 0;
4556 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304557
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304559 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560}
4561
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304562static int iw_set_ap_genie(struct net_device *dev,
4563 struct iw_request_info *info,
4564 union iwreq_data *wrqu, char *extra)
4565{
4566 int ret;
4567
4568 vos_ssr_protect(__func__);
4569 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4570 vos_ssr_unprotect(__func__);
4571
4572 return ret;
4573}
4574
Jeff Johnson295189b2012-06-20 16:38:30 -07004575static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4576{
4577 eHalStatus hstatus;
4578 long lrc;
4579 struct statsContext context;
4580
4581 if (NULL == pAdapter)
4582 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304583 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 return VOS_STATUS_E_FAULT;
4585 }
4586
4587 init_completion(&context.completion);
4588 context.pAdapter = pAdapter;
4589 context.magic = STATS_CONTEXT_MAGIC;
4590 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4591 eCSR_HDD,
4592 SME_GLOBAL_CLASSA_STATS,
4593 hdd_GetClassA_statisticsCB,
4594 0, // not periodic
4595 FALSE, //non-cached results
4596 staid,
4597 &context);
4598 if (eHAL_STATUS_SUCCESS != hstatus)
4599 {
4600 hddLog(VOS_TRACE_LEVEL_ERROR,
4601 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004602 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 }
4604 else
4605 {
4606 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4607 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 if (lrc <= 0)
4609 {
4610 hddLog(VOS_TRACE_LEVEL_ERROR,
4611 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004612 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 }
4614 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004615
4616 /* either we never sent a request, we sent a request and received a
4617 response or we sent a request and timed out. if we never sent a
4618 request or if we sent a request and got a response, we want to
4619 clear the magic out of paranoia. if we timed out there is a
4620 race condition such that the callback function could be
4621 executing at the same time we are. of primary concern is if the
4622 callback function had already verified the "magic" but had not
4623 yet set the completion variable when a timeout occurred. we
4624 serialize these activities by invalidating the magic while
4625 holding a shared spinlock which will cause us to block if the
4626 callback is currently executing */
4627 spin_lock(&hdd_context_lock);
4628 context.magic = 0;
4629 spin_unlock(&hdd_context_lock);
4630
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 return VOS_STATUS_SUCCESS;
4632}
4633
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304634int __iw_get_softap_linkspeed(struct net_device *dev,
4635 struct iw_request_info *info,
4636 union iwreq_data *wrqu,
4637 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
4639{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304640 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304641 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004643 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304644 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304646 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004648 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304649 int rc, valid;
4650
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304651 ENTER();
4652
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304653 pHostapdAdapter = (netdev_priv(dev));
4654 if (NULL == pHostapdAdapter)
4655 {
4656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4657 "%s: Adapter is NULL",__func__);
4658 return -EINVAL;
4659 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304660 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304661 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304662 if (0 != valid)
4663 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304664 return valid;
4665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004666
Arif Hussain6d2a3322013-11-17 19:50:10 -08004667 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004668
4669 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004670 {
Arif Hussaina9571842014-01-15 16:43:41 -08004671 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4672 if (NULL == pmacAddress) {
4673 hddLog(LOG1, "unable to allocate memory");
4674 return -ENOMEM;
4675 }
4676 if (copy_from_user((void *)pmacAddress,
4677 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4678 {
4679 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4680 kfree(pmacAddress);
4681 return -EFAULT;
4682 }
4683 pmacAddress[MAC_ADDRESS_STR_LEN] = '\0';
4684
4685 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004686 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004687
4688 if (!VOS_IS_STATUS_SUCCESS(status ))
4689 {
4690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4691 }
Arif Hussained667642013-10-27 23:01:14 -07004692 }
Kiet Lam61589852013-09-19 17:10:58 +05304693 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304694 * link speed for first connected client will be returned.
4695 */
Arif Hussaina9571842014-01-15 16:43:41 -08004696 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304697 {
4698 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4699 }
4700 else
4701 {
4702 status = hdd_softap_GetStaId(pHostapdAdapter,
4703 (v_MACADDR_t *)macAddress, (void *)(&staId));
4704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004705
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304706 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304708 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 link_speed = 0;
4710 }
4711 else
4712 {
4713 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304714
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 if (!VOS_IS_STATUS_SUCCESS(status ))
4716 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 return -EINVAL;
4719 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304720
4721 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4722 staId, &link_speed);
4723
4724 link_speed = link_speed / 10;
4725
4726 if (0 == link_speed)
4727 {
4728 /* The linkspeed returned by HAL is in units of 500kbps.
4729 * converting it to mbps.
4730 * This is required to support legacy firmware which does
4731 * not return link capacity.
4732 */
4733 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 }
4736
4737 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004738 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304739
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 if ((rc < 0) || (rc >= len))
4741 {
4742 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304743 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 return -EIO;
4745 }
4746
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304747 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 return 0;
4749}
4750
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304751int iw_get_softap_linkspeed(struct net_device *dev,
4752 struct iw_request_info *info,
4753 union iwreq_data *wrqu,
4754 char *extra)
4755{
4756 int ret;
4757
4758 vos_ssr_protect(__func__);
4759 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4760 vos_ssr_unprotect(__func__);
4761
4762 return ret;
4763}
4764
4765
Jeff Johnson295189b2012-06-20 16:38:30 -07004766static const iw_handler hostapd_handler[] =
4767{
4768 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4769 (iw_handler) NULL, /* SIOCGIWNAME */
4770 (iw_handler) NULL, /* SIOCSIWNWID */
4771 (iw_handler) NULL, /* SIOCGIWNWID */
4772 (iw_handler) NULL, /* SIOCSIWFREQ */
4773 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4774 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304775 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 (iw_handler) NULL, /* SIOCSIWSENS */
4777 (iw_handler) NULL, /* SIOCGIWSENS */
4778 (iw_handler) NULL, /* SIOCSIWRANGE */
4779 (iw_handler) NULL, /* SIOCGIWRANGE */
4780 (iw_handler) NULL, /* SIOCSIWPRIV */
4781 (iw_handler) NULL, /* SIOCGIWPRIV */
4782 (iw_handler) NULL, /* SIOCSIWSTATS */
4783 (iw_handler) NULL, /* SIOCGIWSTATS */
4784 (iw_handler) NULL, /* SIOCSIWSPY */
4785 (iw_handler) NULL, /* SIOCGIWSPY */
4786 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4787 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4788 (iw_handler) NULL, /* SIOCSIWAP */
4789 (iw_handler) NULL, /* SIOCGIWAP */
4790 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4791 (iw_handler) NULL, /* SIOCGIWAPLIST */
4792 (iw_handler) NULL, /* SIOCSIWSCAN */
4793 (iw_handler) NULL, /* SIOCGIWSCAN */
4794 (iw_handler) NULL, /* SIOCSIWESSID */
4795 (iw_handler) NULL, /* SIOCGIWESSID */
4796 (iw_handler) NULL, /* SIOCSIWNICKN */
4797 (iw_handler) NULL, /* SIOCGIWNICKN */
4798 (iw_handler) NULL, /* -- hole -- */
4799 (iw_handler) NULL, /* -- hole -- */
4800 (iw_handler) NULL, /* SIOCSIWRATE */
4801 (iw_handler) NULL, /* SIOCGIWRATE */
4802 (iw_handler) NULL, /* SIOCSIWRTS */
4803 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4804 (iw_handler) NULL, /* SIOCSIWFRAG */
4805 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4806 (iw_handler) NULL, /* SIOCSIWTXPOW */
4807 (iw_handler) NULL, /* SIOCGIWTXPOW */
4808 (iw_handler) NULL, /* SIOCSIWRETRY */
4809 (iw_handler) NULL, /* SIOCGIWRETRY */
4810 (iw_handler) NULL, /* SIOCSIWENCODE */
4811 (iw_handler) NULL, /* SIOCGIWENCODE */
4812 (iw_handler) NULL, /* SIOCSIWPOWER */
4813 (iw_handler) NULL, /* SIOCGIWPOWER */
4814 (iw_handler) NULL, /* -- hole -- */
4815 (iw_handler) NULL, /* -- hole -- */
4816 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4817 (iw_handler) NULL, /* SIOCGIWGENIE */
4818 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4819 (iw_handler) NULL, /* SIOCGIWAUTH */
4820 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4821 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4822 (iw_handler) NULL, /* SIOCSIWPMKSA */
4823};
4824
Jeff Johnson224f3702014-03-26 11:09:47 -07004825/*
4826 * Note that the following ioctls were defined with semantics which
4827 * cannot be handled by the "iwpriv" userspace application and hence
4828 * they are not included in the hostapd_private_args array
4829 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4830 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004831
4832static const struct iw_priv_args hostapd_private_args[] = {
4833 { QCSAP_IOCTL_SETPARAM,
4834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4835 { QCSAP_IOCTL_SETPARAM,
4836 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304837 { QCSAP_PARAM_GET_FRAME_LOGS,
4838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 { QCSAP_PARAM_MAX_ASSOC,
4840 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4841 { QCSAP_PARAM_HIDE_SSID,
4842 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004843 { QCSAP_PARAM_SET_MC_RATE,
4844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 { QCSAP_IOCTL_GETPARAM,
4846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4848 { QCSAP_IOCTL_GETPARAM, 0,
4849 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4850 { QCSAP_PARAM_MAX_ASSOC, 0,
4851 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004852 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4853 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4854 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304856 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4857 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 { QCSAP_PARAM_CLR_ACL, 0,
4859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4860 { QCSAP_PARAM_ACL_MODE,
4861 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 { QCSAP_IOCTL_GET_STAWPAIE,
4863 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
4864 { QCSAP_IOCTL_SETWPAIE,
4865 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
4866 { QCSAP_IOCTL_STOPBSS,
4867 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4868 { QCSAP_IOCTL_VERSION, 0,
4869 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004870 { QCSAP_IOCTL_GET_STA_INFO, 0,
4871 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004873 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004876 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304878 { QCSAP_IOCTL_AP_STATS, 0,
4879 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304880 { QCSAP_IOCTL_GET_STATS, 0,
4881 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4882 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4884 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304885 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004886
4887 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4888 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4889 /* handlers for sub-ioctl */
4890 { WE_SET_WLAN_DBG,
4891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4892 0,
4893 "setwlandbg" },
4894
4895 /* handlers for main ioctl */
4896 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4897 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4898 0,
4899 "" },
4900
4901 /* handlers for sub-ioctl */
4902 { WE_LOG_DUMP_CMD,
4903 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4904 0,
4905 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 { WE_P2P_NOA_CMD,
4907 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4908 0,
4909 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004910 /* handlers for sub ioctl */
4911 {
4912 WE_MCC_CONFIG_CREDENTIAL,
4913 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4914 0,
4915 "setMccCrdnl" },
4916
4917 /* handlers for sub ioctl */
4918 {
4919 WE_MCC_CONFIG_PARAMS,
4920 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4921 0,
4922 "setMccConfig" },
4923
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 /* handlers for main ioctl */
4925 { QCSAP_IOCTL_MODIFY_ACL,
4926 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4927 0,
4928 "modify_acl" },
4929
4930 /* handlers for main ioctl */
4931 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4932 0,
4933 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4934 "getChannelList" },
4935
Jeff Johnsone7245742012-09-05 17:12:55 -07004936 /* handlers for main ioctl */
4937 { QCSAP_IOCTL_SET_TX_POWER,
4938 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4939 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304940 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004941
4942 /* handlers for main ioctl */
4943 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4944 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4945 0,
4946 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304947
4948 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4949 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4950 0,
4951 "dataSnapshot" },
4952
4953 /* handlers for main ioctl */
4954 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4955 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4956 0,
4957 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004958};
Jeff Johnsone7245742012-09-05 17:12:55 -07004959
Jeff Johnson295189b2012-06-20 16:38:30 -07004960static const iw_handler hostapd_private[] = {
4961 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
4962 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
4964 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
4965 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4966 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4967 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4968 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4969 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4970 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4971 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304972 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4974 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4975 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4976 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004977 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004978 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4979 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004980 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304981 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304982 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304983 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4984 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004985};
4986const struct iw_handler_def hostapd_handler_def = {
4987 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4988 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4989 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4990 .standard = (iw_handler *)hostapd_handler,
4991 .private = (iw_handler *)hostapd_private,
4992 .private_args = hostapd_private_args,
4993 .get_wireless_stats = NULL,
4994};
4995#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4996struct net_device_ops net_ops_struct = {
4997 .ndo_open = hdd_hostapd_open,
4998 .ndo_stop = hdd_hostapd_stop,
4999 .ndo_uninit = hdd_hostapd_uninit,
5000 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5001 .ndo_tx_timeout = hdd_softap_tx_timeout,
5002 .ndo_get_stats = hdd_softap_stats,
5003 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5004 .ndo_do_ioctl = hdd_hostapd_ioctl,
5005 .ndo_change_mtu = hdd_hostapd_change_mtu,
5006 .ndo_select_queue = hdd_hostapd_select_queue,
5007 };
5008#endif
5009
5010int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5011{
5012 return VOS_STATUS_SUCCESS;
5013}
5014
5015void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5016{
5017#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5018 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5019#else
5020 pWlanHostapdDev->open = hdd_hostapd_open;
5021 pWlanHostapdDev->stop = hdd_hostapd_stop;
5022 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5023 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5024 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5025 pWlanHostapdDev->get_stats = hdd_softap_stats;
5026 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5027 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5028#endif
5029}
5030
5031VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305032{
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 hdd_hostapd_state_t * phostapdBuf;
5034 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005035 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005037#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005038 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5039 v_U16_t unsafeChannelCount;
5040#endif /* FEATURE_WLAN_CH_AVOID */
5041
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305042 if (pHddCtx->isLogpInProgress) {
5043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5044 "%s:LOGP in Progress. Ignore!!!",__func__);
5045 status = VOS_STATUS_E_FAILURE;
5046 }
5047
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305049 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305051
Nirav Shah7e3c8132015-06-22 23:51:42 +05305052 spin_lock_init(&pAdapter->sta_hash_lock);
5053 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5054
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005055 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5056
Leo Chang0b0e45a2013-12-15 15:18:55 -08005057#ifdef FEATURE_WLAN_CH_AVOID
5058 /* Get unsafe cahnnel list from cached location */
5059 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5060 sizeof(unsafeChannelList),
5061 &unsafeChannelCount);
5062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5063 "%s : Unsafe Channel count %d",
5064 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305065 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005066 unsafeChannelList,
5067 unsafeChannelCount);
5068#endif /* FEATURE_WLAN_CH_AVOID */
5069
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 // Zero the memory. This zeros the profile structure.
5071 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
5072
5073 // Set up the pointer to the Wireless Extensions state structure
5074 // NOP
5075 status = hdd_set_hostapd(pAdapter);
5076 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 return status;
5079 }
5080
5081 status = vos_event_init(&phostapdBuf->vosEvent);
5082 if (!VOS_IS_STATUS_SUCCESS(status))
5083 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 return status;
5086 }
5087
Jeff Johnson295189b2012-06-20 16:38:30 -07005088
5089 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5090
5091 // Register as a wireless device
5092 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5093
5094 //Initialize the data path module
5095 status = hdd_softap_init_tx_rx(pAdapter);
5096 if ( !VOS_IS_STATUS_SUCCESS( status ))
5097 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005098 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305100
5101 status = hdd_wmm_adapter_init( pAdapter );
5102 if (!VOS_IS_STATUS_SUCCESS(status))
5103 {
5104 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005105 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305106 status, status );
5107 goto error_wmm_init;
5108 }
5109
5110 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5111
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305112 return status;
5113
5114error_wmm_init:
5115 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 EXIT();
5117 return status;
5118}
5119
5120hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5121{
5122 struct net_device *pWlanHostapdDev = NULL;
5123 hdd_adapter_t *pHostapdAdapter = NULL;
5124 v_CONTEXT_t pVosContext= NULL;
5125
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305126 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5127#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5128 NET_NAME_UNKNOWN,
5129#endif
5130 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 if (pWlanHostapdDev != NULL)
5132 {
5133 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5134
5135 //Init the net_device structure
5136 ether_setup(pWlanHostapdDev);
5137
5138 //Initialize the adapter context to zeros.
5139 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5140 pHostapdAdapter->dev = pWlanHostapdDev;
5141 pHostapdAdapter->pHddCtx = pHddCtx;
5142 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5143
5144 //Get the Global VOSS context.
5145 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5146 //Save the adapter context in global context for future.
5147 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5148
5149 //Init the net_device structure
5150 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5151
5152 hdd_set_ap_ops( pHostapdAdapter->dev );
5153
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5155 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5156
5157 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5158 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5159
5160 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5162 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5163 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005164
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5166 }
5167 return pHostapdAdapter;
5168}
5169
5170VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5171{
5172 struct net_device *dev = pAdapter->dev;
5173 VOS_STATUS status = VOS_STATUS_SUCCESS;
5174
5175 ENTER();
5176
5177 if( rtnl_lock_held )
5178 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005179 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 if( dev_alloc_name(dev, dev->name) < 0 )
5181 {
5182 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5183 return VOS_STATUS_E_FAILURE;
5184 }
5185 }
5186 if (register_netdevice(dev))
5187 {
5188 hddLog(VOS_TRACE_LEVEL_FATAL,
5189 "%s:Failed:register_netdevice", __func__);
5190 return VOS_STATUS_E_FAILURE;
5191 }
5192 }
5193 else
5194 {
5195 if (register_netdev(dev))
5196 {
5197 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5198 return VOS_STATUS_E_FAILURE;
5199 }
5200 }
5201 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5202
5203 EXIT();
5204 return status;
5205}
5206
c_hpothu002231a2015-02-05 14:58:51 +05305207VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005208{
5209 ENTER();
5210
5211 hdd_softap_deinit_tx_rx(pAdapter);
5212
5213 /* if we are being called during driver unload, then the dev has already
5214 been invalidated. if we are being called at other times, then we can
5215 detatch the wireless device handlers */
5216 if (pAdapter->dev)
5217 {
c_hpothu002231a2015-02-05 14:58:51 +05305218 if (TRUE == rtnl_held)
5219 {
5220 pAdapter->dev->wireless_handlers = NULL;
5221 }
5222 else
5223 {
5224 rtnl_lock();
5225 pAdapter->dev->wireless_handlers = NULL;
5226 rtnl_unlock();
5227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 }
5229 EXIT();
5230 return 0;
5231}