blob: 03e187155c3bf7e7dd249db09b06c780235c38b7 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashish6773c902017-01-06 19:45:03 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053082#include <wlan_hdd_wowl.h>
Agrawal Ashish17ef5082016-10-17 18:33:21 +053083#include "wlan_hdd_hostapd.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Leo Chang0b0e45a2013-12-15 15:18:55 -080085#ifdef FEATURE_WLAN_CH_AVOID
86#include "wcnss_wlan.h"
87#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053088#include "wlan_hdd_trace.h"
89#include "vos_types.h"
90#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080091
Jeff Johnson295189b2012-06-20 16:38:30 -070092#define IS_UP(_dev) \
93 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
94#define IS_UP_AUTO(_ic) \
95 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
96#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070097#define WE_GET_STA_INFO_SIZE 30
98/* WEXT limition: MAX allowed buf len for any *
99 * IW_PRIV_TYPE_CHAR is 2Kbytes *
100 */
101#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530103#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700104
Leo Chang0b0e45a2013-12-15 15:18:55 -0800105#ifdef FEATURE_WLAN_CH_AVOID
106/* Channle/Freqency table */
107extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
108safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
109{
110 /*CH , SAFE, default safe */
111 {1 , VOS_TRUE}, //RF_CHAN_1,
112 {2 , VOS_TRUE}, //RF_CHAN_2,
113 {3 , VOS_TRUE}, //RF_CHAN_3,
114 {4 , VOS_TRUE}, //RF_CHAN_4,
115 {5 , VOS_TRUE}, //RF_CHAN_5,
116 {6 , VOS_TRUE}, //RF_CHAN_6,
117 {7 , VOS_TRUE}, //RF_CHAN_7,
118 {8 , VOS_TRUE}, //RF_CHAN_8,
119 {9 , VOS_TRUE}, //RF_CHAN_9,
120 {10 , VOS_TRUE}, //RF_CHAN_10,
121 {11 , VOS_TRUE}, //RF_CHAN_11,
122 {12 , VOS_TRUE}, //RF_CHAN_12,
123 {13 , VOS_TRUE}, //RF_CHAN_13,
124 {14 , VOS_TRUE}, //RF_CHAN_14,
125 {240, VOS_TRUE}, //RF_CHAN_240,
126 {244, VOS_TRUE}, //RF_CHAN_244,
127 {248, VOS_TRUE}, //RF_CHAN_248,
128 {252, VOS_TRUE}, //RF_CHAN_252,
129 {208, VOS_TRUE}, //RF_CHAN_208,
130 {212, VOS_TRUE}, //RF_CHAN_212,
131 {216, VOS_TRUE}, //RF_CHAN_216,
132 {36 , VOS_TRUE}, //RF_CHAN_36,
133 {40 , VOS_TRUE}, //RF_CHAN_40,
134 {44 , VOS_TRUE}, //RF_CHAN_44,
135 {48 , VOS_TRUE}, //RF_CHAN_48,
136 {52 , VOS_TRUE}, //RF_CHAN_52,
137 {56 , VOS_TRUE}, //RF_CHAN_56,
138 {60 , VOS_TRUE}, //RF_CHAN_60,
139 {64 , VOS_TRUE}, //RF_CHAN_64,
140 {100, VOS_TRUE}, //RF_CHAN_100,
141 {104, VOS_TRUE}, //RF_CHAN_104,
142 {108, VOS_TRUE}, //RF_CHAN_108,
143 {112, VOS_TRUE}, //RF_CHAN_112,
144 {116, VOS_TRUE}, //RF_CHAN_116,
145 {120, VOS_TRUE}, //RF_CHAN_120,
146 {124, VOS_TRUE}, //RF_CHAN_124,
147 {128, VOS_TRUE}, //RF_CHAN_128,
148 {132, VOS_TRUE}, //RF_CHAN_132,
149 {136, VOS_TRUE}, //RF_CHAN_136,
150 {140, VOS_TRUE}, //RF_CHAN_140,
151 {149, VOS_TRUE}, //RF_CHAN_149,
152 {153, VOS_TRUE}, //RF_CHAN_153,
153 {157, VOS_TRUE}, //RF_CHAN_157,
154 {161, VOS_TRUE}, //RF_CHAN_161,
155 {165, VOS_TRUE}, //RF_CHAN_165,
156};
157#endif /* FEATURE_WLAN_CH_AVOID */
158
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530159/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 * Function definitions
161 *-------------------------------------------------------------------------*/
162/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530164 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 This is called in response to ifconfig up
167
168 \param - dev Pointer to net_device structure
169
170 \return - 0 for success non-zero for failure
171
172 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530173int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 ENTER();
178
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530179 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
180 {
181 //WMM_INIT OR BSS_START not completed
182 hddLog( LOGW, "Ignore hostadp open request");
183 EXIT();
184 return 0;
185 }
186
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530187 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
188 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 //Turn ON carrier state
190 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530191 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 EXIT();
196 return 0;
197}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530198
199int hdd_hostapd_open (struct net_device *dev)
200{
201 int ret;
202
203 vos_ssr_protect(__func__);
204 ret = __hdd_hostapd_open(dev);
205 vos_ssr_unprotect(__func__);
206
207 return ret;
208}
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210/**---------------------------------------------------------------------------
211
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530212 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214 This is called in response to ifconfig down
215
216 \param - dev Pointer to net_device structure
217
218 \return - 0 for success non-zero for failure
219
220 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530221int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222{
223 ENTER();
224
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530226 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530227 //Stop all tx queues
228 netif_tx_disable(dev);
229
230 //Turn OFF carrier state
231 netif_carrier_off(dev);
232 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234 EXIT();
235 return 0;
236}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530237
238int hdd_hostapd_stop (struct net_device *dev)
239{
240 int ret;
241
242 vos_ssr_protect(__func__);
243 ret = __hdd_hostapd_stop(dev);
244 vos_ssr_unprotect(__func__);
245
246 return ret;
247}
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249/**---------------------------------------------------------------------------
250
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530251 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253 This is called during the netdev unregister to uninitialize all data
254associated with the device
255
256 \param - dev Pointer to net_device structure
257
258 \return - void
259
260 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530261static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700262{
263 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530264 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 ENTER();
267
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530270 hddLog(VOS_TRACE_LEVEL_ERROR,
271 FL("Invalid magic"));
272 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530274 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
275 if (NULL == pHddCtx)
276 {
277 hddLog(VOS_TRACE_LEVEL_ERROR,
278 FL("NULL pHddCtx"));
279 return;
280 }
281
282 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
283
284 /* after uninit our adapter structure will no longer be valid */
285 pHostapdAdapter->dev = NULL;
286 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 EXIT();
289}
290
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530291static void hdd_hostapd_uninit (struct net_device *dev)
292{
293 vos_ssr_protect(__func__);
294 __hdd_hostapd_uninit(dev);
295 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530297 return;
298}
Jeff Johnson295189b2012-06-20 16:38:30 -0700299/**============================================================================
300 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
301 transmitting packets. There are 2 versions of this function. One that uses
302 locked queue and other that uses lockless queues. Both have been retained to
303 do some performance testing
304 @param skb : [in] pointer to OS packet (sk_buff)
305 @param dev : [in] pointer to Libra network device
306
307 @return : NET_XMIT_DROP if packets are dropped
308 : NET_XMIT_SUCCESS if packet is enqueued succesfully
309 ===========================================================================*/
310int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
311{
312 return 0;
313}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530314
315int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700316{
317 return 0;
318}
319
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530320int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
321{
322 int ret;
323 vos_ssr_protect(__func__);
324 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
325 vos_ssr_unprotect(__func__);
326
327 return ret;
328}
329
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700330static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
331 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700333 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530334 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
335 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530337 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700338 /*
339 * Note that valid pointers are provided by caller
340 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530342 ENTER();
343
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700344 if (priv_data->total_len <= 0 ||
345 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
346 {
347 /* below we allocate one more byte for command buffer.
348 * To avoid addition overflow total_len should be
349 * smaller than INT_MAX. */
350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
351 __func__, priv_data->total_len);
352 ret = -EFAULT;
353 goto exit;
354 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530355 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 if (0 != status)
357 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530358 return status;
359 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700361 /* Allocate +1 for '\0' */
362 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
363 if (!command)
364 {
365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
366 ret = -ENOMEM;
367 goto exit;
368 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700369
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700370 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
371 {
372 ret = -EFAULT;
373 goto exit;
374 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800375
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 /* Make sure the command is NUL-terminated */
377 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700379 hddLog(VOS_TRACE_LEVEL_INFO,
380 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700382 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
383 {
384 hdd_setP2pNoa(pAdapter->dev, command);
385 }
386 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
387 {
388 hdd_setP2pOpps(pAdapter->dev, command);
389 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800390#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700391 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
392 {
393 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
394 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800395#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700396 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
397 {
398 /*
399 * command should be a string having format
400 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
401 */
402 hddLog(VOS_TRACE_LEVEL_INFO,
403 "%s: Received Command to Set Preferred Channels for SAP",
404 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800405
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700406 ret = sapSetPreferredChannel(command);
407 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530408 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
409 {
410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
411 tANI_U8 filterType = 0;
412 tANI_U8 *value;
413 value = command + 9;
414
415 /* Convert the value from ascii to integer */
416 ret = kstrtou8(value, 10, &filterType);
417 if (ret < 0)
418 {
419 /* If the input value is greater than max value of datatype,
420 * then also kstrtou8 fails
421 */
422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
423 "%s: kstrtou8 failed range ", __func__);
424 ret = -EINVAL;
425 goto exit;
426 }
427 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
428 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
429 {
430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
431 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
432 " 2-Sink ", __func__);
433 ret = -EINVAL;
434 goto exit;
435 }
436 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
437 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530438 pScanInfo = &pHddCtx->scan_info;
439 if (filterType && pScanInfo != NULL &&
440 pHddCtx->scan_info.mScanPending)
441 {
442 /*Miracast Session started. Abort Scan */
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
444 "%s, Aborting Scan For Miracast",__func__);
445 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
446 eCSR_SCAN_ABORT_DEFAULT);
447 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530448 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
449 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
450 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530451 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
452 {
453 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
454 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456exit:
457 if (command)
458 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700459 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 return ret;
463}
464
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700465#ifdef CONFIG_COMPAT
466static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
467 struct ifreq *ifr)
468{
469 struct {
470 compat_uptr_t buf;
471 int used_len;
472 int total_len;
473 } compat_priv_data;
474 hdd_priv_data_t priv_data;
475 int ret = 0;
476
477 /*
478 * Note that pAdapter and ifr have already been verified by caller,
479 * and HDD context has also been validated
480 */
481 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
482 sizeof(compat_priv_data))) {
483 ret = -EFAULT;
484 goto exit;
485 }
486 priv_data.buf = compat_ptr(compat_priv_data.buf);
487 priv_data.used_len = compat_priv_data.used_len;
488 priv_data.total_len = compat_priv_data.total_len;
489 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
490 exit:
491 return ret;
492}
493#else /* CONFIG_COMPAT */
494static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
495 struct ifreq *ifr)
496{
497 /* will never be invoked */
498 return 0;
499}
500#endif /* CONFIG_COMPAT */
501
502static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
503{
504 hdd_priv_data_t priv_data;
505 int ret = 0;
506
507 /*
508 * Note that pAdapter and ifr have already been verified by caller,
509 * and HDD context has also been validated
510 */
511 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
512 ret = -EFAULT;
513 } else {
514 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
515 }
516 return ret;
517}
518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530519static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700520 struct ifreq *ifr, int cmd)
521{
522 hdd_adapter_t *pAdapter;
523 hdd_context_t *pHddCtx;
524 int ret;
525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530526 ENTER();
527
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
529 if (NULL == pAdapter) {
530 hddLog(VOS_TRACE_LEVEL_ERROR,
531 "%s: HDD adapter context is Null", __func__);
532 ret = -ENODEV;
533 goto exit;
534 }
535 if (dev != pAdapter->dev) {
536 hddLog(VOS_TRACE_LEVEL_ERROR,
537 "%s: HDD adapter/dev inconsistency", __func__);
538 ret = -ENODEV;
539 goto exit;
540 }
541
542 if ((!ifr) || (!ifr->ifr_data)) {
543 ret = -EINVAL;
544 goto exit;
545 }
546
547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
548 ret = wlan_hdd_validate_context(pHddCtx);
549 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700550 ret = -EBUSY;
551 goto exit;
552 }
553
554 switch (cmd) {
555 case (SIOCDEVPRIVATE + 1):
556 if (is_compat_task())
557 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
558 else
559 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
560 break;
561 default:
562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
563 __func__, cmd);
564 ret = -EINVAL;
565 break;
566 }
567 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530568 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700569 return ret;
570}
571
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530572static int hdd_hostapd_ioctl(struct net_device *dev,
573 struct ifreq *ifr, int cmd)
574{
575 int ret;
576
577 vos_ssr_protect(__func__);
578 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
579 vos_ssr_unprotect(__func__);
580
581 return ret;
582}
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584/**---------------------------------------------------------------------------
585
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530586 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 This function sets the user specified mac address using
588 the command ifconfig wlanX hw ether <mac adress>.
589
590 \param - dev - Pointer to the net device.
591 - addr - Pointer to the sockaddr.
592 \return - 0 for success, non zero for failure
593
594 --------------------------------------------------------------------------*/
595
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530596static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597{
598 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530599 hdd_adapter_t *pAdapter;
600 hdd_context_t *pHddCtx;
601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530602
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
605 if (NULL == pAdapter)
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Adapter is NULL",__func__);
609 return -EINVAL;
610 }
611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
612 ret = wlan_hdd_validate_context(pHddCtx);
613 if (0 != ret)
614 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530615 return ret;
616 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
618 EXIT();
619 return 0;
620}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530621
622static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
623{
624 int ret;
625
626 vos_ssr_protect(__func__);
627 ret = __hdd_hostapd_set_mac_address(dev, addr);
628 vos_ssr_unprotect(__func__);
629
630 return ret;
631}
632
Jeff Johnson295189b2012-06-20 16:38:30 -0700633void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
634{
635 struct net_device *dev = (struct net_device *)usrDataForCallback;
636 v_BYTE_t we_custom_event[64];
637 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530639 hdd_context_t *pHddCtx;
640#ifdef DISABLE_CONCURRENCY_AUTOSAVE
641 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hdd_ap_ctx_t *pHddApCtx;
643#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
644
645 /* event_name space-delimiter driver_module_name */
646 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
647 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
648 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
649
650 ENTER();
651
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530652 pHostapdAdapter = netdev_priv(dev);
653 if ((NULL == pHostapdAdapter) ||
654 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
655 {
656 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
657 return;
658 }
659 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
660 if (0 != (wlan_hdd_validate_context(pHddCtx)))
661 {
662 return;
663 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530664#ifdef DISABLE_CONCURRENCY_AUTOSAVE
665 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530666 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 /*
668 This timer routine is going to be called only when AP
669 persona is up.
670 If there are concurrent sessions running we do not want
671 to shut down the Bss.Instead we run the timer again so
672 that if Autosave is enabled next time and other session
673 was down only then we bring down AP
674 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
676 vos_status = vos_timer_start(
677 &pHddApCtx->hdd_ap_inactivity_timer,
678 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
679 * 1000);
680 if (!VOS_IS_STATUS_SUCCESS(vos_status))
681 {
682 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
683 }
684 EXIT();
685 return;
686 }
687#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
688 memset(&we_custom_event, '\0', sizeof(we_custom_event));
689 memcpy(&we_custom_event, autoShutEvent, event_len);
690
691 memset(&wrqu, 0, sizeof(wrqu));
692 wrqu.data.length = event_len;
693
694 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
695 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
696
697 EXIT();
698}
699
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800700VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
701{
702 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
703 ptSapContext pSapCtx = NULL;
704 eHalStatus halStatus = eHAL_STATUS_FAILURE;
705 v_PVOID_t hHal = NULL;
706
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
708 "%s: UPDATE Beacon Params", __func__);
709
710 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
711 pSapCtx = VOS_GET_SAP_CB(pVosContext);
712 if ( NULL == pSapCtx )
713 {
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
715 "%s: Invalid SAP pointer from pvosGCtx", __func__);
716 return VOS_STATUS_E_FAULT;
717 }
718
719 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
720 if ( NULL == hHal ){
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Invalid HAL pointer from pvosGCtx", __func__);
723 return VOS_STATUS_E_FAULT;
724 }
725 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
726 if(halStatus == eHAL_STATUS_FAILURE ){
727 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
728 "%s: Failed to update Beacon Params", __func__);
729 return VOS_STATUS_E_FAILURE;
730 }
731 }
732 return VOS_STATUS_SUCCESS;
733}
734
735void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
736{
737 v_U8_t staId = 0;
738 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530739 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
740 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800741
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530742 dev = (struct net_device *)usrDataForCallback;
743 pSapCtx = VOS_GET_SAP_CB(pVosContext);
744 if(pSapCtx == NULL){
745 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
746 FL("psapCtx is NULL"));
747 return;
748 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800749 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
751 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530752 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800753 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
754 {
755 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530756 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800757 }
758 }
759}
760
Agarwal Ashish8e538932014-12-24 18:12:52 +0530761static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762{
763 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530764 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800765 VOS_STATUS status = VOS_STATUS_SUCCESS;
766 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530767
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800768 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530769
770 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
771 status = wlan_hdd_validate_context(pHddCtx);
772
773 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530774 return status;
775 }
776
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800777 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
778 {
779 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
780 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800782 }
783 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530784 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800785 }
786 EXIT();
787 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
788}
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530790#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530791bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530792 bool enabled)
793{
794 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530795 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530796
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530797 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530798 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
799
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530800 sap_offload_info.sap_auth_offload_enable = enabled;
801 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530802 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530803 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530804 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
805
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530806 if (sap_offload_info.sap_auth_offload_enable &&
807 sap_offload_info.sap_auth_offload_sec_type)
808 {
809 if (sap_offload_info.key_len < 8 ||
810 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
811 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530812 hddLog(VOS_TRACE_LEVEL_ERROR,
813 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530814 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530815 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530816 }
817 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530818 if (sap_offload_info.key_len)
819 {
820 vos_mem_copy(sap_offload_info.key,
821 pHddCtx->cfg_ini->sap_auth_offload_key,
822 sap_offload_info.key_len);
823 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530824 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530825 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
826 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530827 hddLog(VOS_TRACE_LEVEL_ERROR,
828 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530829 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530830 }
831
832 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
833 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530834 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530835}
836#endif
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
839{
840 hdd_adapter_t *pHostapdAdapter;
841 hdd_ap_ctx_t *pHddApCtx;
842 hdd_hostapd_state_t *pHostapdState;
843 struct net_device *dev;
844 eSapHddEvent sapEvent;
845 union iwreq_data wrqu;
846 v_BYTE_t *we_custom_event_generic = NULL;
847 int we_event = 0;
848 int i = 0;
849 v_U8_t staId;
850 VOS_STATUS vos_status;
851 v_BOOL_t bWPSState;
852 v_BOOL_t bApActive = FALSE;
853 v_BOOL_t bAuthRequired = TRUE;
854 tpSap_AssocMacAddr pAssocStasArray = NULL;
855 char unknownSTAEvent[IW_CUSTOM_MAX+1];
856 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
857 v_BYTE_t we_custom_start_event[64];
858 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800859 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800860 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700861 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530862 v_CONTEXT_t pVosContext = NULL;
863 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +0530864 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
866 dev = (struct net_device *)usrDataForCallback;
867 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530868
869 if ((NULL == pHostapdAdapter) ||
870 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
871 {
872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
873 "invalid adapter or adapter has invalid magic");
874 return eHAL_STATUS_FAILURE;
875 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530876 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
877 pSapCtx = VOS_GET_SAP_CB(pVosContext);
878 if(pSapCtx == NULL){
879 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
880 FL("psapCtx is NULL"));
881 return eHAL_STATUS_FAILURE;
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
884 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
885 sapEvent = pSapEvent->sapHddEventCode;
886 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800887 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +0530888 cfg_param = pHddCtx->cfg_ini;
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890
891 switch(sapEvent)
892 {
893 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800894 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
896 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
897 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
898
899 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
900 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +0530901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +0530903 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 goto stopbss;
906 }
907 else
Deepthi Gowried085092015-10-20 19:30:52 +0530908 {
909 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
910 {
911 if ((cfg_param->dynSplitscan) &&
912 (!pHddCtx->issplitscan_enabled))
913 {
914 pHddCtx->issplitscan_enabled = TRUE;
915 sme_enable_disable_split_scan(
916 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
917 cfg_param->nNumStaChanCombinedConc,
918 cfg_param->nNumP2PChanCombinedConc);
919 }
920 }
921
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
923 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530924 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
925 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530926 {
c_hpothuffdb5272013-10-02 16:42:35 +0530927 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530928 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 }
Deepthi Gowried085092015-10-20 19:30:52 +0530931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
933 {
934 // AP Inactivity timer init and start
935 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
936 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
937 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800938 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939
940 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
941 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800942 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 }
945 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
946 pHostapdState->bssState = BSS_START;
947
948 // Send current operating channel of SoftAP to BTC-ES
949 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 //Check if there is any group key pending to set.
952 if( pHddApCtx->groupKey.keyLength )
953 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700954 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
956 &pHddApCtx->groupKey ) )
957 {
958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 "%s: WLANSAP_SetKeySta failed", __func__);
960 }
961 pHddApCtx->groupKey.keyLength = 0;
962 }
963 else if ( pHddApCtx->wepKey[0].keyLength )
964 {
965 int i=0;
966 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
967 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700968 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
970 &pHddApCtx->wepKey[i] ) )
971 {
972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
973 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
974 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
976 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
978 startBssEvent = "SOFTAP.enabled";
979 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
980 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
981 memset(&wrqu, 0, sizeof(wrqu));
982 wrqu.data.length = strlen(startBssEvent);
983 we_event = IWEVCUSTOM;
984 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700985 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 break; //Event will be sent after Switch-Case stmt
987
988 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800989 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
991
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530992#ifdef SAP_AUTH_OFFLOAD
993 if (cfg_param->enable_sap_auth_offload)
994 hdd_set_sap_auth_offload(pHostapdAdapter, FALSE);
995#endif
996
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700997 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700998 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301001
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301002 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301003 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301004 hddLog(LOG1,
1005 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1006 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301007 }
1008
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 goto stopbss;
1010 case eSAP_STA_SET_KEY_EVENT:
1011 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001012 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1014 return VOS_STATUS_SUCCESS;
1015 case eSAP_STA_DEL_KEY_EVENT:
1016 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001017 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 return VOS_STATUS_SUCCESS;
1019 case eSAP_STA_MIC_FAILURE_EVENT:
1020 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 memset(&msg, '\0', sizeof(msg));
1022 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001023 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001024 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001025 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 msg.flags = IW_MICFAILURE_GROUP;
1027 else
1028 msg.flags = IW_MICFAILURE_PAIRWISE;
1029 memset(&wrqu, 0, sizeof(wrqu));
1030 wrqu.data.length = sizeof(msg);
1031 we_event = IWEVMICHAELMICFAILURE;
1032 we_custom_event_generic = (v_BYTE_t *)&msg;
1033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /* inform mic failure to nl80211 */
1035 cfg80211_michael_mic_failure(dev,
1036 pSapEvent->sapevt.
1037 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001038 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 NL80211_KEYTYPE_GROUP :
1040 NL80211_KEYTYPE_PAIRWISE),
1041 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1042 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1043 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 break;
1045
1046 case eSAP_STA_ASSOC_EVENT:
1047 case eSAP_STA_REASSOC_EVENT:
1048 wrqu.addr.sa_family = ARPHRD_ETHER;
1049 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001050 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001051 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 we_event = IWEVREGISTERED;
1053
1054 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1055
1056 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1057 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1058 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1059 {
1060 bAuthRequired = FALSE;
1061 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301062 /* fAuthRequiredshould should be false for sap offload */
1063 if ((bAuthRequired || bWPSState)
1064#ifdef SAP_AUTH_OFFLOAD
1065 && !cfg_param->enable_sap_auth_offload
1066#endif
1067 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 {
c_hpothuffdb5272013-10-02 16:42:35 +05301069 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 TRUE,
1071 pHddApCtx->uPrivacy,
1072 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1073 0,
1074 0,
1075 (v_MACADDR_t *)wrqu.addr.sa_data,
1076 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301077
1078 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1079 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1080 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 }
1082 else
1083 {
c_hpothuffdb5272013-10-02 16:42:35 +05301084 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 FALSE,
1086 pHddApCtx->uPrivacy,
1087 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1088 0,
1089 0,
1090 (v_MACADDR_t *)wrqu.addr.sa_data,
1091 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301092 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1093 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1094 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001095 }
1096
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301097 staId =
1098 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1099 if (VOS_IS_STATUS_SUCCESS(vos_status))
1100 {
1101
1102 pSapCtx->aStaInfo[staId].rate_flags =
1103 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1104 }
1105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 // Stop AP inactivity timer
1107 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1108 {
1109 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1110 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001111 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001113#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001114 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1115 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301116 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1117 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001118 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301119 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1120 HDD_SAP_WAKE_LOCK_DURATION,
1121 WIFI_POWER_EVENT_WAKELOCK_SAP);
1122
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001123#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1125 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301126 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1128
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301129 staInfo = vos_mem_malloc(sizeof(*staInfo));
1130 if (staInfo == NULL) {
1131 hddLog(LOGE, FL("alloc station_info failed"));
1132 return VOS_STATUS_E_NOMEM;
1133 }
1134
1135 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1137 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301138 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301140 staInfo->assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001141#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301142 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001143#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 cfg80211_new_sta(dev,
1145 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301146 staInfo, GFP_KERNEL);
1147 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 }
1149 else
1150 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001151 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 }
1153 }
1154#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301155 hdd_manage_delack_timer(pHddCtx);
1156
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001157 pScanInfo = &pHddCtx->scan_info;
1158 // Lets do abort scan to ensure smooth authentication for client
1159 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1160 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301161 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301162 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001164
1165 break;
1166 case eSAP_STA_DISASSOC_EVENT:
1167 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001168 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001169 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1171 hddLog(LOG1," User initiated disassociation");
1172 else
1173 hddLog(LOG1," MAC initiated disassociation");
1174 we_event = IWEVEXPIRED;
1175 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1176 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1177 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001178 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 -07001179 return VOS_STATUS_E_FAILURE;
1180 }
1181 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1182
1183 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1184 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301185 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 // Start AP inactivity timer if no stations associated with it
1187 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1188 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301189 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 {
1191 bApActive = TRUE;
1192 break;
1193 }
1194 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301195 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001196
1197 if (bApActive == FALSE)
1198 {
1199 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1200 {
1201 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1202 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001203 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 }
1205 else
1206 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1207 }
1208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001209#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1210 cfg80211_del_sta(dev,
1211 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1212 GFP_KERNEL);
1213#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001214 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301215 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1216 if (VOS_STATUS_SUCCESS != vos_status)
1217 {
1218 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1219 __func__, vos_status);
1220 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301221 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 break;
1223 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1224 {
1225 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1226 union iwreq_data wreq;
1227
1228 down(&pHddApCtx->semWpsPBCOverlapInd);
1229 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1230
1231 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1232 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1233
1234 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001235 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 memset(&wreq, 0, sizeof(wreq));
1237 wreq.data.length = strlen(message); // This is length of message
1238 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1239
1240 return VOS_STATUS_SUCCESS;
1241 }
1242 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1243 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1244 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1245 { // List of associated stations
1246 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1247 {
1248 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1249 i+1,
1250 pAssocStasArray->assocId,
1251 pAssocStasArray->staId,
1252 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1253 pAssocStasArray++;
1254 }
1255 }
1256 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001257 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 case eSAP_REMAIN_CHAN_READY:
1260 hdd_remainChanReadyHandler( pHostapdAdapter );
1261 return VOS_STATUS_SUCCESS;
1262 case eSAP_SEND_ACTION_CNF:
1263 hdd_sendActionCnf( pHostapdAdapter,
1264 ( eSAP_STATUS_SUCCESS ==
1265 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1266 TRUE : FALSE );
1267 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 case eSAP_UNKNOWN_STA_JOIN:
1269 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1270 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1271 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1272 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1273 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1274 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1275 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1276 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1277 wrqu.data.pointer = unknownSTAEvent;
1278 wrqu.data.length = strlen(unknownSTAEvent);
1279 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301280 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 break;
1282
1283 case eSAP_MAX_ASSOC_EXCEEDED:
1284 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1285 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1286 " one or more devices to enable the new device connection",
1287 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1288 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1289 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1290 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1291 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1292 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1293 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1294 wrqu.data.pointer = maxAssocExceededEvent;
1295 wrqu.data.length = strlen(maxAssocExceededEvent);
1296 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001297 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 break;
1299 case eSAP_STA_ASSOC_IND:
1300 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001301
1302 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001303 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001304 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1305 return VOS_STATUS_SUCCESS;
1306
1307 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301308 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301309 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1310 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301311 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301312 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001313 return VOS_STATUS_SUCCESS;
1314
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001316 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 goto stopbss;
1318 return VOS_STATUS_SUCCESS;
1319 }
1320 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1321 return VOS_STATUS_SUCCESS;
1322
1323stopbss :
1324 {
1325 v_BYTE_t we_custom_event[64];
1326 char *stopBssEvent = "STOP-BSS.response";//17
1327 int event_len = strlen(stopBssEvent);
1328
1329 hddLog(LOG1, FL("BSS stop status = %s"),
1330 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1331 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1332
1333 /* Change the BSS state now since, as we are shutting things down,
1334 * we don't want interfaces to become re-enabled */
1335 pHostapdState->bssState = BSS_STOP;
1336
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301337 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1338 {
1339 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1340 {
1341 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1342 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1343 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1344 }
1345
1346 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1347 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1348 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1349 }
1350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 /* Stop the pkts from n/w stack as we are going to free all of
1352 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301353
1354 /*
1355 * If channel avoidance is in progress means driver is performing SAP
1356 * restart. So don't do carrier off, which may lead framework to do
1357 * driver reload.
1358 */
1359 hddLog(LOG1, FL("ch avoid in progress: %d"),
1360 pHddCtx->is_ch_avoid_in_progress);
1361 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301362 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301363 netif_tx_disable(dev);
1364 else
1365 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001366
1367 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301368 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1369 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1370 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001371
Amar Singhal37e6f052013-03-05 16:16:54 -08001372 /* once the event is set, structure dev/pHostapdAdapter should
1373 * not be touched since they are now subject to being deleted
1374 * by another thread */
1375 if (eSAP_STOP_BSS_EVENT == sapEvent)
1376 vos_event_set(&pHostapdState->vosEvent);
1377
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 /* notify userspace that the BSS has stopped */
1379 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1380 memcpy(&we_custom_event, stopBssEvent, event_len);
1381 memset(&wrqu, 0, sizeof(wrqu));
1382 wrqu.data.length = event_len;
1383 we_event = IWEVCUSTOM;
1384 we_custom_event_generic = we_custom_event;
1385 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001386 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 }
1388 return VOS_STATUS_SUCCESS;
1389}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001390
1391int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001393 eCsrEncryptionType *pEncryptType,
1394 eCsrEncryptionType *mcEncryptType,
1395 eCsrAuthType *pAuthType,
1396 v_BOOL_t *pMFPCapable,
1397 v_BOOL_t *pMFPRequired,
1398 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 u_int8_t *gen_ie )
1400{
1401 tDot11fIERSN dot11RSNIE;
1402 tDot11fIEWPA dot11WPAIE;
1403
1404 tANI_U8 *pRsnIe;
1405 tANI_U16 RSNIeLen;
1406
1407 if (NULL == halHandle)
1408 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001409 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 return -EINVAL;
1411 }
1412
1413 // Validity checks
1414 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1415 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1416 return -EINVAL;
1417 // Type check
1418 if ( gen_ie[0] == DOT11F_EID_RSN)
1419 {
1420 // Validity checks
1421 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1422 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1423 {
1424 return VOS_STATUS_E_FAILURE;
1425 }
1426 // Skip past the EID byte and length byte
1427 pRsnIe = gen_ie + 2;
1428 RSNIeLen = gen_ie_len - 2;
1429 // Unpack the RSN IE
1430 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1431 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1432 pRsnIe,
1433 RSNIeLen,
1434 &dot11RSNIE);
1435 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001436 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001437 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001438 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001439 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 /*Here we have followed the apple base code,
1441 but probably I suspect we can do something different*/
1442 //dot11RSNIE.akm_suite_count
1443 // Just translate the FIRST one
1444 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1445 //dot11RSNIE.pwise_cipher_suite_count
1446 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1447 //dot11RSNIE.gp_cipher_suite_count
1448 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1449 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001450 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1451 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001452
1453 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1454 } else
1455 if (gen_ie[0] == DOT11F_EID_WPA)
1456 {
1457 // Validity checks
1458 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1459 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1460 {
1461 return VOS_STATUS_E_FAILURE;
1462 }
1463 // Skip past the EID byte and length byte - and four byte WiFi OUI
1464 pRsnIe = gen_ie + 2 + 4;
1465 RSNIeLen = gen_ie_len - (2 + 4);
1466 // Unpack the WPA IE
1467 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1468 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1469 pRsnIe,
1470 RSNIeLen,
1471 &dot11WPAIE);
1472 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001473 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001474 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001475 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001476 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 //dot11WPAIE.auth_suite_count
1478 // Just translate the FIRST one
1479 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1480 //dot11WPAIE.unicast_cipher_count
1481 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1482 //dot11WPAIE.unicast_cipher_count
1483 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001484 *pMFPCapable = VOS_FALSE;
1485 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 }
1487 else
1488 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001489 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 return VOS_STATUS_E_FAILURE;
1491 }
1492 return VOS_STATUS_SUCCESS;
1493}
Leo Chang614d2072013-08-22 14:59:44 -07001494
Leo Chang0b0e45a2013-12-15 15:18:55 -08001495#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001496
1497/*==========================================================================
1498 FUNCTION sapUpdateUnsafeChannelList
1499
1500 DESCRIPTION
1501 Function Undate unsafe channel list table
1502
1503 DEPENDENCIES
1504 NA.
1505
1506 PARAMETERS
1507
1508 IN
1509 pSapCtx : SAP context pointer, include unsafe channel list
1510
1511 RETURN VALUE
1512 NONE
1513============================================================================*/
1514void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1515 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1516{
1517 v_U16_t i, j;
1518
1519 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1520 sizeof(pHddCtx->unsafeChannelList));
1521 if (0 == unsafeChannelCount)
1522 {
1523 pHddCtx->unsafeChannelCount = 0;
1524 }
1525 else
1526 {
c_hpothu8de53e42014-08-22 15:00:37 +05301527 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1528 {
1529 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1530 FL("unsafeChannelCount%hd greater than %d"),
1531 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1532 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1533 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001534 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1535 unsafeChannelList,
1536 unsafeChannelCount * sizeof(tANI_U16));
1537 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1538 }
1539
1540 /* Flush, default set all channel safe */
1541 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1542 {
1543 safeChannels[i].isSafe = VOS_TRUE;
1544 }
1545
1546 /* Try to find unsafe channel */
1547 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1548 {
1549 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1550 {
1551 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1552 {
1553 /* Found unsafe channel, update it */
1554 safeChannels[j].isSafe = VOS_FALSE;
1555 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1556 "%s : CH %d is not safe",
1557 __func__, pHddCtx->unsafeChannelList[i]);
1558 break;
1559 }
1560 }
1561 }
1562
1563 return;
1564}
1565
Kapil Gupta137ef892016-12-13 19:38:00 +05301566/**
1567 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1568 * @adapter: hdd ap adapter
1569 *
1570 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1571 * and if ACS is enabled, driver will ask userspace to restart the
1572 * sap. User space on LTE coex indication restart driver.
1573 *
1574 * Return - none
1575 */
1576static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1577 hdd_context_t *hdd_ctx)
1578{
1579
1580 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1581 return;
1582 }
1583
1584 hddLog(LOG1, FL("Current operation channel %d"),
1585 adapter->sessionCtx.ap.operatingChannel);
1586 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1587 hdd_change_ch_avoidance_status(hdd_ctx, true);
1588
1589 vos_flush_work(
1590 &hdd_ctx->sap_start_work);
1591
1592 /*
1593 * current operating channel
1594 * is un-safe channel, restart SAP
1595 */
1596 hddLog(LOG1,
1597 FL("Restarting SAP due to unsafe channel"));
1598
1599 adapter->sessionCtx.ap.sapConfig.channel =
1600 AUTO_CHANNEL_SELECT;
1601
Kapil Gupta137ef892016-12-13 19:38:00 +05301602
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301603 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05301604 netif_tx_disable(adapter->dev);
1605 schedule_work(&hdd_ctx->sap_start_work);
1606 } else {
1607 hdd_hostapd_stop(adapter->dev);
1608 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301609
1610 return;
1611 }
1612 return;
1613}
1614
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301615void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
1616 hdd_context_t *hdd_ctxt)
1617{
1618 v_U16_t channelLoop;
1619 v_U16_t unsafeChannelCount = 0;
1620 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1621
1622 /* Get unsafe channel list */
1623 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
1624 &unsafeChannelCount);
1625 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1626 {
1627 if ((unsafeChannelList[channelLoop] ==
1628 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
1629 if ((AUTO_CHANNEL_SELECT ==
1630 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
1631 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
1632 /*
1633 * current operating channel is un-safe channel
1634 * restart driver
1635 */
1636 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
1637 /*
1638 * On LE, this event is handled by wlan-services to
1639 * restart SAP. On android, this event would be
1640 * ignored.
1641 */
1642 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1643 NULL, 0);
1644 }
1645 break;
1646 }
1647 }
1648 return;
1649}
1650
1651
Kapil Gupta137ef892016-12-13 19:38:00 +05301652
Leo Chang0b0e45a2013-12-15 15:18:55 -08001653/**---------------------------------------------------------------------------
1654
1655 \brief hdd_hostapd_ch_avoid_cb() -
1656
1657 Avoid channel notification from FW handler.
1658 FW will send un-safe channle list to avoid overwrapping.
1659 hostapd should not use notified channel
1660
1661 \param - pAdapter HDD adapter pointer
1662 indParam channel avoid notification parameter
1663
1664 \return - None
1665
1666 --------------------------------------------------------------------------*/
1667void hdd_hostapd_ch_avoid_cb
1668(
Kapil Gupta137ef892016-12-13 19:38:00 +05301669 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08001670 void *indParam
1671)
1672{
1673 hdd_adapter_t *pHostapdAdapter = NULL;
1674 hdd_context_t *hddCtxt;
1675 tSirChAvoidIndType *chAvoidInd;
1676 v_U8_t rangeLoop;
1677 v_U16_t channelLoop;
1678 v_U16_t dupCheck;
1679 v_U16_t startChannel;
1680 v_U16_t endChannel;
1681 v_U16_t unsafeChannelCount = 0;
1682 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1683 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001684 tHddAvoidFreqList hddAvoidFreqList;
1685 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301686#ifdef WLAN_FEATURE_AP_HT40_24G
1687 ptSapContext pSapCtx = NULL;
1688 tHalHandle hHal;
1689 v_U8_t cbMode;
1690 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1691 v_U32_t delay;
1692#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001693
1694 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05301695 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001696 {
1697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1698 "%s : Invalid arguments", __func__);
1699 return;
1700 }
1701
Kapil Gupta137ef892016-12-13 19:38:00 +05301702 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001703 chAvoidInd = (tSirChAvoidIndType *)indParam;
1704 pVosContext = hddCtxt->pvosContext;
1705
1706 /* Make unsafe channel list */
1707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1708 "%s : band count %d",
1709 __func__, chAvoidInd->avoidRangeCount);
1710 vos_mem_zero((void *)unsafeChannelList,
1711 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1712 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1713 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301714 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1715 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1716 break;
1717 }
1718 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001719 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301720 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001721 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1723 "%s : start %d : %d, end %d : %d",
1724 __func__,
1725 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1726 startChannel,
1727 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1728 endChannel);
1729 for (channelLoop = startChannel;
1730 channelLoop < (endChannel + 1);
1731 channelLoop++)
1732 {
1733 /* Channel duplicate check routine */
1734 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1735 {
1736 if (unsafeChannelList[dupCheck] == channelLoop)
1737 {
1738 /* This channel is duplicated */
1739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1740 "%s : found duplicated channel %d",
1741 __func__, channelLoop);
1742 break;
1743 }
1744 }
1745 if (dupCheck == unsafeChannelCount)
1746 {
c_hpothu8de53e42014-08-22 15:00:37 +05301747 int ii;
1748 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1749 {
1750 if (channelLoop == safeChannels[ii].channelNumber)
1751 {
1752 unsafeChannelList[unsafeChannelCount] = channelLoop;
1753 unsafeChannelCount++;
1754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1755 "%s : unsafe channel %d, count %d",
1756 __func__,
1757 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301758 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1759 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1760 break;
1761 }
c_hpothu8de53e42014-08-22 15:00:37 +05301762 }
1763 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001764 }
1765 else
1766 {
1767 /* DUP, do nothing */
1768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1769 "%s : duplicated channel %d",
1770 __func__, channelLoop);
1771 }
1772 }
1773 }
1774 /* Update unsafe channel cache
1775 * WCN Platform Driver cache */
1776 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1777 unsafeChannelCount);
1778
1779 /* Store into local cache
1780 * Start with STA and later start SAP
1781 * in this scenario, local cache will be used */
1782 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1783 unsafeChannelList,
1784 unsafeChannelCount);
1785
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001786 /* generate vendor specific event */
1787 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1788 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1789 {
1790 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1791 chAvoidInd->avoidFreqRange[i].startFreq;
1792 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1793 chAvoidInd->avoidFreqRange[i].endFreq;
1794 }
1795 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1796
1797 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1798
Leo Chang0b0e45a2013-12-15 15:18:55 -08001799 /* Get SAP context first
1800 * SAP and P2PGO would not concurrent */
1801 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301802#ifdef WLAN_FEATURE_AP_HT40_24G
1803 if (NULL == pHostapdAdapter)
1804 {
1805 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1806 }
1807#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301808 if ((pHostapdAdapter) &&
1809 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1810 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001811 {
1812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1813 "%s : Current operation channel %d",
1814 __func__,
1815 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301816 /* Check and Restart the SAP if it is on unsafe channel */
1817 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
1818
Leo Chang0b0e45a2013-12-15 15:18:55 -08001819 }
1820
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301821#ifdef WLAN_FEATURE_AP_HT40_24G
1822 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1823 {
1824 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1825
1826 if(pSapCtx == NULL)
1827 {
1828 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1829 FL("psapCtx is NULL"));
1830 return;
1831 }
1832
1833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1834 FL("SAP Secondary channel: %d "),
1835 pSapCtx->sap_sec_chan);
1836
1837 /* tHalHandle */
1838 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1839
1840 if (NULL == hHal)
1841 {
1842 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1843 FL("In invalid hHal"));
1844 return;
1845 }
1846
1847 cbMode = sme_GetChannelBondingMode24G(hHal);
1848
1849 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1850 FL("Selected Channel bonding : %d"), cbMode);
1851
1852 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1853 {
1854 int i;
1855 eHalStatus halStatus;
1856
1857 for (i = 0; i < unsafeChannelCount; i++)
1858 {
1859 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1860 {
1861 /* Current SAP Secondary channel is un-safe channel */
1862 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1863 FL("Move SAP from HT40 to HT20"));
1864
1865 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1866 PHY_SINGLE_CHANNEL_CENTERED);
1867
1868 if (halStatus == eHAL_STATUS_FAILURE)
1869 {
1870 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1871 FL("Failed to change HT20/40 mode"));
1872 return;
1873 }
1874
1875 /* Disable Channel Bonding for 2.4GHz */
1876 sme_UpdateChannelBondingMode24G(hHal,
1877 PHY_SINGLE_CHANNEL_CENTERED);
1878 return;
1879 }
1880 }
1881 }
1882
1883 if ((!pSapCtx->numHT40IntoSta)
1884 && (pHostapdAdapter)
1885 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1886 {
1887 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1888 * are Safe then start HT20/40 timer to Move SAP from HT20
1889 * to HT40.
1890 */
1891 if (((!unsafeChannelCount)
1892 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1893 {
1894 /* Stop Previous Running HT20/40 Timer & Start timer
1895 with (OBSS TransitionDelayFactor * obss interval)
1896 delay after time out move AP from HT20 -> HT40
1897 mode
1898 */
1899 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1900 {
1901 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1902 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1903 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1904 FL("Failed to Stop HT20/40 timer"));
1905 }
1906
1907 delay =
1908 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1909
1910 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1911 FL("Start HT20/40 transition timer (%d sec)"), delay);
1912
1913 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1914 (delay * 1000));
1915
1916 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1917 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1918 FL("Failed to Start HT20/40 timer"));
1919 }
1920 else
1921 {
1922 /* Stop HT20/40 Timer */
1923 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1924 {
1925 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1926 FL("Stop HT20/40 transition timer"));
1927 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1928 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1929 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1930 FL("Failed to Stop HT20/40 timer"));
1931 }
1932 }
1933 }
1934 }
1935#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001936 return;
1937}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001938#endif /* FEATURE_WLAN_CH_AVOID */
1939
Jeff Johnson295189b2012-06-20 16:38:30 -07001940int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301941static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 struct iw_request_info *info,
1943 union iwreq_data *wrqu, char *extra)
1944{
1945 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001946 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301947 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 int *value = (int *)extra;
1949 int sub_cmd = value[0];
1950 int set_value = value[1];
1951 eHalStatus status;
1952 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05301953 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001954 v_CONTEXT_t pVosContext;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 ENTER();
1957
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301958 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001959 {
1960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301961 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001962 __func__);
1963 return -1;
1964 }
1965
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301966 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1967 ret = wlan_hdd_validate_context(pHddCtx);
1968 if (0 != ret)
1969 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301970 return -1;
1971 }
1972
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001973 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1974 if (!hHal)
1975 {
1976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1977 "%s: Hal ctx is null", __func__);
1978 return -1;
1979 }
1980
1981 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1982 if (!pVosContext)
1983 {
1984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1985 "%s: Vos ctx is null", __func__);
1986 return -1;
1987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001988
1989 switch(sub_cmd)
1990 {
1991
1992 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001993 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001994 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301995 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001996 }
1997 break;
1998
1999 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302000 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2002 {
2003 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2004 ret = -EINVAL;
2005 }
2006 else
2007 {
2008 WLANSAP_SetMode(pVosContext, set_value);
2009 }
2010 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302011
2012 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2013 if ((0 != set_value) && (1 != set_value))
2014 {
2015 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2016 ret = -EINVAL;
2017 }
2018 else
2019 {
2020 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2021 }
2022 break;
2023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 case QCSAP_PARAM_MAX_ASSOC:
2025 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2026 {
2027 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2028 ret = -EINVAL;
2029 }
2030 else
2031 {
2032 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2033 {
2034 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2035 "Setting it to max allowed and continuing"),
2036 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2037 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2038 }
2039 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2040 set_value, NULL, eANI_BOOLEAN_FALSE);
2041 if ( status != eHAL_STATUS_SUCCESS )
2042 {
2043 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2044 status);
2045 ret = -EIO;
2046 }
2047 }
2048 break;
2049
2050 case QCSAP_PARAM_HIDE_SSID:
2051 {
2052 eHalStatus status = eHAL_STATUS_SUCCESS;
2053 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2054 if(eHAL_STATUS_SUCCESS != status)
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR,
2057 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002058 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 return status;
2060 }
2061 break;
2062 }
2063
Leo Chang614d2072013-08-22 14:59:44 -07002064 case QCSAP_PARAM_SET_MC_RATE:
2065 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002066 tSirRateUpdateInd *rateUpdate;
2067
2068 rateUpdate = (tSirRateUpdateInd *)
2069 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2070 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002071 {
2072 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002073 "%s: SET_MC_RATE indication alloc fail", __func__);
2074 ret = -1;
2075 break;
2076 }
2077 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2078
2079 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2080 /* Ignore unicast */
2081 rateUpdate->ucastDataRate = -1;
2082 rateUpdate->mcastDataRate24GHz = set_value;
2083 rateUpdate->mcastDataRate5GHz = set_value;
2084 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2085 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2086 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2087 if (eHAL_STATUS_SUCCESS != status)
2088 {
2089 hddLog(VOS_TRACE_LEVEL_ERROR,
2090 "%s: SET_MC_RATE failed", __func__);
2091 vos_mem_free(rateUpdate);
2092 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002093 }
2094 break;
2095 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302096 case QCSAP_PARAM_GET_FRAME_LOGS:
2097 {
2098 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2099 != VOS_STATUS_SUCCESS)
2100 {
2101 ret = -EINVAL;
2102 }
2103 break;
2104 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302105 case QCSAP_PARAM_SET_PROXIMITY:
2106 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302107 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302108 break;
2109 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302110 case QCSAP_PARAM_SET_WOWL:
2111 {
2112 if (!pHddCtx->is_ap_mode_wow_supported)
2113 {
2114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2115 "%s: Not supported",__func__);
2116 return -ENOTSUPP;
2117 }
2118 switch (set_value)
2119 {
2120 case 0x00:
2121 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2122 break;
2123 case 0x01:
2124 case 0x02:
2125 case 0x03:
2126 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2127 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2128 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2129 (enable_magic_pkt ? "YES":"NO"),
2130 (enable_pattrn_byte_match ? "YES":"NO"));
2131 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2132 enable_pattrn_byte_match);
2133 break;
2134 default:
2135 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2136 ret = -EINVAL;
2137 break;
2138 }
2139 break;
2140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 default:
2142 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2143 sub_cmd, set_value);
2144 ret = -EINVAL;
2145 break;
2146 }
2147
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302148 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 return ret;
2150}
2151
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302152int
2153static iw_softap_setparam(struct net_device *dev,
2154 struct iw_request_info *info,
2155 union iwreq_data *wrqu, char *extra)
2156{
2157 int ret;
2158
2159 vos_ssr_protect(__func__);
2160 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2161 vos_ssr_unprotect(__func__);
2162
2163 return ret;
2164}
Jeff Johnson295189b2012-06-20 16:38:30 -07002165
2166int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302167static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 struct iw_request_info *info,
2169 union iwreq_data *wrqu, char *extra)
2170{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302171 hdd_adapter_t *pHostapdAdapter;
2172 tHalHandle hHal;
2173 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 int *value = (int *)extra;
2175 int sub_cmd = value[0];
2176 eHalStatus status;
2177 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302178 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002179
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302180 ENTER();
2181
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302182 pHostapdAdapter = (netdev_priv(dev));
2183 if (NULL == pHostapdAdapter)
2184 {
2185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2186 "%s: Adapter is NULL",__func__);
2187 return -EINVAL;
2188 }
2189 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2190 ret = wlan_hdd_validate_context(pHddCtx);
2191 if (0 != ret)
2192 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302193 return ret;
2194 }
2195 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2196 if (NULL == hHal)
2197 {
2198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2199 "%s: Hal Context is NULL",__func__);
2200 return -EINVAL;
2201 }
2202 pVosContext = pHddCtx->pvosContext;
2203 if (NULL == pVosContext)
2204 {
2205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2206 "%s: pVosContext Context is NULL",__func__);
2207 return -EINVAL;
2208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 switch (sub_cmd)
2210 {
2211 case QCSAP_PARAM_MAX_ASSOC:
2212 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2213 if (eHAL_STATUS_SUCCESS != status)
2214 {
c_hpothuffdb5272013-10-02 16:42:35 +05302215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2216 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 ret = -EIO;
2218 }
Girish Gowli385be612014-09-18 11:17:20 +05302219
2220#ifdef WLAN_SOFTAP_VSTA_FEATURE
2221 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2222 {
2223 if (*value > VSTA_NUM_ASSOC_STA)
2224 {
2225 *value = VSTA_NUM_ASSOC_STA;
2226 }
2227 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2228 (*value > (VSTA_NUM_ASSOC_STA -
2229 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2230 {
2231 *value = (VSTA_NUM_ASSOC_STA -
2232 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2233 }
2234 }
2235 else
2236#endif
2237 {
2238 if (*value > NUM_ASSOC_STA)
2239 {
2240 *value = NUM_ASSOC_STA;
2241 }
2242 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2243 (*value > (NUM_ASSOC_STA -
2244 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2245 {
2246 *value = (NUM_ASSOC_STA -
2247 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2248 }
2249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002253 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 {
c_hpothuffdb5272013-10-02 16:42:35 +05302255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2256 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302257 ret = -EIO;
2258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 *value = 0;
2260 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302261
Jeff Johnson43971f52012-07-17 12:26:56 -07002262 case QCSAP_PARAM_GET_WLAN_DBG:
2263 {
2264 vos_trace_display();
2265 *value = 0;
2266 break;
2267 }
2268
2269 case QCSAP_PARAM_AUTO_CHANNEL:
2270 {
2271 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2272 break;
2273 }
2274
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 default:
2276 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2277 ret = -EINVAL;
2278 break;
2279
2280 }
2281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302282 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 return ret;
2284}
2285
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302286int
2287static iw_softap_getparam(struct net_device *dev,
2288 struct iw_request_info *info,
2289 union iwreq_data *wrqu, char *extra)
2290{
2291 int ret;
2292
2293 vos_ssr_protect(__func__);
2294 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2295 vos_ssr_unprotect(__func__);
2296
2297 return ret;
2298}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302299
2300int
2301static __iw_softap_setchar_getnone(struct net_device *dev,
2302 struct iw_request_info *info,
2303 union iwreq_data *wrqu, char *extra)
2304{
2305 int sub_cmd;
2306 int ret = 0; /* success */
2307 char *pBuffer = NULL;
2308 hdd_adapter_t *pAdapter;
2309 hdd_context_t *pHddCtx;
2310 struct iw_point s_priv_data;
2311
2312 ENTER();
2313
2314 if (!capable(CAP_NET_ADMIN))
2315 {
2316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2317 FL("permission check failed"));
2318 return -EPERM;
2319 }
2320
2321 pAdapter = (netdev_priv(dev));
2322 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2323 ret = wlan_hdd_validate_context(pHddCtx);
2324 if (0 != ret)
2325 {
2326 return ret;
2327 }
2328
2329 if (!pHddCtx->is_ap_mode_wow_supported)
2330 {
2331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2332 "%s: Not supported",__func__);
2333 return -ENOTSUPP;
2334 }
2335
2336 /* helper function to get iwreq_data with compat handling. */
2337 if (hdd_priv_get_data(&s_priv_data, wrqu))
2338 {
2339 return -EINVAL;
2340 }
2341
2342 /* make sure all params are correctly passed to function */
2343 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2344 {
2345 return -EINVAL;
2346 }
2347
2348 sub_cmd = s_priv_data.flags;
2349
2350 /* ODD number is used for set, copy data using copy_from_user */
2351 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2352 s_priv_data.length);
2353 if (NULL == pBuffer)
2354 {
2355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2356 "mem_alloc_copy_from_user_helper fail");
2357 return -ENOMEM;
2358 }
2359
2360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2361 "%s: Received length %d", __func__, s_priv_data.length);
2362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2363 "%s: Received data %s", __func__, pBuffer);
2364
2365 switch(sub_cmd)
2366 {
2367 case WE_WOWL_ADD_PTRN:
2368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2369 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2370 if (!ret)
2371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2372 "Failed to add pattern :%d", ret);
2373 break;
2374 case WE_WOWL_DEL_PTRN:
2375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2376 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2377 if (!ret)
2378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2379 "Failed to del pattern :%d", ret);
2380 break;
2381 default:
2382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2383 ret = -EINVAL;
2384 break;
2385 }
2386
2387 kfree(pBuffer);
2388 return ret;
2389}
2390
2391int
2392static iw_softap_setchar_getnone(struct net_device *dev,
2393 struct iw_request_info *info,
2394 union iwreq_data *wrqu, char *extra)
2395{
2396 int ret;
2397
2398 vos_ssr_protect(__func__);
2399 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2400 vos_ssr_unprotect(__func__);
2401
2402 return ret;
2403}
2404
Jeff Johnson295189b2012-06-20 16:38:30 -07002405/* Usage:
2406 BLACK_LIST = 0
2407 WHITE_LIST = 1
2408 ADD MAC = 0
2409 REMOVE MAC = 1
2410
2411 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2412 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2413 while using this ioctl
2414
2415 Syntax:
2416 iwpriv softap.0 modify_acl
2417 <6 octet mac addr> <list type> <cmd type>
2418
2419 Examples:
2420 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2421 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2422 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2423 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2424*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302425int __iw_softap_modify_acl(struct net_device *dev,
2426 struct iw_request_info *info,
2427 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002428{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302429 hdd_adapter_t *pHostapdAdapter;
2430 v_CONTEXT_t pVosContext;
2431 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 v_BYTE_t *value = (v_BYTE_t*)extra;
2433 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2434 int listType, cmd, i;
2435 int ret = 0; /* success */
2436
2437 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302438 pHostapdAdapter = (netdev_priv(dev));
2439 if (NULL == pHostapdAdapter)
2440 {
2441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2442 "%s: Adapter is NULL",__func__);
2443 return -EINVAL;
2444 }
2445 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2446 ret = wlan_hdd_validate_context(pHddCtx);
2447 if (0 != ret)
2448 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302449 return ret;
2450 }
2451 pVosContext = pHddCtx->pvosContext;
2452 if (NULL == pVosContext)
2453 {
2454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2455 "%s: Vos Context is NULL",__func__);
2456 return -EINVAL;
2457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2459 {
2460 pPeerStaMac[i] = *(value+i);
2461 }
2462 listType = (int)(*(value+i));
2463 i++;
2464 cmd = (int)(*(value+i));
2465
Arif Hussain24bafea2013-11-15 15:10:03 -08002466 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2467 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002468
2469 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2470 != VOS_STATUS_SUCCESS)
2471 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002472 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 ret = -EIO;
2474 }
2475 EXIT();
2476 return ret;
2477}
2478
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302479int iw_softap_modify_acl(struct net_device *dev,
2480 struct iw_request_info *info,
2481 union iwreq_data *wrqu, char *extra)
2482{
2483 int ret;
2484
2485 vos_ssr_protect(__func__);
2486 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2487 vos_ssr_unprotect(__func__);
2488
2489 return ret;
2490}
2491
Jeff Johnson295189b2012-06-20 16:38:30 -07002492int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302493static __iw_softap_getchannel(struct net_device *dev,
2494 struct iw_request_info *info,
2495 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002496{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 hdd_adapter_t *pHostapdAdapter;
2498 hdd_context_t *pHddCtx;
2499 int ret = 0;
2500 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302501
2502 ENTER();
2503
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302504 pHostapdAdapter = (netdev_priv(dev));
2505 if (NULL == pHostapdAdapter)
2506 {
2507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2508 "%s: Adapter is NULL",__func__);
2509 return -EINVAL;
2510 }
2511 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2512 ret = wlan_hdd_validate_context(pHddCtx);
2513 if (0 != ret)
2514 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302515 return ret;
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302518 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002519
Jeff Johnson43971f52012-07-17 12:26:56 -07002520 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302521
2522 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 return 0;
2524}
2525
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302526
Jeff Johnsone7245742012-09-05 17:12:55 -07002527int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302528static iw_softap_getchannel(struct net_device *dev,
2529 struct iw_request_info *info,
2530 union iwreq_data *wrqu, char *extra)
2531{
2532 int ret;
2533
2534 vos_ssr_protect(__func__);
2535 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2536 vos_ssr_unprotect(__func__);
2537
2538 return ret;
2539}
2540
2541int
2542static __iw_softap_set_max_tx_power(struct net_device *dev,
2543 struct iw_request_info *info,
2544 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002545{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302546 hdd_adapter_t *pHostapdAdapter;
2547 tHalHandle hHal;
2548 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002549 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302550 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002551 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2552 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2553
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302554 ENTER();
2555
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302556 pHostapdAdapter = (netdev_priv(dev));
2557 if (NULL == pHostapdAdapter)
2558 {
2559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2560 "%s: Adapter is NULL",__func__);
2561 return -EINVAL;
2562 }
2563 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2564 ret = wlan_hdd_validate_context(pHddCtx);
2565 if (0 != ret)
2566 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302567 return ret;
2568 }
2569 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2570 if (NULL == hHal)
2571 {
2572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2573 "%s: Hal Context is NULL",__func__);
2574 return -EINVAL;
2575 }
schang86c22c42013-03-13 18:41:24 -07002576 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002577 return -ENOMEM;
2578
Leo Changd37675a2013-08-01 13:19:45 -07002579 /* Assign correct slef MAC address */
2580 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2581 VOS_MAC_ADDR_SIZE);
2582 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2583 VOS_MAC_ADDR_SIZE);
2584
schang86c22c42013-03-13 18:41:24 -07002585 set_value = value[0];
2586 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2587 {
2588 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002589 __func__);
schang86c22c42013-03-13 18:41:24 -07002590 return -EIO;
2591 }
2592
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302593 EXIT();
schang86c22c42013-03-13 18:41:24 -07002594 return 0;
2595}
2596
2597int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302598static iw_softap_set_max_tx_power(struct net_device *dev,
2599 struct iw_request_info *info,
2600 union iwreq_data *wrqu, char *extra)
2601{
2602 int ret;
2603
2604 vos_ssr_protect(__func__);
2605 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2606 vos_ssr_unprotect(__func__);
2607
2608 return ret;
2609}
2610
2611
2612int
2613static __iw_display_data_path_snapshot(struct net_device *dev,
2614 struct iw_request_info *info,
2615 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302616{
2617
2618 /* Function intitiating dumping states of
2619 * HDD(WMM Tx Queues)
2620 * TL State (with Per Client infor)
2621 * DXE Snapshot (Called at the end of TL Snapshot)
2622 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302623 hdd_adapter_t *pHostapdAdapter;
2624 hdd_context_t *pHddCtx;
2625 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302626
2627 ENTER();
2628
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302629 pHostapdAdapter = (netdev_priv(dev));
2630 if (NULL == pHostapdAdapter)
2631 {
2632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2633 "%s: Adapter is NULL",__func__);
2634 return -EINVAL;
2635 }
2636 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2637 ret = wlan_hdd_validate_context(pHddCtx);
2638 if (0 != ret)
2639 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302640 return ret;
2641 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302642 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302643 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302644
2645 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302646 return 0;
2647}
2648
2649int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302650static iw_display_data_path_snapshot(struct net_device *dev,
2651 struct iw_request_info *info,
2652 union iwreq_data *wrqu, char *extra)
2653{
2654 int ret;
2655
2656 vos_ssr_protect(__func__);
2657 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2658 vos_ssr_unprotect(__func__);
2659
2660 return ret;
2661}
2662
2663int
2664static __iw_softap_set_tx_power(struct net_device *dev,
2665 struct iw_request_info *info,
2666 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002667{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302668 hdd_adapter_t *pHostapdAdapter;
2669 hdd_context_t *pHddCtx;
2670 v_CONTEXT_t pVosContext;
2671 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002672 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302673 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002674 ptSapContext pSapCtx = NULL;
2675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302676 ENTER();
2677
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302678 pHostapdAdapter = (netdev_priv(dev));
2679 if (NULL == pHostapdAdapter)
2680 {
2681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2682 "%s: Adapter is NULL",__func__);
2683 return -EINVAL;
2684 }
2685 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2686 ret = wlan_hdd_validate_context(pHddCtx);
2687 if (0 != ret)
2688 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302689 return ret;
2690 }
2691 pVosContext = pHddCtx->pvosContext;
2692 if (NULL == pVosContext)
2693 {
2694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2695 "%s: Vos Context is NULL",__func__);
2696 return -EINVAL;
2697 }
2698 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2699 if (NULL == hHal)
2700 {
2701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2702 "%s: Hal Context is NULL",__func__);
2703 return -EINVAL;
2704 }
schang86c22c42013-03-13 18:41:24 -07002705 if (NULL == value)
2706 return -ENOMEM;
2707
2708 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2709 if (NULL == pSapCtx)
2710 {
2711 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2712 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2713 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002714 }
2715
2716 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002717 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002718 {
schang86c22c42013-03-13 18:41:24 -07002719 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002720 __func__);
2721 return -EIO;
2722 }
2723
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302724 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002725 return 0;
2726}
2727
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302728int
2729static iw_softap_set_tx_power(struct net_device *dev,
2730 struct iw_request_info *info,
2731 union iwreq_data *wrqu, char *extra)
2732{
2733 int ret;
2734
2735 vos_ssr_protect(__func__);
2736 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2737 vos_ssr_unprotect(__func__);
2738
2739 return ret;
2740}
2741
Kiet Lambcf38522013-10-26 18:28:27 +05302742/**---------------------------------------------------------------------------
2743
2744 \brief iw_softap_set_trafficmonitor() -
2745 This function dynamically enable/disable traffic monitor functonality
2746 the command iwpriv wlanX setTrafficMon <value>.
2747
2748 \param - dev - Pointer to the net device.
2749 - addr - Pointer to the sockaddr.
2750 \return - 0 for success, non zero for failure
2751
2752 --------------------------------------------------------------------------*/
2753
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302754static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2755 struct iw_request_info *info,
2756 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302757{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302758 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302759 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302760 hdd_context_t *pHddCtx;
2761 int status;
2762
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302763 ENTER();
2764
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302765 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302766 if (NULL == pAdapter)
2767 {
2768 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2769 "%s: HDD adapter is Null", __func__);
2770 return -ENODEV;
2771 }
2772
2773 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2774
2775 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302776 if (0 != status)
2777 {
Kiet Lambcf38522013-10-26 18:28:27 +05302778 return status;
2779 }
2780
2781 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2782
2783 if (NULL == isSetTrafficMon)
2784 {
2785 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2786 "%s: Invalid SAP pointer from extra", __func__);
2787 return -ENOMEM;
2788 }
2789
2790 if (TRUE == *isSetTrafficMon)
2791 {
2792 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2793 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2794 {
2795 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2796 "%s: failed to Start Traffic Monitor timer ", __func__ );
2797 return -EIO;
2798 }
2799 }
2800 else if (FALSE == *isSetTrafficMon)
2801 {
2802 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2803 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2804 {
2805 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2806 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2807 return -EIO;
2808 }
2809
2810 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302811
2812 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302813 return 0;
2814}
2815
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302816static int iw_softap_set_trafficmonitor(struct net_device *dev,
2817 struct iw_request_info *info,
2818 union iwreq_data *wrqu, char *extra)
2819{
2820 int ret;
2821
2822 vos_ssr_protect(__func__);
2823 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2824 vos_ssr_unprotect(__func__);
2825
2826 return ret;
2827}
2828
Jeff Johnson295189b2012-06-20 16:38:30 -07002829#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2830
2831int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302832static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2833 struct iw_request_info *info,
2834 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002835{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302836 hdd_adapter_t *pHostapdAdapter;
2837 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302838 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002839 char *buf;
2840 int cnt = 0;
2841 int left;
2842 int ret = 0;
2843 /* maclist_index must be u32 to match userspace */
2844 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302845 v_CONTEXT_t pVosContext = NULL;
2846 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302847
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302848 ENTER();
2849
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302850 pHostapdAdapter = (netdev_priv(dev));
2851 if (NULL == pHostapdAdapter)
2852 {
2853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2854 "%s: Adapter is NULL",__func__);
2855 return -EINVAL;
2856 }
2857 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2858 ret = wlan_hdd_validate_context(pHddCtx);
2859 if (0 != ret)
2860 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302861 return ret;
2862 }
2863
Jeff Johnson224f3702014-03-26 11:09:47 -07002864 /*
2865 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2866 * number, and even numbered iocts are supposed to have "set"
2867 * semantics. Hence the wireless extensions support in the kernel
2868 * won't correctly copy the result to userspace, so the ioctl
2869 * handler itself must copy the data. Output format is 32-bit
2870 * record length, followed by 0 or more 6-byte STA MAC addresses.
2871 *
2872 * Further note that due to the incorrect semantics, the "iwpriv"
2873 * userspace application is unable to correctly invoke this API,
2874 * hence it is not registered in the hostapd_private_args. This
2875 * API can only be invoked by directly invoking the ioctl() system
2876 * call.
2877 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002878
Jeff Johnson224f3702014-03-26 11:09:47 -07002879 /* make sure userspace allocated a reasonable buffer size */
2880 if (wrqu->data.length < sizeof(maclist_index)) {
2881 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2882 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002884
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302885 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2886 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2887 if(pSapCtx == NULL){
2888 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2889 FL("psapCtx is NULL"));
2890 return -EFAULT;
2891 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302892
2893 /* allocate local buffer to build the response */
2894 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2895 if (!buf) {
2896 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2897 return -ENOMEM;
2898 }
2899
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302900 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002901 /* start indexing beyond where the record count will be written */
2902 maclist_index = sizeof(maclist_index);
2903 left = wrqu->data.length - maclist_index;
2904
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302905 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002906 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2907 if ((pStaInfo[cnt].isUsed) &&
2908 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2909 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2910 VOS_MAC_ADDR_SIZE);
2911 maclist_index += VOS_MAC_ADDR_SIZE;
2912 left -= VOS_MAC_ADDR_SIZE;
2913 }
2914 cnt++;
2915 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302916 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002917
2918 *((u32 *)buf) = maclist_index;
2919 wrqu->data.length = maclist_index;
2920 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2921 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2922 ret = -EFAULT;
2923 }
2924 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302925
2926 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002927 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002928}
2929
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302930int
2931static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2932 struct iw_request_info *info,
2933 union iwreq_data *wrqu, char *extra)
2934{
2935 int ret;
2936
2937 vos_ssr_protect(__func__);
2938 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2939 vos_ssr_unprotect(__func__);
2940
2941 return ret;
2942}
2943
Jeff Johnson295189b2012-06-20 16:38:30 -07002944/* Usage:
2945 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2946 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2947 while using this ioctl
2948
2949 Syntax:
2950 iwpriv softap.0 disassoc_sta <6 octet mac address>
2951
2952 e.g.
2953 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2954 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2955*/
2956
2957int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302958static __iw_softap_disassoc_sta(struct net_device *dev,
2959 struct iw_request_info *info,
2960 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002961{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302962 hdd_adapter_t *pHostapdAdapter;
2963 hdd_context_t *pHddCtx;
2964 v_U8_t *peerMacAddr;
2965 int ret = 0;
2966
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302968
2969 if (!capable(CAP_NET_ADMIN)) {
2970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2971 FL("permission check failed"));
2972 return -EPERM;
2973 }
2974
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302975 pHostapdAdapter = (netdev_priv(dev));
2976 if (NULL == pHostapdAdapter)
2977 {
2978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2979 "%s: Adapter is NULL",__func__);
2980 return -EINVAL;
2981 }
2982 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2983 ret = wlan_hdd_validate_context(pHddCtx);
2984 if (0 != ret)
2985 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302986 return ret;
2987 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302988 /* iwpriv tool or framework calls this ioctl with
2989 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302991 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002992
Arif Hussain24bafea2013-11-15 15:10:03 -08002993 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2994 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2996 EXIT();
2997 return 0;
2998}
2999
3000int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303001static iw_softap_disassoc_sta(struct net_device *dev,
3002 struct iw_request_info *info,
3003 union iwreq_data *wrqu, char *extra)
3004{
3005 int ret;
3006
3007 vos_ssr_protect(__func__);
3008 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3009 vos_ssr_unprotect(__func__);
3010
3011 return ret;
3012}
3013
3014int
3015static __iw_softap_ap_stats(struct net_device *dev,
3016 struct iw_request_info *info,
3017 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003018{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303019 hdd_adapter_t *pHostapdAdapter;
3020 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 WLANTL_TRANSFER_STA_TYPE statBuffer;
3022 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303023 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303025 ENTER();
3026
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303027 pHostapdAdapter = (netdev_priv(dev));
3028 if (NULL == pHostapdAdapter)
3029 {
3030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3031 "%s: Adapter is NULL",__func__);
3032 return -EINVAL;
3033 }
3034 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3035 ret = wlan_hdd_validate_context(pHddCtx);
3036 if (0 != ret)
3037 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303038 return ret;
3039 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003040 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003041 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3042 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003043
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303044 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003045 if(NULL == pstatbuf) {
3046 hddLog(LOG1, "unable to allocate memory");
3047 return -ENOMEM;
3048 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303049
3050 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003051 "RUF=%d RMF=%d RBF=%d "
3052 "RUB=%d RMB=%d RBB=%d "
3053 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303054 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003055 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3056 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3057 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3058 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3059 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3060 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003061
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303062 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003063 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3064 kfree(pstatbuf);
3065 return -EFAULT;
3066 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303067
3068 strlcpy(extra, pstatbuf, len);
3069 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003070 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303071
3072 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 return 0;
3074}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303075int
3076static __iw_softap_ap_get_stats(struct net_device *dev,
3077 struct iw_request_info *info,
3078 union iwreq_data *wrqu, char *extra)
3079{
3080 hdd_adapter_t *pAdapter;
3081 hdd_tx_rx_stats_t *pStats;
3082
3083 ENTER();
3084 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3085 if (NULL == pAdapter)
3086 {
3087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3088 "%s: Adapter is NULL",__func__);
3089 return -EINVAL;
3090 }
3091
3092 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3093 snprintf(extra, QCSAP_MAX_STR_LEN,
3094 "\nTransmit"
3095 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3096 "\n dropped BK %u, BE %u, VI %u, VO %u"
3097 "\n classified BK %u, BE %u, VI %u, VO %u"
3098 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3099 "\n queued BK %u, BE %u, VI %u, VO %u"
3100 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3101 "\ndequeued %u, depressured %u, deque-depressured %u,\
3102 completed %u, flushed %u"
3103 "\n fetched BK %u, BE %u, VI %u, VO %u"
3104 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3105 "\n depressured BK %u, BE %u, VI %u, VO %u"
3106 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3107 "\n flushed BK %u, BE %u, VI %u, VO %u"
3108 "\n\nReceive"
3109 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3110 "\n\nResetsStats"
3111 "\n",
3112 pStats->txXmitCalled,
3113 pStats->txXmitDropped,
3114 pStats->txXmitBackPressured,
3115 pStats->txXmitQueued,
3116
3117 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3118 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3119 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3120 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3121
3122 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3123 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3124 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3125 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3126
3127 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3128 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3129 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3130 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3131
3132 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3133 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3134 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3135 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3136
3137 pStats->txFetched,
3138 pStats->txFetchEmpty,
3139 pStats->txFetchLowResources,
3140 pStats->txFetchDequeueError,
3141
3142 pStats->txFetchDequeued,
3143 pStats->txFetchDePressured,
3144 pStats->txDequeDePressured,
3145 pStats->txCompleted,
3146 pStats->txFlushed,
3147
3148 pStats->txFetchedAC[WLANTL_AC_BK],
3149 pStats->txFetchedAC[WLANTL_AC_BE],
3150 pStats->txFetchedAC[WLANTL_AC_VI],
3151 pStats->txFetchedAC[WLANTL_AC_VO],
3152
3153 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3154 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3155 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3156 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3157
3158 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3159 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3160 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3161 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3162
3163 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3164 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3165 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3166 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3167
3168 pStats->txFlushedAC[WLANTL_AC_BK],
3169 pStats->txFlushedAC[WLANTL_AC_BE],
3170 pStats->txFlushedAC[WLANTL_AC_VI],
3171 pStats->txFlushedAC[WLANTL_AC_VO],
3172
3173 pStats->rxChains,
3174 pStats->rxPackets,
3175 pStats->rxDropped,
3176 pStats->rxDelivered,
3177 pStats->rxRefused
3178 );
3179
3180 wrqu->data.length = strlen(extra) + 1;
3181
3182 return 0;
3183}
3184
3185int
3186static __iw_softap_ap_clear_stats(struct net_device *dev,
3187 struct iw_request_info *info,
3188 union iwreq_data *wrqu, char *extra)
3189{
3190 hdd_adapter_t *pAdapter;
3191
3192 ENTER();
3193
3194 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3195 if (NULL == pAdapter)
3196 {
3197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3198 "%s: Adapter is NULL",__func__);
3199 return -EINVAL;
3200 }
3201
3202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3203 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3204 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3205 return 0;
3206}
3207
3208
3209int
3210static iw_softap_get_stats(struct net_device *dev,
3211 struct iw_request_info *info,
3212 union iwreq_data *wrqu, char *extra)
3213{
3214 int ret;
3215 vos_ssr_protect(__func__);
3216 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3217 vos_ssr_unprotect(__func__);
3218 return ret;
3219}
3220
3221int
3222static iw_softap_clear_stats(struct net_device *dev,
3223 struct iw_request_info *info,
3224 union iwreq_data *wrqu, char *extra)
3225{
3226 int ret;
3227 vos_ssr_protect(__func__);
3228 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3229 vos_ssr_unprotect(__func__);
3230 return ret;
3231}
Jeff Johnson295189b2012-06-20 16:38:30 -07003232
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303233int
3234static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 struct iw_request_info *info,
3236 union iwreq_data *wrqu, char *extra)
3237{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303238 int ret;
3239
3240 vos_ssr_protect(__func__);
3241 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3242 vos_ssr_unprotect(__func__);
3243
3244 return ret;
3245}
3246
3247static int __iw_softap_set_channel_range(struct net_device *dev,
3248 struct iw_request_info *info,
3249 union iwreq_data *wrqu, char *extra)
3250{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303251 hdd_adapter_t *pHostapdAdapter;
3252 tHalHandle hHal;
3253 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 int *value = (int *)extra;
3255 int startChannel = value[0];
3256 int endChannel = value[1];
3257 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003258 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 int ret = 0; /* success */
3260
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303261 ENTER();
3262
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303263 if (!capable(CAP_NET_ADMIN))
3264 {
3265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3266 FL("permission check failed"));
3267 return -EPERM;
3268 }
3269
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303270 pHostapdAdapter = (netdev_priv(dev));
3271 if (NULL == pHostapdAdapter)
3272 {
3273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3274 "%s: Adapter is NULL",__func__);
3275 return -EINVAL;
3276 }
3277 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3278 ret = wlan_hdd_validate_context(pHddCtx);
3279 if (0 != ret)
3280 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303281 return ret;
3282 }
3283 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3284 if (NULL == hHal)
3285 {
3286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3287 "%s: Hal Context is NULL",__func__);
3288 return -EINVAL;
3289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3291 if(status != VOS_STATUS_SUCCESS)
3292 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003293 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 startChannel,endChannel, band);
3295 ret = -EINVAL;
3296 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003297
3298 pHddCtx->is_dynamic_channel_range_set = 1;
3299
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303300 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 return ret;
3302}
3303
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303304static int iw_softap_set_channel_range(struct net_device *dev,
3305 struct iw_request_info *info,
3306 union iwreq_data *wrqu, char *extra)
3307{
3308 int ret;
3309
3310 vos_ssr_protect(__func__);
3311 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3312 vos_ssr_unprotect(__func__);
3313
3314 return ret;
3315}
3316
3317
3318int __iw_softap_get_channel_list(struct net_device *dev,
3319 struct iw_request_info *info,
3320 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003321{
3322 v_U32_t num_channels = 0;
3323 v_U8_t i = 0;
3324 v_U8_t bandStartChannel = RF_CHAN_1;
3325 v_U8_t bandEndChannel = RF_CHAN_165;
3326 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303327 hdd_adapter_t *pHostapdAdapter;
3328 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003331 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303332 hdd_context_t *pHddCtx;
3333 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303334
3335 ENTER();
3336
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303337 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3338 if (NULL == pHostapdAdapter)
3339 {
3340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3341 "%s: Adapter is NULL",__func__);
3342 return -EINVAL;
3343 }
3344 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3345 ret = wlan_hdd_validate_context(pHddCtx);
3346 if (0 != ret)
3347 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303348 return ret;
3349 }
3350 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3351 if (NULL == hHal)
3352 {
3353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3354 "%s: Hal Context is NULL",__func__);
3355 return -EINVAL;
3356 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003357 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3358 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003359 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003360 return -EIO;
3361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 wrqu->data.length = sizeof(tChannelListInfo);
3363 ENTER();
3364
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003365 if (eCSR_BAND_24 == curBand)
3366 {
3367 bandStartChannel = RF_CHAN_1;
3368 bandEndChannel = RF_CHAN_14;
3369 }
3370 else if (eCSR_BAND_5G == curBand)
3371 {
3372 bandStartChannel = RF_CHAN_36;
3373 bandEndChannel = RF_CHAN_165;
3374 }
3375
Arif Hussain6d2a3322013-11-17 19:50:10 -08003376 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303377 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003378 bandStartChannel, bandEndChannel );
3379
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3381 {
3382 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3383 {
3384 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3385 num_channels++;
3386 }
3387 }
3388
3389 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3390
3391 temp_num_channels = num_channels;
3392
3393 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3394 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303395 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003396 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 }
3398
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303399 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3400 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 {
3402 for(i = 0; i < temp_num_channels; i++)
3403 {
3404
3405 if((channel_list->channels[i] > 35) &&
3406 (channel_list->channels[i] < 49))
3407 {
3408 vos_mem_move(&channel_list->channels[i],
3409 &channel_list->channels[i+1],
3410 temp_num_channels - (i-1));
3411 num_channels--;
3412 temp_num_channels--;
3413 i--;
3414 }
3415 }
3416 }
3417
Arif Hussain6d2a3322013-11-17 19:50:10 -08003418 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 channel_list->num_channels = num_channels;
3421 EXIT();
3422
3423 return 0;
3424}
3425
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303426int iw_softap_get_channel_list(struct net_device *dev,
3427 struct iw_request_info *info,
3428 union iwreq_data *wrqu, char *extra)
3429{
3430 int ret;
3431
3432 vos_ssr_protect(__func__);
3433 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3434 vos_ssr_unprotect(__func__);
3435
3436 return ret;
3437}
3438
3439static
3440int __iw_get_genie(struct net_device *dev,
3441 struct iw_request_info *info,
3442 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003443{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303444 hdd_adapter_t *pHostapdAdapter;
3445 hdd_context_t *pHddCtx;
3446 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303447 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3449 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303450 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303453
3454 pHostapdAdapter = (netdev_priv(dev));
3455 if (NULL == pHostapdAdapter)
3456 {
3457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3458 "%s: Adapter is NULL",__func__);
3459 return -EINVAL;
3460 }
3461 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3462 ret = wlan_hdd_validate_context(pHddCtx);
3463 if (0 != ret)
3464 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303465 return ret;
3466 }
3467 pVosContext = pHddCtx->pvosContext;
3468 if (NULL == pVosContext)
3469 {
3470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3471 "%s: vos context is not valid ",__func__);
3472 return -EINVAL;
3473 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003474 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3476 status = WLANSap_getstationIE_information(pVosContext,
3477 &length,
3478 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303479
3480 if (VOS_STATUS_SUCCESS != status) {
3481 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003482 return -EFAULT;
3483 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303484
Arif Hussained667642013-10-27 23:01:14 -07003485 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303486 if (length > DOT11F_IE_RSN_MAX_LEN) {
3487 hddLog(LOGE,
3488 FL("invalid buffer length length:%d"), length);
3489 return -E2BIG;
3490 }
3491
3492 vos_mem_copy(extra, genIeBytes, length);
3493
3494 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3495
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 EXIT();
3497 return 0;
3498}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303499
3500static
3501int iw_get_genie(struct net_device *dev,
3502 struct iw_request_info *info,
3503 union iwreq_data *wrqu, char *extra)
3504{
3505 int ret;
3506
3507 vos_ssr_protect(__func__);
3508 ret = __iw_get_genie(dev, info, wrqu, extra);
3509 vos_ssr_unprotect(__func__);
3510
3511 return ret;
3512}
3513
3514static
3515int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3516 struct iw_request_info *info,
3517 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003518{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303519 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003520 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303521 hdd_ap_ctx_t *pHddApCtx;
3522 hdd_context_t *pHddCtx;
3523 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303524
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003526
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303527 pHostapdAdapter = (netdev_priv(dev));
3528 if (NULL == pHostapdAdapter)
3529 {
3530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3531 "%s: Adapter is NULL",__func__);
3532 return -EINVAL;
3533 }
3534 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3535 ret = wlan_hdd_validate_context(pHddCtx);
3536 if (0 != ret)
3537 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303538 return ret;
3539 }
3540 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3541 if (NULL == pHddApCtx)
3542 {
3543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3544 "%s: AP context is NULL",__func__);
3545 return -EINVAL;
3546 }
3547
Arif Hussain6d2a3322013-11-17 19:50:10 -08003548 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003549 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3550
3551 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3552 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3553 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3554 WPSPBCProbeReqIEs.probeReqIELen);
3555 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3556 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3557 sizeof(v_MACADDR_t));
3558 if (copy_to_user(wrqu->data.pointer,
3559 (void *)&WPSPBCProbeReqIEs,
3560 sizeof(WPSPBCProbeReqIEs)))
3561 {
3562 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3563 return -EFAULT;
3564 }
3565 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003566 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003567 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 up(&pHddApCtx->semWpsPBCOverlapInd);
3569 EXIT();
3570 return 0;
3571}
3572
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303573static
3574int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3575 struct iw_request_info *info,
3576 union iwreq_data *wrqu, char *extra)
3577{
3578 int ret;
3579
3580 vos_ssr_protect(__func__);
3581 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3582 vos_ssr_unprotect(__func__);
3583
3584 return ret;
3585}
3586
Jeff Johnson295189b2012-06-20 16:38:30 -07003587/**---------------------------------------------------------------------------
3588
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303589 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 This function sets the auth type received from the wpa_supplicant.
3591
3592 \param - dev - Pointer to the net device.
3593 - info - Pointer to the iw_request_info.
3594 - wrqu - Pointer to the iwreq_data.
3595 - extra - Pointer to the data.
3596 \return - 0 for success, non zero for failure
3597
3598 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303599int __iw_set_auth_hostap(struct net_device *dev,
3600 struct iw_request_info *info,
3601 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003602{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303603 hdd_adapter_t *pAdapter;
3604 hdd_context_t *pHddCtx;
3605 hdd_wext_state_t *pWextState;
3606 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303607
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303609
3610 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3611 if (NULL == pAdapter)
3612 {
3613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3614 "%s: Adapter is NULL",__func__);
3615 return -EINVAL;
3616 }
3617
3618 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3619 ret = wlan_hdd_validate_context(pHddCtx);
3620 if (0 != ret)
3621 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303622 return ret;
3623 }
3624 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3625 if (NULL == pWextState)
3626 {
3627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3628 "%s: pWextState is NULL",__func__);
3629 return -EINVAL;
3630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 switch(wrqu->param.flags & IW_AUTH_INDEX)
3632 {
3633 case IW_AUTH_TKIP_COUNTERMEASURES:
3634 {
3635 if(wrqu->param.value) {
3636 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3637 "Counter Measure started %d", wrqu->param.value);
3638 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303639 }
3640 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3642 "Counter Measure stopped=%d", wrqu->param.value);
3643 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3644 }
3645
3646 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3647 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303650
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303652
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003653 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 wrqu->param.flags & IW_AUTH_INDEX);
3655 break;
3656 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303657
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 EXIT();
3659 return 0;
3660}
3661
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303662int iw_set_auth_hostap(struct net_device *dev,
3663 struct iw_request_info *info,
3664 union iwreq_data *wrqu,char *extra)
3665{
3666 int ret;
3667
3668 vos_ssr_protect(__func__);
3669 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3670 vos_ssr_unprotect(__func__);
3671
3672 return ret;
3673}
3674
3675static int __iw_set_ap_encodeext(struct net_device *dev,
3676 struct iw_request_info *info,
3677 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003678{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303679 hdd_adapter_t *pHostapdAdapter;
3680 v_CONTEXT_t pVosContext;
3681 hdd_context_t *pHddCtx;
3682 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003683 int retval = 0;
3684 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3686 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3687 int key_index;
3688 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303689 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003690// tCsrRoamRemoveKey RemoveKey;
3691 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303692
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303693 ENTER();
3694 pHostapdAdapter = (netdev_priv(dev));
3695 if (NULL == pHostapdAdapter)
3696 {
3697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3698 "%s: Adapter is NULL",__func__);
3699 return -EINVAL;
3700 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003701
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303702 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3703 retval = wlan_hdd_validate_context(pHddCtx);
3704 if (0 != retval)
3705 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303706 return retval;
3707 }
3708 pVosContext = pHddCtx->pvosContext;
3709 if (NULL == pVosContext)
3710 {
3711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3712 "%s: pVosContext is NULL",__func__);
3713 return -EINVAL;
3714 }
3715 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3716 if (NULL == pHddApCtx)
3717 {
3718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3719 "%s: AP Context is NULL",__func__);
3720 return -EINVAL;
3721 }
3722
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303724
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303726
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 /*Convert from 1-based to 0-based keying*/
3728 key_index--;
3729 }
3730 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303731#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 /*Set the encrytion type to NONE*/
3733#if 0
3734 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3735#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303736
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 RemoveKey.keyId = key_index;
3738 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3739 /*Key direction for group is RX only*/
3740 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3741 }
3742 else {
3743 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3744 }
3745 switch(ext->alg)
3746 {
3747 case IW_ENCODE_ALG_NONE:
3748 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3749 break;
3750 case IW_ENCODE_ALG_WEP:
3751 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3752 break;
3753 case IW_ENCODE_ALG_TKIP:
3754 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003755 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 case IW_ENCODE_ALG_CCMP:
3757 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3758 break;
3759 default:
3760 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3761 break;
3762 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003763 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 -07003764 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003766 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003768 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3769 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 {
3771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003772 __LINE__, vstatus );
3773 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003775#endif
3776 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003777
Jeff Johnson43971f52012-07-17 12:26:56 -07003778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003779
3780 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3781
3782 setKey.keyId = key_index;
3783 setKey.keyLength = ext->key_len;
3784
3785 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3786 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3787 }
3788
3789 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3790 /*Key direction for group is RX only*/
3791 setKey.keyDirection = eSIR_RX_ONLY;
3792 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3793 }
3794 else {
3795
3796 setKey.keyDirection = eSIR_TX_RX;
3797 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3798 }
3799 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3800 {
3801 setKey.keyDirection = eSIR_TX_DEFAULT;
3802 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3803 }
3804
3805 /*For supplicant pae role is zero*/
3806 setKey.paeRole = 0;
3807
3808 switch(ext->alg)
3809 {
3810 case IW_ENCODE_ALG_NONE:
3811 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3812 break;
3813
3814 case IW_ENCODE_ALG_WEP:
3815 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3816 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003817 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 break;
3819
3820 case IW_ENCODE_ALG_TKIP:
3821 {
3822 v_U8_t *pKey = &setKey.Key[0];
3823
3824 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3825
3826 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3827
3828 /*Supplicant sends the 32bytes key in this order
3829
3830 |--------------|----------|----------|
3831 | Tk1 |TX-MIC | RX Mic |
3832 |--------------|----------|----------|
3833 <---16bytes---><--8bytes--><--8bytes-->
3834
3835 */
3836 /*Sme expects the 32 bytes key to be in the below order
3837
3838 |--------------|----------|----------|
3839 | Tk1 |RX-MIC | TX Mic |
3840 |--------------|----------|----------|
3841 <---16bytes---><--8bytes--><--8bytes-->
3842 */
3843 /* Copy the Temporal Key 1 (TK1) */
3844 vos_mem_copy(pKey,ext->key,16);
3845
3846 /*Copy the rx mic first*/
3847 vos_mem_copy(&pKey[16],&ext->key[24],8);
3848
3849 /*Copy the tx mic */
3850 vos_mem_copy(&pKey[24],&ext->key[16],8);
3851
3852 }
3853 break;
3854
3855 case IW_ENCODE_ALG_CCMP:
3856 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3857 break;
3858
3859 default:
3860 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3861 break;
3862 }
3863
3864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303865 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 setKey.keyId);
3867 for(i=0; i< ext->key_len; i++)
3868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3869 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003870
3871 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3872 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 {
3874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003875 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3876 retval = -EINVAL;
3877 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303878
3879 EXIT();
3880 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003881}
Jeff Johnson43971f52012-07-17 12:26:56 -07003882
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303883static int iw_set_ap_encodeext(struct net_device *dev,
3884 struct iw_request_info *info,
3885 union iwreq_data *wrqu, char *extra)
3886{
3887 int ret;
3888
3889 vos_ssr_protect(__func__);
3890 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3891 vos_ssr_unprotect(__func__);
3892
3893 return ret;
3894}
Jeff Johnson43971f52012-07-17 12:26:56 -07003895
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303896static int __iw_set_ap_mlme(struct net_device *dev,
3897 struct iw_request_info *info,
3898 union iwreq_data *wrqu,
3899 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003900{
3901#if 0
3902 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3903 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3904
3905 ENTER();
3906
3907 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3908 switch (mlme->cmd) {
3909 case IW_MLME_DISASSOC:
3910 case IW_MLME_DEAUTH:
3911 hddLog(LOG1, "Station disassociate");
3912 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3913 {
3914 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3915
3916 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3917 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3918
3919 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3920
3921 //clear all the reason codes
3922 if (status != 0)
3923 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003924 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 }
3926
3927 netif_stop_queue(dev);
3928 netif_carrier_off(dev);
3929 }
3930 else
3931 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003932 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 -07003933 }
3934 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003935 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 return -EINVAL;
3937 }//end of switch
3938 EXIT();
3939#endif
3940 return 0;
3941// return status;
3942}
3943
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303944static int iw_set_ap_mlme(struct net_device *dev,
3945 struct iw_request_info *info,
3946 union iwreq_data *wrqu,
3947 char *extra)
3948{
3949 int ret;
3950
3951 vos_ssr_protect(__func__);
3952 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3953 vos_ssr_unprotect(__func__);
3954
3955 return ret;
3956}
3957
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303958static int __iw_get_ap_rts_threshold(struct net_device *dev,
3959 struct iw_request_info *info,
3960 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003961{
3962 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3963 v_U32_t status = 0;
3964
3965 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3966
3967 return status;
3968}
3969
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303970static int iw_get_ap_rts_threshold(struct net_device *dev,
3971 struct iw_request_info *info,
3972 union iwreq_data *wrqu, char *extra)
3973{
3974 int ret;
3975
3976 vos_ssr_protect(__func__);
3977 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3978 vos_ssr_unprotect(__func__);
3979
3980 return ret;
3981}
3982
3983static int __iw_get_ap_frag_threshold(struct net_device *dev,
3984 struct iw_request_info *info,
3985 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003986{
3987 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3988 v_U32_t status = 0;
3989
3990 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3991
3992 return status;
3993}
3994
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303995static int iw_get_ap_frag_threshold(struct net_device *dev,
3996 struct iw_request_info *info,
3997 union iwreq_data *wrqu, char *extra)
3998{
3999 int ret;
4000
4001 vos_ssr_protect(__func__);
4002 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4003 vos_ssr_unprotect(__func__);
4004
4005 return ret;
4006}
4007
4008static int __iw_get_ap_freq(struct net_device *dev,
4009 struct iw_request_info *info,
4010 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004011{
Jeff Johnsone7245742012-09-05 17:12:55 -07004012 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304013 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 tHalHandle hHal;
4015 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304016 hdd_ap_ctx_t *pHddApCtx;
4017 hdd_context_t *pHddCtx;
4018 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019
4020 ENTER();
4021
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304022 pHostapdAdapter = (netdev_priv(dev));
4023 if (NULL == pHostapdAdapter)
4024 {
4025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4026 "%s: Adapter is NULL",__func__);
4027 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304029 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4030 ret = wlan_hdd_validate_context(pHddCtx);
4031 if (0 != ret)
4032 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304033 return ret;
4034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304036 if (NULL == pHostapdState)
4037 {
4038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4039 "%s: pHostapdState is NULL",__func__);
4040 return -EINVAL;
4041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304043 if (NULL == hHal)
4044 {
4045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4046 "%s: Hal Context is NULL",__func__);
4047 return -EINVAL;
4048 }
4049 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4050 if (NULL == pHddApCtx)
4051 {
4052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4053 "%s: AP context is NULL",__func__);
4054 return -EINVAL;
4055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 if(pHostapdState->bssState == BSS_STOP )
4057 {
4058 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4059 != eHAL_STATUS_SUCCESS)
4060 {
c_hpothuffdb5272013-10-02 16:42:35 +05304061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4062 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 return -EIO;
4064 }
4065 else
4066 {
4067 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004068 if( TRUE == status)
4069 {
4070 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4071 * iwlist & iwconfig command shows frequency into proper
4072 * format (2.412 GHz instead of 246.2 MHz)*/
4073 fwrq->m = freq;
4074 fwrq->e = MHZ;
4075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 }
4077 }
4078 else
4079 {
4080 channel = pHddApCtx->operatingChannel;
4081 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004082 if( TRUE == status)
4083 {
4084 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4085 * iwlist & iwconfig command shows frequency into proper
4086 * format (2.412 GHz instead of 246.2 MHz)*/
4087 fwrq->m = freq;
4088 fwrq->e = MHZ;
4089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304091
4092 EXIT();
4093 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004094}
4095
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304096static int iw_get_ap_freq(struct net_device *dev,
4097 struct iw_request_info *info,
4098 struct iw_freq *fwrq, char *extra)
4099{
4100 int ret;
4101
4102 vos_ssr_protect(__func__);
4103 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4104 vos_ssr_unprotect(__func__);
4105
4106 return ret;
4107}
4108
4109static int __iw_get_mode(struct net_device *dev,
4110 struct iw_request_info *info,
4111 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304112{
4113 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304114 hdd_adapter_t *pAdapter;
4115 hdd_context_t *pHddCtx;
4116
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304117 ENTER();
4118
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304119 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4120 if (NULL == pAdapter)
4121 {
4122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4123 "%s: Adapter is NULL",__func__);
4124 return -EINVAL;
4125 }
4126 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4127 status = wlan_hdd_validate_context(pHddCtx);
4128 if (0 != status)
4129 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304130 return status;
4131 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304132
4133 wrqu->mode = IW_MODE_MASTER;
4134
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304135 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304136 return status;
4137}
4138
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304139static int iw_get_mode(struct net_device *dev,
4140 struct iw_request_info *info,
4141 union iwreq_data *wrqu, char *extra)
4142{
4143 int ret;
4144
4145 vos_ssr_protect(__func__);
4146 ret = __iw_get_mode(dev, info, wrqu, extra);
4147 vos_ssr_unprotect(__func__);
4148
4149 return ret;
4150}
4151
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304152
4153static int __iw_softap_stopbss(struct net_device *dev,
4154 struct iw_request_info *info,
4155 union iwreq_data *wrqu,
4156 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004157{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304158 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304160 hdd_context_t *pHddCtx = NULL;
4161
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304163 pHostapdAdapter = (netdev_priv(dev));
4164 if (NULL == pHostapdAdapter)
4165 {
4166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4167 "%s: Adapter is NULL",__func__);
4168 return -EINVAL;
4169 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304170 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4171 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304172 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304173 return status;
4174 }
4175
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304176 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 {
4178 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4179 {
4180 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4181
4182 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304183
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304185 {
4186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004187 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 VOS_ASSERT(0);
4189 }
4190 }
4191 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304192 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 }
4194 EXIT();
4195 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4196}
4197
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304198static int iw_softap_stopbss(struct net_device *dev,
4199 struct iw_request_info *info,
4200 union iwreq_data *wrqu,
4201 char *extra)
4202{
4203 int ret;
4204
4205 vos_ssr_protect(__func__);
4206 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4207 vos_ssr_unprotect(__func__);
4208
4209 return ret;
4210}
4211
4212static int __iw_softap_version(struct net_device *dev,
4213 struct iw_request_info *info,
4214 union iwreq_data *wrqu,
4215 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004216{
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304218 hdd_context_t *pHddCtx;
4219 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304220
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304222 pHostapdAdapter = (netdev_priv(dev));
4223 if (NULL == pHostapdAdapter)
4224 {
4225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4226 "%s: Adapter is NULL",__func__);
4227 return -EINVAL;
4228 }
4229 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4230 ret = wlan_hdd_validate_context(pHddCtx);
4231 if (0 != ret)
4232 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304233 return ret;
4234 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004235 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 return 0;
4238}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004239
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304240static int iw_softap_version(struct net_device *dev,
4241 struct iw_request_info *info,
4242 union iwreq_data *wrqu,
4243 char *extra)
4244{
4245 int ret;
4246
4247 vos_ssr_protect(__func__);
4248 ret = __iw_softap_version(dev, info, wrqu, extra);
4249 vos_ssr_unprotect(__func__);
4250
4251 return ret;
4252}
4253
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304254int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004255{
4256 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004257 int len = 0;
4258 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304259 v_CONTEXT_t pVosContext;
4260 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304261 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304262
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304263 ENTER();
4264
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304265 if (NULL == pAdapter)
4266 {
4267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4268 "%s: Adapter is NULL",__func__);
4269 return -EINVAL;
4270 }
4271 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4272 if (0 != wlan_hdd_validate_context(pHddCtx))
4273 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304274 return VOS_STATUS_E_FAULT;
4275 }
4276 pVosContext = pHddCtx->pvosContext;
4277 if (NULL == pVosContext)
4278 {
4279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4280 "%s: VOS context is not valid",__func__);
4281 return VOS_STATUS_E_FAULT;
4282 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304283 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304284 if(pSapCtx == NULL)
4285 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304286 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4287 FL("psapCtx is NULL"));
4288 return VOS_STATUS_E_FAULT;
4289 }
4290
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304291 len = snprintf(pBuf, buf_len, sta_info_header);
4292 if (len >= buf_len) {
4293 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4294 return -E2BIG;
4295 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004296 pBuf += len;
4297 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004298
4299 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4300 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304301 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004302 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004303 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304304 pSapCtx->aStaInfo[i].ucSTAId,
4305 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4306 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4307 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4308 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4309 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4310 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304311 if (len >= buf_len) {
4312 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4313 return -E2BIG;
4314 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004315 pBuf += len;
4316 buf_len -= len;
4317 }
4318 if(WE_GET_STA_INFO_SIZE > buf_len)
4319 {
4320 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004321 }
4322 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304323 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304324 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004325}
4326
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304327static int __iw_softap_get_sta_info(struct net_device *dev,
4328 struct iw_request_info *info,
4329 union iwreq_data *wrqu,
4330 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004331{
4332 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304333 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004334 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304335 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4336 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004337 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304338 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004339 }
4340 wrqu->data.length = strlen(extra);
4341 EXIT();
4342 return 0;
4343}
4344
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304345static int iw_softap_get_sta_info(struct net_device *dev,
4346 struct iw_request_info *info,
4347 union iwreq_data *wrqu,
4348 char *extra)
4349{
4350 int ret;
4351
4352 vos_ssr_protect(__func__);
4353 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4354 vos_ssr_unprotect(__func__);
4355
4356 return ret;
4357}
4358
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304359static int __iw_set_ap_genie(struct net_device *dev,
4360 struct iw_request_info *info,
4361 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004362{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304363
4364 hdd_adapter_t *pHostapdAdapter;
4365 hdd_context_t *pHddCtx;
4366 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004368 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304369 int ret = 0;
4370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304372 pHostapdAdapter = (netdev_priv(dev));
4373 if (NULL == pHostapdAdapter)
4374 {
4375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4376 "%s: Adapter is NULL",__func__);
4377 return -EINVAL;
4378 }
4379 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4380 ret = wlan_hdd_validate_context(pHddCtx);
4381 if (0 != ret)
4382 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304383 return ret;
4384 }
4385 pVosContext = pHddCtx->pvosContext;
4386 if (NULL == pVosContext)
4387 {
4388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4389 "%s: VOS Context is NULL",__func__);
4390 return -EINVAL;
4391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 if(!wrqu->data.length)
4393 {
4394 EXIT();
4395 return 0;
4396 }
Arif Hussained667642013-10-27 23:01:14 -07004397
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304398 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304400 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 case DOT11F_EID_RSN:
4402 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4403 {
4404 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4405 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004408 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304410
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004412 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 halStatus = 0;
4414 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304415
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304417 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004418}
4419
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304420static int iw_set_ap_genie(struct net_device *dev,
4421 struct iw_request_info *info,
4422 union iwreq_data *wrqu, char *extra)
4423{
4424 int ret;
4425
4426 vos_ssr_protect(__func__);
4427 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4428 vos_ssr_unprotect(__func__);
4429
4430 return ret;
4431}
4432
Jeff Johnson295189b2012-06-20 16:38:30 -07004433static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4434{
4435 eHalStatus hstatus;
4436 long lrc;
4437 struct statsContext context;
4438
4439 if (NULL == pAdapter)
4440 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304441 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 return VOS_STATUS_E_FAULT;
4443 }
4444
4445 init_completion(&context.completion);
4446 context.pAdapter = pAdapter;
4447 context.magic = STATS_CONTEXT_MAGIC;
4448 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4449 eCSR_HDD,
4450 SME_GLOBAL_CLASSA_STATS,
4451 hdd_GetClassA_statisticsCB,
4452 0, // not periodic
4453 FALSE, //non-cached results
4454 staid,
4455 &context);
4456 if (eHAL_STATUS_SUCCESS != hstatus)
4457 {
4458 hddLog(VOS_TRACE_LEVEL_ERROR,
4459 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004460 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 }
4462 else
4463 {
4464 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4465 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 if (lrc <= 0)
4467 {
4468 hddLog(VOS_TRACE_LEVEL_ERROR,
4469 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004470 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 }
4472 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004473
4474 /* either we never sent a request, we sent a request and received a
4475 response or we sent a request and timed out. if we never sent a
4476 request or if we sent a request and got a response, we want to
4477 clear the magic out of paranoia. if we timed out there is a
4478 race condition such that the callback function could be
4479 executing at the same time we are. of primary concern is if the
4480 callback function had already verified the "magic" but had not
4481 yet set the completion variable when a timeout occurred. we
4482 serialize these activities by invalidating the magic while
4483 holding a shared spinlock which will cause us to block if the
4484 callback is currently executing */
4485 spin_lock(&hdd_context_lock);
4486 context.magic = 0;
4487 spin_unlock(&hdd_context_lock);
4488
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 return VOS_STATUS_SUCCESS;
4490}
4491
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304492int __iw_get_softap_linkspeed(struct net_device *dev,
4493 struct iw_request_info *info,
4494 union iwreq_data *wrqu,
4495 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004496
4497{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304498 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304499 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004501 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304502 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304504 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004506 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304507 int rc, valid;
4508
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304509 ENTER();
4510
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304511 pHostapdAdapter = (netdev_priv(dev));
4512 if (NULL == pHostapdAdapter)
4513 {
4514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4515 "%s: Adapter is NULL",__func__);
4516 return -EINVAL;
4517 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304518 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304519 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304520 if (0 != valid)
4521 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304522 return valid;
4523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004524
Arif Hussain6d2a3322013-11-17 19:50:10 -08004525 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004526
4527 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004528 {
Arif Hussaina9571842014-01-15 16:43:41 -08004529 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4530 if (NULL == pmacAddress) {
4531 hddLog(LOG1, "unable to allocate memory");
4532 return -ENOMEM;
4533 }
4534 if (copy_from_user((void *)pmacAddress,
4535 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4536 {
4537 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4538 kfree(pmacAddress);
4539 return -EFAULT;
4540 }
Manjeet Singha3739742016-05-03 16:21:46 +05304541 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004542
4543 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004544 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004545
4546 if (!VOS_IS_STATUS_SUCCESS(status ))
4547 {
4548 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4549 }
Arif Hussained667642013-10-27 23:01:14 -07004550 }
Kiet Lam61589852013-09-19 17:10:58 +05304551 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304552 * link speed for first connected client will be returned.
4553 */
Arif Hussaina9571842014-01-15 16:43:41 -08004554 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304555 {
4556 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4557 }
4558 else
4559 {
4560 status = hdd_softap_GetStaId(pHostapdAdapter,
4561 (v_MACADDR_t *)macAddress, (void *)(&staId));
4562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004563
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304564 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304566 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 link_speed = 0;
4568 }
4569 else
4570 {
4571 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304572
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 if (!VOS_IS_STATUS_SUCCESS(status ))
4574 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304575 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 return -EINVAL;
4577 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304578
4579 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4580 staId, &link_speed);
4581
4582 link_speed = link_speed / 10;
4583
4584 if (0 == link_speed)
4585 {
4586 /* The linkspeed returned by HAL is in units of 500kbps.
4587 * converting it to mbps.
4588 * This is required to support legacy firmware which does
4589 * not return link capacity.
4590 */
4591 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 }
4594
4595 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004596 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304597
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 if ((rc < 0) || (rc >= len))
4599 {
4600 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304601 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 return -EIO;
4603 }
4604
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304605 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 return 0;
4607}
4608
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304609int iw_get_softap_linkspeed(struct net_device *dev,
4610 struct iw_request_info *info,
4611 union iwreq_data *wrqu,
4612 char *extra)
4613{
4614 int ret;
4615
4616 vos_ssr_protect(__func__);
4617 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4618 vos_ssr_unprotect(__func__);
4619
4620 return ret;
4621}
4622
4623
Jeff Johnson295189b2012-06-20 16:38:30 -07004624static const iw_handler hostapd_handler[] =
4625{
4626 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4627 (iw_handler) NULL, /* SIOCGIWNAME */
4628 (iw_handler) NULL, /* SIOCSIWNWID */
4629 (iw_handler) NULL, /* SIOCGIWNWID */
4630 (iw_handler) NULL, /* SIOCSIWFREQ */
4631 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4632 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304633 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 (iw_handler) NULL, /* SIOCSIWSENS */
4635 (iw_handler) NULL, /* SIOCGIWSENS */
4636 (iw_handler) NULL, /* SIOCSIWRANGE */
4637 (iw_handler) NULL, /* SIOCGIWRANGE */
4638 (iw_handler) NULL, /* SIOCSIWPRIV */
4639 (iw_handler) NULL, /* SIOCGIWPRIV */
4640 (iw_handler) NULL, /* SIOCSIWSTATS */
4641 (iw_handler) NULL, /* SIOCGIWSTATS */
4642 (iw_handler) NULL, /* SIOCSIWSPY */
4643 (iw_handler) NULL, /* SIOCGIWSPY */
4644 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4645 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4646 (iw_handler) NULL, /* SIOCSIWAP */
4647 (iw_handler) NULL, /* SIOCGIWAP */
4648 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4649 (iw_handler) NULL, /* SIOCGIWAPLIST */
4650 (iw_handler) NULL, /* SIOCSIWSCAN */
4651 (iw_handler) NULL, /* SIOCGIWSCAN */
4652 (iw_handler) NULL, /* SIOCSIWESSID */
4653 (iw_handler) NULL, /* SIOCGIWESSID */
4654 (iw_handler) NULL, /* SIOCSIWNICKN */
4655 (iw_handler) NULL, /* SIOCGIWNICKN */
4656 (iw_handler) NULL, /* -- hole -- */
4657 (iw_handler) NULL, /* -- hole -- */
4658 (iw_handler) NULL, /* SIOCSIWRATE */
4659 (iw_handler) NULL, /* SIOCGIWRATE */
4660 (iw_handler) NULL, /* SIOCSIWRTS */
4661 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4662 (iw_handler) NULL, /* SIOCSIWFRAG */
4663 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4664 (iw_handler) NULL, /* SIOCSIWTXPOW */
4665 (iw_handler) NULL, /* SIOCGIWTXPOW */
4666 (iw_handler) NULL, /* SIOCSIWRETRY */
4667 (iw_handler) NULL, /* SIOCGIWRETRY */
4668 (iw_handler) NULL, /* SIOCSIWENCODE */
4669 (iw_handler) NULL, /* SIOCGIWENCODE */
4670 (iw_handler) NULL, /* SIOCSIWPOWER */
4671 (iw_handler) NULL, /* SIOCGIWPOWER */
4672 (iw_handler) NULL, /* -- hole -- */
4673 (iw_handler) NULL, /* -- hole -- */
4674 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4675 (iw_handler) NULL, /* SIOCGIWGENIE */
4676 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4677 (iw_handler) NULL, /* SIOCGIWAUTH */
4678 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4679 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4680 (iw_handler) NULL, /* SIOCSIWPMKSA */
4681};
4682
Jeff Johnson224f3702014-03-26 11:09:47 -07004683/*
4684 * Note that the following ioctls were defined with semantics which
4685 * cannot be handled by the "iwpriv" userspace application and hence
4686 * they are not included in the hostapd_private_args array
4687 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4688 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004689
4690static const struct iw_priv_args hostapd_private_args[] = {
4691 { QCSAP_IOCTL_SETPARAM,
4692 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4693 { QCSAP_IOCTL_SETPARAM,
4694 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304695 { QCSAP_PARAM_GET_FRAME_LOGS,
4696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 { QCSAP_PARAM_MAX_ASSOC,
4698 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4699 { QCSAP_PARAM_HIDE_SSID,
4700 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004701 { QCSAP_PARAM_SET_MC_RATE,
4702 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304703 { QCSAP_PARAM_SET_PROXIMITY,
4704 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304705 { QCSAP_PARAM_SET_WOWL,
4706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 { QCSAP_IOCTL_GETPARAM,
4708 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4709 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4710 { QCSAP_IOCTL_GETPARAM, 0,
4711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4712 { QCSAP_PARAM_MAX_ASSOC, 0,
4713 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004714 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4716 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304718 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4719 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 { QCSAP_PARAM_CLR_ACL, 0,
4721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4722 { QCSAP_PARAM_ACL_MODE,
4723 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304725 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 { QCSAP_IOCTL_STOPBSS,
4727 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4728 { QCSAP_IOCTL_VERSION, 0,
4729 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004730 { QCSAP_IOCTL_GET_STA_INFO, 0,
4731 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004732 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004733 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004736 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304738 { QCSAP_IOCTL_AP_STATS, 0,
4739 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304740 { QCSAP_IOCTL_GET_STATS, 0,
4741 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4742 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4744 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304745 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004746
4747 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4748 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4749 /* handlers for sub-ioctl */
4750 { WE_SET_WLAN_DBG,
4751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4752 0,
4753 "setwlandbg" },
4754
4755 /* handlers for main ioctl */
4756 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4757 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4758 0,
4759 "" },
4760
4761 /* handlers for sub-ioctl */
4762 { WE_LOG_DUMP_CMD,
4763 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4764 0,
4765 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 { WE_P2P_NOA_CMD,
4767 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4768 0,
4769 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004770 /* handlers for sub ioctl */
4771 {
4772 WE_MCC_CONFIG_CREDENTIAL,
4773 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4774 0,
4775 "setMccCrdnl" },
4776
4777 /* handlers for sub ioctl */
4778 {
4779 WE_MCC_CONFIG_PARAMS,
4780 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4781 0,
4782 "setMccConfig" },
4783
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 /* handlers for main ioctl */
4785 { QCSAP_IOCTL_MODIFY_ACL,
4786 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4787 0,
4788 "modify_acl" },
4789
4790 /* handlers for main ioctl */
4791 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4792 0,
4793 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4794 "getChannelList" },
4795
Jeff Johnsone7245742012-09-05 17:12:55 -07004796 /* handlers for main ioctl */
4797 { QCSAP_IOCTL_SET_TX_POWER,
4798 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4799 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304800 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004801
4802 /* handlers for main ioctl */
4803 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4804 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4805 0,
4806 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304807
4808 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4809 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4810 0,
4811 "dataSnapshot" },
4812
4813 /* handlers for main ioctl */
4814 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4815 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4816 0,
4817 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304818 /* handlers for main ioctl */
4819 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
4820 IW_PRIV_TYPE_CHAR| 512,
4821 0,
4822 "" },
4823
4824 /* handlers for sub-ioctl */
4825 { WE_WOWL_ADD_PTRN,
4826 IW_PRIV_TYPE_CHAR| 512,
4827 0,
4828 "wowlAddPtrn" },
4829
4830 { WE_WOWL_DEL_PTRN,
4831 IW_PRIV_TYPE_CHAR| 512,
4832 0,
4833 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004834};
Jeff Johnsone7245742012-09-05 17:12:55 -07004835
Jeff Johnson295189b2012-06-20 16:38:30 -07004836static const iw_handler hostapd_private[] = {
4837 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304838 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
4839 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
4840 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4843 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4844 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4845 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4846 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4847 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4848 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304849 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4851 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4852 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4853 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004854 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004855 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4856 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004857 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304858 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304859 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304860 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4861 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004862};
4863const struct iw_handler_def hostapd_handler_def = {
4864 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4865 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4866 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4867 .standard = (iw_handler *)hostapd_handler,
4868 .private = (iw_handler *)hostapd_private,
4869 .private_args = hostapd_private_args,
4870 .get_wireless_stats = NULL,
4871};
4872#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4873struct net_device_ops net_ops_struct = {
4874 .ndo_open = hdd_hostapd_open,
4875 .ndo_stop = hdd_hostapd_stop,
4876 .ndo_uninit = hdd_hostapd_uninit,
4877 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4878 .ndo_tx_timeout = hdd_softap_tx_timeout,
4879 .ndo_get_stats = hdd_softap_stats,
4880 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4881 .ndo_do_ioctl = hdd_hostapd_ioctl,
4882 .ndo_change_mtu = hdd_hostapd_change_mtu,
4883 .ndo_select_queue = hdd_hostapd_select_queue,
4884 };
4885#endif
4886
4887int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4888{
4889 return VOS_STATUS_SUCCESS;
4890}
4891
4892void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4893{
4894#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4895 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4896#else
4897 pWlanHostapdDev->open = hdd_hostapd_open;
4898 pWlanHostapdDev->stop = hdd_hostapd_stop;
4899 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4900 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4901 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4902 pWlanHostapdDev->get_stats = hdd_softap_stats;
4903 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4904 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4905#endif
4906}
4907
4908VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304909{
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05304911#ifdef DHCP_SERVER_OFFLOAD
4912 hdd_dhcp_state_t *dhcp_status;
4913#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304914#ifdef MDNS_OFFLOAD
4915 hdd_mdns_state_t *mdns_status;
4916#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004918 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004920#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004921 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4922 v_U16_t unsafeChannelCount;
4923#endif /* FEATURE_WLAN_CH_AVOID */
4924
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304925 if (pHddCtx->isLogpInProgress) {
4926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4927 "%s:LOGP in Progress. Ignore!!!",__func__);
4928 status = VOS_STATUS_E_FAILURE;
4929 }
4930
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304932
4933#ifdef SAP_AUTH_OFFLOAD
4934 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05304935 {
4936 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
4937 {
4938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4939 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
4940 return VOS_STATUS_E_FAILURE;
4941 }
4942 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304943#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304944
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304945 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05304947#ifdef DHCP_SERVER_OFFLOAD
4948 dhcp_status = &pAdapter->dhcp_status;
4949#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304950#ifdef MDNS_OFFLOAD
4951 mdns_status = &pAdapter->mdns_status;
4952#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304953
Nirav Shah7e3c8132015-06-22 23:51:42 +05304954 spin_lock_init(&pAdapter->sta_hash_lock);
4955 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4956
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004957 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4958
Leo Chang0b0e45a2013-12-15 15:18:55 -08004959#ifdef FEATURE_WLAN_CH_AVOID
4960 /* Get unsafe cahnnel list from cached location */
4961 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4962 sizeof(unsafeChannelList),
4963 &unsafeChannelCount);
4964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4965 "%s : Unsafe Channel count %d",
4966 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304967 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004968 unsafeChannelList,
4969 unsafeChannelCount);
4970#endif /* FEATURE_WLAN_CH_AVOID */
4971
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 // Zero the memory. This zeros the profile structure.
4973 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05304974#ifdef DHCP_SERVER_OFFLOAD
4975 memset(dhcp_status, 0,sizeof(*dhcp_status));
4976#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304977#ifdef MDNS_OFFLOAD
4978 memset(mdns_status, 0,sizeof(*mdns_status));
4979#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05304980
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 // Set up the pointer to the Wireless Extensions state structure
4982 // NOP
4983 status = hdd_set_hostapd(pAdapter);
4984 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 return status;
4987 }
4988
4989 status = vos_event_init(&phostapdBuf->vosEvent);
4990 if (!VOS_IS_STATUS_SUCCESS(status))
4991 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 return status;
4994 }
Anurag Chouhan83026002016-12-13 22:46:21 +05304995#ifdef DHCP_SERVER_OFFLOAD
4996 status = vos_event_init(&dhcp_status->vos_event);
4997 if (!VOS_IS_STATUS_SUCCESS(status)) {
4998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
4999 return status;
5000 }
5001#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305002#ifdef MDNS_OFFLOAD
5003 status = vos_event_init(&mdns_status->vos_event);
5004 if (!VOS_IS_STATUS_SUCCESS(status)) {
5005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5006 ("Hostapd HDD vos event init failed!!"));
5007 return status;
5008 }
5009#endif /* MDNS_OFFLOAD */
5010
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5012
5013 // Register as a wireless device
5014 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5015
5016 //Initialize the data path module
5017 status = hdd_softap_init_tx_rx(pAdapter);
5018 if ( !VOS_IS_STATUS_SUCCESS( status ))
5019 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005020 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305022
5023 status = hdd_wmm_adapter_init( pAdapter );
5024 if (!VOS_IS_STATUS_SUCCESS(status))
5025 {
5026 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005027 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305028 status, status );
5029 goto error_wmm_init;
5030 }
5031
5032 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5033
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305034 return status;
5035
5036error_wmm_init:
5037 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 EXIT();
5039 return status;
5040}
5041
5042hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5043{
5044 struct net_device *pWlanHostapdDev = NULL;
5045 hdd_adapter_t *pHostapdAdapter = NULL;
5046 v_CONTEXT_t pVosContext= NULL;
5047
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305048 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5050 NET_NAME_UNKNOWN,
5051#endif
5052 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 if (pWlanHostapdDev != NULL)
5054 {
5055 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5056
5057 //Init the net_device structure
5058 ether_setup(pWlanHostapdDev);
5059
5060 //Initialize the adapter context to zeros.
5061 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5062 pHostapdAdapter->dev = pWlanHostapdDev;
5063 pHostapdAdapter->pHddCtx = pHddCtx;
5064 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5065
5066 //Get the Global VOSS context.
5067 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5068 //Save the adapter context in global context for future.
5069 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5070
5071 //Init the net_device structure
5072 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5073
5074 hdd_set_ap_ops( pHostapdAdapter->dev );
5075
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5077 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5078
5079 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5080 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5081
5082 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5084 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5085 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005086
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5088 }
5089 return pHostapdAdapter;
5090}
5091
5092VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5093{
5094 struct net_device *dev = pAdapter->dev;
5095 VOS_STATUS status = VOS_STATUS_SUCCESS;
5096
5097 ENTER();
5098
5099 if( rtnl_lock_held )
5100 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005101 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 if( dev_alloc_name(dev, dev->name) < 0 )
5103 {
5104 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5105 return VOS_STATUS_E_FAILURE;
5106 }
5107 }
5108 if (register_netdevice(dev))
5109 {
5110 hddLog(VOS_TRACE_LEVEL_FATAL,
5111 "%s:Failed:register_netdevice", __func__);
5112 return VOS_STATUS_E_FAILURE;
5113 }
5114 }
5115 else
5116 {
5117 if (register_netdev(dev))
5118 {
5119 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5120 return VOS_STATUS_E_FAILURE;
5121 }
5122 }
5123 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5124
5125 EXIT();
5126 return status;
5127}
5128
c_hpothu002231a2015-02-05 14:58:51 +05305129VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005130{
5131 ENTER();
5132
5133 hdd_softap_deinit_tx_rx(pAdapter);
5134
5135 /* if we are being called during driver unload, then the dev has already
5136 been invalidated. if we are being called at other times, then we can
5137 detatch the wireless device handlers */
5138 if (pAdapter->dev)
5139 {
c_hpothu002231a2015-02-05 14:58:51 +05305140 if (TRUE == rtnl_held)
5141 {
5142 pAdapter->dev->wireless_handlers = NULL;
5143 }
5144 else
5145 {
5146 rtnl_lock();
5147 pAdapter->dev->wireless_handlers = NULL;
5148 rtnl_unlock();
5149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 }
5151 EXIT();
5152 return 0;
5153}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305154
5155/**
5156 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5157 * to supplicant, if there any clients connected to SAP interface.
5158 * @adapter: sap adapter context
5159 *
5160 * Return: nothing
5161 */
5162void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5163{
5164 tSap_Event sap_event;
5165 int staId;
5166 hdd_context_t *hdd_ctx;
5167 v_CONTEXT_t vos_ctx;
5168 ptSapContext sap_ctx;
5169
5170 ENTER();
5171
5172 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5173 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
5174 return;
5175 }
5176
5177 vos_ctx = hdd_ctx->pvosContext;
5178 if (NULL == vos_ctx) {
5179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5180 "%s: VOS context is not valid",__func__);
5181 return;
5182 }
5183
5184 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5185 if (!sap_ctx) {
5186 hddLog(LOGE, FL("invalid sap context"));
5187 return;
5188 }
5189
5190 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5191 if (sap_ctx->aStaInfo[staId].isUsed) {
5192 hddLog(LOG1, FL("staId: %d isUsed: %d %p"),
5193 staId, sap_ctx->aStaInfo[staId].isUsed,
5194 sap_ctx);
5195
5196 if (vos_is_macaddr_broadcast(
5197 &sap_ctx->aStaInfo[staId].macAddrSTA))
5198 continue;
5199
5200 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5201 vos_mem_copy(
5202 &sap_event.sapevt.
5203 sapStationDisassocCompleteEvent.staMac,
5204 &sap_ctx->aStaInfo[staId].macAddrSTA,
5205 sizeof(v_MACADDR_t));
5206 sap_event.sapevt.sapStationDisassocCompleteEvent.
5207 reason =
5208 eSAP_MAC_INITATED_DISASSOC;
5209 sap_event.sapevt.sapStationDisassocCompleteEvent.
5210 statusCode =
5211 eSIR_SME_RESOURCES_UNAVAILABLE;
5212 hdd_hostapd_SAPEventCB(&sap_event,
5213 sap_ctx->pUsrContext);
5214 }
5215 }
5216
5217 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5218
5219 EXIT();
5220}
5221
5222/**
5223 * hdd_sap_destroy_events() - Destroy sap evets
5224 * @adapter: sap adapter context
5225 *
5226 * Return: nothing
5227 */
5228void hdd_sap_destroy_events(hdd_adapter_t *adapter)
5229{
5230 hdd_context_t *hdd_ctx;
5231 v_CONTEXT_t vos_ctx;
5232 ptSapContext sap_ctx;
5233
5234 ENTER();
5235
5236 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5237 if (0 != wlan_hdd_validate_context(hdd_ctx)) {
5238 return;
5239 }
5240
5241 vos_ctx = hdd_ctx->pvosContext;
5242 if (NULL == vos_ctx) {
5243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5244 "%s: VOS context is not valid",__func__);
5245 return;
5246 }
5247
5248 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5249 if (!sap_ctx) {
5250 hddLog(LOGE, FL("invalid sap context"));
5251 return;
5252 }
5253
5254 if (!VOS_IS_STATUS_SUCCESS(vos_lock_destroy(&sap_ctx->SapGlobalLock)))
5255 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5256 FL("WLANSAP_Stop failed destroy lock"));
5257}