blob: 246fda4b157b04915b6363d6cca7fabfa176b2b2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashish6773c902017-01-06 19:45:03 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053082#include <wlan_hdd_wowl.h>
Agrawal Ashish17ef5082016-10-17 18:33:21 +053083#include "wlan_hdd_hostapd.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Leo Chang0b0e45a2013-12-15 15:18:55 -080085#ifdef FEATURE_WLAN_CH_AVOID
86#include "wcnss_wlan.h"
87#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053088#include "wlan_hdd_trace.h"
89#include "vos_types.h"
90#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080091
Jeff Johnson295189b2012-06-20 16:38:30 -070092#define IS_UP(_dev) \
93 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
94#define IS_UP_AUTO(_ic) \
95 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
96#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070097#define WE_GET_STA_INFO_SIZE 30
98/* WEXT limition: MAX allowed buf len for any *
99 * IW_PRIV_TYPE_CHAR is 2Kbytes *
100 */
101#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530103#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700104
Leo Chang0b0e45a2013-12-15 15:18:55 -0800105#ifdef FEATURE_WLAN_CH_AVOID
106/* Channle/Freqency table */
107extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
108safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
109{
110 /*CH , SAFE, default safe */
111 {1 , VOS_TRUE}, //RF_CHAN_1,
112 {2 , VOS_TRUE}, //RF_CHAN_2,
113 {3 , VOS_TRUE}, //RF_CHAN_3,
114 {4 , VOS_TRUE}, //RF_CHAN_4,
115 {5 , VOS_TRUE}, //RF_CHAN_5,
116 {6 , VOS_TRUE}, //RF_CHAN_6,
117 {7 , VOS_TRUE}, //RF_CHAN_7,
118 {8 , VOS_TRUE}, //RF_CHAN_8,
119 {9 , VOS_TRUE}, //RF_CHAN_9,
120 {10 , VOS_TRUE}, //RF_CHAN_10,
121 {11 , VOS_TRUE}, //RF_CHAN_11,
122 {12 , VOS_TRUE}, //RF_CHAN_12,
123 {13 , VOS_TRUE}, //RF_CHAN_13,
124 {14 , VOS_TRUE}, //RF_CHAN_14,
125 {240, VOS_TRUE}, //RF_CHAN_240,
126 {244, VOS_TRUE}, //RF_CHAN_244,
127 {248, VOS_TRUE}, //RF_CHAN_248,
128 {252, VOS_TRUE}, //RF_CHAN_252,
129 {208, VOS_TRUE}, //RF_CHAN_208,
130 {212, VOS_TRUE}, //RF_CHAN_212,
131 {216, VOS_TRUE}, //RF_CHAN_216,
132 {36 , VOS_TRUE}, //RF_CHAN_36,
133 {40 , VOS_TRUE}, //RF_CHAN_40,
134 {44 , VOS_TRUE}, //RF_CHAN_44,
135 {48 , VOS_TRUE}, //RF_CHAN_48,
136 {52 , VOS_TRUE}, //RF_CHAN_52,
137 {56 , VOS_TRUE}, //RF_CHAN_56,
138 {60 , VOS_TRUE}, //RF_CHAN_60,
139 {64 , VOS_TRUE}, //RF_CHAN_64,
140 {100, VOS_TRUE}, //RF_CHAN_100,
141 {104, VOS_TRUE}, //RF_CHAN_104,
142 {108, VOS_TRUE}, //RF_CHAN_108,
143 {112, VOS_TRUE}, //RF_CHAN_112,
144 {116, VOS_TRUE}, //RF_CHAN_116,
145 {120, VOS_TRUE}, //RF_CHAN_120,
146 {124, VOS_TRUE}, //RF_CHAN_124,
147 {128, VOS_TRUE}, //RF_CHAN_128,
148 {132, VOS_TRUE}, //RF_CHAN_132,
149 {136, VOS_TRUE}, //RF_CHAN_136,
150 {140, VOS_TRUE}, //RF_CHAN_140,
151 {149, VOS_TRUE}, //RF_CHAN_149,
152 {153, VOS_TRUE}, //RF_CHAN_153,
153 {157, VOS_TRUE}, //RF_CHAN_157,
154 {161, VOS_TRUE}, //RF_CHAN_161,
155 {165, VOS_TRUE}, //RF_CHAN_165,
156};
157#endif /* FEATURE_WLAN_CH_AVOID */
158
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530159/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 * Function definitions
161 *-------------------------------------------------------------------------*/
162/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530164 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 This is called in response to ifconfig up
167
168 \param - dev Pointer to net_device structure
169
170 \return - 0 for success non-zero for failure
171
172 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530173int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 ENTER();
178
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530179 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
180 {
181 //WMM_INIT OR BSS_START not completed
182 hddLog( LOGW, "Ignore hostadp open request");
183 EXIT();
184 return 0;
185 }
186
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530187 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
188 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 //Turn ON carrier state
190 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530191 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 EXIT();
196 return 0;
197}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530198
199int hdd_hostapd_open (struct net_device *dev)
200{
201 int ret;
202
203 vos_ssr_protect(__func__);
204 ret = __hdd_hostapd_open(dev);
205 vos_ssr_unprotect(__func__);
206
207 return ret;
208}
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210/**---------------------------------------------------------------------------
211
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530212 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214 This is called in response to ifconfig down
215
216 \param - dev Pointer to net_device structure
217
218 \return - 0 for success non-zero for failure
219
220 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530221int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222{
223 ENTER();
224
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530226 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530227 //Stop all tx queues
228 netif_tx_disable(dev);
229
230 //Turn OFF carrier state
231 netif_carrier_off(dev);
232 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234 EXIT();
235 return 0;
236}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530237
238int hdd_hostapd_stop (struct net_device *dev)
239{
240 int ret;
241
242 vos_ssr_protect(__func__);
243 ret = __hdd_hostapd_stop(dev);
244 vos_ssr_unprotect(__func__);
245
246 return ret;
247}
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249/**---------------------------------------------------------------------------
250
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530251 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253 This is called during the netdev unregister to uninitialize all data
254associated with the device
255
256 \param - dev Pointer to net_device structure
257
258 \return - void
259
260 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530261static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700262{
263 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530264 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 ENTER();
267
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530270 hddLog(VOS_TRACE_LEVEL_ERROR,
271 FL("Invalid magic"));
272 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530274 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
275 if (NULL == pHddCtx)
276 {
277 hddLog(VOS_TRACE_LEVEL_ERROR,
278 FL("NULL pHddCtx"));
279 return;
280 }
281
282 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
283
284 /* after uninit our adapter structure will no longer be valid */
285 pHostapdAdapter->dev = NULL;
286 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 EXIT();
289}
290
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530291static void hdd_hostapd_uninit (struct net_device *dev)
292{
293 vos_ssr_protect(__func__);
294 __hdd_hostapd_uninit(dev);
295 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530297 return;
298}
Jeff Johnson295189b2012-06-20 16:38:30 -0700299/**============================================================================
300 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
301 transmitting packets. There are 2 versions of this function. One that uses
302 locked queue and other that uses lockless queues. Both have been retained to
303 do some performance testing
304 @param skb : [in] pointer to OS packet (sk_buff)
305 @param dev : [in] pointer to Libra network device
306
307 @return : NET_XMIT_DROP if packets are dropped
308 : NET_XMIT_SUCCESS if packet is enqueued succesfully
309 ===========================================================================*/
310int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
311{
312 return 0;
313}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530314
315int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700316{
317 return 0;
318}
319
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530320int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
321{
322 int ret;
323 vos_ssr_protect(__func__);
324 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
325 vos_ssr_unprotect(__func__);
326
327 return ret;
328}
329
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700330static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
331 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700333 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530334 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
335 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530337 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700338 /*
339 * Note that valid pointers are provided by caller
340 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530342 ENTER();
343
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700344 if (priv_data->total_len <= 0 ||
345 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
346 {
347 /* below we allocate one more byte for command buffer.
348 * To avoid addition overflow total_len should be
349 * smaller than INT_MAX. */
350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
351 __func__, priv_data->total_len);
352 ret = -EFAULT;
353 goto exit;
354 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530355 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 if (0 != status)
357 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530358 return status;
359 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700361 /* Allocate +1 for '\0' */
362 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
363 if (!command)
364 {
365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
366 ret = -ENOMEM;
367 goto exit;
368 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700369
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700370 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
371 {
372 ret = -EFAULT;
373 goto exit;
374 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800375
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 /* Make sure the command is NUL-terminated */
377 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700379 hddLog(VOS_TRACE_LEVEL_INFO,
380 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700382 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
383 {
384 hdd_setP2pNoa(pAdapter->dev, command);
385 }
386 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
387 {
388 hdd_setP2pOpps(pAdapter->dev, command);
389 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800390#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700391 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
392 {
393 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
394 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800395#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700396 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
397 {
398 /*
399 * command should be a string having format
400 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
401 */
402 hddLog(VOS_TRACE_LEVEL_INFO,
403 "%s: Received Command to Set Preferred Channels for SAP",
404 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800405
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700406 ret = sapSetPreferredChannel(command);
407 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530408 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
409 {
410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
411 tANI_U8 filterType = 0;
412 tANI_U8 *value;
413 value = command + 9;
414
415 /* Convert the value from ascii to integer */
416 ret = kstrtou8(value, 10, &filterType);
417 if (ret < 0)
418 {
419 /* If the input value is greater than max value of datatype,
420 * then also kstrtou8 fails
421 */
422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
423 "%s: kstrtou8 failed range ", __func__);
424 ret = -EINVAL;
425 goto exit;
426 }
427 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
428 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
429 {
430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
431 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
432 " 2-Sink ", __func__);
433 ret = -EINVAL;
434 goto exit;
435 }
436 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
437 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530438 pScanInfo = &pHddCtx->scan_info;
439 if (filterType && pScanInfo != NULL &&
440 pHddCtx->scan_info.mScanPending)
441 {
442 /*Miracast Session started. Abort Scan */
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
444 "%s, Aborting Scan For Miracast",__func__);
445 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
446 eCSR_SCAN_ABORT_DEFAULT);
447 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530448 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
449 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
450 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530451 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
452 {
453 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
454 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456exit:
457 if (command)
458 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700459 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 return ret;
463}
464
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700465#ifdef CONFIG_COMPAT
466static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
467 struct ifreq *ifr)
468{
469 struct {
470 compat_uptr_t buf;
471 int used_len;
472 int total_len;
473 } compat_priv_data;
474 hdd_priv_data_t priv_data;
475 int ret = 0;
476
477 /*
478 * Note that pAdapter and ifr have already been verified by caller,
479 * and HDD context has also been validated
480 */
481 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
482 sizeof(compat_priv_data))) {
483 ret = -EFAULT;
484 goto exit;
485 }
486 priv_data.buf = compat_ptr(compat_priv_data.buf);
487 priv_data.used_len = compat_priv_data.used_len;
488 priv_data.total_len = compat_priv_data.total_len;
489 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
490 exit:
491 return ret;
492}
493#else /* CONFIG_COMPAT */
494static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
495 struct ifreq *ifr)
496{
497 /* will never be invoked */
498 return 0;
499}
500#endif /* CONFIG_COMPAT */
501
502static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
503{
504 hdd_priv_data_t priv_data;
505 int ret = 0;
506
507 /*
508 * Note that pAdapter and ifr have already been verified by caller,
509 * and HDD context has also been validated
510 */
511 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
512 ret = -EFAULT;
513 } else {
514 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
515 }
516 return ret;
517}
518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530519static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700520 struct ifreq *ifr, int cmd)
521{
522 hdd_adapter_t *pAdapter;
523 hdd_context_t *pHddCtx;
524 int ret;
525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530526 ENTER();
527
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
529 if (NULL == pAdapter) {
530 hddLog(VOS_TRACE_LEVEL_ERROR,
531 "%s: HDD adapter context is Null", __func__);
532 ret = -ENODEV;
533 goto exit;
534 }
535 if (dev != pAdapter->dev) {
536 hddLog(VOS_TRACE_LEVEL_ERROR,
537 "%s: HDD adapter/dev inconsistency", __func__);
538 ret = -ENODEV;
539 goto exit;
540 }
541
542 if ((!ifr) || (!ifr->ifr_data)) {
543 ret = -EINVAL;
544 goto exit;
545 }
546
547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
548 ret = wlan_hdd_validate_context(pHddCtx);
549 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700550 ret = -EBUSY;
551 goto exit;
552 }
553
554 switch (cmd) {
555 case (SIOCDEVPRIVATE + 1):
556 if (is_compat_task())
557 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
558 else
559 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
560 break;
561 default:
562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
563 __func__, cmd);
564 ret = -EINVAL;
565 break;
566 }
567 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530568 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700569 return ret;
570}
571
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530572static int hdd_hostapd_ioctl(struct net_device *dev,
573 struct ifreq *ifr, int cmd)
574{
575 int ret;
576
577 vos_ssr_protect(__func__);
578 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
579 vos_ssr_unprotect(__func__);
580
581 return ret;
582}
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584/**---------------------------------------------------------------------------
585
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530586 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 This function sets the user specified mac address using
588 the command ifconfig wlanX hw ether <mac adress>.
589
590 \param - dev - Pointer to the net device.
591 - addr - Pointer to the sockaddr.
592 \return - 0 for success, non zero for failure
593
594 --------------------------------------------------------------------------*/
595
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530596static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597{
598 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530599 hdd_adapter_t *pAdapter;
600 hdd_context_t *pHddCtx;
601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530602
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
605 if (NULL == pAdapter)
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Adapter is NULL",__func__);
609 return -EINVAL;
610 }
611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
612 ret = wlan_hdd_validate_context(pHddCtx);
613 if (0 != ret)
614 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530615 return ret;
616 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
618 EXIT();
619 return 0;
620}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530621
622static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
623{
624 int ret;
625
626 vos_ssr_protect(__func__);
627 ret = __hdd_hostapd_set_mac_address(dev, addr);
628 vos_ssr_unprotect(__func__);
629
630 return ret;
631}
632
Jeff Johnson295189b2012-06-20 16:38:30 -0700633void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
634{
635 struct net_device *dev = (struct net_device *)usrDataForCallback;
636 v_BYTE_t we_custom_event[64];
637 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530639 hdd_context_t *pHddCtx;
640#ifdef DISABLE_CONCURRENCY_AUTOSAVE
641 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hdd_ap_ctx_t *pHddApCtx;
643#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
644
645 /* event_name space-delimiter driver_module_name */
646 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
647 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
648 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
649
650 ENTER();
651
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530652 pHostapdAdapter = netdev_priv(dev);
653 if ((NULL == pHostapdAdapter) ||
654 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
655 {
656 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
657 return;
658 }
659 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
660 if (0 != (wlan_hdd_validate_context(pHddCtx)))
661 {
662 return;
663 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530664#ifdef DISABLE_CONCURRENCY_AUTOSAVE
665 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530666 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 /*
668 This timer routine is going to be called only when AP
669 persona is up.
670 If there are concurrent sessions running we do not want
671 to shut down the Bss.Instead we run the timer again so
672 that if Autosave is enabled next time and other session
673 was down only then we bring down AP
674 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
676 vos_status = vos_timer_start(
677 &pHddApCtx->hdd_ap_inactivity_timer,
678 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
679 * 1000);
680 if (!VOS_IS_STATUS_SUCCESS(vos_status))
681 {
682 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
683 }
684 EXIT();
685 return;
686 }
687#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
688 memset(&we_custom_event, '\0', sizeof(we_custom_event));
689 memcpy(&we_custom_event, autoShutEvent, event_len);
690
691 memset(&wrqu, 0, sizeof(wrqu));
692 wrqu.data.length = event_len;
693
694 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
695 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
696
697 EXIT();
698}
699
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800700VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
701{
702 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
703 ptSapContext pSapCtx = NULL;
704 eHalStatus halStatus = eHAL_STATUS_FAILURE;
705 v_PVOID_t hHal = NULL;
706
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
708 "%s: UPDATE Beacon Params", __func__);
709
710 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
711 pSapCtx = VOS_GET_SAP_CB(pVosContext);
712 if ( NULL == pSapCtx )
713 {
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
715 "%s: Invalid SAP pointer from pvosGCtx", __func__);
716 return VOS_STATUS_E_FAULT;
717 }
718
719 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
720 if ( NULL == hHal ){
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Invalid HAL pointer from pvosGCtx", __func__);
723 return VOS_STATUS_E_FAULT;
724 }
725 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
726 if(halStatus == eHAL_STATUS_FAILURE ){
727 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
728 "%s: Failed to update Beacon Params", __func__);
729 return VOS_STATUS_E_FAILURE;
730 }
731 }
732 return VOS_STATUS_SUCCESS;
733}
734
735void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
736{
737 v_U8_t staId = 0;
738 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530739 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
740 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800741
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530742 dev = (struct net_device *)usrDataForCallback;
743 pSapCtx = VOS_GET_SAP_CB(pVosContext);
744 if(pSapCtx == NULL){
745 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
746 FL("psapCtx is NULL"));
747 return;
748 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800749 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
751 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530752 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800753 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
754 {
755 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530756 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800757 }
758 }
759}
760
Agarwal Ashish8e538932014-12-24 18:12:52 +0530761static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762{
763 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530764 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800765 VOS_STATUS status = VOS_STATUS_SUCCESS;
766 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530767
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800768 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530769
770 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
771 status = wlan_hdd_validate_context(pHddCtx);
772
773 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530774 return status;
775 }
776
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800777 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
778 {
779 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
780 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800782 }
783 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530784 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800785 }
786 EXIT();
787 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
788}
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530790#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530791bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530792 bool enabled)
793{
794 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530795 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530796
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530797 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530798 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
799
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530800 sap_offload_info.sap_auth_offload_enable = enabled;
801 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530802 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530803 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530804 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
805
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530806 if (sap_offload_info.sap_auth_offload_enable &&
807 sap_offload_info.sap_auth_offload_sec_type)
808 {
809 if (sap_offload_info.key_len < 8 ||
810 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
811 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530812 hddLog(VOS_TRACE_LEVEL_ERROR,
813 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530814 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530815 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530816 }
817 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530818 if (sap_offload_info.key_len)
819 {
820 vos_mem_copy(sap_offload_info.key,
821 pHddCtx->cfg_ini->sap_auth_offload_key,
822 sap_offload_info.key_len);
823 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530824 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530825 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
826 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530827 hddLog(VOS_TRACE_LEVEL_ERROR,
828 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530829 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530830 }
831
832 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
833 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530834 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530835}
836#endif
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
839{
840 hdd_adapter_t *pHostapdAdapter;
841 hdd_ap_ctx_t *pHddApCtx;
842 hdd_hostapd_state_t *pHostapdState;
843 struct net_device *dev;
844 eSapHddEvent sapEvent;
845 union iwreq_data wrqu;
846 v_BYTE_t *we_custom_event_generic = NULL;
847 int we_event = 0;
848 int i = 0;
849 v_U8_t staId;
850 VOS_STATUS vos_status;
851 v_BOOL_t bWPSState;
852 v_BOOL_t bApActive = FALSE;
853 v_BOOL_t bAuthRequired = TRUE;
854 tpSap_AssocMacAddr pAssocStasArray = NULL;
855 char unknownSTAEvent[IW_CUSTOM_MAX+1];
856 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
857 v_BYTE_t we_custom_start_event[64];
858 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800859 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800860 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700861 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530862 v_CONTEXT_t pVosContext = NULL;
863 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +0530864 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
866 dev = (struct net_device *)usrDataForCallback;
867 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530868
869 if ((NULL == pHostapdAdapter) ||
870 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
871 {
872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
873 "invalid adapter or adapter has invalid magic");
874 return eHAL_STATUS_FAILURE;
875 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530876 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
877 pSapCtx = VOS_GET_SAP_CB(pVosContext);
878 if(pSapCtx == NULL){
879 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
880 FL("psapCtx is NULL"));
881 return eHAL_STATUS_FAILURE;
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
884 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
885 sapEvent = pSapEvent->sapHddEventCode;
886 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800887 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +0530888 cfg_param = pHddCtx->cfg_ini;
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890
891 switch(sapEvent)
892 {
893 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800894 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
896 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
897 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
898
899 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
900 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +0530901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +0530903 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 goto stopbss;
906 }
907 else
Deepthi Gowried085092015-10-20 19:30:52 +0530908 {
909 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
910 {
911 if ((cfg_param->dynSplitscan) &&
912 (!pHddCtx->issplitscan_enabled))
913 {
914 pHddCtx->issplitscan_enabled = TRUE;
915 sme_enable_disable_split_scan(
916 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
917 cfg_param->nNumStaChanCombinedConc,
918 cfg_param->nNumP2PChanCombinedConc);
919 }
920 }
921
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
923 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530924 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
925 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530926 {
c_hpothuffdb5272013-10-02 16:42:35 +0530927 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530928 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 }
Deepthi Gowried085092015-10-20 19:30:52 +0530931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
933 {
934 // AP Inactivity timer init and start
935 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
936 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
937 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800938 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939
940 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
941 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800942 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 }
945 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
946 pHostapdState->bssState = BSS_START;
947
948 // Send current operating channel of SoftAP to BTC-ES
949 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 //Check if there is any group key pending to set.
952 if( pHddApCtx->groupKey.keyLength )
953 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700954 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
956 &pHddApCtx->groupKey ) )
957 {
958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 "%s: WLANSAP_SetKeySta failed", __func__);
960 }
961 pHddApCtx->groupKey.keyLength = 0;
962 }
963 else if ( pHddApCtx->wepKey[0].keyLength )
964 {
965 int i=0;
966 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
967 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700968 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
970 &pHddApCtx->wepKey[i] ) )
971 {
972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
973 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
974 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
976 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
978 startBssEvent = "SOFTAP.enabled";
979 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
980 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
981 memset(&wrqu, 0, sizeof(wrqu));
982 wrqu.data.length = strlen(startBssEvent);
983 we_event = IWEVCUSTOM;
984 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700985 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 break; //Event will be sent after Switch-Case stmt
987
988 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800989 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
991
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700992 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700993 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530996
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530997 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +0530998 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +0530999 hddLog(LOG1,
1000 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1001 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301002 }
1003
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 goto stopbss;
1005 case eSAP_STA_SET_KEY_EVENT:
1006 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001007 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1009 return VOS_STATUS_SUCCESS;
1010 case eSAP_STA_DEL_KEY_EVENT:
1011 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001012 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 return VOS_STATUS_SUCCESS;
1014 case eSAP_STA_MIC_FAILURE_EVENT:
1015 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 memset(&msg, '\0', sizeof(msg));
1017 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001018 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001019 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001020 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 msg.flags = IW_MICFAILURE_GROUP;
1022 else
1023 msg.flags = IW_MICFAILURE_PAIRWISE;
1024 memset(&wrqu, 0, sizeof(wrqu));
1025 wrqu.data.length = sizeof(msg);
1026 we_event = IWEVMICHAELMICFAILURE;
1027 we_custom_event_generic = (v_BYTE_t *)&msg;
1028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 /* inform mic failure to nl80211 */
1030 cfg80211_michael_mic_failure(dev,
1031 pSapEvent->sapevt.
1032 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001033 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 NL80211_KEYTYPE_GROUP :
1035 NL80211_KEYTYPE_PAIRWISE),
1036 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1037 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1038 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 break;
1040
1041 case eSAP_STA_ASSOC_EVENT:
1042 case eSAP_STA_REASSOC_EVENT:
1043 wrqu.addr.sa_family = ARPHRD_ETHER;
1044 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001045 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001046 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 we_event = IWEVREGISTERED;
1048
1049 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1050
1051 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1052 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1053 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1054 {
1055 bAuthRequired = FALSE;
1056 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301057 /* fAuthRequiredshould should be false for sap offload */
1058 if ((bAuthRequired || bWPSState)
1059#ifdef SAP_AUTH_OFFLOAD
1060 && !cfg_param->enable_sap_auth_offload
1061#endif
1062 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 {
c_hpothuffdb5272013-10-02 16:42:35 +05301064 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 TRUE,
1066 pHddApCtx->uPrivacy,
1067 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1068 0,
1069 0,
1070 (v_MACADDR_t *)wrqu.addr.sa_data,
1071 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301072
1073 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1074 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1075 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 }
1077 else
1078 {
c_hpothuffdb5272013-10-02 16:42:35 +05301079 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 FALSE,
1081 pHddApCtx->uPrivacy,
1082 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1083 0,
1084 0,
1085 (v_MACADDR_t *)wrqu.addr.sa_data,
1086 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301087 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1088 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1089 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001090 }
1091
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301092 staId =
1093 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1094 if (VOS_IS_STATUS_SUCCESS(vos_status))
1095 {
1096
1097 pSapCtx->aStaInfo[staId].rate_flags =
1098 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1099 }
1100
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 // Stop AP inactivity timer
1102 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1103 {
1104 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1105 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001106 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001108#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001109 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1110 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301111 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1112 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001113 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301114 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1115 HDD_SAP_WAKE_LOCK_DURATION,
1116 WIFI_POWER_EVENT_WAKELOCK_SAP);
1117
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001118#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001119#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1120 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301121 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1123
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301124 staInfo = vos_mem_malloc(sizeof(*staInfo));
1125 if (staInfo == NULL) {
1126 hddLog(LOGE, FL("alloc station_info failed"));
1127 return VOS_STATUS_E_NOMEM;
1128 }
1129
1130 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1132 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301133 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301135 staInfo->assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001136#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301137 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 cfg80211_new_sta(dev,
1140 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301141 staInfo, GFP_KERNEL);
1142 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 }
1144 else
1145 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001146 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 }
1148 }
1149#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301150 hdd_manage_delack_timer(pHddCtx);
1151
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001152 pScanInfo = &pHddCtx->scan_info;
1153 // Lets do abort scan to ensure smooth authentication for client
1154 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1155 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301156 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301157 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001159
1160 break;
1161 case eSAP_STA_DISASSOC_EVENT:
1162 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001163 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001164 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1166 hddLog(LOG1," User initiated disassociation");
1167 else
1168 hddLog(LOG1," MAC initiated disassociation");
1169 we_event = IWEVEXPIRED;
1170 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1171 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1172 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001173 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 -07001174 return VOS_STATUS_E_FAILURE;
1175 }
1176 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1177
1178 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1179 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301180 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 // Start AP inactivity timer if no stations associated with it
1182 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1183 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301184 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 {
1186 bApActive = TRUE;
1187 break;
1188 }
1189 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301190 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001191
1192 if (bApActive == FALSE)
1193 {
1194 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1195 {
1196 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1197 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001198 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 }
1200 else
1201 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1202 }
1203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001204#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1205 cfg80211_del_sta(dev,
1206 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1207 GFP_KERNEL);
1208#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001209 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301210 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1211 if (VOS_STATUS_SUCCESS != vos_status)
1212 {
1213 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1214 __func__, vos_status);
1215 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301216 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 break;
1218 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1219 {
1220 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1221 union iwreq_data wreq;
1222
1223 down(&pHddApCtx->semWpsPBCOverlapInd);
1224 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1225
1226 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1227 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1228
1229 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001230 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 memset(&wreq, 0, sizeof(wreq));
1232 wreq.data.length = strlen(message); // This is length of message
1233 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1234
1235 return VOS_STATUS_SUCCESS;
1236 }
1237 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1238 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1239 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1240 { // List of associated stations
1241 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1242 {
1243 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1244 i+1,
1245 pAssocStasArray->assocId,
1246 pAssocStasArray->staId,
1247 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1248 pAssocStasArray++;
1249 }
1250 }
1251 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001252 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 case eSAP_REMAIN_CHAN_READY:
1255 hdd_remainChanReadyHandler( pHostapdAdapter );
1256 return VOS_STATUS_SUCCESS;
1257 case eSAP_SEND_ACTION_CNF:
1258 hdd_sendActionCnf( pHostapdAdapter,
1259 ( eSAP_STATUS_SUCCESS ==
1260 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1261 TRUE : FALSE );
1262 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 case eSAP_UNKNOWN_STA_JOIN:
1264 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1265 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1266 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1267 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1268 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1269 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1270 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1271 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1272 wrqu.data.pointer = unknownSTAEvent;
1273 wrqu.data.length = strlen(unknownSTAEvent);
1274 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301275 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 break;
1277
1278 case eSAP_MAX_ASSOC_EXCEEDED:
1279 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1280 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1281 " one or more devices to enable the new device connection",
1282 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1283 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1284 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1285 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1286 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1287 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1288 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1289 wrqu.data.pointer = maxAssocExceededEvent;
1290 wrqu.data.length = strlen(maxAssocExceededEvent);
1291 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001292 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 break;
1294 case eSAP_STA_ASSOC_IND:
1295 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001296
1297 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001298 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001299 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1300 return VOS_STATUS_SUCCESS;
1301
1302 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301303 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301304 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1305 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301306 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301307 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001308 return VOS_STATUS_SUCCESS;
1309
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001311 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 goto stopbss;
1313 return VOS_STATUS_SUCCESS;
1314 }
1315 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1316 return VOS_STATUS_SUCCESS;
1317
1318stopbss :
1319 {
1320 v_BYTE_t we_custom_event[64];
1321 char *stopBssEvent = "STOP-BSS.response";//17
1322 int event_len = strlen(stopBssEvent);
1323
1324 hddLog(LOG1, FL("BSS stop status = %s"),
1325 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1326 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1327
1328 /* Change the BSS state now since, as we are shutting things down,
1329 * we don't want interfaces to become re-enabled */
1330 pHostapdState->bssState = BSS_STOP;
1331
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301332 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1333 {
1334 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1335 {
1336 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1337 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1338 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1339 }
1340
1341 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1342 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1343 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1344 }
1345
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 /* Stop the pkts from n/w stack as we are going to free all of
1347 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301348
1349 /*
1350 * If channel avoidance is in progress means driver is performing SAP
1351 * restart. So don't do carrier off, which may lead framework to do
1352 * driver reload.
1353 */
1354 hddLog(LOG1, FL("ch avoid in progress: %d"),
1355 pHddCtx->is_ch_avoid_in_progress);
1356 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301357 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301358 netif_tx_disable(dev);
1359 else
1360 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
1362 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301363 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1364 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1365 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001366
Amar Singhal37e6f052013-03-05 16:16:54 -08001367 /* once the event is set, structure dev/pHostapdAdapter should
1368 * not be touched since they are now subject to being deleted
1369 * by another thread */
1370 if (eSAP_STOP_BSS_EVENT == sapEvent)
1371 vos_event_set(&pHostapdState->vosEvent);
1372
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 /* notify userspace that the BSS has stopped */
1374 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1375 memcpy(&we_custom_event, stopBssEvent, event_len);
1376 memset(&wrqu, 0, sizeof(wrqu));
1377 wrqu.data.length = event_len;
1378 we_event = IWEVCUSTOM;
1379 we_custom_event_generic = we_custom_event;
1380 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001381 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 }
1383 return VOS_STATUS_SUCCESS;
1384}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001385
1386int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001388 eCsrEncryptionType *pEncryptType,
1389 eCsrEncryptionType *mcEncryptType,
1390 eCsrAuthType *pAuthType,
1391 v_BOOL_t *pMFPCapable,
1392 v_BOOL_t *pMFPRequired,
1393 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 u_int8_t *gen_ie )
1395{
1396 tDot11fIERSN dot11RSNIE;
1397 tDot11fIEWPA dot11WPAIE;
1398
1399 tANI_U8 *pRsnIe;
1400 tANI_U16 RSNIeLen;
1401
1402 if (NULL == halHandle)
1403 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001404 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 return -EINVAL;
1406 }
1407
1408 // Validity checks
1409 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1410 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1411 return -EINVAL;
1412 // Type check
1413 if ( gen_ie[0] == DOT11F_EID_RSN)
1414 {
1415 // Validity checks
1416 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1417 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1418 {
1419 return VOS_STATUS_E_FAILURE;
1420 }
1421 // Skip past the EID byte and length byte
1422 pRsnIe = gen_ie + 2;
1423 RSNIeLen = gen_ie_len - 2;
1424 // Unpack the RSN IE
1425 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1426 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1427 pRsnIe,
1428 RSNIeLen,
1429 &dot11RSNIE);
1430 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001431 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001432 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001433 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001434 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 /*Here we have followed the apple base code,
1436 but probably I suspect we can do something different*/
1437 //dot11RSNIE.akm_suite_count
1438 // Just translate the FIRST one
1439 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1440 //dot11RSNIE.pwise_cipher_suite_count
1441 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1442 //dot11RSNIE.gp_cipher_suite_count
1443 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1444 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001445 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1446 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001447
1448 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1449 } else
1450 if (gen_ie[0] == DOT11F_EID_WPA)
1451 {
1452 // Validity checks
1453 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1454 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1455 {
1456 return VOS_STATUS_E_FAILURE;
1457 }
1458 // Skip past the EID byte and length byte - and four byte WiFi OUI
1459 pRsnIe = gen_ie + 2 + 4;
1460 RSNIeLen = gen_ie_len - (2 + 4);
1461 // Unpack the WPA IE
1462 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1463 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1464 pRsnIe,
1465 RSNIeLen,
1466 &dot11WPAIE);
1467 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001468 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001469 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001470 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001471 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 //dot11WPAIE.auth_suite_count
1473 // Just translate the FIRST one
1474 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1475 //dot11WPAIE.unicast_cipher_count
1476 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1477 //dot11WPAIE.unicast_cipher_count
1478 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001479 *pMFPCapable = VOS_FALSE;
1480 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 }
1482 else
1483 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001484 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 return VOS_STATUS_E_FAILURE;
1486 }
1487 return VOS_STATUS_SUCCESS;
1488}
Leo Chang614d2072013-08-22 14:59:44 -07001489
Leo Chang0b0e45a2013-12-15 15:18:55 -08001490#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001491
1492/*==========================================================================
1493 FUNCTION sapUpdateUnsafeChannelList
1494
1495 DESCRIPTION
1496 Function Undate unsafe channel list table
1497
1498 DEPENDENCIES
1499 NA.
1500
1501 PARAMETERS
1502
1503 IN
1504 pSapCtx : SAP context pointer, include unsafe channel list
1505
1506 RETURN VALUE
1507 NONE
1508============================================================================*/
1509void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1510 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1511{
1512 v_U16_t i, j;
1513
1514 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1515 sizeof(pHddCtx->unsafeChannelList));
1516 if (0 == unsafeChannelCount)
1517 {
1518 pHddCtx->unsafeChannelCount = 0;
1519 }
1520 else
1521 {
c_hpothu8de53e42014-08-22 15:00:37 +05301522 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1523 {
1524 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1525 FL("unsafeChannelCount%hd greater than %d"),
1526 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1527 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1528 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001529 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1530 unsafeChannelList,
1531 unsafeChannelCount * sizeof(tANI_U16));
1532 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1533 }
1534
1535 /* Flush, default set all channel safe */
1536 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1537 {
1538 safeChannels[i].isSafe = VOS_TRUE;
1539 }
1540
1541 /* Try to find unsafe channel */
1542 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1543 {
1544 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1545 {
1546 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1547 {
1548 /* Found unsafe channel, update it */
1549 safeChannels[j].isSafe = VOS_FALSE;
1550 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1551 "%s : CH %d is not safe",
1552 __func__, pHddCtx->unsafeChannelList[i]);
1553 break;
1554 }
1555 }
1556 }
1557
1558 return;
1559}
1560
Kapil Gupta137ef892016-12-13 19:38:00 +05301561/**
1562 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1563 * @adapter: hdd ap adapter
1564 *
1565 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1566 * and if ACS is enabled, driver will ask userspace to restart the
1567 * sap. User space on LTE coex indication restart driver.
1568 *
1569 * Return - none
1570 */
1571static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1572 hdd_context_t *hdd_ctx)
1573{
1574
1575 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1576 return;
1577 }
1578
1579 hddLog(LOG1, FL("Current operation channel %d"),
1580 adapter->sessionCtx.ap.operatingChannel);
1581 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1582 hdd_change_ch_avoidance_status(hdd_ctx, true);
1583
1584 vos_flush_work(
1585 &hdd_ctx->sap_start_work);
1586
1587 /*
1588 * current operating channel
1589 * is un-safe channel, restart SAP
1590 */
1591 hddLog(LOG1,
1592 FL("Restarting SAP due to unsafe channel"));
1593
1594 adapter->sessionCtx.ap.sapConfig.channel =
1595 AUTO_CHANNEL_SELECT;
1596
Kapil Gupta137ef892016-12-13 19:38:00 +05301597
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301598 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05301599 netif_tx_disable(adapter->dev);
1600 schedule_work(&hdd_ctx->sap_start_work);
1601 } else {
1602 hdd_hostapd_stop(adapter->dev);
1603 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301604
1605 return;
1606 }
1607 return;
1608}
1609
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301610void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
1611 hdd_context_t *hdd_ctxt)
1612{
1613 v_U16_t channelLoop;
1614 v_U16_t unsafeChannelCount = 0;
1615 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1616
1617 /* Get unsafe channel list */
1618 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
1619 &unsafeChannelCount);
1620 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1621 {
1622 if ((unsafeChannelList[channelLoop] ==
1623 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
1624 if ((AUTO_CHANNEL_SELECT ==
1625 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
1626 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
1627 /*
1628 * current operating channel is un-safe channel
1629 * restart driver
1630 */
1631 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
1632 /*
1633 * On LE, this event is handled by wlan-services to
1634 * restart SAP. On android, this event would be
1635 * ignored.
1636 */
1637 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1638 NULL, 0);
1639 }
1640 break;
1641 }
1642 }
1643 return;
1644}
1645
1646
Kapil Gupta137ef892016-12-13 19:38:00 +05301647
Leo Chang0b0e45a2013-12-15 15:18:55 -08001648/**---------------------------------------------------------------------------
1649
1650 \brief hdd_hostapd_ch_avoid_cb() -
1651
1652 Avoid channel notification from FW handler.
1653 FW will send un-safe channle list to avoid overwrapping.
1654 hostapd should not use notified channel
1655
1656 \param - pAdapter HDD adapter pointer
1657 indParam channel avoid notification parameter
1658
1659 \return - None
1660
1661 --------------------------------------------------------------------------*/
1662void hdd_hostapd_ch_avoid_cb
1663(
Kapil Gupta137ef892016-12-13 19:38:00 +05301664 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08001665 void *indParam
1666)
1667{
1668 hdd_adapter_t *pHostapdAdapter = NULL;
1669 hdd_context_t *hddCtxt;
1670 tSirChAvoidIndType *chAvoidInd;
1671 v_U8_t rangeLoop;
1672 v_U16_t channelLoop;
1673 v_U16_t dupCheck;
1674 v_U16_t startChannel;
1675 v_U16_t endChannel;
1676 v_U16_t unsafeChannelCount = 0;
1677 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1678 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001679 tHddAvoidFreqList hddAvoidFreqList;
1680 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301681#ifdef WLAN_FEATURE_AP_HT40_24G
1682 ptSapContext pSapCtx = NULL;
1683 tHalHandle hHal;
1684 v_U8_t cbMode;
1685 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1686 v_U32_t delay;
1687#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001688
1689 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05301690 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001691 {
1692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1693 "%s : Invalid arguments", __func__);
1694 return;
1695 }
1696
Kapil Gupta137ef892016-12-13 19:38:00 +05301697 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001698 chAvoidInd = (tSirChAvoidIndType *)indParam;
1699 pVosContext = hddCtxt->pvosContext;
1700
1701 /* Make unsafe channel list */
1702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1703 "%s : band count %d",
1704 __func__, chAvoidInd->avoidRangeCount);
1705 vos_mem_zero((void *)unsafeChannelList,
1706 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1707 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1708 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301709 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1710 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1711 break;
1712 }
1713 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001714 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301715 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001716 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1718 "%s : start %d : %d, end %d : %d",
1719 __func__,
1720 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1721 startChannel,
1722 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1723 endChannel);
1724 for (channelLoop = startChannel;
1725 channelLoop < (endChannel + 1);
1726 channelLoop++)
1727 {
1728 /* Channel duplicate check routine */
1729 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1730 {
1731 if (unsafeChannelList[dupCheck] == channelLoop)
1732 {
1733 /* This channel is duplicated */
1734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1735 "%s : found duplicated channel %d",
1736 __func__, channelLoop);
1737 break;
1738 }
1739 }
1740 if (dupCheck == unsafeChannelCount)
1741 {
c_hpothu8de53e42014-08-22 15:00:37 +05301742 int ii;
1743 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1744 {
1745 if (channelLoop == safeChannels[ii].channelNumber)
1746 {
1747 unsafeChannelList[unsafeChannelCount] = channelLoop;
1748 unsafeChannelCount++;
1749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1750 "%s : unsafe channel %d, count %d",
1751 __func__,
1752 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301753 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1754 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1755 break;
1756 }
c_hpothu8de53e42014-08-22 15:00:37 +05301757 }
1758 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001759 }
1760 else
1761 {
1762 /* DUP, do nothing */
1763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1764 "%s : duplicated channel %d",
1765 __func__, channelLoop);
1766 }
1767 }
1768 }
1769 /* Update unsafe channel cache
1770 * WCN Platform Driver cache */
1771 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1772 unsafeChannelCount);
1773
1774 /* Store into local cache
1775 * Start with STA and later start SAP
1776 * in this scenario, local cache will be used */
1777 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1778 unsafeChannelList,
1779 unsafeChannelCount);
1780
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001781 /* generate vendor specific event */
1782 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1783 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1784 {
1785 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1786 chAvoidInd->avoidFreqRange[i].startFreq;
1787 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1788 chAvoidInd->avoidFreqRange[i].endFreq;
1789 }
1790 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1791
1792 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1793
Leo Chang0b0e45a2013-12-15 15:18:55 -08001794 /* Get SAP context first
1795 * SAP and P2PGO would not concurrent */
1796 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301797#ifdef WLAN_FEATURE_AP_HT40_24G
1798 if (NULL == pHostapdAdapter)
1799 {
1800 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1801 }
1802#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301803 if ((pHostapdAdapter) &&
1804 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1805 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001806 {
1807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1808 "%s : Current operation channel %d",
1809 __func__,
1810 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301811 /* Check and Restart the SAP if it is on unsafe channel */
1812 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
1813
Leo Chang0b0e45a2013-12-15 15:18:55 -08001814 }
1815
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301816#ifdef WLAN_FEATURE_AP_HT40_24G
1817 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1818 {
1819 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1820
1821 if(pSapCtx == NULL)
1822 {
1823 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1824 FL("psapCtx is NULL"));
1825 return;
1826 }
1827
1828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1829 FL("SAP Secondary channel: %d "),
1830 pSapCtx->sap_sec_chan);
1831
1832 /* tHalHandle */
1833 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1834
1835 if (NULL == hHal)
1836 {
1837 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1838 FL("In invalid hHal"));
1839 return;
1840 }
1841
1842 cbMode = sme_GetChannelBondingMode24G(hHal);
1843
1844 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1845 FL("Selected Channel bonding : %d"), cbMode);
1846
1847 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1848 {
1849 int i;
1850 eHalStatus halStatus;
1851
1852 for (i = 0; i < unsafeChannelCount; i++)
1853 {
1854 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1855 {
1856 /* Current SAP Secondary channel is un-safe channel */
1857 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1858 FL("Move SAP from HT40 to HT20"));
1859
1860 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1861 PHY_SINGLE_CHANNEL_CENTERED);
1862
1863 if (halStatus == eHAL_STATUS_FAILURE)
1864 {
1865 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1866 FL("Failed to change HT20/40 mode"));
1867 return;
1868 }
1869
1870 /* Disable Channel Bonding for 2.4GHz */
1871 sme_UpdateChannelBondingMode24G(hHal,
1872 PHY_SINGLE_CHANNEL_CENTERED);
1873 return;
1874 }
1875 }
1876 }
1877
1878 if ((!pSapCtx->numHT40IntoSta)
1879 && (pHostapdAdapter)
1880 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1881 {
1882 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1883 * are Safe then start HT20/40 timer to Move SAP from HT20
1884 * to HT40.
1885 */
1886 if (((!unsafeChannelCount)
1887 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1888 {
1889 /* Stop Previous Running HT20/40 Timer & Start timer
1890 with (OBSS TransitionDelayFactor * obss interval)
1891 delay after time out move AP from HT20 -> HT40
1892 mode
1893 */
1894 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1895 {
1896 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1897 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1898 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1899 FL("Failed to Stop HT20/40 timer"));
1900 }
1901
1902 delay =
1903 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1904
1905 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1906 FL("Start HT20/40 transition timer (%d sec)"), delay);
1907
1908 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1909 (delay * 1000));
1910
1911 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1912 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1913 FL("Failed to Start HT20/40 timer"));
1914 }
1915 else
1916 {
1917 /* Stop HT20/40 Timer */
1918 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1919 {
1920 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1921 FL("Stop HT20/40 transition timer"));
1922 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1923 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1924 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1925 FL("Failed to Stop HT20/40 timer"));
1926 }
1927 }
1928 }
1929 }
1930#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001931 return;
1932}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001933#endif /* FEATURE_WLAN_CH_AVOID */
1934
Jeff Johnson295189b2012-06-20 16:38:30 -07001935int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301936static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 struct iw_request_info *info,
1938 union iwreq_data *wrqu, char *extra)
1939{
1940 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001941 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301942 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 int *value = (int *)extra;
1944 int sub_cmd = value[0];
1945 int set_value = value[1];
1946 eHalStatus status;
1947 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05301948 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001949 v_CONTEXT_t pVosContext;
1950
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301951 ENTER();
1952
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301953 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001954 {
1955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301956 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001957 __func__);
1958 return -1;
1959 }
1960
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301961 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1962 ret = wlan_hdd_validate_context(pHddCtx);
1963 if (0 != ret)
1964 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301965 return -1;
1966 }
1967
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001968 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1969 if (!hHal)
1970 {
1971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1972 "%s: Hal ctx is null", __func__);
1973 return -1;
1974 }
1975
1976 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1977 if (!pVosContext)
1978 {
1979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1980 "%s: Vos ctx is null", __func__);
1981 return -1;
1982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001983
1984 switch(sub_cmd)
1985 {
1986
1987 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001988 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301990 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 }
1992 break;
1993
1994 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301995 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001996 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1997 {
1998 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1999 ret = -EINVAL;
2000 }
2001 else
2002 {
2003 WLANSAP_SetMode(pVosContext, set_value);
2004 }
2005 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302006
2007 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2008 if ((0 != set_value) && (1 != set_value))
2009 {
2010 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2011 ret = -EINVAL;
2012 }
2013 else
2014 {
2015 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2016 }
2017 break;
2018
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 case QCSAP_PARAM_MAX_ASSOC:
2020 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2021 {
2022 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2023 ret = -EINVAL;
2024 }
2025 else
2026 {
2027 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2028 {
2029 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2030 "Setting it to max allowed and continuing"),
2031 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2032 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2033 }
2034 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2035 set_value, NULL, eANI_BOOLEAN_FALSE);
2036 if ( status != eHAL_STATUS_SUCCESS )
2037 {
2038 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2039 status);
2040 ret = -EIO;
2041 }
2042 }
2043 break;
2044
2045 case QCSAP_PARAM_HIDE_SSID:
2046 {
2047 eHalStatus status = eHAL_STATUS_SUCCESS;
2048 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2049 if(eHAL_STATUS_SUCCESS != status)
2050 {
2051 hddLog(VOS_TRACE_LEVEL_ERROR,
2052 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002053 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 return status;
2055 }
2056 break;
2057 }
2058
Leo Chang614d2072013-08-22 14:59:44 -07002059 case QCSAP_PARAM_SET_MC_RATE:
2060 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002061 tSirRateUpdateInd *rateUpdate;
2062
2063 rateUpdate = (tSirRateUpdateInd *)
2064 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2065 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002066 {
2067 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002068 "%s: SET_MC_RATE indication alloc fail", __func__);
2069 ret = -1;
2070 break;
2071 }
2072 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2073
2074 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2075 /* Ignore unicast */
2076 rateUpdate->ucastDataRate = -1;
2077 rateUpdate->mcastDataRate24GHz = set_value;
2078 rateUpdate->mcastDataRate5GHz = set_value;
2079 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2080 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2081 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2082 if (eHAL_STATUS_SUCCESS != status)
2083 {
2084 hddLog(VOS_TRACE_LEVEL_ERROR,
2085 "%s: SET_MC_RATE failed", __func__);
2086 vos_mem_free(rateUpdate);
2087 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002088 }
2089 break;
2090 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302091 case QCSAP_PARAM_GET_FRAME_LOGS:
2092 {
2093 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2094 != VOS_STATUS_SUCCESS)
2095 {
2096 ret = -EINVAL;
2097 }
2098 break;
2099 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302100 case QCSAP_PARAM_SET_PROXIMITY:
2101 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302102 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302103 break;
2104 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302105 case QCSAP_PARAM_SET_WOWL:
2106 {
2107 if (!pHddCtx->is_ap_mode_wow_supported)
2108 {
2109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2110 "%s: Not supported",__func__);
2111 return -ENOTSUPP;
2112 }
2113 switch (set_value)
2114 {
2115 case 0x00:
2116 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2117 break;
2118 case 0x01:
2119 case 0x02:
2120 case 0x03:
2121 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2122 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2123 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2124 (enable_magic_pkt ? "YES":"NO"),
2125 (enable_pattrn_byte_match ? "YES":"NO"));
2126 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2127 enable_pattrn_byte_match);
2128 break;
2129 default:
2130 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2131 ret = -EINVAL;
2132 break;
2133 }
2134 break;
2135 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302136 case QCSAP_PARAM_CAP_TSF:
2137 {
2138 ret = hdd_capture_tsf(pHostapdAdapter,
2139 (uint32_t *)&set_value, 1);
2140 break;
2141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 default:
2143 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2144 sub_cmd, set_value);
2145 ret = -EINVAL;
2146 break;
2147 }
2148
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302149 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 return ret;
2151}
2152
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302153int
2154static iw_softap_setparam(struct net_device *dev,
2155 struct iw_request_info *info,
2156 union iwreq_data *wrqu, char *extra)
2157{
2158 int ret;
2159
2160 vos_ssr_protect(__func__);
2161 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2162 vos_ssr_unprotect(__func__);
2163
2164 return ret;
2165}
Jeff Johnson295189b2012-06-20 16:38:30 -07002166
2167int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302168static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 struct iw_request_info *info,
2170 union iwreq_data *wrqu, char *extra)
2171{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302172 hdd_adapter_t *pHostapdAdapter;
2173 tHalHandle hHal;
2174 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 int *value = (int *)extra;
2176 int sub_cmd = value[0];
2177 eHalStatus status;
2178 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302179 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002180
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302181 ENTER();
2182
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302183 pHostapdAdapter = (netdev_priv(dev));
2184 if (NULL == pHostapdAdapter)
2185 {
2186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2187 "%s: Adapter is NULL",__func__);
2188 return -EINVAL;
2189 }
2190 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2191 ret = wlan_hdd_validate_context(pHddCtx);
2192 if (0 != ret)
2193 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302194 return ret;
2195 }
2196 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2197 if (NULL == hHal)
2198 {
2199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2200 "%s: Hal Context is NULL",__func__);
2201 return -EINVAL;
2202 }
2203 pVosContext = pHddCtx->pvosContext;
2204 if (NULL == pVosContext)
2205 {
2206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2207 "%s: pVosContext Context is NULL",__func__);
2208 return -EINVAL;
2209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 switch (sub_cmd)
2211 {
2212 case QCSAP_PARAM_MAX_ASSOC:
2213 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2214 if (eHAL_STATUS_SUCCESS != status)
2215 {
c_hpothuffdb5272013-10-02 16:42:35 +05302216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2217 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 ret = -EIO;
2219 }
Girish Gowli385be612014-09-18 11:17:20 +05302220
2221#ifdef WLAN_SOFTAP_VSTA_FEATURE
2222 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2223 {
2224 if (*value > VSTA_NUM_ASSOC_STA)
2225 {
2226 *value = VSTA_NUM_ASSOC_STA;
2227 }
2228 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2229 (*value > (VSTA_NUM_ASSOC_STA -
2230 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2231 {
2232 *value = (VSTA_NUM_ASSOC_STA -
2233 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2234 }
2235 }
2236 else
2237#endif
2238 {
2239 if (*value > NUM_ASSOC_STA)
2240 {
2241 *value = NUM_ASSOC_STA;
2242 }
2243 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2244 (*value > (NUM_ASSOC_STA -
2245 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2246 {
2247 *value = (NUM_ASSOC_STA -
2248 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2249 }
2250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302252
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002254 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 {
c_hpothuffdb5272013-10-02 16:42:35 +05302256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2257 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302258 ret = -EIO;
2259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 *value = 0;
2261 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302262
Jeff Johnson43971f52012-07-17 12:26:56 -07002263 case QCSAP_PARAM_GET_WLAN_DBG:
2264 {
2265 vos_trace_display();
2266 *value = 0;
2267 break;
2268 }
2269
2270 case QCSAP_PARAM_AUTO_CHANNEL:
2271 {
2272 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2273 break;
2274 }
2275
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 default:
2277 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2278 ret = -EINVAL;
2279 break;
2280
2281 }
2282
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302283 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 return ret;
2285}
2286
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302287int
2288static iw_softap_getparam(struct net_device *dev,
2289 struct iw_request_info *info,
2290 union iwreq_data *wrqu, char *extra)
2291{
2292 int ret;
2293
2294 vos_ssr_protect(__func__);
2295 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2296 vos_ssr_unprotect(__func__);
2297
2298 return ret;
2299}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302300
2301int
2302static __iw_softap_setchar_getnone(struct net_device *dev,
2303 struct iw_request_info *info,
2304 union iwreq_data *wrqu, char *extra)
2305{
2306 int sub_cmd;
2307 int ret = 0; /* success */
2308 char *pBuffer = NULL;
2309 hdd_adapter_t *pAdapter;
2310 hdd_context_t *pHddCtx;
2311 struct iw_point s_priv_data;
2312
2313 ENTER();
2314
2315 if (!capable(CAP_NET_ADMIN))
2316 {
2317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2318 FL("permission check failed"));
2319 return -EPERM;
2320 }
2321
2322 pAdapter = (netdev_priv(dev));
2323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2324 ret = wlan_hdd_validate_context(pHddCtx);
2325 if (0 != ret)
2326 {
2327 return ret;
2328 }
2329
2330 if (!pHddCtx->is_ap_mode_wow_supported)
2331 {
2332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2333 "%s: Not supported",__func__);
2334 return -ENOTSUPP;
2335 }
2336
2337 /* helper function to get iwreq_data with compat handling. */
2338 if (hdd_priv_get_data(&s_priv_data, wrqu))
2339 {
2340 return -EINVAL;
2341 }
2342
2343 /* make sure all params are correctly passed to function */
2344 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2345 {
2346 return -EINVAL;
2347 }
2348
2349 sub_cmd = s_priv_data.flags;
2350
2351 /* ODD number is used for set, copy data using copy_from_user */
2352 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2353 s_priv_data.length);
2354 if (NULL == pBuffer)
2355 {
2356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2357 "mem_alloc_copy_from_user_helper fail");
2358 return -ENOMEM;
2359 }
2360
2361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2362 "%s: Received length %d", __func__, s_priv_data.length);
2363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2364 "%s: Received data %s", __func__, pBuffer);
2365
2366 switch(sub_cmd)
2367 {
2368 case WE_WOWL_ADD_PTRN:
2369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2370 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2371 if (!ret)
2372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2373 "Failed to add pattern :%d", ret);
2374 break;
2375 case WE_WOWL_DEL_PTRN:
2376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2377 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2378 if (!ret)
2379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2380 "Failed to del pattern :%d", ret);
2381 break;
2382 default:
2383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2384 ret = -EINVAL;
2385 break;
2386 }
2387
2388 kfree(pBuffer);
2389 return ret;
2390}
2391
2392int
2393static iw_softap_setchar_getnone(struct net_device *dev,
2394 struct iw_request_info *info,
2395 union iwreq_data *wrqu, char *extra)
2396{
2397 int ret;
2398
2399 vos_ssr_protect(__func__);
2400 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2401 vos_ssr_unprotect(__func__);
2402
2403 return ret;
2404}
2405
Jeff Johnson295189b2012-06-20 16:38:30 -07002406/* Usage:
2407 BLACK_LIST = 0
2408 WHITE_LIST = 1
2409 ADD MAC = 0
2410 REMOVE MAC = 1
2411
2412 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2413 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2414 while using this ioctl
2415
2416 Syntax:
2417 iwpriv softap.0 modify_acl
2418 <6 octet mac addr> <list type> <cmd type>
2419
2420 Examples:
2421 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2422 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2423 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2424 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2425*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302426int __iw_softap_modify_acl(struct net_device *dev,
2427 struct iw_request_info *info,
2428 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002429{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302430 hdd_adapter_t *pHostapdAdapter;
2431 v_CONTEXT_t pVosContext;
2432 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 v_BYTE_t *value = (v_BYTE_t*)extra;
2434 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2435 int listType, cmd, i;
2436 int ret = 0; /* success */
2437
2438 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302439 pHostapdAdapter = (netdev_priv(dev));
2440 if (NULL == pHostapdAdapter)
2441 {
2442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2443 "%s: Adapter is NULL",__func__);
2444 return -EINVAL;
2445 }
2446 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2447 ret = wlan_hdd_validate_context(pHddCtx);
2448 if (0 != ret)
2449 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302450 return ret;
2451 }
2452 pVosContext = pHddCtx->pvosContext;
2453 if (NULL == pVosContext)
2454 {
2455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2456 "%s: Vos Context is NULL",__func__);
2457 return -EINVAL;
2458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2460 {
2461 pPeerStaMac[i] = *(value+i);
2462 }
2463 listType = (int)(*(value+i));
2464 i++;
2465 cmd = (int)(*(value+i));
2466
Arif Hussain24bafea2013-11-15 15:10:03 -08002467 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2468 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002469
2470 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2471 != VOS_STATUS_SUCCESS)
2472 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002473 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 ret = -EIO;
2475 }
2476 EXIT();
2477 return ret;
2478}
2479
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302480int iw_softap_modify_acl(struct net_device *dev,
2481 struct iw_request_info *info,
2482 union iwreq_data *wrqu, char *extra)
2483{
2484 int ret;
2485
2486 vos_ssr_protect(__func__);
2487 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2488 vos_ssr_unprotect(__func__);
2489
2490 return ret;
2491}
2492
Jeff Johnson295189b2012-06-20 16:38:30 -07002493int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302494static __iw_softap_getchannel(struct net_device *dev,
2495 struct iw_request_info *info,
2496 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002497{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302498 hdd_adapter_t *pHostapdAdapter;
2499 hdd_context_t *pHddCtx;
2500 int ret = 0;
2501 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302502
2503 ENTER();
2504
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302505 pHostapdAdapter = (netdev_priv(dev));
2506 if (NULL == pHostapdAdapter)
2507 {
2508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2509 "%s: Adapter is NULL",__func__);
2510 return -EINVAL;
2511 }
2512 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2513 ret = wlan_hdd_validate_context(pHddCtx);
2514 if (0 != ret)
2515 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302516 return ret;
2517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002518
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302519 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002520
Jeff Johnson43971f52012-07-17 12:26:56 -07002521 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302522
2523 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 return 0;
2525}
2526
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302527
Jeff Johnsone7245742012-09-05 17:12:55 -07002528int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302529static iw_softap_getchannel(struct net_device *dev,
2530 struct iw_request_info *info,
2531 union iwreq_data *wrqu, char *extra)
2532{
2533 int ret;
2534
2535 vos_ssr_protect(__func__);
2536 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2537 vos_ssr_unprotect(__func__);
2538
2539 return ret;
2540}
2541
2542int
2543static __iw_softap_set_max_tx_power(struct net_device *dev,
2544 struct iw_request_info *info,
2545 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002546{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302547 hdd_adapter_t *pHostapdAdapter;
2548 tHalHandle hHal;
2549 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002550 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302551 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002552 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2553 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302555 ENTER();
2556
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302557 pHostapdAdapter = (netdev_priv(dev));
2558 if (NULL == pHostapdAdapter)
2559 {
2560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2561 "%s: Adapter is NULL",__func__);
2562 return -EINVAL;
2563 }
2564 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2565 ret = wlan_hdd_validate_context(pHddCtx);
2566 if (0 != ret)
2567 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302568 return ret;
2569 }
2570 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2571 if (NULL == hHal)
2572 {
2573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2574 "%s: Hal Context is NULL",__func__);
2575 return -EINVAL;
2576 }
schang86c22c42013-03-13 18:41:24 -07002577 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002578 return -ENOMEM;
2579
Leo Changd37675a2013-08-01 13:19:45 -07002580 /* Assign correct slef MAC address */
2581 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2582 VOS_MAC_ADDR_SIZE);
2583 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2584 VOS_MAC_ADDR_SIZE);
2585
schang86c22c42013-03-13 18:41:24 -07002586 set_value = value[0];
2587 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2588 {
2589 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002590 __func__);
schang86c22c42013-03-13 18:41:24 -07002591 return -EIO;
2592 }
2593
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302594 EXIT();
schang86c22c42013-03-13 18:41:24 -07002595 return 0;
2596}
2597
2598int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302599static iw_softap_set_max_tx_power(struct net_device *dev,
2600 struct iw_request_info *info,
2601 union iwreq_data *wrqu, char *extra)
2602{
2603 int ret;
2604
2605 vos_ssr_protect(__func__);
2606 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2607 vos_ssr_unprotect(__func__);
2608
2609 return ret;
2610}
2611
2612
2613int
2614static __iw_display_data_path_snapshot(struct net_device *dev,
2615 struct iw_request_info *info,
2616 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302617{
2618
2619 /* Function intitiating dumping states of
2620 * HDD(WMM Tx Queues)
2621 * TL State (with Per Client infor)
2622 * DXE Snapshot (Called at the end of TL Snapshot)
2623 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302624 hdd_adapter_t *pHostapdAdapter;
2625 hdd_context_t *pHddCtx;
2626 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302627
2628 ENTER();
2629
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302630 pHostapdAdapter = (netdev_priv(dev));
2631 if (NULL == pHostapdAdapter)
2632 {
2633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2634 "%s: Adapter is NULL",__func__);
2635 return -EINVAL;
2636 }
2637 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2638 ret = wlan_hdd_validate_context(pHddCtx);
2639 if (0 != ret)
2640 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302641 return ret;
2642 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302643 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302644 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302645
2646 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302647 return 0;
2648}
2649
2650int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302651static iw_display_data_path_snapshot(struct net_device *dev,
2652 struct iw_request_info *info,
2653 union iwreq_data *wrqu, char *extra)
2654{
2655 int ret;
2656
2657 vos_ssr_protect(__func__);
2658 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2659 vos_ssr_unprotect(__func__);
2660
2661 return ret;
2662}
2663
2664int
2665static __iw_softap_set_tx_power(struct net_device *dev,
2666 struct iw_request_info *info,
2667 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002668{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302669 hdd_adapter_t *pHostapdAdapter;
2670 hdd_context_t *pHddCtx;
2671 v_CONTEXT_t pVosContext;
2672 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002673 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302674 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002675 ptSapContext pSapCtx = NULL;
2676
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302677 ENTER();
2678
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302679 pHostapdAdapter = (netdev_priv(dev));
2680 if (NULL == pHostapdAdapter)
2681 {
2682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2683 "%s: Adapter is NULL",__func__);
2684 return -EINVAL;
2685 }
2686 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2687 ret = wlan_hdd_validate_context(pHddCtx);
2688 if (0 != ret)
2689 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302690 return ret;
2691 }
2692 pVosContext = pHddCtx->pvosContext;
2693 if (NULL == pVosContext)
2694 {
2695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2696 "%s: Vos Context is NULL",__func__);
2697 return -EINVAL;
2698 }
2699 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2700 if (NULL == hHal)
2701 {
2702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2703 "%s: Hal Context is NULL",__func__);
2704 return -EINVAL;
2705 }
schang86c22c42013-03-13 18:41:24 -07002706 if (NULL == value)
2707 return -ENOMEM;
2708
2709 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2710 if (NULL == pSapCtx)
2711 {
2712 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2713 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2714 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002715 }
2716
2717 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002718 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002719 {
schang86c22c42013-03-13 18:41:24 -07002720 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002721 __func__);
2722 return -EIO;
2723 }
2724
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302725 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002726 return 0;
2727}
2728
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302729int
2730static iw_softap_set_tx_power(struct net_device *dev,
2731 struct iw_request_info *info,
2732 union iwreq_data *wrqu, char *extra)
2733{
2734 int ret;
2735
2736 vos_ssr_protect(__func__);
2737 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2738 vos_ssr_unprotect(__func__);
2739
2740 return ret;
2741}
2742
Kiet Lambcf38522013-10-26 18:28:27 +05302743/**---------------------------------------------------------------------------
2744
2745 \brief iw_softap_set_trafficmonitor() -
2746 This function dynamically enable/disable traffic monitor functonality
2747 the command iwpriv wlanX setTrafficMon <value>.
2748
2749 \param - dev - Pointer to the net device.
2750 - addr - Pointer to the sockaddr.
2751 \return - 0 for success, non zero for failure
2752
2753 --------------------------------------------------------------------------*/
2754
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302755static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2756 struct iw_request_info *info,
2757 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302758{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302759 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302760 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302761 hdd_context_t *pHddCtx;
2762 int status;
2763
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302764 ENTER();
2765
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302766 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302767 if (NULL == pAdapter)
2768 {
2769 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2770 "%s: HDD adapter is Null", __func__);
2771 return -ENODEV;
2772 }
2773
2774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2775
2776 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302777 if (0 != status)
2778 {
Kiet Lambcf38522013-10-26 18:28:27 +05302779 return status;
2780 }
2781
2782 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2783
2784 if (NULL == isSetTrafficMon)
2785 {
2786 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2787 "%s: Invalid SAP pointer from extra", __func__);
2788 return -ENOMEM;
2789 }
2790
2791 if (TRUE == *isSetTrafficMon)
2792 {
2793 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05302794 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05302795 {
2796 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2797 "%s: failed to Start Traffic Monitor timer ", __func__ );
2798 return -EIO;
2799 }
2800 }
2801 else if (FALSE == *isSetTrafficMon)
2802 {
2803 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05302804 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05302805 {
2806 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2807 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2808 return -EIO;
2809 }
2810
2811 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302812
2813 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302814 return 0;
2815}
2816
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302817static int iw_softap_set_trafficmonitor(struct net_device *dev,
2818 struct iw_request_info *info,
2819 union iwreq_data *wrqu, char *extra)
2820{
2821 int ret;
2822
2823 vos_ssr_protect(__func__);
2824 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2825 vos_ssr_unprotect(__func__);
2826
2827 return ret;
2828}
2829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2831
2832int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302833static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2834 struct iw_request_info *info,
2835 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002836{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302837 hdd_adapter_t *pHostapdAdapter;
2838 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302839 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002840 char *buf;
2841 int cnt = 0;
2842 int left;
2843 int ret = 0;
2844 /* maclist_index must be u32 to match userspace */
2845 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302846 v_CONTEXT_t pVosContext = NULL;
2847 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302848
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302849 ENTER();
2850
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302851 pHostapdAdapter = (netdev_priv(dev));
2852 if (NULL == pHostapdAdapter)
2853 {
2854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2855 "%s: Adapter is NULL",__func__);
2856 return -EINVAL;
2857 }
2858 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2859 ret = wlan_hdd_validate_context(pHddCtx);
2860 if (0 != ret)
2861 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302862 return ret;
2863 }
2864
Jeff Johnson224f3702014-03-26 11:09:47 -07002865 /*
2866 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2867 * number, and even numbered iocts are supposed to have "set"
2868 * semantics. Hence the wireless extensions support in the kernel
2869 * won't correctly copy the result to userspace, so the ioctl
2870 * handler itself must copy the data. Output format is 32-bit
2871 * record length, followed by 0 or more 6-byte STA MAC addresses.
2872 *
2873 * Further note that due to the incorrect semantics, the "iwpriv"
2874 * userspace application is unable to correctly invoke this API,
2875 * hence it is not registered in the hostapd_private_args. This
2876 * API can only be invoked by directly invoking the ioctl() system
2877 * call.
2878 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002879
Jeff Johnson224f3702014-03-26 11:09:47 -07002880 /* make sure userspace allocated a reasonable buffer size */
2881 if (wrqu->data.length < sizeof(maclist_index)) {
2882 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2883 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302886 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2887 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2888 if(pSapCtx == NULL){
2889 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2890 FL("psapCtx is NULL"));
2891 return -EFAULT;
2892 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302893
2894 /* allocate local buffer to build the response */
2895 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2896 if (!buf) {
2897 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2898 return -ENOMEM;
2899 }
2900
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302901 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002902 /* start indexing beyond where the record count will be written */
2903 maclist_index = sizeof(maclist_index);
2904 left = wrqu->data.length - maclist_index;
2905
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302906 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002907 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2908 if ((pStaInfo[cnt].isUsed) &&
2909 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2910 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2911 VOS_MAC_ADDR_SIZE);
2912 maclist_index += VOS_MAC_ADDR_SIZE;
2913 left -= VOS_MAC_ADDR_SIZE;
2914 }
2915 cnt++;
2916 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302917 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002918
2919 *((u32 *)buf) = maclist_index;
2920 wrqu->data.length = maclist_index;
2921 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2922 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2923 ret = -EFAULT;
2924 }
2925 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302926
2927 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002928 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002929}
2930
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302931int
2932static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2933 struct iw_request_info *info,
2934 union iwreq_data *wrqu, char *extra)
2935{
2936 int ret;
2937
2938 vos_ssr_protect(__func__);
2939 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2940 vos_ssr_unprotect(__func__);
2941
2942 return ret;
2943}
2944
Jeff Johnson295189b2012-06-20 16:38:30 -07002945/* Usage:
2946 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2947 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2948 while using this ioctl
2949
2950 Syntax:
2951 iwpriv softap.0 disassoc_sta <6 octet mac address>
2952
2953 e.g.
2954 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2955 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2956*/
2957
2958int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302959static __iw_softap_disassoc_sta(struct net_device *dev,
2960 struct iw_request_info *info,
2961 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002962{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302963 hdd_adapter_t *pHostapdAdapter;
2964 hdd_context_t *pHddCtx;
2965 v_U8_t *peerMacAddr;
2966 int ret = 0;
2967
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302969
2970 if (!capable(CAP_NET_ADMIN)) {
2971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2972 FL("permission check failed"));
2973 return -EPERM;
2974 }
2975
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302976 pHostapdAdapter = (netdev_priv(dev));
2977 if (NULL == pHostapdAdapter)
2978 {
2979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2980 "%s: Adapter is NULL",__func__);
2981 return -EINVAL;
2982 }
2983 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2984 ret = wlan_hdd_validate_context(pHddCtx);
2985 if (0 != ret)
2986 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302987 return ret;
2988 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302989 /* iwpriv tool or framework calls this ioctl with
2990 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302992 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002993
Arif Hussain24bafea2013-11-15 15:10:03 -08002994 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2995 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2997 EXIT();
2998 return 0;
2999}
3000
3001int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303002static iw_softap_disassoc_sta(struct net_device *dev,
3003 struct iw_request_info *info,
3004 union iwreq_data *wrqu, char *extra)
3005{
3006 int ret;
3007
3008 vos_ssr_protect(__func__);
3009 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3010 vos_ssr_unprotect(__func__);
3011
3012 return ret;
3013}
3014
3015int
3016static __iw_softap_ap_stats(struct net_device *dev,
3017 struct iw_request_info *info,
3018 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003019{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303020 hdd_adapter_t *pHostapdAdapter;
3021 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 WLANTL_TRANSFER_STA_TYPE statBuffer;
3023 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303024 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303026 ENTER();
3027
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303028 pHostapdAdapter = (netdev_priv(dev));
3029 if (NULL == pHostapdAdapter)
3030 {
3031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3032 "%s: Adapter is NULL",__func__);
3033 return -EINVAL;
3034 }
3035 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3036 ret = wlan_hdd_validate_context(pHddCtx);
3037 if (0 != ret)
3038 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303039 return ret;
3040 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003041 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003042 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3043 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003044
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303045 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003046 if(NULL == pstatbuf) {
3047 hddLog(LOG1, "unable to allocate memory");
3048 return -ENOMEM;
3049 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303050
3051 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003052 "RUF=%d RMF=%d RBF=%d "
3053 "RUB=%d RMB=%d RBB=%d "
3054 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303055 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003056 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3057 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3058 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3059 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3060 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3061 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003062
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303063 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003064 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3065 kfree(pstatbuf);
3066 return -EFAULT;
3067 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303068
3069 strlcpy(extra, pstatbuf, len);
3070 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003071 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303072
3073 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 return 0;
3075}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303076int
3077static __iw_softap_ap_get_stats(struct net_device *dev,
3078 struct iw_request_info *info,
3079 union iwreq_data *wrqu, char *extra)
3080{
3081 hdd_adapter_t *pAdapter;
3082 hdd_tx_rx_stats_t *pStats;
3083
3084 ENTER();
3085 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3086 if (NULL == pAdapter)
3087 {
3088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: Adapter is NULL",__func__);
3090 return -EINVAL;
3091 }
3092
3093 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3094 snprintf(extra, QCSAP_MAX_STR_LEN,
3095 "\nTransmit"
3096 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3097 "\n dropped BK %u, BE %u, VI %u, VO %u"
3098 "\n classified BK %u, BE %u, VI %u, VO %u"
3099 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3100 "\n queued BK %u, BE %u, VI %u, VO %u"
3101 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3102 "\ndequeued %u, depressured %u, deque-depressured %u,\
3103 completed %u, flushed %u"
3104 "\n fetched BK %u, BE %u, VI %u, VO %u"
3105 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3106 "\n depressured BK %u, BE %u, VI %u, VO %u"
3107 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3108 "\n flushed BK %u, BE %u, VI %u, VO %u"
3109 "\n\nReceive"
3110 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3111 "\n\nResetsStats"
3112 "\n",
3113 pStats->txXmitCalled,
3114 pStats->txXmitDropped,
3115 pStats->txXmitBackPressured,
3116 pStats->txXmitQueued,
3117
3118 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3119 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3120 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3121 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3122
3123 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3124 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3125 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3126 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3127
3128 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3129 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3130 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3131 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3132
3133 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3134 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3135 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3136 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3137
3138 pStats->txFetched,
3139 pStats->txFetchEmpty,
3140 pStats->txFetchLowResources,
3141 pStats->txFetchDequeueError,
3142
3143 pStats->txFetchDequeued,
3144 pStats->txFetchDePressured,
3145 pStats->txDequeDePressured,
3146 pStats->txCompleted,
3147 pStats->txFlushed,
3148
3149 pStats->txFetchedAC[WLANTL_AC_BK],
3150 pStats->txFetchedAC[WLANTL_AC_BE],
3151 pStats->txFetchedAC[WLANTL_AC_VI],
3152 pStats->txFetchedAC[WLANTL_AC_VO],
3153
3154 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3155 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3156 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3157 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3158
3159 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3160 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3161 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3162 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3163
3164 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3165 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3166 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3167 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3168
3169 pStats->txFlushedAC[WLANTL_AC_BK],
3170 pStats->txFlushedAC[WLANTL_AC_BE],
3171 pStats->txFlushedAC[WLANTL_AC_VI],
3172 pStats->txFlushedAC[WLANTL_AC_VO],
3173
3174 pStats->rxChains,
3175 pStats->rxPackets,
3176 pStats->rxDropped,
3177 pStats->rxDelivered,
3178 pStats->rxRefused
3179 );
3180
3181 wrqu->data.length = strlen(extra) + 1;
3182
3183 return 0;
3184}
3185
3186int
3187static __iw_softap_ap_clear_stats(struct net_device *dev,
3188 struct iw_request_info *info,
3189 union iwreq_data *wrqu, char *extra)
3190{
3191 hdd_adapter_t *pAdapter;
3192
3193 ENTER();
3194
3195 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3196 if (NULL == pAdapter)
3197 {
3198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3199 "%s: Adapter is NULL",__func__);
3200 return -EINVAL;
3201 }
3202
3203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3204 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3205 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3206 return 0;
3207}
3208
3209
3210int
3211static iw_softap_get_stats(struct net_device *dev,
3212 struct iw_request_info *info,
3213 union iwreq_data *wrqu, char *extra)
3214{
3215 int ret;
3216 vos_ssr_protect(__func__);
3217 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3218 vos_ssr_unprotect(__func__);
3219 return ret;
3220}
3221
3222int
3223static iw_softap_clear_stats(struct net_device *dev,
3224 struct iw_request_info *info,
3225 union iwreq_data *wrqu, char *extra)
3226{
3227 int ret;
3228 vos_ssr_protect(__func__);
3229 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3230 vos_ssr_unprotect(__func__);
3231 return ret;
3232}
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303234int
3235static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 struct iw_request_info *info,
3237 union iwreq_data *wrqu, char *extra)
3238{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303239 int ret;
3240
3241 vos_ssr_protect(__func__);
3242 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3243 vos_ssr_unprotect(__func__);
3244
3245 return ret;
3246}
3247
Manjeet Singh3ed79242017-01-11 19:04:32 +05303248/**
3249 * __iw_softap_get_three() - return three value to upper layer.
3250 *
3251 * @dev: pointer of net_device of this wireless card
3252 * @info: meta data about Request sent
3253 * @wrqu: include request info
3254 * @extra: buf used for in/out
3255 *
3256 * Return: execute result
3257 */
3258static int __iw_softap_get_three(struct net_device *dev,
3259 struct iw_request_info *info,
3260 union iwreq_data *wrqu, char *extra)
3261{
3262 uint32_t *value = (uint32_t *)extra;
3263 uint32_t sub_cmd = value[0];
3264 int ret = 0; /* success */
3265
3266 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3267
3268 switch (sub_cmd) {
3269 case QCSAP_IOCTL_GET_TSF:
3270 ret = hdd_indicate_tsf(padapter, value, 3);
3271 break;
3272 default:
3273 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3274 break;
3275 }
3276 return ret;
3277}
3278
3279
3280/**
3281 * iw_softap_get_three() - return three value to upper layer.
3282 *
3283 * @dev: pointer of net_device of this wireless card
3284 * @info: meta data about Request sent
3285 * @wrqu: include request info
3286 * @extra: buf used for in/Output
3287 *
3288 * Return: execute result
3289 */
3290static int iw_softap_get_three(struct net_device *dev,
3291 struct iw_request_info *info,
3292 union iwreq_data *wrqu, char *extra)
3293{
3294 int ret;
3295
3296 vos_ssr_protect(__func__);
3297 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3298 vos_ssr_unprotect(__func__);
3299
3300 return ret;
3301}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303302static int __iw_softap_set_channel_range(struct net_device *dev,
3303 struct iw_request_info *info,
3304 union iwreq_data *wrqu, char *extra)
3305{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303306 hdd_adapter_t *pHostapdAdapter;
3307 tHalHandle hHal;
3308 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 int *value = (int *)extra;
3310 int startChannel = value[0];
3311 int endChannel = value[1];
3312 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003313 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 int ret = 0; /* success */
3315
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303316 ENTER();
3317
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303318 if (!capable(CAP_NET_ADMIN))
3319 {
3320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3321 FL("permission check failed"));
3322 return -EPERM;
3323 }
3324
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303325 pHostapdAdapter = (netdev_priv(dev));
3326 if (NULL == pHostapdAdapter)
3327 {
3328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3329 "%s: Adapter is NULL",__func__);
3330 return -EINVAL;
3331 }
3332 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3333 ret = wlan_hdd_validate_context(pHddCtx);
3334 if (0 != ret)
3335 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303336 return ret;
3337 }
3338 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3339 if (NULL == hHal)
3340 {
3341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3342 "%s: Hal Context is NULL",__func__);
3343 return -EINVAL;
3344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3346 if(status != VOS_STATUS_SUCCESS)
3347 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003348 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 startChannel,endChannel, band);
3350 ret = -EINVAL;
3351 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003352
3353 pHddCtx->is_dynamic_channel_range_set = 1;
3354
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303355 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 return ret;
3357}
3358
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303359static int iw_softap_set_channel_range(struct net_device *dev,
3360 struct iw_request_info *info,
3361 union iwreq_data *wrqu, char *extra)
3362{
3363 int ret;
3364
3365 vos_ssr_protect(__func__);
3366 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3367 vos_ssr_unprotect(__func__);
3368
3369 return ret;
3370}
3371
3372
3373int __iw_softap_get_channel_list(struct net_device *dev,
3374 struct iw_request_info *info,
3375 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003376{
3377 v_U32_t num_channels = 0;
3378 v_U8_t i = 0;
3379 v_U8_t bandStartChannel = RF_CHAN_1;
3380 v_U8_t bandEndChannel = RF_CHAN_165;
3381 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303382 hdd_adapter_t *pHostapdAdapter;
3383 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003386 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303387 hdd_context_t *pHddCtx;
3388 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303389
3390 ENTER();
3391
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303392 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3393 if (NULL == pHostapdAdapter)
3394 {
3395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3396 "%s: Adapter is NULL",__func__);
3397 return -EINVAL;
3398 }
3399 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3400 ret = wlan_hdd_validate_context(pHddCtx);
3401 if (0 != ret)
3402 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303403 return ret;
3404 }
3405 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3406 if (NULL == hHal)
3407 {
3408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3409 "%s: Hal Context is NULL",__func__);
3410 return -EINVAL;
3411 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003412 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3413 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003414 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003415 return -EIO;
3416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 wrqu->data.length = sizeof(tChannelListInfo);
3418 ENTER();
3419
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003420 if (eCSR_BAND_24 == curBand)
3421 {
3422 bandStartChannel = RF_CHAN_1;
3423 bandEndChannel = RF_CHAN_14;
3424 }
3425 else if (eCSR_BAND_5G == curBand)
3426 {
3427 bandStartChannel = RF_CHAN_36;
3428 bandEndChannel = RF_CHAN_165;
3429 }
3430
Arif Hussain6d2a3322013-11-17 19:50:10 -08003431 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303432 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003433 bandStartChannel, bandEndChannel );
3434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3436 {
3437 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3438 {
3439 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3440 num_channels++;
3441 }
3442 }
3443
3444 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3445
3446 temp_num_channels = num_channels;
3447
3448 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3449 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303450 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003451 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 }
3453
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303454 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3455 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 {
3457 for(i = 0; i < temp_num_channels; i++)
3458 {
3459
3460 if((channel_list->channels[i] > 35) &&
3461 (channel_list->channels[i] < 49))
3462 {
3463 vos_mem_move(&channel_list->channels[i],
3464 &channel_list->channels[i+1],
3465 temp_num_channels - (i-1));
3466 num_channels--;
3467 temp_num_channels--;
3468 i--;
3469 }
3470 }
3471 }
3472
Arif Hussain6d2a3322013-11-17 19:50:10 -08003473 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 channel_list->num_channels = num_channels;
3476 EXIT();
3477
3478 return 0;
3479}
3480
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303481int iw_softap_get_channel_list(struct net_device *dev,
3482 struct iw_request_info *info,
3483 union iwreq_data *wrqu, char *extra)
3484{
3485 int ret;
3486
3487 vos_ssr_protect(__func__);
3488 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3489 vos_ssr_unprotect(__func__);
3490
3491 return ret;
3492}
3493
3494static
3495int __iw_get_genie(struct net_device *dev,
3496 struct iw_request_info *info,
3497 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303499 hdd_adapter_t *pHostapdAdapter;
3500 hdd_context_t *pHddCtx;
3501 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303502 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3504 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303505 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303506
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303508
3509 pHostapdAdapter = (netdev_priv(dev));
3510 if (NULL == pHostapdAdapter)
3511 {
3512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3513 "%s: Adapter is NULL",__func__);
3514 return -EINVAL;
3515 }
3516 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3517 ret = wlan_hdd_validate_context(pHddCtx);
3518 if (0 != ret)
3519 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303520 return ret;
3521 }
3522 pVosContext = pHddCtx->pvosContext;
3523 if (NULL == pVosContext)
3524 {
3525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3526 "%s: vos context is not valid ",__func__);
3527 return -EINVAL;
3528 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003529 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3531 status = WLANSap_getstationIE_information(pVosContext,
3532 &length,
3533 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303534
3535 if (VOS_STATUS_SUCCESS != status) {
3536 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003537 return -EFAULT;
3538 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303539
Arif Hussained667642013-10-27 23:01:14 -07003540 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303541 if (length > DOT11F_IE_RSN_MAX_LEN) {
3542 hddLog(LOGE,
3543 FL("invalid buffer length length:%d"), length);
3544 return -E2BIG;
3545 }
3546
3547 vos_mem_copy(extra, genIeBytes, length);
3548
3549 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3550
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 EXIT();
3552 return 0;
3553}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303554
3555static
3556int iw_get_genie(struct net_device *dev,
3557 struct iw_request_info *info,
3558 union iwreq_data *wrqu, char *extra)
3559{
3560 int ret;
3561
3562 vos_ssr_protect(__func__);
3563 ret = __iw_get_genie(dev, info, wrqu, extra);
3564 vos_ssr_unprotect(__func__);
3565
3566 return ret;
3567}
3568
3569static
3570int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3571 struct iw_request_info *info,
3572 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003573{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303574 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003575 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303576 hdd_ap_ctx_t *pHddApCtx;
3577 hdd_context_t *pHddCtx;
3578 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303579
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003581
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303582 pHostapdAdapter = (netdev_priv(dev));
3583 if (NULL == pHostapdAdapter)
3584 {
3585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3586 "%s: Adapter is NULL",__func__);
3587 return -EINVAL;
3588 }
3589 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3590 ret = wlan_hdd_validate_context(pHddCtx);
3591 if (0 != ret)
3592 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303593 return ret;
3594 }
3595 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3596 if (NULL == pHddApCtx)
3597 {
3598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3599 "%s: AP context is NULL",__func__);
3600 return -EINVAL;
3601 }
3602
Arif Hussain6d2a3322013-11-17 19:50:10 -08003603 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003604 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3605
3606 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3607 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3608 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3609 WPSPBCProbeReqIEs.probeReqIELen);
3610 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3611 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3612 sizeof(v_MACADDR_t));
3613 if (copy_to_user(wrqu->data.pointer,
3614 (void *)&WPSPBCProbeReqIEs,
3615 sizeof(WPSPBCProbeReqIEs)))
3616 {
3617 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3618 return -EFAULT;
3619 }
3620 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003621 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003622 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 up(&pHddApCtx->semWpsPBCOverlapInd);
3624 EXIT();
3625 return 0;
3626}
3627
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303628static
3629int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3630 struct iw_request_info *info,
3631 union iwreq_data *wrqu, char *extra)
3632{
3633 int ret;
3634
3635 vos_ssr_protect(__func__);
3636 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3637 vos_ssr_unprotect(__func__);
3638
3639 return ret;
3640}
3641
Jeff Johnson295189b2012-06-20 16:38:30 -07003642/**---------------------------------------------------------------------------
3643
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303644 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 This function sets the auth type received from the wpa_supplicant.
3646
3647 \param - dev - Pointer to the net device.
3648 - info - Pointer to the iw_request_info.
3649 - wrqu - Pointer to the iwreq_data.
3650 - extra - Pointer to the data.
3651 \return - 0 for success, non zero for failure
3652
3653 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303654int __iw_set_auth_hostap(struct net_device *dev,
3655 struct iw_request_info *info,
3656 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003657{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303658 hdd_adapter_t *pAdapter;
3659 hdd_context_t *pHddCtx;
3660 hdd_wext_state_t *pWextState;
3661 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303662
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303664
3665 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3666 if (NULL == pAdapter)
3667 {
3668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3669 "%s: Adapter is NULL",__func__);
3670 return -EINVAL;
3671 }
3672
3673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3674 ret = wlan_hdd_validate_context(pHddCtx);
3675 if (0 != ret)
3676 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303677 return ret;
3678 }
3679 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3680 if (NULL == pWextState)
3681 {
3682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3683 "%s: pWextState is NULL",__func__);
3684 return -EINVAL;
3685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 switch(wrqu->param.flags & IW_AUTH_INDEX)
3687 {
3688 case IW_AUTH_TKIP_COUNTERMEASURES:
3689 {
3690 if(wrqu->param.value) {
3691 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3692 "Counter Measure started %d", wrqu->param.value);
3693 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303694 }
3695 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3697 "Counter Measure stopped=%d", wrqu->param.value);
3698 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3699 }
3700
3701 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3702 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303707
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003708 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 wrqu->param.flags & IW_AUTH_INDEX);
3710 break;
3711 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303712
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 EXIT();
3714 return 0;
3715}
3716
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303717int iw_set_auth_hostap(struct net_device *dev,
3718 struct iw_request_info *info,
3719 union iwreq_data *wrqu,char *extra)
3720{
3721 int ret;
3722
3723 vos_ssr_protect(__func__);
3724 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3725 vos_ssr_unprotect(__func__);
3726
3727 return ret;
3728}
3729
3730static int __iw_set_ap_encodeext(struct net_device *dev,
3731 struct iw_request_info *info,
3732 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003733{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303734 hdd_adapter_t *pHostapdAdapter;
3735 v_CONTEXT_t pVosContext;
3736 hdd_context_t *pHddCtx;
3737 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003738 int retval = 0;
3739 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3741 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3742 int key_index;
3743 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303744 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003745// tCsrRoamRemoveKey RemoveKey;
3746 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303747
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303748 ENTER();
3749 pHostapdAdapter = (netdev_priv(dev));
3750 if (NULL == pHostapdAdapter)
3751 {
3752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3753 "%s: Adapter is NULL",__func__);
3754 return -EINVAL;
3755 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003756
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303757 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3758 retval = wlan_hdd_validate_context(pHddCtx);
3759 if (0 != retval)
3760 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303761 return retval;
3762 }
3763 pVosContext = pHddCtx->pvosContext;
3764 if (NULL == pVosContext)
3765 {
3766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3767 "%s: pVosContext is NULL",__func__);
3768 return -EINVAL;
3769 }
3770 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3771 if (NULL == pHddApCtx)
3772 {
3773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3774 "%s: AP Context is NULL",__func__);
3775 return -EINVAL;
3776 }
3777
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303779
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303781
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 /*Convert from 1-based to 0-based keying*/
3783 key_index--;
3784 }
3785 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303786#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 /*Set the encrytion type to NONE*/
3788#if 0
3789 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3790#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303791
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 RemoveKey.keyId = key_index;
3793 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3794 /*Key direction for group is RX only*/
3795 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3796 }
3797 else {
3798 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3799 }
3800 switch(ext->alg)
3801 {
3802 case IW_ENCODE_ALG_NONE:
3803 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3804 break;
3805 case IW_ENCODE_ALG_WEP:
3806 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3807 break;
3808 case IW_ENCODE_ALG_TKIP:
3809 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003810 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 case IW_ENCODE_ALG_CCMP:
3812 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3813 break;
3814 default:
3815 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3816 break;
3817 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003818 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 -07003819 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003821 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003823 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3824 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 {
3826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003827 __LINE__, vstatus );
3828 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003830#endif
3831 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003832
Jeff Johnson43971f52012-07-17 12:26:56 -07003833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003834
3835 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3836
3837 setKey.keyId = key_index;
3838 setKey.keyLength = ext->key_len;
3839
3840 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3841 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3842 }
3843
3844 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3845 /*Key direction for group is RX only*/
3846 setKey.keyDirection = eSIR_RX_ONLY;
3847 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3848 }
3849 else {
3850
3851 setKey.keyDirection = eSIR_TX_RX;
3852 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3853 }
3854 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3855 {
3856 setKey.keyDirection = eSIR_TX_DEFAULT;
3857 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3858 }
3859
3860 /*For supplicant pae role is zero*/
3861 setKey.paeRole = 0;
3862
3863 switch(ext->alg)
3864 {
3865 case IW_ENCODE_ALG_NONE:
3866 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3867 break;
3868
3869 case IW_ENCODE_ALG_WEP:
3870 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3871 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003872 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 break;
3874
3875 case IW_ENCODE_ALG_TKIP:
3876 {
3877 v_U8_t *pKey = &setKey.Key[0];
3878
3879 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3880
3881 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3882
3883 /*Supplicant sends the 32bytes key in this order
3884
3885 |--------------|----------|----------|
3886 | Tk1 |TX-MIC | RX Mic |
3887 |--------------|----------|----------|
3888 <---16bytes---><--8bytes--><--8bytes-->
3889
3890 */
3891 /*Sme expects the 32 bytes key to be in the below order
3892
3893 |--------------|----------|----------|
3894 | Tk1 |RX-MIC | TX Mic |
3895 |--------------|----------|----------|
3896 <---16bytes---><--8bytes--><--8bytes-->
3897 */
3898 /* Copy the Temporal Key 1 (TK1) */
3899 vos_mem_copy(pKey,ext->key,16);
3900
3901 /*Copy the rx mic first*/
3902 vos_mem_copy(&pKey[16],&ext->key[24],8);
3903
3904 /*Copy the tx mic */
3905 vos_mem_copy(&pKey[24],&ext->key[16],8);
3906
3907 }
3908 break;
3909
3910 case IW_ENCODE_ALG_CCMP:
3911 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3912 break;
3913
3914 default:
3915 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3916 break;
3917 }
3918
3919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303920 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 setKey.keyId);
3922 for(i=0; i< ext->key_len; i++)
3923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3924 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003925
3926 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3927 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 {
3929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003930 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3931 retval = -EINVAL;
3932 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303933
3934 EXIT();
3935 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003936}
Jeff Johnson43971f52012-07-17 12:26:56 -07003937
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303938static int iw_set_ap_encodeext(struct net_device *dev,
3939 struct iw_request_info *info,
3940 union iwreq_data *wrqu, char *extra)
3941{
3942 int ret;
3943
3944 vos_ssr_protect(__func__);
3945 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3946 vos_ssr_unprotect(__func__);
3947
3948 return ret;
3949}
Jeff Johnson43971f52012-07-17 12:26:56 -07003950
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303951static int __iw_set_ap_mlme(struct net_device *dev,
3952 struct iw_request_info *info,
3953 union iwreq_data *wrqu,
3954 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003955{
3956#if 0
3957 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3958 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3959
3960 ENTER();
3961
3962 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3963 switch (mlme->cmd) {
3964 case IW_MLME_DISASSOC:
3965 case IW_MLME_DEAUTH:
3966 hddLog(LOG1, "Station disassociate");
3967 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3968 {
3969 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3970
3971 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3972 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3973
3974 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3975
3976 //clear all the reason codes
3977 if (status != 0)
3978 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003979 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 }
3981
3982 netif_stop_queue(dev);
3983 netif_carrier_off(dev);
3984 }
3985 else
3986 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003987 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 -07003988 }
3989 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003990 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 return -EINVAL;
3992 }//end of switch
3993 EXIT();
3994#endif
3995 return 0;
3996// return status;
3997}
3998
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303999static int iw_set_ap_mlme(struct net_device *dev,
4000 struct iw_request_info *info,
4001 union iwreq_data *wrqu,
4002 char *extra)
4003{
4004 int ret;
4005
4006 vos_ssr_protect(__func__);
4007 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4008 vos_ssr_unprotect(__func__);
4009
4010 return ret;
4011}
4012
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304013static int __iw_get_ap_rts_threshold(struct net_device *dev,
4014 struct iw_request_info *info,
4015 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004016{
4017 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4018 v_U32_t status = 0;
4019
4020 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4021
4022 return status;
4023}
4024
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304025static int iw_get_ap_rts_threshold(struct net_device *dev,
4026 struct iw_request_info *info,
4027 union iwreq_data *wrqu, char *extra)
4028{
4029 int ret;
4030
4031 vos_ssr_protect(__func__);
4032 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4033 vos_ssr_unprotect(__func__);
4034
4035 return ret;
4036}
4037
4038static int __iw_get_ap_frag_threshold(struct net_device *dev,
4039 struct iw_request_info *info,
4040 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004041{
4042 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4043 v_U32_t status = 0;
4044
4045 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4046
4047 return status;
4048}
4049
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304050static int iw_get_ap_frag_threshold(struct net_device *dev,
4051 struct iw_request_info *info,
4052 union iwreq_data *wrqu, char *extra)
4053{
4054 int ret;
4055
4056 vos_ssr_protect(__func__);
4057 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4058 vos_ssr_unprotect(__func__);
4059
4060 return ret;
4061}
4062
4063static int __iw_get_ap_freq(struct net_device *dev,
4064 struct iw_request_info *info,
4065 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004066{
Jeff Johnsone7245742012-09-05 17:12:55 -07004067 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304068 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 tHalHandle hHal;
4070 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304071 hdd_ap_ctx_t *pHddApCtx;
4072 hdd_context_t *pHddCtx;
4073 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004074
4075 ENTER();
4076
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304077 pHostapdAdapter = (netdev_priv(dev));
4078 if (NULL == pHostapdAdapter)
4079 {
4080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4081 "%s: Adapter is NULL",__func__);
4082 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304084 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4085 ret = wlan_hdd_validate_context(pHddCtx);
4086 if (0 != ret)
4087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304088 return ret;
4089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304091 if (NULL == pHostapdState)
4092 {
4093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4094 "%s: pHostapdState is NULL",__func__);
4095 return -EINVAL;
4096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304098 if (NULL == hHal)
4099 {
4100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4101 "%s: Hal Context is NULL",__func__);
4102 return -EINVAL;
4103 }
4104 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4105 if (NULL == pHddApCtx)
4106 {
4107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4108 "%s: AP context is NULL",__func__);
4109 return -EINVAL;
4110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 if(pHostapdState->bssState == BSS_STOP )
4112 {
4113 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4114 != eHAL_STATUS_SUCCESS)
4115 {
c_hpothuffdb5272013-10-02 16:42:35 +05304116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4117 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 return -EIO;
4119 }
4120 else
4121 {
4122 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004123 if( TRUE == status)
4124 {
4125 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4126 * iwlist & iwconfig command shows frequency into proper
4127 * format (2.412 GHz instead of 246.2 MHz)*/
4128 fwrq->m = freq;
4129 fwrq->e = MHZ;
4130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 }
4132 }
4133 else
4134 {
4135 channel = pHddApCtx->operatingChannel;
4136 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004137 if( TRUE == status)
4138 {
4139 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4140 * iwlist & iwconfig command shows frequency into proper
4141 * format (2.412 GHz instead of 246.2 MHz)*/
4142 fwrq->m = freq;
4143 fwrq->e = MHZ;
4144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304146
4147 EXIT();
4148 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004149}
4150
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304151static int iw_get_ap_freq(struct net_device *dev,
4152 struct iw_request_info *info,
4153 struct iw_freq *fwrq, char *extra)
4154{
4155 int ret;
4156
4157 vos_ssr_protect(__func__);
4158 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4159 vos_ssr_unprotect(__func__);
4160
4161 return ret;
4162}
4163
4164static int __iw_get_mode(struct net_device *dev,
4165 struct iw_request_info *info,
4166 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304167{
4168 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304169 hdd_adapter_t *pAdapter;
4170 hdd_context_t *pHddCtx;
4171
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304172 ENTER();
4173
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304174 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4175 if (NULL == pAdapter)
4176 {
4177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4178 "%s: Adapter is NULL",__func__);
4179 return -EINVAL;
4180 }
4181 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4182 status = wlan_hdd_validate_context(pHddCtx);
4183 if (0 != status)
4184 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304185 return status;
4186 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304187
4188 wrqu->mode = IW_MODE_MASTER;
4189
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304190 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304191 return status;
4192}
4193
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304194static int iw_get_mode(struct net_device *dev,
4195 struct iw_request_info *info,
4196 union iwreq_data *wrqu, char *extra)
4197{
4198 int ret;
4199
4200 vos_ssr_protect(__func__);
4201 ret = __iw_get_mode(dev, info, wrqu, extra);
4202 vos_ssr_unprotect(__func__);
4203
4204 return ret;
4205}
4206
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304207
4208static int __iw_softap_stopbss(struct net_device *dev,
4209 struct iw_request_info *info,
4210 union iwreq_data *wrqu,
4211 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004212{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304213 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304215 hdd_context_t *pHddCtx = NULL;
4216
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304218 pHostapdAdapter = (netdev_priv(dev));
4219 if (NULL == pHostapdAdapter)
4220 {
4221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4222 "%s: Adapter is NULL",__func__);
4223 return -EINVAL;
4224 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304225 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4226 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304227 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304228 return status;
4229 }
4230
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304231 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 {
4233 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4234 {
4235 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4236
4237 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304238
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304240 {
4241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004242 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 VOS_ASSERT(0);
4244 }
4245 }
4246 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304247 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 }
4249 EXIT();
4250 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4251}
4252
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304253static int iw_softap_stopbss(struct net_device *dev,
4254 struct iw_request_info *info,
4255 union iwreq_data *wrqu,
4256 char *extra)
4257{
4258 int ret;
4259
4260 vos_ssr_protect(__func__);
4261 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4262 vos_ssr_unprotect(__func__);
4263
4264 return ret;
4265}
4266
4267static int __iw_softap_version(struct net_device *dev,
4268 struct iw_request_info *info,
4269 union iwreq_data *wrqu,
4270 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004271{
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304273 hdd_context_t *pHddCtx;
4274 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304275
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304277 pHostapdAdapter = (netdev_priv(dev));
4278 if (NULL == pHostapdAdapter)
4279 {
4280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4281 "%s: Adapter is NULL",__func__);
4282 return -EINVAL;
4283 }
4284 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4285 ret = wlan_hdd_validate_context(pHddCtx);
4286 if (0 != ret)
4287 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304288 return ret;
4289 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004290 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 return 0;
4293}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004294
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304295static int iw_softap_version(struct net_device *dev,
4296 struct iw_request_info *info,
4297 union iwreq_data *wrqu,
4298 char *extra)
4299{
4300 int ret;
4301
4302 vos_ssr_protect(__func__);
4303 ret = __iw_softap_version(dev, info, wrqu, extra);
4304 vos_ssr_unprotect(__func__);
4305
4306 return ret;
4307}
4308
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304309int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004310{
4311 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004312 int len = 0;
4313 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304314 v_CONTEXT_t pVosContext;
4315 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304316 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304317
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304318 ENTER();
4319
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304320 if (NULL == pAdapter)
4321 {
4322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4323 "%s: Adapter is NULL",__func__);
4324 return -EINVAL;
4325 }
4326 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4327 if (0 != wlan_hdd_validate_context(pHddCtx))
4328 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304329 return VOS_STATUS_E_FAULT;
4330 }
4331 pVosContext = pHddCtx->pvosContext;
4332 if (NULL == pVosContext)
4333 {
4334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4335 "%s: VOS context is not valid",__func__);
4336 return VOS_STATUS_E_FAULT;
4337 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304338 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304339 if(pSapCtx == NULL)
4340 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304341 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4342 FL("psapCtx is NULL"));
4343 return VOS_STATUS_E_FAULT;
4344 }
4345
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304346 len = snprintf(pBuf, buf_len, sta_info_header);
4347 if (len >= buf_len) {
4348 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4349 return -E2BIG;
4350 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004351 pBuf += len;
4352 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004353
4354 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4355 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304356 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004357 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004358 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304359 pSapCtx->aStaInfo[i].ucSTAId,
4360 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4361 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4362 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4363 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4364 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4365 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304366 if (len >= buf_len) {
4367 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4368 return -E2BIG;
4369 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004370 pBuf += len;
4371 buf_len -= len;
4372 }
4373 if(WE_GET_STA_INFO_SIZE > buf_len)
4374 {
4375 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004376 }
4377 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304378 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304379 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004380}
4381
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304382static int __iw_softap_get_sta_info(struct net_device *dev,
4383 struct iw_request_info *info,
4384 union iwreq_data *wrqu,
4385 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004386{
4387 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304388 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004389 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304390 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4391 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004392 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304393 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004394 }
4395 wrqu->data.length = strlen(extra);
4396 EXIT();
4397 return 0;
4398}
4399
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304400static int iw_softap_get_sta_info(struct net_device *dev,
4401 struct iw_request_info *info,
4402 union iwreq_data *wrqu,
4403 char *extra)
4404{
4405 int ret;
4406
4407 vos_ssr_protect(__func__);
4408 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4409 vos_ssr_unprotect(__func__);
4410
4411 return ret;
4412}
4413
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304414static int __iw_set_ap_genie(struct net_device *dev,
4415 struct iw_request_info *info,
4416 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004417{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304418
4419 hdd_adapter_t *pHostapdAdapter;
4420 hdd_context_t *pHddCtx;
4421 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004423 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304424 int ret = 0;
4425
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304427 pHostapdAdapter = (netdev_priv(dev));
4428 if (NULL == pHostapdAdapter)
4429 {
4430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4431 "%s: Adapter is NULL",__func__);
4432 return -EINVAL;
4433 }
4434 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4435 ret = wlan_hdd_validate_context(pHddCtx);
4436 if (0 != ret)
4437 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304438 return ret;
4439 }
4440 pVosContext = pHddCtx->pvosContext;
4441 if (NULL == pVosContext)
4442 {
4443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4444 "%s: VOS Context is NULL",__func__);
4445 return -EINVAL;
4446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 if(!wrqu->data.length)
4448 {
4449 EXIT();
4450 return 0;
4451 }
Arif Hussained667642013-10-27 23:01:14 -07004452
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05304453 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
4454 {
4455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4456 "%s: WPARSN Ie input length is more than max[%d]", __func__,
4457 wrqu->data.length);
4458 return -EINVAL;
4459 }
4460
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304461 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304463 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 case DOT11F_EID_RSN:
4465 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4466 {
4467 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4468 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004471 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304473
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004475 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 halStatus = 0;
4477 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304478
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304480 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004481}
4482
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304483static int iw_set_ap_genie(struct net_device *dev,
4484 struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
4486{
4487 int ret;
4488
4489 vos_ssr_protect(__func__);
4490 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4491 vos_ssr_unprotect(__func__);
4492
4493 return ret;
4494}
4495
Jeff Johnson295189b2012-06-20 16:38:30 -07004496static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4497{
4498 eHalStatus hstatus;
4499 long lrc;
4500 struct statsContext context;
4501
4502 if (NULL == pAdapter)
4503 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304504 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 return VOS_STATUS_E_FAULT;
4506 }
4507
4508 init_completion(&context.completion);
4509 context.pAdapter = pAdapter;
4510 context.magic = STATS_CONTEXT_MAGIC;
4511 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4512 eCSR_HDD,
4513 SME_GLOBAL_CLASSA_STATS,
4514 hdd_GetClassA_statisticsCB,
4515 0, // not periodic
4516 FALSE, //non-cached results
4517 staid,
4518 &context);
4519 if (eHAL_STATUS_SUCCESS != hstatus)
4520 {
4521 hddLog(VOS_TRACE_LEVEL_ERROR,
4522 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004523 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 }
4525 else
4526 {
4527 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4528 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 if (lrc <= 0)
4530 {
4531 hddLog(VOS_TRACE_LEVEL_ERROR,
4532 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004533 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 }
4535 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004536
4537 /* either we never sent a request, we sent a request and received a
4538 response or we sent a request and timed out. if we never sent a
4539 request or if we sent a request and got a response, we want to
4540 clear the magic out of paranoia. if we timed out there is a
4541 race condition such that the callback function could be
4542 executing at the same time we are. of primary concern is if the
4543 callback function had already verified the "magic" but had not
4544 yet set the completion variable when a timeout occurred. we
4545 serialize these activities by invalidating the magic while
4546 holding a shared spinlock which will cause us to block if the
4547 callback is currently executing */
4548 spin_lock(&hdd_context_lock);
4549 context.magic = 0;
4550 spin_unlock(&hdd_context_lock);
4551
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 return VOS_STATUS_SUCCESS;
4553}
4554
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304555int __iw_get_softap_linkspeed(struct net_device *dev,
4556 struct iw_request_info *info,
4557 union iwreq_data *wrqu,
4558 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304561 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304562 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004564 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304565 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304567 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004569 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304570 int rc, valid;
4571
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304572 ENTER();
4573
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304574 pHostapdAdapter = (netdev_priv(dev));
4575 if (NULL == pHostapdAdapter)
4576 {
4577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4578 "%s: Adapter is NULL",__func__);
4579 return -EINVAL;
4580 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304581 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304582 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304583 if (0 != valid)
4584 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304585 return valid;
4586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004587
Arif Hussain6d2a3322013-11-17 19:50:10 -08004588 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004589
4590 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004591 {
Arif Hussaina9571842014-01-15 16:43:41 -08004592 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4593 if (NULL == pmacAddress) {
4594 hddLog(LOG1, "unable to allocate memory");
4595 return -ENOMEM;
4596 }
4597 if (copy_from_user((void *)pmacAddress,
4598 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4599 {
4600 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4601 kfree(pmacAddress);
4602 return -EFAULT;
4603 }
Manjeet Singha3739742016-05-03 16:21:46 +05304604 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004605
4606 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004607 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004608
4609 if (!VOS_IS_STATUS_SUCCESS(status ))
4610 {
4611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4612 }
Arif Hussained667642013-10-27 23:01:14 -07004613 }
Kiet Lam61589852013-09-19 17:10:58 +05304614 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304615 * link speed for first connected client will be returned.
4616 */
Arif Hussaina9571842014-01-15 16:43:41 -08004617 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304618 {
4619 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4620 }
4621 else
4622 {
4623 status = hdd_softap_GetStaId(pHostapdAdapter,
4624 (v_MACADDR_t *)macAddress, (void *)(&staId));
4625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004626
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304627 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304629 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 link_speed = 0;
4631 }
4632 else
4633 {
4634 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304635
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 if (!VOS_IS_STATUS_SUCCESS(status ))
4637 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304638 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 return -EINVAL;
4640 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304641
4642 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4643 staId, &link_speed);
4644
4645 link_speed = link_speed / 10;
4646
4647 if (0 == link_speed)
4648 {
4649 /* The linkspeed returned by HAL is in units of 500kbps.
4650 * converting it to mbps.
4651 * This is required to support legacy firmware which does
4652 * not return link capacity.
4653 */
4654 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 }
4657
4658 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004659 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304660
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 if ((rc < 0) || (rc >= len))
4662 {
4663 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304664 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 return -EIO;
4666 }
4667
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304668 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 return 0;
4670}
4671
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304672int iw_get_softap_linkspeed(struct net_device *dev,
4673 struct iw_request_info *info,
4674 union iwreq_data *wrqu,
4675 char *extra)
4676{
4677 int ret;
4678
4679 vos_ssr_protect(__func__);
4680 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4681 vos_ssr_unprotect(__func__);
4682
4683 return ret;
4684}
4685
4686
Jeff Johnson295189b2012-06-20 16:38:30 -07004687static const iw_handler hostapd_handler[] =
4688{
4689 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4690 (iw_handler) NULL, /* SIOCGIWNAME */
4691 (iw_handler) NULL, /* SIOCSIWNWID */
4692 (iw_handler) NULL, /* SIOCGIWNWID */
4693 (iw_handler) NULL, /* SIOCSIWFREQ */
4694 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4695 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304696 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 (iw_handler) NULL, /* SIOCSIWSENS */
4698 (iw_handler) NULL, /* SIOCGIWSENS */
4699 (iw_handler) NULL, /* SIOCSIWRANGE */
4700 (iw_handler) NULL, /* SIOCGIWRANGE */
4701 (iw_handler) NULL, /* SIOCSIWPRIV */
4702 (iw_handler) NULL, /* SIOCGIWPRIV */
4703 (iw_handler) NULL, /* SIOCSIWSTATS */
4704 (iw_handler) NULL, /* SIOCGIWSTATS */
4705 (iw_handler) NULL, /* SIOCSIWSPY */
4706 (iw_handler) NULL, /* SIOCGIWSPY */
4707 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4708 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4709 (iw_handler) NULL, /* SIOCSIWAP */
4710 (iw_handler) NULL, /* SIOCGIWAP */
4711 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4712 (iw_handler) NULL, /* SIOCGIWAPLIST */
4713 (iw_handler) NULL, /* SIOCSIWSCAN */
4714 (iw_handler) NULL, /* SIOCGIWSCAN */
4715 (iw_handler) NULL, /* SIOCSIWESSID */
4716 (iw_handler) NULL, /* SIOCGIWESSID */
4717 (iw_handler) NULL, /* SIOCSIWNICKN */
4718 (iw_handler) NULL, /* SIOCGIWNICKN */
4719 (iw_handler) NULL, /* -- hole -- */
4720 (iw_handler) NULL, /* -- hole -- */
4721 (iw_handler) NULL, /* SIOCSIWRATE */
4722 (iw_handler) NULL, /* SIOCGIWRATE */
4723 (iw_handler) NULL, /* SIOCSIWRTS */
4724 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4725 (iw_handler) NULL, /* SIOCSIWFRAG */
4726 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4727 (iw_handler) NULL, /* SIOCSIWTXPOW */
4728 (iw_handler) NULL, /* SIOCGIWTXPOW */
4729 (iw_handler) NULL, /* SIOCSIWRETRY */
4730 (iw_handler) NULL, /* SIOCGIWRETRY */
4731 (iw_handler) NULL, /* SIOCSIWENCODE */
4732 (iw_handler) NULL, /* SIOCGIWENCODE */
4733 (iw_handler) NULL, /* SIOCSIWPOWER */
4734 (iw_handler) NULL, /* SIOCGIWPOWER */
4735 (iw_handler) NULL, /* -- hole -- */
4736 (iw_handler) NULL, /* -- hole -- */
4737 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4738 (iw_handler) NULL, /* SIOCGIWGENIE */
4739 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4740 (iw_handler) NULL, /* SIOCGIWAUTH */
4741 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4742 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4743 (iw_handler) NULL, /* SIOCSIWPMKSA */
4744};
4745
Jeff Johnson224f3702014-03-26 11:09:47 -07004746/*
4747 * Note that the following ioctls were defined with semantics which
4748 * cannot be handled by the "iwpriv" userspace application and hence
4749 * they are not included in the hostapd_private_args array
4750 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4751 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004752
4753static const struct iw_priv_args hostapd_private_args[] = {
4754 { QCSAP_IOCTL_SETPARAM,
4755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4756 { QCSAP_IOCTL_SETPARAM,
4757 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304758 { QCSAP_PARAM_GET_FRAME_LOGS,
4759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 { QCSAP_PARAM_MAX_ASSOC,
4761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4762 { QCSAP_PARAM_HIDE_SSID,
4763 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004764 { QCSAP_PARAM_SET_MC_RATE,
4765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304766 { QCSAP_PARAM_SET_PROXIMITY,
4767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05304768 { QCSAP_PARAM_CAP_TSF,
4769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304770 { QCSAP_PARAM_SET_WOWL,
4771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 { QCSAP_IOCTL_GETPARAM,
4773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4775 { QCSAP_IOCTL_GETPARAM, 0,
4776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4777 { QCSAP_PARAM_MAX_ASSOC, 0,
4778 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004779 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4781 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4782 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304783 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 { QCSAP_PARAM_CLR_ACL, 0,
4786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4787 { QCSAP_PARAM_ACL_MODE,
4788 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304790 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 { QCSAP_IOCTL_STOPBSS,
4792 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4793 { QCSAP_IOCTL_VERSION, 0,
4794 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004795 { QCSAP_IOCTL_GET_STA_INFO, 0,
4796 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004798 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004801 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304803 { QCSAP_IOCTL_AP_STATS, 0,
4804 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05304805 /* handlers for main ioctl */
4806 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
4807 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
4808#ifdef WLAN_FEATURE_TSF
4809 { QCSAP_IOCTL_GET_TSF, 0,
4810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4811 "get_tsf" },
4812#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05304813 { QCSAP_IOCTL_GET_STATS, 0,
4814 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4815 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4817 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304818 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004819
4820 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4822 /* handlers for sub-ioctl */
4823 { WE_SET_WLAN_DBG,
4824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4825 0,
4826 "setwlandbg" },
4827
4828 /* handlers for main ioctl */
4829 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4830 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4831 0,
4832 "" },
4833
4834 /* handlers for sub-ioctl */
4835 { WE_LOG_DUMP_CMD,
4836 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4837 0,
4838 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 { WE_P2P_NOA_CMD,
4840 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4841 0,
4842 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004843 /* handlers for sub ioctl */
4844 {
4845 WE_MCC_CONFIG_CREDENTIAL,
4846 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4847 0,
4848 "setMccCrdnl" },
4849
4850 /* handlers for sub ioctl */
4851 {
4852 WE_MCC_CONFIG_PARAMS,
4853 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4854 0,
4855 "setMccConfig" },
4856
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 /* handlers for main ioctl */
4858 { QCSAP_IOCTL_MODIFY_ACL,
4859 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4860 0,
4861 "modify_acl" },
4862
4863 /* handlers for main ioctl */
4864 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4865 0,
4866 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4867 "getChannelList" },
4868
Jeff Johnsone7245742012-09-05 17:12:55 -07004869 /* handlers for main ioctl */
4870 { QCSAP_IOCTL_SET_TX_POWER,
4871 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4872 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304873 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004874
4875 /* handlers for main ioctl */
4876 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4877 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4878 0,
4879 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304880
4881 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4882 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4883 0,
4884 "dataSnapshot" },
4885
4886 /* handlers for main ioctl */
4887 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4888 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4889 0,
4890 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304891 /* handlers for main ioctl */
4892 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
4893 IW_PRIV_TYPE_CHAR| 512,
4894 0,
4895 "" },
4896
4897 /* handlers for sub-ioctl */
4898 { WE_WOWL_ADD_PTRN,
4899 IW_PRIV_TYPE_CHAR| 512,
4900 0,
4901 "wowlAddPtrn" },
4902
4903 { WE_WOWL_DEL_PTRN,
4904 IW_PRIV_TYPE_CHAR| 512,
4905 0,
4906 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004907};
Jeff Johnsone7245742012-09-05 17:12:55 -07004908
Jeff Johnson295189b2012-06-20 16:38:30 -07004909static const iw_handler hostapd_private[] = {
4910 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304911 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
4912 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
4913 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4916 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4917 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4918 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4919 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4920 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4921 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05304922 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304923 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4925 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4926 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4927 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004928 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004929 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4930 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004931 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304932 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304933 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304934 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4935 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004936};
4937const struct iw_handler_def hostapd_handler_def = {
4938 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4939 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4940 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4941 .standard = (iw_handler *)hostapd_handler,
4942 .private = (iw_handler *)hostapd_private,
4943 .private_args = hostapd_private_args,
4944 .get_wireless_stats = NULL,
4945};
4946#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4947struct net_device_ops net_ops_struct = {
4948 .ndo_open = hdd_hostapd_open,
4949 .ndo_stop = hdd_hostapd_stop,
4950 .ndo_uninit = hdd_hostapd_uninit,
4951 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4952 .ndo_tx_timeout = hdd_softap_tx_timeout,
4953 .ndo_get_stats = hdd_softap_stats,
4954 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4955 .ndo_do_ioctl = hdd_hostapd_ioctl,
4956 .ndo_change_mtu = hdd_hostapd_change_mtu,
4957 .ndo_select_queue = hdd_hostapd_select_queue,
4958 };
4959#endif
4960
4961int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4962{
4963 return VOS_STATUS_SUCCESS;
4964}
4965
4966void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4967{
4968#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4969 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4970#else
4971 pWlanHostapdDev->open = hdd_hostapd_open;
4972 pWlanHostapdDev->stop = hdd_hostapd_stop;
4973 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4974 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4975 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4976 pWlanHostapdDev->get_stats = hdd_softap_stats;
4977 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4978 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4979#endif
4980}
4981
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05304982VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304983{
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05304985#ifdef DHCP_SERVER_OFFLOAD
4986 hdd_dhcp_state_t *dhcp_status;
4987#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304988#ifdef MDNS_OFFLOAD
4989 hdd_mdns_state_t *mdns_status;
4990#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004992 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05304994 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004995#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004996 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4997 v_U16_t unsafeChannelCount;
4998#endif /* FEATURE_WLAN_CH_AVOID */
4999
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305000 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5002 "%s:LOGP in Progress. Ignore!!!",__func__);
5003 status = VOS_STATUS_E_FAILURE;
5004 }
5005
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305007
5008#ifdef SAP_AUTH_OFFLOAD
5009 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305010 {
5011 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5012 {
5013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5014 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5015 return VOS_STATUS_E_FAILURE;
5016 }
5017 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305018#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305019
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305020 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305022#ifdef DHCP_SERVER_OFFLOAD
5023 dhcp_status = &pAdapter->dhcp_status;
5024#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305025#ifdef MDNS_OFFLOAD
5026 mdns_status = &pAdapter->mdns_status;
5027#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305028
Nirav Shah7e3c8132015-06-22 23:51:42 +05305029 spin_lock_init(&pAdapter->sta_hash_lock);
5030 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5031
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005032 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5033
Leo Chang0b0e45a2013-12-15 15:18:55 -08005034#ifdef FEATURE_WLAN_CH_AVOID
5035 /* Get unsafe cahnnel list from cached location */
5036 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5037 sizeof(unsafeChannelList),
5038 &unsafeChannelCount);
5039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5040 "%s : Unsafe Channel count %d",
5041 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305042 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005043 unsafeChannelList,
5044 unsafeChannelCount);
5045#endif /* FEATURE_WLAN_CH_AVOID */
5046
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 // Zero the memory. This zeros the profile structure.
5048 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305049#ifdef DHCP_SERVER_OFFLOAD
5050 memset(dhcp_status, 0,sizeof(*dhcp_status));
5051#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305052#ifdef MDNS_OFFLOAD
5053 memset(mdns_status, 0,sizeof(*mdns_status));
5054#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305055
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 // Set up the pointer to the Wireless Extensions state structure
5057 // NOP
5058 status = hdd_set_hostapd(pAdapter);
5059 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 return status;
5062 }
5063
5064 status = vos_event_init(&phostapdBuf->vosEvent);
5065 if (!VOS_IS_STATUS_SUCCESS(status))
5066 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 return status;
5069 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305070#ifdef DHCP_SERVER_OFFLOAD
5071 status = vos_event_init(&dhcp_status->vos_event);
5072 if (!VOS_IS_STATUS_SUCCESS(status)) {
5073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5074 return status;
5075 }
5076#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305077#ifdef MDNS_OFFLOAD
5078 status = vos_event_init(&mdns_status->vos_event);
5079 if (!VOS_IS_STATUS_SUCCESS(status)) {
5080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5081 ("Hostapd HDD vos event init failed!!"));
5082 return status;
5083 }
5084#endif /* MDNS_OFFLOAD */
5085
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5087
5088 // Register as a wireless device
5089 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5090
5091 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305092 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 if ( !VOS_IS_STATUS_SUCCESS( status ))
5094 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005095 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305097
5098 status = hdd_wmm_adapter_init( pAdapter );
5099 if (!VOS_IS_STATUS_SUCCESS(status))
5100 {
5101 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005102 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305103 status, status );
5104 goto error_wmm_init;
5105 }
5106
5107 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5108
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305109 ini_cfg = pHddCtx->cfg_ini;
5110 if (re_init && ini_cfg) {
5111 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5112 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5113 ini_cfg->apOperatingBand);
5114 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5115 ini_cfg->apStartChannelNum,
5116 ini_cfg->apEndChannelNum,
5117 ini_cfg->apOperatingBand);
5118 }
5119
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305120 return status;
5121
5122error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305123 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 EXIT();
5125 return status;
5126}
5127
5128hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5129{
5130 struct net_device *pWlanHostapdDev = NULL;
5131 hdd_adapter_t *pHostapdAdapter = NULL;
5132 v_CONTEXT_t pVosContext= NULL;
5133
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305134 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5135#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5136 NET_NAME_UNKNOWN,
5137#endif
5138 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 if (pWlanHostapdDev != NULL)
5140 {
5141 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5142
5143 //Init the net_device structure
5144 ether_setup(pWlanHostapdDev);
5145
5146 //Initialize the adapter context to zeros.
5147 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5148 pHostapdAdapter->dev = pWlanHostapdDev;
5149 pHostapdAdapter->pHddCtx = pHddCtx;
5150 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5151
5152 //Get the Global VOSS context.
5153 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5154 //Save the adapter context in global context for future.
5155 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5156
5157 //Init the net_device structure
5158 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5159
5160 hdd_set_ap_ops( pHostapdAdapter->dev );
5161
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5163 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5164
5165 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5166 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5167
5168 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5170 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5171 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5174 }
5175 return pHostapdAdapter;
5176}
5177
5178VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5179{
5180 struct net_device *dev = pAdapter->dev;
5181 VOS_STATUS status = VOS_STATUS_SUCCESS;
5182
5183 ENTER();
5184
5185 if( rtnl_lock_held )
5186 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005187 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 if( dev_alloc_name(dev, dev->name) < 0 )
5189 {
5190 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5191 return VOS_STATUS_E_FAILURE;
5192 }
5193 }
5194 if (register_netdevice(dev))
5195 {
5196 hddLog(VOS_TRACE_LEVEL_FATAL,
5197 "%s:Failed:register_netdevice", __func__);
5198 return VOS_STATUS_E_FAILURE;
5199 }
5200 }
5201 else
5202 {
5203 if (register_netdev(dev))
5204 {
5205 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5206 return VOS_STATUS_E_FAILURE;
5207 }
5208 }
5209 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5210
5211 EXIT();
5212 return status;
5213}
5214
c_hpothu002231a2015-02-05 14:58:51 +05305215VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005216{
5217 ENTER();
5218
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305219 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 /* if we are being called during driver unload, then the dev has already
5222 been invalidated. if we are being called at other times, then we can
5223 detatch the wireless device handlers */
5224 if (pAdapter->dev)
5225 {
c_hpothu002231a2015-02-05 14:58:51 +05305226 if (TRUE == rtnl_held)
5227 {
5228 pAdapter->dev->wireless_handlers = NULL;
5229 }
5230 else
5231 {
5232 rtnl_lock();
5233 pAdapter->dev->wireless_handlers = NULL;
5234 rtnl_unlock();
5235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 }
5237 EXIT();
5238 return 0;
5239}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305240
5241/**
5242 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5243 * to supplicant, if there any clients connected to SAP interface.
5244 * @adapter: sap adapter context
5245 *
5246 * Return: nothing
5247 */
5248void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5249{
5250 tSap_Event sap_event;
5251 int staId;
5252 hdd_context_t *hdd_ctx;
5253 v_CONTEXT_t vos_ctx;
5254 ptSapContext sap_ctx;
5255
5256 ENTER();
5257
5258 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305259 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5261 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305262 return;
5263 }
5264
5265 vos_ctx = hdd_ctx->pvosContext;
5266 if (NULL == vos_ctx) {
5267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5268 "%s: VOS context is not valid",__func__);
5269 return;
5270 }
5271
5272 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5273 if (!sap_ctx) {
5274 hddLog(LOGE, FL("invalid sap context"));
5275 return;
5276 }
5277
5278 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5279 if (sap_ctx->aStaInfo[staId].isUsed) {
5280 hddLog(LOG1, FL("staId: %d isUsed: %d %p"),
5281 staId, sap_ctx->aStaInfo[staId].isUsed,
5282 sap_ctx);
5283
5284 if (vos_is_macaddr_broadcast(
5285 &sap_ctx->aStaInfo[staId].macAddrSTA))
5286 continue;
5287
5288 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5289 vos_mem_copy(
5290 &sap_event.sapevt.
5291 sapStationDisassocCompleteEvent.staMac,
5292 &sap_ctx->aStaInfo[staId].macAddrSTA,
5293 sizeof(v_MACADDR_t));
5294 sap_event.sapevt.sapStationDisassocCompleteEvent.
5295 reason =
5296 eSAP_MAC_INITATED_DISASSOC;
5297 sap_event.sapevt.sapStationDisassocCompleteEvent.
5298 statusCode =
5299 eSIR_SME_RESOURCES_UNAVAILABLE;
5300 hdd_hostapd_SAPEventCB(&sap_event,
5301 sap_ctx->pUsrContext);
5302 }
5303 }
5304
5305 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5306
5307 EXIT();
5308}
5309
5310/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305311 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305312 * @adapter: sap adapter context
5313 *
5314 * Return: nothing
5315 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305316void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305317{
5318 hdd_context_t *hdd_ctx;
5319 v_CONTEXT_t vos_ctx;
5320 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305321 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305322
5323 ENTER();
5324
5325 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305326 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5327 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5328 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305329 return;
5330 }
5331
5332 vos_ctx = hdd_ctx->pvosContext;
5333 if (NULL == vos_ctx) {
5334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5335 "%s: VOS context is not valid",__func__);
5336 return;
5337 }
5338
5339 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5340 if (!sap_ctx) {
5341 hddLog(LOGE, FL("invalid sap context"));
5342 return;
5343 }
5344
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305345 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5346 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5347 if (!VOS_IS_STATUS_SUCCESS(status))
5348 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5349 FL("Failed to Stop HT20/40 timer"));
5350 }
5351
5352 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5353 if (!VOS_IS_STATUS_SUCCESS(status))
5354 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5355 FL("Failed to Destroy HT20/40 timer"));
5356
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305357}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305358
5359/**
5360 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5361 * @adapter: hdd ap adapter
5362 *
5363 * hdd_force_scc_restart_sap will choose station channel and will
5364 * schedule work to restart the sap.
5365 *
5366 * Return - none
5367 */
5368void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5369 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5370{
5371 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5372 return;
5373 }
5374
5375 hddLog(LOG1, FL("Current operation channel %d"),
5376 adapter->sessionCtx.ap.operatingChannel);
5377 hddLog(LOG1, FL("STA channel is %d"),
5378 channelId);
5379
5380 vos_flush_work(
5381 &hdd_ctx->sap_start_work);
5382
5383 hddLog(LOGE,
5384 FL("Restarting SAP for force SCC "));
5385
5386 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5387
5388 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5389 netif_tx_disable(adapter->dev);
5390 schedule_work(&hdd_ctx->sap_start_work);
5391 } else {
5392 hdd_hostapd_stop(adapter->dev);
5393 }
5394 return;
5395}