blob: e4abb854e2594c10f7d25295c23a797dd37b03c9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashish6773c902017-01-06 19:45:03 +05302 * Copyright (c) 2012-2017 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"
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053082#include <wlan_hdd_wowl.h>
Agrawal Ashish17ef5082016-10-17 18:33:21 +053083#include "wlan_hdd_hostapd.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Leo Chang0b0e45a2013-12-15 15:18:55 -080085#ifdef FEATURE_WLAN_CH_AVOID
86#include "wcnss_wlan.h"
87#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053088#include "wlan_hdd_trace.h"
89#include "vos_types.h"
90#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080091
Jeff Johnson295189b2012-06-20 16:38:30 -070092#define IS_UP(_dev) \
93 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
94#define IS_UP_AUTO(_ic) \
95 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
96#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070097#define WE_GET_STA_INFO_SIZE 30
98/* WEXT limition: MAX allowed buf len for any *
99 * IW_PRIV_TYPE_CHAR is 2Kbytes *
100 */
101#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530103#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700104
Leo Chang0b0e45a2013-12-15 15:18:55 -0800105#ifdef FEATURE_WLAN_CH_AVOID
106/* Channle/Freqency table */
107extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
108safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
109{
110 /*CH , SAFE, default safe */
111 {1 , VOS_TRUE}, //RF_CHAN_1,
112 {2 , VOS_TRUE}, //RF_CHAN_2,
113 {3 , VOS_TRUE}, //RF_CHAN_3,
114 {4 , VOS_TRUE}, //RF_CHAN_4,
115 {5 , VOS_TRUE}, //RF_CHAN_5,
116 {6 , VOS_TRUE}, //RF_CHAN_6,
117 {7 , VOS_TRUE}, //RF_CHAN_7,
118 {8 , VOS_TRUE}, //RF_CHAN_8,
119 {9 , VOS_TRUE}, //RF_CHAN_9,
120 {10 , VOS_TRUE}, //RF_CHAN_10,
121 {11 , VOS_TRUE}, //RF_CHAN_11,
122 {12 , VOS_TRUE}, //RF_CHAN_12,
123 {13 , VOS_TRUE}, //RF_CHAN_13,
124 {14 , VOS_TRUE}, //RF_CHAN_14,
125 {240, VOS_TRUE}, //RF_CHAN_240,
126 {244, VOS_TRUE}, //RF_CHAN_244,
127 {248, VOS_TRUE}, //RF_CHAN_248,
128 {252, VOS_TRUE}, //RF_CHAN_252,
129 {208, VOS_TRUE}, //RF_CHAN_208,
130 {212, VOS_TRUE}, //RF_CHAN_212,
131 {216, VOS_TRUE}, //RF_CHAN_216,
132 {36 , VOS_TRUE}, //RF_CHAN_36,
133 {40 , VOS_TRUE}, //RF_CHAN_40,
134 {44 , VOS_TRUE}, //RF_CHAN_44,
135 {48 , VOS_TRUE}, //RF_CHAN_48,
136 {52 , VOS_TRUE}, //RF_CHAN_52,
137 {56 , VOS_TRUE}, //RF_CHAN_56,
138 {60 , VOS_TRUE}, //RF_CHAN_60,
139 {64 , VOS_TRUE}, //RF_CHAN_64,
140 {100, VOS_TRUE}, //RF_CHAN_100,
141 {104, VOS_TRUE}, //RF_CHAN_104,
142 {108, VOS_TRUE}, //RF_CHAN_108,
143 {112, VOS_TRUE}, //RF_CHAN_112,
144 {116, VOS_TRUE}, //RF_CHAN_116,
145 {120, VOS_TRUE}, //RF_CHAN_120,
146 {124, VOS_TRUE}, //RF_CHAN_124,
147 {128, VOS_TRUE}, //RF_CHAN_128,
148 {132, VOS_TRUE}, //RF_CHAN_132,
149 {136, VOS_TRUE}, //RF_CHAN_136,
150 {140, VOS_TRUE}, //RF_CHAN_140,
151 {149, VOS_TRUE}, //RF_CHAN_149,
152 {153, VOS_TRUE}, //RF_CHAN_153,
153 {157, VOS_TRUE}, //RF_CHAN_157,
154 {161, VOS_TRUE}, //RF_CHAN_161,
155 {165, VOS_TRUE}, //RF_CHAN_165,
156};
157#endif /* FEATURE_WLAN_CH_AVOID */
158
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530159/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 * Function definitions
161 *-------------------------------------------------------------------------*/
162/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530164 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 This is called in response to ifconfig up
167
168 \param - dev Pointer to net_device structure
169
170 \return - 0 for success non-zero for failure
171
172 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530173int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 ENTER();
178
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530179 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
180 {
181 //WMM_INIT OR BSS_START not completed
182 hddLog( LOGW, "Ignore hostadp open request");
183 EXIT();
184 return 0;
185 }
186
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530187 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
188 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 //Turn ON carrier state
190 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530191 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 EXIT();
196 return 0;
197}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530198
199int hdd_hostapd_open (struct net_device *dev)
200{
201 int ret;
202
203 vos_ssr_protect(__func__);
204 ret = __hdd_hostapd_open(dev);
205 vos_ssr_unprotect(__func__);
206
207 return ret;
208}
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210/**---------------------------------------------------------------------------
211
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530212 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214 This is called in response to ifconfig down
215
216 \param - dev Pointer to net_device structure
217
218 \return - 0 for success non-zero for failure
219
220 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530221int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222{
223 ENTER();
224
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530226 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530227 //Stop all tx queues
228 netif_tx_disable(dev);
229
230 //Turn OFF carrier state
231 netif_carrier_off(dev);
232 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234 EXIT();
235 return 0;
236}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530237
238int hdd_hostapd_stop (struct net_device *dev)
239{
240 int ret;
241
242 vos_ssr_protect(__func__);
243 ret = __hdd_hostapd_stop(dev);
244 vos_ssr_unprotect(__func__);
245
246 return ret;
247}
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249/**---------------------------------------------------------------------------
250
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530251 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253 This is called during the netdev unregister to uninitialize all data
254associated with the device
255
256 \param - dev Pointer to net_device structure
257
258 \return - void
259
260 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530261static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700262{
263 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530264 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 ENTER();
267
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530270 hddLog(VOS_TRACE_LEVEL_ERROR,
271 FL("Invalid magic"));
272 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530274 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
275 if (NULL == pHddCtx)
276 {
277 hddLog(VOS_TRACE_LEVEL_ERROR,
278 FL("NULL pHddCtx"));
279 return;
280 }
281
282 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
283
284 /* after uninit our adapter structure will no longer be valid */
285 pHostapdAdapter->dev = NULL;
286 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 EXIT();
289}
290
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530291static void hdd_hostapd_uninit (struct net_device *dev)
292{
293 vos_ssr_protect(__func__);
294 __hdd_hostapd_uninit(dev);
295 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530297 return;
298}
Jeff Johnson295189b2012-06-20 16:38:30 -0700299/**============================================================================
300 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
301 transmitting packets. There are 2 versions of this function. One that uses
302 locked queue and other that uses lockless queues. Both have been retained to
303 do some performance testing
304 @param skb : [in] pointer to OS packet (sk_buff)
305 @param dev : [in] pointer to Libra network device
306
307 @return : NET_XMIT_DROP if packets are dropped
308 : NET_XMIT_SUCCESS if packet is enqueued succesfully
309 ===========================================================================*/
310int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
311{
312 return 0;
313}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530314
315int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700316{
317 return 0;
318}
319
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530320int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
321{
322 int ret;
323 vos_ssr_protect(__func__);
324 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
325 vos_ssr_unprotect(__func__);
326
327 return ret;
328}
329
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700330static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
331 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700333 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530334 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
335 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530337 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700338 /*
339 * Note that valid pointers are provided by caller
340 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530342 ENTER();
343
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700344 if (priv_data->total_len <= 0 ||
345 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
346 {
347 /* below we allocate one more byte for command buffer.
348 * To avoid addition overflow total_len should be
349 * smaller than INT_MAX. */
350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
351 __func__, priv_data->total_len);
352 ret = -EFAULT;
353 goto exit;
354 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530355 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 if (0 != status)
357 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530358 return status;
359 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700361 /* Allocate +1 for '\0' */
362 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
363 if (!command)
364 {
365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
366 ret = -ENOMEM;
367 goto exit;
368 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700369
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700370 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
371 {
372 ret = -EFAULT;
373 goto exit;
374 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800375
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 /* Make sure the command is NUL-terminated */
377 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700379 hddLog(VOS_TRACE_LEVEL_INFO,
380 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700382 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
383 {
384 hdd_setP2pNoa(pAdapter->dev, command);
385 }
386 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
387 {
388 hdd_setP2pOpps(pAdapter->dev, command);
389 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800390#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700391 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
392 {
393 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
394 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800395#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700396 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
397 {
398 /*
399 * command should be a string having format
400 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
401 */
402 hddLog(VOS_TRACE_LEVEL_INFO,
403 "%s: Received Command to Set Preferred Channels for SAP",
404 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800405
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700406 ret = sapSetPreferredChannel(command);
407 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530408 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
409 {
410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
411 tANI_U8 filterType = 0;
412 tANI_U8 *value;
413 value = command + 9;
414
415 /* Convert the value from ascii to integer */
416 ret = kstrtou8(value, 10, &filterType);
417 if (ret < 0)
418 {
419 /* If the input value is greater than max value of datatype,
420 * then also kstrtou8 fails
421 */
422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
423 "%s: kstrtou8 failed range ", __func__);
424 ret = -EINVAL;
425 goto exit;
426 }
427 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
428 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
429 {
430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
431 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
432 " 2-Sink ", __func__);
433 ret = -EINVAL;
434 goto exit;
435 }
436 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
437 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530438 pScanInfo = &pHddCtx->scan_info;
439 if (filterType && pScanInfo != NULL &&
440 pHddCtx->scan_info.mScanPending)
441 {
442 /*Miracast Session started. Abort Scan */
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
444 "%s, Aborting Scan For Miracast",__func__);
445 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
446 eCSR_SCAN_ABORT_DEFAULT);
447 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530448 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
449 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
450 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530451 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
452 {
453 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
454 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456exit:
457 if (command)
458 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700459 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 return ret;
463}
464
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700465#ifdef CONFIG_COMPAT
466static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
467 struct ifreq *ifr)
468{
469 struct {
470 compat_uptr_t buf;
471 int used_len;
472 int total_len;
473 } compat_priv_data;
474 hdd_priv_data_t priv_data;
475 int ret = 0;
476
477 /*
478 * Note that pAdapter and ifr have already been verified by caller,
479 * and HDD context has also been validated
480 */
481 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
482 sizeof(compat_priv_data))) {
483 ret = -EFAULT;
484 goto exit;
485 }
486 priv_data.buf = compat_ptr(compat_priv_data.buf);
487 priv_data.used_len = compat_priv_data.used_len;
488 priv_data.total_len = compat_priv_data.total_len;
489 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
490 exit:
491 return ret;
492}
493#else /* CONFIG_COMPAT */
494static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
495 struct ifreq *ifr)
496{
497 /* will never be invoked */
498 return 0;
499}
500#endif /* CONFIG_COMPAT */
501
502static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
503{
504 hdd_priv_data_t priv_data;
505 int ret = 0;
506
507 /*
508 * Note that pAdapter and ifr have already been verified by caller,
509 * and HDD context has also been validated
510 */
511 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
512 ret = -EFAULT;
513 } else {
514 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
515 }
516 return ret;
517}
518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530519static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700520 struct ifreq *ifr, int cmd)
521{
522 hdd_adapter_t *pAdapter;
523 hdd_context_t *pHddCtx;
524 int ret;
525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530526 ENTER();
527
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
529 if (NULL == pAdapter) {
530 hddLog(VOS_TRACE_LEVEL_ERROR,
531 "%s: HDD adapter context is Null", __func__);
532 ret = -ENODEV;
533 goto exit;
534 }
535 if (dev != pAdapter->dev) {
536 hddLog(VOS_TRACE_LEVEL_ERROR,
537 "%s: HDD adapter/dev inconsistency", __func__);
538 ret = -ENODEV;
539 goto exit;
540 }
541
542 if ((!ifr) || (!ifr->ifr_data)) {
543 ret = -EINVAL;
544 goto exit;
545 }
546
547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
548 ret = wlan_hdd_validate_context(pHddCtx);
549 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700550 ret = -EBUSY;
551 goto exit;
552 }
553
554 switch (cmd) {
555 case (SIOCDEVPRIVATE + 1):
556 if (is_compat_task())
557 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
558 else
559 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
560 break;
561 default:
562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
563 __func__, cmd);
564 ret = -EINVAL;
565 break;
566 }
567 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530568 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700569 return ret;
570}
571
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530572static int hdd_hostapd_ioctl(struct net_device *dev,
573 struct ifreq *ifr, int cmd)
574{
575 int ret;
576
577 vos_ssr_protect(__func__);
578 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
579 vos_ssr_unprotect(__func__);
580
581 return ret;
582}
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584/**---------------------------------------------------------------------------
585
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530586 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 This function sets the user specified mac address using
588 the command ifconfig wlanX hw ether <mac adress>.
589
590 \param - dev - Pointer to the net device.
591 - addr - Pointer to the sockaddr.
592 \return - 0 for success, non zero for failure
593
594 --------------------------------------------------------------------------*/
595
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530596static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597{
598 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530599 hdd_adapter_t *pAdapter;
600 hdd_context_t *pHddCtx;
601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530602
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
605 if (NULL == pAdapter)
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Adapter is NULL",__func__);
609 return -EINVAL;
610 }
611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
612 ret = wlan_hdd_validate_context(pHddCtx);
613 if (0 != ret)
614 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530615 return ret;
616 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
618 EXIT();
619 return 0;
620}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530621
622static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
623{
624 int ret;
625
626 vos_ssr_protect(__func__);
627 ret = __hdd_hostapd_set_mac_address(dev, addr);
628 vos_ssr_unprotect(__func__);
629
630 return ret;
631}
632
Jeff Johnson295189b2012-06-20 16:38:30 -0700633void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
634{
635 struct net_device *dev = (struct net_device *)usrDataForCallback;
636 v_BYTE_t we_custom_event[64];
637 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530639 hdd_context_t *pHddCtx;
640#ifdef DISABLE_CONCURRENCY_AUTOSAVE
641 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hdd_ap_ctx_t *pHddApCtx;
643#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
644
645 /* event_name space-delimiter driver_module_name */
646 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
647 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
648 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
649
650 ENTER();
651
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530652 pHostapdAdapter = netdev_priv(dev);
653 if ((NULL == pHostapdAdapter) ||
654 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
655 {
656 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
657 return;
658 }
659 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
660 if (0 != (wlan_hdd_validate_context(pHddCtx)))
661 {
662 return;
663 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530664#ifdef DISABLE_CONCURRENCY_AUTOSAVE
665 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530666 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 /*
668 This timer routine is going to be called only when AP
669 persona is up.
670 If there are concurrent sessions running we do not want
671 to shut down the Bss.Instead we run the timer again so
672 that if Autosave is enabled next time and other session
673 was down only then we bring down AP
674 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
676 vos_status = vos_timer_start(
677 &pHddApCtx->hdd_ap_inactivity_timer,
678 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
679 * 1000);
680 if (!VOS_IS_STATUS_SUCCESS(vos_status))
681 {
682 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
683 }
684 EXIT();
685 return;
686 }
687#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
688 memset(&we_custom_event, '\0', sizeof(we_custom_event));
689 memcpy(&we_custom_event, autoShutEvent, event_len);
690
691 memset(&wrqu, 0, sizeof(wrqu));
692 wrqu.data.length = event_len;
693
694 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
695 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
696
697 EXIT();
698}
699
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800700VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
701{
702 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
703 ptSapContext pSapCtx = NULL;
704 eHalStatus halStatus = eHAL_STATUS_FAILURE;
705 v_PVOID_t hHal = NULL;
706
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
708 "%s: UPDATE Beacon Params", __func__);
709
710 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
711 pSapCtx = VOS_GET_SAP_CB(pVosContext);
712 if ( NULL == pSapCtx )
713 {
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
715 "%s: Invalid SAP pointer from pvosGCtx", __func__);
716 return VOS_STATUS_E_FAULT;
717 }
718
719 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
720 if ( NULL == hHal ){
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Invalid HAL pointer from pvosGCtx", __func__);
723 return VOS_STATUS_E_FAULT;
724 }
725 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
726 if(halStatus == eHAL_STATUS_FAILURE ){
727 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
728 "%s: Failed to update Beacon Params", __func__);
729 return VOS_STATUS_E_FAILURE;
730 }
731 }
732 return VOS_STATUS_SUCCESS;
733}
734
735void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
736{
737 v_U8_t staId = 0;
738 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530739 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
740 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800741
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530742 dev = (struct net_device *)usrDataForCallback;
743 pSapCtx = VOS_GET_SAP_CB(pVosContext);
744 if(pSapCtx == NULL){
745 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
746 FL("psapCtx is NULL"));
747 return;
748 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800749 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
751 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530752 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800753 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
754 {
755 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530756 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800757 }
758 }
759}
760
Agarwal Ashish8e538932014-12-24 18:12:52 +0530761static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762{
763 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530764 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800765 VOS_STATUS status = VOS_STATUS_SUCCESS;
766 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530767
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800768 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530769
770 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
771 status = wlan_hdd_validate_context(pHddCtx);
772
773 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530774 return status;
775 }
776
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800777 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
778 {
779 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
780 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800782 }
783 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530784 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800785 }
786 EXIT();
787 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
788}
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530790#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530791bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530792 bool enabled)
793{
794 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530795 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530796
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530797 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530798 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
799
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530800 sap_offload_info.sap_auth_offload_enable = enabled;
801 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530802 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530803 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530804 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
805
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530806 if (sap_offload_info.sap_auth_offload_enable &&
807 sap_offload_info.sap_auth_offload_sec_type)
808 {
809 if (sap_offload_info.key_len < 8 ||
810 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
811 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530812 hddLog(VOS_TRACE_LEVEL_ERROR,
813 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530814 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530815 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530816 }
817 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530818 if (sap_offload_info.key_len)
819 {
820 vos_mem_copy(sap_offload_info.key,
821 pHddCtx->cfg_ini->sap_auth_offload_key,
822 sap_offload_info.key_len);
823 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530824 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530825 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
826 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530827 hddLog(VOS_TRACE_LEVEL_ERROR,
828 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530829 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530830 }
831
832 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
833 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530834 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530835}
836#endif
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
839{
840 hdd_adapter_t *pHostapdAdapter;
841 hdd_ap_ctx_t *pHddApCtx;
842 hdd_hostapd_state_t *pHostapdState;
843 struct net_device *dev;
844 eSapHddEvent sapEvent;
845 union iwreq_data wrqu;
846 v_BYTE_t *we_custom_event_generic = NULL;
847 int we_event = 0;
848 int i = 0;
849 v_U8_t staId;
850 VOS_STATUS vos_status;
851 v_BOOL_t bWPSState;
852 v_BOOL_t bApActive = FALSE;
853 v_BOOL_t bAuthRequired = TRUE;
854 tpSap_AssocMacAddr pAssocStasArray = NULL;
855 char unknownSTAEvent[IW_CUSTOM_MAX+1];
856 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
857 v_BYTE_t we_custom_start_event[64];
858 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800859 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800860 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700861 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530862 v_CONTEXT_t pVosContext = NULL;
863 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +0530864 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
866 dev = (struct net_device *)usrDataForCallback;
867 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530868
869 if ((NULL == pHostapdAdapter) ||
870 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
871 {
872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
873 "invalid adapter or adapter has invalid magic");
874 return eHAL_STATUS_FAILURE;
875 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530876 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
877 pSapCtx = VOS_GET_SAP_CB(pVosContext);
878 if(pSapCtx == NULL){
879 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
880 FL("psapCtx is NULL"));
881 return eHAL_STATUS_FAILURE;
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
884 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
885 sapEvent = pSapEvent->sapHddEventCode;
886 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800887 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +0530888 cfg_param = pHddCtx->cfg_ini;
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890
891 switch(sapEvent)
892 {
893 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800894 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
896 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
897 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
898
899 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
900 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +0530901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +0530903 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 goto stopbss;
906 }
907 else
Deepthi Gowried085092015-10-20 19:30:52 +0530908 {
909 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
910 {
911 if ((cfg_param->dynSplitscan) &&
912 (!pHddCtx->issplitscan_enabled))
913 {
914 pHddCtx->issplitscan_enabled = TRUE;
915 sme_enable_disable_split_scan(
916 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
917 cfg_param->nNumStaChanCombinedConc,
918 cfg_param->nNumP2PChanCombinedConc);
919 }
920 }
921
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
923 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530924 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
925 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530926 {
c_hpothuffdb5272013-10-02 16:42:35 +0530927 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530928 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 }
Deepthi Gowried085092015-10-20 19:30:52 +0530931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
933 {
934 // AP Inactivity timer init and start
935 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
936 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
937 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800938 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939
940 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
941 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800942 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 }
945 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
946 pHostapdState->bssState = BSS_START;
947
948 // Send current operating channel of SoftAP to BTC-ES
949 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 //Check if there is any group key pending to set.
952 if( pHddApCtx->groupKey.keyLength )
953 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700954 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
956 &pHddApCtx->groupKey ) )
957 {
958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 "%s: WLANSAP_SetKeySta failed", __func__);
960 }
961 pHddApCtx->groupKey.keyLength = 0;
962 }
963 else if ( pHddApCtx->wepKey[0].keyLength )
964 {
965 int i=0;
966 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
967 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700968 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
970 &pHddApCtx->wepKey[i] ) )
971 {
972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
973 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
974 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
976 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
978 startBssEvent = "SOFTAP.enabled";
979 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
980 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
981 memset(&wrqu, 0, sizeof(wrqu));
982 wrqu.data.length = strlen(startBssEvent);
983 we_event = IWEVCUSTOM;
984 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700985 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 break; //Event will be sent after Switch-Case stmt
987
988 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800989 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
991
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530992#ifdef SAP_AUTH_OFFLOAD
993 if (cfg_param->enable_sap_auth_offload)
994 hdd_set_sap_auth_offload(pHostapdAdapter, FALSE);
995#endif
996
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700997 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700998 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301001
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301002 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301003 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301004 hddLog(LOG1,
1005 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1006 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301007 }
1008
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 goto stopbss;
1010 case eSAP_STA_SET_KEY_EVENT:
1011 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001012 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1014 return VOS_STATUS_SUCCESS;
1015 case eSAP_STA_DEL_KEY_EVENT:
1016 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001017 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 return VOS_STATUS_SUCCESS;
1019 case eSAP_STA_MIC_FAILURE_EVENT:
1020 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 memset(&msg, '\0', sizeof(msg));
1022 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001023 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001024 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001025 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 msg.flags = IW_MICFAILURE_GROUP;
1027 else
1028 msg.flags = IW_MICFAILURE_PAIRWISE;
1029 memset(&wrqu, 0, sizeof(wrqu));
1030 wrqu.data.length = sizeof(msg);
1031 we_event = IWEVMICHAELMICFAILURE;
1032 we_custom_event_generic = (v_BYTE_t *)&msg;
1033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /* inform mic failure to nl80211 */
1035 cfg80211_michael_mic_failure(dev,
1036 pSapEvent->sapevt.
1037 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001038 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 NL80211_KEYTYPE_GROUP :
1040 NL80211_KEYTYPE_PAIRWISE),
1041 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1042 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1043 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 break;
1045
1046 case eSAP_STA_ASSOC_EVENT:
1047 case eSAP_STA_REASSOC_EVENT:
1048 wrqu.addr.sa_family = ARPHRD_ETHER;
1049 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001050 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001051 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 we_event = IWEVREGISTERED;
1053
1054 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1055
1056 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1057 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1058 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1059 {
1060 bAuthRequired = FALSE;
1061 }
1062
1063 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
1064 {
c_hpothuffdb5272013-10-02 16:42:35 +05301065 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 TRUE,
1067 pHddApCtx->uPrivacy,
1068 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1069 0,
1070 0,
1071 (v_MACADDR_t *)wrqu.addr.sa_data,
1072 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301073
1074 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1075 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1076 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 }
1078 else
1079 {
c_hpothuffdb5272013-10-02 16:42:35 +05301080 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 FALSE,
1082 pHddApCtx->uPrivacy,
1083 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1084 0,
1085 0,
1086 (v_MACADDR_t *)wrqu.addr.sa_data,
1087 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301088 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1089 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1090 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001091 }
1092
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301093 staId =
1094 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1095 if (VOS_IS_STATUS_SUCCESS(vos_status))
1096 {
1097
1098 pSapCtx->aStaInfo[staId].rate_flags =
1099 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1100 }
1101
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 // Stop AP inactivity timer
1103 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1104 {
1105 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1106 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001107 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001109#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001110 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1111 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301112 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1113 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001114 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301115 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1116 HDD_SAP_WAKE_LOCK_DURATION,
1117 WIFI_POWER_EVENT_WAKELOCK_SAP);
1118
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001119#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001120#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1121 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301122 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1124
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301125 staInfo = vos_mem_malloc(sizeof(*staInfo));
1126 if (staInfo == NULL) {
1127 hddLog(LOGE, FL("alloc station_info failed"));
1128 return VOS_STATUS_E_NOMEM;
1129 }
1130
1131 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1133 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301134 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301136 staInfo->assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001137#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301138 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 cfg80211_new_sta(dev,
1141 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301142 staInfo, GFP_KERNEL);
1143 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 }
1145 else
1146 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001147 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 }
1149 }
1150#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301151 hdd_manage_delack_timer(pHddCtx);
1152
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001153 pScanInfo = &pHddCtx->scan_info;
1154 // Lets do abort scan to ensure smooth authentication for client
1155 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1156 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301157 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301158 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001160
1161 break;
1162 case eSAP_STA_DISASSOC_EVENT:
1163 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001164 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001165 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1167 hddLog(LOG1," User initiated disassociation");
1168 else
1169 hddLog(LOG1," MAC initiated disassociation");
1170 we_event = IWEVEXPIRED;
1171 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1172 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1173 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001174 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 -07001175 return VOS_STATUS_E_FAILURE;
1176 }
1177 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1178
1179 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1180 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301181 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 // Start AP inactivity timer if no stations associated with it
1183 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1184 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301185 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 {
1187 bApActive = TRUE;
1188 break;
1189 }
1190 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301191 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193 if (bApActive == FALSE)
1194 {
1195 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1196 {
1197 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1198 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001199 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 }
1201 else
1202 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1203 }
1204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001205#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1206 cfg80211_del_sta(dev,
1207 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1208 GFP_KERNEL);
1209#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001210 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301211 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1212 if (VOS_STATUS_SUCCESS != vos_status)
1213 {
1214 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1215 __func__, vos_status);
1216 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301217 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 break;
1219 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1220 {
1221 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1222 union iwreq_data wreq;
1223
1224 down(&pHddApCtx->semWpsPBCOverlapInd);
1225 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1226
1227 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1228 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1229
1230 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001231 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 memset(&wreq, 0, sizeof(wreq));
1233 wreq.data.length = strlen(message); // This is length of message
1234 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1235
1236 return VOS_STATUS_SUCCESS;
1237 }
1238 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1239 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1240 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1241 { // List of associated stations
1242 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1243 {
1244 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1245 i+1,
1246 pAssocStasArray->assocId,
1247 pAssocStasArray->staId,
1248 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1249 pAssocStasArray++;
1250 }
1251 }
1252 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001253 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 case eSAP_REMAIN_CHAN_READY:
1256 hdd_remainChanReadyHandler( pHostapdAdapter );
1257 return VOS_STATUS_SUCCESS;
1258 case eSAP_SEND_ACTION_CNF:
1259 hdd_sendActionCnf( pHostapdAdapter,
1260 ( eSAP_STATUS_SUCCESS ==
1261 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1262 TRUE : FALSE );
1263 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 case eSAP_UNKNOWN_STA_JOIN:
1265 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1266 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1267 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1268 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1269 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1270 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1271 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1272 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1273 wrqu.data.pointer = unknownSTAEvent;
1274 wrqu.data.length = strlen(unknownSTAEvent);
1275 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301276 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 break;
1278
1279 case eSAP_MAX_ASSOC_EXCEEDED:
1280 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1281 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1282 " one or more devices to enable the new device connection",
1283 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1284 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1285 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1286 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1287 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1288 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1289 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1290 wrqu.data.pointer = maxAssocExceededEvent;
1291 wrqu.data.length = strlen(maxAssocExceededEvent);
1292 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001293 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 break;
1295 case eSAP_STA_ASSOC_IND:
1296 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001297
1298 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001299 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001300 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1301 return VOS_STATUS_SUCCESS;
1302
1303 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301304 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301305 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1306 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301307 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301308 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001309 return VOS_STATUS_SUCCESS;
1310
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001312 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 goto stopbss;
1314 return VOS_STATUS_SUCCESS;
1315 }
1316 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1317 return VOS_STATUS_SUCCESS;
1318
1319stopbss :
1320 {
1321 v_BYTE_t we_custom_event[64];
1322 char *stopBssEvent = "STOP-BSS.response";//17
1323 int event_len = strlen(stopBssEvent);
1324
1325 hddLog(LOG1, FL("BSS stop status = %s"),
1326 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1327 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1328
1329 /* Change the BSS state now since, as we are shutting things down,
1330 * we don't want interfaces to become re-enabled */
1331 pHostapdState->bssState = BSS_STOP;
1332
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301333 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1334 {
1335 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1336 {
1337 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1338 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1339 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1340 }
1341
1342 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1343 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1344 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1345 }
1346
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 /* Stop the pkts from n/w stack as we are going to free all of
1348 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301349
1350 /*
1351 * If channel avoidance is in progress means driver is performing SAP
1352 * restart. So don't do carrier off, which may lead framework to do
1353 * driver reload.
1354 */
1355 hddLog(LOG1, FL("ch avoid in progress: %d"),
1356 pHddCtx->is_ch_avoid_in_progress);
1357 if (pHddCtx->is_ch_avoid_in_progress &&
1358 pHddCtx->cfg_ini->sap_restrt_ch_avoid)
1359 netif_tx_disable(dev);
1360 else
1361 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301364 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1365 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1366 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
Amar Singhal37e6f052013-03-05 16:16:54 -08001368 /* once the event is set, structure dev/pHostapdAdapter should
1369 * not be touched since they are now subject to being deleted
1370 * by another thread */
1371 if (eSAP_STOP_BSS_EVENT == sapEvent)
1372 vos_event_set(&pHostapdState->vosEvent);
1373
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 /* notify userspace that the BSS has stopped */
1375 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1376 memcpy(&we_custom_event, stopBssEvent, event_len);
1377 memset(&wrqu, 0, sizeof(wrqu));
1378 wrqu.data.length = event_len;
1379 we_event = IWEVCUSTOM;
1380 we_custom_event_generic = we_custom_event;
1381 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001382 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 }
1384 return VOS_STATUS_SUCCESS;
1385}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001386
1387int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001389 eCsrEncryptionType *pEncryptType,
1390 eCsrEncryptionType *mcEncryptType,
1391 eCsrAuthType *pAuthType,
1392 v_BOOL_t *pMFPCapable,
1393 v_BOOL_t *pMFPRequired,
1394 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 u_int8_t *gen_ie )
1396{
1397 tDot11fIERSN dot11RSNIE;
1398 tDot11fIEWPA dot11WPAIE;
1399
1400 tANI_U8 *pRsnIe;
1401 tANI_U16 RSNIeLen;
1402
1403 if (NULL == halHandle)
1404 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001405 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 return -EINVAL;
1407 }
1408
1409 // Validity checks
1410 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1411 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1412 return -EINVAL;
1413 // Type check
1414 if ( gen_ie[0] == DOT11F_EID_RSN)
1415 {
1416 // Validity checks
1417 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1418 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1419 {
1420 return VOS_STATUS_E_FAILURE;
1421 }
1422 // Skip past the EID byte and length byte
1423 pRsnIe = gen_ie + 2;
1424 RSNIeLen = gen_ie_len - 2;
1425 // Unpack the RSN IE
1426 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1427 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1428 pRsnIe,
1429 RSNIeLen,
1430 &dot11RSNIE);
1431 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001432 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001433 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001434 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001435 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 /*Here we have followed the apple base code,
1437 but probably I suspect we can do something different*/
1438 //dot11RSNIE.akm_suite_count
1439 // Just translate the FIRST one
1440 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1441 //dot11RSNIE.pwise_cipher_suite_count
1442 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1443 //dot11RSNIE.gp_cipher_suite_count
1444 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1445 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001446 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1447 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001448
1449 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1450 } else
1451 if (gen_ie[0] == DOT11F_EID_WPA)
1452 {
1453 // Validity checks
1454 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1455 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1456 {
1457 return VOS_STATUS_E_FAILURE;
1458 }
1459 // Skip past the EID byte and length byte - and four byte WiFi OUI
1460 pRsnIe = gen_ie + 2 + 4;
1461 RSNIeLen = gen_ie_len - (2 + 4);
1462 // Unpack the WPA IE
1463 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1464 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1465 pRsnIe,
1466 RSNIeLen,
1467 &dot11WPAIE);
1468 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001469 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001470 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001471 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001472 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 //dot11WPAIE.auth_suite_count
1474 // Just translate the FIRST one
1475 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1476 //dot11WPAIE.unicast_cipher_count
1477 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1478 //dot11WPAIE.unicast_cipher_count
1479 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001480 *pMFPCapable = VOS_FALSE;
1481 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 }
1483 else
1484 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001485 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 return VOS_STATUS_E_FAILURE;
1487 }
1488 return VOS_STATUS_SUCCESS;
1489}
Leo Chang614d2072013-08-22 14:59:44 -07001490
Leo Chang0b0e45a2013-12-15 15:18:55 -08001491#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001492
1493/*==========================================================================
1494 FUNCTION sapUpdateUnsafeChannelList
1495
1496 DESCRIPTION
1497 Function Undate unsafe channel list table
1498
1499 DEPENDENCIES
1500 NA.
1501
1502 PARAMETERS
1503
1504 IN
1505 pSapCtx : SAP context pointer, include unsafe channel list
1506
1507 RETURN VALUE
1508 NONE
1509============================================================================*/
1510void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1511 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1512{
1513 v_U16_t i, j;
1514
1515 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1516 sizeof(pHddCtx->unsafeChannelList));
1517 if (0 == unsafeChannelCount)
1518 {
1519 pHddCtx->unsafeChannelCount = 0;
1520 }
1521 else
1522 {
c_hpothu8de53e42014-08-22 15:00:37 +05301523 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1524 {
1525 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1526 FL("unsafeChannelCount%hd greater than %d"),
1527 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1528 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1529 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001530 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1531 unsafeChannelList,
1532 unsafeChannelCount * sizeof(tANI_U16));
1533 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1534 }
1535
1536 /* Flush, default set all channel safe */
1537 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1538 {
1539 safeChannels[i].isSafe = VOS_TRUE;
1540 }
1541
1542 /* Try to find unsafe channel */
1543 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1544 {
1545 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1546 {
1547 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1548 {
1549 /* Found unsafe channel, update it */
1550 safeChannels[j].isSafe = VOS_FALSE;
1551 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1552 "%s : CH %d is not safe",
1553 __func__, pHddCtx->unsafeChannelList[i]);
1554 break;
1555 }
1556 }
1557 }
1558
1559 return;
1560}
1561
Kapil Gupta137ef892016-12-13 19:38:00 +05301562/**
1563 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1564 * @adapter: hdd ap adapter
1565 *
1566 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1567 * and if ACS is enabled, driver will ask userspace to restart the
1568 * sap. User space on LTE coex indication restart driver.
1569 *
1570 * Return - none
1571 */
1572static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1573 hdd_context_t *hdd_ctx)
1574{
1575
1576 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1577 return;
1578 }
1579
1580 hddLog(LOG1, FL("Current operation channel %d"),
1581 adapter->sessionCtx.ap.operatingChannel);
1582 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1583 hdd_change_ch_avoidance_status(hdd_ctx, true);
1584
1585 vos_flush_work(
1586 &hdd_ctx->sap_start_work);
1587
1588 /*
1589 * current operating channel
1590 * is un-safe channel, restart SAP
1591 */
1592 hddLog(LOG1,
1593 FL("Restarting SAP due to unsafe channel"));
1594
1595 adapter->sessionCtx.ap.sapConfig.channel =
1596 AUTO_CHANNEL_SELECT;
1597
Kapil Gupta137ef892016-12-13 19:38:00 +05301598
Kapil Gupta0afd1912016-12-28 12:52:13 +05301599 if (hdd_ctx->cfg_ini->sap_restrt_ch_avoid) {
1600 netif_tx_disable(adapter->dev);
1601 schedule_work(&hdd_ctx->sap_start_work);
1602 } else {
1603 hdd_hostapd_stop(adapter->dev);
1604 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301605
1606 return;
1607 }
1608 return;
1609}
1610
1611
Leo Chang0b0e45a2013-12-15 15:18:55 -08001612/**---------------------------------------------------------------------------
1613
1614 \brief hdd_hostapd_ch_avoid_cb() -
1615
1616 Avoid channel notification from FW handler.
1617 FW will send un-safe channle list to avoid overwrapping.
1618 hostapd should not use notified channel
1619
1620 \param - pAdapter HDD adapter pointer
1621 indParam channel avoid notification parameter
1622
1623 \return - None
1624
1625 --------------------------------------------------------------------------*/
1626void hdd_hostapd_ch_avoid_cb
1627(
Kapil Gupta137ef892016-12-13 19:38:00 +05301628 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08001629 void *indParam
1630)
1631{
1632 hdd_adapter_t *pHostapdAdapter = NULL;
1633 hdd_context_t *hddCtxt;
1634 tSirChAvoidIndType *chAvoidInd;
1635 v_U8_t rangeLoop;
1636 v_U16_t channelLoop;
1637 v_U16_t dupCheck;
1638 v_U16_t startChannel;
1639 v_U16_t endChannel;
1640 v_U16_t unsafeChannelCount = 0;
1641 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1642 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001643 tHddAvoidFreqList hddAvoidFreqList;
1644 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301645#ifdef WLAN_FEATURE_AP_HT40_24G
1646 ptSapContext pSapCtx = NULL;
1647 tHalHandle hHal;
1648 v_U8_t cbMode;
1649 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1650 v_U32_t delay;
1651#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001652
1653 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05301654 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001655 {
1656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1657 "%s : Invalid arguments", __func__);
1658 return;
1659 }
1660
Kapil Gupta137ef892016-12-13 19:38:00 +05301661 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001662 chAvoidInd = (tSirChAvoidIndType *)indParam;
1663 pVosContext = hddCtxt->pvosContext;
1664
1665 /* Make unsafe channel list */
1666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1667 "%s : band count %d",
1668 __func__, chAvoidInd->avoidRangeCount);
1669 vos_mem_zero((void *)unsafeChannelList,
1670 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1671 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1672 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301673 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1674 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1675 break;
1676 }
1677 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001678 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301679 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001680 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1682 "%s : start %d : %d, end %d : %d",
1683 __func__,
1684 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1685 startChannel,
1686 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1687 endChannel);
1688 for (channelLoop = startChannel;
1689 channelLoop < (endChannel + 1);
1690 channelLoop++)
1691 {
1692 /* Channel duplicate check routine */
1693 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1694 {
1695 if (unsafeChannelList[dupCheck] == channelLoop)
1696 {
1697 /* This channel is duplicated */
1698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1699 "%s : found duplicated channel %d",
1700 __func__, channelLoop);
1701 break;
1702 }
1703 }
1704 if (dupCheck == unsafeChannelCount)
1705 {
c_hpothu8de53e42014-08-22 15:00:37 +05301706 int ii;
1707 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1708 {
1709 if (channelLoop == safeChannels[ii].channelNumber)
1710 {
1711 unsafeChannelList[unsafeChannelCount] = channelLoop;
1712 unsafeChannelCount++;
1713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1714 "%s : unsafe channel %d, count %d",
1715 __func__,
1716 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301717 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1718 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1719 break;
1720 }
c_hpothu8de53e42014-08-22 15:00:37 +05301721 }
1722 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001723 }
1724 else
1725 {
1726 /* DUP, do nothing */
1727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1728 "%s : duplicated channel %d",
1729 __func__, channelLoop);
1730 }
1731 }
1732 }
1733 /* Update unsafe channel cache
1734 * WCN Platform Driver cache */
1735 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1736 unsafeChannelCount);
1737
1738 /* Store into local cache
1739 * Start with STA and later start SAP
1740 * in this scenario, local cache will be used */
1741 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1742 unsafeChannelList,
1743 unsafeChannelCount);
1744
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001745 /* generate vendor specific event */
1746 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1747 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1748 {
1749 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1750 chAvoidInd->avoidFreqRange[i].startFreq;
1751 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1752 chAvoidInd->avoidFreqRange[i].endFreq;
1753 }
1754 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1755
1756 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1757
Leo Chang0b0e45a2013-12-15 15:18:55 -08001758 /* Get SAP context first
1759 * SAP and P2PGO would not concurrent */
1760 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301761#ifdef WLAN_FEATURE_AP_HT40_24G
1762 if (NULL == pHostapdAdapter)
1763 {
1764 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1765 }
1766#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301767 if ((pHostapdAdapter) &&
1768 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1769 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001770 {
1771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1772 "%s : Current operation channel %d",
1773 __func__,
1774 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1775 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1776 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301777 if ((unsafeChannelList[channelLoop] ==
1778 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1779 {
1780 if ((AUTO_CHANNEL_SELECT ==
1781 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1782 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1783 {
1784 /* current operating channel is un-safe channel
1785 * restart driver */
Kapil Gupta137ef892016-12-13 19:38:00 +05301786 hdd_unsafe_channel_restart_sap(pHostapdAdapter, hddCtxt);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301787 /* On LE, this event is handled by wlan-services to
1788 * restart SAP. On android, this event would be
1789 * ignored.
1790 */
1791 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1792 NULL, 0);
1793 }
1794 return;
1795 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001796 }
1797 }
1798
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301799#ifdef WLAN_FEATURE_AP_HT40_24G
1800 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1801 {
1802 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1803
1804 if(pSapCtx == NULL)
1805 {
1806 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1807 FL("psapCtx is NULL"));
1808 return;
1809 }
1810
1811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1812 FL("SAP Secondary channel: %d "),
1813 pSapCtx->sap_sec_chan);
1814
1815 /* tHalHandle */
1816 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1817
1818 if (NULL == hHal)
1819 {
1820 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1821 FL("In invalid hHal"));
1822 return;
1823 }
1824
1825 cbMode = sme_GetChannelBondingMode24G(hHal);
1826
1827 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1828 FL("Selected Channel bonding : %d"), cbMode);
1829
1830 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1831 {
1832 int i;
1833 eHalStatus halStatus;
1834
1835 for (i = 0; i < unsafeChannelCount; i++)
1836 {
1837 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1838 {
1839 /* Current SAP Secondary channel is un-safe channel */
1840 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1841 FL("Move SAP from HT40 to HT20"));
1842
1843 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1844 PHY_SINGLE_CHANNEL_CENTERED);
1845
1846 if (halStatus == eHAL_STATUS_FAILURE)
1847 {
1848 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1849 FL("Failed to change HT20/40 mode"));
1850 return;
1851 }
1852
1853 /* Disable Channel Bonding for 2.4GHz */
1854 sme_UpdateChannelBondingMode24G(hHal,
1855 PHY_SINGLE_CHANNEL_CENTERED);
1856 return;
1857 }
1858 }
1859 }
1860
1861 if ((!pSapCtx->numHT40IntoSta)
1862 && (pHostapdAdapter)
1863 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1864 {
1865 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1866 * are Safe then start HT20/40 timer to Move SAP from HT20
1867 * to HT40.
1868 */
1869 if (((!unsafeChannelCount)
1870 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1871 {
1872 /* Stop Previous Running HT20/40 Timer & Start timer
1873 with (OBSS TransitionDelayFactor * obss interval)
1874 delay after time out move AP from HT20 -> HT40
1875 mode
1876 */
1877 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1878 {
1879 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1880 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1881 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1882 FL("Failed to Stop HT20/40 timer"));
1883 }
1884
1885 delay =
1886 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1887
1888 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1889 FL("Start HT20/40 transition timer (%d sec)"), delay);
1890
1891 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1892 (delay * 1000));
1893
1894 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1895 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1896 FL("Failed to Start HT20/40 timer"));
1897 }
1898 else
1899 {
1900 /* Stop HT20/40 Timer */
1901 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1902 {
1903 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1904 FL("Stop HT20/40 transition timer"));
1905 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1906 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1907 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1908 FL("Failed to Stop HT20/40 timer"));
1909 }
1910 }
1911 }
1912 }
1913#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001914 return;
1915}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001916#endif /* FEATURE_WLAN_CH_AVOID */
1917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301919static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 struct iw_request_info *info,
1921 union iwreq_data *wrqu, char *extra)
1922{
1923 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001924 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301925 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 int *value = (int *)extra;
1927 int sub_cmd = value[0];
1928 int set_value = value[1];
1929 eHalStatus status;
1930 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05301931 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001932 v_CONTEXT_t pVosContext;
1933
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301934 ENTER();
1935
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301936 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001937 {
1938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301939 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001940 __func__);
1941 return -1;
1942 }
1943
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301944 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1945 ret = wlan_hdd_validate_context(pHddCtx);
1946 if (0 != ret)
1947 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301948 return -1;
1949 }
1950
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001951 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1952 if (!hHal)
1953 {
1954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1955 "%s: Hal ctx is null", __func__);
1956 return -1;
1957 }
1958
1959 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1960 if (!pVosContext)
1961 {
1962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1963 "%s: Vos ctx is null", __func__);
1964 return -1;
1965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001966
1967 switch(sub_cmd)
1968 {
1969
1970 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001971 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301973 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 }
1975 break;
1976
1977 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301978 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1980 {
1981 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1982 ret = -EINVAL;
1983 }
1984 else
1985 {
1986 WLANSAP_SetMode(pVosContext, set_value);
1987 }
1988 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301989
1990 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1991 if ((0 != set_value) && (1 != set_value))
1992 {
1993 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1994 ret = -EINVAL;
1995 }
1996 else
1997 {
1998 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1999 }
2000 break;
2001
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 case QCSAP_PARAM_MAX_ASSOC:
2003 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2004 {
2005 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2006 ret = -EINVAL;
2007 }
2008 else
2009 {
2010 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2011 {
2012 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2013 "Setting it to max allowed and continuing"),
2014 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2015 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2016 }
2017 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2018 set_value, NULL, eANI_BOOLEAN_FALSE);
2019 if ( status != eHAL_STATUS_SUCCESS )
2020 {
2021 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2022 status);
2023 ret = -EIO;
2024 }
2025 }
2026 break;
2027
2028 case QCSAP_PARAM_HIDE_SSID:
2029 {
2030 eHalStatus status = eHAL_STATUS_SUCCESS;
2031 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2032 if(eHAL_STATUS_SUCCESS != status)
2033 {
2034 hddLog(VOS_TRACE_LEVEL_ERROR,
2035 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002036 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 return status;
2038 }
2039 break;
2040 }
2041
Leo Chang614d2072013-08-22 14:59:44 -07002042 case QCSAP_PARAM_SET_MC_RATE:
2043 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002044 tSirRateUpdateInd *rateUpdate;
2045
2046 rateUpdate = (tSirRateUpdateInd *)
2047 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2048 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002051 "%s: SET_MC_RATE indication alloc fail", __func__);
2052 ret = -1;
2053 break;
2054 }
2055 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2056
2057 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2058 /* Ignore unicast */
2059 rateUpdate->ucastDataRate = -1;
2060 rateUpdate->mcastDataRate24GHz = set_value;
2061 rateUpdate->mcastDataRate5GHz = set_value;
2062 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2063 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2064 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2065 if (eHAL_STATUS_SUCCESS != status)
2066 {
2067 hddLog(VOS_TRACE_LEVEL_ERROR,
2068 "%s: SET_MC_RATE failed", __func__);
2069 vos_mem_free(rateUpdate);
2070 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002071 }
2072 break;
2073 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302074 case QCSAP_PARAM_GET_FRAME_LOGS:
2075 {
2076 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2077 != VOS_STATUS_SUCCESS)
2078 {
2079 ret = -EINVAL;
2080 }
2081 break;
2082 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302083 case QCSAP_PARAM_SET_PROXIMITY:
2084 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302085 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302086 break;
2087 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302088 case QCSAP_PARAM_SET_WOWL:
2089 {
2090 if (!pHddCtx->is_ap_mode_wow_supported)
2091 {
2092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2093 "%s: Not supported",__func__);
2094 return -ENOTSUPP;
2095 }
2096 switch (set_value)
2097 {
2098 case 0x00:
2099 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2100 break;
2101 case 0x01:
2102 case 0x02:
2103 case 0x03:
2104 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2105 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2106 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2107 (enable_magic_pkt ? "YES":"NO"),
2108 (enable_pattrn_byte_match ? "YES":"NO"));
2109 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2110 enable_pattrn_byte_match);
2111 break;
2112 default:
2113 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2114 ret = -EINVAL;
2115 break;
2116 }
2117 break;
2118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 default:
2120 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2121 sub_cmd, set_value);
2122 ret = -EINVAL;
2123 break;
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_setparam(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_setparam(dev, info, wrqu, extra);
2139 vos_ssr_unprotect(__func__);
2140
2141 return ret;
2142}
Jeff Johnson295189b2012-06-20 16:38:30 -07002143
2144int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302145static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 struct iw_request_info *info,
2147 union iwreq_data *wrqu, char *extra)
2148{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302149 hdd_adapter_t *pHostapdAdapter;
2150 tHalHandle hHal;
2151 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 int *value = (int *)extra;
2153 int sub_cmd = value[0];
2154 eHalStatus status;
2155 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302156 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002157
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302158 ENTER();
2159
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302160 pHostapdAdapter = (netdev_priv(dev));
2161 if (NULL == pHostapdAdapter)
2162 {
2163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2164 "%s: Adapter is NULL",__func__);
2165 return -EINVAL;
2166 }
2167 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2168 ret = wlan_hdd_validate_context(pHddCtx);
2169 if (0 != ret)
2170 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302171 return ret;
2172 }
2173 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2174 if (NULL == hHal)
2175 {
2176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2177 "%s: Hal Context is NULL",__func__);
2178 return -EINVAL;
2179 }
2180 pVosContext = pHddCtx->pvosContext;
2181 if (NULL == pVosContext)
2182 {
2183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2184 "%s: pVosContext Context is NULL",__func__);
2185 return -EINVAL;
2186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 switch (sub_cmd)
2188 {
2189 case QCSAP_PARAM_MAX_ASSOC:
2190 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2191 if (eHAL_STATUS_SUCCESS != status)
2192 {
c_hpothuffdb5272013-10-02 16:42:35 +05302193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2194 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 ret = -EIO;
2196 }
Girish Gowli385be612014-09-18 11:17:20 +05302197
2198#ifdef WLAN_SOFTAP_VSTA_FEATURE
2199 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2200 {
2201 if (*value > VSTA_NUM_ASSOC_STA)
2202 {
2203 *value = VSTA_NUM_ASSOC_STA;
2204 }
2205 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2206 (*value > (VSTA_NUM_ASSOC_STA -
2207 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2208 {
2209 *value = (VSTA_NUM_ASSOC_STA -
2210 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2211 }
2212 }
2213 else
2214#endif
2215 {
2216 if (*value > NUM_ASSOC_STA)
2217 {
2218 *value = NUM_ASSOC_STA;
2219 }
2220 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2221 (*value > (NUM_ASSOC_STA -
2222 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2223 {
2224 *value = (NUM_ASSOC_STA -
2225 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2226 }
2227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302229
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002231 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 {
c_hpothuffdb5272013-10-02 16:42:35 +05302233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2234 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302235 ret = -EIO;
2236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 *value = 0;
2238 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302239
Jeff Johnson43971f52012-07-17 12:26:56 -07002240 case QCSAP_PARAM_GET_WLAN_DBG:
2241 {
2242 vos_trace_display();
2243 *value = 0;
2244 break;
2245 }
2246
2247 case QCSAP_PARAM_AUTO_CHANNEL:
2248 {
2249 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2250 break;
2251 }
2252
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 default:
2254 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2255 ret = -EINVAL;
2256 break;
2257
2258 }
2259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302260 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 return ret;
2262}
2263
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302264int
2265static iw_softap_getparam(struct net_device *dev,
2266 struct iw_request_info *info,
2267 union iwreq_data *wrqu, char *extra)
2268{
2269 int ret;
2270
2271 vos_ssr_protect(__func__);
2272 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2273 vos_ssr_unprotect(__func__);
2274
2275 return ret;
2276}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302277
2278int
2279static __iw_softap_setchar_getnone(struct net_device *dev,
2280 struct iw_request_info *info,
2281 union iwreq_data *wrqu, char *extra)
2282{
2283 int sub_cmd;
2284 int ret = 0; /* success */
2285 char *pBuffer = NULL;
2286 hdd_adapter_t *pAdapter;
2287 hdd_context_t *pHddCtx;
2288 struct iw_point s_priv_data;
2289
2290 ENTER();
2291
2292 if (!capable(CAP_NET_ADMIN))
2293 {
2294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2295 FL("permission check failed"));
2296 return -EPERM;
2297 }
2298
2299 pAdapter = (netdev_priv(dev));
2300 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2301 ret = wlan_hdd_validate_context(pHddCtx);
2302 if (0 != ret)
2303 {
2304 return ret;
2305 }
2306
2307 if (!pHddCtx->is_ap_mode_wow_supported)
2308 {
2309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2310 "%s: Not supported",__func__);
2311 return -ENOTSUPP;
2312 }
2313
2314 /* helper function to get iwreq_data with compat handling. */
2315 if (hdd_priv_get_data(&s_priv_data, wrqu))
2316 {
2317 return -EINVAL;
2318 }
2319
2320 /* make sure all params are correctly passed to function */
2321 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2322 {
2323 return -EINVAL;
2324 }
2325
2326 sub_cmd = s_priv_data.flags;
2327
2328 /* ODD number is used for set, copy data using copy_from_user */
2329 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2330 s_priv_data.length);
2331 if (NULL == pBuffer)
2332 {
2333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2334 "mem_alloc_copy_from_user_helper fail");
2335 return -ENOMEM;
2336 }
2337
2338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2339 "%s: Received length %d", __func__, s_priv_data.length);
2340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2341 "%s: Received data %s", __func__, pBuffer);
2342
2343 switch(sub_cmd)
2344 {
2345 case WE_WOWL_ADD_PTRN:
2346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2347 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2348 if (!ret)
2349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2350 "Failed to add pattern :%d", ret);
2351 break;
2352 case WE_WOWL_DEL_PTRN:
2353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2354 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2355 if (!ret)
2356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2357 "Failed to del pattern :%d", ret);
2358 break;
2359 default:
2360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2361 ret = -EINVAL;
2362 break;
2363 }
2364
2365 kfree(pBuffer);
2366 return ret;
2367}
2368
2369int
2370static iw_softap_setchar_getnone(struct net_device *dev,
2371 struct iw_request_info *info,
2372 union iwreq_data *wrqu, char *extra)
2373{
2374 int ret;
2375
2376 vos_ssr_protect(__func__);
2377 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2378 vos_ssr_unprotect(__func__);
2379
2380 return ret;
2381}
2382
Jeff Johnson295189b2012-06-20 16:38:30 -07002383/* Usage:
2384 BLACK_LIST = 0
2385 WHITE_LIST = 1
2386 ADD MAC = 0
2387 REMOVE MAC = 1
2388
2389 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2390 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2391 while using this ioctl
2392
2393 Syntax:
2394 iwpriv softap.0 modify_acl
2395 <6 octet mac addr> <list type> <cmd type>
2396
2397 Examples:
2398 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2399 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2400 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2401 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2402*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302403int __iw_softap_modify_acl(struct net_device *dev,
2404 struct iw_request_info *info,
2405 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002406{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302407 hdd_adapter_t *pHostapdAdapter;
2408 v_CONTEXT_t pVosContext;
2409 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 v_BYTE_t *value = (v_BYTE_t*)extra;
2411 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2412 int listType, cmd, i;
2413 int ret = 0; /* success */
2414
2415 ENTER();
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 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2437 {
2438 pPeerStaMac[i] = *(value+i);
2439 }
2440 listType = (int)(*(value+i));
2441 i++;
2442 cmd = (int)(*(value+i));
2443
Arif Hussain24bafea2013-11-15 15:10:03 -08002444 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2445 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446
2447 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2448 != VOS_STATUS_SUCCESS)
2449 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002450 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 ret = -EIO;
2452 }
2453 EXIT();
2454 return ret;
2455}
2456
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302457int iw_softap_modify_acl(struct net_device *dev,
2458 struct iw_request_info *info,
2459 union iwreq_data *wrqu, char *extra)
2460{
2461 int ret;
2462
2463 vos_ssr_protect(__func__);
2464 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2465 vos_ssr_unprotect(__func__);
2466
2467 return ret;
2468}
2469
Jeff Johnson295189b2012-06-20 16:38:30 -07002470int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302471static __iw_softap_getchannel(struct net_device *dev,
2472 struct iw_request_info *info,
2473 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002474{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302475 hdd_adapter_t *pHostapdAdapter;
2476 hdd_context_t *pHddCtx;
2477 int ret = 0;
2478 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302479
2480 ENTER();
2481
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302482 pHostapdAdapter = (netdev_priv(dev));
2483 if (NULL == pHostapdAdapter)
2484 {
2485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2486 "%s: Adapter is NULL",__func__);
2487 return -EINVAL;
2488 }
2489 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2490 ret = wlan_hdd_validate_context(pHddCtx);
2491 if (0 != ret)
2492 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302493 return ret;
2494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002495
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302496 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002497
Jeff Johnson43971f52012-07-17 12:26:56 -07002498 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302499
2500 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 return 0;
2502}
2503
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302504
Jeff Johnsone7245742012-09-05 17:12:55 -07002505int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302506static iw_softap_getchannel(struct net_device *dev,
2507 struct iw_request_info *info,
2508 union iwreq_data *wrqu, char *extra)
2509{
2510 int ret;
2511
2512 vos_ssr_protect(__func__);
2513 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2514 vos_ssr_unprotect(__func__);
2515
2516 return ret;
2517}
2518
2519int
2520static __iw_softap_set_max_tx_power(struct net_device *dev,
2521 struct iw_request_info *info,
2522 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002523{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 hdd_adapter_t *pHostapdAdapter;
2525 tHalHandle hHal;
2526 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002527 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302528 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002529 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2530 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2531
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302532 ENTER();
2533
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302534 pHostapdAdapter = (netdev_priv(dev));
2535 if (NULL == pHostapdAdapter)
2536 {
2537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2538 "%s: Adapter is NULL",__func__);
2539 return -EINVAL;
2540 }
2541 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2542 ret = wlan_hdd_validate_context(pHddCtx);
2543 if (0 != ret)
2544 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302545 return ret;
2546 }
2547 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2548 if (NULL == hHal)
2549 {
2550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2551 "%s: Hal Context is NULL",__func__);
2552 return -EINVAL;
2553 }
schang86c22c42013-03-13 18:41:24 -07002554 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002555 return -ENOMEM;
2556
Leo Changd37675a2013-08-01 13:19:45 -07002557 /* Assign correct slef MAC address */
2558 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2559 VOS_MAC_ADDR_SIZE);
2560 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2561 VOS_MAC_ADDR_SIZE);
2562
schang86c22c42013-03-13 18:41:24 -07002563 set_value = value[0];
2564 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2565 {
2566 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002567 __func__);
schang86c22c42013-03-13 18:41:24 -07002568 return -EIO;
2569 }
2570
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302571 EXIT();
schang86c22c42013-03-13 18:41:24 -07002572 return 0;
2573}
2574
2575int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302576static iw_softap_set_max_tx_power(struct net_device *dev,
2577 struct iw_request_info *info,
2578 union iwreq_data *wrqu, char *extra)
2579{
2580 int ret;
2581
2582 vos_ssr_protect(__func__);
2583 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2584 vos_ssr_unprotect(__func__);
2585
2586 return ret;
2587}
2588
2589
2590int
2591static __iw_display_data_path_snapshot(struct net_device *dev,
2592 struct iw_request_info *info,
2593 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302594{
2595
2596 /* Function intitiating dumping states of
2597 * HDD(WMM Tx Queues)
2598 * TL State (with Per Client infor)
2599 * DXE Snapshot (Called at the end of TL Snapshot)
2600 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302601 hdd_adapter_t *pHostapdAdapter;
2602 hdd_context_t *pHddCtx;
2603 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302604
2605 ENTER();
2606
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302607 pHostapdAdapter = (netdev_priv(dev));
2608 if (NULL == pHostapdAdapter)
2609 {
2610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2611 "%s: Adapter is NULL",__func__);
2612 return -EINVAL;
2613 }
2614 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2615 ret = wlan_hdd_validate_context(pHddCtx);
2616 if (0 != ret)
2617 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302618 return ret;
2619 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302620 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302621 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302622
2623 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302624 return 0;
2625}
2626
2627int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302628static iw_display_data_path_snapshot(struct net_device *dev,
2629 struct iw_request_info *info,
2630 union iwreq_data *wrqu, char *extra)
2631{
2632 int ret;
2633
2634 vos_ssr_protect(__func__);
2635 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2636 vos_ssr_unprotect(__func__);
2637
2638 return ret;
2639}
2640
2641int
2642static __iw_softap_set_tx_power(struct net_device *dev,
2643 struct iw_request_info *info,
2644 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002645{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302646 hdd_adapter_t *pHostapdAdapter;
2647 hdd_context_t *pHddCtx;
2648 v_CONTEXT_t pVosContext;
2649 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002650 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302651 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002652 ptSapContext pSapCtx = NULL;
2653
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302654 ENTER();
2655
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302656 pHostapdAdapter = (netdev_priv(dev));
2657 if (NULL == pHostapdAdapter)
2658 {
2659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2660 "%s: Adapter is NULL",__func__);
2661 return -EINVAL;
2662 }
2663 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2664 ret = wlan_hdd_validate_context(pHddCtx);
2665 if (0 != ret)
2666 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302667 return ret;
2668 }
2669 pVosContext = pHddCtx->pvosContext;
2670 if (NULL == pVosContext)
2671 {
2672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2673 "%s: Vos Context is NULL",__func__);
2674 return -EINVAL;
2675 }
2676 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2677 if (NULL == hHal)
2678 {
2679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2680 "%s: Hal Context is NULL",__func__);
2681 return -EINVAL;
2682 }
schang86c22c42013-03-13 18:41:24 -07002683 if (NULL == value)
2684 return -ENOMEM;
2685
2686 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2687 if (NULL == pSapCtx)
2688 {
2689 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2690 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2691 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002692 }
2693
2694 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002695 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002696 {
schang86c22c42013-03-13 18:41:24 -07002697 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002698 __func__);
2699 return -EIO;
2700 }
2701
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302702 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002703 return 0;
2704}
2705
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302706int
2707static iw_softap_set_tx_power(struct net_device *dev,
2708 struct iw_request_info *info,
2709 union iwreq_data *wrqu, char *extra)
2710{
2711 int ret;
2712
2713 vos_ssr_protect(__func__);
2714 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2715 vos_ssr_unprotect(__func__);
2716
2717 return ret;
2718}
2719
Kiet Lambcf38522013-10-26 18:28:27 +05302720/**---------------------------------------------------------------------------
2721
2722 \brief iw_softap_set_trafficmonitor() -
2723 This function dynamically enable/disable traffic monitor functonality
2724 the command iwpriv wlanX setTrafficMon <value>.
2725
2726 \param - dev - Pointer to the net device.
2727 - addr - Pointer to the sockaddr.
2728 \return - 0 for success, non zero for failure
2729
2730 --------------------------------------------------------------------------*/
2731
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302732static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2733 struct iw_request_info *info,
2734 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302735{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302736 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302737 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302738 hdd_context_t *pHddCtx;
2739 int status;
2740
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302741 ENTER();
2742
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302743 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302744 if (NULL == pAdapter)
2745 {
2746 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2747 "%s: HDD adapter is Null", __func__);
2748 return -ENODEV;
2749 }
2750
2751 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2752
2753 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302754 if (0 != status)
2755 {
Kiet Lambcf38522013-10-26 18:28:27 +05302756 return status;
2757 }
2758
2759 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2760
2761 if (NULL == isSetTrafficMon)
2762 {
2763 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2764 "%s: Invalid SAP pointer from extra", __func__);
2765 return -ENOMEM;
2766 }
2767
2768 if (TRUE == *isSetTrafficMon)
2769 {
2770 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2771 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2772 {
2773 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2774 "%s: failed to Start Traffic Monitor timer ", __func__ );
2775 return -EIO;
2776 }
2777 }
2778 else if (FALSE == *isSetTrafficMon)
2779 {
2780 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2781 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2782 {
2783 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2784 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2785 return -EIO;
2786 }
2787
2788 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302789
2790 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302791 return 0;
2792}
2793
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302794static int iw_softap_set_trafficmonitor(struct net_device *dev,
2795 struct iw_request_info *info,
2796 union iwreq_data *wrqu, char *extra)
2797{
2798 int ret;
2799
2800 vos_ssr_protect(__func__);
2801 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2802 vos_ssr_unprotect(__func__);
2803
2804 return ret;
2805}
2806
Jeff Johnson295189b2012-06-20 16:38:30 -07002807#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2808
2809int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302810static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2811 struct iw_request_info *info,
2812 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002813{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302814 hdd_adapter_t *pHostapdAdapter;
2815 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302816 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002817 char *buf;
2818 int cnt = 0;
2819 int left;
2820 int ret = 0;
2821 /* maclist_index must be u32 to match userspace */
2822 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302823 v_CONTEXT_t pVosContext = NULL;
2824 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302825
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302826 ENTER();
2827
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302828 pHostapdAdapter = (netdev_priv(dev));
2829 if (NULL == pHostapdAdapter)
2830 {
2831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2832 "%s: Adapter is NULL",__func__);
2833 return -EINVAL;
2834 }
2835 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2836 ret = wlan_hdd_validate_context(pHddCtx);
2837 if (0 != ret)
2838 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302839 return ret;
2840 }
2841
Jeff Johnson224f3702014-03-26 11:09:47 -07002842 /*
2843 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2844 * number, and even numbered iocts are supposed to have "set"
2845 * semantics. Hence the wireless extensions support in the kernel
2846 * won't correctly copy the result to userspace, so the ioctl
2847 * handler itself must copy the data. Output format is 32-bit
2848 * record length, followed by 0 or more 6-byte STA MAC addresses.
2849 *
2850 * Further note that due to the incorrect semantics, the "iwpriv"
2851 * userspace application is unable to correctly invoke this API,
2852 * hence it is not registered in the hostapd_private_args. This
2853 * API can only be invoked by directly invoking the ioctl() system
2854 * call.
2855 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002856
Jeff Johnson224f3702014-03-26 11:09:47 -07002857 /* make sure userspace allocated a reasonable buffer size */
2858 if (wrqu->data.length < sizeof(maclist_index)) {
2859 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2860 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002862
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302863 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2864 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2865 if(pSapCtx == NULL){
2866 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2867 FL("psapCtx is NULL"));
2868 return -EFAULT;
2869 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302870
2871 /* allocate local buffer to build the response */
2872 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2873 if (!buf) {
2874 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2875 return -ENOMEM;
2876 }
2877
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302878 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002879 /* start indexing beyond where the record count will be written */
2880 maclist_index = sizeof(maclist_index);
2881 left = wrqu->data.length - maclist_index;
2882
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302883 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002884 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2885 if ((pStaInfo[cnt].isUsed) &&
2886 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2887 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2888 VOS_MAC_ADDR_SIZE);
2889 maclist_index += VOS_MAC_ADDR_SIZE;
2890 left -= VOS_MAC_ADDR_SIZE;
2891 }
2892 cnt++;
2893 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302894 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002895
2896 *((u32 *)buf) = maclist_index;
2897 wrqu->data.length = maclist_index;
2898 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2899 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2900 ret = -EFAULT;
2901 }
2902 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302903
2904 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002905 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002906}
2907
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302908int
2909static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
2912{
2913 int ret;
2914
2915 vos_ssr_protect(__func__);
2916 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2917 vos_ssr_unprotect(__func__);
2918
2919 return ret;
2920}
2921
Jeff Johnson295189b2012-06-20 16:38:30 -07002922/* Usage:
2923 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2924 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2925 while using this ioctl
2926
2927 Syntax:
2928 iwpriv softap.0 disassoc_sta <6 octet mac address>
2929
2930 e.g.
2931 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2932 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2933*/
2934
2935int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302936static __iw_softap_disassoc_sta(struct net_device *dev,
2937 struct iw_request_info *info,
2938 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002939{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302940 hdd_adapter_t *pHostapdAdapter;
2941 hdd_context_t *pHddCtx;
2942 v_U8_t *peerMacAddr;
2943 int ret = 0;
2944
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302946
2947 if (!capable(CAP_NET_ADMIN)) {
2948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2949 FL("permission check failed"));
2950 return -EPERM;
2951 }
2952
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302953 pHostapdAdapter = (netdev_priv(dev));
2954 if (NULL == pHostapdAdapter)
2955 {
2956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2957 "%s: Adapter is NULL",__func__);
2958 return -EINVAL;
2959 }
2960 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2961 ret = wlan_hdd_validate_context(pHddCtx);
2962 if (0 != ret)
2963 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302964 return ret;
2965 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302966 /* iwpriv tool or framework calls this ioctl with
2967 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302969 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
Arif Hussain24bafea2013-11-15 15:10:03 -08002971 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2972 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2974 EXIT();
2975 return 0;
2976}
2977
2978int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302979static iw_softap_disassoc_sta(struct net_device *dev,
2980 struct iw_request_info *info,
2981 union iwreq_data *wrqu, char *extra)
2982{
2983 int ret;
2984
2985 vos_ssr_protect(__func__);
2986 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2987 vos_ssr_unprotect(__func__);
2988
2989 return ret;
2990}
2991
2992int
2993static __iw_softap_ap_stats(struct net_device *dev,
2994 struct iw_request_info *info,
2995 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002996{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302997 hdd_adapter_t *pHostapdAdapter;
2998 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 WLANTL_TRANSFER_STA_TYPE statBuffer;
3000 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303001 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003002
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303003 ENTER();
3004
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303005 pHostapdAdapter = (netdev_priv(dev));
3006 if (NULL == pHostapdAdapter)
3007 {
3008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3009 "%s: Adapter is NULL",__func__);
3010 return -EINVAL;
3011 }
3012 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3013 ret = wlan_hdd_validate_context(pHddCtx);
3014 if (0 != ret)
3015 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303016 return ret;
3017 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003018 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003019 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3020 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003021
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303022 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003023 if(NULL == pstatbuf) {
3024 hddLog(LOG1, "unable to allocate memory");
3025 return -ENOMEM;
3026 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303027
3028 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003029 "RUF=%d RMF=%d RBF=%d "
3030 "RUB=%d RMB=%d RBB=%d "
3031 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303032 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003033 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3034 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3035 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3036 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3037 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3038 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003039
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303040 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003041 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3042 kfree(pstatbuf);
3043 return -EFAULT;
3044 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303045
3046 strlcpy(extra, pstatbuf, len);
3047 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003048 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303049
3050 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 return 0;
3052}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303053int
3054static __iw_softap_ap_get_stats(struct net_device *dev,
3055 struct iw_request_info *info,
3056 union iwreq_data *wrqu, char *extra)
3057{
3058 hdd_adapter_t *pAdapter;
3059 hdd_tx_rx_stats_t *pStats;
3060
3061 ENTER();
3062 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3063 if (NULL == pAdapter)
3064 {
3065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: Adapter is NULL",__func__);
3067 return -EINVAL;
3068 }
3069
3070 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3071 snprintf(extra, QCSAP_MAX_STR_LEN,
3072 "\nTransmit"
3073 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3074 "\n dropped BK %u, BE %u, VI %u, VO %u"
3075 "\n classified BK %u, BE %u, VI %u, VO %u"
3076 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3077 "\n queued BK %u, BE %u, VI %u, VO %u"
3078 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3079 "\ndequeued %u, depressured %u, deque-depressured %u,\
3080 completed %u, flushed %u"
3081 "\n fetched BK %u, BE %u, VI %u, VO %u"
3082 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3083 "\n depressured BK %u, BE %u, VI %u, VO %u"
3084 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3085 "\n flushed BK %u, BE %u, VI %u, VO %u"
3086 "\n\nReceive"
3087 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3088 "\n\nResetsStats"
3089 "\n",
3090 pStats->txXmitCalled,
3091 pStats->txXmitDropped,
3092 pStats->txXmitBackPressured,
3093 pStats->txXmitQueued,
3094
3095 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3096 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3097 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3098 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3099
3100 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3101 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3102 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3103 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3104
3105 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3106 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3107 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3108 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3109
3110 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3111 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3112 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3113 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3114
3115 pStats->txFetched,
3116 pStats->txFetchEmpty,
3117 pStats->txFetchLowResources,
3118 pStats->txFetchDequeueError,
3119
3120 pStats->txFetchDequeued,
3121 pStats->txFetchDePressured,
3122 pStats->txDequeDePressured,
3123 pStats->txCompleted,
3124 pStats->txFlushed,
3125
3126 pStats->txFetchedAC[WLANTL_AC_BK],
3127 pStats->txFetchedAC[WLANTL_AC_BE],
3128 pStats->txFetchedAC[WLANTL_AC_VI],
3129 pStats->txFetchedAC[WLANTL_AC_VO],
3130
3131 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3132 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3133 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3134 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3135
3136 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3137 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3138 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3139 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3140
3141 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3142 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3143 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3144 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3145
3146 pStats->txFlushedAC[WLANTL_AC_BK],
3147 pStats->txFlushedAC[WLANTL_AC_BE],
3148 pStats->txFlushedAC[WLANTL_AC_VI],
3149 pStats->txFlushedAC[WLANTL_AC_VO],
3150
3151 pStats->rxChains,
3152 pStats->rxPackets,
3153 pStats->rxDropped,
3154 pStats->rxDelivered,
3155 pStats->rxRefused
3156 );
3157
3158 wrqu->data.length = strlen(extra) + 1;
3159
3160 return 0;
3161}
3162
3163int
3164static __iw_softap_ap_clear_stats(struct net_device *dev,
3165 struct iw_request_info *info,
3166 union iwreq_data *wrqu, char *extra)
3167{
3168 hdd_adapter_t *pAdapter;
3169
3170 ENTER();
3171
3172 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3173 if (NULL == pAdapter)
3174 {
3175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3176 "%s: Adapter is NULL",__func__);
3177 return -EINVAL;
3178 }
3179
3180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3181 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3182 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3183 return 0;
3184}
3185
3186
3187int
3188static iw_softap_get_stats(struct net_device *dev,
3189 struct iw_request_info *info,
3190 union iwreq_data *wrqu, char *extra)
3191{
3192 int ret;
3193 vos_ssr_protect(__func__);
3194 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3195 vos_ssr_unprotect(__func__);
3196 return ret;
3197}
3198
3199int
3200static iw_softap_clear_stats(struct net_device *dev,
3201 struct iw_request_info *info,
3202 union iwreq_data *wrqu, char *extra)
3203{
3204 int ret;
3205 vos_ssr_protect(__func__);
3206 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3207 vos_ssr_unprotect(__func__);
3208 return ret;
3209}
Jeff Johnson295189b2012-06-20 16:38:30 -07003210
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303211int
3212static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 struct iw_request_info *info,
3214 union iwreq_data *wrqu, char *extra)
3215{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303216 int ret;
3217
3218 vos_ssr_protect(__func__);
3219 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3220 vos_ssr_unprotect(__func__);
3221
3222 return ret;
3223}
3224
3225static int __iw_softap_set_channel_range(struct net_device *dev,
3226 struct iw_request_info *info,
3227 union iwreq_data *wrqu, char *extra)
3228{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303229 hdd_adapter_t *pHostapdAdapter;
3230 tHalHandle hHal;
3231 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 int *value = (int *)extra;
3233 int startChannel = value[0];
3234 int endChannel = value[1];
3235 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003236 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 int ret = 0; /* success */
3238
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303239 ENTER();
3240
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303241 if (!capable(CAP_NET_ADMIN))
3242 {
3243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3244 FL("permission check failed"));
3245 return -EPERM;
3246 }
3247
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303248 pHostapdAdapter = (netdev_priv(dev));
3249 if (NULL == pHostapdAdapter)
3250 {
3251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3252 "%s: Adapter is NULL",__func__);
3253 return -EINVAL;
3254 }
3255 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3256 ret = wlan_hdd_validate_context(pHddCtx);
3257 if (0 != ret)
3258 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303259 return ret;
3260 }
3261 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3262 if (NULL == hHal)
3263 {
3264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3265 "%s: Hal Context is NULL",__func__);
3266 return -EINVAL;
3267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3269 if(status != VOS_STATUS_SUCCESS)
3270 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003271 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 startChannel,endChannel, band);
3273 ret = -EINVAL;
3274 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003275
3276 pHddCtx->is_dynamic_channel_range_set = 1;
3277
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303278 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 return ret;
3280}
3281
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303282static int iw_softap_set_channel_range(struct net_device *dev,
3283 struct iw_request_info *info,
3284 union iwreq_data *wrqu, char *extra)
3285{
3286 int ret;
3287
3288 vos_ssr_protect(__func__);
3289 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3290 vos_ssr_unprotect(__func__);
3291
3292 return ret;
3293}
3294
3295
3296int __iw_softap_get_channel_list(struct net_device *dev,
3297 struct iw_request_info *info,
3298 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003299{
3300 v_U32_t num_channels = 0;
3301 v_U8_t i = 0;
3302 v_U8_t bandStartChannel = RF_CHAN_1;
3303 v_U8_t bandEndChannel = RF_CHAN_165;
3304 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303305 hdd_adapter_t *pHostapdAdapter;
3306 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003309 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303310 hdd_context_t *pHddCtx;
3311 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303312
3313 ENTER();
3314
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303315 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3316 if (NULL == pHostapdAdapter)
3317 {
3318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3319 "%s: Adapter is NULL",__func__);
3320 return -EINVAL;
3321 }
3322 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3323 ret = wlan_hdd_validate_context(pHddCtx);
3324 if (0 != ret)
3325 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303326 return ret;
3327 }
3328 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3329 if (NULL == hHal)
3330 {
3331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3332 "%s: Hal Context is NULL",__func__);
3333 return -EINVAL;
3334 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003335 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003337 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003338 return -EIO;
3339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 wrqu->data.length = sizeof(tChannelListInfo);
3341 ENTER();
3342
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003343 if (eCSR_BAND_24 == curBand)
3344 {
3345 bandStartChannel = RF_CHAN_1;
3346 bandEndChannel = RF_CHAN_14;
3347 }
3348 else if (eCSR_BAND_5G == curBand)
3349 {
3350 bandStartChannel = RF_CHAN_36;
3351 bandEndChannel = RF_CHAN_165;
3352 }
3353
Arif Hussain6d2a3322013-11-17 19:50:10 -08003354 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303355 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003356 bandStartChannel, bandEndChannel );
3357
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3359 {
3360 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3361 {
3362 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3363 num_channels++;
3364 }
3365 }
3366
3367 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3368
3369 temp_num_channels = num_channels;
3370
3371 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3372 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303373 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003374 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 }
3376
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303377 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3378 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 {
3380 for(i = 0; i < temp_num_channels; i++)
3381 {
3382
3383 if((channel_list->channels[i] > 35) &&
3384 (channel_list->channels[i] < 49))
3385 {
3386 vos_mem_move(&channel_list->channels[i],
3387 &channel_list->channels[i+1],
3388 temp_num_channels - (i-1));
3389 num_channels--;
3390 temp_num_channels--;
3391 i--;
3392 }
3393 }
3394 }
3395
Arif Hussain6d2a3322013-11-17 19:50:10 -08003396 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 channel_list->num_channels = num_channels;
3399 EXIT();
3400
3401 return 0;
3402}
3403
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303404int iw_softap_get_channel_list(struct net_device *dev,
3405 struct iw_request_info *info,
3406 union iwreq_data *wrqu, char *extra)
3407{
3408 int ret;
3409
3410 vos_ssr_protect(__func__);
3411 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3412 vos_ssr_unprotect(__func__);
3413
3414 return ret;
3415}
3416
3417static
3418int __iw_get_genie(struct net_device *dev,
3419 struct iw_request_info *info,
3420 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003421{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303422 hdd_adapter_t *pHostapdAdapter;
3423 hdd_context_t *pHddCtx;
3424 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303425 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3427 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303428 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303429
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303431
3432 pHostapdAdapter = (netdev_priv(dev));
3433 if (NULL == pHostapdAdapter)
3434 {
3435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3436 "%s: Adapter is NULL",__func__);
3437 return -EINVAL;
3438 }
3439 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3440 ret = wlan_hdd_validate_context(pHddCtx);
3441 if (0 != ret)
3442 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303443 return ret;
3444 }
3445 pVosContext = pHddCtx->pvosContext;
3446 if (NULL == pVosContext)
3447 {
3448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3449 "%s: vos context is not valid ",__func__);
3450 return -EINVAL;
3451 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003452 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3454 status = WLANSap_getstationIE_information(pVosContext,
3455 &length,
3456 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303457
3458 if (VOS_STATUS_SUCCESS != status) {
3459 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003460 return -EFAULT;
3461 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303462
Arif Hussained667642013-10-27 23:01:14 -07003463 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303464 if (length > DOT11F_IE_RSN_MAX_LEN) {
3465 hddLog(LOGE,
3466 FL("invalid buffer length length:%d"), length);
3467 return -E2BIG;
3468 }
3469
3470 vos_mem_copy(extra, genIeBytes, length);
3471
3472 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3473
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 EXIT();
3475 return 0;
3476}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303477
3478static
3479int iw_get_genie(struct net_device *dev,
3480 struct iw_request_info *info,
3481 union iwreq_data *wrqu, char *extra)
3482{
3483 int ret;
3484
3485 vos_ssr_protect(__func__);
3486 ret = __iw_get_genie(dev, info, wrqu, extra);
3487 vos_ssr_unprotect(__func__);
3488
3489 return ret;
3490}
3491
3492static
3493int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3494 struct iw_request_info *info,
3495 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003496{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303497 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003498 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303499 hdd_ap_ctx_t *pHddApCtx;
3500 hdd_context_t *pHddCtx;
3501 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303502
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003504
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303505 pHostapdAdapter = (netdev_priv(dev));
3506 if (NULL == pHostapdAdapter)
3507 {
3508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3509 "%s: Adapter is NULL",__func__);
3510 return -EINVAL;
3511 }
3512 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3513 ret = wlan_hdd_validate_context(pHddCtx);
3514 if (0 != ret)
3515 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303516 return ret;
3517 }
3518 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3519 if (NULL == pHddApCtx)
3520 {
3521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3522 "%s: AP context is NULL",__func__);
3523 return -EINVAL;
3524 }
3525
Arif Hussain6d2a3322013-11-17 19:50:10 -08003526 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003527 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3528
3529 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3530 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3531 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3532 WPSPBCProbeReqIEs.probeReqIELen);
3533 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3534 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3535 sizeof(v_MACADDR_t));
3536 if (copy_to_user(wrqu->data.pointer,
3537 (void *)&WPSPBCProbeReqIEs,
3538 sizeof(WPSPBCProbeReqIEs)))
3539 {
3540 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3541 return -EFAULT;
3542 }
3543 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003544 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003545 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 up(&pHddApCtx->semWpsPBCOverlapInd);
3547 EXIT();
3548 return 0;
3549}
3550
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303551static
3552int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3553 struct iw_request_info *info,
3554 union iwreq_data *wrqu, char *extra)
3555{
3556 int ret;
3557
3558 vos_ssr_protect(__func__);
3559 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3560 vos_ssr_unprotect(__func__);
3561
3562 return ret;
3563}
3564
Jeff Johnson295189b2012-06-20 16:38:30 -07003565/**---------------------------------------------------------------------------
3566
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303567 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 This function sets the auth type received from the wpa_supplicant.
3569
3570 \param - dev - Pointer to the net device.
3571 - info - Pointer to the iw_request_info.
3572 - wrqu - Pointer to the iwreq_data.
3573 - extra - Pointer to the data.
3574 \return - 0 for success, non zero for failure
3575
3576 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303577int __iw_set_auth_hostap(struct net_device *dev,
3578 struct iw_request_info *info,
3579 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003580{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303581 hdd_adapter_t *pAdapter;
3582 hdd_context_t *pHddCtx;
3583 hdd_wext_state_t *pWextState;
3584 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303587
3588 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3589 if (NULL == pAdapter)
3590 {
3591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3592 "%s: Adapter is NULL",__func__);
3593 return -EINVAL;
3594 }
3595
3596 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3597 ret = wlan_hdd_validate_context(pHddCtx);
3598 if (0 != ret)
3599 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303600 return ret;
3601 }
3602 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3603 if (NULL == pWextState)
3604 {
3605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3606 "%s: pWextState is NULL",__func__);
3607 return -EINVAL;
3608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 switch(wrqu->param.flags & IW_AUTH_INDEX)
3610 {
3611 case IW_AUTH_TKIP_COUNTERMEASURES:
3612 {
3613 if(wrqu->param.value) {
3614 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3615 "Counter Measure started %d", wrqu->param.value);
3616 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303617 }
3618 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3620 "Counter Measure stopped=%d", wrqu->param.value);
3621 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3622 }
3623
3624 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3625 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303628
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303630
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003631 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 wrqu->param.flags & IW_AUTH_INDEX);
3633 break;
3634 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303635
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 EXIT();
3637 return 0;
3638}
3639
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303640int iw_set_auth_hostap(struct net_device *dev,
3641 struct iw_request_info *info,
3642 union iwreq_data *wrqu,char *extra)
3643{
3644 int ret;
3645
3646 vos_ssr_protect(__func__);
3647 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3648 vos_ssr_unprotect(__func__);
3649
3650 return ret;
3651}
3652
3653static int __iw_set_ap_encodeext(struct net_device *dev,
3654 struct iw_request_info *info,
3655 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003656{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303657 hdd_adapter_t *pHostapdAdapter;
3658 v_CONTEXT_t pVosContext;
3659 hdd_context_t *pHddCtx;
3660 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003661 int retval = 0;
3662 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3664 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3665 int key_index;
3666 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303667 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003668// tCsrRoamRemoveKey RemoveKey;
3669 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303670
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303671 ENTER();
3672 pHostapdAdapter = (netdev_priv(dev));
3673 if (NULL == pHostapdAdapter)
3674 {
3675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3676 "%s: Adapter is NULL",__func__);
3677 return -EINVAL;
3678 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003679
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303680 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3681 retval = wlan_hdd_validate_context(pHddCtx);
3682 if (0 != retval)
3683 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303684 return retval;
3685 }
3686 pVosContext = pHddCtx->pvosContext;
3687 if (NULL == pVosContext)
3688 {
3689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3690 "%s: pVosContext is NULL",__func__);
3691 return -EINVAL;
3692 }
3693 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3694 if (NULL == pHddApCtx)
3695 {
3696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3697 "%s: AP Context is NULL",__func__);
3698 return -EINVAL;
3699 }
3700
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303702
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303704
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 /*Convert from 1-based to 0-based keying*/
3706 key_index--;
3707 }
3708 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303709#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 /*Set the encrytion type to NONE*/
3711#if 0
3712 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3713#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303714
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 RemoveKey.keyId = key_index;
3716 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3717 /*Key direction for group is RX only*/
3718 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3719 }
3720 else {
3721 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3722 }
3723 switch(ext->alg)
3724 {
3725 case IW_ENCODE_ALG_NONE:
3726 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3727 break;
3728 case IW_ENCODE_ALG_WEP:
3729 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3730 break;
3731 case IW_ENCODE_ALG_TKIP:
3732 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003733 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 case IW_ENCODE_ALG_CCMP:
3735 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3736 break;
3737 default:
3738 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3739 break;
3740 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003741 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 -07003742 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003744 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003746 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3747 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 {
3749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003750 __LINE__, vstatus );
3751 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003753#endif
3754 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003755
Jeff Johnson43971f52012-07-17 12:26:56 -07003756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003757
3758 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3759
3760 setKey.keyId = key_index;
3761 setKey.keyLength = ext->key_len;
3762
3763 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3764 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3765 }
3766
3767 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3768 /*Key direction for group is RX only*/
3769 setKey.keyDirection = eSIR_RX_ONLY;
3770 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3771 }
3772 else {
3773
3774 setKey.keyDirection = eSIR_TX_RX;
3775 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3776 }
3777 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3778 {
3779 setKey.keyDirection = eSIR_TX_DEFAULT;
3780 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3781 }
3782
3783 /*For supplicant pae role is zero*/
3784 setKey.paeRole = 0;
3785
3786 switch(ext->alg)
3787 {
3788 case IW_ENCODE_ALG_NONE:
3789 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3790 break;
3791
3792 case IW_ENCODE_ALG_WEP:
3793 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3794 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003795 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 break;
3797
3798 case IW_ENCODE_ALG_TKIP:
3799 {
3800 v_U8_t *pKey = &setKey.Key[0];
3801
3802 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3803
3804 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3805
3806 /*Supplicant sends the 32bytes key in this order
3807
3808 |--------------|----------|----------|
3809 | Tk1 |TX-MIC | RX Mic |
3810 |--------------|----------|----------|
3811 <---16bytes---><--8bytes--><--8bytes-->
3812
3813 */
3814 /*Sme expects the 32 bytes key to be in the below order
3815
3816 |--------------|----------|----------|
3817 | Tk1 |RX-MIC | TX Mic |
3818 |--------------|----------|----------|
3819 <---16bytes---><--8bytes--><--8bytes-->
3820 */
3821 /* Copy the Temporal Key 1 (TK1) */
3822 vos_mem_copy(pKey,ext->key,16);
3823
3824 /*Copy the rx mic first*/
3825 vos_mem_copy(&pKey[16],&ext->key[24],8);
3826
3827 /*Copy the tx mic */
3828 vos_mem_copy(&pKey[24],&ext->key[16],8);
3829
3830 }
3831 break;
3832
3833 case IW_ENCODE_ALG_CCMP:
3834 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3835 break;
3836
3837 default:
3838 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3839 break;
3840 }
3841
3842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303843 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 setKey.keyId);
3845 for(i=0; i< ext->key_len; i++)
3846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3847 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003848
3849 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3850 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 {
3852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003853 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3854 retval = -EINVAL;
3855 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303856
3857 EXIT();
3858 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003859}
Jeff Johnson43971f52012-07-17 12:26:56 -07003860
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303861static int iw_set_ap_encodeext(struct net_device *dev,
3862 struct iw_request_info *info,
3863 union iwreq_data *wrqu, char *extra)
3864{
3865 int ret;
3866
3867 vos_ssr_protect(__func__);
3868 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3869 vos_ssr_unprotect(__func__);
3870
3871 return ret;
3872}
Jeff Johnson43971f52012-07-17 12:26:56 -07003873
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303874static int __iw_set_ap_mlme(struct net_device *dev,
3875 struct iw_request_info *info,
3876 union iwreq_data *wrqu,
3877 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003878{
3879#if 0
3880 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3881 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3882
3883 ENTER();
3884
3885 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3886 switch (mlme->cmd) {
3887 case IW_MLME_DISASSOC:
3888 case IW_MLME_DEAUTH:
3889 hddLog(LOG1, "Station disassociate");
3890 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3891 {
3892 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3893
3894 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3895 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3896
3897 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3898
3899 //clear all the reason codes
3900 if (status != 0)
3901 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003902 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 }
3904
3905 netif_stop_queue(dev);
3906 netif_carrier_off(dev);
3907 }
3908 else
3909 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003910 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 -07003911 }
3912 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 return -EINVAL;
3915 }//end of switch
3916 EXIT();
3917#endif
3918 return 0;
3919// return status;
3920}
3921
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303922static int iw_set_ap_mlme(struct net_device *dev,
3923 struct iw_request_info *info,
3924 union iwreq_data *wrqu,
3925 char *extra)
3926{
3927 int ret;
3928
3929 vos_ssr_protect(__func__);
3930 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3931 vos_ssr_unprotect(__func__);
3932
3933 return ret;
3934}
3935
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303936static int __iw_get_ap_rts_threshold(struct net_device *dev,
3937 struct iw_request_info *info,
3938 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003939{
3940 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3941 v_U32_t status = 0;
3942
3943 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3944
3945 return status;
3946}
3947
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303948static int iw_get_ap_rts_threshold(struct net_device *dev,
3949 struct iw_request_info *info,
3950 union iwreq_data *wrqu, char *extra)
3951{
3952 int ret;
3953
3954 vos_ssr_protect(__func__);
3955 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3956 vos_ssr_unprotect(__func__);
3957
3958 return ret;
3959}
3960
3961static int __iw_get_ap_frag_threshold(struct net_device *dev,
3962 struct iw_request_info *info,
3963 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003964{
3965 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3966 v_U32_t status = 0;
3967
3968 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3969
3970 return status;
3971}
3972
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303973static int iw_get_ap_frag_threshold(struct net_device *dev,
3974 struct iw_request_info *info,
3975 union iwreq_data *wrqu, char *extra)
3976{
3977 int ret;
3978
3979 vos_ssr_protect(__func__);
3980 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3981 vos_ssr_unprotect(__func__);
3982
3983 return ret;
3984}
3985
3986static int __iw_get_ap_freq(struct net_device *dev,
3987 struct iw_request_info *info,
3988 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003989{
Jeff Johnsone7245742012-09-05 17:12:55 -07003990 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303991 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 tHalHandle hHal;
3993 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303994 hdd_ap_ctx_t *pHddApCtx;
3995 hdd_context_t *pHddCtx;
3996 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003997
3998 ENTER();
3999
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304000 pHostapdAdapter = (netdev_priv(dev));
4001 if (NULL == pHostapdAdapter)
4002 {
4003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4004 "%s: Adapter is NULL",__func__);
4005 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304007 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4008 ret = wlan_hdd_validate_context(pHddCtx);
4009 if (0 != ret)
4010 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304011 return ret;
4012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304014 if (NULL == pHostapdState)
4015 {
4016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4017 "%s: pHostapdState is NULL",__func__);
4018 return -EINVAL;
4019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304021 if (NULL == hHal)
4022 {
4023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4024 "%s: Hal Context is NULL",__func__);
4025 return -EINVAL;
4026 }
4027 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4028 if (NULL == pHddApCtx)
4029 {
4030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4031 "%s: AP context is NULL",__func__);
4032 return -EINVAL;
4033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 if(pHostapdState->bssState == BSS_STOP )
4035 {
4036 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4037 != eHAL_STATUS_SUCCESS)
4038 {
c_hpothuffdb5272013-10-02 16:42:35 +05304039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4040 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 return -EIO;
4042 }
4043 else
4044 {
4045 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004046 if( TRUE == status)
4047 {
4048 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4049 * iwlist & iwconfig command shows frequency into proper
4050 * format (2.412 GHz instead of 246.2 MHz)*/
4051 fwrq->m = freq;
4052 fwrq->e = MHZ;
4053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 }
4055 }
4056 else
4057 {
4058 channel = pHddApCtx->operatingChannel;
4059 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004060 if( TRUE == status)
4061 {
4062 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4063 * iwlist & iwconfig command shows frequency into proper
4064 * format (2.412 GHz instead of 246.2 MHz)*/
4065 fwrq->m = freq;
4066 fwrq->e = MHZ;
4067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304069
4070 EXIT();
4071 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004072}
4073
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304074static int iw_get_ap_freq(struct net_device *dev,
4075 struct iw_request_info *info,
4076 struct iw_freq *fwrq, char *extra)
4077{
4078 int ret;
4079
4080 vos_ssr_protect(__func__);
4081 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4082 vos_ssr_unprotect(__func__);
4083
4084 return ret;
4085}
4086
4087static int __iw_get_mode(struct net_device *dev,
4088 struct iw_request_info *info,
4089 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304090{
4091 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304092 hdd_adapter_t *pAdapter;
4093 hdd_context_t *pHddCtx;
4094
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304095 ENTER();
4096
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304097 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4098 if (NULL == pAdapter)
4099 {
4100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4101 "%s: Adapter is NULL",__func__);
4102 return -EINVAL;
4103 }
4104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4105 status = wlan_hdd_validate_context(pHddCtx);
4106 if (0 != status)
4107 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304108 return status;
4109 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304110
4111 wrqu->mode = IW_MODE_MASTER;
4112
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304113 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304114 return status;
4115}
4116
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304117static int iw_get_mode(struct net_device *dev,
4118 struct iw_request_info *info,
4119 union iwreq_data *wrqu, char *extra)
4120{
4121 int ret;
4122
4123 vos_ssr_protect(__func__);
4124 ret = __iw_get_mode(dev, info, wrqu, extra);
4125 vos_ssr_unprotect(__func__);
4126
4127 return ret;
4128}
4129
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304130
4131static int __iw_softap_stopbss(struct net_device *dev,
4132 struct iw_request_info *info,
4133 union iwreq_data *wrqu,
4134 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004135{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304136 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304138 hdd_context_t *pHddCtx = NULL;
4139
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304141 pHostapdAdapter = (netdev_priv(dev));
4142 if (NULL == pHostapdAdapter)
4143 {
4144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4145 "%s: Adapter is NULL",__func__);
4146 return -EINVAL;
4147 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304148 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4149 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304150 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304151 return status;
4152 }
4153
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304154 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 {
4156 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4157 {
4158 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4159
4160 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304161
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304163 {
4164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004165 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 VOS_ASSERT(0);
4167 }
4168 }
4169 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304170 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 }
4172 EXIT();
4173 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4174}
4175
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304176static int iw_softap_stopbss(struct net_device *dev,
4177 struct iw_request_info *info,
4178 union iwreq_data *wrqu,
4179 char *extra)
4180{
4181 int ret;
4182
4183 vos_ssr_protect(__func__);
4184 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4185 vos_ssr_unprotect(__func__);
4186
4187 return ret;
4188}
4189
4190static int __iw_softap_version(struct net_device *dev,
4191 struct iw_request_info *info,
4192 union iwreq_data *wrqu,
4193 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004194{
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304196 hdd_context_t *pHddCtx;
4197 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304198
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304200 pHostapdAdapter = (netdev_priv(dev));
4201 if (NULL == pHostapdAdapter)
4202 {
4203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4204 "%s: Adapter is NULL",__func__);
4205 return -EINVAL;
4206 }
4207 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4208 ret = wlan_hdd_validate_context(pHddCtx);
4209 if (0 != ret)
4210 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304211 return ret;
4212 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004213 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 return 0;
4216}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004217
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304218static int iw_softap_version(struct net_device *dev,
4219 struct iw_request_info *info,
4220 union iwreq_data *wrqu,
4221 char *extra)
4222{
4223 int ret;
4224
4225 vos_ssr_protect(__func__);
4226 ret = __iw_softap_version(dev, info, wrqu, extra);
4227 vos_ssr_unprotect(__func__);
4228
4229 return ret;
4230}
4231
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304232int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004233{
4234 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004235 int len = 0;
4236 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304237 v_CONTEXT_t pVosContext;
4238 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304239 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304241 ENTER();
4242
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304243 if (NULL == pAdapter)
4244 {
4245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4246 "%s: Adapter is NULL",__func__);
4247 return -EINVAL;
4248 }
4249 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4250 if (0 != wlan_hdd_validate_context(pHddCtx))
4251 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304252 return VOS_STATUS_E_FAULT;
4253 }
4254 pVosContext = pHddCtx->pvosContext;
4255 if (NULL == pVosContext)
4256 {
4257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4258 "%s: VOS context is not valid",__func__);
4259 return VOS_STATUS_E_FAULT;
4260 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304261 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304262 if(pSapCtx == NULL)
4263 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304264 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4265 FL("psapCtx is NULL"));
4266 return VOS_STATUS_E_FAULT;
4267 }
4268
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304269 len = snprintf(pBuf, buf_len, sta_info_header);
4270 if (len >= buf_len) {
4271 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4272 return -E2BIG;
4273 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004274 pBuf += len;
4275 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004276
4277 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4278 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304279 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004280 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004281 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304282 pSapCtx->aStaInfo[i].ucSTAId,
4283 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4284 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4285 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4286 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4287 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4288 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304289 if (len >= buf_len) {
4290 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4291 return -E2BIG;
4292 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004293 pBuf += len;
4294 buf_len -= len;
4295 }
4296 if(WE_GET_STA_INFO_SIZE > buf_len)
4297 {
4298 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004299 }
4300 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304301 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304302 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004303}
4304
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304305static int __iw_softap_get_sta_info(struct net_device *dev,
4306 struct iw_request_info *info,
4307 union iwreq_data *wrqu,
4308 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004309{
4310 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304311 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004312 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304313 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4314 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004315 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304316 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004317 }
4318 wrqu->data.length = strlen(extra);
4319 EXIT();
4320 return 0;
4321}
4322
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304323static int iw_softap_get_sta_info(struct net_device *dev,
4324 struct iw_request_info *info,
4325 union iwreq_data *wrqu,
4326 char *extra)
4327{
4328 int ret;
4329
4330 vos_ssr_protect(__func__);
4331 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4332 vos_ssr_unprotect(__func__);
4333
4334 return ret;
4335}
4336
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304337static int __iw_set_ap_genie(struct net_device *dev,
4338 struct iw_request_info *info,
4339 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004340{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304341
4342 hdd_adapter_t *pHostapdAdapter;
4343 hdd_context_t *pHddCtx;
4344 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004346 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304347 int ret = 0;
4348
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304350 pHostapdAdapter = (netdev_priv(dev));
4351 if (NULL == pHostapdAdapter)
4352 {
4353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4354 "%s: Adapter is NULL",__func__);
4355 return -EINVAL;
4356 }
4357 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4358 ret = wlan_hdd_validate_context(pHddCtx);
4359 if (0 != ret)
4360 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304361 return ret;
4362 }
4363 pVosContext = pHddCtx->pvosContext;
4364 if (NULL == pVosContext)
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4367 "%s: VOS Context is NULL",__func__);
4368 return -EINVAL;
4369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 if(!wrqu->data.length)
4371 {
4372 EXIT();
4373 return 0;
4374 }
Arif Hussained667642013-10-27 23:01:14 -07004375
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304376 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304378 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 case DOT11F_EID_RSN:
4380 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4381 {
4382 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4383 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004386 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304388
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004390 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 halStatus = 0;
4392 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304393
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304395 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004396}
4397
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304398static int iw_set_ap_genie(struct net_device *dev,
4399 struct iw_request_info *info,
4400 union iwreq_data *wrqu, char *extra)
4401{
4402 int ret;
4403
4404 vos_ssr_protect(__func__);
4405 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4406 vos_ssr_unprotect(__func__);
4407
4408 return ret;
4409}
4410
Jeff Johnson295189b2012-06-20 16:38:30 -07004411static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4412{
4413 eHalStatus hstatus;
4414 long lrc;
4415 struct statsContext context;
4416
4417 if (NULL == pAdapter)
4418 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304419 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 return VOS_STATUS_E_FAULT;
4421 }
4422
4423 init_completion(&context.completion);
4424 context.pAdapter = pAdapter;
4425 context.magic = STATS_CONTEXT_MAGIC;
4426 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4427 eCSR_HDD,
4428 SME_GLOBAL_CLASSA_STATS,
4429 hdd_GetClassA_statisticsCB,
4430 0, // not periodic
4431 FALSE, //non-cached results
4432 staid,
4433 &context);
4434 if (eHAL_STATUS_SUCCESS != hstatus)
4435 {
4436 hddLog(VOS_TRACE_LEVEL_ERROR,
4437 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004438 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 }
4440 else
4441 {
4442 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4443 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 if (lrc <= 0)
4445 {
4446 hddLog(VOS_TRACE_LEVEL_ERROR,
4447 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004448 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 }
4450 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004451
4452 /* either we never sent a request, we sent a request and received a
4453 response or we sent a request and timed out. if we never sent a
4454 request or if we sent a request and got a response, we want to
4455 clear the magic out of paranoia. if we timed out there is a
4456 race condition such that the callback function could be
4457 executing at the same time we are. of primary concern is if the
4458 callback function had already verified the "magic" but had not
4459 yet set the completion variable when a timeout occurred. we
4460 serialize these activities by invalidating the magic while
4461 holding a shared spinlock which will cause us to block if the
4462 callback is currently executing */
4463 spin_lock(&hdd_context_lock);
4464 context.magic = 0;
4465 spin_unlock(&hdd_context_lock);
4466
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 return VOS_STATUS_SUCCESS;
4468}
4469
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304470int __iw_get_softap_linkspeed(struct net_device *dev,
4471 struct iw_request_info *info,
4472 union iwreq_data *wrqu,
4473 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004474
4475{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304476 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304477 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004479 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304480 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304482 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004484 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304485 int rc, valid;
4486
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304487 ENTER();
4488
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304489 pHostapdAdapter = (netdev_priv(dev));
4490 if (NULL == pHostapdAdapter)
4491 {
4492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4493 "%s: Adapter is NULL",__func__);
4494 return -EINVAL;
4495 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304496 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304497 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304498 if (0 != valid)
4499 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304500 return valid;
4501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004502
Arif Hussain6d2a3322013-11-17 19:50:10 -08004503 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004504
4505 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004506 {
Arif Hussaina9571842014-01-15 16:43:41 -08004507 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4508 if (NULL == pmacAddress) {
4509 hddLog(LOG1, "unable to allocate memory");
4510 return -ENOMEM;
4511 }
4512 if (copy_from_user((void *)pmacAddress,
4513 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4514 {
4515 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4516 kfree(pmacAddress);
4517 return -EFAULT;
4518 }
Manjeet Singha3739742016-05-03 16:21:46 +05304519 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004520
4521 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004522 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004523
4524 if (!VOS_IS_STATUS_SUCCESS(status ))
4525 {
4526 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4527 }
Arif Hussained667642013-10-27 23:01:14 -07004528 }
Kiet Lam61589852013-09-19 17:10:58 +05304529 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304530 * link speed for first connected client will be returned.
4531 */
Arif Hussaina9571842014-01-15 16:43:41 -08004532 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304533 {
4534 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4535 }
4536 else
4537 {
4538 status = hdd_softap_GetStaId(pHostapdAdapter,
4539 (v_MACADDR_t *)macAddress, (void *)(&staId));
4540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004541
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304542 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304544 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 link_speed = 0;
4546 }
4547 else
4548 {
4549 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 if (!VOS_IS_STATUS_SUCCESS(status ))
4552 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304553 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 return -EINVAL;
4555 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304556
4557 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4558 staId, &link_speed);
4559
4560 link_speed = link_speed / 10;
4561
4562 if (0 == link_speed)
4563 {
4564 /* The linkspeed returned by HAL is in units of 500kbps.
4565 * converting it to mbps.
4566 * This is required to support legacy firmware which does
4567 * not return link capacity.
4568 */
4569 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 }
4572
4573 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004574 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304575
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 if ((rc < 0) || (rc >= len))
4577 {
4578 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304579 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 return -EIO;
4581 }
4582
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304583 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 return 0;
4585}
4586
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304587int iw_get_softap_linkspeed(struct net_device *dev,
4588 struct iw_request_info *info,
4589 union iwreq_data *wrqu,
4590 char *extra)
4591{
4592 int ret;
4593
4594 vos_ssr_protect(__func__);
4595 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4596 vos_ssr_unprotect(__func__);
4597
4598 return ret;
4599}
4600
4601
Jeff Johnson295189b2012-06-20 16:38:30 -07004602static const iw_handler hostapd_handler[] =
4603{
4604 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4605 (iw_handler) NULL, /* SIOCGIWNAME */
4606 (iw_handler) NULL, /* SIOCSIWNWID */
4607 (iw_handler) NULL, /* SIOCGIWNWID */
4608 (iw_handler) NULL, /* SIOCSIWFREQ */
4609 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4610 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304611 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 (iw_handler) NULL, /* SIOCSIWSENS */
4613 (iw_handler) NULL, /* SIOCGIWSENS */
4614 (iw_handler) NULL, /* SIOCSIWRANGE */
4615 (iw_handler) NULL, /* SIOCGIWRANGE */
4616 (iw_handler) NULL, /* SIOCSIWPRIV */
4617 (iw_handler) NULL, /* SIOCGIWPRIV */
4618 (iw_handler) NULL, /* SIOCSIWSTATS */
4619 (iw_handler) NULL, /* SIOCGIWSTATS */
4620 (iw_handler) NULL, /* SIOCSIWSPY */
4621 (iw_handler) NULL, /* SIOCGIWSPY */
4622 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4623 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4624 (iw_handler) NULL, /* SIOCSIWAP */
4625 (iw_handler) NULL, /* SIOCGIWAP */
4626 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4627 (iw_handler) NULL, /* SIOCGIWAPLIST */
4628 (iw_handler) NULL, /* SIOCSIWSCAN */
4629 (iw_handler) NULL, /* SIOCGIWSCAN */
4630 (iw_handler) NULL, /* SIOCSIWESSID */
4631 (iw_handler) NULL, /* SIOCGIWESSID */
4632 (iw_handler) NULL, /* SIOCSIWNICKN */
4633 (iw_handler) NULL, /* SIOCGIWNICKN */
4634 (iw_handler) NULL, /* -- hole -- */
4635 (iw_handler) NULL, /* -- hole -- */
4636 (iw_handler) NULL, /* SIOCSIWRATE */
4637 (iw_handler) NULL, /* SIOCGIWRATE */
4638 (iw_handler) NULL, /* SIOCSIWRTS */
4639 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4640 (iw_handler) NULL, /* SIOCSIWFRAG */
4641 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4642 (iw_handler) NULL, /* SIOCSIWTXPOW */
4643 (iw_handler) NULL, /* SIOCGIWTXPOW */
4644 (iw_handler) NULL, /* SIOCSIWRETRY */
4645 (iw_handler) NULL, /* SIOCGIWRETRY */
4646 (iw_handler) NULL, /* SIOCSIWENCODE */
4647 (iw_handler) NULL, /* SIOCGIWENCODE */
4648 (iw_handler) NULL, /* SIOCSIWPOWER */
4649 (iw_handler) NULL, /* SIOCGIWPOWER */
4650 (iw_handler) NULL, /* -- hole -- */
4651 (iw_handler) NULL, /* -- hole -- */
4652 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4653 (iw_handler) NULL, /* SIOCGIWGENIE */
4654 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4655 (iw_handler) NULL, /* SIOCGIWAUTH */
4656 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4657 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4658 (iw_handler) NULL, /* SIOCSIWPMKSA */
4659};
4660
Jeff Johnson224f3702014-03-26 11:09:47 -07004661/*
4662 * Note that the following ioctls were defined with semantics which
4663 * cannot be handled by the "iwpriv" userspace application and hence
4664 * they are not included in the hostapd_private_args array
4665 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4666 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004667
4668static const struct iw_priv_args hostapd_private_args[] = {
4669 { QCSAP_IOCTL_SETPARAM,
4670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4671 { QCSAP_IOCTL_SETPARAM,
4672 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304673 { QCSAP_PARAM_GET_FRAME_LOGS,
4674 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 { QCSAP_PARAM_MAX_ASSOC,
4676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4677 { QCSAP_PARAM_HIDE_SSID,
4678 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004679 { QCSAP_PARAM_SET_MC_RATE,
4680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304681 { QCSAP_PARAM_SET_PROXIMITY,
4682 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304683 { QCSAP_PARAM_SET_WOWL,
4684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 { QCSAP_IOCTL_GETPARAM,
4686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4687 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4688 { QCSAP_IOCTL_GETPARAM, 0,
4689 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4690 { QCSAP_PARAM_MAX_ASSOC, 0,
4691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004692 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4693 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4694 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304696 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4697 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 { QCSAP_PARAM_CLR_ACL, 0,
4699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4700 { QCSAP_PARAM_ACL_MODE,
4701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304703 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 { QCSAP_IOCTL_STOPBSS,
4705 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4706 { QCSAP_IOCTL_VERSION, 0,
4707 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004708 { QCSAP_IOCTL_GET_STA_INFO, 0,
4709 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004711 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004713 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004714 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304716 { QCSAP_IOCTL_AP_STATS, 0,
4717 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304718 { QCSAP_IOCTL_GET_STATS, 0,
4719 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4720 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4722 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304723 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004724
4725 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4727 /* handlers for sub-ioctl */
4728 { WE_SET_WLAN_DBG,
4729 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4730 0,
4731 "setwlandbg" },
4732
4733 /* handlers for main ioctl */
4734 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4735 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4736 0,
4737 "" },
4738
4739 /* handlers for sub-ioctl */
4740 { WE_LOG_DUMP_CMD,
4741 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4742 0,
4743 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 { WE_P2P_NOA_CMD,
4745 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4746 0,
4747 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004748 /* handlers for sub ioctl */
4749 {
4750 WE_MCC_CONFIG_CREDENTIAL,
4751 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4752 0,
4753 "setMccCrdnl" },
4754
4755 /* handlers for sub ioctl */
4756 {
4757 WE_MCC_CONFIG_PARAMS,
4758 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4759 0,
4760 "setMccConfig" },
4761
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 /* handlers for main ioctl */
4763 { QCSAP_IOCTL_MODIFY_ACL,
4764 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4765 0,
4766 "modify_acl" },
4767
4768 /* handlers for main ioctl */
4769 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4770 0,
4771 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4772 "getChannelList" },
4773
Jeff Johnsone7245742012-09-05 17:12:55 -07004774 /* handlers for main ioctl */
4775 { QCSAP_IOCTL_SET_TX_POWER,
4776 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4777 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304778 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004779
4780 /* handlers for main ioctl */
4781 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4782 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4783 0,
4784 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304785
4786 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4787 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4788 0,
4789 "dataSnapshot" },
4790
4791 /* handlers for main ioctl */
4792 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4793 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4794 0,
4795 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304796 /* handlers for main ioctl */
4797 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
4798 IW_PRIV_TYPE_CHAR| 512,
4799 0,
4800 "" },
4801
4802 /* handlers for sub-ioctl */
4803 { WE_WOWL_ADD_PTRN,
4804 IW_PRIV_TYPE_CHAR| 512,
4805 0,
4806 "wowlAddPtrn" },
4807
4808 { WE_WOWL_DEL_PTRN,
4809 IW_PRIV_TYPE_CHAR| 512,
4810 0,
4811 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004812};
Jeff Johnsone7245742012-09-05 17:12:55 -07004813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814static const iw_handler hostapd_private[] = {
4815 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304816 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
4817 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
4818 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4821 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4822 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4823 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4824 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4825 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4826 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304827 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4829 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4830 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4831 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004832 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004833 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4834 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004835 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304836 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304837 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304838 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4839 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004840};
4841const struct iw_handler_def hostapd_handler_def = {
4842 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4843 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4844 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4845 .standard = (iw_handler *)hostapd_handler,
4846 .private = (iw_handler *)hostapd_private,
4847 .private_args = hostapd_private_args,
4848 .get_wireless_stats = NULL,
4849};
4850#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4851struct net_device_ops net_ops_struct = {
4852 .ndo_open = hdd_hostapd_open,
4853 .ndo_stop = hdd_hostapd_stop,
4854 .ndo_uninit = hdd_hostapd_uninit,
4855 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4856 .ndo_tx_timeout = hdd_softap_tx_timeout,
4857 .ndo_get_stats = hdd_softap_stats,
4858 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4859 .ndo_do_ioctl = hdd_hostapd_ioctl,
4860 .ndo_change_mtu = hdd_hostapd_change_mtu,
4861 .ndo_select_queue = hdd_hostapd_select_queue,
4862 };
4863#endif
4864
4865int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4866{
4867 return VOS_STATUS_SUCCESS;
4868}
4869
4870void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4871{
4872#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4873 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4874#else
4875 pWlanHostapdDev->open = hdd_hostapd_open;
4876 pWlanHostapdDev->stop = hdd_hostapd_stop;
4877 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4878 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4879 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4880 pWlanHostapdDev->get_stats = hdd_softap_stats;
4881 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4882 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4883#endif
4884}
4885
4886VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304887{
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05304889#ifdef DHCP_SERVER_OFFLOAD
4890 hdd_dhcp_state_t *dhcp_status;
4891#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304892#ifdef MDNS_OFFLOAD
4893 hdd_mdns_state_t *mdns_status;
4894#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004896 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004898#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004899 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4900 v_U16_t unsafeChannelCount;
4901#endif /* FEATURE_WLAN_CH_AVOID */
4902
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304903 if (pHddCtx->isLogpInProgress) {
4904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4905 "%s:LOGP in Progress. Ignore!!!",__func__);
4906 status = VOS_STATUS_E_FAILURE;
4907 }
4908
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304910
4911#ifdef SAP_AUTH_OFFLOAD
4912 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05304913 {
4914 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
4915 {
4916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4917 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
4918 return VOS_STATUS_E_FAILURE;
4919 }
4920 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304921#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304922
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304923 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05304925#ifdef DHCP_SERVER_OFFLOAD
4926 dhcp_status = &pAdapter->dhcp_status;
4927#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304928#ifdef MDNS_OFFLOAD
4929 mdns_status = &pAdapter->mdns_status;
4930#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304931
Nirav Shah7e3c8132015-06-22 23:51:42 +05304932 spin_lock_init(&pAdapter->sta_hash_lock);
4933 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4934
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004935 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4936
Leo Chang0b0e45a2013-12-15 15:18:55 -08004937#ifdef FEATURE_WLAN_CH_AVOID
4938 /* Get unsafe cahnnel list from cached location */
4939 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4940 sizeof(unsafeChannelList),
4941 &unsafeChannelCount);
4942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4943 "%s : Unsafe Channel count %d",
4944 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304945 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004946 unsafeChannelList,
4947 unsafeChannelCount);
4948#endif /* FEATURE_WLAN_CH_AVOID */
4949
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 // Zero the memory. This zeros the profile structure.
4951 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05304952#ifdef DHCP_SERVER_OFFLOAD
4953 memset(dhcp_status, 0,sizeof(*dhcp_status));
4954#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304955#ifdef MDNS_OFFLOAD
4956 memset(mdns_status, 0,sizeof(*mdns_status));
4957#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05304958
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 // Set up the pointer to the Wireless Extensions state structure
4960 // NOP
4961 status = hdd_set_hostapd(pAdapter);
4962 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 return status;
4965 }
4966
4967 status = vos_event_init(&phostapdBuf->vosEvent);
4968 if (!VOS_IS_STATUS_SUCCESS(status))
4969 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 return status;
4972 }
Anurag Chouhan83026002016-12-13 22:46:21 +05304973#ifdef DHCP_SERVER_OFFLOAD
4974 status = vos_event_init(&dhcp_status->vos_event);
4975 if (!VOS_IS_STATUS_SUCCESS(status)) {
4976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
4977 return status;
4978 }
4979#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304980#ifdef MDNS_OFFLOAD
4981 status = vos_event_init(&mdns_status->vos_event);
4982 if (!VOS_IS_STATUS_SUCCESS(status)) {
4983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4984 ("Hostapd HDD vos event init failed!!"));
4985 return status;
4986 }
4987#endif /* MDNS_OFFLOAD */
4988
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4990
4991 // Register as a wireless device
4992 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4993
4994 //Initialize the data path module
4995 status = hdd_softap_init_tx_rx(pAdapter);
4996 if ( !VOS_IS_STATUS_SUCCESS( status ))
4997 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004998 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305000
5001 status = hdd_wmm_adapter_init( pAdapter );
5002 if (!VOS_IS_STATUS_SUCCESS(status))
5003 {
5004 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005005 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305006 status, status );
5007 goto error_wmm_init;
5008 }
5009
5010 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5011
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305012 return status;
5013
5014error_wmm_init:
5015 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 EXIT();
5017 return status;
5018}
5019
5020hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5021{
5022 struct net_device *pWlanHostapdDev = NULL;
5023 hdd_adapter_t *pHostapdAdapter = NULL;
5024 v_CONTEXT_t pVosContext= NULL;
5025
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305026 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5027#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5028 NET_NAME_UNKNOWN,
5029#endif
5030 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 if (pWlanHostapdDev != NULL)
5032 {
5033 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5034
5035 //Init the net_device structure
5036 ether_setup(pWlanHostapdDev);
5037
5038 //Initialize the adapter context to zeros.
5039 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5040 pHostapdAdapter->dev = pWlanHostapdDev;
5041 pHostapdAdapter->pHddCtx = pHddCtx;
5042 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5043
5044 //Get the Global VOSS context.
5045 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5046 //Save the adapter context in global context for future.
5047 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5048
5049 //Init the net_device structure
5050 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5051
5052 hdd_set_ap_ops( pHostapdAdapter->dev );
5053
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5055 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5056
5057 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5058 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5059
5060 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5062 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5063 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005064
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5066 }
5067 return pHostapdAdapter;
5068}
5069
5070VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5071{
5072 struct net_device *dev = pAdapter->dev;
5073 VOS_STATUS status = VOS_STATUS_SUCCESS;
5074
5075 ENTER();
5076
5077 if( rtnl_lock_held )
5078 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005079 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 if( dev_alloc_name(dev, dev->name) < 0 )
5081 {
5082 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5083 return VOS_STATUS_E_FAILURE;
5084 }
5085 }
5086 if (register_netdevice(dev))
5087 {
5088 hddLog(VOS_TRACE_LEVEL_FATAL,
5089 "%s:Failed:register_netdevice", __func__);
5090 return VOS_STATUS_E_FAILURE;
5091 }
5092 }
5093 else
5094 {
5095 if (register_netdev(dev))
5096 {
5097 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5098 return VOS_STATUS_E_FAILURE;
5099 }
5100 }
5101 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5102
5103 EXIT();
5104 return status;
5105}
5106
c_hpothu002231a2015-02-05 14:58:51 +05305107VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005108{
5109 ENTER();
5110
5111 hdd_softap_deinit_tx_rx(pAdapter);
5112
5113 /* if we are being called during driver unload, then the dev has already
5114 been invalidated. if we are being called at other times, then we can
5115 detatch the wireless device handlers */
5116 if (pAdapter->dev)
5117 {
c_hpothu002231a2015-02-05 14:58:51 +05305118 if (TRUE == rtnl_held)
5119 {
5120 pAdapter->dev->wireless_handlers = NULL;
5121 }
5122 else
5123 {
5124 rtnl_lock();
5125 pAdapter->dev->wireless_handlers = NULL;
5126 rtnl_unlock();
5127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 }
5129 EXIT();
5130 return 0;
5131}