blob: 16d905844869610b94e9b76d8ac29c286c179946 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh57a31542016-01-04 21:01:43 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053082#include <wlan_hdd_wowl.h>
Agrawal Ashish17ef5082016-10-17 18:33:21 +053083#include "wlan_hdd_hostapd.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Leo Chang0b0e45a2013-12-15 15:18:55 -080085#ifdef FEATURE_WLAN_CH_AVOID
86#include "wcnss_wlan.h"
87#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053088#include "wlan_hdd_trace.h"
89#include "vos_types.h"
90#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080091
Jeff Johnson295189b2012-06-20 16:38:30 -070092#define IS_UP(_dev) \
93 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
94#define IS_UP_AUTO(_ic) \
95 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
96#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070097#define WE_GET_STA_INFO_SIZE 30
98/* WEXT limition: MAX allowed buf len for any *
99 * IW_PRIV_TYPE_CHAR is 2Kbytes *
100 */
101#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530103#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700104
Leo Chang0b0e45a2013-12-15 15:18:55 -0800105#ifdef FEATURE_WLAN_CH_AVOID
106/* Channle/Freqency table */
107extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
108safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
109{
110 /*CH , SAFE, default safe */
111 {1 , VOS_TRUE}, //RF_CHAN_1,
112 {2 , VOS_TRUE}, //RF_CHAN_2,
113 {3 , VOS_TRUE}, //RF_CHAN_3,
114 {4 , VOS_TRUE}, //RF_CHAN_4,
115 {5 , VOS_TRUE}, //RF_CHAN_5,
116 {6 , VOS_TRUE}, //RF_CHAN_6,
117 {7 , VOS_TRUE}, //RF_CHAN_7,
118 {8 , VOS_TRUE}, //RF_CHAN_8,
119 {9 , VOS_TRUE}, //RF_CHAN_9,
120 {10 , VOS_TRUE}, //RF_CHAN_10,
121 {11 , VOS_TRUE}, //RF_CHAN_11,
122 {12 , VOS_TRUE}, //RF_CHAN_12,
123 {13 , VOS_TRUE}, //RF_CHAN_13,
124 {14 , VOS_TRUE}, //RF_CHAN_14,
125 {240, VOS_TRUE}, //RF_CHAN_240,
126 {244, VOS_TRUE}, //RF_CHAN_244,
127 {248, VOS_TRUE}, //RF_CHAN_248,
128 {252, VOS_TRUE}, //RF_CHAN_252,
129 {208, VOS_TRUE}, //RF_CHAN_208,
130 {212, VOS_TRUE}, //RF_CHAN_212,
131 {216, VOS_TRUE}, //RF_CHAN_216,
132 {36 , VOS_TRUE}, //RF_CHAN_36,
133 {40 , VOS_TRUE}, //RF_CHAN_40,
134 {44 , VOS_TRUE}, //RF_CHAN_44,
135 {48 , VOS_TRUE}, //RF_CHAN_48,
136 {52 , VOS_TRUE}, //RF_CHAN_52,
137 {56 , VOS_TRUE}, //RF_CHAN_56,
138 {60 , VOS_TRUE}, //RF_CHAN_60,
139 {64 , VOS_TRUE}, //RF_CHAN_64,
140 {100, VOS_TRUE}, //RF_CHAN_100,
141 {104, VOS_TRUE}, //RF_CHAN_104,
142 {108, VOS_TRUE}, //RF_CHAN_108,
143 {112, VOS_TRUE}, //RF_CHAN_112,
144 {116, VOS_TRUE}, //RF_CHAN_116,
145 {120, VOS_TRUE}, //RF_CHAN_120,
146 {124, VOS_TRUE}, //RF_CHAN_124,
147 {128, VOS_TRUE}, //RF_CHAN_128,
148 {132, VOS_TRUE}, //RF_CHAN_132,
149 {136, VOS_TRUE}, //RF_CHAN_136,
150 {140, VOS_TRUE}, //RF_CHAN_140,
151 {149, VOS_TRUE}, //RF_CHAN_149,
152 {153, VOS_TRUE}, //RF_CHAN_153,
153 {157, VOS_TRUE}, //RF_CHAN_157,
154 {161, VOS_TRUE}, //RF_CHAN_161,
155 {165, VOS_TRUE}, //RF_CHAN_165,
156};
157#endif /* FEATURE_WLAN_CH_AVOID */
158
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530159/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 * Function definitions
161 *-------------------------------------------------------------------------*/
162/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530164 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 This is called in response to ifconfig up
167
168 \param - dev Pointer to net_device structure
169
170 \return - 0 for success non-zero for failure
171
172 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530173int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 ENTER();
178
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530179 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
180 {
181 //WMM_INIT OR BSS_START not completed
182 hddLog( LOGW, "Ignore hostadp open request");
183 EXIT();
184 return 0;
185 }
186
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530187 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
188 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 //Turn ON carrier state
190 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530191 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 EXIT();
196 return 0;
197}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530198
199int hdd_hostapd_open (struct net_device *dev)
200{
201 int ret;
202
203 vos_ssr_protect(__func__);
204 ret = __hdd_hostapd_open(dev);
205 vos_ssr_unprotect(__func__);
206
207 return ret;
208}
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210/**---------------------------------------------------------------------------
211
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530212 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214 This is called in response to ifconfig down
215
216 \param - dev Pointer to net_device structure
217
218 \return - 0 for success non-zero for failure
219
220 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530221int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222{
223 ENTER();
224
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530226 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530227 //Stop all tx queues
228 netif_tx_disable(dev);
229
230 //Turn OFF carrier state
231 netif_carrier_off(dev);
232 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234 EXIT();
235 return 0;
236}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530237
238int hdd_hostapd_stop (struct net_device *dev)
239{
240 int ret;
241
242 vos_ssr_protect(__func__);
243 ret = __hdd_hostapd_stop(dev);
244 vos_ssr_unprotect(__func__);
245
246 return ret;
247}
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249/**---------------------------------------------------------------------------
250
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530251 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253 This is called during the netdev unregister to uninitialize all data
254associated with the device
255
256 \param - dev Pointer to net_device structure
257
258 \return - void
259
260 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530261static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700262{
263 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530264 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 ENTER();
267
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530270 hddLog(VOS_TRACE_LEVEL_ERROR,
271 FL("Invalid magic"));
272 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530274 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
275 if (NULL == pHddCtx)
276 {
277 hddLog(VOS_TRACE_LEVEL_ERROR,
278 FL("NULL pHddCtx"));
279 return;
280 }
281
282 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
283
284 /* after uninit our adapter structure will no longer be valid */
285 pHostapdAdapter->dev = NULL;
286 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 EXIT();
289}
290
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530291static void hdd_hostapd_uninit (struct net_device *dev)
292{
293 vos_ssr_protect(__func__);
294 __hdd_hostapd_uninit(dev);
295 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530297 return;
298}
Jeff Johnson295189b2012-06-20 16:38:30 -0700299/**============================================================================
300 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
301 transmitting packets. There are 2 versions of this function. One that uses
302 locked queue and other that uses lockless queues. Both have been retained to
303 do some performance testing
304 @param skb : [in] pointer to OS packet (sk_buff)
305 @param dev : [in] pointer to Libra network device
306
307 @return : NET_XMIT_DROP if packets are dropped
308 : NET_XMIT_SUCCESS if packet is enqueued succesfully
309 ===========================================================================*/
310int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
311{
312 return 0;
313}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530314
315int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700316{
317 return 0;
318}
319
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530320int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
321{
322 int ret;
323 vos_ssr_protect(__func__);
324 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
325 vos_ssr_unprotect(__func__);
326
327 return ret;
328}
329
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700330static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
331 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700333 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530334 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
335 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530337 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700338 /*
339 * Note that valid pointers are provided by caller
340 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530342 ENTER();
343
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700344 if (priv_data->total_len <= 0 ||
345 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
346 {
347 /* below we allocate one more byte for command buffer.
348 * To avoid addition overflow total_len should be
349 * smaller than INT_MAX. */
350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
351 __func__, priv_data->total_len);
352 ret = -EFAULT;
353 goto exit;
354 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530355 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 if (0 != status)
357 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530358 return status;
359 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700361 /* Allocate +1 for '\0' */
362 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
363 if (!command)
364 {
365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
366 ret = -ENOMEM;
367 goto exit;
368 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700369
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700370 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
371 {
372 ret = -EFAULT;
373 goto exit;
374 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800375
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 /* Make sure the command is NUL-terminated */
377 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700379 hddLog(VOS_TRACE_LEVEL_INFO,
380 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700382 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
383 {
384 hdd_setP2pNoa(pAdapter->dev, command);
385 }
386 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
387 {
388 hdd_setP2pOpps(pAdapter->dev, command);
389 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800390#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700391 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
392 {
393 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
394 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800395#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700396 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
397 {
398 /*
399 * command should be a string having format
400 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
401 */
402 hddLog(VOS_TRACE_LEVEL_INFO,
403 "%s: Received Command to Set Preferred Channels for SAP",
404 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800405
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700406 ret = sapSetPreferredChannel(command);
407 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530408 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
409 {
410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
411 tANI_U8 filterType = 0;
412 tANI_U8 *value;
413 value = command + 9;
414
415 /* Convert the value from ascii to integer */
416 ret = kstrtou8(value, 10, &filterType);
417 if (ret < 0)
418 {
419 /* If the input value is greater than max value of datatype,
420 * then also kstrtou8 fails
421 */
422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
423 "%s: kstrtou8 failed range ", __func__);
424 ret = -EINVAL;
425 goto exit;
426 }
427 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
428 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
429 {
430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
431 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
432 " 2-Sink ", __func__);
433 ret = -EINVAL;
434 goto exit;
435 }
436 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
437 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530438 pScanInfo = &pHddCtx->scan_info;
439 if (filterType && pScanInfo != NULL &&
440 pHddCtx->scan_info.mScanPending)
441 {
442 /*Miracast Session started. Abort Scan */
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
444 "%s, Aborting Scan For Miracast",__func__);
445 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
446 eCSR_SCAN_ABORT_DEFAULT);
447 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530448 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
449 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
450 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530451 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
452 {
453 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
454 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456exit:
457 if (command)
458 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700459 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 return ret;
463}
464
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700465#ifdef CONFIG_COMPAT
466static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
467 struct ifreq *ifr)
468{
469 struct {
470 compat_uptr_t buf;
471 int used_len;
472 int total_len;
473 } compat_priv_data;
474 hdd_priv_data_t priv_data;
475 int ret = 0;
476
477 /*
478 * Note that pAdapter and ifr have already been verified by caller,
479 * and HDD context has also been validated
480 */
481 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
482 sizeof(compat_priv_data))) {
483 ret = -EFAULT;
484 goto exit;
485 }
486 priv_data.buf = compat_ptr(compat_priv_data.buf);
487 priv_data.used_len = compat_priv_data.used_len;
488 priv_data.total_len = compat_priv_data.total_len;
489 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
490 exit:
491 return ret;
492}
493#else /* CONFIG_COMPAT */
494static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
495 struct ifreq *ifr)
496{
497 /* will never be invoked */
498 return 0;
499}
500#endif /* CONFIG_COMPAT */
501
502static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
503{
504 hdd_priv_data_t priv_data;
505 int ret = 0;
506
507 /*
508 * Note that pAdapter and ifr have already been verified by caller,
509 * and HDD context has also been validated
510 */
511 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
512 ret = -EFAULT;
513 } else {
514 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
515 }
516 return ret;
517}
518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530519static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700520 struct ifreq *ifr, int cmd)
521{
522 hdd_adapter_t *pAdapter;
523 hdd_context_t *pHddCtx;
524 int ret;
525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530526 ENTER();
527
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
529 if (NULL == pAdapter) {
530 hddLog(VOS_TRACE_LEVEL_ERROR,
531 "%s: HDD adapter context is Null", __func__);
532 ret = -ENODEV;
533 goto exit;
534 }
535 if (dev != pAdapter->dev) {
536 hddLog(VOS_TRACE_LEVEL_ERROR,
537 "%s: HDD adapter/dev inconsistency", __func__);
538 ret = -ENODEV;
539 goto exit;
540 }
541
542 if ((!ifr) || (!ifr->ifr_data)) {
543 ret = -EINVAL;
544 goto exit;
545 }
546
547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
548 ret = wlan_hdd_validate_context(pHddCtx);
549 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700550 ret = -EBUSY;
551 goto exit;
552 }
553
554 switch (cmd) {
555 case (SIOCDEVPRIVATE + 1):
556 if (is_compat_task())
557 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
558 else
559 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
560 break;
561 default:
562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
563 __func__, cmd);
564 ret = -EINVAL;
565 break;
566 }
567 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530568 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700569 return ret;
570}
571
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530572static int hdd_hostapd_ioctl(struct net_device *dev,
573 struct ifreq *ifr, int cmd)
574{
575 int ret;
576
577 vos_ssr_protect(__func__);
578 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
579 vos_ssr_unprotect(__func__);
580
581 return ret;
582}
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584/**---------------------------------------------------------------------------
585
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530586 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 This function sets the user specified mac address using
588 the command ifconfig wlanX hw ether <mac adress>.
589
590 \param - dev - Pointer to the net device.
591 - addr - Pointer to the sockaddr.
592 \return - 0 for success, non zero for failure
593
594 --------------------------------------------------------------------------*/
595
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530596static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597{
598 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530599 hdd_adapter_t *pAdapter;
600 hdd_context_t *pHddCtx;
601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530602
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
605 if (NULL == pAdapter)
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Adapter is NULL",__func__);
609 return -EINVAL;
610 }
611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
612 ret = wlan_hdd_validate_context(pHddCtx);
613 if (0 != ret)
614 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530615 return ret;
616 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
618 EXIT();
619 return 0;
620}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530621
622static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
623{
624 int ret;
625
626 vos_ssr_protect(__func__);
627 ret = __hdd_hostapd_set_mac_address(dev, addr);
628 vos_ssr_unprotect(__func__);
629
630 return ret;
631}
632
Jeff Johnson295189b2012-06-20 16:38:30 -0700633void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
634{
635 struct net_device *dev = (struct net_device *)usrDataForCallback;
636 v_BYTE_t we_custom_event[64];
637 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530639 hdd_context_t *pHddCtx;
640#ifdef DISABLE_CONCURRENCY_AUTOSAVE
641 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hdd_ap_ctx_t *pHddApCtx;
643#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
644
645 /* event_name space-delimiter driver_module_name */
646 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
647 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
648 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
649
650 ENTER();
651
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530652 pHostapdAdapter = netdev_priv(dev);
653 if ((NULL == pHostapdAdapter) ||
654 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
655 {
656 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
657 return;
658 }
659 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
660 if (0 != (wlan_hdd_validate_context(pHddCtx)))
661 {
662 return;
663 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530664#ifdef DISABLE_CONCURRENCY_AUTOSAVE
665 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530666 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 /*
668 This timer routine is going to be called only when AP
669 persona is up.
670 If there are concurrent sessions running we do not want
671 to shut down the Bss.Instead we run the timer again so
672 that if Autosave is enabled next time and other session
673 was down only then we bring down AP
674 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
676 vos_status = vos_timer_start(
677 &pHddApCtx->hdd_ap_inactivity_timer,
678 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
679 * 1000);
680 if (!VOS_IS_STATUS_SUCCESS(vos_status))
681 {
682 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
683 }
684 EXIT();
685 return;
686 }
687#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
688 memset(&we_custom_event, '\0', sizeof(we_custom_event));
689 memcpy(&we_custom_event, autoShutEvent, event_len);
690
691 memset(&wrqu, 0, sizeof(wrqu));
692 wrqu.data.length = event_len;
693
694 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
695 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
696
697 EXIT();
698}
699
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800700VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
701{
702 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
703 ptSapContext pSapCtx = NULL;
704 eHalStatus halStatus = eHAL_STATUS_FAILURE;
705 v_PVOID_t hHal = NULL;
706
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
708 "%s: UPDATE Beacon Params", __func__);
709
710 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
711 pSapCtx = VOS_GET_SAP_CB(pVosContext);
712 if ( NULL == pSapCtx )
713 {
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
715 "%s: Invalid SAP pointer from pvosGCtx", __func__);
716 return VOS_STATUS_E_FAULT;
717 }
718
719 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
720 if ( NULL == hHal ){
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Invalid HAL pointer from pvosGCtx", __func__);
723 return VOS_STATUS_E_FAULT;
724 }
725 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
726 if(halStatus == eHAL_STATUS_FAILURE ){
727 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
728 "%s: Failed to update Beacon Params", __func__);
729 return VOS_STATUS_E_FAILURE;
730 }
731 }
732 return VOS_STATUS_SUCCESS;
733}
734
735void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
736{
737 v_U8_t staId = 0;
738 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530739 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
740 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800741
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530742 dev = (struct net_device *)usrDataForCallback;
743 pSapCtx = VOS_GET_SAP_CB(pVosContext);
744 if(pSapCtx == NULL){
745 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
746 FL("psapCtx is NULL"));
747 return;
748 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800749 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
751 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530752 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800753 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
754 {
755 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530756 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800757 }
758 }
759}
760
Agarwal Ashish8e538932014-12-24 18:12:52 +0530761static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762{
763 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530764 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800765 VOS_STATUS status = VOS_STATUS_SUCCESS;
766 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530767
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800768 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530769
770 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
771 status = wlan_hdd_validate_context(pHddCtx);
772
773 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530774 return status;
775 }
776
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800777 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
778 {
779 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
780 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800782 }
783 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530784 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800785 }
786 EXIT();
787 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
788}
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530790#ifdef SAP_AUTH_OFFLOAD
791void hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
792 bool enabled)
793{
794 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530795 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530796
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530797 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530798 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
799
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530800 sap_offload_info.sap_auth_offload_enable = enabled;
801 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530802 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530803 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530804 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
805
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530806 if (sap_offload_info.sap_auth_offload_enable &&
807 sap_offload_info.sap_auth_offload_sec_type)
808 {
809 if (sap_offload_info.key_len < 8 ||
810 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
811 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530812 hddLog(VOS_TRACE_LEVEL_ERROR,
813 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530814 sap_offload_info.key_len);
815 return;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530816 }
817 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530818 if (sap_offload_info.key_len)
819 {
820 vos_mem_copy(sap_offload_info.key,
821 pHddCtx->cfg_ini->sap_auth_offload_key,
822 sap_offload_info.key_len);
823 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530824 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530825 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
826 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530827 hddLog(VOS_TRACE_LEVEL_ERROR,
828 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530829 return;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530830 }
831
832 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
833 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530834 return;
835}
836#endif
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
839{
840 hdd_adapter_t *pHostapdAdapter;
841 hdd_ap_ctx_t *pHddApCtx;
842 hdd_hostapd_state_t *pHostapdState;
843 struct net_device *dev;
844 eSapHddEvent sapEvent;
845 union iwreq_data wrqu;
846 v_BYTE_t *we_custom_event_generic = NULL;
847 int we_event = 0;
848 int i = 0;
849 v_U8_t staId;
850 VOS_STATUS vos_status;
851 v_BOOL_t bWPSState;
852 v_BOOL_t bApActive = FALSE;
853 v_BOOL_t bAuthRequired = TRUE;
854 tpSap_AssocMacAddr pAssocStasArray = NULL;
855 char unknownSTAEvent[IW_CUSTOM_MAX+1];
856 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
857 v_BYTE_t we_custom_start_event[64];
858 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800859 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800860 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700861 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530862 v_CONTEXT_t pVosContext = NULL;
863 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +0530864 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
866 dev = (struct net_device *)usrDataForCallback;
867 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530868
869 if ((NULL == pHostapdAdapter) ||
870 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
871 {
872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
873 "invalid adapter or adapter has invalid magic");
874 return eHAL_STATUS_FAILURE;
875 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530876 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
877 pSapCtx = VOS_GET_SAP_CB(pVosContext);
878 if(pSapCtx == NULL){
879 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
880 FL("psapCtx is NULL"));
881 return eHAL_STATUS_FAILURE;
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
884 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
885 sapEvent = pSapEvent->sapHddEventCode;
886 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800887 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +0530888 cfg_param = pHddCtx->cfg_ini;
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890
891 switch(sapEvent)
892 {
893 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800894 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
896 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
897 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
898
899 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
900 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +0530901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +0530903 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 goto stopbss;
906 }
907 else
Deepthi Gowried085092015-10-20 19:30:52 +0530908 {
909 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
910 {
911 if ((cfg_param->dynSplitscan) &&
912 (!pHddCtx->issplitscan_enabled))
913 {
914 pHddCtx->issplitscan_enabled = TRUE;
915 sme_enable_disable_split_scan(
916 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
917 cfg_param->nNumStaChanCombinedConc,
918 cfg_param->nNumP2PChanCombinedConc);
919 }
920 }
921
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
923 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530924 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
925 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530926 {
c_hpothuffdb5272013-10-02 16:42:35 +0530927 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530928 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 }
Deepthi Gowried085092015-10-20 19:30:52 +0530931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
933 {
934 // AP Inactivity timer init and start
935 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
936 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
937 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800938 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939
940 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
941 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800942 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 }
945 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
946 pHostapdState->bssState = BSS_START;
947
948 // Send current operating channel of SoftAP to BTC-ES
949 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 //Check if there is any group key pending to set.
952 if( pHddApCtx->groupKey.keyLength )
953 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700954 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
956 &pHddApCtx->groupKey ) )
957 {
958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 "%s: WLANSAP_SetKeySta failed", __func__);
960 }
961 pHddApCtx->groupKey.keyLength = 0;
962 }
963 else if ( pHddApCtx->wepKey[0].keyLength )
964 {
965 int i=0;
966 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
967 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700968 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
970 &pHddApCtx->wepKey[i] ) )
971 {
972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
973 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
974 }
975 pHddApCtx->wepKey[i].keyLength = 0;
976 }
977 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
979 startBssEvent = "SOFTAP.enabled";
980 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
981 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
982 memset(&wrqu, 0, sizeof(wrqu));
983 wrqu.data.length = strlen(startBssEvent);
984 we_event = IWEVCUSTOM;
985 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700986 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 break; //Event will be sent after Switch-Case stmt
988
989 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800990 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
992
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530993#ifdef SAP_AUTH_OFFLOAD
994 if (cfg_param->enable_sap_auth_offload)
995 hdd_set_sap_auth_offload(pHostapdAdapter, FALSE);
996#endif
997
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700998 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700999 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001000
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301002
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301003 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301004 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301005 hddLog(LOG1,
1006 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1007 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301008 }
1009
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 goto stopbss;
1011 case eSAP_STA_SET_KEY_EVENT:
1012 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001013 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1015 return VOS_STATUS_SUCCESS;
1016 case eSAP_STA_DEL_KEY_EVENT:
1017 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001018 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 return VOS_STATUS_SUCCESS;
1020 case eSAP_STA_MIC_FAILURE_EVENT:
1021 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 memset(&msg, '\0', sizeof(msg));
1023 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001024 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001025 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001026 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 msg.flags = IW_MICFAILURE_GROUP;
1028 else
1029 msg.flags = IW_MICFAILURE_PAIRWISE;
1030 memset(&wrqu, 0, sizeof(wrqu));
1031 wrqu.data.length = sizeof(msg);
1032 we_event = IWEVMICHAELMICFAILURE;
1033 we_custom_event_generic = (v_BYTE_t *)&msg;
1034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 /* inform mic failure to nl80211 */
1036 cfg80211_michael_mic_failure(dev,
1037 pSapEvent->sapevt.
1038 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001039 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 NL80211_KEYTYPE_GROUP :
1041 NL80211_KEYTYPE_PAIRWISE),
1042 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1043 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1044 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 break;
1046
1047 case eSAP_STA_ASSOC_EVENT:
1048 case eSAP_STA_REASSOC_EVENT:
1049 wrqu.addr.sa_family = ARPHRD_ETHER;
1050 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001051 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001052 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 we_event = IWEVREGISTERED;
1054
1055 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1056
1057 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1058 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1059 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1060 {
1061 bAuthRequired = FALSE;
1062 }
1063
1064 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
1065 {
c_hpothuffdb5272013-10-02 16:42:35 +05301066 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 TRUE,
1068 pHddApCtx->uPrivacy,
1069 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1070 0,
1071 0,
1072 (v_MACADDR_t *)wrqu.addr.sa_data,
1073 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301074
1075 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1076 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1077 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 }
1079 else
1080 {
c_hpothuffdb5272013-10-02 16:42:35 +05301081 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 FALSE,
1083 pHddApCtx->uPrivacy,
1084 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1085 0,
1086 0,
1087 (v_MACADDR_t *)wrqu.addr.sa_data,
1088 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301089 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1090 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1091 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001092 }
1093
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301094 staId =
1095 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1096 if (VOS_IS_STATUS_SUCCESS(vos_status))
1097 {
1098
1099 pSapCtx->aStaInfo[staId].rate_flags =
1100 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1101 }
1102
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 // Stop AP inactivity timer
1104 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1105 {
1106 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1107 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001108 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001110#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001111 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1112 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301113 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1114 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001115 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301116 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1117 HDD_SAP_WAKE_LOCK_DURATION,
1118 WIFI_POWER_EVENT_WAKELOCK_SAP);
1119
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001120#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001121#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1122 {
1123 struct station_info staInfo;
1124 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1125
1126 memset(&staInfo, 0, sizeof(staInfo));
1127 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1128 {
1129 staInfo.assoc_req_ies =
1130 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
1131 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001132#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001133 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
1134#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 cfg80211_new_sta(dev,
1136 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
1137 &staInfo, GFP_KERNEL);
1138 }
1139 else
1140 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001141 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 }
1143 }
1144#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301145 hdd_manage_delack_timer(pHddCtx);
1146
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001147 pScanInfo = &pHddCtx->scan_info;
1148 // Lets do abort scan to ensure smooth authentication for client
1149 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1150 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301151 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301152 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
1155 break;
1156 case eSAP_STA_DISASSOC_EVENT:
1157 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001158 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001159 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1161 hddLog(LOG1," User initiated disassociation");
1162 else
1163 hddLog(LOG1," MAC initiated disassociation");
1164 we_event = IWEVEXPIRED;
1165 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1166 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1167 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001168 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 -07001169 return VOS_STATUS_E_FAILURE;
1170 }
1171 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1172
1173 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1174 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301175 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 // Start AP inactivity timer if no stations associated with it
1177 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1178 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301179 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 {
1181 bApActive = TRUE;
1182 break;
1183 }
1184 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301185 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001186
1187 if (bApActive == FALSE)
1188 {
1189 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1190 {
1191 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1192 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001193 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 }
1195 else
1196 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1197 }
1198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001199#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1200 cfg80211_del_sta(dev,
1201 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1202 GFP_KERNEL);
1203#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001204 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301205 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1206 if (VOS_STATUS_SUCCESS != vos_status)
1207 {
1208 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1209 __func__, vos_status);
1210 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301211 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 break;
1213 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1214 {
1215 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1216 union iwreq_data wreq;
1217
1218 down(&pHddApCtx->semWpsPBCOverlapInd);
1219 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1220
1221 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1222 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1223
1224 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001225 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 memset(&wreq, 0, sizeof(wreq));
1227 wreq.data.length = strlen(message); // This is length of message
1228 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1229
1230 return VOS_STATUS_SUCCESS;
1231 }
1232 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1233 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1234 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1235 { // List of associated stations
1236 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1237 {
1238 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1239 i+1,
1240 pAssocStasArray->assocId,
1241 pAssocStasArray->staId,
1242 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1243 pAssocStasArray++;
1244 }
1245 }
1246 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001247 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 case eSAP_REMAIN_CHAN_READY:
1250 hdd_remainChanReadyHandler( pHostapdAdapter );
1251 return VOS_STATUS_SUCCESS;
1252 case eSAP_SEND_ACTION_CNF:
1253 hdd_sendActionCnf( pHostapdAdapter,
1254 ( eSAP_STATUS_SUCCESS ==
1255 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1256 TRUE : FALSE );
1257 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 case eSAP_UNKNOWN_STA_JOIN:
1259 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1260 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1261 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1262 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1263 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1264 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1265 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1266 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1267 wrqu.data.pointer = unknownSTAEvent;
1268 wrqu.data.length = strlen(unknownSTAEvent);
1269 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301270 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 break;
1272
1273 case eSAP_MAX_ASSOC_EXCEEDED:
1274 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1275 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1276 " one or more devices to enable the new device connection",
1277 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1278 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1279 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1280 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1281 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1282 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1283 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1284 wrqu.data.pointer = maxAssocExceededEvent;
1285 wrqu.data.length = strlen(maxAssocExceededEvent);
1286 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001287 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 break;
1289 case eSAP_STA_ASSOC_IND:
1290 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001291
1292 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001293 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001294 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1295 return VOS_STATUS_SUCCESS;
1296
1297 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301298 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301299 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1300 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301301 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301302 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001303 return VOS_STATUS_SUCCESS;
1304
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001306 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 goto stopbss;
1308 return VOS_STATUS_SUCCESS;
1309 }
1310 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1311 return VOS_STATUS_SUCCESS;
1312
1313stopbss :
1314 {
1315 v_BYTE_t we_custom_event[64];
1316 char *stopBssEvent = "STOP-BSS.response";//17
1317 int event_len = strlen(stopBssEvent);
1318
1319 hddLog(LOG1, FL("BSS stop status = %s"),
1320 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1321 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1322
1323 /* Change the BSS state now since, as we are shutting things down,
1324 * we don't want interfaces to become re-enabled */
1325 pHostapdState->bssState = BSS_STOP;
1326
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301327 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1328 {
1329 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1330 {
1331 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1332 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1333 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1334 }
1335
1336 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1337 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1338 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1339 }
1340
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 /* Stop the pkts from n/w stack as we are going to free all of
1342 * the TX WMM queues for all STAID's */
1343 hdd_hostapd_stop(dev);
1344
1345 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301346 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1347 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1348 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001349
Amar Singhal37e6f052013-03-05 16:16:54 -08001350 /* once the event is set, structure dev/pHostapdAdapter should
1351 * not be touched since they are now subject to being deleted
1352 * by another thread */
1353 if (eSAP_STOP_BSS_EVENT == sapEvent)
1354 vos_event_set(&pHostapdState->vosEvent);
1355
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 /* notify userspace that the BSS has stopped */
1357 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1358 memcpy(&we_custom_event, stopBssEvent, event_len);
1359 memset(&wrqu, 0, sizeof(wrqu));
1360 wrqu.data.length = event_len;
1361 we_event = IWEVCUSTOM;
1362 we_custom_event_generic = we_custom_event;
1363 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001364 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001365 }
1366 return VOS_STATUS_SUCCESS;
1367}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001368
1369int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001371 eCsrEncryptionType *pEncryptType,
1372 eCsrEncryptionType *mcEncryptType,
1373 eCsrAuthType *pAuthType,
1374 v_BOOL_t *pMFPCapable,
1375 v_BOOL_t *pMFPRequired,
1376 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 u_int8_t *gen_ie )
1378{
1379 tDot11fIERSN dot11RSNIE;
1380 tDot11fIEWPA dot11WPAIE;
1381
1382 tANI_U8 *pRsnIe;
1383 tANI_U16 RSNIeLen;
1384
1385 if (NULL == halHandle)
1386 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001387 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 return -EINVAL;
1389 }
1390
1391 // Validity checks
1392 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1393 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1394 return -EINVAL;
1395 // Type check
1396 if ( gen_ie[0] == DOT11F_EID_RSN)
1397 {
1398 // Validity checks
1399 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1400 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1401 {
1402 return VOS_STATUS_E_FAILURE;
1403 }
1404 // Skip past the EID byte and length byte
1405 pRsnIe = gen_ie + 2;
1406 RSNIeLen = gen_ie_len - 2;
1407 // Unpack the RSN IE
1408 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1409 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1410 pRsnIe,
1411 RSNIeLen,
1412 &dot11RSNIE);
1413 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001414 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001415 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001416 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001417 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 /*Here we have followed the apple base code,
1419 but probably I suspect we can do something different*/
1420 //dot11RSNIE.akm_suite_count
1421 // Just translate the FIRST one
1422 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1423 //dot11RSNIE.pwise_cipher_suite_count
1424 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1425 //dot11RSNIE.gp_cipher_suite_count
1426 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1427 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001428 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1429 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001430
1431 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1432 } else
1433 if (gen_ie[0] == DOT11F_EID_WPA)
1434 {
1435 // Validity checks
1436 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1437 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1438 {
1439 return VOS_STATUS_E_FAILURE;
1440 }
1441 // Skip past the EID byte and length byte - and four byte WiFi OUI
1442 pRsnIe = gen_ie + 2 + 4;
1443 RSNIeLen = gen_ie_len - (2 + 4);
1444 // Unpack the WPA IE
1445 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1446 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1447 pRsnIe,
1448 RSNIeLen,
1449 &dot11WPAIE);
1450 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001451 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001452 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001453 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001454 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 //dot11WPAIE.auth_suite_count
1456 // Just translate the FIRST one
1457 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1458 //dot11WPAIE.unicast_cipher_count
1459 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1460 //dot11WPAIE.unicast_cipher_count
1461 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001462 *pMFPCapable = VOS_FALSE;
1463 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 }
1465 else
1466 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001467 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 return VOS_STATUS_E_FAILURE;
1469 }
1470 return VOS_STATUS_SUCCESS;
1471}
Leo Chang614d2072013-08-22 14:59:44 -07001472
Leo Chang0b0e45a2013-12-15 15:18:55 -08001473#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001474
1475/*==========================================================================
1476 FUNCTION sapUpdateUnsafeChannelList
1477
1478 DESCRIPTION
1479 Function Undate unsafe channel list table
1480
1481 DEPENDENCIES
1482 NA.
1483
1484 PARAMETERS
1485
1486 IN
1487 pSapCtx : SAP context pointer, include unsafe channel list
1488
1489 RETURN VALUE
1490 NONE
1491============================================================================*/
1492void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1493 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1494{
1495 v_U16_t i, j;
1496
1497 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1498 sizeof(pHddCtx->unsafeChannelList));
1499 if (0 == unsafeChannelCount)
1500 {
1501 pHddCtx->unsafeChannelCount = 0;
1502 }
1503 else
1504 {
c_hpothu8de53e42014-08-22 15:00:37 +05301505 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1506 {
1507 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1508 FL("unsafeChannelCount%hd greater than %d"),
1509 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1510 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1511 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001512 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1513 unsafeChannelList,
1514 unsafeChannelCount * sizeof(tANI_U16));
1515 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1516 }
1517
1518 /* Flush, default set all channel safe */
1519 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1520 {
1521 safeChannels[i].isSafe = VOS_TRUE;
1522 }
1523
1524 /* Try to find unsafe channel */
1525 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1526 {
1527 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1528 {
1529 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1530 {
1531 /* Found unsafe channel, update it */
1532 safeChannels[j].isSafe = VOS_FALSE;
1533 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1534 "%s : CH %d is not safe",
1535 __func__, pHddCtx->unsafeChannelList[i]);
1536 break;
1537 }
1538 }
1539 }
1540
1541 return;
1542}
1543
1544/**---------------------------------------------------------------------------
1545
1546 \brief hdd_hostapd_ch_avoid_cb() -
1547
1548 Avoid channel notification from FW handler.
1549 FW will send un-safe channle list to avoid overwrapping.
1550 hostapd should not use notified channel
1551
1552 \param - pAdapter HDD adapter pointer
1553 indParam channel avoid notification parameter
1554
1555 \return - None
1556
1557 --------------------------------------------------------------------------*/
1558void hdd_hostapd_ch_avoid_cb
1559(
1560 void *pAdapter,
1561 void *indParam
1562)
1563{
1564 hdd_adapter_t *pHostapdAdapter = NULL;
1565 hdd_context_t *hddCtxt;
1566 tSirChAvoidIndType *chAvoidInd;
1567 v_U8_t rangeLoop;
1568 v_U16_t channelLoop;
1569 v_U16_t dupCheck;
1570 v_U16_t startChannel;
1571 v_U16_t endChannel;
1572 v_U16_t unsafeChannelCount = 0;
1573 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1574 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001575 tHddAvoidFreqList hddAvoidFreqList;
1576 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301577#ifdef WLAN_FEATURE_AP_HT40_24G
1578 ptSapContext pSapCtx = NULL;
1579 tHalHandle hHal;
1580 v_U8_t cbMode;
1581 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1582 v_U32_t delay;
1583#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001584
1585 /* Basic sanity */
1586 if ((NULL == pAdapter) || (NULL == indParam))
1587 {
1588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1589 "%s : Invalid arguments", __func__);
1590 return;
1591 }
1592
1593 hddCtxt = (hdd_context_t *)pAdapter;
1594 chAvoidInd = (tSirChAvoidIndType *)indParam;
1595 pVosContext = hddCtxt->pvosContext;
1596
1597 /* Make unsafe channel list */
1598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1599 "%s : band count %d",
1600 __func__, chAvoidInd->avoidRangeCount);
1601 vos_mem_zero((void *)unsafeChannelList,
1602 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1603 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1604 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301605 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1606 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1607 break;
1608 }
1609 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001610 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301611 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001612 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1614 "%s : start %d : %d, end %d : %d",
1615 __func__,
1616 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1617 startChannel,
1618 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1619 endChannel);
1620 for (channelLoop = startChannel;
1621 channelLoop < (endChannel + 1);
1622 channelLoop++)
1623 {
1624 /* Channel duplicate check routine */
1625 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1626 {
1627 if (unsafeChannelList[dupCheck] == channelLoop)
1628 {
1629 /* This channel is duplicated */
1630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1631 "%s : found duplicated channel %d",
1632 __func__, channelLoop);
1633 break;
1634 }
1635 }
1636 if (dupCheck == unsafeChannelCount)
1637 {
c_hpothu8de53e42014-08-22 15:00:37 +05301638 int ii;
1639 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1640 {
1641 if (channelLoop == safeChannels[ii].channelNumber)
1642 {
1643 unsafeChannelList[unsafeChannelCount] = channelLoop;
1644 unsafeChannelCount++;
1645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1646 "%s : unsafe channel %d, count %d",
1647 __func__,
1648 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301649 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1650 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1651 break;
1652 }
c_hpothu8de53e42014-08-22 15:00:37 +05301653 }
1654 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001655 }
1656 else
1657 {
1658 /* DUP, do nothing */
1659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1660 "%s : duplicated channel %d",
1661 __func__, channelLoop);
1662 }
1663 }
1664 }
1665 /* Update unsafe channel cache
1666 * WCN Platform Driver cache */
1667 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1668 unsafeChannelCount);
1669
1670 /* Store into local cache
1671 * Start with STA and later start SAP
1672 * in this scenario, local cache will be used */
1673 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1674 unsafeChannelList,
1675 unsafeChannelCount);
1676
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001677 /* generate vendor specific event */
1678 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1679 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1680 {
1681 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1682 chAvoidInd->avoidFreqRange[i].startFreq;
1683 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1684 chAvoidInd->avoidFreqRange[i].endFreq;
1685 }
1686 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1687
1688 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1689
Leo Chang0b0e45a2013-12-15 15:18:55 -08001690 /* Get SAP context first
1691 * SAP and P2PGO would not concurrent */
1692 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301693#ifdef WLAN_FEATURE_AP_HT40_24G
1694 if (NULL == pHostapdAdapter)
1695 {
1696 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1697 }
1698#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301699 if ((pHostapdAdapter) &&
1700 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1701 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001702 {
1703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1704 "%s : Current operation channel %d",
1705 __func__,
1706 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1707 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1708 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301709 if ((unsafeChannelList[channelLoop] ==
1710 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1711 {
1712 if ((AUTO_CHANNEL_SELECT ==
1713 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1714 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1715 {
1716 /* current operating channel is un-safe channel
1717 * restart driver */
1718 hdd_hostapd_stop(pHostapdAdapter->dev);
1719 /* On LE, this event is handled by wlan-services to
1720 * restart SAP. On android, this event would be
1721 * ignored.
1722 */
1723 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1724 NULL, 0);
1725 }
1726 return;
1727 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001728 }
1729 }
1730
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301731#ifdef WLAN_FEATURE_AP_HT40_24G
1732 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1733 {
1734 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1735
1736 if(pSapCtx == NULL)
1737 {
1738 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1739 FL("psapCtx is NULL"));
1740 return;
1741 }
1742
1743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1744 FL("SAP Secondary channel: %d "),
1745 pSapCtx->sap_sec_chan);
1746
1747 /* tHalHandle */
1748 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1749
1750 if (NULL == hHal)
1751 {
1752 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1753 FL("In invalid hHal"));
1754 return;
1755 }
1756
1757 cbMode = sme_GetChannelBondingMode24G(hHal);
1758
1759 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1760 FL("Selected Channel bonding : %d"), cbMode);
1761
1762 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1763 {
1764 int i;
1765 eHalStatus halStatus;
1766
1767 for (i = 0; i < unsafeChannelCount; i++)
1768 {
1769 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1770 {
1771 /* Current SAP Secondary channel is un-safe channel */
1772 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1773 FL("Move SAP from HT40 to HT20"));
1774
1775 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1776 PHY_SINGLE_CHANNEL_CENTERED);
1777
1778 if (halStatus == eHAL_STATUS_FAILURE)
1779 {
1780 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1781 FL("Failed to change HT20/40 mode"));
1782 return;
1783 }
1784
1785 /* Disable Channel Bonding for 2.4GHz */
1786 sme_UpdateChannelBondingMode24G(hHal,
1787 PHY_SINGLE_CHANNEL_CENTERED);
1788 return;
1789 }
1790 }
1791 }
1792
1793 if ((!pSapCtx->numHT40IntoSta)
1794 && (pHostapdAdapter)
1795 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1796 {
1797 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1798 * are Safe then start HT20/40 timer to Move SAP from HT20
1799 * to HT40.
1800 */
1801 if (((!unsafeChannelCount)
1802 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1803 {
1804 /* Stop Previous Running HT20/40 Timer & Start timer
1805 with (OBSS TransitionDelayFactor * obss interval)
1806 delay after time out move AP from HT20 -> HT40
1807 mode
1808 */
1809 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1810 {
1811 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1812 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1813 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1814 FL("Failed to Stop HT20/40 timer"));
1815 }
1816
1817 delay =
1818 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1819
1820 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1821 FL("Start HT20/40 transition timer (%d sec)"), delay);
1822
1823 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1824 (delay * 1000));
1825
1826 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1827 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1828 FL("Failed to Start HT20/40 timer"));
1829 }
1830 else
1831 {
1832 /* Stop HT20/40 Timer */
1833 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1834 {
1835 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1836 FL("Stop HT20/40 transition timer"));
1837 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1838 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1839 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1840 FL("Failed to Stop HT20/40 timer"));
1841 }
1842 }
1843 }
1844 }
1845#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001846 return;
1847}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001848#endif /* FEATURE_WLAN_CH_AVOID */
1849
Jeff Johnson295189b2012-06-20 16:38:30 -07001850int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301851static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 struct iw_request_info *info,
1853 union iwreq_data *wrqu, char *extra)
1854{
1855 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001856 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301857 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 int *value = (int *)extra;
1859 int sub_cmd = value[0];
1860 int set_value = value[1];
1861 eHalStatus status;
1862 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05301863 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001864 v_CONTEXT_t pVosContext;
1865
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301866 ENTER();
1867
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301868 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001869 {
1870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301871 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001872 __func__);
1873 return -1;
1874 }
1875
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301876 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1877 ret = wlan_hdd_validate_context(pHddCtx);
1878 if (0 != ret)
1879 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301880 return -1;
1881 }
1882
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001883 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1884 if (!hHal)
1885 {
1886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1887 "%s: Hal ctx is null", __func__);
1888 return -1;
1889 }
1890
1891 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1892 if (!pVosContext)
1893 {
1894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1895 "%s: Vos ctx is null", __func__);
1896 return -1;
1897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
1899 switch(sub_cmd)
1900 {
1901
1902 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001903 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301905 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 }
1907 break;
1908
1909 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301910 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1912 {
1913 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1914 ret = -EINVAL;
1915 }
1916 else
1917 {
1918 WLANSAP_SetMode(pVosContext, set_value);
1919 }
1920 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301921
1922 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1923 if ((0 != set_value) && (1 != set_value))
1924 {
1925 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1926 ret = -EINVAL;
1927 }
1928 else
1929 {
1930 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
1931 }
1932 break;
1933
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 case QCSAP_PARAM_MAX_ASSOC:
1935 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1936 {
1937 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1938 ret = -EINVAL;
1939 }
1940 else
1941 {
1942 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1943 {
1944 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1945 "Setting it to max allowed and continuing"),
1946 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1947 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1948 }
1949 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1950 set_value, NULL, eANI_BOOLEAN_FALSE);
1951 if ( status != eHAL_STATUS_SUCCESS )
1952 {
1953 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1954 status);
1955 ret = -EIO;
1956 }
1957 }
1958 break;
1959
1960 case QCSAP_PARAM_HIDE_SSID:
1961 {
1962 eHalStatus status = eHAL_STATUS_SUCCESS;
1963 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1964 if(eHAL_STATUS_SUCCESS != status)
1965 {
1966 hddLog(VOS_TRACE_LEVEL_ERROR,
1967 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001968 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 return status;
1970 }
1971 break;
1972 }
1973
Leo Chang614d2072013-08-22 14:59:44 -07001974 case QCSAP_PARAM_SET_MC_RATE:
1975 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001976 tSirRateUpdateInd *rateUpdate;
1977
1978 rateUpdate = (tSirRateUpdateInd *)
1979 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1980 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001981 {
1982 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001983 "%s: SET_MC_RATE indication alloc fail", __func__);
1984 ret = -1;
1985 break;
1986 }
1987 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1988
1989 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1990 /* Ignore unicast */
1991 rateUpdate->ucastDataRate = -1;
1992 rateUpdate->mcastDataRate24GHz = set_value;
1993 rateUpdate->mcastDataRate5GHz = set_value;
1994 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1995 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1996 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1997 if (eHAL_STATUS_SUCCESS != status)
1998 {
1999 hddLog(VOS_TRACE_LEVEL_ERROR,
2000 "%s: SET_MC_RATE failed", __func__);
2001 vos_mem_free(rateUpdate);
2002 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002003 }
2004 break;
2005 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302006 case QCSAP_PARAM_GET_FRAME_LOGS:
2007 {
2008 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2009 != VOS_STATUS_SUCCESS)
2010 {
2011 ret = -EINVAL;
2012 }
2013 break;
2014 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302015 case QCSAP_PARAM_SET_PROXIMITY:
2016 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302017 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302018 break;
2019 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302020 case QCSAP_PARAM_SET_WOWL:
2021 {
2022 if (!pHddCtx->is_ap_mode_wow_supported)
2023 {
2024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2025 "%s: Not supported",__func__);
2026 return -ENOTSUPP;
2027 }
2028 switch (set_value)
2029 {
2030 case 0x00:
2031 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2032 break;
2033 case 0x01:
2034 case 0x02:
2035 case 0x03:
2036 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2037 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2038 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2039 (enable_magic_pkt ? "YES":"NO"),
2040 (enable_pattrn_byte_match ? "YES":"NO"));
2041 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2042 enable_pattrn_byte_match);
2043 break;
2044 default:
2045 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2046 ret = -EINVAL;
2047 break;
2048 }
2049 break;
2050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 default:
2052 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2053 sub_cmd, set_value);
2054 ret = -EINVAL;
2055 break;
2056 }
2057
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302058 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 return ret;
2060}
2061
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302062int
2063static iw_softap_setparam(struct net_device *dev,
2064 struct iw_request_info *info,
2065 union iwreq_data *wrqu, char *extra)
2066{
2067 int ret;
2068
2069 vos_ssr_protect(__func__);
2070 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2071 vos_ssr_unprotect(__func__);
2072
2073 return ret;
2074}
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
2076int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302077static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 struct iw_request_info *info,
2079 union iwreq_data *wrqu, char *extra)
2080{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302081 hdd_adapter_t *pHostapdAdapter;
2082 tHalHandle hHal;
2083 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 int *value = (int *)extra;
2085 int sub_cmd = value[0];
2086 eHalStatus status;
2087 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302088 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002089
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302090 ENTER();
2091
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302092 pHostapdAdapter = (netdev_priv(dev));
2093 if (NULL == pHostapdAdapter)
2094 {
2095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2096 "%s: Adapter is NULL",__func__);
2097 return -EINVAL;
2098 }
2099 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2100 ret = wlan_hdd_validate_context(pHddCtx);
2101 if (0 != ret)
2102 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302103 return ret;
2104 }
2105 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2106 if (NULL == hHal)
2107 {
2108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2109 "%s: Hal Context is NULL",__func__);
2110 return -EINVAL;
2111 }
2112 pVosContext = pHddCtx->pvosContext;
2113 if (NULL == pVosContext)
2114 {
2115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2116 "%s: pVosContext Context is NULL",__func__);
2117 return -EINVAL;
2118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 switch (sub_cmd)
2120 {
2121 case QCSAP_PARAM_MAX_ASSOC:
2122 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2123 if (eHAL_STATUS_SUCCESS != status)
2124 {
c_hpothuffdb5272013-10-02 16:42:35 +05302125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2126 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 ret = -EIO;
2128 }
Girish Gowli385be612014-09-18 11:17:20 +05302129
2130#ifdef WLAN_SOFTAP_VSTA_FEATURE
2131 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2132 {
2133 if (*value > VSTA_NUM_ASSOC_STA)
2134 {
2135 *value = VSTA_NUM_ASSOC_STA;
2136 }
2137 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2138 (*value > (VSTA_NUM_ASSOC_STA -
2139 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2140 {
2141 *value = (VSTA_NUM_ASSOC_STA -
2142 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2143 }
2144 }
2145 else
2146#endif
2147 {
2148 if (*value > NUM_ASSOC_STA)
2149 {
2150 *value = NUM_ASSOC_STA;
2151 }
2152 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2153 (*value > (NUM_ASSOC_STA -
2154 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2155 {
2156 *value = (NUM_ASSOC_STA -
2157 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2158 }
2159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002163 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 {
c_hpothuffdb5272013-10-02 16:42:35 +05302165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2166 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302167 ret = -EIO;
2168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 *value = 0;
2170 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302171
Jeff Johnson43971f52012-07-17 12:26:56 -07002172 case QCSAP_PARAM_GET_WLAN_DBG:
2173 {
2174 vos_trace_display();
2175 *value = 0;
2176 break;
2177 }
2178
2179 case QCSAP_PARAM_AUTO_CHANNEL:
2180 {
2181 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2182 break;
2183 }
2184
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 default:
2186 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2187 ret = -EINVAL;
2188 break;
2189
2190 }
2191
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302192 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 return ret;
2194}
2195
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302196int
2197static iw_softap_getparam(struct net_device *dev,
2198 struct iw_request_info *info,
2199 union iwreq_data *wrqu, char *extra)
2200{
2201 int ret;
2202
2203 vos_ssr_protect(__func__);
2204 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2205 vos_ssr_unprotect(__func__);
2206
2207 return ret;
2208}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302209
2210int
2211static __iw_softap_setchar_getnone(struct net_device *dev,
2212 struct iw_request_info *info,
2213 union iwreq_data *wrqu, char *extra)
2214{
2215 int sub_cmd;
2216 int ret = 0; /* success */
2217 char *pBuffer = NULL;
2218 hdd_adapter_t *pAdapter;
2219 hdd_context_t *pHddCtx;
2220 struct iw_point s_priv_data;
2221
2222 ENTER();
2223
2224 if (!capable(CAP_NET_ADMIN))
2225 {
2226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2227 FL("permission check failed"));
2228 return -EPERM;
2229 }
2230
2231 pAdapter = (netdev_priv(dev));
2232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2233 ret = wlan_hdd_validate_context(pHddCtx);
2234 if (0 != ret)
2235 {
2236 return ret;
2237 }
2238
2239 if (!pHddCtx->is_ap_mode_wow_supported)
2240 {
2241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2242 "%s: Not supported",__func__);
2243 return -ENOTSUPP;
2244 }
2245
2246 /* helper function to get iwreq_data with compat handling. */
2247 if (hdd_priv_get_data(&s_priv_data, wrqu))
2248 {
2249 return -EINVAL;
2250 }
2251
2252 /* make sure all params are correctly passed to function */
2253 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2254 {
2255 return -EINVAL;
2256 }
2257
2258 sub_cmd = s_priv_data.flags;
2259
2260 /* ODD number is used for set, copy data using copy_from_user */
2261 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2262 s_priv_data.length);
2263 if (NULL == pBuffer)
2264 {
2265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2266 "mem_alloc_copy_from_user_helper fail");
2267 return -ENOMEM;
2268 }
2269
2270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2271 "%s: Received length %d", __func__, s_priv_data.length);
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2273 "%s: Received data %s", __func__, pBuffer);
2274
2275 switch(sub_cmd)
2276 {
2277 case WE_WOWL_ADD_PTRN:
2278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2279 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2280 if (!ret)
2281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2282 "Failed to add pattern :%d", ret);
2283 break;
2284 case WE_WOWL_DEL_PTRN:
2285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2286 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2287 if (!ret)
2288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2289 "Failed to del pattern :%d", ret);
2290 break;
2291 default:
2292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2293 ret = -EINVAL;
2294 break;
2295 }
2296
2297 kfree(pBuffer);
2298 return ret;
2299}
2300
2301int
2302static iw_softap_setchar_getnone(struct net_device *dev,
2303 struct iw_request_info *info,
2304 union iwreq_data *wrqu, char *extra)
2305{
2306 int ret;
2307
2308 vos_ssr_protect(__func__);
2309 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2310 vos_ssr_unprotect(__func__);
2311
2312 return ret;
2313}
2314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315/* Usage:
2316 BLACK_LIST = 0
2317 WHITE_LIST = 1
2318 ADD MAC = 0
2319 REMOVE MAC = 1
2320
2321 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2322 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2323 while using this ioctl
2324
2325 Syntax:
2326 iwpriv softap.0 modify_acl
2327 <6 octet mac addr> <list type> <cmd type>
2328
2329 Examples:
2330 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2331 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2332 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2333 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2334*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302335int __iw_softap_modify_acl(struct net_device *dev,
2336 struct iw_request_info *info,
2337 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002338{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302339 hdd_adapter_t *pHostapdAdapter;
2340 v_CONTEXT_t pVosContext;
2341 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 v_BYTE_t *value = (v_BYTE_t*)extra;
2343 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2344 int listType, cmd, i;
2345 int ret = 0; /* success */
2346
2347 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302348 pHostapdAdapter = (netdev_priv(dev));
2349 if (NULL == pHostapdAdapter)
2350 {
2351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2352 "%s: Adapter is NULL",__func__);
2353 return -EINVAL;
2354 }
2355 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2356 ret = wlan_hdd_validate_context(pHddCtx);
2357 if (0 != ret)
2358 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302359 return ret;
2360 }
2361 pVosContext = pHddCtx->pvosContext;
2362 if (NULL == pVosContext)
2363 {
2364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2365 "%s: Vos Context is NULL",__func__);
2366 return -EINVAL;
2367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2369 {
2370 pPeerStaMac[i] = *(value+i);
2371 }
2372 listType = (int)(*(value+i));
2373 i++;
2374 cmd = (int)(*(value+i));
2375
Arif Hussain24bafea2013-11-15 15:10:03 -08002376 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2377 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
2379 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2380 != VOS_STATUS_SUCCESS)
2381 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002382 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 ret = -EIO;
2384 }
2385 EXIT();
2386 return ret;
2387}
2388
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302389int iw_softap_modify_acl(struct net_device *dev,
2390 struct iw_request_info *info,
2391 union iwreq_data *wrqu, char *extra)
2392{
2393 int ret;
2394
2395 vos_ssr_protect(__func__);
2396 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2397 vos_ssr_unprotect(__func__);
2398
2399 return ret;
2400}
2401
Jeff Johnson295189b2012-06-20 16:38:30 -07002402int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302403static __iw_softap_getchannel(struct net_device *dev,
2404 struct iw_request_info *info,
2405 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002406{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302407 hdd_adapter_t *pHostapdAdapter;
2408 hdd_context_t *pHddCtx;
2409 int ret = 0;
2410 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302411
2412 ENTER();
2413
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302414 pHostapdAdapter = (netdev_priv(dev));
2415 if (NULL == pHostapdAdapter)
2416 {
2417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2418 "%s: Adapter is NULL",__func__);
2419 return -EINVAL;
2420 }
2421 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2422 ret = wlan_hdd_validate_context(pHddCtx);
2423 if (0 != ret)
2424 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302425 return ret;
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302428 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002429
Jeff Johnson43971f52012-07-17 12:26:56 -07002430 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302431
2432 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 return 0;
2434}
2435
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302436
Jeff Johnsone7245742012-09-05 17:12:55 -07002437int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302438static iw_softap_getchannel(struct net_device *dev,
2439 struct iw_request_info *info,
2440 union iwreq_data *wrqu, char *extra)
2441{
2442 int ret;
2443
2444 vos_ssr_protect(__func__);
2445 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2446 vos_ssr_unprotect(__func__);
2447
2448 return ret;
2449}
2450
2451int
2452static __iw_softap_set_max_tx_power(struct net_device *dev,
2453 struct iw_request_info *info,
2454 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002455{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302456 hdd_adapter_t *pHostapdAdapter;
2457 tHalHandle hHal;
2458 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002459 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302460 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002461 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2462 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2463
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302464 ENTER();
2465
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302466 pHostapdAdapter = (netdev_priv(dev));
2467 if (NULL == pHostapdAdapter)
2468 {
2469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2470 "%s: Adapter is NULL",__func__);
2471 return -EINVAL;
2472 }
2473 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2474 ret = wlan_hdd_validate_context(pHddCtx);
2475 if (0 != ret)
2476 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302477 return ret;
2478 }
2479 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2480 if (NULL == hHal)
2481 {
2482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2483 "%s: Hal Context is NULL",__func__);
2484 return -EINVAL;
2485 }
schang86c22c42013-03-13 18:41:24 -07002486 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002487 return -ENOMEM;
2488
Leo Changd37675a2013-08-01 13:19:45 -07002489 /* Assign correct slef MAC address */
2490 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2491 VOS_MAC_ADDR_SIZE);
2492 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2493 VOS_MAC_ADDR_SIZE);
2494
schang86c22c42013-03-13 18:41:24 -07002495 set_value = value[0];
2496 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2497 {
2498 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002499 __func__);
schang86c22c42013-03-13 18:41:24 -07002500 return -EIO;
2501 }
2502
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302503 EXIT();
schang86c22c42013-03-13 18:41:24 -07002504 return 0;
2505}
2506
2507int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302508static iw_softap_set_max_tx_power(struct net_device *dev,
2509 struct iw_request_info *info,
2510 union iwreq_data *wrqu, char *extra)
2511{
2512 int ret;
2513
2514 vos_ssr_protect(__func__);
2515 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2516 vos_ssr_unprotect(__func__);
2517
2518 return ret;
2519}
2520
2521
2522int
2523static __iw_display_data_path_snapshot(struct net_device *dev,
2524 struct iw_request_info *info,
2525 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302526{
2527
2528 /* Function intitiating dumping states of
2529 * HDD(WMM Tx Queues)
2530 * TL State (with Per Client infor)
2531 * DXE Snapshot (Called at the end of TL Snapshot)
2532 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302533 hdd_adapter_t *pHostapdAdapter;
2534 hdd_context_t *pHddCtx;
2535 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302536
2537 ENTER();
2538
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302539 pHostapdAdapter = (netdev_priv(dev));
2540 if (NULL == pHostapdAdapter)
2541 {
2542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2543 "%s: Adapter is NULL",__func__);
2544 return -EINVAL;
2545 }
2546 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2547 ret = wlan_hdd_validate_context(pHddCtx);
2548 if (0 != ret)
2549 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302550 return ret;
2551 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302552 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302553 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302554
2555 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302556 return 0;
2557}
2558
2559int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302560static iw_display_data_path_snapshot(struct net_device *dev,
2561 struct iw_request_info *info,
2562 union iwreq_data *wrqu, char *extra)
2563{
2564 int ret;
2565
2566 vos_ssr_protect(__func__);
2567 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2568 vos_ssr_unprotect(__func__);
2569
2570 return ret;
2571}
2572
2573int
2574static __iw_softap_set_tx_power(struct net_device *dev,
2575 struct iw_request_info *info,
2576 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002577{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302578 hdd_adapter_t *pHostapdAdapter;
2579 hdd_context_t *pHddCtx;
2580 v_CONTEXT_t pVosContext;
2581 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002582 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302583 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002584 ptSapContext pSapCtx = NULL;
2585
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302586 ENTER();
2587
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302588 pHostapdAdapter = (netdev_priv(dev));
2589 if (NULL == pHostapdAdapter)
2590 {
2591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2592 "%s: Adapter is NULL",__func__);
2593 return -EINVAL;
2594 }
2595 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2596 ret = wlan_hdd_validate_context(pHddCtx);
2597 if (0 != ret)
2598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302599 return ret;
2600 }
2601 pVosContext = pHddCtx->pvosContext;
2602 if (NULL == pVosContext)
2603 {
2604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2605 "%s: Vos Context is NULL",__func__);
2606 return -EINVAL;
2607 }
2608 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2609 if (NULL == hHal)
2610 {
2611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2612 "%s: Hal Context is NULL",__func__);
2613 return -EINVAL;
2614 }
schang86c22c42013-03-13 18:41:24 -07002615 if (NULL == value)
2616 return -ENOMEM;
2617
2618 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2619 if (NULL == pSapCtx)
2620 {
2621 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2622 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2623 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002624 }
2625
2626 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002627 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002628 {
schang86c22c42013-03-13 18:41:24 -07002629 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002630 __func__);
2631 return -EIO;
2632 }
2633
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302634 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002635 return 0;
2636}
2637
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302638int
2639static iw_softap_set_tx_power(struct net_device *dev,
2640 struct iw_request_info *info,
2641 union iwreq_data *wrqu, char *extra)
2642{
2643 int ret;
2644
2645 vos_ssr_protect(__func__);
2646 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2647 vos_ssr_unprotect(__func__);
2648
2649 return ret;
2650}
2651
Kiet Lambcf38522013-10-26 18:28:27 +05302652/**---------------------------------------------------------------------------
2653
2654 \brief iw_softap_set_trafficmonitor() -
2655 This function dynamically enable/disable traffic monitor functonality
2656 the command iwpriv wlanX setTrafficMon <value>.
2657
2658 \param - dev - Pointer to the net device.
2659 - addr - Pointer to the sockaddr.
2660 \return - 0 for success, non zero for failure
2661
2662 --------------------------------------------------------------------------*/
2663
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302664static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2665 struct iw_request_info *info,
2666 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302667{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302668 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302669 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302670 hdd_context_t *pHddCtx;
2671 int status;
2672
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302673 ENTER();
2674
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302675 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302676 if (NULL == pAdapter)
2677 {
2678 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2679 "%s: HDD adapter is Null", __func__);
2680 return -ENODEV;
2681 }
2682
2683 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2684
2685 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302686 if (0 != status)
2687 {
Kiet Lambcf38522013-10-26 18:28:27 +05302688 return status;
2689 }
2690
2691 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2692
2693 if (NULL == isSetTrafficMon)
2694 {
2695 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2696 "%s: Invalid SAP pointer from extra", __func__);
2697 return -ENOMEM;
2698 }
2699
2700 if (TRUE == *isSetTrafficMon)
2701 {
2702 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2703 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2704 {
2705 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2706 "%s: failed to Start Traffic Monitor timer ", __func__ );
2707 return -EIO;
2708 }
2709 }
2710 else if (FALSE == *isSetTrafficMon)
2711 {
2712 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2713 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2714 {
2715 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2716 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2717 return -EIO;
2718 }
2719
2720 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302721
2722 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302723 return 0;
2724}
2725
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302726static int iw_softap_set_trafficmonitor(struct net_device *dev,
2727 struct iw_request_info *info,
2728 union iwreq_data *wrqu, char *extra)
2729{
2730 int ret;
2731
2732 vos_ssr_protect(__func__);
2733 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2734 vos_ssr_unprotect(__func__);
2735
2736 return ret;
2737}
2738
Jeff Johnson295189b2012-06-20 16:38:30 -07002739#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2740
2741int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302742static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2743 struct iw_request_info *info,
2744 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002745{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302746 hdd_adapter_t *pHostapdAdapter;
2747 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302748 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002749 char *buf;
2750 int cnt = 0;
2751 int left;
2752 int ret = 0;
2753 /* maclist_index must be u32 to match userspace */
2754 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302755 v_CONTEXT_t pVosContext = NULL;
2756 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302757
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302758 ENTER();
2759
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302760 pHostapdAdapter = (netdev_priv(dev));
2761 if (NULL == pHostapdAdapter)
2762 {
2763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2764 "%s: Adapter is NULL",__func__);
2765 return -EINVAL;
2766 }
2767 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2768 ret = wlan_hdd_validate_context(pHddCtx);
2769 if (0 != ret)
2770 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302771 return ret;
2772 }
2773
Jeff Johnson224f3702014-03-26 11:09:47 -07002774 /*
2775 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2776 * number, and even numbered iocts are supposed to have "set"
2777 * semantics. Hence the wireless extensions support in the kernel
2778 * won't correctly copy the result to userspace, so the ioctl
2779 * handler itself must copy the data. Output format is 32-bit
2780 * record length, followed by 0 or more 6-byte STA MAC addresses.
2781 *
2782 * Further note that due to the incorrect semantics, the "iwpriv"
2783 * userspace application is unable to correctly invoke this API,
2784 * hence it is not registered in the hostapd_private_args. This
2785 * API can only be invoked by directly invoking the ioctl() system
2786 * call.
2787 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
Jeff Johnson224f3702014-03-26 11:09:47 -07002789 /* make sure userspace allocated a reasonable buffer size */
2790 if (wrqu->data.length < sizeof(maclist_index)) {
2791 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2792 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002794
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302795 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2796 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2797 if(pSapCtx == NULL){
2798 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2799 FL("psapCtx is NULL"));
2800 return -EFAULT;
2801 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302802
2803 /* allocate local buffer to build the response */
2804 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2805 if (!buf) {
2806 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2807 return -ENOMEM;
2808 }
2809
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302810 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002811 /* start indexing beyond where the record count will be written */
2812 maclist_index = sizeof(maclist_index);
2813 left = wrqu->data.length - maclist_index;
2814
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302815 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002816 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2817 if ((pStaInfo[cnt].isUsed) &&
2818 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2819 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2820 VOS_MAC_ADDR_SIZE);
2821 maclist_index += VOS_MAC_ADDR_SIZE;
2822 left -= VOS_MAC_ADDR_SIZE;
2823 }
2824 cnt++;
2825 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302826 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002827
2828 *((u32 *)buf) = maclist_index;
2829 wrqu->data.length = maclist_index;
2830 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2831 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2832 ret = -EFAULT;
2833 }
2834 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302835
2836 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002837 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002838}
2839
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302840int
2841static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2842 struct iw_request_info *info,
2843 union iwreq_data *wrqu, char *extra)
2844{
2845 int ret;
2846
2847 vos_ssr_protect(__func__);
2848 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2849 vos_ssr_unprotect(__func__);
2850
2851 return ret;
2852}
2853
Jeff Johnson295189b2012-06-20 16:38:30 -07002854/* Usage:
2855 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2856 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2857 while using this ioctl
2858
2859 Syntax:
2860 iwpriv softap.0 disassoc_sta <6 octet mac address>
2861
2862 e.g.
2863 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2864 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2865*/
2866
2867int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302868static __iw_softap_disassoc_sta(struct net_device *dev,
2869 struct iw_request_info *info,
2870 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002871{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302872 hdd_adapter_t *pHostapdAdapter;
2873 hdd_context_t *pHddCtx;
2874 v_U8_t *peerMacAddr;
2875 int ret = 0;
2876
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302878
2879 if (!capable(CAP_NET_ADMIN)) {
2880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2881 FL("permission check failed"));
2882 return -EPERM;
2883 }
2884
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302885 pHostapdAdapter = (netdev_priv(dev));
2886 if (NULL == pHostapdAdapter)
2887 {
2888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2889 "%s: Adapter is NULL",__func__);
2890 return -EINVAL;
2891 }
2892 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2893 ret = wlan_hdd_validate_context(pHddCtx);
2894 if (0 != ret)
2895 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302896 return ret;
2897 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302898 /* iwpriv tool or framework calls this ioctl with
2899 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302901 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002902
Arif Hussain24bafea2013-11-15 15:10:03 -08002903 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2904 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2906 EXIT();
2907 return 0;
2908}
2909
2910int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302911static iw_softap_disassoc_sta(struct net_device *dev,
2912 struct iw_request_info *info,
2913 union iwreq_data *wrqu, char *extra)
2914{
2915 int ret;
2916
2917 vos_ssr_protect(__func__);
2918 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2919 vos_ssr_unprotect(__func__);
2920
2921 return ret;
2922}
2923
2924int
2925static __iw_softap_ap_stats(struct net_device *dev,
2926 struct iw_request_info *info,
2927 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002928{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 hdd_adapter_t *pHostapdAdapter;
2930 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 WLANTL_TRANSFER_STA_TYPE statBuffer;
2932 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302933 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002934
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302935 ENTER();
2936
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302937 pHostapdAdapter = (netdev_priv(dev));
2938 if (NULL == pHostapdAdapter)
2939 {
2940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2941 "%s: Adapter is NULL",__func__);
2942 return -EINVAL;
2943 }
2944 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2945 ret = wlan_hdd_validate_context(pHddCtx);
2946 if (0 != ret)
2947 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302948 return ret;
2949 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002950 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07002951 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
2952 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302954 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07002955 if(NULL == pstatbuf) {
2956 hddLog(LOG1, "unable to allocate memory");
2957 return -ENOMEM;
2958 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302959
2960 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07002961 "RUF=%d RMF=%d RBF=%d "
2962 "RUB=%d RMB=%d RBB=%d "
2963 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302964 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07002965 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
2966 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
2967 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
2968 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
2969 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
2970 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07002971
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302972 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07002973 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2974 kfree(pstatbuf);
2975 return -EFAULT;
2976 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05302977
2978 strlcpy(extra, pstatbuf, len);
2979 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07002980 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302981
2982 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 return 0;
2984}
Bhargav Shah7f03b812015-08-21 11:17:32 +05302985int
2986static __iw_softap_ap_get_stats(struct net_device *dev,
2987 struct iw_request_info *info,
2988 union iwreq_data *wrqu, char *extra)
2989{
2990 hdd_adapter_t *pAdapter;
2991 hdd_tx_rx_stats_t *pStats;
2992
2993 ENTER();
2994 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2995 if (NULL == pAdapter)
2996 {
2997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2998 "%s: Adapter is NULL",__func__);
2999 return -EINVAL;
3000 }
3001
3002 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3003 snprintf(extra, QCSAP_MAX_STR_LEN,
3004 "\nTransmit"
3005 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3006 "\n dropped BK %u, BE %u, VI %u, VO %u"
3007 "\n classified BK %u, BE %u, VI %u, VO %u"
3008 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3009 "\n queued BK %u, BE %u, VI %u, VO %u"
3010 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3011 "\ndequeued %u, depressured %u, deque-depressured %u,\
3012 completed %u, flushed %u"
3013 "\n fetched BK %u, BE %u, VI %u, VO %u"
3014 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3015 "\n depressured BK %u, BE %u, VI %u, VO %u"
3016 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3017 "\n flushed BK %u, BE %u, VI %u, VO %u"
3018 "\n\nReceive"
3019 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3020 "\n\nResetsStats"
3021 "\n",
3022 pStats->txXmitCalled,
3023 pStats->txXmitDropped,
3024 pStats->txXmitBackPressured,
3025 pStats->txXmitQueued,
3026
3027 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3028 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3029 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3030 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3031
3032 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3033 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3034 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3035 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3036
3037 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3038 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3039 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3040 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3041
3042 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3043 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3044 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3045 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3046
3047 pStats->txFetched,
3048 pStats->txFetchEmpty,
3049 pStats->txFetchLowResources,
3050 pStats->txFetchDequeueError,
3051
3052 pStats->txFetchDequeued,
3053 pStats->txFetchDePressured,
3054 pStats->txDequeDePressured,
3055 pStats->txCompleted,
3056 pStats->txFlushed,
3057
3058 pStats->txFetchedAC[WLANTL_AC_BK],
3059 pStats->txFetchedAC[WLANTL_AC_BE],
3060 pStats->txFetchedAC[WLANTL_AC_VI],
3061 pStats->txFetchedAC[WLANTL_AC_VO],
3062
3063 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3064 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3065 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3066 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3067
3068 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3069 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3070 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3071 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3072
3073 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3074 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3075 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3076 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3077
3078 pStats->txFlushedAC[WLANTL_AC_BK],
3079 pStats->txFlushedAC[WLANTL_AC_BE],
3080 pStats->txFlushedAC[WLANTL_AC_VI],
3081 pStats->txFlushedAC[WLANTL_AC_VO],
3082
3083 pStats->rxChains,
3084 pStats->rxPackets,
3085 pStats->rxDropped,
3086 pStats->rxDelivered,
3087 pStats->rxRefused
3088 );
3089
3090 wrqu->data.length = strlen(extra) + 1;
3091
3092 return 0;
3093}
3094
3095int
3096static __iw_softap_ap_clear_stats(struct net_device *dev,
3097 struct iw_request_info *info,
3098 union iwreq_data *wrqu, char *extra)
3099{
3100 hdd_adapter_t *pAdapter;
3101
3102 ENTER();
3103
3104 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3105 if (NULL == pAdapter)
3106 {
3107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3108 "%s: Adapter is NULL",__func__);
3109 return -EINVAL;
3110 }
3111
3112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3113 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3114 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3115 return 0;
3116}
3117
3118
3119int
3120static iw_softap_get_stats(struct net_device *dev,
3121 struct iw_request_info *info,
3122 union iwreq_data *wrqu, char *extra)
3123{
3124 int ret;
3125 vos_ssr_protect(__func__);
3126 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3127 vos_ssr_unprotect(__func__);
3128 return ret;
3129}
3130
3131int
3132static iw_softap_clear_stats(struct net_device *dev,
3133 struct iw_request_info *info,
3134 union iwreq_data *wrqu, char *extra)
3135{
3136 int ret;
3137 vos_ssr_protect(__func__);
3138 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3139 vos_ssr_unprotect(__func__);
3140 return ret;
3141}
Jeff Johnson295189b2012-06-20 16:38:30 -07003142
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303143int
3144static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 struct iw_request_info *info,
3146 union iwreq_data *wrqu, char *extra)
3147{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303148 int ret;
3149
3150 vos_ssr_protect(__func__);
3151 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3152 vos_ssr_unprotect(__func__);
3153
3154 return ret;
3155}
3156
3157static int __iw_softap_set_channel_range(struct net_device *dev,
3158 struct iw_request_info *info,
3159 union iwreq_data *wrqu, char *extra)
3160{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303161 hdd_adapter_t *pHostapdAdapter;
3162 tHalHandle hHal;
3163 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 int *value = (int *)extra;
3165 int startChannel = value[0];
3166 int endChannel = value[1];
3167 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003168 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 int ret = 0; /* success */
3170
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303171 ENTER();
3172
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303173 if (!capable(CAP_NET_ADMIN))
3174 {
3175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3176 FL("permission check failed"));
3177 return -EPERM;
3178 }
3179
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303180 pHostapdAdapter = (netdev_priv(dev));
3181 if (NULL == pHostapdAdapter)
3182 {
3183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3184 "%s: Adapter is NULL",__func__);
3185 return -EINVAL;
3186 }
3187 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3188 ret = wlan_hdd_validate_context(pHddCtx);
3189 if (0 != ret)
3190 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303191 return ret;
3192 }
3193 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3194 if (NULL == hHal)
3195 {
3196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3197 "%s: Hal Context is NULL",__func__);
3198 return -EINVAL;
3199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3201 if(status != VOS_STATUS_SUCCESS)
3202 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003203 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 startChannel,endChannel, band);
3205 ret = -EINVAL;
3206 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003207
3208 pHddCtx->is_dynamic_channel_range_set = 1;
3209
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303210 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 return ret;
3212}
3213
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303214static int iw_softap_set_channel_range(struct net_device *dev,
3215 struct iw_request_info *info,
3216 union iwreq_data *wrqu, char *extra)
3217{
3218 int ret;
3219
3220 vos_ssr_protect(__func__);
3221 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3222 vos_ssr_unprotect(__func__);
3223
3224 return ret;
3225}
3226
3227
3228int __iw_softap_get_channel_list(struct net_device *dev,
3229 struct iw_request_info *info,
3230 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003231{
3232 v_U32_t num_channels = 0;
3233 v_U8_t i = 0;
3234 v_U8_t bandStartChannel = RF_CHAN_1;
3235 v_U8_t bandEndChannel = RF_CHAN_165;
3236 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303237 hdd_adapter_t *pHostapdAdapter;
3238 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003241 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303242 hdd_context_t *pHddCtx;
3243 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303244
3245 ENTER();
3246
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303247 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3248 if (NULL == pHostapdAdapter)
3249 {
3250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3251 "%s: Adapter is NULL",__func__);
3252 return -EINVAL;
3253 }
3254 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3255 ret = wlan_hdd_validate_context(pHddCtx);
3256 if (0 != ret)
3257 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303258 return ret;
3259 }
3260 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3261 if (NULL == hHal)
3262 {
3263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3264 "%s: Hal Context is NULL",__func__);
3265 return -EINVAL;
3266 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003267 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3268 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003269 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003270 return -EIO;
3271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 wrqu->data.length = sizeof(tChannelListInfo);
3273 ENTER();
3274
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003275 if (eCSR_BAND_24 == curBand)
3276 {
3277 bandStartChannel = RF_CHAN_1;
3278 bandEndChannel = RF_CHAN_14;
3279 }
3280 else if (eCSR_BAND_5G == curBand)
3281 {
3282 bandStartChannel = RF_CHAN_36;
3283 bandEndChannel = RF_CHAN_165;
3284 }
3285
Arif Hussain6d2a3322013-11-17 19:50:10 -08003286 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303287 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003288 bandStartChannel, bandEndChannel );
3289
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3291 {
3292 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3293 {
3294 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3295 num_channels++;
3296 }
3297 }
3298
3299 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3300
3301 temp_num_channels = num_channels;
3302
3303 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3304 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303305 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003306 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 }
3308
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303309 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3310 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 {
3312 for(i = 0; i < temp_num_channels; i++)
3313 {
3314
3315 if((channel_list->channels[i] > 35) &&
3316 (channel_list->channels[i] < 49))
3317 {
3318 vos_mem_move(&channel_list->channels[i],
3319 &channel_list->channels[i+1],
3320 temp_num_channels - (i-1));
3321 num_channels--;
3322 temp_num_channels--;
3323 i--;
3324 }
3325 }
3326 }
3327
Arif Hussain6d2a3322013-11-17 19:50:10 -08003328 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 channel_list->num_channels = num_channels;
3331 EXIT();
3332
3333 return 0;
3334}
3335
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303336int iw_softap_get_channel_list(struct net_device *dev,
3337 struct iw_request_info *info,
3338 union iwreq_data *wrqu, char *extra)
3339{
3340 int ret;
3341
3342 vos_ssr_protect(__func__);
3343 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3344 vos_ssr_unprotect(__func__);
3345
3346 return ret;
3347}
3348
3349static
3350int __iw_get_genie(struct net_device *dev,
3351 struct iw_request_info *info,
3352 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003353{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303354 hdd_adapter_t *pHostapdAdapter;
3355 hdd_context_t *pHddCtx;
3356 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303357 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3359 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303360 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303361
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303363
3364 pHostapdAdapter = (netdev_priv(dev));
3365 if (NULL == pHostapdAdapter)
3366 {
3367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3368 "%s: Adapter is NULL",__func__);
3369 return -EINVAL;
3370 }
3371 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3372 ret = wlan_hdd_validate_context(pHddCtx);
3373 if (0 != ret)
3374 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303375 return ret;
3376 }
3377 pVosContext = pHddCtx->pvosContext;
3378 if (NULL == pVosContext)
3379 {
3380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3381 "%s: vos context is not valid ",__func__);
3382 return -EINVAL;
3383 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003384 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3386 status = WLANSap_getstationIE_information(pVosContext,
3387 &length,
3388 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303389
3390 if (VOS_STATUS_SUCCESS != status) {
3391 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003392 return -EFAULT;
3393 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303394
Arif Hussained667642013-10-27 23:01:14 -07003395 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303396 if (length > DOT11F_IE_RSN_MAX_LEN) {
3397 hddLog(LOGE,
3398 FL("invalid buffer length length:%d"), length);
3399 return -E2BIG;
3400 }
3401
3402 vos_mem_copy(extra, genIeBytes, length);
3403
3404 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3405
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 EXIT();
3407 return 0;
3408}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303409
3410static
3411int iw_get_genie(struct net_device *dev,
3412 struct iw_request_info *info,
3413 union iwreq_data *wrqu, char *extra)
3414{
3415 int ret;
3416
3417 vos_ssr_protect(__func__);
3418 ret = __iw_get_genie(dev, info, wrqu, extra);
3419 vos_ssr_unprotect(__func__);
3420
3421 return ret;
3422}
3423
3424static
3425int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3426 struct iw_request_info *info,
3427 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003428{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303429 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003430 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303431 hdd_ap_ctx_t *pHddApCtx;
3432 hdd_context_t *pHddCtx;
3433 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003436
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303437 pHostapdAdapter = (netdev_priv(dev));
3438 if (NULL == pHostapdAdapter)
3439 {
3440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3441 "%s: Adapter is NULL",__func__);
3442 return -EINVAL;
3443 }
3444 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3445 ret = wlan_hdd_validate_context(pHddCtx);
3446 if (0 != ret)
3447 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303448 return ret;
3449 }
3450 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3451 if (NULL == pHddApCtx)
3452 {
3453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3454 "%s: AP context is NULL",__func__);
3455 return -EINVAL;
3456 }
3457
Arif Hussain6d2a3322013-11-17 19:50:10 -08003458 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003459 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3460
3461 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3462 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3463 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3464 WPSPBCProbeReqIEs.probeReqIELen);
3465 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3466 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3467 sizeof(v_MACADDR_t));
3468 if (copy_to_user(wrqu->data.pointer,
3469 (void *)&WPSPBCProbeReqIEs,
3470 sizeof(WPSPBCProbeReqIEs)))
3471 {
3472 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3473 return -EFAULT;
3474 }
3475 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003476 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003477 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 up(&pHddApCtx->semWpsPBCOverlapInd);
3479 EXIT();
3480 return 0;
3481}
3482
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303483static
3484int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3485 struct iw_request_info *info,
3486 union iwreq_data *wrqu, char *extra)
3487{
3488 int ret;
3489
3490 vos_ssr_protect(__func__);
3491 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3492 vos_ssr_unprotect(__func__);
3493
3494 return ret;
3495}
3496
Jeff Johnson295189b2012-06-20 16:38:30 -07003497/**---------------------------------------------------------------------------
3498
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303499 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 This function sets the auth type received from the wpa_supplicant.
3501
3502 \param - dev - Pointer to the net device.
3503 - info - Pointer to the iw_request_info.
3504 - wrqu - Pointer to the iwreq_data.
3505 - extra - Pointer to the data.
3506 \return - 0 for success, non zero for failure
3507
3508 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303509int __iw_set_auth_hostap(struct net_device *dev,
3510 struct iw_request_info *info,
3511 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003512{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303513 hdd_adapter_t *pAdapter;
3514 hdd_context_t *pHddCtx;
3515 hdd_wext_state_t *pWextState;
3516 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303517
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303519
3520 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3521 if (NULL == pAdapter)
3522 {
3523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3524 "%s: Adapter is NULL",__func__);
3525 return -EINVAL;
3526 }
3527
3528 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3529 ret = wlan_hdd_validate_context(pHddCtx);
3530 if (0 != ret)
3531 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303532 return ret;
3533 }
3534 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3535 if (NULL == pWextState)
3536 {
3537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3538 "%s: pWextState is NULL",__func__);
3539 return -EINVAL;
3540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 switch(wrqu->param.flags & IW_AUTH_INDEX)
3542 {
3543 case IW_AUTH_TKIP_COUNTERMEASURES:
3544 {
3545 if(wrqu->param.value) {
3546 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3547 "Counter Measure started %d", wrqu->param.value);
3548 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303549 }
3550 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3552 "Counter Measure stopped=%d", wrqu->param.value);
3553 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3554 }
3555
3556 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3557 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303560
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303562
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003563 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 wrqu->param.flags & IW_AUTH_INDEX);
3565 break;
3566 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303567
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 EXIT();
3569 return 0;
3570}
3571
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303572int iw_set_auth_hostap(struct net_device *dev,
3573 struct iw_request_info *info,
3574 union iwreq_data *wrqu,char *extra)
3575{
3576 int ret;
3577
3578 vos_ssr_protect(__func__);
3579 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3580 vos_ssr_unprotect(__func__);
3581
3582 return ret;
3583}
3584
3585static int __iw_set_ap_encodeext(struct net_device *dev,
3586 struct iw_request_info *info,
3587 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003588{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303589 hdd_adapter_t *pHostapdAdapter;
3590 v_CONTEXT_t pVosContext;
3591 hdd_context_t *pHddCtx;
3592 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003593 int retval = 0;
3594 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3596 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3597 int key_index;
3598 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303599 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003600// tCsrRoamRemoveKey RemoveKey;
3601 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303602
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303603 ENTER();
3604 pHostapdAdapter = (netdev_priv(dev));
3605 if (NULL == pHostapdAdapter)
3606 {
3607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3608 "%s: Adapter is NULL",__func__);
3609 return -EINVAL;
3610 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003611
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303612 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3613 retval = wlan_hdd_validate_context(pHddCtx);
3614 if (0 != retval)
3615 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303616 return retval;
3617 }
3618 pVosContext = pHddCtx->pvosContext;
3619 if (NULL == pVosContext)
3620 {
3621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3622 "%s: pVosContext is NULL",__func__);
3623 return -EINVAL;
3624 }
3625 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3626 if (NULL == pHddApCtx)
3627 {
3628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3629 "%s: AP Context is NULL",__func__);
3630 return -EINVAL;
3631 }
3632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303634
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303636
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 /*Convert from 1-based to 0-based keying*/
3638 key_index--;
3639 }
3640 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303641#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 /*Set the encrytion type to NONE*/
3643#if 0
3644 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3645#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303646
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 RemoveKey.keyId = key_index;
3648 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3649 /*Key direction for group is RX only*/
3650 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3651 }
3652 else {
3653 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3654 }
3655 switch(ext->alg)
3656 {
3657 case IW_ENCODE_ALG_NONE:
3658 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3659 break;
3660 case IW_ENCODE_ALG_WEP:
3661 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3662 break;
3663 case IW_ENCODE_ALG_TKIP:
3664 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003665 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 case IW_ENCODE_ALG_CCMP:
3667 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3668 break;
3669 default:
3670 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3671 break;
3672 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003673 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 -07003674 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003676 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003678 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3679 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 {
3681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003682 __LINE__, vstatus );
3683 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003685#endif
3686 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003687
Jeff Johnson43971f52012-07-17 12:26:56 -07003688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003689
3690 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3691
3692 setKey.keyId = key_index;
3693 setKey.keyLength = ext->key_len;
3694
3695 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3696 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3697 }
3698
3699 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3700 /*Key direction for group is RX only*/
3701 setKey.keyDirection = eSIR_RX_ONLY;
3702 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3703 }
3704 else {
3705
3706 setKey.keyDirection = eSIR_TX_RX;
3707 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3708 }
3709 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3710 {
3711 setKey.keyDirection = eSIR_TX_DEFAULT;
3712 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3713 }
3714
3715 /*For supplicant pae role is zero*/
3716 setKey.paeRole = 0;
3717
3718 switch(ext->alg)
3719 {
3720 case IW_ENCODE_ALG_NONE:
3721 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3722 break;
3723
3724 case IW_ENCODE_ALG_WEP:
3725 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3726 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003727 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 break;
3729
3730 case IW_ENCODE_ALG_TKIP:
3731 {
3732 v_U8_t *pKey = &setKey.Key[0];
3733
3734 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3735
3736 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3737
3738 /*Supplicant sends the 32bytes key in this order
3739
3740 |--------------|----------|----------|
3741 | Tk1 |TX-MIC | RX Mic |
3742 |--------------|----------|----------|
3743 <---16bytes---><--8bytes--><--8bytes-->
3744
3745 */
3746 /*Sme expects the 32 bytes key to be in the below order
3747
3748 |--------------|----------|----------|
3749 | Tk1 |RX-MIC | TX Mic |
3750 |--------------|----------|----------|
3751 <---16bytes---><--8bytes--><--8bytes-->
3752 */
3753 /* Copy the Temporal Key 1 (TK1) */
3754 vos_mem_copy(pKey,ext->key,16);
3755
3756 /*Copy the rx mic first*/
3757 vos_mem_copy(&pKey[16],&ext->key[24],8);
3758
3759 /*Copy the tx mic */
3760 vos_mem_copy(&pKey[24],&ext->key[16],8);
3761
3762 }
3763 break;
3764
3765 case IW_ENCODE_ALG_CCMP:
3766 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3767 break;
3768
3769 default:
3770 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3771 break;
3772 }
3773
3774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303775 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 setKey.keyId);
3777 for(i=0; i< ext->key_len; i++)
3778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3779 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003780
3781 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3782 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 {
3784 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003785 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3786 retval = -EINVAL;
3787 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303788
3789 EXIT();
3790 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003791}
Jeff Johnson43971f52012-07-17 12:26:56 -07003792
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303793static int iw_set_ap_encodeext(struct net_device *dev,
3794 struct iw_request_info *info,
3795 union iwreq_data *wrqu, char *extra)
3796{
3797 int ret;
3798
3799 vos_ssr_protect(__func__);
3800 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3801 vos_ssr_unprotect(__func__);
3802
3803 return ret;
3804}
Jeff Johnson43971f52012-07-17 12:26:56 -07003805
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303806static int __iw_set_ap_mlme(struct net_device *dev,
3807 struct iw_request_info *info,
3808 union iwreq_data *wrqu,
3809 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003810{
3811#if 0
3812 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3813 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3814
3815 ENTER();
3816
3817 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3818 switch (mlme->cmd) {
3819 case IW_MLME_DISASSOC:
3820 case IW_MLME_DEAUTH:
3821 hddLog(LOG1, "Station disassociate");
3822 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3823 {
3824 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3825
3826 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3827 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3828
3829 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3830
3831 //clear all the reason codes
3832 if (status != 0)
3833 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003834 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 }
3836
3837 netif_stop_queue(dev);
3838 netif_carrier_off(dev);
3839 }
3840 else
3841 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003842 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 -07003843 }
3844 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003845 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 return -EINVAL;
3847 }//end of switch
3848 EXIT();
3849#endif
3850 return 0;
3851// return status;
3852}
3853
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303854static int iw_set_ap_mlme(struct net_device *dev,
3855 struct iw_request_info *info,
3856 union iwreq_data *wrqu,
3857 char *extra)
3858{
3859 int ret;
3860
3861 vos_ssr_protect(__func__);
3862 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3863 vos_ssr_unprotect(__func__);
3864
3865 return ret;
3866}
3867
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303868static int __iw_get_ap_rts_threshold(struct net_device *dev,
3869 struct iw_request_info *info,
3870 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003871{
3872 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3873 v_U32_t status = 0;
3874
3875 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3876
3877 return status;
3878}
3879
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303880static int iw_get_ap_rts_threshold(struct net_device *dev,
3881 struct iw_request_info *info,
3882 union iwreq_data *wrqu, char *extra)
3883{
3884 int ret;
3885
3886 vos_ssr_protect(__func__);
3887 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3888 vos_ssr_unprotect(__func__);
3889
3890 return ret;
3891}
3892
3893static int __iw_get_ap_frag_threshold(struct net_device *dev,
3894 struct iw_request_info *info,
3895 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003896{
3897 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3898 v_U32_t status = 0;
3899
3900 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3901
3902 return status;
3903}
3904
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303905static int iw_get_ap_frag_threshold(struct net_device *dev,
3906 struct iw_request_info *info,
3907 union iwreq_data *wrqu, char *extra)
3908{
3909 int ret;
3910
3911 vos_ssr_protect(__func__);
3912 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3913 vos_ssr_unprotect(__func__);
3914
3915 return ret;
3916}
3917
3918static int __iw_get_ap_freq(struct net_device *dev,
3919 struct iw_request_info *info,
3920 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003921{
Jeff Johnsone7245742012-09-05 17:12:55 -07003922 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303923 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 tHalHandle hHal;
3925 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303926 hdd_ap_ctx_t *pHddApCtx;
3927 hdd_context_t *pHddCtx;
3928 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003929
3930 ENTER();
3931
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303932 pHostapdAdapter = (netdev_priv(dev));
3933 if (NULL == pHostapdAdapter)
3934 {
3935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3936 "%s: Adapter is NULL",__func__);
3937 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303939 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3940 ret = wlan_hdd_validate_context(pHddCtx);
3941 if (0 != ret)
3942 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303943 return ret;
3944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303946 if (NULL == pHostapdState)
3947 {
3948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3949 "%s: pHostapdState is NULL",__func__);
3950 return -EINVAL;
3951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303953 if (NULL == hHal)
3954 {
3955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3956 "%s: Hal Context is NULL",__func__);
3957 return -EINVAL;
3958 }
3959 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3960 if (NULL == pHddApCtx)
3961 {
3962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3963 "%s: AP context is NULL",__func__);
3964 return -EINVAL;
3965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 if(pHostapdState->bssState == BSS_STOP )
3967 {
3968 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
3969 != eHAL_STATUS_SUCCESS)
3970 {
c_hpothuffdb5272013-10-02 16:42:35 +05303971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3972 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 return -EIO;
3974 }
3975 else
3976 {
3977 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003978 if( TRUE == status)
3979 {
3980 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3981 * iwlist & iwconfig command shows frequency into proper
3982 * format (2.412 GHz instead of 246.2 MHz)*/
3983 fwrq->m = freq;
3984 fwrq->e = MHZ;
3985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987 }
3988 else
3989 {
3990 channel = pHddApCtx->operatingChannel;
3991 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07003992 if( TRUE == status)
3993 {
3994 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
3995 * iwlist & iwconfig command shows frequency into proper
3996 * format (2.412 GHz instead of 246.2 MHz)*/
3997 fwrq->m = freq;
3998 fwrq->e = MHZ;
3999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304001
4002 EXIT();
4003 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004004}
4005
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304006static int iw_get_ap_freq(struct net_device *dev,
4007 struct iw_request_info *info,
4008 struct iw_freq *fwrq, char *extra)
4009{
4010 int ret;
4011
4012 vos_ssr_protect(__func__);
4013 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4014 vos_ssr_unprotect(__func__);
4015
4016 return ret;
4017}
4018
4019static int __iw_get_mode(struct net_device *dev,
4020 struct iw_request_info *info,
4021 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304022{
4023 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304024 hdd_adapter_t *pAdapter;
4025 hdd_context_t *pHddCtx;
4026
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304027 ENTER();
4028
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304029 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4030 if (NULL == pAdapter)
4031 {
4032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4033 "%s: Adapter is NULL",__func__);
4034 return -EINVAL;
4035 }
4036 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4037 status = wlan_hdd_validate_context(pHddCtx);
4038 if (0 != status)
4039 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304040 return status;
4041 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304042
4043 wrqu->mode = IW_MODE_MASTER;
4044
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304045 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304046 return status;
4047}
4048
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304049static int iw_get_mode(struct net_device *dev,
4050 struct iw_request_info *info,
4051 union iwreq_data *wrqu, char *extra)
4052{
4053 int ret;
4054
4055 vos_ssr_protect(__func__);
4056 ret = __iw_get_mode(dev, info, wrqu, extra);
4057 vos_ssr_unprotect(__func__);
4058
4059 return ret;
4060}
4061
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304062
4063static int __iw_softap_stopbss(struct net_device *dev,
4064 struct iw_request_info *info,
4065 union iwreq_data *wrqu,
4066 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004067{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304068 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304070 hdd_context_t *pHddCtx = NULL;
4071
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304073 pHostapdAdapter = (netdev_priv(dev));
4074 if (NULL == pHostapdAdapter)
4075 {
4076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4077 "%s: Adapter is NULL",__func__);
4078 return -EINVAL;
4079 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304080 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4081 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304082 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304083 return status;
4084 }
4085
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304086 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 {
4088 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4089 {
4090 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4091
4092 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304093
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304095 {
4096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004097 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 VOS_ASSERT(0);
4099 }
4100 }
4101 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304102 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 }
4104 EXIT();
4105 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4106}
4107
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304108static int iw_softap_stopbss(struct net_device *dev,
4109 struct iw_request_info *info,
4110 union iwreq_data *wrqu,
4111 char *extra)
4112{
4113 int ret;
4114
4115 vos_ssr_protect(__func__);
4116 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4117 vos_ssr_unprotect(__func__);
4118
4119 return ret;
4120}
4121
4122static int __iw_softap_version(struct net_device *dev,
4123 struct iw_request_info *info,
4124 union iwreq_data *wrqu,
4125 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004126{
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304128 hdd_context_t *pHddCtx;
4129 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304130
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304132 pHostapdAdapter = (netdev_priv(dev));
4133 if (NULL == pHostapdAdapter)
4134 {
4135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4136 "%s: Adapter is NULL",__func__);
4137 return -EINVAL;
4138 }
4139 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4140 ret = wlan_hdd_validate_context(pHddCtx);
4141 if (0 != ret)
4142 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304143 return ret;
4144 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004145 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 return 0;
4148}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004149
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304150static int iw_softap_version(struct net_device *dev,
4151 struct iw_request_info *info,
4152 union iwreq_data *wrqu,
4153 char *extra)
4154{
4155 int ret;
4156
4157 vos_ssr_protect(__func__);
4158 ret = __iw_softap_version(dev, info, wrqu, extra);
4159 vos_ssr_unprotect(__func__);
4160
4161 return ret;
4162}
4163
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304164int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004165{
4166 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004167 int len = 0;
4168 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304169 v_CONTEXT_t pVosContext;
4170 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304171 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304172
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304173 ENTER();
4174
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304175 if (NULL == pAdapter)
4176 {
4177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4178 "%s: Adapter is NULL",__func__);
4179 return -EINVAL;
4180 }
4181 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4182 if (0 != wlan_hdd_validate_context(pHddCtx))
4183 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304184 return VOS_STATUS_E_FAULT;
4185 }
4186 pVosContext = pHddCtx->pvosContext;
4187 if (NULL == pVosContext)
4188 {
4189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4190 "%s: VOS context is not valid",__func__);
4191 return VOS_STATUS_E_FAULT;
4192 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304193 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304194 if(pSapCtx == NULL)
4195 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304196 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4197 FL("psapCtx is NULL"));
4198 return VOS_STATUS_E_FAULT;
4199 }
4200
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304201 len = snprintf(pBuf, buf_len, sta_info_header);
4202 if (len >= buf_len) {
4203 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4204 return -E2BIG;
4205 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004206 pBuf += len;
4207 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004208
4209 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4210 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304211 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004212 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004213 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304214 pSapCtx->aStaInfo[i].ucSTAId,
4215 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4216 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4217 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4218 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4219 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4220 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304221 if (len >= buf_len) {
4222 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4223 return -E2BIG;
4224 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004225 pBuf += len;
4226 buf_len -= len;
4227 }
4228 if(WE_GET_STA_INFO_SIZE > buf_len)
4229 {
4230 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004231 }
4232 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304233 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304234 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004235}
4236
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304237static int __iw_softap_get_sta_info(struct net_device *dev,
4238 struct iw_request_info *info,
4239 union iwreq_data *wrqu,
4240 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004241{
4242 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304243 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004244 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304245 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4246 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004247 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304248 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004249 }
4250 wrqu->data.length = strlen(extra);
4251 EXIT();
4252 return 0;
4253}
4254
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304255static int iw_softap_get_sta_info(struct net_device *dev,
4256 struct iw_request_info *info,
4257 union iwreq_data *wrqu,
4258 char *extra)
4259{
4260 int ret;
4261
4262 vos_ssr_protect(__func__);
4263 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4264 vos_ssr_unprotect(__func__);
4265
4266 return ret;
4267}
4268
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304269static int __iw_set_ap_genie(struct net_device *dev,
4270 struct iw_request_info *info,
4271 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004272{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304273
4274 hdd_adapter_t *pHostapdAdapter;
4275 hdd_context_t *pHddCtx;
4276 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004278 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304279 int ret = 0;
4280
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304282 pHostapdAdapter = (netdev_priv(dev));
4283 if (NULL == pHostapdAdapter)
4284 {
4285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4286 "%s: Adapter is NULL",__func__);
4287 return -EINVAL;
4288 }
4289 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4290 ret = wlan_hdd_validate_context(pHddCtx);
4291 if (0 != ret)
4292 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304293 return ret;
4294 }
4295 pVosContext = pHddCtx->pvosContext;
4296 if (NULL == pVosContext)
4297 {
4298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4299 "%s: VOS Context is NULL",__func__);
4300 return -EINVAL;
4301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 if(!wrqu->data.length)
4303 {
4304 EXIT();
4305 return 0;
4306 }
Arif Hussained667642013-10-27 23:01:14 -07004307
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304308 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304310 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 case DOT11F_EID_RSN:
4312 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4313 {
4314 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4315 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004318 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304320
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004322 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 halStatus = 0;
4324 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304325
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304327 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004328}
4329
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304330static int iw_set_ap_genie(struct net_device *dev,
4331 struct iw_request_info *info,
4332 union iwreq_data *wrqu, char *extra)
4333{
4334 int ret;
4335
4336 vos_ssr_protect(__func__);
4337 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4338 vos_ssr_unprotect(__func__);
4339
4340 return ret;
4341}
4342
Jeff Johnson295189b2012-06-20 16:38:30 -07004343static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4344{
4345 eHalStatus hstatus;
4346 long lrc;
4347 struct statsContext context;
4348
4349 if (NULL == pAdapter)
4350 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304351 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 return VOS_STATUS_E_FAULT;
4353 }
4354
4355 init_completion(&context.completion);
4356 context.pAdapter = pAdapter;
4357 context.magic = STATS_CONTEXT_MAGIC;
4358 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4359 eCSR_HDD,
4360 SME_GLOBAL_CLASSA_STATS,
4361 hdd_GetClassA_statisticsCB,
4362 0, // not periodic
4363 FALSE, //non-cached results
4364 staid,
4365 &context);
4366 if (eHAL_STATUS_SUCCESS != hstatus)
4367 {
4368 hddLog(VOS_TRACE_LEVEL_ERROR,
4369 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004370 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 }
4372 else
4373 {
4374 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4375 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 if (lrc <= 0)
4377 {
4378 hddLog(VOS_TRACE_LEVEL_ERROR,
4379 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004380 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 }
4382 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004383
4384 /* either we never sent a request, we sent a request and received a
4385 response or we sent a request and timed out. if we never sent a
4386 request or if we sent a request and got a response, we want to
4387 clear the magic out of paranoia. if we timed out there is a
4388 race condition such that the callback function could be
4389 executing at the same time we are. of primary concern is if the
4390 callback function had already verified the "magic" but had not
4391 yet set the completion variable when a timeout occurred. we
4392 serialize these activities by invalidating the magic while
4393 holding a shared spinlock which will cause us to block if the
4394 callback is currently executing */
4395 spin_lock(&hdd_context_lock);
4396 context.magic = 0;
4397 spin_unlock(&hdd_context_lock);
4398
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 return VOS_STATUS_SUCCESS;
4400}
4401
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304402int __iw_get_softap_linkspeed(struct net_device *dev,
4403 struct iw_request_info *info,
4404 union iwreq_data *wrqu,
4405 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004406
4407{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304408 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304409 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004411 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304412 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304414 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004416 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304417 int rc, valid;
4418
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304419 ENTER();
4420
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304421 pHostapdAdapter = (netdev_priv(dev));
4422 if (NULL == pHostapdAdapter)
4423 {
4424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4425 "%s: Adapter is NULL",__func__);
4426 return -EINVAL;
4427 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304428 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304429 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304430 if (0 != valid)
4431 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304432 return valid;
4433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004434
Arif Hussain6d2a3322013-11-17 19:50:10 -08004435 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004436
4437 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004438 {
Arif Hussaina9571842014-01-15 16:43:41 -08004439 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4440 if (NULL == pmacAddress) {
4441 hddLog(LOG1, "unable to allocate memory");
4442 return -ENOMEM;
4443 }
4444 if (copy_from_user((void *)pmacAddress,
4445 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4446 {
4447 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4448 kfree(pmacAddress);
4449 return -EFAULT;
4450 }
Manjeet Singha3739742016-05-03 16:21:46 +05304451 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004452
4453 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004454 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004455
4456 if (!VOS_IS_STATUS_SUCCESS(status ))
4457 {
4458 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4459 }
Arif Hussained667642013-10-27 23:01:14 -07004460 }
Kiet Lam61589852013-09-19 17:10:58 +05304461 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304462 * link speed for first connected client will be returned.
4463 */
Arif Hussaina9571842014-01-15 16:43:41 -08004464 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304465 {
4466 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4467 }
4468 else
4469 {
4470 status = hdd_softap_GetStaId(pHostapdAdapter,
4471 (v_MACADDR_t *)macAddress, (void *)(&staId));
4472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004473
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304474 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 link_speed = 0;
4478 }
4479 else
4480 {
4481 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 if (!VOS_IS_STATUS_SUCCESS(status ))
4484 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304485 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 return -EINVAL;
4487 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304488
4489 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4490 staId, &link_speed);
4491
4492 link_speed = link_speed / 10;
4493
4494 if (0 == link_speed)
4495 {
4496 /* The linkspeed returned by HAL is in units of 500kbps.
4497 * converting it to mbps.
4498 * This is required to support legacy firmware which does
4499 * not return link capacity.
4500 */
4501 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 }
4504
4505 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004506 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304507
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 if ((rc < 0) || (rc >= len))
4509 {
4510 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304511 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 return -EIO;
4513 }
4514
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304515 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 return 0;
4517}
4518
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304519int iw_get_softap_linkspeed(struct net_device *dev,
4520 struct iw_request_info *info,
4521 union iwreq_data *wrqu,
4522 char *extra)
4523{
4524 int ret;
4525
4526 vos_ssr_protect(__func__);
4527 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4528 vos_ssr_unprotect(__func__);
4529
4530 return ret;
4531}
4532
4533
Jeff Johnson295189b2012-06-20 16:38:30 -07004534static const iw_handler hostapd_handler[] =
4535{
4536 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4537 (iw_handler) NULL, /* SIOCGIWNAME */
4538 (iw_handler) NULL, /* SIOCSIWNWID */
4539 (iw_handler) NULL, /* SIOCGIWNWID */
4540 (iw_handler) NULL, /* SIOCSIWFREQ */
4541 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4542 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304543 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 (iw_handler) NULL, /* SIOCSIWSENS */
4545 (iw_handler) NULL, /* SIOCGIWSENS */
4546 (iw_handler) NULL, /* SIOCSIWRANGE */
4547 (iw_handler) NULL, /* SIOCGIWRANGE */
4548 (iw_handler) NULL, /* SIOCSIWPRIV */
4549 (iw_handler) NULL, /* SIOCGIWPRIV */
4550 (iw_handler) NULL, /* SIOCSIWSTATS */
4551 (iw_handler) NULL, /* SIOCGIWSTATS */
4552 (iw_handler) NULL, /* SIOCSIWSPY */
4553 (iw_handler) NULL, /* SIOCGIWSPY */
4554 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4555 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4556 (iw_handler) NULL, /* SIOCSIWAP */
4557 (iw_handler) NULL, /* SIOCGIWAP */
4558 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4559 (iw_handler) NULL, /* SIOCGIWAPLIST */
4560 (iw_handler) NULL, /* SIOCSIWSCAN */
4561 (iw_handler) NULL, /* SIOCGIWSCAN */
4562 (iw_handler) NULL, /* SIOCSIWESSID */
4563 (iw_handler) NULL, /* SIOCGIWESSID */
4564 (iw_handler) NULL, /* SIOCSIWNICKN */
4565 (iw_handler) NULL, /* SIOCGIWNICKN */
4566 (iw_handler) NULL, /* -- hole -- */
4567 (iw_handler) NULL, /* -- hole -- */
4568 (iw_handler) NULL, /* SIOCSIWRATE */
4569 (iw_handler) NULL, /* SIOCGIWRATE */
4570 (iw_handler) NULL, /* SIOCSIWRTS */
4571 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4572 (iw_handler) NULL, /* SIOCSIWFRAG */
4573 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4574 (iw_handler) NULL, /* SIOCSIWTXPOW */
4575 (iw_handler) NULL, /* SIOCGIWTXPOW */
4576 (iw_handler) NULL, /* SIOCSIWRETRY */
4577 (iw_handler) NULL, /* SIOCGIWRETRY */
4578 (iw_handler) NULL, /* SIOCSIWENCODE */
4579 (iw_handler) NULL, /* SIOCGIWENCODE */
4580 (iw_handler) NULL, /* SIOCSIWPOWER */
4581 (iw_handler) NULL, /* SIOCGIWPOWER */
4582 (iw_handler) NULL, /* -- hole -- */
4583 (iw_handler) NULL, /* -- hole -- */
4584 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4585 (iw_handler) NULL, /* SIOCGIWGENIE */
4586 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4587 (iw_handler) NULL, /* SIOCGIWAUTH */
4588 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4589 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4590 (iw_handler) NULL, /* SIOCSIWPMKSA */
4591};
4592
Jeff Johnson224f3702014-03-26 11:09:47 -07004593/*
4594 * Note that the following ioctls were defined with semantics which
4595 * cannot be handled by the "iwpriv" userspace application and hence
4596 * they are not included in the hostapd_private_args array
4597 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4598 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004599
4600static const struct iw_priv_args hostapd_private_args[] = {
4601 { QCSAP_IOCTL_SETPARAM,
4602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4603 { QCSAP_IOCTL_SETPARAM,
4604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304605 { QCSAP_PARAM_GET_FRAME_LOGS,
4606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 { QCSAP_PARAM_MAX_ASSOC,
4608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4609 { QCSAP_PARAM_HIDE_SSID,
4610 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004611 { QCSAP_PARAM_SET_MC_RATE,
4612 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304613 { QCSAP_PARAM_SET_PROXIMITY,
4614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304615 { QCSAP_PARAM_SET_WOWL,
4616 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 { QCSAP_IOCTL_GETPARAM,
4618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4619 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4620 { QCSAP_IOCTL_GETPARAM, 0,
4621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4622 { QCSAP_PARAM_MAX_ASSOC, 0,
4623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004624 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4626 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4627 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304628 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 { QCSAP_PARAM_CLR_ACL, 0,
4631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4632 { QCSAP_PARAM_ACL_MODE,
4633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304635 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 { QCSAP_IOCTL_STOPBSS,
4637 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4638 { QCSAP_IOCTL_VERSION, 0,
4639 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004640 { QCSAP_IOCTL_GET_STA_INFO, 0,
4641 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004643 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004646 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304648 { QCSAP_IOCTL_AP_STATS, 0,
4649 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304650 { QCSAP_IOCTL_GET_STATS, 0,
4651 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4652 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4654 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304655 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004656
4657 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4659 /* handlers for sub-ioctl */
4660 { WE_SET_WLAN_DBG,
4661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4662 0,
4663 "setwlandbg" },
4664
4665 /* handlers for main ioctl */
4666 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4667 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4668 0,
4669 "" },
4670
4671 /* handlers for sub-ioctl */
4672 { WE_LOG_DUMP_CMD,
4673 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4674 0,
4675 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 { WE_P2P_NOA_CMD,
4677 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4678 0,
4679 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004680 /* handlers for sub ioctl */
4681 {
4682 WE_MCC_CONFIG_CREDENTIAL,
4683 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4684 0,
4685 "setMccCrdnl" },
4686
4687 /* handlers for sub ioctl */
4688 {
4689 WE_MCC_CONFIG_PARAMS,
4690 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4691 0,
4692 "setMccConfig" },
4693
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 /* handlers for main ioctl */
4695 { QCSAP_IOCTL_MODIFY_ACL,
4696 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4697 0,
4698 "modify_acl" },
4699
4700 /* handlers for main ioctl */
4701 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4702 0,
4703 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4704 "getChannelList" },
4705
Jeff Johnsone7245742012-09-05 17:12:55 -07004706 /* handlers for main ioctl */
4707 { QCSAP_IOCTL_SET_TX_POWER,
4708 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4709 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304710 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004711
4712 /* handlers for main ioctl */
4713 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4714 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4715 0,
4716 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304717
4718 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4719 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4720 0,
4721 "dataSnapshot" },
4722
4723 /* handlers for main ioctl */
4724 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4725 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4726 0,
4727 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304728 /* handlers for main ioctl */
4729 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
4730 IW_PRIV_TYPE_CHAR| 512,
4731 0,
4732 "" },
4733
4734 /* handlers for sub-ioctl */
4735 { WE_WOWL_ADD_PTRN,
4736 IW_PRIV_TYPE_CHAR| 512,
4737 0,
4738 "wowlAddPtrn" },
4739
4740 { WE_WOWL_DEL_PTRN,
4741 IW_PRIV_TYPE_CHAR| 512,
4742 0,
4743 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004744};
Jeff Johnsone7245742012-09-05 17:12:55 -07004745
Jeff Johnson295189b2012-06-20 16:38:30 -07004746static const iw_handler hostapd_private[] = {
4747 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304748 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
4749 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
4750 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4753 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4754 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4755 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4756 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4757 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4758 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304759 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4761 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4762 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4763 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004764 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004765 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4766 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004767 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304768 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304769 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304770 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4771 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004772};
4773const struct iw_handler_def hostapd_handler_def = {
4774 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4775 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4776 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4777 .standard = (iw_handler *)hostapd_handler,
4778 .private = (iw_handler *)hostapd_private,
4779 .private_args = hostapd_private_args,
4780 .get_wireless_stats = NULL,
4781};
4782#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4783struct net_device_ops net_ops_struct = {
4784 .ndo_open = hdd_hostapd_open,
4785 .ndo_stop = hdd_hostapd_stop,
4786 .ndo_uninit = hdd_hostapd_uninit,
4787 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4788 .ndo_tx_timeout = hdd_softap_tx_timeout,
4789 .ndo_get_stats = hdd_softap_stats,
4790 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4791 .ndo_do_ioctl = hdd_hostapd_ioctl,
4792 .ndo_change_mtu = hdd_hostapd_change_mtu,
4793 .ndo_select_queue = hdd_hostapd_select_queue,
4794 };
4795#endif
4796
4797int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4798{
4799 return VOS_STATUS_SUCCESS;
4800}
4801
4802void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4803{
4804#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4805 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4806#else
4807 pWlanHostapdDev->open = hdd_hostapd_open;
4808 pWlanHostapdDev->stop = hdd_hostapd_stop;
4809 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4810 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4811 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4812 pWlanHostapdDev->get_stats = hdd_softap_stats;
4813 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4814 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4815#endif
4816}
4817
4818VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304819{
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05304821#ifdef DHCP_SERVER_OFFLOAD
4822 hdd_dhcp_state_t *dhcp_status;
4823#endif /* DHCP_SERVER_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004825 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004827#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004828 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4829 v_U16_t unsafeChannelCount;
4830#endif /* FEATURE_WLAN_CH_AVOID */
4831
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304832 if (pHddCtx->isLogpInProgress) {
4833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4834 "%s:LOGP in Progress. Ignore!!!",__func__);
4835 status = VOS_STATUS_E_FAILURE;
4836 }
4837
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304839
4840#ifdef SAP_AUTH_OFFLOAD
4841 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
4842 hdd_set_sap_auth_offload(pAdapter, TRUE);
4843#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304844
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304845 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05304847#ifdef DHCP_SERVER_OFFLOAD
4848 dhcp_status = &pAdapter->dhcp_status;
4849#endif /* DHCP_SERVER_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304850
Nirav Shah7e3c8132015-06-22 23:51:42 +05304851 spin_lock_init(&pAdapter->sta_hash_lock);
4852 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4853
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004854 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4855
Leo Chang0b0e45a2013-12-15 15:18:55 -08004856#ifdef FEATURE_WLAN_CH_AVOID
4857 /* Get unsafe cahnnel list from cached location */
4858 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4859 sizeof(unsafeChannelList),
4860 &unsafeChannelCount);
4861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4862 "%s : Unsafe Channel count %d",
4863 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304864 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004865 unsafeChannelList,
4866 unsafeChannelCount);
4867#endif /* FEATURE_WLAN_CH_AVOID */
4868
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 // Zero the memory. This zeros the profile structure.
4870 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05304871#ifdef DHCP_SERVER_OFFLOAD
4872 memset(dhcp_status, 0,sizeof(*dhcp_status));
4873#endif /* DHCP_SERVER_OFFLOAD */
4874
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 // Set up the pointer to the Wireless Extensions state structure
4876 // NOP
4877 status = hdd_set_hostapd(pAdapter);
4878 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 return status;
4881 }
4882
4883 status = vos_event_init(&phostapdBuf->vosEvent);
4884 if (!VOS_IS_STATUS_SUCCESS(status))
4885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 return status;
4888 }
Anurag Chouhan83026002016-12-13 22:46:21 +05304889#ifdef DHCP_SERVER_OFFLOAD
4890 status = vos_event_init(&dhcp_status->vos_event);
4891 if (!VOS_IS_STATUS_SUCCESS(status)) {
4892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
4893 return status;
4894 }
4895#endif /* DHCP_SERVER_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4897
4898 // Register as a wireless device
4899 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4900
4901 //Initialize the data path module
4902 status = hdd_softap_init_tx_rx(pAdapter);
4903 if ( !VOS_IS_STATUS_SUCCESS( status ))
4904 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004905 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304907
4908 status = hdd_wmm_adapter_init( pAdapter );
4909 if (!VOS_IS_STATUS_SUCCESS(status))
4910 {
4911 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004912 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304913 status, status );
4914 goto error_wmm_init;
4915 }
4916
4917 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
4918
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304919 pHddCtx->is_ap_mode_wow_supported =
4920 sme_IsFeatureSupportedByFW(SAP_MODE_WOW);
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05304921 return status;
4922
4923error_wmm_init:
4924 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 EXIT();
4926 return status;
4927}
4928
4929hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
4930{
4931 struct net_device *pWlanHostapdDev = NULL;
4932 hdd_adapter_t *pHostapdAdapter = NULL;
4933 v_CONTEXT_t pVosContext= NULL;
4934
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05304935 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
4936#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
4937 NET_NAME_UNKNOWN,
4938#endif
4939 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 if (pWlanHostapdDev != NULL)
4941 {
4942 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
4943
4944 //Init the net_device structure
4945 ether_setup(pWlanHostapdDev);
4946
4947 //Initialize the adapter context to zeros.
4948 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
4949 pHostapdAdapter->dev = pWlanHostapdDev;
4950 pHostapdAdapter->pHddCtx = pHddCtx;
4951 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
4952
4953 //Get the Global VOSS context.
4954 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
4955 //Save the adapter context in global context for future.
4956 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
4957
4958 //Init the net_device structure
4959 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
4960
4961 hdd_set_ap_ops( pHostapdAdapter->dev );
4962
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
4964 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
4965
4966 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
4967 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
4968
4969 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
4971 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
4972 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07004973
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
4975 }
4976 return pHostapdAdapter;
4977}
4978
4979VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
4980{
4981 struct net_device *dev = pAdapter->dev;
4982 VOS_STATUS status = VOS_STATUS_SUCCESS;
4983
4984 ENTER();
4985
4986 if( rtnl_lock_held )
4987 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08004988 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 if( dev_alloc_name(dev, dev->name) < 0 )
4990 {
4991 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
4992 return VOS_STATUS_E_FAILURE;
4993 }
4994 }
4995 if (register_netdevice(dev))
4996 {
4997 hddLog(VOS_TRACE_LEVEL_FATAL,
4998 "%s:Failed:register_netdevice", __func__);
4999 return VOS_STATUS_E_FAILURE;
5000 }
5001 }
5002 else
5003 {
5004 if (register_netdev(dev))
5005 {
5006 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5007 return VOS_STATUS_E_FAILURE;
5008 }
5009 }
5010 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5011
5012 EXIT();
5013 return status;
5014}
5015
c_hpothu002231a2015-02-05 14:58:51 +05305016VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005017{
5018 ENTER();
5019
5020 hdd_softap_deinit_tx_rx(pAdapter);
5021
5022 /* if we are being called during driver unload, then the dev has already
5023 been invalidated. if we are being called at other times, then we can
5024 detatch the wireless device handlers */
5025 if (pAdapter->dev)
5026 {
c_hpothu002231a2015-02-05 14:58:51 +05305027 if (TRUE == rtnl_held)
5028 {
5029 pAdapter->dev->wireless_handlers = NULL;
5030 }
5031 else
5032 {
5033 rtnl_lock();
5034 pAdapter->dev->wireless_handlers = NULL;
5035 rtnl_unlock();
5036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 }
5038 EXIT();
5039 return 0;
5040}