blob: b4fd06f84b8e13b4919484daaa5c0500cec39a64 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh57a31542016-01-04 21:01:43 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
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
791void hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
792 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);
815 return;
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 Ashisha8e8a722016-10-18 19:07:45 +0530829 return;
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 Ashish17ef5082016-10-17 18:33:21 +0530834 return;
835}
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 }
975 pHddApCtx->wepKey[i].keyLength = 0;
976 }
977 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
979 startBssEvent = "SOFTAP.enabled";
980 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
981 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
982 memset(&wrqu, 0, sizeof(wrqu));
983 wrqu.data.length = strlen(startBssEvent);
984 we_event = IWEVCUSTOM;
985 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700986 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 break; //Event will be sent after Switch-Case stmt
988
989 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800990 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
992
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530993#ifdef SAP_AUTH_OFFLOAD
994 if (cfg_param->enable_sap_auth_offload)
995 hdd_set_sap_auth_offload(pHostapdAdapter, FALSE);
996#endif
997
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700998 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700999 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001000
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301002
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301003 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301004 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301005 hddLog(LOG1,
1006 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1007 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301008 }
1009
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 goto stopbss;
1011 case eSAP_STA_SET_KEY_EVENT:
1012 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001013 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1015 return VOS_STATUS_SUCCESS;
1016 case eSAP_STA_DEL_KEY_EVENT:
1017 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001018 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 return VOS_STATUS_SUCCESS;
1020 case eSAP_STA_MIC_FAILURE_EVENT:
1021 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 memset(&msg, '\0', sizeof(msg));
1023 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001024 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001025 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001026 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 msg.flags = IW_MICFAILURE_GROUP;
1028 else
1029 msg.flags = IW_MICFAILURE_PAIRWISE;
1030 memset(&wrqu, 0, sizeof(wrqu));
1031 wrqu.data.length = sizeof(msg);
1032 we_event = IWEVMICHAELMICFAILURE;
1033 we_custom_event_generic = (v_BYTE_t *)&msg;
1034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 /* inform mic failure to nl80211 */
1036 cfg80211_michael_mic_failure(dev,
1037 pSapEvent->sapevt.
1038 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001039 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 NL80211_KEYTYPE_GROUP :
1041 NL80211_KEYTYPE_PAIRWISE),
1042 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1043 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1044 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 break;
1046
1047 case eSAP_STA_ASSOC_EVENT:
1048 case eSAP_STA_REASSOC_EVENT:
1049 wrqu.addr.sa_family = ARPHRD_ETHER;
1050 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001051 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001052 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 we_event = IWEVREGISTERED;
1054
1055 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1056
1057 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1058 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1059 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1060 {
1061 bAuthRequired = FALSE;
1062 }
1063
1064 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
1065 {
c_hpothuffdb5272013-10-02 16:42:35 +05301066 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 TRUE,
1068 pHddApCtx->uPrivacy,
1069 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1070 0,
1071 0,
1072 (v_MACADDR_t *)wrqu.addr.sa_data,
1073 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301074
1075 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1076 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1077 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 }
1079 else
1080 {
c_hpothuffdb5272013-10-02 16:42:35 +05301081 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 FALSE,
1083 pHddApCtx->uPrivacy,
1084 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1085 0,
1086 0,
1087 (v_MACADDR_t *)wrqu.addr.sa_data,
1088 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301089 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1090 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1091 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001092 }
1093
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301094 staId =
1095 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1096 if (VOS_IS_STATUS_SUCCESS(vos_status))
1097 {
1098
1099 pSapCtx->aStaInfo[staId].rate_flags =
1100 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1101 }
1102
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 // Stop AP inactivity timer
1104 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1105 {
1106 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1107 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001108 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001110#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001111 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1112 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301113 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1114 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001115 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301116 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1117 HDD_SAP_WAKE_LOCK_DURATION,
1118 WIFI_POWER_EVENT_WAKELOCK_SAP);
1119
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001120#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001121#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1122 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301123 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1125
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301126 staInfo = vos_mem_malloc(sizeof(*staInfo));
1127 if (staInfo == NULL) {
1128 hddLog(LOGE, FL("alloc station_info failed"));
1129 return VOS_STATUS_E_NOMEM;
1130 }
1131
1132 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1134 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301135 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301137 staInfo->assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001138#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301139 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 cfg80211_new_sta(dev,
1142 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301143 staInfo, GFP_KERNEL);
1144 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 }
1146 else
1147 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001148 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 }
1150 }
1151#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301152 hdd_manage_delack_timer(pHddCtx);
1153
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001154 pScanInfo = &pHddCtx->scan_info;
1155 // Lets do abort scan to ensure smooth authentication for client
1156 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1157 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301158 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301159 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001161
1162 break;
1163 case eSAP_STA_DISASSOC_EVENT:
1164 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001165 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001166 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1168 hddLog(LOG1," User initiated disassociation");
1169 else
1170 hddLog(LOG1," MAC initiated disassociation");
1171 we_event = IWEVEXPIRED;
1172 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1173 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1174 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001175 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 -07001176 return VOS_STATUS_E_FAILURE;
1177 }
1178 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1179
1180 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1181 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301182 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 // Start AP inactivity timer if no stations associated with it
1184 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1185 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301186 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 {
1188 bApActive = TRUE;
1189 break;
1190 }
1191 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301192 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194 if (bApActive == FALSE)
1195 {
1196 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1197 {
1198 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1199 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001200 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 }
1202 else
1203 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1204 }
1205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001206#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1207 cfg80211_del_sta(dev,
1208 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1209 GFP_KERNEL);
1210#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001211 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301212 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1213 if (VOS_STATUS_SUCCESS != vos_status)
1214 {
1215 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1216 __func__, vos_status);
1217 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301218 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 break;
1220 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1221 {
1222 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1223 union iwreq_data wreq;
1224
1225 down(&pHddApCtx->semWpsPBCOverlapInd);
1226 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1227
1228 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1229 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1230
1231 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001232 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 memset(&wreq, 0, sizeof(wreq));
1234 wreq.data.length = strlen(message); // This is length of message
1235 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1236
1237 return VOS_STATUS_SUCCESS;
1238 }
1239 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1240 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1241 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1242 { // List of associated stations
1243 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1244 {
1245 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1246 i+1,
1247 pAssocStasArray->assocId,
1248 pAssocStasArray->staId,
1249 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1250 pAssocStasArray++;
1251 }
1252 }
1253 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001254 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 case eSAP_REMAIN_CHAN_READY:
1257 hdd_remainChanReadyHandler( pHostapdAdapter );
1258 return VOS_STATUS_SUCCESS;
1259 case eSAP_SEND_ACTION_CNF:
1260 hdd_sendActionCnf( pHostapdAdapter,
1261 ( eSAP_STATUS_SUCCESS ==
1262 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1263 TRUE : FALSE );
1264 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 case eSAP_UNKNOWN_STA_JOIN:
1266 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1267 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1268 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1269 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1270 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1271 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1272 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1273 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1274 wrqu.data.pointer = unknownSTAEvent;
1275 wrqu.data.length = strlen(unknownSTAEvent);
1276 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301277 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 break;
1279
1280 case eSAP_MAX_ASSOC_EXCEEDED:
1281 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1282 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1283 " one or more devices to enable the new device connection",
1284 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1285 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1286 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1287 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1288 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1289 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1290 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1291 wrqu.data.pointer = maxAssocExceededEvent;
1292 wrqu.data.length = strlen(maxAssocExceededEvent);
1293 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001294 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 break;
1296 case eSAP_STA_ASSOC_IND:
1297 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001298
1299 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001300 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001301 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1302 return VOS_STATUS_SUCCESS;
1303
1304 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301305 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301306 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1307 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301308 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301309 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001310 return VOS_STATUS_SUCCESS;
1311
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001313 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 goto stopbss;
1315 return VOS_STATUS_SUCCESS;
1316 }
1317 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1318 return VOS_STATUS_SUCCESS;
1319
1320stopbss :
1321 {
1322 v_BYTE_t we_custom_event[64];
1323 char *stopBssEvent = "STOP-BSS.response";//17
1324 int event_len = strlen(stopBssEvent);
1325
1326 hddLog(LOG1, FL("BSS stop status = %s"),
1327 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1328 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1329
1330 /* Change the BSS state now since, as we are shutting things down,
1331 * we don't want interfaces to become re-enabled */
1332 pHostapdState->bssState = BSS_STOP;
1333
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301334 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1335 {
1336 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1337 {
1338 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1339 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1340 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1341 }
1342
1343 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1344 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1345 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1346 }
1347
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 /* Stop the pkts from n/w stack as we are going to free all of
1349 * the TX WMM queues for all STAID's */
1350 hdd_hostapd_stop(dev);
1351
1352 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301353 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1354 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1355 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001356
Amar Singhal37e6f052013-03-05 16:16:54 -08001357 /* once the event is set, structure dev/pHostapdAdapter should
1358 * not be touched since they are now subject to being deleted
1359 * by another thread */
1360 if (eSAP_STOP_BSS_EVENT == sapEvent)
1361 vos_event_set(&pHostapdState->vosEvent);
1362
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 /* notify userspace that the BSS has stopped */
1364 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1365 memcpy(&we_custom_event, stopBssEvent, event_len);
1366 memset(&wrqu, 0, sizeof(wrqu));
1367 wrqu.data.length = event_len;
1368 we_event = IWEVCUSTOM;
1369 we_custom_event_generic = we_custom_event;
1370 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001371 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 }
1373 return VOS_STATUS_SUCCESS;
1374}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001375
1376int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001378 eCsrEncryptionType *pEncryptType,
1379 eCsrEncryptionType *mcEncryptType,
1380 eCsrAuthType *pAuthType,
1381 v_BOOL_t *pMFPCapable,
1382 v_BOOL_t *pMFPRequired,
1383 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 u_int8_t *gen_ie )
1385{
1386 tDot11fIERSN dot11RSNIE;
1387 tDot11fIEWPA dot11WPAIE;
1388
1389 tANI_U8 *pRsnIe;
1390 tANI_U16 RSNIeLen;
1391
1392 if (NULL == halHandle)
1393 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001394 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 return -EINVAL;
1396 }
1397
1398 // Validity checks
1399 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1400 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1401 return -EINVAL;
1402 // Type check
1403 if ( gen_ie[0] == DOT11F_EID_RSN)
1404 {
1405 // Validity checks
1406 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1407 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1408 {
1409 return VOS_STATUS_E_FAILURE;
1410 }
1411 // Skip past the EID byte and length byte
1412 pRsnIe = gen_ie + 2;
1413 RSNIeLen = gen_ie_len - 2;
1414 // Unpack the RSN IE
1415 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1416 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1417 pRsnIe,
1418 RSNIeLen,
1419 &dot11RSNIE);
1420 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001421 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001422 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001423 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001424 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 /*Here we have followed the apple base code,
1426 but probably I suspect we can do something different*/
1427 //dot11RSNIE.akm_suite_count
1428 // Just translate the FIRST one
1429 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1430 //dot11RSNIE.pwise_cipher_suite_count
1431 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1432 //dot11RSNIE.gp_cipher_suite_count
1433 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1434 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001435 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1436 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001437
1438 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1439 } else
1440 if (gen_ie[0] == DOT11F_EID_WPA)
1441 {
1442 // Validity checks
1443 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1444 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1445 {
1446 return VOS_STATUS_E_FAILURE;
1447 }
1448 // Skip past the EID byte and length byte - and four byte WiFi OUI
1449 pRsnIe = gen_ie + 2 + 4;
1450 RSNIeLen = gen_ie_len - (2 + 4);
1451 // Unpack the WPA IE
1452 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1453 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1454 pRsnIe,
1455 RSNIeLen,
1456 &dot11WPAIE);
1457 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001458 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001459 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001460 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001461 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 //dot11WPAIE.auth_suite_count
1463 // Just translate the FIRST one
1464 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1465 //dot11WPAIE.unicast_cipher_count
1466 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1467 //dot11WPAIE.unicast_cipher_count
1468 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001469 *pMFPCapable = VOS_FALSE;
1470 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 }
1472 else
1473 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001474 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 return VOS_STATUS_E_FAILURE;
1476 }
1477 return VOS_STATUS_SUCCESS;
1478}
Leo Chang614d2072013-08-22 14:59:44 -07001479
Leo Chang0b0e45a2013-12-15 15:18:55 -08001480#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001481
1482/*==========================================================================
1483 FUNCTION sapUpdateUnsafeChannelList
1484
1485 DESCRIPTION
1486 Function Undate unsafe channel list table
1487
1488 DEPENDENCIES
1489 NA.
1490
1491 PARAMETERS
1492
1493 IN
1494 pSapCtx : SAP context pointer, include unsafe channel list
1495
1496 RETURN VALUE
1497 NONE
1498============================================================================*/
1499void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1500 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1501{
1502 v_U16_t i, j;
1503
1504 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1505 sizeof(pHddCtx->unsafeChannelList));
1506 if (0 == unsafeChannelCount)
1507 {
1508 pHddCtx->unsafeChannelCount = 0;
1509 }
1510 else
1511 {
c_hpothu8de53e42014-08-22 15:00:37 +05301512 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1513 {
1514 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1515 FL("unsafeChannelCount%hd greater than %d"),
1516 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1517 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1518 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001519 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1520 unsafeChannelList,
1521 unsafeChannelCount * sizeof(tANI_U16));
1522 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1523 }
1524
1525 /* Flush, default set all channel safe */
1526 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1527 {
1528 safeChannels[i].isSafe = VOS_TRUE;
1529 }
1530
1531 /* Try to find unsafe channel */
1532 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1533 {
1534 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1535 {
1536 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1537 {
1538 /* Found unsafe channel, update it */
1539 safeChannels[j].isSafe = VOS_FALSE;
1540 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1541 "%s : CH %d is not safe",
1542 __func__, pHddCtx->unsafeChannelList[i]);
1543 break;
1544 }
1545 }
1546 }
1547
1548 return;
1549}
1550
1551/**---------------------------------------------------------------------------
1552
1553 \brief hdd_hostapd_ch_avoid_cb() -
1554
1555 Avoid channel notification from FW handler.
1556 FW will send un-safe channle list to avoid overwrapping.
1557 hostapd should not use notified channel
1558
1559 \param - pAdapter HDD adapter pointer
1560 indParam channel avoid notification parameter
1561
1562 \return - None
1563
1564 --------------------------------------------------------------------------*/
1565void hdd_hostapd_ch_avoid_cb
1566(
1567 void *pAdapter,
1568 void *indParam
1569)
1570{
1571 hdd_adapter_t *pHostapdAdapter = NULL;
1572 hdd_context_t *hddCtxt;
1573 tSirChAvoidIndType *chAvoidInd;
1574 v_U8_t rangeLoop;
1575 v_U16_t channelLoop;
1576 v_U16_t dupCheck;
1577 v_U16_t startChannel;
1578 v_U16_t endChannel;
1579 v_U16_t unsafeChannelCount = 0;
1580 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1581 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001582 tHddAvoidFreqList hddAvoidFreqList;
1583 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301584#ifdef WLAN_FEATURE_AP_HT40_24G
1585 ptSapContext pSapCtx = NULL;
1586 tHalHandle hHal;
1587 v_U8_t cbMode;
1588 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1589 v_U32_t delay;
1590#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001591
1592 /* Basic sanity */
1593 if ((NULL == pAdapter) || (NULL == indParam))
1594 {
1595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1596 "%s : Invalid arguments", __func__);
1597 return;
1598 }
1599
1600 hddCtxt = (hdd_context_t *)pAdapter;
1601 chAvoidInd = (tSirChAvoidIndType *)indParam;
1602 pVosContext = hddCtxt->pvosContext;
1603
1604 /* Make unsafe channel list */
1605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1606 "%s : band count %d",
1607 __func__, chAvoidInd->avoidRangeCount);
1608 vos_mem_zero((void *)unsafeChannelList,
1609 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1610 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1611 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301612 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1613 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1614 break;
1615 }
1616 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001617 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301618 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001619 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1621 "%s : start %d : %d, end %d : %d",
1622 __func__,
1623 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1624 startChannel,
1625 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1626 endChannel);
1627 for (channelLoop = startChannel;
1628 channelLoop < (endChannel + 1);
1629 channelLoop++)
1630 {
1631 /* Channel duplicate check routine */
1632 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1633 {
1634 if (unsafeChannelList[dupCheck] == channelLoop)
1635 {
1636 /* This channel is duplicated */
1637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1638 "%s : found duplicated channel %d",
1639 __func__, channelLoop);
1640 break;
1641 }
1642 }
1643 if (dupCheck == unsafeChannelCount)
1644 {
c_hpothu8de53e42014-08-22 15:00:37 +05301645 int ii;
1646 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1647 {
1648 if (channelLoop == safeChannels[ii].channelNumber)
1649 {
1650 unsafeChannelList[unsafeChannelCount] = channelLoop;
1651 unsafeChannelCount++;
1652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1653 "%s : unsafe channel %d, count %d",
1654 __func__,
1655 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301656 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1657 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1658 break;
1659 }
c_hpothu8de53e42014-08-22 15:00:37 +05301660 }
1661 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001662 }
1663 else
1664 {
1665 /* DUP, do nothing */
1666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1667 "%s : duplicated channel %d",
1668 __func__, channelLoop);
1669 }
1670 }
1671 }
1672 /* Update unsafe channel cache
1673 * WCN Platform Driver cache */
1674 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1675 unsafeChannelCount);
1676
1677 /* Store into local cache
1678 * Start with STA and later start SAP
1679 * in this scenario, local cache will be used */
1680 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1681 unsafeChannelList,
1682 unsafeChannelCount);
1683
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001684 /* generate vendor specific event */
1685 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1686 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1687 {
1688 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1689 chAvoidInd->avoidFreqRange[i].startFreq;
1690 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1691 chAvoidInd->avoidFreqRange[i].endFreq;
1692 }
1693 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1694
1695 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1696
Leo Chang0b0e45a2013-12-15 15:18:55 -08001697 /* Get SAP context first
1698 * SAP and P2PGO would not concurrent */
1699 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301700#ifdef WLAN_FEATURE_AP_HT40_24G
1701 if (NULL == pHostapdAdapter)
1702 {
1703 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1704 }
1705#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301706 if ((pHostapdAdapter) &&
1707 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1708 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001709 {
1710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1711 "%s : Current operation channel %d",
1712 __func__,
1713 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1714 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1715 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301716 if ((unsafeChannelList[channelLoop] ==
1717 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1718 {
1719 if ((AUTO_CHANNEL_SELECT ==
1720 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1721 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1722 {
1723 /* current operating channel is un-safe channel
1724 * restart driver */
1725 hdd_hostapd_stop(pHostapdAdapter->dev);
1726 /* On LE, this event is handled by wlan-services to
1727 * restart SAP. On android, this event would be
1728 * ignored.
1729 */
1730 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1731 NULL, 0);
1732 }
1733 return;
1734 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001735 }
1736 }
1737
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301738#ifdef WLAN_FEATURE_AP_HT40_24G
1739 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1740 {
1741 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1742
1743 if(pSapCtx == NULL)
1744 {
1745 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1746 FL("psapCtx is NULL"));
1747 return;
1748 }
1749
1750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1751 FL("SAP Secondary channel: %d "),
1752 pSapCtx->sap_sec_chan);
1753
1754 /* tHalHandle */
1755 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1756
1757 if (NULL == hHal)
1758 {
1759 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1760 FL("In invalid hHal"));
1761 return;
1762 }
1763
1764 cbMode = sme_GetChannelBondingMode24G(hHal);
1765
1766 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1767 FL("Selected Channel bonding : %d"), cbMode);
1768
1769 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1770 {
1771 int i;
1772 eHalStatus halStatus;
1773
1774 for (i = 0; i < unsafeChannelCount; i++)
1775 {
1776 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1777 {
1778 /* Current SAP Secondary channel is un-safe channel */
1779 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1780 FL("Move SAP from HT40 to HT20"));
1781
1782 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1783 PHY_SINGLE_CHANNEL_CENTERED);
1784
1785 if (halStatus == eHAL_STATUS_FAILURE)
1786 {
1787 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1788 FL("Failed to change HT20/40 mode"));
1789 return;
1790 }
1791
1792 /* Disable Channel Bonding for 2.4GHz */
1793 sme_UpdateChannelBondingMode24G(hHal,
1794 PHY_SINGLE_CHANNEL_CENTERED);
1795 return;
1796 }
1797 }
1798 }
1799
1800 if ((!pSapCtx->numHT40IntoSta)
1801 && (pHostapdAdapter)
1802 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1803 {
1804 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1805 * are Safe then start HT20/40 timer to Move SAP from HT20
1806 * to HT40.
1807 */
1808 if (((!unsafeChannelCount)
1809 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1810 {
1811 /* Stop Previous Running HT20/40 Timer & Start timer
1812 with (OBSS TransitionDelayFactor * obss interval)
1813 delay after time out move AP from HT20 -> HT40
1814 mode
1815 */
1816 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1817 {
1818 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1819 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1820 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1821 FL("Failed to Stop HT20/40 timer"));
1822 }
1823
1824 delay =
1825 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1826
1827 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1828 FL("Start HT20/40 transition timer (%d sec)"), delay);
1829
1830 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1831 (delay * 1000));
1832
1833 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1834 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1835 FL("Failed to Start HT20/40 timer"));
1836 }
1837 else
1838 {
1839 /* Stop HT20/40 Timer */
1840 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1841 {
1842 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1843 FL("Stop HT20/40 transition timer"));
1844 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1845 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1846 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1847 FL("Failed to Stop HT20/40 timer"));
1848 }
1849 }
1850 }
1851 }
1852#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001853 return;
1854}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001855#endif /* FEATURE_WLAN_CH_AVOID */
1856
Jeff Johnson295189b2012-06-20 16:38:30 -07001857int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301858static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 struct iw_request_info *info,
1860 union iwreq_data *wrqu, char *extra)
1861{
1862 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001863 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301864 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 int *value = (int *)extra;
1866 int sub_cmd = value[0];
1867 int set_value = value[1];
1868 eHalStatus status;
1869 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05301870 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001871 v_CONTEXT_t pVosContext;
1872
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301873 ENTER();
1874
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301875 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001876 {
1877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301878 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001879 __func__);
1880 return -1;
1881 }
1882
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301883 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1884 ret = wlan_hdd_validate_context(pHddCtx);
1885 if (0 != ret)
1886 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301887 return -1;
1888 }
1889
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001890 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1891 if (!hHal)
1892 {
1893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1894 "%s: Hal ctx is null", __func__);
1895 return -1;
1896 }
1897
1898 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1899 if (!pVosContext)
1900 {
1901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1902 "%s: Vos ctx is null", __func__);
1903 return -1;
1904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001905
1906 switch(sub_cmd)
1907 {
1908
1909 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001910 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301912 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 }
1914 break;
1915
1916 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301917 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1919 {
1920 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1921 ret = -EINVAL;
1922 }
1923 else
1924 {
1925 WLANSAP_SetMode(pVosContext, set_value);
1926 }
1927 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301928
1929 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1930 if ((0 != set_value) && (1 != set_value))
1931 {
1932 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1933 ret = -EINVAL;
1934 }
1935 else
1936 {
1937 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1938 }
1939 break;
1940
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 case QCSAP_PARAM_MAX_ASSOC:
1942 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1943 {
1944 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1945 ret = -EINVAL;
1946 }
1947 else
1948 {
1949 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1950 {
1951 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1952 "Setting it to max allowed and continuing"),
1953 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1954 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1955 }
1956 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1957 set_value, NULL, eANI_BOOLEAN_FALSE);
1958 if ( status != eHAL_STATUS_SUCCESS )
1959 {
1960 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1961 status);
1962 ret = -EIO;
1963 }
1964 }
1965 break;
1966
1967 case QCSAP_PARAM_HIDE_SSID:
1968 {
1969 eHalStatus status = eHAL_STATUS_SUCCESS;
1970 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1971 if(eHAL_STATUS_SUCCESS != status)
1972 {
1973 hddLog(VOS_TRACE_LEVEL_ERROR,
1974 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001975 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 return status;
1977 }
1978 break;
1979 }
1980
Leo Chang614d2072013-08-22 14:59:44 -07001981 case QCSAP_PARAM_SET_MC_RATE:
1982 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001983 tSirRateUpdateInd *rateUpdate;
1984
1985 rateUpdate = (tSirRateUpdateInd *)
1986 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1987 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001988 {
1989 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001990 "%s: SET_MC_RATE indication alloc fail", __func__);
1991 ret = -1;
1992 break;
1993 }
1994 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1995
1996 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1997 /* Ignore unicast */
1998 rateUpdate->ucastDataRate = -1;
1999 rateUpdate->mcastDataRate24GHz = set_value;
2000 rateUpdate->mcastDataRate5GHz = set_value;
2001 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2002 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2003 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2004 if (eHAL_STATUS_SUCCESS != status)
2005 {
2006 hddLog(VOS_TRACE_LEVEL_ERROR,
2007 "%s: SET_MC_RATE failed", __func__);
2008 vos_mem_free(rateUpdate);
2009 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002010 }
2011 break;
2012 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302013 case QCSAP_PARAM_GET_FRAME_LOGS:
2014 {
2015 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2016 != VOS_STATUS_SUCCESS)
2017 {
2018 ret = -EINVAL;
2019 }
2020 break;
2021 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302022 case QCSAP_PARAM_SET_PROXIMITY:
2023 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302024 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302025 break;
2026 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302027 case QCSAP_PARAM_SET_WOWL:
2028 {
2029 if (!pHddCtx->is_ap_mode_wow_supported)
2030 {
2031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2032 "%s: Not supported",__func__);
2033 return -ENOTSUPP;
2034 }
2035 switch (set_value)
2036 {
2037 case 0x00:
2038 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2039 break;
2040 case 0x01:
2041 case 0x02:
2042 case 0x03:
2043 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2044 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2045 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2046 (enable_magic_pkt ? "YES":"NO"),
2047 (enable_pattrn_byte_match ? "YES":"NO"));
2048 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2049 enable_pattrn_byte_match);
2050 break;
2051 default:
2052 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2053 ret = -EINVAL;
2054 break;
2055 }
2056 break;
2057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 default:
2059 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2060 sub_cmd, set_value);
2061 ret = -EINVAL;
2062 break;
2063 }
2064
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302065 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 return ret;
2067}
2068
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302069int
2070static iw_softap_setparam(struct net_device *dev,
2071 struct iw_request_info *info,
2072 union iwreq_data *wrqu, char *extra)
2073{
2074 int ret;
2075
2076 vos_ssr_protect(__func__);
2077 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2078 vos_ssr_unprotect(__func__);
2079
2080 return ret;
2081}
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302084static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 struct iw_request_info *info,
2086 union iwreq_data *wrqu, char *extra)
2087{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302088 hdd_adapter_t *pHostapdAdapter;
2089 tHalHandle hHal;
2090 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 int *value = (int *)extra;
2092 int sub_cmd = value[0];
2093 eHalStatus status;
2094 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302095 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002096
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302097 ENTER();
2098
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302099 pHostapdAdapter = (netdev_priv(dev));
2100 if (NULL == pHostapdAdapter)
2101 {
2102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2103 "%s: Adapter is NULL",__func__);
2104 return -EINVAL;
2105 }
2106 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2107 ret = wlan_hdd_validate_context(pHddCtx);
2108 if (0 != ret)
2109 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302110 return ret;
2111 }
2112 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2113 if (NULL == hHal)
2114 {
2115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2116 "%s: Hal Context is NULL",__func__);
2117 return -EINVAL;
2118 }
2119 pVosContext = pHddCtx->pvosContext;
2120 if (NULL == pVosContext)
2121 {
2122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2123 "%s: pVosContext Context is NULL",__func__);
2124 return -EINVAL;
2125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 switch (sub_cmd)
2127 {
2128 case QCSAP_PARAM_MAX_ASSOC:
2129 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2130 if (eHAL_STATUS_SUCCESS != status)
2131 {
c_hpothuffdb5272013-10-02 16:42:35 +05302132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2133 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 ret = -EIO;
2135 }
Girish Gowli385be612014-09-18 11:17:20 +05302136
2137#ifdef WLAN_SOFTAP_VSTA_FEATURE
2138 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2139 {
2140 if (*value > VSTA_NUM_ASSOC_STA)
2141 {
2142 *value = VSTA_NUM_ASSOC_STA;
2143 }
2144 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2145 (*value > (VSTA_NUM_ASSOC_STA -
2146 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2147 {
2148 *value = (VSTA_NUM_ASSOC_STA -
2149 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2150 }
2151 }
2152 else
2153#endif
2154 {
2155 if (*value > NUM_ASSOC_STA)
2156 {
2157 *value = NUM_ASSOC_STA;
2158 }
2159 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2160 (*value > (NUM_ASSOC_STA -
2161 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2162 {
2163 *value = (NUM_ASSOC_STA -
2164 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2165 }
2166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302168
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002170 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 {
c_hpothuffdb5272013-10-02 16:42:35 +05302172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2173 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302174 ret = -EIO;
2175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 *value = 0;
2177 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302178
Jeff Johnson43971f52012-07-17 12:26:56 -07002179 case QCSAP_PARAM_GET_WLAN_DBG:
2180 {
2181 vos_trace_display();
2182 *value = 0;
2183 break;
2184 }
2185
2186 case QCSAP_PARAM_AUTO_CHANNEL:
2187 {
2188 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2189 break;
2190 }
2191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 default:
2193 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2194 ret = -EINVAL;
2195 break;
2196
2197 }
2198
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302199 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 return ret;
2201}
2202
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302203int
2204static iw_softap_getparam(struct net_device *dev,
2205 struct iw_request_info *info,
2206 union iwreq_data *wrqu, char *extra)
2207{
2208 int ret;
2209
2210 vos_ssr_protect(__func__);
2211 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2212 vos_ssr_unprotect(__func__);
2213
2214 return ret;
2215}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302216
2217int
2218static __iw_softap_setchar_getnone(struct net_device *dev,
2219 struct iw_request_info *info,
2220 union iwreq_data *wrqu, char *extra)
2221{
2222 int sub_cmd;
2223 int ret = 0; /* success */
2224 char *pBuffer = NULL;
2225 hdd_adapter_t *pAdapter;
2226 hdd_context_t *pHddCtx;
2227 struct iw_point s_priv_data;
2228
2229 ENTER();
2230
2231 if (!capable(CAP_NET_ADMIN))
2232 {
2233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2234 FL("permission check failed"));
2235 return -EPERM;
2236 }
2237
2238 pAdapter = (netdev_priv(dev));
2239 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2240 ret = wlan_hdd_validate_context(pHddCtx);
2241 if (0 != ret)
2242 {
2243 return ret;
2244 }
2245
2246 if (!pHddCtx->is_ap_mode_wow_supported)
2247 {
2248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2249 "%s: Not supported",__func__);
2250 return -ENOTSUPP;
2251 }
2252
2253 /* helper function to get iwreq_data with compat handling. */
2254 if (hdd_priv_get_data(&s_priv_data, wrqu))
2255 {
2256 return -EINVAL;
2257 }
2258
2259 /* make sure all params are correctly passed to function */
2260 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2261 {
2262 return -EINVAL;
2263 }
2264
2265 sub_cmd = s_priv_data.flags;
2266
2267 /* ODD number is used for set, copy data using copy_from_user */
2268 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2269 s_priv_data.length);
2270 if (NULL == pBuffer)
2271 {
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2273 "mem_alloc_copy_from_user_helper fail");
2274 return -ENOMEM;
2275 }
2276
2277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2278 "%s: Received length %d", __func__, s_priv_data.length);
2279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2280 "%s: Received data %s", __func__, pBuffer);
2281
2282 switch(sub_cmd)
2283 {
2284 case WE_WOWL_ADD_PTRN:
2285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2286 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2287 if (!ret)
2288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2289 "Failed to add pattern :%d", ret);
2290 break;
2291 case WE_WOWL_DEL_PTRN:
2292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2293 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2294 if (!ret)
2295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2296 "Failed to del pattern :%d", ret);
2297 break;
2298 default:
2299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2300 ret = -EINVAL;
2301 break;
2302 }
2303
2304 kfree(pBuffer);
2305 return ret;
2306}
2307
2308int
2309static iw_softap_setchar_getnone(struct net_device *dev,
2310 struct iw_request_info *info,
2311 union iwreq_data *wrqu, char *extra)
2312{
2313 int ret;
2314
2315 vos_ssr_protect(__func__);
2316 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2317 vos_ssr_unprotect(__func__);
2318
2319 return ret;
2320}
2321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322/* Usage:
2323 BLACK_LIST = 0
2324 WHITE_LIST = 1
2325 ADD MAC = 0
2326 REMOVE MAC = 1
2327
2328 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2329 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2330 while using this ioctl
2331
2332 Syntax:
2333 iwpriv softap.0 modify_acl
2334 <6 octet mac addr> <list type> <cmd type>
2335
2336 Examples:
2337 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2338 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2339 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2340 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2341*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302342int __iw_softap_modify_acl(struct net_device *dev,
2343 struct iw_request_info *info,
2344 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002345{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 hdd_adapter_t *pHostapdAdapter;
2347 v_CONTEXT_t pVosContext;
2348 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 v_BYTE_t *value = (v_BYTE_t*)extra;
2350 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2351 int listType, cmd, i;
2352 int ret = 0; /* success */
2353
2354 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302355 pHostapdAdapter = (netdev_priv(dev));
2356 if (NULL == pHostapdAdapter)
2357 {
2358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2359 "%s: Adapter is NULL",__func__);
2360 return -EINVAL;
2361 }
2362 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2363 ret = wlan_hdd_validate_context(pHddCtx);
2364 if (0 != ret)
2365 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302366 return ret;
2367 }
2368 pVosContext = pHddCtx->pvosContext;
2369 if (NULL == pVosContext)
2370 {
2371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2372 "%s: Vos Context is NULL",__func__);
2373 return -EINVAL;
2374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2376 {
2377 pPeerStaMac[i] = *(value+i);
2378 }
2379 listType = (int)(*(value+i));
2380 i++;
2381 cmd = (int)(*(value+i));
2382
Arif Hussain24bafea2013-11-15 15:10:03 -08002383 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2384 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2387 != VOS_STATUS_SUCCESS)
2388 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002389 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 ret = -EIO;
2391 }
2392 EXIT();
2393 return ret;
2394}
2395
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302396int iw_softap_modify_acl(struct net_device *dev,
2397 struct iw_request_info *info,
2398 union iwreq_data *wrqu, char *extra)
2399{
2400 int ret;
2401
2402 vos_ssr_protect(__func__);
2403 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2404 vos_ssr_unprotect(__func__);
2405
2406 return ret;
2407}
2408
Jeff Johnson295189b2012-06-20 16:38:30 -07002409int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302410static __iw_softap_getchannel(struct net_device *dev,
2411 struct iw_request_info *info,
2412 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002413{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302414 hdd_adapter_t *pHostapdAdapter;
2415 hdd_context_t *pHddCtx;
2416 int ret = 0;
2417 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302418
2419 ENTER();
2420
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302421 pHostapdAdapter = (netdev_priv(dev));
2422 if (NULL == pHostapdAdapter)
2423 {
2424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2425 "%s: Adapter is NULL",__func__);
2426 return -EINVAL;
2427 }
2428 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2429 ret = wlan_hdd_validate_context(pHddCtx);
2430 if (0 != ret)
2431 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302432 return ret;
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302435 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002436
Jeff Johnson43971f52012-07-17 12:26:56 -07002437 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302438
2439 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 return 0;
2441}
2442
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302443
Jeff Johnsone7245742012-09-05 17:12:55 -07002444int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302445static iw_softap_getchannel(struct net_device *dev,
2446 struct iw_request_info *info,
2447 union iwreq_data *wrqu, char *extra)
2448{
2449 int ret;
2450
2451 vos_ssr_protect(__func__);
2452 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2453 vos_ssr_unprotect(__func__);
2454
2455 return ret;
2456}
2457
2458int
2459static __iw_softap_set_max_tx_power(struct net_device *dev,
2460 struct iw_request_info *info,
2461 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002462{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302463 hdd_adapter_t *pHostapdAdapter;
2464 tHalHandle hHal;
2465 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002466 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302467 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002468 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2469 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2470
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302471 ENTER();
2472
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302473 pHostapdAdapter = (netdev_priv(dev));
2474 if (NULL == pHostapdAdapter)
2475 {
2476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2477 "%s: Adapter is NULL",__func__);
2478 return -EINVAL;
2479 }
2480 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2481 ret = wlan_hdd_validate_context(pHddCtx);
2482 if (0 != ret)
2483 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302484 return ret;
2485 }
2486 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2487 if (NULL == hHal)
2488 {
2489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2490 "%s: Hal Context is NULL",__func__);
2491 return -EINVAL;
2492 }
schang86c22c42013-03-13 18:41:24 -07002493 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002494 return -ENOMEM;
2495
Leo Changd37675a2013-08-01 13:19:45 -07002496 /* Assign correct slef MAC address */
2497 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2498 VOS_MAC_ADDR_SIZE);
2499 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2500 VOS_MAC_ADDR_SIZE);
2501
schang86c22c42013-03-13 18:41:24 -07002502 set_value = value[0];
2503 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2504 {
2505 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002506 __func__);
schang86c22c42013-03-13 18:41:24 -07002507 return -EIO;
2508 }
2509
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302510 EXIT();
schang86c22c42013-03-13 18:41:24 -07002511 return 0;
2512}
2513
2514int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302515static iw_softap_set_max_tx_power(struct net_device *dev,
2516 struct iw_request_info *info,
2517 union iwreq_data *wrqu, char *extra)
2518{
2519 int ret;
2520
2521 vos_ssr_protect(__func__);
2522 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2523 vos_ssr_unprotect(__func__);
2524
2525 return ret;
2526}
2527
2528
2529int
2530static __iw_display_data_path_snapshot(struct net_device *dev,
2531 struct iw_request_info *info,
2532 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302533{
2534
2535 /* Function intitiating dumping states of
2536 * HDD(WMM Tx Queues)
2537 * TL State (with Per Client infor)
2538 * DXE Snapshot (Called at the end of TL Snapshot)
2539 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302540 hdd_adapter_t *pHostapdAdapter;
2541 hdd_context_t *pHddCtx;
2542 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302543
2544 ENTER();
2545
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302546 pHostapdAdapter = (netdev_priv(dev));
2547 if (NULL == pHostapdAdapter)
2548 {
2549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2550 "%s: Adapter is NULL",__func__);
2551 return -EINVAL;
2552 }
2553 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2554 ret = wlan_hdd_validate_context(pHddCtx);
2555 if (0 != ret)
2556 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302557 return ret;
2558 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302559 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302560 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302561
2562 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302563 return 0;
2564}
2565
2566int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302567static iw_display_data_path_snapshot(struct net_device *dev,
2568 struct iw_request_info *info,
2569 union iwreq_data *wrqu, char *extra)
2570{
2571 int ret;
2572
2573 vos_ssr_protect(__func__);
2574 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2575 vos_ssr_unprotect(__func__);
2576
2577 return ret;
2578}
2579
2580int
2581static __iw_softap_set_tx_power(struct net_device *dev,
2582 struct iw_request_info *info,
2583 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002584{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302585 hdd_adapter_t *pHostapdAdapter;
2586 hdd_context_t *pHddCtx;
2587 v_CONTEXT_t pVosContext;
2588 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002589 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302590 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002591 ptSapContext pSapCtx = NULL;
2592
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302593 ENTER();
2594
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302595 pHostapdAdapter = (netdev_priv(dev));
2596 if (NULL == pHostapdAdapter)
2597 {
2598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2599 "%s: Adapter is NULL",__func__);
2600 return -EINVAL;
2601 }
2602 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2603 ret = wlan_hdd_validate_context(pHddCtx);
2604 if (0 != ret)
2605 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302606 return ret;
2607 }
2608 pVosContext = pHddCtx->pvosContext;
2609 if (NULL == pVosContext)
2610 {
2611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2612 "%s: Vos Context is NULL",__func__);
2613 return -EINVAL;
2614 }
2615 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2616 if (NULL == hHal)
2617 {
2618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2619 "%s: Hal Context is NULL",__func__);
2620 return -EINVAL;
2621 }
schang86c22c42013-03-13 18:41:24 -07002622 if (NULL == value)
2623 return -ENOMEM;
2624
2625 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2626 if (NULL == pSapCtx)
2627 {
2628 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2629 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2630 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002631 }
2632
2633 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002634 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002635 {
schang86c22c42013-03-13 18:41:24 -07002636 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002637 __func__);
2638 return -EIO;
2639 }
2640
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302641 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002642 return 0;
2643}
2644
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302645int
2646static iw_softap_set_tx_power(struct net_device *dev,
2647 struct iw_request_info *info,
2648 union iwreq_data *wrqu, char *extra)
2649{
2650 int ret;
2651
2652 vos_ssr_protect(__func__);
2653 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2654 vos_ssr_unprotect(__func__);
2655
2656 return ret;
2657}
2658
Kiet Lambcf38522013-10-26 18:28:27 +05302659/**---------------------------------------------------------------------------
2660
2661 \brief iw_softap_set_trafficmonitor() -
2662 This function dynamically enable/disable traffic monitor functonality
2663 the command iwpriv wlanX setTrafficMon <value>.
2664
2665 \param - dev - Pointer to the net device.
2666 - addr - Pointer to the sockaddr.
2667 \return - 0 for success, non zero for failure
2668
2669 --------------------------------------------------------------------------*/
2670
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302671static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302674{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302675 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302676 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302677 hdd_context_t *pHddCtx;
2678 int status;
2679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302680 ENTER();
2681
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302682 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302683 if (NULL == pAdapter)
2684 {
2685 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2686 "%s: HDD adapter is Null", __func__);
2687 return -ENODEV;
2688 }
2689
2690 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2691
2692 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302693 if (0 != status)
2694 {
Kiet Lambcf38522013-10-26 18:28:27 +05302695 return status;
2696 }
2697
2698 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2699
2700 if (NULL == isSetTrafficMon)
2701 {
2702 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2703 "%s: Invalid SAP pointer from extra", __func__);
2704 return -ENOMEM;
2705 }
2706
2707 if (TRUE == *isSetTrafficMon)
2708 {
2709 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2710 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2711 {
2712 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2713 "%s: failed to Start Traffic Monitor timer ", __func__ );
2714 return -EIO;
2715 }
2716 }
2717 else if (FALSE == *isSetTrafficMon)
2718 {
2719 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2720 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2721 {
2722 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2723 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2724 return -EIO;
2725 }
2726
2727 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302728
2729 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302730 return 0;
2731}
2732
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302733static int iw_softap_set_trafficmonitor(struct net_device *dev,
2734 struct iw_request_info *info,
2735 union iwreq_data *wrqu, char *extra)
2736{
2737 int ret;
2738
2739 vos_ssr_protect(__func__);
2740 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2741 vos_ssr_unprotect(__func__);
2742
2743 return ret;
2744}
2745
Jeff Johnson295189b2012-06-20 16:38:30 -07002746#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2747
2748int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302749static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2750 struct iw_request_info *info,
2751 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002752{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302753 hdd_adapter_t *pHostapdAdapter;
2754 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302755 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002756 char *buf;
2757 int cnt = 0;
2758 int left;
2759 int ret = 0;
2760 /* maclist_index must be u32 to match userspace */
2761 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302762 v_CONTEXT_t pVosContext = NULL;
2763 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302764
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302765 ENTER();
2766
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302767 pHostapdAdapter = (netdev_priv(dev));
2768 if (NULL == pHostapdAdapter)
2769 {
2770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2771 "%s: Adapter is NULL",__func__);
2772 return -EINVAL;
2773 }
2774 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2775 ret = wlan_hdd_validate_context(pHddCtx);
2776 if (0 != ret)
2777 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302778 return ret;
2779 }
2780
Jeff Johnson224f3702014-03-26 11:09:47 -07002781 /*
2782 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2783 * number, and even numbered iocts are supposed to have "set"
2784 * semantics. Hence the wireless extensions support in the kernel
2785 * won't correctly copy the result to userspace, so the ioctl
2786 * handler itself must copy the data. Output format is 32-bit
2787 * record length, followed by 0 or more 6-byte STA MAC addresses.
2788 *
2789 * Further note that due to the incorrect semantics, the "iwpriv"
2790 * userspace application is unable to correctly invoke this API,
2791 * hence it is not registered in the hostapd_private_args. This
2792 * API can only be invoked by directly invoking the ioctl() system
2793 * call.
2794 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002795
Jeff Johnson224f3702014-03-26 11:09:47 -07002796 /* make sure userspace allocated a reasonable buffer size */
2797 if (wrqu->data.length < sizeof(maclist_index)) {
2798 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2799 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002801
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302802 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2803 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2804 if(pSapCtx == NULL){
2805 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2806 FL("psapCtx is NULL"));
2807 return -EFAULT;
2808 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302809
2810 /* allocate local buffer to build the response */
2811 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2812 if (!buf) {
2813 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2814 return -ENOMEM;
2815 }
2816
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302817 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002818 /* start indexing beyond where the record count will be written */
2819 maclist_index = sizeof(maclist_index);
2820 left = wrqu->data.length - maclist_index;
2821
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302822 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002823 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2824 if ((pStaInfo[cnt].isUsed) &&
2825 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2826 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2827 VOS_MAC_ADDR_SIZE);
2828 maclist_index += VOS_MAC_ADDR_SIZE;
2829 left -= VOS_MAC_ADDR_SIZE;
2830 }
2831 cnt++;
2832 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302833 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002834
2835 *((u32 *)buf) = maclist_index;
2836 wrqu->data.length = maclist_index;
2837 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2838 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2839 ret = -EFAULT;
2840 }
2841 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302842
2843 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002844 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002845}
2846
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302847int
2848static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2849 struct iw_request_info *info,
2850 union iwreq_data *wrqu, char *extra)
2851{
2852 int ret;
2853
2854 vos_ssr_protect(__func__);
2855 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2856 vos_ssr_unprotect(__func__);
2857
2858 return ret;
2859}
2860
Jeff Johnson295189b2012-06-20 16:38:30 -07002861/* Usage:
2862 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2863 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2864 while using this ioctl
2865
2866 Syntax:
2867 iwpriv softap.0 disassoc_sta <6 octet mac address>
2868
2869 e.g.
2870 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2871 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2872*/
2873
2874int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302875static __iw_softap_disassoc_sta(struct net_device *dev,
2876 struct iw_request_info *info,
2877 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002878{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302879 hdd_adapter_t *pHostapdAdapter;
2880 hdd_context_t *pHddCtx;
2881 v_U8_t *peerMacAddr;
2882 int ret = 0;
2883
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302885
2886 if (!capable(CAP_NET_ADMIN)) {
2887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2888 FL("permission check failed"));
2889 return -EPERM;
2890 }
2891
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302892 pHostapdAdapter = (netdev_priv(dev));
2893 if (NULL == pHostapdAdapter)
2894 {
2895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2896 "%s: Adapter is NULL",__func__);
2897 return -EINVAL;
2898 }
2899 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2900 ret = wlan_hdd_validate_context(pHddCtx);
2901 if (0 != ret)
2902 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302903 return ret;
2904 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302905 /* iwpriv tool or framework calls this ioctl with
2906 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302908 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002909
Arif Hussain24bafea2013-11-15 15:10:03 -08002910 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2911 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2913 EXIT();
2914 return 0;
2915}
2916
2917int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302918static iw_softap_disassoc_sta(struct net_device *dev,
2919 struct iw_request_info *info,
2920 union iwreq_data *wrqu, char *extra)
2921{
2922 int ret;
2923
2924 vos_ssr_protect(__func__);
2925 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2926 vos_ssr_unprotect(__func__);
2927
2928 return ret;
2929}
2930
2931int
2932static __iw_softap_ap_stats(struct net_device *dev,
2933 struct iw_request_info *info,
2934 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002935{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302936 hdd_adapter_t *pHostapdAdapter;
2937 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 WLANTL_TRANSFER_STA_TYPE statBuffer;
2939 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302940 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002941
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302942 ENTER();
2943
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302944 pHostapdAdapter = (netdev_priv(dev));
2945 if (NULL == pHostapdAdapter)
2946 {
2947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2948 "%s: Adapter is NULL",__func__);
2949 return -EINVAL;
2950 }
2951 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2952 ret = wlan_hdd_validate_context(pHddCtx);
2953 if (0 != ret)
2954 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302955 return ret;
2956 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002957 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002958 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2959 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002960
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302961 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002962 if(NULL == pstatbuf) {
2963 hddLog(LOG1, "unable to allocate memory");
2964 return -ENOMEM;
2965 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302966
2967 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002968 "RUF=%d RMF=%d RBF=%d "
2969 "RUB=%d RMB=%d RBB=%d "
2970 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302971 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002972 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2973 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2974 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2975 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2976 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2977 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002978
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302979 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002980 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2981 kfree(pstatbuf);
2982 return -EFAULT;
2983 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302984
2985 strlcpy(extra, pstatbuf, len);
2986 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002987 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302988
2989 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 return 0;
2991}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302992int
2993static __iw_softap_ap_get_stats(struct net_device *dev,
2994 struct iw_request_info *info,
2995 union iwreq_data *wrqu, char *extra)
2996{
2997 hdd_adapter_t *pAdapter;
2998 hdd_tx_rx_stats_t *pStats;
2999
3000 ENTER();
3001 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3002 if (NULL == pAdapter)
3003 {
3004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3005 "%s: Adapter is NULL",__func__);
3006 return -EINVAL;
3007 }
3008
3009 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3010 snprintf(extra, QCSAP_MAX_STR_LEN,
3011 "\nTransmit"
3012 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3013 "\n dropped BK %u, BE %u, VI %u, VO %u"
3014 "\n classified BK %u, BE %u, VI %u, VO %u"
3015 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3016 "\n queued BK %u, BE %u, VI %u, VO %u"
3017 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3018 "\ndequeued %u, depressured %u, deque-depressured %u,\
3019 completed %u, flushed %u"
3020 "\n fetched BK %u, BE %u, VI %u, VO %u"
3021 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3022 "\n depressured BK %u, BE %u, VI %u, VO %u"
3023 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3024 "\n flushed BK %u, BE %u, VI %u, VO %u"
3025 "\n\nReceive"
3026 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3027 "\n\nResetsStats"
3028 "\n",
3029 pStats->txXmitCalled,
3030 pStats->txXmitDropped,
3031 pStats->txXmitBackPressured,
3032 pStats->txXmitQueued,
3033
3034 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3035 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3036 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3037 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3038
3039 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3040 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3041 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3042 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3043
3044 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3045 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3046 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3047 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3048
3049 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3050 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3051 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3052 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3053
3054 pStats->txFetched,
3055 pStats->txFetchEmpty,
3056 pStats->txFetchLowResources,
3057 pStats->txFetchDequeueError,
3058
3059 pStats->txFetchDequeued,
3060 pStats->txFetchDePressured,
3061 pStats->txDequeDePressured,
3062 pStats->txCompleted,
3063 pStats->txFlushed,
3064
3065 pStats->txFetchedAC[WLANTL_AC_BK],
3066 pStats->txFetchedAC[WLANTL_AC_BE],
3067 pStats->txFetchedAC[WLANTL_AC_VI],
3068 pStats->txFetchedAC[WLANTL_AC_VO],
3069
3070 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3071 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3072 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3073 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3074
3075 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3076 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3077 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3078 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3079
3080 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3081 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3082 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3083 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3084
3085 pStats->txFlushedAC[WLANTL_AC_BK],
3086 pStats->txFlushedAC[WLANTL_AC_BE],
3087 pStats->txFlushedAC[WLANTL_AC_VI],
3088 pStats->txFlushedAC[WLANTL_AC_VO],
3089
3090 pStats->rxChains,
3091 pStats->rxPackets,
3092 pStats->rxDropped,
3093 pStats->rxDelivered,
3094 pStats->rxRefused
3095 );
3096
3097 wrqu->data.length = strlen(extra) + 1;
3098
3099 return 0;
3100}
3101
3102int
3103static __iw_softap_ap_clear_stats(struct net_device *dev,
3104 struct iw_request_info *info,
3105 union iwreq_data *wrqu, char *extra)
3106{
3107 hdd_adapter_t *pAdapter;
3108
3109 ENTER();
3110
3111 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3112 if (NULL == pAdapter)
3113 {
3114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3115 "%s: Adapter is NULL",__func__);
3116 return -EINVAL;
3117 }
3118
3119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3120 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3121 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3122 return 0;
3123}
3124
3125
3126int
3127static iw_softap_get_stats(struct net_device *dev,
3128 struct iw_request_info *info,
3129 union iwreq_data *wrqu, char *extra)
3130{
3131 int ret;
3132 vos_ssr_protect(__func__);
3133 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3134 vos_ssr_unprotect(__func__);
3135 return ret;
3136}
3137
3138int
3139static iw_softap_clear_stats(struct net_device *dev,
3140 struct iw_request_info *info,
3141 union iwreq_data *wrqu, char *extra)
3142{
3143 int ret;
3144 vos_ssr_protect(__func__);
3145 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3146 vos_ssr_unprotect(__func__);
3147 return ret;
3148}
Jeff Johnson295189b2012-06-20 16:38:30 -07003149
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303150int
3151static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 struct iw_request_info *info,
3153 union iwreq_data *wrqu, char *extra)
3154{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303155 int ret;
3156
3157 vos_ssr_protect(__func__);
3158 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3159 vos_ssr_unprotect(__func__);
3160
3161 return ret;
3162}
3163
3164static int __iw_softap_set_channel_range(struct net_device *dev,
3165 struct iw_request_info *info,
3166 union iwreq_data *wrqu, char *extra)
3167{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303168 hdd_adapter_t *pHostapdAdapter;
3169 tHalHandle hHal;
3170 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 int *value = (int *)extra;
3172 int startChannel = value[0];
3173 int endChannel = value[1];
3174 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003175 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 int ret = 0; /* success */
3177
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303178 ENTER();
3179
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303180 if (!capable(CAP_NET_ADMIN))
3181 {
3182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3183 FL("permission check failed"));
3184 return -EPERM;
3185 }
3186
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303187 pHostapdAdapter = (netdev_priv(dev));
3188 if (NULL == pHostapdAdapter)
3189 {
3190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3191 "%s: Adapter is NULL",__func__);
3192 return -EINVAL;
3193 }
3194 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3195 ret = wlan_hdd_validate_context(pHddCtx);
3196 if (0 != ret)
3197 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303198 return ret;
3199 }
3200 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3201 if (NULL == hHal)
3202 {
3203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3204 "%s: Hal Context is NULL",__func__);
3205 return -EINVAL;
3206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3208 if(status != VOS_STATUS_SUCCESS)
3209 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003210 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 startChannel,endChannel, band);
3212 ret = -EINVAL;
3213 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003214
3215 pHddCtx->is_dynamic_channel_range_set = 1;
3216
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303217 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 return ret;
3219}
3220
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303221static int iw_softap_set_channel_range(struct net_device *dev,
3222 struct iw_request_info *info,
3223 union iwreq_data *wrqu, char *extra)
3224{
3225 int ret;
3226
3227 vos_ssr_protect(__func__);
3228 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3229 vos_ssr_unprotect(__func__);
3230
3231 return ret;
3232}
3233
3234
3235int __iw_softap_get_channel_list(struct net_device *dev,
3236 struct iw_request_info *info,
3237 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003238{
3239 v_U32_t num_channels = 0;
3240 v_U8_t i = 0;
3241 v_U8_t bandStartChannel = RF_CHAN_1;
3242 v_U8_t bandEndChannel = RF_CHAN_165;
3243 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303244 hdd_adapter_t *pHostapdAdapter;
3245 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003248 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303249 hdd_context_t *pHddCtx;
3250 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303251
3252 ENTER();
3253
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303254 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3255 if (NULL == pHostapdAdapter)
3256 {
3257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3258 "%s: Adapter is NULL",__func__);
3259 return -EINVAL;
3260 }
3261 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3262 ret = wlan_hdd_validate_context(pHddCtx);
3263 if (0 != ret)
3264 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303265 return ret;
3266 }
3267 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3268 if (NULL == hHal)
3269 {
3270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3271 "%s: Hal Context is NULL",__func__);
3272 return -EINVAL;
3273 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003274 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3275 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003276 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003277 return -EIO;
3278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 wrqu->data.length = sizeof(tChannelListInfo);
3280 ENTER();
3281
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003282 if (eCSR_BAND_24 == curBand)
3283 {
3284 bandStartChannel = RF_CHAN_1;
3285 bandEndChannel = RF_CHAN_14;
3286 }
3287 else if (eCSR_BAND_5G == curBand)
3288 {
3289 bandStartChannel = RF_CHAN_36;
3290 bandEndChannel = RF_CHAN_165;
3291 }
3292
Arif Hussain6d2a3322013-11-17 19:50:10 -08003293 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303294 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003295 bandStartChannel, bandEndChannel );
3296
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3298 {
3299 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3300 {
3301 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3302 num_channels++;
3303 }
3304 }
3305
3306 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3307
3308 temp_num_channels = num_channels;
3309
3310 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3311 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303312 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003313 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 }
3315
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303316 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3317 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 {
3319 for(i = 0; i < temp_num_channels; i++)
3320 {
3321
3322 if((channel_list->channels[i] > 35) &&
3323 (channel_list->channels[i] < 49))
3324 {
3325 vos_mem_move(&channel_list->channels[i],
3326 &channel_list->channels[i+1],
3327 temp_num_channels - (i-1));
3328 num_channels--;
3329 temp_num_channels--;
3330 i--;
3331 }
3332 }
3333 }
3334
Arif Hussain6d2a3322013-11-17 19:50:10 -08003335 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003336
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 channel_list->num_channels = num_channels;
3338 EXIT();
3339
3340 return 0;
3341}
3342
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303343int iw_softap_get_channel_list(struct net_device *dev,
3344 struct iw_request_info *info,
3345 union iwreq_data *wrqu, char *extra)
3346{
3347 int ret;
3348
3349 vos_ssr_protect(__func__);
3350 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3351 vos_ssr_unprotect(__func__);
3352
3353 return ret;
3354}
3355
3356static
3357int __iw_get_genie(struct net_device *dev,
3358 struct iw_request_info *info,
3359 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003360{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303361 hdd_adapter_t *pHostapdAdapter;
3362 hdd_context_t *pHddCtx;
3363 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303364 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3366 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303367 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303368
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303370
3371 pHostapdAdapter = (netdev_priv(dev));
3372 if (NULL == pHostapdAdapter)
3373 {
3374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3375 "%s: Adapter is NULL",__func__);
3376 return -EINVAL;
3377 }
3378 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3379 ret = wlan_hdd_validate_context(pHddCtx);
3380 if (0 != ret)
3381 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303382 return ret;
3383 }
3384 pVosContext = pHddCtx->pvosContext;
3385 if (NULL == pVosContext)
3386 {
3387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3388 "%s: vos context is not valid ",__func__);
3389 return -EINVAL;
3390 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003391 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3393 status = WLANSap_getstationIE_information(pVosContext,
3394 &length,
3395 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303396
3397 if (VOS_STATUS_SUCCESS != status) {
3398 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003399 return -EFAULT;
3400 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303401
Arif Hussained667642013-10-27 23:01:14 -07003402 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303403 if (length > DOT11F_IE_RSN_MAX_LEN) {
3404 hddLog(LOGE,
3405 FL("invalid buffer length length:%d"), length);
3406 return -E2BIG;
3407 }
3408
3409 vos_mem_copy(extra, genIeBytes, length);
3410
3411 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3412
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 EXIT();
3414 return 0;
3415}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303416
3417static
3418int iw_get_genie(struct net_device *dev,
3419 struct iw_request_info *info,
3420 union iwreq_data *wrqu, char *extra)
3421{
3422 int ret;
3423
3424 vos_ssr_protect(__func__);
3425 ret = __iw_get_genie(dev, info, wrqu, extra);
3426 vos_ssr_unprotect(__func__);
3427
3428 return ret;
3429}
3430
3431static
3432int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3433 struct iw_request_info *info,
3434 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003435{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303436 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003437 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303438 hdd_ap_ctx_t *pHddApCtx;
3439 hdd_context_t *pHddCtx;
3440 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003443
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303444 pHostapdAdapter = (netdev_priv(dev));
3445 if (NULL == pHostapdAdapter)
3446 {
3447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3448 "%s: Adapter is NULL",__func__);
3449 return -EINVAL;
3450 }
3451 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3452 ret = wlan_hdd_validate_context(pHddCtx);
3453 if (0 != ret)
3454 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303455 return ret;
3456 }
3457 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3458 if (NULL == pHddApCtx)
3459 {
3460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3461 "%s: AP context is NULL",__func__);
3462 return -EINVAL;
3463 }
3464
Arif Hussain6d2a3322013-11-17 19:50:10 -08003465 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003466 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3467
3468 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3469 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3470 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3471 WPSPBCProbeReqIEs.probeReqIELen);
3472 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3473 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3474 sizeof(v_MACADDR_t));
3475 if (copy_to_user(wrqu->data.pointer,
3476 (void *)&WPSPBCProbeReqIEs,
3477 sizeof(WPSPBCProbeReqIEs)))
3478 {
3479 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3480 return -EFAULT;
3481 }
3482 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003483 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003484 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 up(&pHddApCtx->semWpsPBCOverlapInd);
3486 EXIT();
3487 return 0;
3488}
3489
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303490static
3491int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3492 struct iw_request_info *info,
3493 union iwreq_data *wrqu, char *extra)
3494{
3495 int ret;
3496
3497 vos_ssr_protect(__func__);
3498 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3499 vos_ssr_unprotect(__func__);
3500
3501 return ret;
3502}
3503
Jeff Johnson295189b2012-06-20 16:38:30 -07003504/**---------------------------------------------------------------------------
3505
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303506 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 This function sets the auth type received from the wpa_supplicant.
3508
3509 \param - dev - Pointer to the net device.
3510 - info - Pointer to the iw_request_info.
3511 - wrqu - Pointer to the iwreq_data.
3512 - extra - Pointer to the data.
3513 \return - 0 for success, non zero for failure
3514
3515 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303516int __iw_set_auth_hostap(struct net_device *dev,
3517 struct iw_request_info *info,
3518 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003519{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303520 hdd_adapter_t *pAdapter;
3521 hdd_context_t *pHddCtx;
3522 hdd_wext_state_t *pWextState;
3523 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303524
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303526
3527 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3528 if (NULL == pAdapter)
3529 {
3530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3531 "%s: Adapter is NULL",__func__);
3532 return -EINVAL;
3533 }
3534
3535 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3536 ret = wlan_hdd_validate_context(pHddCtx);
3537 if (0 != ret)
3538 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303539 return ret;
3540 }
3541 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3542 if (NULL == pWextState)
3543 {
3544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3545 "%s: pWextState is NULL",__func__);
3546 return -EINVAL;
3547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 switch(wrqu->param.flags & IW_AUTH_INDEX)
3549 {
3550 case IW_AUTH_TKIP_COUNTERMEASURES:
3551 {
3552 if(wrqu->param.value) {
3553 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3554 "Counter Measure started %d", wrqu->param.value);
3555 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303556 }
3557 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3559 "Counter Measure stopped=%d", wrqu->param.value);
3560 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3561 }
3562
3563 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3564 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303567
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303569
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003570 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 wrqu->param.flags & IW_AUTH_INDEX);
3572 break;
3573 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303574
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 EXIT();
3576 return 0;
3577}
3578
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303579int iw_set_auth_hostap(struct net_device *dev,
3580 struct iw_request_info *info,
3581 union iwreq_data *wrqu,char *extra)
3582{
3583 int ret;
3584
3585 vos_ssr_protect(__func__);
3586 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3587 vos_ssr_unprotect(__func__);
3588
3589 return ret;
3590}
3591
3592static int __iw_set_ap_encodeext(struct net_device *dev,
3593 struct iw_request_info *info,
3594 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003595{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303596 hdd_adapter_t *pHostapdAdapter;
3597 v_CONTEXT_t pVosContext;
3598 hdd_context_t *pHddCtx;
3599 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003600 int retval = 0;
3601 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3603 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3604 int key_index;
3605 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303606 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003607// tCsrRoamRemoveKey RemoveKey;
3608 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303609
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303610 ENTER();
3611 pHostapdAdapter = (netdev_priv(dev));
3612 if (NULL == pHostapdAdapter)
3613 {
3614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3615 "%s: Adapter is NULL",__func__);
3616 return -EINVAL;
3617 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003618
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303619 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3620 retval = wlan_hdd_validate_context(pHddCtx);
3621 if (0 != retval)
3622 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303623 return retval;
3624 }
3625 pVosContext = pHddCtx->pvosContext;
3626 if (NULL == pVosContext)
3627 {
3628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3629 "%s: pVosContext is NULL",__func__);
3630 return -EINVAL;
3631 }
3632 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3633 if (NULL == pHddApCtx)
3634 {
3635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3636 "%s: AP Context is NULL",__func__);
3637 return -EINVAL;
3638 }
3639
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303641
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303643
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 /*Convert from 1-based to 0-based keying*/
3645 key_index--;
3646 }
3647 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303648#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 /*Set the encrytion type to NONE*/
3650#if 0
3651 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3652#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303653
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 RemoveKey.keyId = key_index;
3655 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3656 /*Key direction for group is RX only*/
3657 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3658 }
3659 else {
3660 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3661 }
3662 switch(ext->alg)
3663 {
3664 case IW_ENCODE_ALG_NONE:
3665 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3666 break;
3667 case IW_ENCODE_ALG_WEP:
3668 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3669 break;
3670 case IW_ENCODE_ALG_TKIP:
3671 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 case IW_ENCODE_ALG_CCMP:
3674 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3675 break;
3676 default:
3677 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3678 break;
3679 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003680 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 -07003681 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003683 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003685 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3686 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 {
3688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003689 __LINE__, vstatus );
3690 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003692#endif
3693 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
Jeff Johnson43971f52012-07-17 12:26:56 -07003695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003696
3697 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3698
3699 setKey.keyId = key_index;
3700 setKey.keyLength = ext->key_len;
3701
3702 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3703 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3704 }
3705
3706 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3707 /*Key direction for group is RX only*/
3708 setKey.keyDirection = eSIR_RX_ONLY;
3709 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3710 }
3711 else {
3712
3713 setKey.keyDirection = eSIR_TX_RX;
3714 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3715 }
3716 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3717 {
3718 setKey.keyDirection = eSIR_TX_DEFAULT;
3719 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3720 }
3721
3722 /*For supplicant pae role is zero*/
3723 setKey.paeRole = 0;
3724
3725 switch(ext->alg)
3726 {
3727 case IW_ENCODE_ALG_NONE:
3728 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3729 break;
3730
3731 case IW_ENCODE_ALG_WEP:
3732 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3733 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003734 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 break;
3736
3737 case IW_ENCODE_ALG_TKIP:
3738 {
3739 v_U8_t *pKey = &setKey.Key[0];
3740
3741 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3742
3743 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3744
3745 /*Supplicant sends the 32bytes key in this order
3746
3747 |--------------|----------|----------|
3748 | Tk1 |TX-MIC | RX Mic |
3749 |--------------|----------|----------|
3750 <---16bytes---><--8bytes--><--8bytes-->
3751
3752 */
3753 /*Sme expects the 32 bytes key to be in the below order
3754
3755 |--------------|----------|----------|
3756 | Tk1 |RX-MIC | TX Mic |
3757 |--------------|----------|----------|
3758 <---16bytes---><--8bytes--><--8bytes-->
3759 */
3760 /* Copy the Temporal Key 1 (TK1) */
3761 vos_mem_copy(pKey,ext->key,16);
3762
3763 /*Copy the rx mic first*/
3764 vos_mem_copy(&pKey[16],&ext->key[24],8);
3765
3766 /*Copy the tx mic */
3767 vos_mem_copy(&pKey[24],&ext->key[16],8);
3768
3769 }
3770 break;
3771
3772 case IW_ENCODE_ALG_CCMP:
3773 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3774 break;
3775
3776 default:
3777 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3778 break;
3779 }
3780
3781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303782 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 setKey.keyId);
3784 for(i=0; i< ext->key_len; i++)
3785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3786 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003787
3788 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3789 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 {
3791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003792 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3793 retval = -EINVAL;
3794 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303795
3796 EXIT();
3797 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003798}
Jeff Johnson43971f52012-07-17 12:26:56 -07003799
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303800static int iw_set_ap_encodeext(struct net_device *dev,
3801 struct iw_request_info *info,
3802 union iwreq_data *wrqu, char *extra)
3803{
3804 int ret;
3805
3806 vos_ssr_protect(__func__);
3807 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3808 vos_ssr_unprotect(__func__);
3809
3810 return ret;
3811}
Jeff Johnson43971f52012-07-17 12:26:56 -07003812
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303813static int __iw_set_ap_mlme(struct net_device *dev,
3814 struct iw_request_info *info,
3815 union iwreq_data *wrqu,
3816 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003817{
3818#if 0
3819 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3820 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3821
3822 ENTER();
3823
3824 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3825 switch (mlme->cmd) {
3826 case IW_MLME_DISASSOC:
3827 case IW_MLME_DEAUTH:
3828 hddLog(LOG1, "Station disassociate");
3829 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3830 {
3831 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3832
3833 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3834 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3835
3836 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3837
3838 //clear all the reason codes
3839 if (status != 0)
3840 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003841 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 }
3843
3844 netif_stop_queue(dev);
3845 netif_carrier_off(dev);
3846 }
3847 else
3848 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003849 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 -07003850 }
3851 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003852 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 return -EINVAL;
3854 }//end of switch
3855 EXIT();
3856#endif
3857 return 0;
3858// return status;
3859}
3860
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303861static int iw_set_ap_mlme(struct net_device *dev,
3862 struct iw_request_info *info,
3863 union iwreq_data *wrqu,
3864 char *extra)
3865{
3866 int ret;
3867
3868 vos_ssr_protect(__func__);
3869 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3870 vos_ssr_unprotect(__func__);
3871
3872 return ret;
3873}
3874
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303875static int __iw_get_ap_rts_threshold(struct net_device *dev,
3876 struct iw_request_info *info,
3877 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003878{
3879 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3880 v_U32_t status = 0;
3881
3882 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3883
3884 return status;
3885}
3886
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303887static int iw_get_ap_rts_threshold(struct net_device *dev,
3888 struct iw_request_info *info,
3889 union iwreq_data *wrqu, char *extra)
3890{
3891 int ret;
3892
3893 vos_ssr_protect(__func__);
3894 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3895 vos_ssr_unprotect(__func__);
3896
3897 return ret;
3898}
3899
3900static int __iw_get_ap_frag_threshold(struct net_device *dev,
3901 struct iw_request_info *info,
3902 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003903{
3904 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3905 v_U32_t status = 0;
3906
3907 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3908
3909 return status;
3910}
3911
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303912static int iw_get_ap_frag_threshold(struct net_device *dev,
3913 struct iw_request_info *info,
3914 union iwreq_data *wrqu, char *extra)
3915{
3916 int ret;
3917
3918 vos_ssr_protect(__func__);
3919 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3920 vos_ssr_unprotect(__func__);
3921
3922 return ret;
3923}
3924
3925static int __iw_get_ap_freq(struct net_device *dev,
3926 struct iw_request_info *info,
3927 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003928{
Jeff Johnsone7245742012-09-05 17:12:55 -07003929 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303930 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 tHalHandle hHal;
3932 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303933 hdd_ap_ctx_t *pHddApCtx;
3934 hdd_context_t *pHddCtx;
3935 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003936
3937 ENTER();
3938
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303939 pHostapdAdapter = (netdev_priv(dev));
3940 if (NULL == pHostapdAdapter)
3941 {
3942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3943 "%s: Adapter is NULL",__func__);
3944 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303946 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3947 ret = wlan_hdd_validate_context(pHddCtx);
3948 if (0 != ret)
3949 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303950 return ret;
3951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303953 if (NULL == pHostapdState)
3954 {
3955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3956 "%s: pHostapdState is NULL",__func__);
3957 return -EINVAL;
3958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303960 if (NULL == hHal)
3961 {
3962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3963 "%s: Hal Context is NULL",__func__);
3964 return -EINVAL;
3965 }
3966 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3967 if (NULL == pHddApCtx)
3968 {
3969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3970 "%s: AP context is NULL",__func__);
3971 return -EINVAL;
3972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 if(pHostapdState->bssState == BSS_STOP )
3974 {
3975 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3976 != eHAL_STATUS_SUCCESS)
3977 {
c_hpothuffdb5272013-10-02 16:42:35 +05303978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3979 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 return -EIO;
3981 }
3982 else
3983 {
3984 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003985 if( TRUE == status)
3986 {
3987 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3988 * iwlist & iwconfig command shows frequency into proper
3989 * format (2.412 GHz instead of 246.2 MHz)*/
3990 fwrq->m = freq;
3991 fwrq->e = MHZ;
3992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 }
3994 }
3995 else
3996 {
3997 channel = pHddApCtx->operatingChannel;
3998 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003999 if( TRUE == status)
4000 {
4001 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4002 * iwlist & iwconfig command shows frequency into proper
4003 * format (2.412 GHz instead of 246.2 MHz)*/
4004 fwrq->m = freq;
4005 fwrq->e = MHZ;
4006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304008
4009 EXIT();
4010 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004011}
4012
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304013static int iw_get_ap_freq(struct net_device *dev,
4014 struct iw_request_info *info,
4015 struct iw_freq *fwrq, char *extra)
4016{
4017 int ret;
4018
4019 vos_ssr_protect(__func__);
4020 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4021 vos_ssr_unprotect(__func__);
4022
4023 return ret;
4024}
4025
4026static int __iw_get_mode(struct net_device *dev,
4027 struct iw_request_info *info,
4028 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304029{
4030 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304031 hdd_adapter_t *pAdapter;
4032 hdd_context_t *pHddCtx;
4033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304034 ENTER();
4035
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304036 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4037 if (NULL == pAdapter)
4038 {
4039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4040 "%s: Adapter is NULL",__func__);
4041 return -EINVAL;
4042 }
4043 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4044 status = wlan_hdd_validate_context(pHddCtx);
4045 if (0 != status)
4046 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304047 return status;
4048 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304049
4050 wrqu->mode = IW_MODE_MASTER;
4051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304052 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304053 return status;
4054}
4055
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304056static int iw_get_mode(struct net_device *dev,
4057 struct iw_request_info *info,
4058 union iwreq_data *wrqu, char *extra)
4059{
4060 int ret;
4061
4062 vos_ssr_protect(__func__);
4063 ret = __iw_get_mode(dev, info, wrqu, extra);
4064 vos_ssr_unprotect(__func__);
4065
4066 return ret;
4067}
4068
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304069
4070static int __iw_softap_stopbss(struct net_device *dev,
4071 struct iw_request_info *info,
4072 union iwreq_data *wrqu,
4073 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304077 hdd_context_t *pHddCtx = NULL;
4078
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304080 pHostapdAdapter = (netdev_priv(dev));
4081 if (NULL == pHostapdAdapter)
4082 {
4083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4084 "%s: Adapter is NULL",__func__);
4085 return -EINVAL;
4086 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304087 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4088 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304089 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304090 return status;
4091 }
4092
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304093 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4096 {
4097 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4098
4099 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304100
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304102 {
4103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004104 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 VOS_ASSERT(0);
4106 }
4107 }
4108 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304109 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 }
4111 EXIT();
4112 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4113}
4114
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304115static int iw_softap_stopbss(struct net_device *dev,
4116 struct iw_request_info *info,
4117 union iwreq_data *wrqu,
4118 char *extra)
4119{
4120 int ret;
4121
4122 vos_ssr_protect(__func__);
4123 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4124 vos_ssr_unprotect(__func__);
4125
4126 return ret;
4127}
4128
4129static int __iw_softap_version(struct net_device *dev,
4130 struct iw_request_info *info,
4131 union iwreq_data *wrqu,
4132 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004133{
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304135 hdd_context_t *pHddCtx;
4136 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304139 pHostapdAdapter = (netdev_priv(dev));
4140 if (NULL == pHostapdAdapter)
4141 {
4142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4143 "%s: Adapter is NULL",__func__);
4144 return -EINVAL;
4145 }
4146 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4147 ret = wlan_hdd_validate_context(pHddCtx);
4148 if (0 != ret)
4149 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304150 return ret;
4151 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004152 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 return 0;
4155}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004156
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304157static int iw_softap_version(struct net_device *dev,
4158 struct iw_request_info *info,
4159 union iwreq_data *wrqu,
4160 char *extra)
4161{
4162 int ret;
4163
4164 vos_ssr_protect(__func__);
4165 ret = __iw_softap_version(dev, info, wrqu, extra);
4166 vos_ssr_unprotect(__func__);
4167
4168 return ret;
4169}
4170
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304171int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004172{
4173 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004174 int len = 0;
4175 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304176 v_CONTEXT_t pVosContext;
4177 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304178 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304179
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304180 ENTER();
4181
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304182 if (NULL == pAdapter)
4183 {
4184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4185 "%s: Adapter is NULL",__func__);
4186 return -EINVAL;
4187 }
4188 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4189 if (0 != wlan_hdd_validate_context(pHddCtx))
4190 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304191 return VOS_STATUS_E_FAULT;
4192 }
4193 pVosContext = pHddCtx->pvosContext;
4194 if (NULL == pVosContext)
4195 {
4196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4197 "%s: VOS context is not valid",__func__);
4198 return VOS_STATUS_E_FAULT;
4199 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304200 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304201 if(pSapCtx == NULL)
4202 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304203 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4204 FL("psapCtx is NULL"));
4205 return VOS_STATUS_E_FAULT;
4206 }
4207
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304208 len = snprintf(pBuf, buf_len, sta_info_header);
4209 if (len >= buf_len) {
4210 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4211 return -E2BIG;
4212 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004213 pBuf += len;
4214 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004215
4216 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4217 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304218 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004219 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004220 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304221 pSapCtx->aStaInfo[i].ucSTAId,
4222 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4223 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4224 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4225 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4226 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4227 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304228 if (len >= buf_len) {
4229 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4230 return -E2BIG;
4231 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004232 pBuf += len;
4233 buf_len -= len;
4234 }
4235 if(WE_GET_STA_INFO_SIZE > buf_len)
4236 {
4237 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004238 }
4239 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304240 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304241 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004242}
4243
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304244static int __iw_softap_get_sta_info(struct net_device *dev,
4245 struct iw_request_info *info,
4246 union iwreq_data *wrqu,
4247 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004248{
4249 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304250 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004251 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304252 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4253 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304255 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004256 }
4257 wrqu->data.length = strlen(extra);
4258 EXIT();
4259 return 0;
4260}
4261
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304262static int iw_softap_get_sta_info(struct net_device *dev,
4263 struct iw_request_info *info,
4264 union iwreq_data *wrqu,
4265 char *extra)
4266{
4267 int ret;
4268
4269 vos_ssr_protect(__func__);
4270 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4271 vos_ssr_unprotect(__func__);
4272
4273 return ret;
4274}
4275
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304276static int __iw_set_ap_genie(struct net_device *dev,
4277 struct iw_request_info *info,
4278 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004279{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304280
4281 hdd_adapter_t *pHostapdAdapter;
4282 hdd_context_t *pHddCtx;
4283 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004285 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304286 int ret = 0;
4287
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304289 pHostapdAdapter = (netdev_priv(dev));
4290 if (NULL == pHostapdAdapter)
4291 {
4292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4293 "%s: Adapter is NULL",__func__);
4294 return -EINVAL;
4295 }
4296 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4297 ret = wlan_hdd_validate_context(pHddCtx);
4298 if (0 != ret)
4299 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304300 return ret;
4301 }
4302 pVosContext = pHddCtx->pvosContext;
4303 if (NULL == pVosContext)
4304 {
4305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4306 "%s: VOS Context is NULL",__func__);
4307 return -EINVAL;
4308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 if(!wrqu->data.length)
4310 {
4311 EXIT();
4312 return 0;
4313 }
Arif Hussained667642013-10-27 23:01:14 -07004314
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304315 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304317 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 case DOT11F_EID_RSN:
4319 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4320 {
4321 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4322 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004325 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304327
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004329 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 halStatus = 0;
4331 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304332
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304334 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004335}
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)
4340{
4341 int ret;
4342
4343 vos_ssr_protect(__func__);
4344 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4345 vos_ssr_unprotect(__func__);
4346
4347 return ret;
4348}
4349
Jeff Johnson295189b2012-06-20 16:38:30 -07004350static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4351{
4352 eHalStatus hstatus;
4353 long lrc;
4354 struct statsContext context;
4355
4356 if (NULL == pAdapter)
4357 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304358 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 return VOS_STATUS_E_FAULT;
4360 }
4361
4362 init_completion(&context.completion);
4363 context.pAdapter = pAdapter;
4364 context.magic = STATS_CONTEXT_MAGIC;
4365 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4366 eCSR_HDD,
4367 SME_GLOBAL_CLASSA_STATS,
4368 hdd_GetClassA_statisticsCB,
4369 0, // not periodic
4370 FALSE, //non-cached results
4371 staid,
4372 &context);
4373 if (eHAL_STATUS_SUCCESS != hstatus)
4374 {
4375 hddLog(VOS_TRACE_LEVEL_ERROR,
4376 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004377 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
4379 else
4380 {
4381 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4382 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 if (lrc <= 0)
4384 {
4385 hddLog(VOS_TRACE_LEVEL_ERROR,
4386 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004387 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 }
4389 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004390
4391 /* either we never sent a request, we sent a request and received a
4392 response or we sent a request and timed out. if we never sent a
4393 request or if we sent a request and got a response, we want to
4394 clear the magic out of paranoia. if we timed out there is a
4395 race condition such that the callback function could be
4396 executing at the same time we are. of primary concern is if the
4397 callback function had already verified the "magic" but had not
4398 yet set the completion variable when a timeout occurred. we
4399 serialize these activities by invalidating the magic while
4400 holding a shared spinlock which will cause us to block if the
4401 callback is currently executing */
4402 spin_lock(&hdd_context_lock);
4403 context.magic = 0;
4404 spin_unlock(&hdd_context_lock);
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 return VOS_STATUS_SUCCESS;
4407}
4408
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304409int __iw_get_softap_linkspeed(struct net_device *dev,
4410 struct iw_request_info *info,
4411 union iwreq_data *wrqu,
4412 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004413
4414{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304415 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304416 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004418 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304419 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304421 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004423 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304424 int rc, valid;
4425
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304426 ENTER();
4427
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304428 pHostapdAdapter = (netdev_priv(dev));
4429 if (NULL == pHostapdAdapter)
4430 {
4431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4432 "%s: Adapter is NULL",__func__);
4433 return -EINVAL;
4434 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304435 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304436 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304437 if (0 != valid)
4438 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304439 return valid;
4440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004441
Arif Hussain6d2a3322013-11-17 19:50:10 -08004442 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004443
4444 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004445 {
Arif Hussaina9571842014-01-15 16:43:41 -08004446 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4447 if (NULL == pmacAddress) {
4448 hddLog(LOG1, "unable to allocate memory");
4449 return -ENOMEM;
4450 }
4451 if (copy_from_user((void *)pmacAddress,
4452 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4453 {
4454 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4455 kfree(pmacAddress);
4456 return -EFAULT;
4457 }
Manjeet Singha3739742016-05-03 16:21:46 +05304458 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004459
4460 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004461 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004462
4463 if (!VOS_IS_STATUS_SUCCESS(status ))
4464 {
4465 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4466 }
Arif Hussained667642013-10-27 23:01:14 -07004467 }
Kiet Lam61589852013-09-19 17:10:58 +05304468 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304469 * link speed for first connected client will be returned.
4470 */
Arif Hussaina9571842014-01-15 16:43:41 -08004471 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304472 {
4473 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4474 }
4475 else
4476 {
4477 status = hdd_softap_GetStaId(pHostapdAdapter,
4478 (v_MACADDR_t *)macAddress, (void *)(&staId));
4479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004480
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304481 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 link_speed = 0;
4485 }
4486 else
4487 {
4488 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304489
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 if (!VOS_IS_STATUS_SUCCESS(status ))
4491 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 return -EINVAL;
4494 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304495
4496 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4497 staId, &link_speed);
4498
4499 link_speed = link_speed / 10;
4500
4501 if (0 == link_speed)
4502 {
4503 /* The linkspeed returned by HAL is in units of 500kbps.
4504 * converting it to mbps.
4505 * This is required to support legacy firmware which does
4506 * not return link capacity.
4507 */
4508 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 }
4511
4512 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004513 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 if ((rc < 0) || (rc >= len))
4516 {
4517 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304518 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 return -EIO;
4520 }
4521
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304522 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 return 0;
4524}
4525
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304526int iw_get_softap_linkspeed(struct net_device *dev,
4527 struct iw_request_info *info,
4528 union iwreq_data *wrqu,
4529 char *extra)
4530{
4531 int ret;
4532
4533 vos_ssr_protect(__func__);
4534 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4535 vos_ssr_unprotect(__func__);
4536
4537 return ret;
4538}
4539
4540
Jeff Johnson295189b2012-06-20 16:38:30 -07004541static const iw_handler hostapd_handler[] =
4542{
4543 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4544 (iw_handler) NULL, /* SIOCGIWNAME */
4545 (iw_handler) NULL, /* SIOCSIWNWID */
4546 (iw_handler) NULL, /* SIOCGIWNWID */
4547 (iw_handler) NULL, /* SIOCSIWFREQ */
4548 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4549 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304550 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 (iw_handler) NULL, /* SIOCSIWSENS */
4552 (iw_handler) NULL, /* SIOCGIWSENS */
4553 (iw_handler) NULL, /* SIOCSIWRANGE */
4554 (iw_handler) NULL, /* SIOCGIWRANGE */
4555 (iw_handler) NULL, /* SIOCSIWPRIV */
4556 (iw_handler) NULL, /* SIOCGIWPRIV */
4557 (iw_handler) NULL, /* SIOCSIWSTATS */
4558 (iw_handler) NULL, /* SIOCGIWSTATS */
4559 (iw_handler) NULL, /* SIOCSIWSPY */
4560 (iw_handler) NULL, /* SIOCGIWSPY */
4561 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4562 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4563 (iw_handler) NULL, /* SIOCSIWAP */
4564 (iw_handler) NULL, /* SIOCGIWAP */
4565 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4566 (iw_handler) NULL, /* SIOCGIWAPLIST */
4567 (iw_handler) NULL, /* SIOCSIWSCAN */
4568 (iw_handler) NULL, /* SIOCGIWSCAN */
4569 (iw_handler) NULL, /* SIOCSIWESSID */
4570 (iw_handler) NULL, /* SIOCGIWESSID */
4571 (iw_handler) NULL, /* SIOCSIWNICKN */
4572 (iw_handler) NULL, /* SIOCGIWNICKN */
4573 (iw_handler) NULL, /* -- hole -- */
4574 (iw_handler) NULL, /* -- hole -- */
4575 (iw_handler) NULL, /* SIOCSIWRATE */
4576 (iw_handler) NULL, /* SIOCGIWRATE */
4577 (iw_handler) NULL, /* SIOCSIWRTS */
4578 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4579 (iw_handler) NULL, /* SIOCSIWFRAG */
4580 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4581 (iw_handler) NULL, /* SIOCSIWTXPOW */
4582 (iw_handler) NULL, /* SIOCGIWTXPOW */
4583 (iw_handler) NULL, /* SIOCSIWRETRY */
4584 (iw_handler) NULL, /* SIOCGIWRETRY */
4585 (iw_handler) NULL, /* SIOCSIWENCODE */
4586 (iw_handler) NULL, /* SIOCGIWENCODE */
4587 (iw_handler) NULL, /* SIOCSIWPOWER */
4588 (iw_handler) NULL, /* SIOCGIWPOWER */
4589 (iw_handler) NULL, /* -- hole -- */
4590 (iw_handler) NULL, /* -- hole -- */
4591 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4592 (iw_handler) NULL, /* SIOCGIWGENIE */
4593 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4594 (iw_handler) NULL, /* SIOCGIWAUTH */
4595 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4596 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4597 (iw_handler) NULL, /* SIOCSIWPMKSA */
4598};
4599
Jeff Johnson224f3702014-03-26 11:09:47 -07004600/*
4601 * Note that the following ioctls were defined with semantics which
4602 * cannot be handled by the "iwpriv" userspace application and hence
4603 * they are not included in the hostapd_private_args array
4604 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4605 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004606
4607static const struct iw_priv_args hostapd_private_args[] = {
4608 { QCSAP_IOCTL_SETPARAM,
4609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4610 { QCSAP_IOCTL_SETPARAM,
4611 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304612 { QCSAP_PARAM_GET_FRAME_LOGS,
4613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 { QCSAP_PARAM_MAX_ASSOC,
4615 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4616 { QCSAP_PARAM_HIDE_SSID,
4617 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004618 { QCSAP_PARAM_SET_MC_RATE,
4619 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304620 { QCSAP_PARAM_SET_PROXIMITY,
4621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304622 { QCSAP_PARAM_SET_WOWL,
4623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 { QCSAP_IOCTL_GETPARAM,
4625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4627 { QCSAP_IOCTL_GETPARAM, 0,
4628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4629 { QCSAP_PARAM_MAX_ASSOC, 0,
4630 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004631 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4632 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4633 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304635 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 { QCSAP_PARAM_CLR_ACL, 0,
4638 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4639 { QCSAP_PARAM_ACL_MODE,
4640 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304642 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 { QCSAP_IOCTL_STOPBSS,
4644 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4645 { QCSAP_IOCTL_VERSION, 0,
4646 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004647 { QCSAP_IOCTL_GET_STA_INFO, 0,
4648 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004650 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004653 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304655 { QCSAP_IOCTL_AP_STATS, 0,
4656 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304657 { QCSAP_IOCTL_GET_STATS, 0,
4658 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4659 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4661 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304662 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004663
4664 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4666 /* handlers for sub-ioctl */
4667 { WE_SET_WLAN_DBG,
4668 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4669 0,
4670 "setwlandbg" },
4671
4672 /* handlers for main ioctl */
4673 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4674 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4675 0,
4676 "" },
4677
4678 /* handlers for sub-ioctl */
4679 { WE_LOG_DUMP_CMD,
4680 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4681 0,
4682 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 { WE_P2P_NOA_CMD,
4684 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4685 0,
4686 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004687 /* handlers for sub ioctl */
4688 {
4689 WE_MCC_CONFIG_CREDENTIAL,
4690 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4691 0,
4692 "setMccCrdnl" },
4693
4694 /* handlers for sub ioctl */
4695 {
4696 WE_MCC_CONFIG_PARAMS,
4697 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4698 0,
4699 "setMccConfig" },
4700
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 /* handlers for main ioctl */
4702 { QCSAP_IOCTL_MODIFY_ACL,
4703 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4704 0,
4705 "modify_acl" },
4706
4707 /* handlers for main ioctl */
4708 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4709 0,
4710 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4711 "getChannelList" },
4712
Jeff Johnsone7245742012-09-05 17:12:55 -07004713 /* handlers for main ioctl */
4714 { QCSAP_IOCTL_SET_TX_POWER,
4715 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4716 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304717 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004718
4719 /* handlers for main ioctl */
4720 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4721 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4722 0,
4723 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304724
4725 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4726 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4727 0,
4728 "dataSnapshot" },
4729
4730 /* handlers for main ioctl */
4731 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4732 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4733 0,
4734 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304735 /* handlers for main ioctl */
4736 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
4737 IW_PRIV_TYPE_CHAR| 512,
4738 0,
4739 "" },
4740
4741 /* handlers for sub-ioctl */
4742 { WE_WOWL_ADD_PTRN,
4743 IW_PRIV_TYPE_CHAR| 512,
4744 0,
4745 "wowlAddPtrn" },
4746
4747 { WE_WOWL_DEL_PTRN,
4748 IW_PRIV_TYPE_CHAR| 512,
4749 0,
4750 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004751};
Jeff Johnsone7245742012-09-05 17:12:55 -07004752
Jeff Johnson295189b2012-06-20 16:38:30 -07004753static const iw_handler hostapd_private[] = {
4754 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304755 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
4756 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
4757 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4760 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4761 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4762 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4763 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4764 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4765 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304766 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4768 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4769 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4770 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004771 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004772 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4773 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004774 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304775 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304776 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304777 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4778 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004779};
4780const struct iw_handler_def hostapd_handler_def = {
4781 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4782 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4783 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4784 .standard = (iw_handler *)hostapd_handler,
4785 .private = (iw_handler *)hostapd_private,
4786 .private_args = hostapd_private_args,
4787 .get_wireless_stats = NULL,
4788};
4789#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4790struct net_device_ops net_ops_struct = {
4791 .ndo_open = hdd_hostapd_open,
4792 .ndo_stop = hdd_hostapd_stop,
4793 .ndo_uninit = hdd_hostapd_uninit,
4794 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4795 .ndo_tx_timeout = hdd_softap_tx_timeout,
4796 .ndo_get_stats = hdd_softap_stats,
4797 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4798 .ndo_do_ioctl = hdd_hostapd_ioctl,
4799 .ndo_change_mtu = hdd_hostapd_change_mtu,
4800 .ndo_select_queue = hdd_hostapd_select_queue,
4801 };
4802#endif
4803
4804int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4805{
4806 return VOS_STATUS_SUCCESS;
4807}
4808
4809void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4810{
4811#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4812 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4813#else
4814 pWlanHostapdDev->open = hdd_hostapd_open;
4815 pWlanHostapdDev->stop = hdd_hostapd_stop;
4816 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4817 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4818 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4819 pWlanHostapdDev->get_stats = hdd_softap_stats;
4820 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4821 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4822#endif
4823}
4824
4825VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304826{
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05304828#ifdef DHCP_SERVER_OFFLOAD
4829 hdd_dhcp_state_t *dhcp_status;
4830#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304831#ifdef MDNS_OFFLOAD
4832 hdd_mdns_state_t *mdns_status;
4833#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004835 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004837#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004838 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4839 v_U16_t unsafeChannelCount;
4840#endif /* FEATURE_WLAN_CH_AVOID */
4841
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304842 if (pHddCtx->isLogpInProgress) {
4843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4844 "%s:LOGP in Progress. Ignore!!!",__func__);
4845 status = VOS_STATUS_E_FAILURE;
4846 }
4847
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304849
4850#ifdef SAP_AUTH_OFFLOAD
4851 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
4852 hdd_set_sap_auth_offload(pAdapter, TRUE);
4853#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304854
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304855 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05304857#ifdef DHCP_SERVER_OFFLOAD
4858 dhcp_status = &pAdapter->dhcp_status;
4859#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304860#ifdef MDNS_OFFLOAD
4861 mdns_status = &pAdapter->mdns_status;
4862#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304863
Nirav Shah7e3c8132015-06-22 23:51:42 +05304864 spin_lock_init(&pAdapter->sta_hash_lock);
4865 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4866
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004867 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4868
Leo Chang0b0e45a2013-12-15 15:18:55 -08004869#ifdef FEATURE_WLAN_CH_AVOID
4870 /* Get unsafe cahnnel list from cached location */
4871 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4872 sizeof(unsafeChannelList),
4873 &unsafeChannelCount);
4874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4875 "%s : Unsafe Channel count %d",
4876 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304877 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004878 unsafeChannelList,
4879 unsafeChannelCount);
4880#endif /* FEATURE_WLAN_CH_AVOID */
4881
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 // Zero the memory. This zeros the profile structure.
4883 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05304884#ifdef DHCP_SERVER_OFFLOAD
4885 memset(dhcp_status, 0,sizeof(*dhcp_status));
4886#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304887#ifdef MDNS_OFFLOAD
4888 memset(mdns_status, 0,sizeof(*mdns_status));
4889#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05304890
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 // Set up the pointer to the Wireless Extensions state structure
4892 // NOP
4893 status = hdd_set_hostapd(pAdapter);
4894 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 return status;
4897 }
4898
4899 status = vos_event_init(&phostapdBuf->vosEvent);
4900 if (!VOS_IS_STATUS_SUCCESS(status))
4901 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 return status;
4904 }
Anurag Chouhan83026002016-12-13 22:46:21 +05304905#ifdef DHCP_SERVER_OFFLOAD
4906 status = vos_event_init(&dhcp_status->vos_event);
4907 if (!VOS_IS_STATUS_SUCCESS(status)) {
4908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
4909 return status;
4910 }
4911#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304912#ifdef MDNS_OFFLOAD
4913 status = vos_event_init(&mdns_status->vos_event);
4914 if (!VOS_IS_STATUS_SUCCESS(status)) {
4915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4916 ("Hostapd HDD vos event init failed!!"));
4917 return status;
4918 }
4919#endif /* MDNS_OFFLOAD */
4920
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4922
4923 // Register as a wireless device
4924 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4925
4926 //Initialize the data path module
4927 status = hdd_softap_init_tx_rx(pAdapter);
4928 if ( !VOS_IS_STATUS_SUCCESS( status ))
4929 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004930 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304932
4933 status = hdd_wmm_adapter_init( pAdapter );
4934 if (!VOS_IS_STATUS_SUCCESS(status))
4935 {
4936 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004937 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304938 status, status );
4939 goto error_wmm_init;
4940 }
4941
4942 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
4943
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304944 pHddCtx->is_ap_mode_wow_supported =
4945 sme_IsFeatureSupportedByFW(SAP_MODE_WOW);
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304946 return status;
4947
4948error_wmm_init:
4949 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 EXIT();
4951 return status;
4952}
4953
4954hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4955{
4956 struct net_device *pWlanHostapdDev = NULL;
4957 hdd_adapter_t *pHostapdAdapter = NULL;
4958 v_CONTEXT_t pVosContext= NULL;
4959
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05304960 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
4961#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
4962 NET_NAME_UNKNOWN,
4963#endif
4964 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 if (pWlanHostapdDev != NULL)
4966 {
4967 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4968
4969 //Init the net_device structure
4970 ether_setup(pWlanHostapdDev);
4971
4972 //Initialize the adapter context to zeros.
4973 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4974 pHostapdAdapter->dev = pWlanHostapdDev;
4975 pHostapdAdapter->pHddCtx = pHddCtx;
4976 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4977
4978 //Get the Global VOSS context.
4979 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4980 //Save the adapter context in global context for future.
4981 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4982
4983 //Init the net_device structure
4984 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4985
4986 hdd_set_ap_ops( pHostapdAdapter->dev );
4987
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4989 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4990
4991 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4992 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4993
4994 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4996 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4997 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5000 }
5001 return pHostapdAdapter;
5002}
5003
5004VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5005{
5006 struct net_device *dev = pAdapter->dev;
5007 VOS_STATUS status = VOS_STATUS_SUCCESS;
5008
5009 ENTER();
5010
5011 if( rtnl_lock_held )
5012 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005013 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 if( dev_alloc_name(dev, dev->name) < 0 )
5015 {
5016 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5017 return VOS_STATUS_E_FAILURE;
5018 }
5019 }
5020 if (register_netdevice(dev))
5021 {
5022 hddLog(VOS_TRACE_LEVEL_FATAL,
5023 "%s:Failed:register_netdevice", __func__);
5024 return VOS_STATUS_E_FAILURE;
5025 }
5026 }
5027 else
5028 {
5029 if (register_netdev(dev))
5030 {
5031 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5032 return VOS_STATUS_E_FAILURE;
5033 }
5034 }
5035 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5036
5037 EXIT();
5038 return status;
5039}
5040
c_hpothu002231a2015-02-05 14:58:51 +05305041VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005042{
5043 ENTER();
5044
5045 hdd_softap_deinit_tx_rx(pAdapter);
5046
5047 /* if we are being called during driver unload, then the dev has already
5048 been invalidated. if we are being called at other times, then we can
5049 detatch the wireless device handlers */
5050 if (pAdapter->dev)
5051 {
c_hpothu002231a2015-02-05 14:58:51 +05305052 if (TRUE == rtnl_held)
5053 {
5054 pAdapter->dev->wireless_handlers = NULL;
5055 }
5056 else
5057 {
5058 rtnl_lock();
5059 pAdapter->dev->wireless_handlers = NULL;
5060 rtnl_unlock();
5061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 }
5063 EXIT();
5064 return 0;
5065}