blob: 49801cf035885cdcc2f98f113d20e28ac7331b87 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashish6773c902017-01-06 19:45:03 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053082#include <wlan_hdd_wowl.h>
Agrawal Ashish17ef5082016-10-17 18:33:21 +053083#include "wlan_hdd_hostapd.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Leo Chang0b0e45a2013-12-15 15:18:55 -080085#ifdef FEATURE_WLAN_CH_AVOID
86#include "wcnss_wlan.h"
87#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053088#include "wlan_hdd_trace.h"
89#include "vos_types.h"
90#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080091
Jeff Johnson295189b2012-06-20 16:38:30 -070092#define IS_UP(_dev) \
93 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
94#define IS_UP_AUTO(_ic) \
95 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
96#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070097#define WE_GET_STA_INFO_SIZE 30
98/* WEXT limition: MAX allowed buf len for any *
99 * IW_PRIV_TYPE_CHAR is 2Kbytes *
100 */
101#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530103#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700104
Leo Chang0b0e45a2013-12-15 15:18:55 -0800105#ifdef FEATURE_WLAN_CH_AVOID
106/* Channle/Freqency table */
107extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
108safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
109{
110 /*CH , SAFE, default safe */
111 {1 , VOS_TRUE}, //RF_CHAN_1,
112 {2 , VOS_TRUE}, //RF_CHAN_2,
113 {3 , VOS_TRUE}, //RF_CHAN_3,
114 {4 , VOS_TRUE}, //RF_CHAN_4,
115 {5 , VOS_TRUE}, //RF_CHAN_5,
116 {6 , VOS_TRUE}, //RF_CHAN_6,
117 {7 , VOS_TRUE}, //RF_CHAN_7,
118 {8 , VOS_TRUE}, //RF_CHAN_8,
119 {9 , VOS_TRUE}, //RF_CHAN_9,
120 {10 , VOS_TRUE}, //RF_CHAN_10,
121 {11 , VOS_TRUE}, //RF_CHAN_11,
122 {12 , VOS_TRUE}, //RF_CHAN_12,
123 {13 , VOS_TRUE}, //RF_CHAN_13,
124 {14 , VOS_TRUE}, //RF_CHAN_14,
125 {240, VOS_TRUE}, //RF_CHAN_240,
126 {244, VOS_TRUE}, //RF_CHAN_244,
127 {248, VOS_TRUE}, //RF_CHAN_248,
128 {252, VOS_TRUE}, //RF_CHAN_252,
129 {208, VOS_TRUE}, //RF_CHAN_208,
130 {212, VOS_TRUE}, //RF_CHAN_212,
131 {216, VOS_TRUE}, //RF_CHAN_216,
132 {36 , VOS_TRUE}, //RF_CHAN_36,
133 {40 , VOS_TRUE}, //RF_CHAN_40,
134 {44 , VOS_TRUE}, //RF_CHAN_44,
135 {48 , VOS_TRUE}, //RF_CHAN_48,
136 {52 , VOS_TRUE}, //RF_CHAN_52,
137 {56 , VOS_TRUE}, //RF_CHAN_56,
138 {60 , VOS_TRUE}, //RF_CHAN_60,
139 {64 , VOS_TRUE}, //RF_CHAN_64,
140 {100, VOS_TRUE}, //RF_CHAN_100,
141 {104, VOS_TRUE}, //RF_CHAN_104,
142 {108, VOS_TRUE}, //RF_CHAN_108,
143 {112, VOS_TRUE}, //RF_CHAN_112,
144 {116, VOS_TRUE}, //RF_CHAN_116,
145 {120, VOS_TRUE}, //RF_CHAN_120,
146 {124, VOS_TRUE}, //RF_CHAN_124,
147 {128, VOS_TRUE}, //RF_CHAN_128,
148 {132, VOS_TRUE}, //RF_CHAN_132,
149 {136, VOS_TRUE}, //RF_CHAN_136,
150 {140, VOS_TRUE}, //RF_CHAN_140,
151 {149, VOS_TRUE}, //RF_CHAN_149,
152 {153, VOS_TRUE}, //RF_CHAN_153,
153 {157, VOS_TRUE}, //RF_CHAN_157,
154 {161, VOS_TRUE}, //RF_CHAN_161,
155 {165, VOS_TRUE}, //RF_CHAN_165,
156};
157#endif /* FEATURE_WLAN_CH_AVOID */
158
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530159/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 * Function definitions
161 *-------------------------------------------------------------------------*/
162/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530163
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530164 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 This is called in response to ifconfig up
167
168 \param - dev Pointer to net_device structure
169
170 \return - 0 for success non-zero for failure
171
172 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530173int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 ENTER();
178
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530179 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
180 {
181 //WMM_INIT OR BSS_START not completed
182 hddLog( LOGW, "Ignore hostadp open request");
183 EXIT();
184 return 0;
185 }
186
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530187 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
188 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 //Turn ON carrier state
190 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530191 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530192 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530194
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 EXIT();
196 return 0;
197}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530198
199int hdd_hostapd_open (struct net_device *dev)
200{
201 int ret;
202
203 vos_ssr_protect(__func__);
204 ret = __hdd_hostapd_open(dev);
205 vos_ssr_unprotect(__func__);
206
207 return ret;
208}
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210/**---------------------------------------------------------------------------
211
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530212 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214 This is called in response to ifconfig down
215
216 \param - dev Pointer to net_device structure
217
218 \return - 0 for success non-zero for failure
219
220 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530221int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700222{
223 ENTER();
224
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530225 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530226 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530227 //Stop all tx queues
228 netif_tx_disable(dev);
229
230 //Turn OFF carrier state
231 netif_carrier_off(dev);
232 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234 EXIT();
235 return 0;
236}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530237
238int hdd_hostapd_stop (struct net_device *dev)
239{
240 int ret;
241
242 vos_ssr_protect(__func__);
243 ret = __hdd_hostapd_stop(dev);
244 vos_ssr_unprotect(__func__);
245
246 return ret;
247}
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249/**---------------------------------------------------------------------------
250
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530251 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
253 This is called during the netdev unregister to uninitialize all data
254associated with the device
255
256 \param - dev Pointer to net_device structure
257
258 \return - void
259
260 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530261static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700262{
263 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530264 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 ENTER();
267
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530268 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530270 hddLog(VOS_TRACE_LEVEL_ERROR,
271 FL("Invalid magic"));
272 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530274 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
275 if (NULL == pHddCtx)
276 {
277 hddLog(VOS_TRACE_LEVEL_ERROR,
278 FL("NULL pHddCtx"));
279 return;
280 }
281
282 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
283
284 /* after uninit our adapter structure will no longer be valid */
285 pHostapdAdapter->dev = NULL;
286 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288 EXIT();
289}
290
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530291static void hdd_hostapd_uninit (struct net_device *dev)
292{
293 vos_ssr_protect(__func__);
294 __hdd_hostapd_uninit(dev);
295 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530297 return;
298}
Jeff Johnson295189b2012-06-20 16:38:30 -0700299/**============================================================================
300 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
301 transmitting packets. There are 2 versions of this function. One that uses
302 locked queue and other that uses lockless queues. Both have been retained to
303 do some performance testing
304 @param skb : [in] pointer to OS packet (sk_buff)
305 @param dev : [in] pointer to Libra network device
306
307 @return : NET_XMIT_DROP if packets are dropped
308 : NET_XMIT_SUCCESS if packet is enqueued succesfully
309 ===========================================================================*/
310int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
311{
312 return 0;
313}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530314
315int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700316{
317 return 0;
318}
319
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530320int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
321{
322 int ret;
323 vos_ssr_protect(__func__);
324 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
325 vos_ssr_unprotect(__func__);
326
327 return ret;
328}
329
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700330static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
331 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700333 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530334 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
335 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700336 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530337 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700338 /*
339 * Note that valid pointers are provided by caller
340 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530342 ENTER();
343
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700344 if (priv_data->total_len <= 0 ||
345 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
346 {
347 /* below we allocate one more byte for command buffer.
348 * To avoid addition overflow total_len should be
349 * smaller than INT_MAX. */
350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
351 __func__, priv_data->total_len);
352 ret = -EFAULT;
353 goto exit;
354 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530355 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 if (0 != status)
357 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530358 return status;
359 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700361 /* Allocate +1 for '\0' */
362 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
363 if (!command)
364 {
365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
366 ret = -ENOMEM;
367 goto exit;
368 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700369
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700370 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
371 {
372 ret = -EFAULT;
373 goto exit;
374 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800375
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700376 /* Make sure the command is NUL-terminated */
377 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700378
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700379 hddLog(VOS_TRACE_LEVEL_INFO,
380 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700382 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
383 {
384 hdd_setP2pNoa(pAdapter->dev, command);
385 }
386 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
387 {
388 hdd_setP2pOpps(pAdapter->dev, command);
389 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800390#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700391 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
392 {
393 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
394 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800395#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700396 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
397 {
398 /*
399 * command should be a string having format
400 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
401 */
402 hddLog(VOS_TRACE_LEVEL_INFO,
403 "%s: Received Command to Set Preferred Channels for SAP",
404 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800405
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700406 ret = sapSetPreferredChannel(command);
407 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530408 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
409 {
410 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
411 tANI_U8 filterType = 0;
412 tANI_U8 *value;
413 value = command + 9;
414
415 /* Convert the value from ascii to integer */
416 ret = kstrtou8(value, 10, &filterType);
417 if (ret < 0)
418 {
419 /* If the input value is greater than max value of datatype,
420 * then also kstrtou8 fails
421 */
422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
423 "%s: kstrtou8 failed range ", __func__);
424 ret = -EINVAL;
425 goto exit;
426 }
427 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
428 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
429 {
430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
431 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
432 " 2-Sink ", __func__);
433 ret = -EINVAL;
434 goto exit;
435 }
436 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
437 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530438 pScanInfo = &pHddCtx->scan_info;
439 if (filterType && pScanInfo != NULL &&
440 pHddCtx->scan_info.mScanPending)
441 {
442 /*Miracast Session started. Abort Scan */
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
444 "%s, Aborting Scan For Miracast",__func__);
445 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
446 eCSR_SCAN_ABORT_DEFAULT);
447 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530448 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
449 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
450 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530451 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
452 {
453 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
454 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700455
Jeff Johnson295189b2012-06-20 16:38:30 -0700456exit:
457 if (command)
458 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700459 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530461 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 return ret;
463}
464
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700465#ifdef CONFIG_COMPAT
466static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
467 struct ifreq *ifr)
468{
469 struct {
470 compat_uptr_t buf;
471 int used_len;
472 int total_len;
473 } compat_priv_data;
474 hdd_priv_data_t priv_data;
475 int ret = 0;
476
477 /*
478 * Note that pAdapter and ifr have already been verified by caller,
479 * and HDD context has also been validated
480 */
481 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
482 sizeof(compat_priv_data))) {
483 ret = -EFAULT;
484 goto exit;
485 }
486 priv_data.buf = compat_ptr(compat_priv_data.buf);
487 priv_data.used_len = compat_priv_data.used_len;
488 priv_data.total_len = compat_priv_data.total_len;
489 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
490 exit:
491 return ret;
492}
493#else /* CONFIG_COMPAT */
494static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
495 struct ifreq *ifr)
496{
497 /* will never be invoked */
498 return 0;
499}
500#endif /* CONFIG_COMPAT */
501
502static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
503{
504 hdd_priv_data_t priv_data;
505 int ret = 0;
506
507 /*
508 * Note that pAdapter and ifr have already been verified by caller,
509 * and HDD context has also been validated
510 */
511 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
512 ret = -EFAULT;
513 } else {
514 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
515 }
516 return ret;
517}
518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530519static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700520 struct ifreq *ifr, int cmd)
521{
522 hdd_adapter_t *pAdapter;
523 hdd_context_t *pHddCtx;
524 int ret;
525
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530526 ENTER();
527
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
529 if (NULL == pAdapter) {
530 hddLog(VOS_TRACE_LEVEL_ERROR,
531 "%s: HDD adapter context is Null", __func__);
532 ret = -ENODEV;
533 goto exit;
534 }
535 if (dev != pAdapter->dev) {
536 hddLog(VOS_TRACE_LEVEL_ERROR,
537 "%s: HDD adapter/dev inconsistency", __func__);
538 ret = -ENODEV;
539 goto exit;
540 }
541
542 if ((!ifr) || (!ifr->ifr_data)) {
543 ret = -EINVAL;
544 goto exit;
545 }
546
547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
548 ret = wlan_hdd_validate_context(pHddCtx);
549 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700550 ret = -EBUSY;
551 goto exit;
552 }
553
554 switch (cmd) {
555 case (SIOCDEVPRIVATE + 1):
556 if (is_compat_task())
557 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
558 else
559 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
560 break;
561 default:
562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
563 __func__, cmd);
564 ret = -EINVAL;
565 break;
566 }
567 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530568 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700569 return ret;
570}
571
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530572static int hdd_hostapd_ioctl(struct net_device *dev,
573 struct ifreq *ifr, int cmd)
574{
575 int ret;
576
577 vos_ssr_protect(__func__);
578 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
579 vos_ssr_unprotect(__func__);
580
581 return ret;
582}
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584/**---------------------------------------------------------------------------
585
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530586 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 This function sets the user specified mac address using
588 the command ifconfig wlanX hw ether <mac adress>.
589
590 \param - dev - Pointer to the net device.
591 - addr - Pointer to the sockaddr.
592 \return - 0 for success, non zero for failure
593
594 --------------------------------------------------------------------------*/
595
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530596static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700597{
598 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530599 hdd_adapter_t *pAdapter;
600 hdd_context_t *pHddCtx;
601 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530602
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
605 if (NULL == pAdapter)
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Adapter is NULL",__func__);
609 return -EINVAL;
610 }
611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
612 ret = wlan_hdd_validate_context(pHddCtx);
613 if (0 != ret)
614 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530615 return ret;
616 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
618 EXIT();
619 return 0;
620}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530621
622static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
623{
624 int ret;
625
626 vos_ssr_protect(__func__);
627 ret = __hdd_hostapd_set_mac_address(dev, addr);
628 vos_ssr_unprotect(__func__);
629
630 return ret;
631}
632
Jeff Johnson295189b2012-06-20 16:38:30 -0700633void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
634{
635 struct net_device *dev = (struct net_device *)usrDataForCallback;
636 v_BYTE_t we_custom_event[64];
637 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530639 hdd_context_t *pHddCtx;
640#ifdef DISABLE_CONCURRENCY_AUTOSAVE
641 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 hdd_ap_ctx_t *pHddApCtx;
643#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
644
645 /* event_name space-delimiter driver_module_name */
646 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
647 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
648 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
649
650 ENTER();
651
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530652 pHostapdAdapter = netdev_priv(dev);
653 if ((NULL == pHostapdAdapter) ||
654 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
655 {
656 hddLog(LOGE, FL("invalid adapter: %p"), pHostapdAdapter);
657 return;
658 }
659 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
660 if (0 != (wlan_hdd_validate_context(pHddCtx)))
661 {
662 return;
663 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530664#ifdef DISABLE_CONCURRENCY_AUTOSAVE
665 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530666 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 /*
668 This timer routine is going to be called only when AP
669 persona is up.
670 If there are concurrent sessions running we do not want
671 to shut down the Bss.Instead we run the timer again so
672 that if Autosave is enabled next time and other session
673 was down only then we bring down AP
674 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
676 vos_status = vos_timer_start(
677 &pHddApCtx->hdd_ap_inactivity_timer,
678 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
679 * 1000);
680 if (!VOS_IS_STATUS_SUCCESS(vos_status))
681 {
682 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
683 }
684 EXIT();
685 return;
686 }
687#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
688 memset(&we_custom_event, '\0', sizeof(we_custom_event));
689 memcpy(&we_custom_event, autoShutEvent, event_len);
690
691 memset(&wrqu, 0, sizeof(wrqu));
692 wrqu.data.length = event_len;
693
694 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
695 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
696
697 EXIT();
698}
699
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800700VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
701{
702 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
703 ptSapContext pSapCtx = NULL;
704 eHalStatus halStatus = eHAL_STATUS_FAILURE;
705 v_PVOID_t hHal = NULL;
706
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
708 "%s: UPDATE Beacon Params", __func__);
709
710 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
711 pSapCtx = VOS_GET_SAP_CB(pVosContext);
712 if ( NULL == pSapCtx )
713 {
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
715 "%s: Invalid SAP pointer from pvosGCtx", __func__);
716 return VOS_STATUS_E_FAULT;
717 }
718
719 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
720 if ( NULL == hHal ){
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
722 "%s: Invalid HAL pointer from pvosGCtx", __func__);
723 return VOS_STATUS_E_FAULT;
724 }
725 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
726 if(halStatus == eHAL_STATUS_FAILURE ){
727 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
728 "%s: Failed to update Beacon Params", __func__);
729 return VOS_STATUS_E_FAILURE;
730 }
731 }
732 return VOS_STATUS_SUCCESS;
733}
734
735void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
736{
737 v_U8_t staId = 0;
738 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530739 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
740 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800741
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530742 dev = (struct net_device *)usrDataForCallback;
743 pSapCtx = VOS_GET_SAP_CB(pVosContext);
744 if(pSapCtx == NULL){
745 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
746 FL("psapCtx is NULL"));
747 return;
748 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800749 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
751 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530752 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800753 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
754 {
755 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530756 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800757 }
758 }
759}
760
Agarwal Ashish8e538932014-12-24 18:12:52 +0530761static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762{
763 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530764 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800765 VOS_STATUS status = VOS_STATUS_SUCCESS;
766 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530767
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800768 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530769
770 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
771 status = wlan_hdd_validate_context(pHddCtx);
772
773 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530774 return status;
775 }
776
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800777 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
778 {
779 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
780 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800782 }
783 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530784 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800785 }
786 EXIT();
787 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
788}
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530790#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530791bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530792 bool enabled)
793{
794 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530795 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530796
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530797 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530798 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
799
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530800 sap_offload_info.sap_auth_offload_enable = enabled;
801 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530802 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530803 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530804 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
805
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530806 if (sap_offload_info.sap_auth_offload_enable &&
807 sap_offload_info.sap_auth_offload_sec_type)
808 {
809 if (sap_offload_info.key_len < 8 ||
810 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
811 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530812 hddLog(VOS_TRACE_LEVEL_ERROR,
813 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530814 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530815 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530816 }
817 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530818 if (sap_offload_info.key_len)
819 {
820 vos_mem_copy(sap_offload_info.key,
821 pHddCtx->cfg_ini->sap_auth_offload_key,
822 sap_offload_info.key_len);
823 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530824 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530825 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
826 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530827 hddLog(VOS_TRACE_LEVEL_ERROR,
828 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530829 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530830 }
831
832 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
833 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530834 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530835}
836#endif
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
839{
840 hdd_adapter_t *pHostapdAdapter;
841 hdd_ap_ctx_t *pHddApCtx;
842 hdd_hostapd_state_t *pHostapdState;
843 struct net_device *dev;
844 eSapHddEvent sapEvent;
845 union iwreq_data wrqu;
846 v_BYTE_t *we_custom_event_generic = NULL;
847 int we_event = 0;
848 int i = 0;
849 v_U8_t staId;
850 VOS_STATUS vos_status;
851 v_BOOL_t bWPSState;
852 v_BOOL_t bApActive = FALSE;
853 v_BOOL_t bAuthRequired = TRUE;
854 tpSap_AssocMacAddr pAssocStasArray = NULL;
855 char unknownSTAEvent[IW_CUSTOM_MAX+1];
856 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
857 v_BYTE_t we_custom_start_event[64];
858 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800859 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800860 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700861 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530862 v_CONTEXT_t pVosContext = NULL;
863 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +0530864 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
866 dev = (struct net_device *)usrDataForCallback;
867 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530868
869 if ((NULL == pHostapdAdapter) ||
870 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
871 {
872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
873 "invalid adapter or adapter has invalid magic");
874 return eHAL_STATUS_FAILURE;
875 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530876 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
877 pSapCtx = VOS_GET_SAP_CB(pVosContext);
878 if(pSapCtx == NULL){
879 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
880 FL("psapCtx is NULL"));
881 return eHAL_STATUS_FAILURE;
882 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
884 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
885 sapEvent = pSapEvent->sapHddEventCode;
886 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800887 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +0530888 cfg_param = pHddCtx->cfg_ini;
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890
891 switch(sapEvent)
892 {
893 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800894 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
896 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
897 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
898
899 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
900 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +0530901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +0530903 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 goto stopbss;
906 }
907 else
Deepthi Gowried085092015-10-20 19:30:52 +0530908 {
909 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
910 {
911 if ((cfg_param->dynSplitscan) &&
912 (!pHddCtx->issplitscan_enabled))
913 {
914 pHddCtx->issplitscan_enabled = TRUE;
915 sme_enable_disable_split_scan(
916 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
917 cfg_param->nNumStaChanCombinedConc,
918 cfg_param->nNumP2PChanCombinedConc);
919 }
920 }
921
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
923 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +0530924 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
925 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +0530926 {
c_hpothuffdb5272013-10-02 16:42:35 +0530927 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +0530928 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 }
Deepthi Gowried085092015-10-20 19:30:52 +0530931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
933 {
934 // AP Inactivity timer init and start
935 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
936 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
937 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800938 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939
940 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
941 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800942 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 }
945 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
946 pHostapdState->bssState = BSS_START;
947
948 // Send current operating channel of SoftAP to BTC-ES
949 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
950
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 //Check if there is any group key pending to set.
952 if( pHddApCtx->groupKey.keyLength )
953 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700954 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
956 &pHddApCtx->groupKey ) )
957 {
958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 "%s: WLANSAP_SetKeySta failed", __func__);
960 }
961 pHddApCtx->groupKey.keyLength = 0;
962 }
963 else if ( pHddApCtx->wepKey[0].keyLength )
964 {
965 int i=0;
966 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
967 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700968 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
970 &pHddApCtx->wepKey[i] ) )
971 {
972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
973 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
974 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
976 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
978 startBssEvent = "SOFTAP.enabled";
979 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
980 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
981 memset(&wrqu, 0, sizeof(wrqu));
982 wrqu.data.length = strlen(startBssEvent);
983 we_event = IWEVCUSTOM;
984 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700985 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 break; //Event will be sent after Switch-Case stmt
987
988 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800989 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
991
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530992#ifdef SAP_AUTH_OFFLOAD
993 if (cfg_param->enable_sap_auth_offload)
994 hdd_set_sap_auth_offload(pHostapdAdapter, FALSE);
995#endif
996
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700997 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700998 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301001
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301002 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301003 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301004 hddLog(LOG1,
1005 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1006 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301007 }
1008
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 goto stopbss;
1010 case eSAP_STA_SET_KEY_EVENT:
1011 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001012 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1014 return VOS_STATUS_SUCCESS;
1015 case eSAP_STA_DEL_KEY_EVENT:
1016 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001017 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 return VOS_STATUS_SUCCESS;
1019 case eSAP_STA_MIC_FAILURE_EVENT:
1020 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 memset(&msg, '\0', sizeof(msg));
1022 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001023 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001024 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001025 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 msg.flags = IW_MICFAILURE_GROUP;
1027 else
1028 msg.flags = IW_MICFAILURE_PAIRWISE;
1029 memset(&wrqu, 0, sizeof(wrqu));
1030 wrqu.data.length = sizeof(msg);
1031 we_event = IWEVMICHAELMICFAILURE;
1032 we_custom_event_generic = (v_BYTE_t *)&msg;
1033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 /* inform mic failure to nl80211 */
1035 cfg80211_michael_mic_failure(dev,
1036 pSapEvent->sapevt.
1037 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001038 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 NL80211_KEYTYPE_GROUP :
1040 NL80211_KEYTYPE_PAIRWISE),
1041 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1042 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1043 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 break;
1045
1046 case eSAP_STA_ASSOC_EVENT:
1047 case eSAP_STA_REASSOC_EVENT:
1048 wrqu.addr.sa_family = ARPHRD_ETHER;
1049 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001050 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001051 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 we_event = IWEVREGISTERED;
1053
1054 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1055
1056 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1057 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1058 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1059 {
1060 bAuthRequired = FALSE;
1061 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301062 /* fAuthRequiredshould should be false for sap offload */
1063 if ((bAuthRequired || bWPSState)
1064#ifdef SAP_AUTH_OFFLOAD
1065 && !cfg_param->enable_sap_auth_offload
1066#endif
1067 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 {
c_hpothuffdb5272013-10-02 16:42:35 +05301069 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 TRUE,
1071 pHddApCtx->uPrivacy,
1072 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1073 0,
1074 0,
1075 (v_MACADDR_t *)wrqu.addr.sa_data,
1076 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301077
1078 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1079 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1080 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 }
1082 else
1083 {
c_hpothuffdb5272013-10-02 16:42:35 +05301084 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 FALSE,
1086 pHddApCtx->uPrivacy,
1087 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1088 0,
1089 0,
1090 (v_MACADDR_t *)wrqu.addr.sa_data,
1091 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301092 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1093 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1094 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001095 }
1096
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301097 staId =
1098 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1099 if (VOS_IS_STATUS_SUCCESS(vos_status))
1100 {
1101
1102 pSapCtx->aStaInfo[staId].rate_flags =
1103 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1104 }
1105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 // Stop AP inactivity timer
1107 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1108 {
1109 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1110 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001111 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001113#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001114 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1115 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301116 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1117 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001118 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301119 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1120 HDD_SAP_WAKE_LOCK_DURATION,
1121 WIFI_POWER_EVENT_WAKELOCK_SAP);
1122
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001123#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1125 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301126 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1128
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301129 staInfo = vos_mem_malloc(sizeof(*staInfo));
1130 if (staInfo == NULL) {
1131 hddLog(LOGE, FL("alloc station_info failed"));
1132 return VOS_STATUS_E_NOMEM;
1133 }
1134
1135 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1137 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301138 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301140 staInfo->assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001141#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301142 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001143#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 cfg80211_new_sta(dev,
1145 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301146 staInfo, GFP_KERNEL);
1147 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 }
1149 else
1150 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001151 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001152 }
1153 }
1154#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301155 hdd_manage_delack_timer(pHddCtx);
1156
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001157 pScanInfo = &pHddCtx->scan_info;
1158 // Lets do abort scan to ensure smooth authentication for client
1159 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1160 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301161 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301162 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001164
1165 break;
1166 case eSAP_STA_DISASSOC_EVENT:
1167 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001168 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001169 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1171 hddLog(LOG1," User initiated disassociation");
1172 else
1173 hddLog(LOG1," MAC initiated disassociation");
1174 we_event = IWEVEXPIRED;
1175 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1176 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1177 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 return VOS_STATUS_E_FAILURE;
1180 }
1181 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1182
1183 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1184 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301185 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 // Start AP inactivity timer if no stations associated with it
1187 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1188 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301189 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 {
1191 bApActive = TRUE;
1192 break;
1193 }
1194 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301195 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001196
1197 if (bApActive == FALSE)
1198 {
1199 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1200 {
1201 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1202 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001203 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 }
1205 else
1206 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1207 }
1208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001209#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1210 cfg80211_del_sta(dev,
1211 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1212 GFP_KERNEL);
1213#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001214 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301215 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1216 if (VOS_STATUS_SUCCESS != vos_status)
1217 {
1218 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1219 __func__, vos_status);
1220 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301221 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 break;
1223 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1224 {
1225 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1226 union iwreq_data wreq;
1227
1228 down(&pHddApCtx->semWpsPBCOverlapInd);
1229 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1230
1231 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1232 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1233
1234 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001235 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 memset(&wreq, 0, sizeof(wreq));
1237 wreq.data.length = strlen(message); // This is length of message
1238 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1239
1240 return VOS_STATUS_SUCCESS;
1241 }
1242 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1243 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1244 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1245 { // List of associated stations
1246 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1247 {
1248 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1249 i+1,
1250 pAssocStasArray->assocId,
1251 pAssocStasArray->staId,
1252 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1253 pAssocStasArray++;
1254 }
1255 }
1256 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001257 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 case eSAP_REMAIN_CHAN_READY:
1260 hdd_remainChanReadyHandler( pHostapdAdapter );
1261 return VOS_STATUS_SUCCESS;
1262 case eSAP_SEND_ACTION_CNF:
1263 hdd_sendActionCnf( pHostapdAdapter,
1264 ( eSAP_STATUS_SUCCESS ==
1265 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1266 TRUE : FALSE );
1267 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 case eSAP_UNKNOWN_STA_JOIN:
1269 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1270 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1271 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1272 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1273 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1274 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1275 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1276 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1277 wrqu.data.pointer = unknownSTAEvent;
1278 wrqu.data.length = strlen(unknownSTAEvent);
1279 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301280 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 break;
1282
1283 case eSAP_MAX_ASSOC_EXCEEDED:
1284 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1285 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1286 " one or more devices to enable the new device connection",
1287 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1288 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1289 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1290 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1291 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1292 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1293 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1294 wrqu.data.pointer = maxAssocExceededEvent;
1295 wrqu.data.length = strlen(maxAssocExceededEvent);
1296 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001297 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 break;
1299 case eSAP_STA_ASSOC_IND:
1300 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001301
1302 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001303 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001304 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1305 return VOS_STATUS_SUCCESS;
1306
1307 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301308 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301309 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1310 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301311 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301312 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001313 return VOS_STATUS_SUCCESS;
1314
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001316 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 goto stopbss;
1318 return VOS_STATUS_SUCCESS;
1319 }
1320 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1321 return VOS_STATUS_SUCCESS;
1322
1323stopbss :
1324 {
1325 v_BYTE_t we_custom_event[64];
1326 char *stopBssEvent = "STOP-BSS.response";//17
1327 int event_len = strlen(stopBssEvent);
1328
1329 hddLog(LOG1, FL("BSS stop status = %s"),
1330 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1331 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1332
1333 /* Change the BSS state now since, as we are shutting things down,
1334 * we don't want interfaces to become re-enabled */
1335 pHostapdState->bssState = BSS_STOP;
1336
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301337 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1338 {
1339 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1340 {
1341 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1342 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1343 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1344 }
1345
1346 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1347 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1348 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1349 }
1350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 /* Stop the pkts from n/w stack as we are going to free all of
1352 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301353
1354 /*
1355 * If channel avoidance is in progress means driver is performing SAP
1356 * restart. So don't do carrier off, which may lead framework to do
1357 * driver reload.
1358 */
1359 hddLog(LOG1, FL("ch avoid in progress: %d"),
1360 pHddCtx->is_ch_avoid_in_progress);
1361 if (pHddCtx->is_ch_avoid_in_progress &&
1362 pHddCtx->cfg_ini->sap_restrt_ch_avoid)
1363 netif_tx_disable(dev);
1364 else
1365 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001366
1367 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301368 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1369 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1370 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001371
Amar Singhal37e6f052013-03-05 16:16:54 -08001372 /* once the event is set, structure dev/pHostapdAdapter should
1373 * not be touched since they are now subject to being deleted
1374 * by another thread */
1375 if (eSAP_STOP_BSS_EVENT == sapEvent)
1376 vos_event_set(&pHostapdState->vosEvent);
1377
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 /* notify userspace that the BSS has stopped */
1379 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1380 memcpy(&we_custom_event, stopBssEvent, event_len);
1381 memset(&wrqu, 0, sizeof(wrqu));
1382 wrqu.data.length = event_len;
1383 we_event = IWEVCUSTOM;
1384 we_custom_event_generic = we_custom_event;
1385 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001386 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 }
1388 return VOS_STATUS_SUCCESS;
1389}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001390
1391int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001393 eCsrEncryptionType *pEncryptType,
1394 eCsrEncryptionType *mcEncryptType,
1395 eCsrAuthType *pAuthType,
1396 v_BOOL_t *pMFPCapable,
1397 v_BOOL_t *pMFPRequired,
1398 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 u_int8_t *gen_ie )
1400{
1401 tDot11fIERSN dot11RSNIE;
1402 tDot11fIEWPA dot11WPAIE;
1403
1404 tANI_U8 *pRsnIe;
1405 tANI_U16 RSNIeLen;
1406
1407 if (NULL == halHandle)
1408 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001409 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 return -EINVAL;
1411 }
1412
1413 // Validity checks
1414 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1415 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1416 return -EINVAL;
1417 // Type check
1418 if ( gen_ie[0] == DOT11F_EID_RSN)
1419 {
1420 // Validity checks
1421 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1422 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1423 {
1424 return VOS_STATUS_E_FAILURE;
1425 }
1426 // Skip past the EID byte and length byte
1427 pRsnIe = gen_ie + 2;
1428 RSNIeLen = gen_ie_len - 2;
1429 // Unpack the RSN IE
1430 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1431 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1432 pRsnIe,
1433 RSNIeLen,
1434 &dot11RSNIE);
1435 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001436 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001437 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001438 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001439 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 /*Here we have followed the apple base code,
1441 but probably I suspect we can do something different*/
1442 //dot11RSNIE.akm_suite_count
1443 // Just translate the FIRST one
1444 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1445 //dot11RSNIE.pwise_cipher_suite_count
1446 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1447 //dot11RSNIE.gp_cipher_suite_count
1448 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1449 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001450 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1451 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001452
1453 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1454 } else
1455 if (gen_ie[0] == DOT11F_EID_WPA)
1456 {
1457 // Validity checks
1458 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1459 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1460 {
1461 return VOS_STATUS_E_FAILURE;
1462 }
1463 // Skip past the EID byte and length byte - and four byte WiFi OUI
1464 pRsnIe = gen_ie + 2 + 4;
1465 RSNIeLen = gen_ie_len - (2 + 4);
1466 // Unpack the WPA IE
1467 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1468 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1469 pRsnIe,
1470 RSNIeLen,
1471 &dot11WPAIE);
1472 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001473 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001474 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001475 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001476 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 //dot11WPAIE.auth_suite_count
1478 // Just translate the FIRST one
1479 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1480 //dot11WPAIE.unicast_cipher_count
1481 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1482 //dot11WPAIE.unicast_cipher_count
1483 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001484 *pMFPCapable = VOS_FALSE;
1485 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 }
1487 else
1488 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001489 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 return VOS_STATUS_E_FAILURE;
1491 }
1492 return VOS_STATUS_SUCCESS;
1493}
Leo Chang614d2072013-08-22 14:59:44 -07001494
Leo Chang0b0e45a2013-12-15 15:18:55 -08001495#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001496
1497/*==========================================================================
1498 FUNCTION sapUpdateUnsafeChannelList
1499
1500 DESCRIPTION
1501 Function Undate unsafe channel list table
1502
1503 DEPENDENCIES
1504 NA.
1505
1506 PARAMETERS
1507
1508 IN
1509 pSapCtx : SAP context pointer, include unsafe channel list
1510
1511 RETURN VALUE
1512 NONE
1513============================================================================*/
1514void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1515 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1516{
1517 v_U16_t i, j;
1518
1519 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1520 sizeof(pHddCtx->unsafeChannelList));
1521 if (0 == unsafeChannelCount)
1522 {
1523 pHddCtx->unsafeChannelCount = 0;
1524 }
1525 else
1526 {
c_hpothu8de53e42014-08-22 15:00:37 +05301527 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1528 {
1529 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1530 FL("unsafeChannelCount%hd greater than %d"),
1531 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1532 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1533 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001534 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1535 unsafeChannelList,
1536 unsafeChannelCount * sizeof(tANI_U16));
1537 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1538 }
1539
1540 /* Flush, default set all channel safe */
1541 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1542 {
1543 safeChannels[i].isSafe = VOS_TRUE;
1544 }
1545
1546 /* Try to find unsafe channel */
1547 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1548 {
1549 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1550 {
1551 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1552 {
1553 /* Found unsafe channel, update it */
1554 safeChannels[j].isSafe = VOS_FALSE;
1555 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1556 "%s : CH %d is not safe",
1557 __func__, pHddCtx->unsafeChannelList[i]);
1558 break;
1559 }
1560 }
1561 }
1562
1563 return;
1564}
1565
Kapil Gupta137ef892016-12-13 19:38:00 +05301566/**
1567 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1568 * @adapter: hdd ap adapter
1569 *
1570 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1571 * and if ACS is enabled, driver will ask userspace to restart the
1572 * sap. User space on LTE coex indication restart driver.
1573 *
1574 * Return - none
1575 */
1576static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1577 hdd_context_t *hdd_ctx)
1578{
1579
1580 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1581 return;
1582 }
1583
1584 hddLog(LOG1, FL("Current operation channel %d"),
1585 adapter->sessionCtx.ap.operatingChannel);
1586 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1587 hdd_change_ch_avoidance_status(hdd_ctx, true);
1588
1589 vos_flush_work(
1590 &hdd_ctx->sap_start_work);
1591
1592 /*
1593 * current operating channel
1594 * is un-safe channel, restart SAP
1595 */
1596 hddLog(LOG1,
1597 FL("Restarting SAP due to unsafe channel"));
1598
1599 adapter->sessionCtx.ap.sapConfig.channel =
1600 AUTO_CHANNEL_SELECT;
1601
Kapil Gupta137ef892016-12-13 19:38:00 +05301602
Kapil Gupta0afd1912016-12-28 12:52:13 +05301603 if (hdd_ctx->cfg_ini->sap_restrt_ch_avoid) {
1604 netif_tx_disable(adapter->dev);
1605 schedule_work(&hdd_ctx->sap_start_work);
1606 } else {
1607 hdd_hostapd_stop(adapter->dev);
1608 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301609
1610 return;
1611 }
1612 return;
1613}
1614
1615
Leo Chang0b0e45a2013-12-15 15:18:55 -08001616/**---------------------------------------------------------------------------
1617
1618 \brief hdd_hostapd_ch_avoid_cb() -
1619
1620 Avoid channel notification from FW handler.
1621 FW will send un-safe channle list to avoid overwrapping.
1622 hostapd should not use notified channel
1623
1624 \param - pAdapter HDD adapter pointer
1625 indParam channel avoid notification parameter
1626
1627 \return - None
1628
1629 --------------------------------------------------------------------------*/
1630void hdd_hostapd_ch_avoid_cb
1631(
Kapil Gupta137ef892016-12-13 19:38:00 +05301632 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08001633 void *indParam
1634)
1635{
1636 hdd_adapter_t *pHostapdAdapter = NULL;
1637 hdd_context_t *hddCtxt;
1638 tSirChAvoidIndType *chAvoidInd;
1639 v_U8_t rangeLoop;
1640 v_U16_t channelLoop;
1641 v_U16_t dupCheck;
1642 v_U16_t startChannel;
1643 v_U16_t endChannel;
1644 v_U16_t unsafeChannelCount = 0;
1645 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1646 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001647 tHddAvoidFreqList hddAvoidFreqList;
1648 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301649#ifdef WLAN_FEATURE_AP_HT40_24G
1650 ptSapContext pSapCtx = NULL;
1651 tHalHandle hHal;
1652 v_U8_t cbMode;
1653 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1654 v_U32_t delay;
1655#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001656
1657 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05301658 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001659 {
1660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1661 "%s : Invalid arguments", __func__);
1662 return;
1663 }
1664
Kapil Gupta137ef892016-12-13 19:38:00 +05301665 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001666 chAvoidInd = (tSirChAvoidIndType *)indParam;
1667 pVosContext = hddCtxt->pvosContext;
1668
1669 /* Make unsafe channel list */
1670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1671 "%s : band count %d",
1672 __func__, chAvoidInd->avoidRangeCount);
1673 vos_mem_zero((void *)unsafeChannelList,
1674 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1675 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1676 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301677 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1678 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1679 break;
1680 }
1681 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001682 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301683 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001684 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1686 "%s : start %d : %d, end %d : %d",
1687 __func__,
1688 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1689 startChannel,
1690 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1691 endChannel);
1692 for (channelLoop = startChannel;
1693 channelLoop < (endChannel + 1);
1694 channelLoop++)
1695 {
1696 /* Channel duplicate check routine */
1697 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1698 {
1699 if (unsafeChannelList[dupCheck] == channelLoop)
1700 {
1701 /* This channel is duplicated */
1702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1703 "%s : found duplicated channel %d",
1704 __func__, channelLoop);
1705 break;
1706 }
1707 }
1708 if (dupCheck == unsafeChannelCount)
1709 {
c_hpothu8de53e42014-08-22 15:00:37 +05301710 int ii;
1711 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1712 {
1713 if (channelLoop == safeChannels[ii].channelNumber)
1714 {
1715 unsafeChannelList[unsafeChannelCount] = channelLoop;
1716 unsafeChannelCount++;
1717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1718 "%s : unsafe channel %d, count %d",
1719 __func__,
1720 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301721 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1722 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1723 break;
1724 }
c_hpothu8de53e42014-08-22 15:00:37 +05301725 }
1726 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001727 }
1728 else
1729 {
1730 /* DUP, do nothing */
1731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1732 "%s : duplicated channel %d",
1733 __func__, channelLoop);
1734 }
1735 }
1736 }
1737 /* Update unsafe channel cache
1738 * WCN Platform Driver cache */
1739 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1740 unsafeChannelCount);
1741
1742 /* Store into local cache
1743 * Start with STA and later start SAP
1744 * in this scenario, local cache will be used */
1745 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1746 unsafeChannelList,
1747 unsafeChannelCount);
1748
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001749 /* generate vendor specific event */
1750 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1751 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1752 {
1753 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1754 chAvoidInd->avoidFreqRange[i].startFreq;
1755 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1756 chAvoidInd->avoidFreqRange[i].endFreq;
1757 }
1758 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1759
1760 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1761
Leo Chang0b0e45a2013-12-15 15:18:55 -08001762 /* Get SAP context first
1763 * SAP and P2PGO would not concurrent */
1764 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301765#ifdef WLAN_FEATURE_AP_HT40_24G
1766 if (NULL == pHostapdAdapter)
1767 {
1768 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1769 }
1770#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301771 if ((pHostapdAdapter) &&
1772 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1773 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001774 {
1775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1776 "%s : Current operation channel %d",
1777 __func__,
1778 pHostapdAdapter->sessionCtx.ap.operatingChannel);
1779 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1780 {
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301781 if ((unsafeChannelList[channelLoop] ==
1782 pHostapdAdapter->sessionCtx.ap.operatingChannel))
1783 {
1784 if ((AUTO_CHANNEL_SELECT ==
1785 pHostapdAdapter->sessionCtx.ap.sapConfig.channel)
1786 && (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode))
1787 {
1788 /* current operating channel is un-safe channel
1789 * restart driver */
Kapil Gupta137ef892016-12-13 19:38:00 +05301790 hdd_unsafe_channel_restart_sap(pHostapdAdapter, hddCtxt);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301791 /* On LE, this event is handled by wlan-services to
1792 * restart SAP. On android, this event would be
1793 * ignored.
1794 */
1795 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1796 NULL, 0);
1797 }
1798 return;
1799 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001800 }
1801 }
1802
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301803#ifdef WLAN_FEATURE_AP_HT40_24G
1804 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1805 {
1806 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1807
1808 if(pSapCtx == NULL)
1809 {
1810 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
1811 FL("psapCtx is NULL"));
1812 return;
1813 }
1814
1815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1816 FL("SAP Secondary channel: %d "),
1817 pSapCtx->sap_sec_chan);
1818
1819 /* tHalHandle */
1820 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1821
1822 if (NULL == hHal)
1823 {
1824 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1825 FL("In invalid hHal"));
1826 return;
1827 }
1828
1829 cbMode = sme_GetChannelBondingMode24G(hHal);
1830
1831 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1832 FL("Selected Channel bonding : %d"), cbMode);
1833
1834 if (cbMode && (pSapCtx->sap_sec_chan > 0))
1835 {
1836 int i;
1837 eHalStatus halStatus;
1838
1839 for (i = 0; i < unsafeChannelCount; i++)
1840 {
1841 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
1842 {
1843 /* Current SAP Secondary channel is un-safe channel */
1844 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1845 FL("Move SAP from HT40 to HT20"));
1846
1847 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
1848 PHY_SINGLE_CHANNEL_CENTERED);
1849
1850 if (halStatus == eHAL_STATUS_FAILURE)
1851 {
1852 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1853 FL("Failed to change HT20/40 mode"));
1854 return;
1855 }
1856
1857 /* Disable Channel Bonding for 2.4GHz */
1858 sme_UpdateChannelBondingMode24G(hHal,
1859 PHY_SINGLE_CHANNEL_CENTERED);
1860 return;
1861 }
1862 }
1863 }
1864
1865 if ((!pSapCtx->numHT40IntoSta)
1866 && (pHostapdAdapter)
1867 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
1868 {
1869 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
1870 * are Safe then start HT20/40 timer to Move SAP from HT20
1871 * to HT40.
1872 */
1873 if (((!unsafeChannelCount)
1874 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
1875 {
1876 /* Stop Previous Running HT20/40 Timer & Start timer
1877 with (OBSS TransitionDelayFactor * obss interval)
1878 delay after time out move AP from HT20 -> HT40
1879 mode
1880 */
1881 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1882 {
1883 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1884 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1885 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1886 FL("Failed to Stop HT20/40 timer"));
1887 }
1888
1889 delay =
1890 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
1891
1892 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1893 FL("Start HT20/40 transition timer (%d sec)"), delay);
1894
1895 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
1896 (delay * 1000));
1897
1898 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1899 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1900 FL("Failed to Start HT20/40 timer"));
1901 }
1902 else
1903 {
1904 /* Stop HT20/40 Timer */
1905 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
1906 {
1907 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1908 FL("Stop HT20/40 transition timer"));
1909 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
1910 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
1911 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1912 FL("Failed to Stop HT20/40 timer"));
1913 }
1914 }
1915 }
1916 }
1917#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001918 return;
1919}
Leo Chang0b0e45a2013-12-15 15:18:55 -08001920#endif /* FEATURE_WLAN_CH_AVOID */
1921
Jeff Johnson295189b2012-06-20 16:38:30 -07001922int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05301923static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 struct iw_request_info *info,
1925 union iwreq_data *wrqu, char *extra)
1926{
1927 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001928 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301929 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 int *value = (int *)extra;
1931 int sub_cmd = value[0];
1932 int set_value = value[1];
1933 eHalStatus status;
1934 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05301935 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001936 v_CONTEXT_t pVosContext;
1937
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301938 ENTER();
1939
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301940 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001941 {
1942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301943 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001944 __func__);
1945 return -1;
1946 }
1947
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301948 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
1949 ret = wlan_hdd_validate_context(pHddCtx);
1950 if (0 != ret)
1951 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05301952 return -1;
1953 }
1954
Rajesh Chauhana0516c62014-01-30 16:11:18 -08001955 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1956 if (!hHal)
1957 {
1958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1959 "%s: Hal ctx is null", __func__);
1960 return -1;
1961 }
1962
1963 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1964 if (!pVosContext)
1965 {
1966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1967 "%s: Vos ctx is null", __func__);
1968 return -1;
1969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
1971 switch(sub_cmd)
1972 {
1973
1974 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001975 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301977 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 }
1979 break;
1980
1981 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301982 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1984 {
1985 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1986 ret = -EINVAL;
1987 }
1988 else
1989 {
1990 WLANSAP_SetMode(pVosContext, set_value);
1991 }
1992 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05301993
1994 case QCSAP_PARAM_SET_AUTO_CHANNEL:
1995 if ((0 != set_value) && (1 != set_value))
1996 {
1997 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
1998 ret = -EINVAL;
1999 }
2000 else
2001 {
2002 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2003 }
2004 break;
2005
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 case QCSAP_PARAM_MAX_ASSOC:
2007 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2008 {
2009 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2010 ret = -EINVAL;
2011 }
2012 else
2013 {
2014 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2015 {
2016 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2017 "Setting it to max allowed and continuing"),
2018 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2019 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2020 }
2021 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2022 set_value, NULL, eANI_BOOLEAN_FALSE);
2023 if ( status != eHAL_STATUS_SUCCESS )
2024 {
2025 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2026 status);
2027 ret = -EIO;
2028 }
2029 }
2030 break;
2031
2032 case QCSAP_PARAM_HIDE_SSID:
2033 {
2034 eHalStatus status = eHAL_STATUS_SUCCESS;
2035 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2036 if(eHAL_STATUS_SUCCESS != status)
2037 {
2038 hddLog(VOS_TRACE_LEVEL_ERROR,
2039 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002040 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 return status;
2042 }
2043 break;
2044 }
2045
Leo Chang614d2072013-08-22 14:59:44 -07002046 case QCSAP_PARAM_SET_MC_RATE:
2047 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002048 tSirRateUpdateInd *rateUpdate;
2049
2050 rateUpdate = (tSirRateUpdateInd *)
2051 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2052 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002053 {
2054 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002055 "%s: SET_MC_RATE indication alloc fail", __func__);
2056 ret = -1;
2057 break;
2058 }
2059 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2060
2061 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2062 /* Ignore unicast */
2063 rateUpdate->ucastDataRate = -1;
2064 rateUpdate->mcastDataRate24GHz = set_value;
2065 rateUpdate->mcastDataRate5GHz = set_value;
2066 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2067 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2068 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2069 if (eHAL_STATUS_SUCCESS != status)
2070 {
2071 hddLog(VOS_TRACE_LEVEL_ERROR,
2072 "%s: SET_MC_RATE failed", __func__);
2073 vos_mem_free(rateUpdate);
2074 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002075 }
2076 break;
2077 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302078 case QCSAP_PARAM_GET_FRAME_LOGS:
2079 {
2080 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2081 != VOS_STATUS_SUCCESS)
2082 {
2083 ret = -EINVAL;
2084 }
2085 break;
2086 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302087 case QCSAP_PARAM_SET_PROXIMITY:
2088 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302089 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302090 break;
2091 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302092 case QCSAP_PARAM_SET_WOWL:
2093 {
2094 if (!pHddCtx->is_ap_mode_wow_supported)
2095 {
2096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2097 "%s: Not supported",__func__);
2098 return -ENOTSUPP;
2099 }
2100 switch (set_value)
2101 {
2102 case 0x00:
2103 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2104 break;
2105 case 0x01:
2106 case 0x02:
2107 case 0x03:
2108 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2109 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2110 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2111 (enable_magic_pkt ? "YES":"NO"),
2112 (enable_pattrn_byte_match ? "YES":"NO"));
2113 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2114 enable_pattrn_byte_match);
2115 break;
2116 default:
2117 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2118 ret = -EINVAL;
2119 break;
2120 }
2121 break;
2122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 default:
2124 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2125 sub_cmd, set_value);
2126 ret = -EINVAL;
2127 break;
2128 }
2129
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302130 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 return ret;
2132}
2133
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302134int
2135static iw_softap_setparam(struct net_device *dev,
2136 struct iw_request_info *info,
2137 union iwreq_data *wrqu, char *extra)
2138{
2139 int ret;
2140
2141 vos_ssr_protect(__func__);
2142 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2143 vos_ssr_unprotect(__func__);
2144
2145 return ret;
2146}
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302149static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 struct iw_request_info *info,
2151 union iwreq_data *wrqu, char *extra)
2152{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302153 hdd_adapter_t *pHostapdAdapter;
2154 tHalHandle hHal;
2155 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 int *value = (int *)extra;
2157 int sub_cmd = value[0];
2158 eHalStatus status;
2159 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302160 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002161
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302162 ENTER();
2163
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302164 pHostapdAdapter = (netdev_priv(dev));
2165 if (NULL == pHostapdAdapter)
2166 {
2167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2168 "%s: Adapter is NULL",__func__);
2169 return -EINVAL;
2170 }
2171 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2172 ret = wlan_hdd_validate_context(pHddCtx);
2173 if (0 != ret)
2174 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302175 return ret;
2176 }
2177 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2178 if (NULL == hHal)
2179 {
2180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2181 "%s: Hal Context is NULL",__func__);
2182 return -EINVAL;
2183 }
2184 pVosContext = pHddCtx->pvosContext;
2185 if (NULL == pVosContext)
2186 {
2187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2188 "%s: pVosContext Context is NULL",__func__);
2189 return -EINVAL;
2190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 switch (sub_cmd)
2192 {
2193 case QCSAP_PARAM_MAX_ASSOC:
2194 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2195 if (eHAL_STATUS_SUCCESS != status)
2196 {
c_hpothuffdb5272013-10-02 16:42:35 +05302197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2198 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 ret = -EIO;
2200 }
Girish Gowli385be612014-09-18 11:17:20 +05302201
2202#ifdef WLAN_SOFTAP_VSTA_FEATURE
2203 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2204 {
2205 if (*value > VSTA_NUM_ASSOC_STA)
2206 {
2207 *value = VSTA_NUM_ASSOC_STA;
2208 }
2209 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2210 (*value > (VSTA_NUM_ASSOC_STA -
2211 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2212 {
2213 *value = (VSTA_NUM_ASSOC_STA -
2214 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2215 }
2216 }
2217 else
2218#endif
2219 {
2220 if (*value > NUM_ASSOC_STA)
2221 {
2222 *value = NUM_ASSOC_STA;
2223 }
2224 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2225 (*value > (NUM_ASSOC_STA -
2226 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2227 {
2228 *value = (NUM_ASSOC_STA -
2229 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2230 }
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302233
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002235 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 {
c_hpothuffdb5272013-10-02 16:42:35 +05302237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2238 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302239 ret = -EIO;
2240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 *value = 0;
2242 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302243
Jeff Johnson43971f52012-07-17 12:26:56 -07002244 case QCSAP_PARAM_GET_WLAN_DBG:
2245 {
2246 vos_trace_display();
2247 *value = 0;
2248 break;
2249 }
2250
2251 case QCSAP_PARAM_AUTO_CHANNEL:
2252 {
2253 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2254 break;
2255 }
2256
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 default:
2258 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2259 ret = -EINVAL;
2260 break;
2261
2262 }
2263
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302264 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 return ret;
2266}
2267
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302268int
2269static iw_softap_getparam(struct net_device *dev,
2270 struct iw_request_info *info,
2271 union iwreq_data *wrqu, char *extra)
2272{
2273 int ret;
2274
2275 vos_ssr_protect(__func__);
2276 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2277 vos_ssr_unprotect(__func__);
2278
2279 return ret;
2280}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302281
2282int
2283static __iw_softap_setchar_getnone(struct net_device *dev,
2284 struct iw_request_info *info,
2285 union iwreq_data *wrqu, char *extra)
2286{
2287 int sub_cmd;
2288 int ret = 0; /* success */
2289 char *pBuffer = NULL;
2290 hdd_adapter_t *pAdapter;
2291 hdd_context_t *pHddCtx;
2292 struct iw_point s_priv_data;
2293
2294 ENTER();
2295
2296 if (!capable(CAP_NET_ADMIN))
2297 {
2298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2299 FL("permission check failed"));
2300 return -EPERM;
2301 }
2302
2303 pAdapter = (netdev_priv(dev));
2304 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2305 ret = wlan_hdd_validate_context(pHddCtx);
2306 if (0 != ret)
2307 {
2308 return ret;
2309 }
2310
2311 if (!pHddCtx->is_ap_mode_wow_supported)
2312 {
2313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2314 "%s: Not supported",__func__);
2315 return -ENOTSUPP;
2316 }
2317
2318 /* helper function to get iwreq_data with compat handling. */
2319 if (hdd_priv_get_data(&s_priv_data, wrqu))
2320 {
2321 return -EINVAL;
2322 }
2323
2324 /* make sure all params are correctly passed to function */
2325 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2326 {
2327 return -EINVAL;
2328 }
2329
2330 sub_cmd = s_priv_data.flags;
2331
2332 /* ODD number is used for set, copy data using copy_from_user */
2333 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2334 s_priv_data.length);
2335 if (NULL == pBuffer)
2336 {
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2338 "mem_alloc_copy_from_user_helper fail");
2339 return -ENOMEM;
2340 }
2341
2342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2343 "%s: Received length %d", __func__, s_priv_data.length);
2344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2345 "%s: Received data %s", __func__, pBuffer);
2346
2347 switch(sub_cmd)
2348 {
2349 case WE_WOWL_ADD_PTRN:
2350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2351 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2352 if (!ret)
2353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2354 "Failed to add pattern :%d", ret);
2355 break;
2356 case WE_WOWL_DEL_PTRN:
2357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2358 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2359 if (!ret)
2360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2361 "Failed to del pattern :%d", ret);
2362 break;
2363 default:
2364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2365 ret = -EINVAL;
2366 break;
2367 }
2368
2369 kfree(pBuffer);
2370 return ret;
2371}
2372
2373int
2374static iw_softap_setchar_getnone(struct net_device *dev,
2375 struct iw_request_info *info,
2376 union iwreq_data *wrqu, char *extra)
2377{
2378 int ret;
2379
2380 vos_ssr_protect(__func__);
2381 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2382 vos_ssr_unprotect(__func__);
2383
2384 return ret;
2385}
2386
Jeff Johnson295189b2012-06-20 16:38:30 -07002387/* Usage:
2388 BLACK_LIST = 0
2389 WHITE_LIST = 1
2390 ADD MAC = 0
2391 REMOVE MAC = 1
2392
2393 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2394 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2395 while using this ioctl
2396
2397 Syntax:
2398 iwpriv softap.0 modify_acl
2399 <6 octet mac addr> <list type> <cmd type>
2400
2401 Examples:
2402 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2403 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2404 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2405 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2406*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302407int __iw_softap_modify_acl(struct net_device *dev,
2408 struct iw_request_info *info,
2409 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002410{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302411 hdd_adapter_t *pHostapdAdapter;
2412 v_CONTEXT_t pVosContext;
2413 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 v_BYTE_t *value = (v_BYTE_t*)extra;
2415 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2416 int listType, cmd, i;
2417 int ret = 0; /* success */
2418
2419 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302420 pHostapdAdapter = (netdev_priv(dev));
2421 if (NULL == pHostapdAdapter)
2422 {
2423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2424 "%s: Adapter is NULL",__func__);
2425 return -EINVAL;
2426 }
2427 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2428 ret = wlan_hdd_validate_context(pHddCtx);
2429 if (0 != ret)
2430 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302431 return ret;
2432 }
2433 pVosContext = pHddCtx->pvosContext;
2434 if (NULL == pVosContext)
2435 {
2436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2437 "%s: Vos Context is NULL",__func__);
2438 return -EINVAL;
2439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2441 {
2442 pPeerStaMac[i] = *(value+i);
2443 }
2444 listType = (int)(*(value+i));
2445 i++;
2446 cmd = (int)(*(value+i));
2447
Arif Hussain24bafea2013-11-15 15:10:03 -08002448 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2449 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
2451 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2452 != VOS_STATUS_SUCCESS)
2453 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002454 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 ret = -EIO;
2456 }
2457 EXIT();
2458 return ret;
2459}
2460
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302461int iw_softap_modify_acl(struct net_device *dev,
2462 struct iw_request_info *info,
2463 union iwreq_data *wrqu, char *extra)
2464{
2465 int ret;
2466
2467 vos_ssr_protect(__func__);
2468 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2469 vos_ssr_unprotect(__func__);
2470
2471 return ret;
2472}
2473
Jeff Johnson295189b2012-06-20 16:38:30 -07002474int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302475static __iw_softap_getchannel(struct net_device *dev,
2476 struct iw_request_info *info,
2477 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002478{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302479 hdd_adapter_t *pHostapdAdapter;
2480 hdd_context_t *pHddCtx;
2481 int ret = 0;
2482 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302483
2484 ENTER();
2485
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302486 pHostapdAdapter = (netdev_priv(dev));
2487 if (NULL == pHostapdAdapter)
2488 {
2489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2490 "%s: Adapter is NULL",__func__);
2491 return -EINVAL;
2492 }
2493 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2494 ret = wlan_hdd_validate_context(pHddCtx);
2495 if (0 != ret)
2496 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 return ret;
2498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002499
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302500 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002501
Jeff Johnson43971f52012-07-17 12:26:56 -07002502 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302503
2504 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 return 0;
2506}
2507
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302508
Jeff Johnsone7245742012-09-05 17:12:55 -07002509int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302510static iw_softap_getchannel(struct net_device *dev,
2511 struct iw_request_info *info,
2512 union iwreq_data *wrqu, char *extra)
2513{
2514 int ret;
2515
2516 vos_ssr_protect(__func__);
2517 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2518 vos_ssr_unprotect(__func__);
2519
2520 return ret;
2521}
2522
2523int
2524static __iw_softap_set_max_tx_power(struct net_device *dev,
2525 struct iw_request_info *info,
2526 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002527{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302528 hdd_adapter_t *pHostapdAdapter;
2529 tHalHandle hHal;
2530 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002531 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302532 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002533 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2534 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2535
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302536 ENTER();
2537
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302538 pHostapdAdapter = (netdev_priv(dev));
2539 if (NULL == pHostapdAdapter)
2540 {
2541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2542 "%s: Adapter is NULL",__func__);
2543 return -EINVAL;
2544 }
2545 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2546 ret = wlan_hdd_validate_context(pHddCtx);
2547 if (0 != ret)
2548 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302549 return ret;
2550 }
2551 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2552 if (NULL == hHal)
2553 {
2554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2555 "%s: Hal Context is NULL",__func__);
2556 return -EINVAL;
2557 }
schang86c22c42013-03-13 18:41:24 -07002558 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002559 return -ENOMEM;
2560
Leo Changd37675a2013-08-01 13:19:45 -07002561 /* Assign correct slef MAC address */
2562 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2563 VOS_MAC_ADDR_SIZE);
2564 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2565 VOS_MAC_ADDR_SIZE);
2566
schang86c22c42013-03-13 18:41:24 -07002567 set_value = value[0];
2568 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2569 {
2570 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002571 __func__);
schang86c22c42013-03-13 18:41:24 -07002572 return -EIO;
2573 }
2574
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302575 EXIT();
schang86c22c42013-03-13 18:41:24 -07002576 return 0;
2577}
2578
2579int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302580static iw_softap_set_max_tx_power(struct net_device *dev,
2581 struct iw_request_info *info,
2582 union iwreq_data *wrqu, char *extra)
2583{
2584 int ret;
2585
2586 vos_ssr_protect(__func__);
2587 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2588 vos_ssr_unprotect(__func__);
2589
2590 return ret;
2591}
2592
2593
2594int
2595static __iw_display_data_path_snapshot(struct net_device *dev,
2596 struct iw_request_info *info,
2597 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302598{
2599
2600 /* Function intitiating dumping states of
2601 * HDD(WMM Tx Queues)
2602 * TL State (with Per Client infor)
2603 * DXE Snapshot (Called at the end of TL Snapshot)
2604 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302605 hdd_adapter_t *pHostapdAdapter;
2606 hdd_context_t *pHddCtx;
2607 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302608
2609 ENTER();
2610
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302611 pHostapdAdapter = (netdev_priv(dev));
2612 if (NULL == pHostapdAdapter)
2613 {
2614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2615 "%s: Adapter is NULL",__func__);
2616 return -EINVAL;
2617 }
2618 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2619 ret = wlan_hdd_validate_context(pHddCtx);
2620 if (0 != ret)
2621 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302622 return ret;
2623 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302624 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302625 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302626
2627 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302628 return 0;
2629}
2630
2631int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302632static iw_display_data_path_snapshot(struct net_device *dev,
2633 struct iw_request_info *info,
2634 union iwreq_data *wrqu, char *extra)
2635{
2636 int ret;
2637
2638 vos_ssr_protect(__func__);
2639 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2640 vos_ssr_unprotect(__func__);
2641
2642 return ret;
2643}
2644
2645int
2646static __iw_softap_set_tx_power(struct net_device *dev,
2647 struct iw_request_info *info,
2648 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002649{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302650 hdd_adapter_t *pHostapdAdapter;
2651 hdd_context_t *pHddCtx;
2652 v_CONTEXT_t pVosContext;
2653 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002654 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302655 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002656 ptSapContext pSapCtx = NULL;
2657
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302658 ENTER();
2659
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302660 pHostapdAdapter = (netdev_priv(dev));
2661 if (NULL == pHostapdAdapter)
2662 {
2663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2664 "%s: Adapter is NULL",__func__);
2665 return -EINVAL;
2666 }
2667 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2668 ret = wlan_hdd_validate_context(pHddCtx);
2669 if (0 != ret)
2670 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302671 return ret;
2672 }
2673 pVosContext = pHddCtx->pvosContext;
2674 if (NULL == pVosContext)
2675 {
2676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2677 "%s: Vos Context is NULL",__func__);
2678 return -EINVAL;
2679 }
2680 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2681 if (NULL == hHal)
2682 {
2683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2684 "%s: Hal Context is NULL",__func__);
2685 return -EINVAL;
2686 }
schang86c22c42013-03-13 18:41:24 -07002687 if (NULL == value)
2688 return -ENOMEM;
2689
2690 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2691 if (NULL == pSapCtx)
2692 {
2693 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2694 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2695 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002696 }
2697
2698 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002699 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002700 {
schang86c22c42013-03-13 18:41:24 -07002701 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002702 __func__);
2703 return -EIO;
2704 }
2705
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302706 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002707 return 0;
2708}
2709
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302710int
2711static iw_softap_set_tx_power(struct net_device *dev,
2712 struct iw_request_info *info,
2713 union iwreq_data *wrqu, char *extra)
2714{
2715 int ret;
2716
2717 vos_ssr_protect(__func__);
2718 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2719 vos_ssr_unprotect(__func__);
2720
2721 return ret;
2722}
2723
Kiet Lambcf38522013-10-26 18:28:27 +05302724/**---------------------------------------------------------------------------
2725
2726 \brief iw_softap_set_trafficmonitor() -
2727 This function dynamically enable/disable traffic monitor functonality
2728 the command iwpriv wlanX setTrafficMon <value>.
2729
2730 \param - dev - Pointer to the net device.
2731 - addr - Pointer to the sockaddr.
2732 \return - 0 for success, non zero for failure
2733
2734 --------------------------------------------------------------------------*/
2735
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302736static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2737 struct iw_request_info *info,
2738 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302739{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302741 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302742 hdd_context_t *pHddCtx;
2743 int status;
2744
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302745 ENTER();
2746
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302747 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302748 if (NULL == pAdapter)
2749 {
2750 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2751 "%s: HDD adapter is Null", __func__);
2752 return -ENODEV;
2753 }
2754
2755 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2756
2757 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302758 if (0 != status)
2759 {
Kiet Lambcf38522013-10-26 18:28:27 +05302760 return status;
2761 }
2762
2763 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2764
2765 if (NULL == isSetTrafficMon)
2766 {
2767 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2768 "%s: Invalid SAP pointer from extra", __func__);
2769 return -ENOMEM;
2770 }
2771
2772 if (TRUE == *isSetTrafficMon)
2773 {
2774 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
2775 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
2776 {
2777 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2778 "%s: failed to Start Traffic Monitor timer ", __func__ );
2779 return -EIO;
2780 }
2781 }
2782 else if (FALSE == *isSetTrafficMon)
2783 {
2784 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
2785 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
2786 {
2787 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2788 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2789 return -EIO;
2790 }
2791
2792 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302793
2794 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05302795 return 0;
2796}
2797
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302798static int iw_softap_set_trafficmonitor(struct net_device *dev,
2799 struct iw_request_info *info,
2800 union iwreq_data *wrqu, char *extra)
2801{
2802 int ret;
2803
2804 vos_ssr_protect(__func__);
2805 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
2806 vos_ssr_unprotect(__func__);
2807
2808 return ret;
2809}
2810
Jeff Johnson295189b2012-06-20 16:38:30 -07002811#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
2812
2813int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302814static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
2815 struct iw_request_info *info,
2816 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002817{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302818 hdd_adapter_t *pHostapdAdapter;
2819 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302820 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07002821 char *buf;
2822 int cnt = 0;
2823 int left;
2824 int ret = 0;
2825 /* maclist_index must be u32 to match userspace */
2826 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302827 v_CONTEXT_t pVosContext = NULL;
2828 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302830 ENTER();
2831
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302832 pHostapdAdapter = (netdev_priv(dev));
2833 if (NULL == pHostapdAdapter)
2834 {
2835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2836 "%s: Adapter is NULL",__func__);
2837 return -EINVAL;
2838 }
2839 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2840 ret = wlan_hdd_validate_context(pHddCtx);
2841 if (0 != ret)
2842 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302843 return ret;
2844 }
2845
Jeff Johnson224f3702014-03-26 11:09:47 -07002846 /*
2847 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
2848 * number, and even numbered iocts are supposed to have "set"
2849 * semantics. Hence the wireless extensions support in the kernel
2850 * won't correctly copy the result to userspace, so the ioctl
2851 * handler itself must copy the data. Output format is 32-bit
2852 * record length, followed by 0 or more 6-byte STA MAC addresses.
2853 *
2854 * Further note that due to the incorrect semantics, the "iwpriv"
2855 * userspace application is unable to correctly invoke this API,
2856 * hence it is not registered in the hostapd_private_args. This
2857 * API can only be invoked by directly invoking the ioctl() system
2858 * call.
2859 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002860
Jeff Johnson224f3702014-03-26 11:09:47 -07002861 /* make sure userspace allocated a reasonable buffer size */
2862 if (wrqu->data.length < sizeof(maclist_index)) {
2863 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
2864 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07002865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002866
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302867 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2868 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2869 if(pSapCtx == NULL){
2870 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2871 FL("psapCtx is NULL"));
2872 return -EFAULT;
2873 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05302874
2875 /* allocate local buffer to build the response */
2876 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
2877 if (!buf) {
2878 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
2879 return -ENOMEM;
2880 }
2881
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302882 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07002883 /* start indexing beyond where the record count will be written */
2884 maclist_index = sizeof(maclist_index);
2885 left = wrqu->data.length - maclist_index;
2886
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302887 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002888 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
2889 if ((pStaInfo[cnt].isUsed) &&
2890 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
2891 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
2892 VOS_MAC_ADDR_SIZE);
2893 maclist_index += VOS_MAC_ADDR_SIZE;
2894 left -= VOS_MAC_ADDR_SIZE;
2895 }
2896 cnt++;
2897 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302898 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07002899
2900 *((u32 *)buf) = maclist_index;
2901 wrqu->data.length = maclist_index;
2902 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
2903 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
2904 ret = -EFAULT;
2905 }
2906 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302907
2908 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07002909 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002910}
2911
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302912int
2913static iw_softap_getassoc_stamacaddr(struct net_device *dev,
2914 struct iw_request_info *info,
2915 union iwreq_data *wrqu, char *extra)
2916{
2917 int ret;
2918
2919 vos_ssr_protect(__func__);
2920 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
2921 vos_ssr_unprotect(__func__);
2922
2923 return ret;
2924}
2925
Jeff Johnson295189b2012-06-20 16:38:30 -07002926/* Usage:
2927 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2928 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2929 while using this ioctl
2930
2931 Syntax:
2932 iwpriv softap.0 disassoc_sta <6 octet mac address>
2933
2934 e.g.
2935 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
2936 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
2937*/
2938
2939int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302940static __iw_softap_disassoc_sta(struct net_device *dev,
2941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302944 hdd_adapter_t *pHostapdAdapter;
2945 hdd_context_t *pHddCtx;
2946 v_U8_t *peerMacAddr;
2947 int ret = 0;
2948
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05302950
2951 if (!capable(CAP_NET_ADMIN)) {
2952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2953 FL("permission check failed"));
2954 return -EPERM;
2955 }
2956
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302957 pHostapdAdapter = (netdev_priv(dev));
2958 if (NULL == pHostapdAdapter)
2959 {
2960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2961 "%s: Adapter is NULL",__func__);
2962 return -EINVAL;
2963 }
2964 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2965 ret = wlan_hdd_validate_context(pHddCtx);
2966 if (0 != ret)
2967 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302968 return ret;
2969 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302970 /* iwpriv tool or framework calls this ioctl with
2971 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05302973 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002974
Arif Hussain24bafea2013-11-15 15:10:03 -08002975 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
2976 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
2978 EXIT();
2979 return 0;
2980}
2981
2982int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302983static iw_softap_disassoc_sta(struct net_device *dev,
2984 struct iw_request_info *info,
2985 union iwreq_data *wrqu, char *extra)
2986{
2987 int ret;
2988
2989 vos_ssr_protect(__func__);
2990 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
2991 vos_ssr_unprotect(__func__);
2992
2993 return ret;
2994}
2995
2996int
2997static __iw_softap_ap_stats(struct net_device *dev,
2998 struct iw_request_info *info,
2999 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003000{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303001 hdd_adapter_t *pHostapdAdapter;
3002 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 WLANTL_TRANSFER_STA_TYPE statBuffer;
3004 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303005 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003006
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303007 ENTER();
3008
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303009 pHostapdAdapter = (netdev_priv(dev));
3010 if (NULL == pHostapdAdapter)
3011 {
3012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3013 "%s: Adapter is NULL",__func__);
3014 return -EINVAL;
3015 }
3016 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3017 ret = wlan_hdd_validate_context(pHddCtx);
3018 if (0 != ret)
3019 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303020 return ret;
3021 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003022 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003023 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3024 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303026 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003027 if(NULL == pstatbuf) {
3028 hddLog(LOG1, "unable to allocate memory");
3029 return -ENOMEM;
3030 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303031
3032 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003033 "RUF=%d RMF=%d RBF=%d "
3034 "RUB=%d RMB=%d RBB=%d "
3035 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303036 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003037 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3038 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3039 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3040 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3041 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3042 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003043
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303044 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003045 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3046 kfree(pstatbuf);
3047 return -EFAULT;
3048 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303049
3050 strlcpy(extra, pstatbuf, len);
3051 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003052 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303053
3054 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003055 return 0;
3056}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303057int
3058static __iw_softap_ap_get_stats(struct net_device *dev,
3059 struct iw_request_info *info,
3060 union iwreq_data *wrqu, char *extra)
3061{
3062 hdd_adapter_t *pAdapter;
3063 hdd_tx_rx_stats_t *pStats;
3064
3065 ENTER();
3066 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3067 if (NULL == pAdapter)
3068 {
3069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3070 "%s: Adapter is NULL",__func__);
3071 return -EINVAL;
3072 }
3073
3074 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3075 snprintf(extra, QCSAP_MAX_STR_LEN,
3076 "\nTransmit"
3077 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3078 "\n dropped BK %u, BE %u, VI %u, VO %u"
3079 "\n classified BK %u, BE %u, VI %u, VO %u"
3080 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3081 "\n queued BK %u, BE %u, VI %u, VO %u"
3082 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3083 "\ndequeued %u, depressured %u, deque-depressured %u,\
3084 completed %u, flushed %u"
3085 "\n fetched BK %u, BE %u, VI %u, VO %u"
3086 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3087 "\n depressured BK %u, BE %u, VI %u, VO %u"
3088 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3089 "\n flushed BK %u, BE %u, VI %u, VO %u"
3090 "\n\nReceive"
3091 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3092 "\n\nResetsStats"
3093 "\n",
3094 pStats->txXmitCalled,
3095 pStats->txXmitDropped,
3096 pStats->txXmitBackPressured,
3097 pStats->txXmitQueued,
3098
3099 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3100 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3101 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3102 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3103
3104 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3105 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3106 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3107 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3108
3109 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3110 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3111 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3112 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3113
3114 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3115 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3116 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3117 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3118
3119 pStats->txFetched,
3120 pStats->txFetchEmpty,
3121 pStats->txFetchLowResources,
3122 pStats->txFetchDequeueError,
3123
3124 pStats->txFetchDequeued,
3125 pStats->txFetchDePressured,
3126 pStats->txDequeDePressured,
3127 pStats->txCompleted,
3128 pStats->txFlushed,
3129
3130 pStats->txFetchedAC[WLANTL_AC_BK],
3131 pStats->txFetchedAC[WLANTL_AC_BE],
3132 pStats->txFetchedAC[WLANTL_AC_VI],
3133 pStats->txFetchedAC[WLANTL_AC_VO],
3134
3135 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3136 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3137 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3138 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3139
3140 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3141 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3142 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3143 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3144
3145 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3146 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3147 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3148 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3149
3150 pStats->txFlushedAC[WLANTL_AC_BK],
3151 pStats->txFlushedAC[WLANTL_AC_BE],
3152 pStats->txFlushedAC[WLANTL_AC_VI],
3153 pStats->txFlushedAC[WLANTL_AC_VO],
3154
3155 pStats->rxChains,
3156 pStats->rxPackets,
3157 pStats->rxDropped,
3158 pStats->rxDelivered,
3159 pStats->rxRefused
3160 );
3161
3162 wrqu->data.length = strlen(extra) + 1;
3163
3164 return 0;
3165}
3166
3167int
3168static __iw_softap_ap_clear_stats(struct net_device *dev,
3169 struct iw_request_info *info,
3170 union iwreq_data *wrqu, char *extra)
3171{
3172 hdd_adapter_t *pAdapter;
3173
3174 ENTER();
3175
3176 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3177 if (NULL == pAdapter)
3178 {
3179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3180 "%s: Adapter is NULL",__func__);
3181 return -EINVAL;
3182 }
3183
3184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3185 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3186 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3187 return 0;
3188}
3189
3190
3191int
3192static iw_softap_get_stats(struct net_device *dev,
3193 struct iw_request_info *info,
3194 union iwreq_data *wrqu, char *extra)
3195{
3196 int ret;
3197 vos_ssr_protect(__func__);
3198 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3199 vos_ssr_unprotect(__func__);
3200 return ret;
3201}
3202
3203int
3204static iw_softap_clear_stats(struct net_device *dev,
3205 struct iw_request_info *info,
3206 union iwreq_data *wrqu, char *extra)
3207{
3208 int ret;
3209 vos_ssr_protect(__func__);
3210 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3211 vos_ssr_unprotect(__func__);
3212 return ret;
3213}
Jeff Johnson295189b2012-06-20 16:38:30 -07003214
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303215int
3216static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 struct iw_request_info *info,
3218 union iwreq_data *wrqu, char *extra)
3219{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303220 int ret;
3221
3222 vos_ssr_protect(__func__);
3223 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3224 vos_ssr_unprotect(__func__);
3225
3226 return ret;
3227}
3228
3229static int __iw_softap_set_channel_range(struct net_device *dev,
3230 struct iw_request_info *info,
3231 union iwreq_data *wrqu, char *extra)
3232{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303233 hdd_adapter_t *pHostapdAdapter;
3234 tHalHandle hHal;
3235 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 int *value = (int *)extra;
3237 int startChannel = value[0];
3238 int endChannel = value[1];
3239 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003240 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 int ret = 0; /* success */
3242
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303243 ENTER();
3244
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303245 if (!capable(CAP_NET_ADMIN))
3246 {
3247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3248 FL("permission check failed"));
3249 return -EPERM;
3250 }
3251
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303252 pHostapdAdapter = (netdev_priv(dev));
3253 if (NULL == pHostapdAdapter)
3254 {
3255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3256 "%s: Adapter is NULL",__func__);
3257 return -EINVAL;
3258 }
3259 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3260 ret = wlan_hdd_validate_context(pHddCtx);
3261 if (0 != ret)
3262 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303263 return ret;
3264 }
3265 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3266 if (NULL == hHal)
3267 {
3268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3269 "%s: Hal Context is NULL",__func__);
3270 return -EINVAL;
3271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3273 if(status != VOS_STATUS_SUCCESS)
3274 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003275 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 startChannel,endChannel, band);
3277 ret = -EINVAL;
3278 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003279
3280 pHddCtx->is_dynamic_channel_range_set = 1;
3281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303282 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 return ret;
3284}
3285
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303286static int iw_softap_set_channel_range(struct net_device *dev,
3287 struct iw_request_info *info,
3288 union iwreq_data *wrqu, char *extra)
3289{
3290 int ret;
3291
3292 vos_ssr_protect(__func__);
3293 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3294 vos_ssr_unprotect(__func__);
3295
3296 return ret;
3297}
3298
3299
3300int __iw_softap_get_channel_list(struct net_device *dev,
3301 struct iw_request_info *info,
3302 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003303{
3304 v_U32_t num_channels = 0;
3305 v_U8_t i = 0;
3306 v_U8_t bandStartChannel = RF_CHAN_1;
3307 v_U8_t bandEndChannel = RF_CHAN_165;
3308 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303309 hdd_adapter_t *pHostapdAdapter;
3310 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003313 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303314 hdd_context_t *pHddCtx;
3315 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303316
3317 ENTER();
3318
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303319 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3320 if (NULL == pHostapdAdapter)
3321 {
3322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3323 "%s: Adapter is NULL",__func__);
3324 return -EINVAL;
3325 }
3326 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3327 ret = wlan_hdd_validate_context(pHddCtx);
3328 if (0 != ret)
3329 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303330 return ret;
3331 }
3332 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3333 if (NULL == hHal)
3334 {
3335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3336 "%s: Hal Context is NULL",__func__);
3337 return -EINVAL;
3338 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003339 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3340 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003341 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003342 return -EIO;
3343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 wrqu->data.length = sizeof(tChannelListInfo);
3345 ENTER();
3346
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003347 if (eCSR_BAND_24 == curBand)
3348 {
3349 bandStartChannel = RF_CHAN_1;
3350 bandEndChannel = RF_CHAN_14;
3351 }
3352 else if (eCSR_BAND_5G == curBand)
3353 {
3354 bandStartChannel = RF_CHAN_36;
3355 bandEndChannel = RF_CHAN_165;
3356 }
3357
Arif Hussain6d2a3322013-11-17 19:50:10 -08003358 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303359 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003360 bandStartChannel, bandEndChannel );
3361
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3363 {
3364 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3365 {
3366 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3367 num_channels++;
3368 }
3369 }
3370
3371 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3372
3373 temp_num_channels = num_channels;
3374
3375 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3376 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303377 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003378 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 }
3380
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303381 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3382 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 {
3384 for(i = 0; i < temp_num_channels; i++)
3385 {
3386
3387 if((channel_list->channels[i] > 35) &&
3388 (channel_list->channels[i] < 49))
3389 {
3390 vos_mem_move(&channel_list->channels[i],
3391 &channel_list->channels[i+1],
3392 temp_num_channels - (i-1));
3393 num_channels--;
3394 temp_num_channels--;
3395 i--;
3396 }
3397 }
3398 }
3399
Arif Hussain6d2a3322013-11-17 19:50:10 -08003400 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003401
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 channel_list->num_channels = num_channels;
3403 EXIT();
3404
3405 return 0;
3406}
3407
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303408int iw_softap_get_channel_list(struct net_device *dev,
3409 struct iw_request_info *info,
3410 union iwreq_data *wrqu, char *extra)
3411{
3412 int ret;
3413
3414 vos_ssr_protect(__func__);
3415 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3416 vos_ssr_unprotect(__func__);
3417
3418 return ret;
3419}
3420
3421static
3422int __iw_get_genie(struct net_device *dev,
3423 struct iw_request_info *info,
3424 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003425{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303426 hdd_adapter_t *pHostapdAdapter;
3427 hdd_context_t *pHddCtx;
3428 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303429 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3431 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303432 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303433
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303435
3436 pHostapdAdapter = (netdev_priv(dev));
3437 if (NULL == pHostapdAdapter)
3438 {
3439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3440 "%s: Adapter is NULL",__func__);
3441 return -EINVAL;
3442 }
3443 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3444 ret = wlan_hdd_validate_context(pHddCtx);
3445 if (0 != ret)
3446 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303447 return ret;
3448 }
3449 pVosContext = pHddCtx->pvosContext;
3450 if (NULL == pVosContext)
3451 {
3452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3453 "%s: vos context is not valid ",__func__);
3454 return -EINVAL;
3455 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003456 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3458 status = WLANSap_getstationIE_information(pVosContext,
3459 &length,
3460 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303461
3462 if (VOS_STATUS_SUCCESS != status) {
3463 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003464 return -EFAULT;
3465 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303466
Arif Hussained667642013-10-27 23:01:14 -07003467 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303468 if (length > DOT11F_IE_RSN_MAX_LEN) {
3469 hddLog(LOGE,
3470 FL("invalid buffer length length:%d"), length);
3471 return -E2BIG;
3472 }
3473
3474 vos_mem_copy(extra, genIeBytes, length);
3475
3476 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3477
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 EXIT();
3479 return 0;
3480}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303481
3482static
3483int iw_get_genie(struct net_device *dev,
3484 struct iw_request_info *info,
3485 union iwreq_data *wrqu, char *extra)
3486{
3487 int ret;
3488
3489 vos_ssr_protect(__func__);
3490 ret = __iw_get_genie(dev, info, wrqu, extra);
3491 vos_ssr_unprotect(__func__);
3492
3493 return ret;
3494}
3495
3496static
3497int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3498 struct iw_request_info *info,
3499 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003500{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303501 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003502 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303503 hdd_ap_ctx_t *pHddApCtx;
3504 hdd_context_t *pHddCtx;
3505 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303506
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003508
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303509 pHostapdAdapter = (netdev_priv(dev));
3510 if (NULL == pHostapdAdapter)
3511 {
3512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3513 "%s: Adapter is NULL",__func__);
3514 return -EINVAL;
3515 }
3516 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3517 ret = wlan_hdd_validate_context(pHddCtx);
3518 if (0 != ret)
3519 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303520 return ret;
3521 }
3522 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3523 if (NULL == pHddApCtx)
3524 {
3525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3526 "%s: AP context is NULL",__func__);
3527 return -EINVAL;
3528 }
3529
Arif Hussain6d2a3322013-11-17 19:50:10 -08003530 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003531 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3532
3533 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3534 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3535 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3536 WPSPBCProbeReqIEs.probeReqIELen);
3537 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3538 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3539 sizeof(v_MACADDR_t));
3540 if (copy_to_user(wrqu->data.pointer,
3541 (void *)&WPSPBCProbeReqIEs,
3542 sizeof(WPSPBCProbeReqIEs)))
3543 {
3544 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3545 return -EFAULT;
3546 }
3547 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003548 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003549 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 up(&pHddApCtx->semWpsPBCOverlapInd);
3551 EXIT();
3552 return 0;
3553}
3554
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303555static
3556int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3557 struct iw_request_info *info,
3558 union iwreq_data *wrqu, char *extra)
3559{
3560 int ret;
3561
3562 vos_ssr_protect(__func__);
3563 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3564 vos_ssr_unprotect(__func__);
3565
3566 return ret;
3567}
3568
Jeff Johnson295189b2012-06-20 16:38:30 -07003569/**---------------------------------------------------------------------------
3570
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303571 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 This function sets the auth type received from the wpa_supplicant.
3573
3574 \param - dev - Pointer to the net device.
3575 - info - Pointer to the iw_request_info.
3576 - wrqu - Pointer to the iwreq_data.
3577 - extra - Pointer to the data.
3578 \return - 0 for success, non zero for failure
3579
3580 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303581int __iw_set_auth_hostap(struct net_device *dev,
3582 struct iw_request_info *info,
3583 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003584{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303585 hdd_adapter_t *pAdapter;
3586 hdd_context_t *pHddCtx;
3587 hdd_wext_state_t *pWextState;
3588 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303589
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303591
3592 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3593 if (NULL == pAdapter)
3594 {
3595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3596 "%s: Adapter is NULL",__func__);
3597 return -EINVAL;
3598 }
3599
3600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3601 ret = wlan_hdd_validate_context(pHddCtx);
3602 if (0 != ret)
3603 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303604 return ret;
3605 }
3606 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3607 if (NULL == pWextState)
3608 {
3609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3610 "%s: pWextState is NULL",__func__);
3611 return -EINVAL;
3612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 switch(wrqu->param.flags & IW_AUTH_INDEX)
3614 {
3615 case IW_AUTH_TKIP_COUNTERMEASURES:
3616 {
3617 if(wrqu->param.value) {
3618 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3619 "Counter Measure started %d", wrqu->param.value);
3620 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303621 }
3622 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3624 "Counter Measure stopped=%d", wrqu->param.value);
3625 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3626 }
3627
3628 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3629 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303634
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003635 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 wrqu->param.flags & IW_AUTH_INDEX);
3637 break;
3638 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303639
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 EXIT();
3641 return 0;
3642}
3643
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303644int iw_set_auth_hostap(struct net_device *dev,
3645 struct iw_request_info *info,
3646 union iwreq_data *wrqu,char *extra)
3647{
3648 int ret;
3649
3650 vos_ssr_protect(__func__);
3651 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3652 vos_ssr_unprotect(__func__);
3653
3654 return ret;
3655}
3656
3657static int __iw_set_ap_encodeext(struct net_device *dev,
3658 struct iw_request_info *info,
3659 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003660{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303661 hdd_adapter_t *pHostapdAdapter;
3662 v_CONTEXT_t pVosContext;
3663 hdd_context_t *pHddCtx;
3664 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003665 int retval = 0;
3666 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3668 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3669 int key_index;
3670 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303671 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003672// tCsrRoamRemoveKey RemoveKey;
3673 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303674
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303675 ENTER();
3676 pHostapdAdapter = (netdev_priv(dev));
3677 if (NULL == pHostapdAdapter)
3678 {
3679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3680 "%s: Adapter is NULL",__func__);
3681 return -EINVAL;
3682 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003683
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303684 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3685 retval = wlan_hdd_validate_context(pHddCtx);
3686 if (0 != retval)
3687 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303688 return retval;
3689 }
3690 pVosContext = pHddCtx->pvosContext;
3691 if (NULL == pVosContext)
3692 {
3693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3694 "%s: pVosContext is NULL",__func__);
3695 return -EINVAL;
3696 }
3697 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3698 if (NULL == pHddApCtx)
3699 {
3700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3701 "%s: AP Context is NULL",__func__);
3702 return -EINVAL;
3703 }
3704
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303706
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303708
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 /*Convert from 1-based to 0-based keying*/
3710 key_index--;
3711 }
3712 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303713#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 /*Set the encrytion type to NONE*/
3715#if 0
3716 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3717#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303718
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 RemoveKey.keyId = key_index;
3720 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3721 /*Key direction for group is RX only*/
3722 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3723 }
3724 else {
3725 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3726 }
3727 switch(ext->alg)
3728 {
3729 case IW_ENCODE_ALG_NONE:
3730 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3731 break;
3732 case IW_ENCODE_ALG_WEP:
3733 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3734 break;
3735 case IW_ENCODE_ALG_TKIP:
3736 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 case IW_ENCODE_ALG_CCMP:
3739 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
3740 break;
3741 default:
3742 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3743 break;
3744 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003745 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 -07003746 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08003747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003748 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 );
Jeff Johnson43971f52012-07-17 12:26:56 -07003750 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
3751 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 {
3753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07003754 __LINE__, vstatus );
3755 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003757#endif
3758 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003759
Jeff Johnson43971f52012-07-17 12:26:56 -07003760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003761
3762 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3763
3764 setKey.keyId = key_index;
3765 setKey.keyLength = ext->key_len;
3766
3767 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3768 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3769 }
3770
3771 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3772 /*Key direction for group is RX only*/
3773 setKey.keyDirection = eSIR_RX_ONLY;
3774 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3775 }
3776 else {
3777
3778 setKey.keyDirection = eSIR_TX_RX;
3779 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3780 }
3781 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3782 {
3783 setKey.keyDirection = eSIR_TX_DEFAULT;
3784 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3785 }
3786
3787 /*For supplicant pae role is zero*/
3788 setKey.paeRole = 0;
3789
3790 switch(ext->alg)
3791 {
3792 case IW_ENCODE_ALG_NONE:
3793 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3794 break;
3795
3796 case IW_ENCODE_ALG_WEP:
3797 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3798 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003799 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 break;
3801
3802 case IW_ENCODE_ALG_TKIP:
3803 {
3804 v_U8_t *pKey = &setKey.Key[0];
3805
3806 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3807
3808 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3809
3810 /*Supplicant sends the 32bytes key in this order
3811
3812 |--------------|----------|----------|
3813 | Tk1 |TX-MIC | RX Mic |
3814 |--------------|----------|----------|
3815 <---16bytes---><--8bytes--><--8bytes-->
3816
3817 */
3818 /*Sme expects the 32 bytes key to be in the below order
3819
3820 |--------------|----------|----------|
3821 | Tk1 |RX-MIC | TX Mic |
3822 |--------------|----------|----------|
3823 <---16bytes---><--8bytes--><--8bytes-->
3824 */
3825 /* Copy the Temporal Key 1 (TK1) */
3826 vos_mem_copy(pKey,ext->key,16);
3827
3828 /*Copy the rx mic first*/
3829 vos_mem_copy(&pKey[16],&ext->key[24],8);
3830
3831 /*Copy the tx mic */
3832 vos_mem_copy(&pKey[24],&ext->key[16],8);
3833
3834 }
3835 break;
3836
3837 case IW_ENCODE_ALG_CCMP:
3838 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3839 break;
3840
3841 default:
3842 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3843 break;
3844 }
3845
3846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303847 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 setKey.keyId);
3849 for(i=0; i< ext->key_len; i++)
3850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3851 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07003852
3853 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
3854 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 {
3856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07003857 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
3858 retval = -EINVAL;
3859 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303860
3861 EXIT();
3862 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07003863}
Jeff Johnson43971f52012-07-17 12:26:56 -07003864
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303865static int iw_set_ap_encodeext(struct net_device *dev,
3866 struct iw_request_info *info,
3867 union iwreq_data *wrqu, char *extra)
3868{
3869 int ret;
3870
3871 vos_ssr_protect(__func__);
3872 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
3873 vos_ssr_unprotect(__func__);
3874
3875 return ret;
3876}
Jeff Johnson43971f52012-07-17 12:26:56 -07003877
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303878static int __iw_set_ap_mlme(struct net_device *dev,
3879 struct iw_request_info *info,
3880 union iwreq_data *wrqu,
3881 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003882{
3883#if 0
3884 hdd_adapter_t *pAdapter = (netdev_priv(dev));
3885 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3886
3887 ENTER();
3888
3889 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3890 switch (mlme->cmd) {
3891 case IW_MLME_DISASSOC:
3892 case IW_MLME_DEAUTH:
3893 hddLog(LOG1, "Station disassociate");
3894 if( pAdapter->conn_info.connState == eConnectionState_Associated )
3895 {
3896 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
3897
3898 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
3899 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
3900
3901 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
3902
3903 //clear all the reason codes
3904 if (status != 0)
3905 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003906 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 }
3908
3909 netif_stop_queue(dev);
3910 netif_carrier_off(dev);
3911 }
3912 else
3913 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003914 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 -07003915 }
3916 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08003917 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 return -EINVAL;
3919 }//end of switch
3920 EXIT();
3921#endif
3922 return 0;
3923// return status;
3924}
3925
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303926static int iw_set_ap_mlme(struct net_device *dev,
3927 struct iw_request_info *info,
3928 union iwreq_data *wrqu,
3929 char *extra)
3930{
3931 int ret;
3932
3933 vos_ssr_protect(__func__);
3934 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
3935 vos_ssr_unprotect(__func__);
3936
3937 return ret;
3938}
3939
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303940static int __iw_get_ap_rts_threshold(struct net_device *dev,
3941 struct iw_request_info *info,
3942 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003943{
3944 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3945 v_U32_t status = 0;
3946
3947 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
3948
3949 return status;
3950}
3951
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303952static int iw_get_ap_rts_threshold(struct net_device *dev,
3953 struct iw_request_info *info,
3954 union iwreq_data *wrqu, char *extra)
3955{
3956 int ret;
3957
3958 vos_ssr_protect(__func__);
3959 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
3960 vos_ssr_unprotect(__func__);
3961
3962 return ret;
3963}
3964
3965static int __iw_get_ap_frag_threshold(struct net_device *dev,
3966 struct iw_request_info *info,
3967 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003968{
3969 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3970 v_U32_t status = 0;
3971
3972 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
3973
3974 return status;
3975}
3976
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303977static int iw_get_ap_frag_threshold(struct net_device *dev,
3978 struct iw_request_info *info,
3979 union iwreq_data *wrqu, char *extra)
3980{
3981 int ret;
3982
3983 vos_ssr_protect(__func__);
3984 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
3985 vos_ssr_unprotect(__func__);
3986
3987 return ret;
3988}
3989
3990static int __iw_get_ap_freq(struct net_device *dev,
3991 struct iw_request_info *info,
3992 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003993{
Jeff Johnsone7245742012-09-05 17:12:55 -07003994 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303995 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 tHalHandle hHal;
3997 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303998 hdd_ap_ctx_t *pHddApCtx;
3999 hdd_context_t *pHddCtx;
4000 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004001
4002 ENTER();
4003
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304004 pHostapdAdapter = (netdev_priv(dev));
4005 if (NULL == pHostapdAdapter)
4006 {
4007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4008 "%s: Adapter is NULL",__func__);
4009 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304011 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4012 ret = wlan_hdd_validate_context(pHddCtx);
4013 if (0 != ret)
4014 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304015 return ret;
4016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304018 if (NULL == pHostapdState)
4019 {
4020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4021 "%s: pHostapdState is NULL",__func__);
4022 return -EINVAL;
4023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304025 if (NULL == hHal)
4026 {
4027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4028 "%s: Hal Context is NULL",__func__);
4029 return -EINVAL;
4030 }
4031 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4032 if (NULL == pHddApCtx)
4033 {
4034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4035 "%s: AP context is NULL",__func__);
4036 return -EINVAL;
4037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 if(pHostapdState->bssState == BSS_STOP )
4039 {
4040 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4041 != eHAL_STATUS_SUCCESS)
4042 {
c_hpothuffdb5272013-10-02 16:42:35 +05304043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4044 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 return -EIO;
4046 }
4047 else
4048 {
4049 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004050 if( TRUE == status)
4051 {
4052 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4053 * iwlist & iwconfig command shows frequency into proper
4054 * format (2.412 GHz instead of 246.2 MHz)*/
4055 fwrq->m = freq;
4056 fwrq->e = MHZ;
4057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 }
4059 }
4060 else
4061 {
4062 channel = pHddApCtx->operatingChannel;
4063 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004064 if( TRUE == status)
4065 {
4066 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4067 * iwlist & iwconfig command shows frequency into proper
4068 * format (2.412 GHz instead of 246.2 MHz)*/
4069 fwrq->m = freq;
4070 fwrq->e = MHZ;
4071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304073
4074 EXIT();
4075 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004076}
4077
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304078static int iw_get_ap_freq(struct net_device *dev,
4079 struct iw_request_info *info,
4080 struct iw_freq *fwrq, char *extra)
4081{
4082 int ret;
4083
4084 vos_ssr_protect(__func__);
4085 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4086 vos_ssr_unprotect(__func__);
4087
4088 return ret;
4089}
4090
4091static int __iw_get_mode(struct net_device *dev,
4092 struct iw_request_info *info,
4093 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304094{
4095 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304096 hdd_adapter_t *pAdapter;
4097 hdd_context_t *pHddCtx;
4098
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304099 ENTER();
4100
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304101 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4102 if (NULL == pAdapter)
4103 {
4104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4105 "%s: Adapter is NULL",__func__);
4106 return -EINVAL;
4107 }
4108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4109 status = wlan_hdd_validate_context(pHddCtx);
4110 if (0 != status)
4111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304112 return status;
4113 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304114
4115 wrqu->mode = IW_MODE_MASTER;
4116
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304117 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304118 return status;
4119}
4120
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304121static int iw_get_mode(struct net_device *dev,
4122 struct iw_request_info *info,
4123 union iwreq_data *wrqu, char *extra)
4124{
4125 int ret;
4126
4127 vos_ssr_protect(__func__);
4128 ret = __iw_get_mode(dev, info, wrqu, extra);
4129 vos_ssr_unprotect(__func__);
4130
4131 return ret;
4132}
4133
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304134
4135static int __iw_softap_stopbss(struct net_device *dev,
4136 struct iw_request_info *info,
4137 union iwreq_data *wrqu,
4138 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004139{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304140 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304142 hdd_context_t *pHddCtx = NULL;
4143
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304145 pHostapdAdapter = (netdev_priv(dev));
4146 if (NULL == pHostapdAdapter)
4147 {
4148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4149 "%s: Adapter is NULL",__func__);
4150 return -EINVAL;
4151 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304152 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4153 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304154 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304155 return status;
4156 }
4157
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304158 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 {
4160 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4161 {
4162 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4163
4164 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304167 {
4168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004169 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 VOS_ASSERT(0);
4171 }
4172 }
4173 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304174 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176 EXIT();
4177 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4178}
4179
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304180static int iw_softap_stopbss(struct net_device *dev,
4181 struct iw_request_info *info,
4182 union iwreq_data *wrqu,
4183 char *extra)
4184{
4185 int ret;
4186
4187 vos_ssr_protect(__func__);
4188 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4189 vos_ssr_unprotect(__func__);
4190
4191 return ret;
4192}
4193
4194static int __iw_softap_version(struct net_device *dev,
4195 struct iw_request_info *info,
4196 union iwreq_data *wrqu,
4197 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004198{
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304200 hdd_context_t *pHddCtx;
4201 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304202
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304204 pHostapdAdapter = (netdev_priv(dev));
4205 if (NULL == pHostapdAdapter)
4206 {
4207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4208 "%s: Adapter is NULL",__func__);
4209 return -EINVAL;
4210 }
4211 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4212 ret = wlan_hdd_validate_context(pHddCtx);
4213 if (0 != ret)
4214 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304215 return ret;
4216 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004217 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 return 0;
4220}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004221
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304222static int iw_softap_version(struct net_device *dev,
4223 struct iw_request_info *info,
4224 union iwreq_data *wrqu,
4225 char *extra)
4226{
4227 int ret;
4228
4229 vos_ssr_protect(__func__);
4230 ret = __iw_softap_version(dev, info, wrqu, extra);
4231 vos_ssr_unprotect(__func__);
4232
4233 return ret;
4234}
4235
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304236int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004237{
4238 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004239 int len = 0;
4240 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304241 v_CONTEXT_t pVosContext;
4242 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304243 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304245 ENTER();
4246
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304247 if (NULL == pAdapter)
4248 {
4249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4250 "%s: Adapter is NULL",__func__);
4251 return -EINVAL;
4252 }
4253 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4254 if (0 != wlan_hdd_validate_context(pHddCtx))
4255 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304256 return VOS_STATUS_E_FAULT;
4257 }
4258 pVosContext = pHddCtx->pvosContext;
4259 if (NULL == pVosContext)
4260 {
4261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4262 "%s: VOS context is not valid",__func__);
4263 return VOS_STATUS_E_FAULT;
4264 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304265 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304266 if(pSapCtx == NULL)
4267 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304268 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4269 FL("psapCtx is NULL"));
4270 return VOS_STATUS_E_FAULT;
4271 }
4272
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304273 len = snprintf(pBuf, buf_len, sta_info_header);
4274 if (len >= buf_len) {
4275 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4276 return -E2BIG;
4277 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004278 pBuf += len;
4279 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004280
4281 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4282 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304283 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004284 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004285 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304286 pSapCtx->aStaInfo[i].ucSTAId,
4287 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4288 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4289 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4290 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4291 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4292 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304293 if (len >= buf_len) {
4294 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4295 return -E2BIG;
4296 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004297 pBuf += len;
4298 buf_len -= len;
4299 }
4300 if(WE_GET_STA_INFO_SIZE > buf_len)
4301 {
4302 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004303 }
4304 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304305 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304306 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004307}
4308
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304309static int __iw_softap_get_sta_info(struct net_device *dev,
4310 struct iw_request_info *info,
4311 union iwreq_data *wrqu,
4312 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004313{
4314 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304315 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004316 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304317 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4318 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004319 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304320 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004321 }
4322 wrqu->data.length = strlen(extra);
4323 EXIT();
4324 return 0;
4325}
4326
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304327static int iw_softap_get_sta_info(struct net_device *dev,
4328 struct iw_request_info *info,
4329 union iwreq_data *wrqu,
4330 char *extra)
4331{
4332 int ret;
4333
4334 vos_ssr_protect(__func__);
4335 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4336 vos_ssr_unprotect(__func__);
4337
4338 return ret;
4339}
4340
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304341static int __iw_set_ap_genie(struct net_device *dev,
4342 struct iw_request_info *info,
4343 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004344{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304345
4346 hdd_adapter_t *pHostapdAdapter;
4347 hdd_context_t *pHddCtx;
4348 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004350 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304351 int ret = 0;
4352
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304354 pHostapdAdapter = (netdev_priv(dev));
4355 if (NULL == pHostapdAdapter)
4356 {
4357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4358 "%s: Adapter is NULL",__func__);
4359 return -EINVAL;
4360 }
4361 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4362 ret = wlan_hdd_validate_context(pHddCtx);
4363 if (0 != ret)
4364 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304365 return ret;
4366 }
4367 pVosContext = pHddCtx->pvosContext;
4368 if (NULL == pVosContext)
4369 {
4370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4371 "%s: VOS Context is NULL",__func__);
4372 return -EINVAL;
4373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 if(!wrqu->data.length)
4375 {
4376 EXIT();
4377 return 0;
4378 }
Arif Hussained667642013-10-27 23:01:14 -07004379
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304380 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304382 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 case DOT11F_EID_RSN:
4384 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4385 {
4386 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4387 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004390 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304392
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004394 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 halStatus = 0;
4396 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304397
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304399 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004400}
4401
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304402static int iw_set_ap_genie(struct net_device *dev,
4403 struct iw_request_info *info,
4404 union iwreq_data *wrqu, char *extra)
4405{
4406 int ret;
4407
4408 vos_ssr_protect(__func__);
4409 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4410 vos_ssr_unprotect(__func__);
4411
4412 return ret;
4413}
4414
Jeff Johnson295189b2012-06-20 16:38:30 -07004415static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4416{
4417 eHalStatus hstatus;
4418 long lrc;
4419 struct statsContext context;
4420
4421 if (NULL == pAdapter)
4422 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304423 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 return VOS_STATUS_E_FAULT;
4425 }
4426
4427 init_completion(&context.completion);
4428 context.pAdapter = pAdapter;
4429 context.magic = STATS_CONTEXT_MAGIC;
4430 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4431 eCSR_HDD,
4432 SME_GLOBAL_CLASSA_STATS,
4433 hdd_GetClassA_statisticsCB,
4434 0, // not periodic
4435 FALSE, //non-cached results
4436 staid,
4437 &context);
4438 if (eHAL_STATUS_SUCCESS != hstatus)
4439 {
4440 hddLog(VOS_TRACE_LEVEL_ERROR,
4441 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004442 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 }
4444 else
4445 {
4446 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4447 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 if (lrc <= 0)
4449 {
4450 hddLog(VOS_TRACE_LEVEL_ERROR,
4451 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004452 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 }
4454 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004455
4456 /* either we never sent a request, we sent a request and received a
4457 response or we sent a request and timed out. if we never sent a
4458 request or if we sent a request and got a response, we want to
4459 clear the magic out of paranoia. if we timed out there is a
4460 race condition such that the callback function could be
4461 executing at the same time we are. of primary concern is if the
4462 callback function had already verified the "magic" but had not
4463 yet set the completion variable when a timeout occurred. we
4464 serialize these activities by invalidating the magic while
4465 holding a shared spinlock which will cause us to block if the
4466 callback is currently executing */
4467 spin_lock(&hdd_context_lock);
4468 context.magic = 0;
4469 spin_unlock(&hdd_context_lock);
4470
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 return VOS_STATUS_SUCCESS;
4472}
4473
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304474int __iw_get_softap_linkspeed(struct net_device *dev,
4475 struct iw_request_info *info,
4476 union iwreq_data *wrqu,
4477 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004478
4479{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304480 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304481 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004483 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304484 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304486 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004488 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304489 int rc, valid;
4490
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304491 ENTER();
4492
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304493 pHostapdAdapter = (netdev_priv(dev));
4494 if (NULL == pHostapdAdapter)
4495 {
4496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4497 "%s: Adapter is NULL",__func__);
4498 return -EINVAL;
4499 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304500 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304501 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304502 if (0 != valid)
4503 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304504 return valid;
4505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004506
Arif Hussain6d2a3322013-11-17 19:50:10 -08004507 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004508
4509 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004510 {
Arif Hussaina9571842014-01-15 16:43:41 -08004511 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4512 if (NULL == pmacAddress) {
4513 hddLog(LOG1, "unable to allocate memory");
4514 return -ENOMEM;
4515 }
4516 if (copy_from_user((void *)pmacAddress,
4517 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4518 {
4519 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4520 kfree(pmacAddress);
4521 return -EFAULT;
4522 }
Manjeet Singha3739742016-05-03 16:21:46 +05304523 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004524
4525 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004526 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004527
4528 if (!VOS_IS_STATUS_SUCCESS(status ))
4529 {
4530 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4531 }
Arif Hussained667642013-10-27 23:01:14 -07004532 }
Kiet Lam61589852013-09-19 17:10:58 +05304533 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304534 * link speed for first connected client will be returned.
4535 */
Arif Hussaina9571842014-01-15 16:43:41 -08004536 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304537 {
4538 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4539 }
4540 else
4541 {
4542 status = hdd_softap_GetStaId(pHostapdAdapter,
4543 (v_MACADDR_t *)macAddress, (void *)(&staId));
4544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004545
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304546 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304548 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 link_speed = 0;
4550 }
4551 else
4552 {
4553 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 if (!VOS_IS_STATUS_SUCCESS(status ))
4556 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304557 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 return -EINVAL;
4559 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304560
4561 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4562 staId, &link_speed);
4563
4564 link_speed = link_speed / 10;
4565
4566 if (0 == link_speed)
4567 {
4568 /* The linkspeed returned by HAL is in units of 500kbps.
4569 * converting it to mbps.
4570 * This is required to support legacy firmware which does
4571 * not return link capacity.
4572 */
4573 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
4576
4577 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004578 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304579
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 if ((rc < 0) || (rc >= len))
4581 {
4582 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304583 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 return -EIO;
4585 }
4586
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304587 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 return 0;
4589}
4590
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304591int iw_get_softap_linkspeed(struct net_device *dev,
4592 struct iw_request_info *info,
4593 union iwreq_data *wrqu,
4594 char *extra)
4595{
4596 int ret;
4597
4598 vos_ssr_protect(__func__);
4599 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4600 vos_ssr_unprotect(__func__);
4601
4602 return ret;
4603}
4604
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606static const iw_handler hostapd_handler[] =
4607{
4608 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4609 (iw_handler) NULL, /* SIOCGIWNAME */
4610 (iw_handler) NULL, /* SIOCSIWNWID */
4611 (iw_handler) NULL, /* SIOCGIWNWID */
4612 (iw_handler) NULL, /* SIOCSIWFREQ */
4613 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4614 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304615 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 (iw_handler) NULL, /* SIOCSIWSENS */
4617 (iw_handler) NULL, /* SIOCGIWSENS */
4618 (iw_handler) NULL, /* SIOCSIWRANGE */
4619 (iw_handler) NULL, /* SIOCGIWRANGE */
4620 (iw_handler) NULL, /* SIOCSIWPRIV */
4621 (iw_handler) NULL, /* SIOCGIWPRIV */
4622 (iw_handler) NULL, /* SIOCSIWSTATS */
4623 (iw_handler) NULL, /* SIOCGIWSTATS */
4624 (iw_handler) NULL, /* SIOCSIWSPY */
4625 (iw_handler) NULL, /* SIOCGIWSPY */
4626 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4627 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4628 (iw_handler) NULL, /* SIOCSIWAP */
4629 (iw_handler) NULL, /* SIOCGIWAP */
4630 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4631 (iw_handler) NULL, /* SIOCGIWAPLIST */
4632 (iw_handler) NULL, /* SIOCSIWSCAN */
4633 (iw_handler) NULL, /* SIOCGIWSCAN */
4634 (iw_handler) NULL, /* SIOCSIWESSID */
4635 (iw_handler) NULL, /* SIOCGIWESSID */
4636 (iw_handler) NULL, /* SIOCSIWNICKN */
4637 (iw_handler) NULL, /* SIOCGIWNICKN */
4638 (iw_handler) NULL, /* -- hole -- */
4639 (iw_handler) NULL, /* -- hole -- */
4640 (iw_handler) NULL, /* SIOCSIWRATE */
4641 (iw_handler) NULL, /* SIOCGIWRATE */
4642 (iw_handler) NULL, /* SIOCSIWRTS */
4643 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4644 (iw_handler) NULL, /* SIOCSIWFRAG */
4645 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4646 (iw_handler) NULL, /* SIOCSIWTXPOW */
4647 (iw_handler) NULL, /* SIOCGIWTXPOW */
4648 (iw_handler) NULL, /* SIOCSIWRETRY */
4649 (iw_handler) NULL, /* SIOCGIWRETRY */
4650 (iw_handler) NULL, /* SIOCSIWENCODE */
4651 (iw_handler) NULL, /* SIOCGIWENCODE */
4652 (iw_handler) NULL, /* SIOCSIWPOWER */
4653 (iw_handler) NULL, /* SIOCGIWPOWER */
4654 (iw_handler) NULL, /* -- hole -- */
4655 (iw_handler) NULL, /* -- hole -- */
4656 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4657 (iw_handler) NULL, /* SIOCGIWGENIE */
4658 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4659 (iw_handler) NULL, /* SIOCGIWAUTH */
4660 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4661 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4662 (iw_handler) NULL, /* SIOCSIWPMKSA */
4663};
4664
Jeff Johnson224f3702014-03-26 11:09:47 -07004665/*
4666 * Note that the following ioctls were defined with semantics which
4667 * cannot be handled by the "iwpriv" userspace application and hence
4668 * they are not included in the hostapd_private_args array
4669 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4670 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004671
4672static const struct iw_priv_args hostapd_private_args[] = {
4673 { QCSAP_IOCTL_SETPARAM,
4674 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4675 { QCSAP_IOCTL_SETPARAM,
4676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304677 { QCSAP_PARAM_GET_FRAME_LOGS,
4678 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 { QCSAP_PARAM_MAX_ASSOC,
4680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4681 { QCSAP_PARAM_HIDE_SSID,
4682 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004683 { QCSAP_PARAM_SET_MC_RATE,
4684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304685 { QCSAP_PARAM_SET_PROXIMITY,
4686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304687 { QCSAP_PARAM_SET_WOWL,
4688 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 { QCSAP_IOCTL_GETPARAM,
4690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4692 { QCSAP_IOCTL_GETPARAM, 0,
4693 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4694 { QCSAP_PARAM_MAX_ASSOC, 0,
4695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004696 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4697 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4698 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304700 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 { QCSAP_PARAM_CLR_ACL, 0,
4703 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4704 { QCSAP_PARAM_ACL_MODE,
4705 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304707 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 { QCSAP_IOCTL_STOPBSS,
4709 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4710 { QCSAP_IOCTL_VERSION, 0,
4711 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004712 { QCSAP_IOCTL_GET_STA_INFO, 0,
4713 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004715 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004718 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304720 { QCSAP_IOCTL_AP_STATS, 0,
4721 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Bhargav Shah7f03b812015-08-21 11:17:32 +05304722 { QCSAP_IOCTL_GET_STATS, 0,
4723 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
4724 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
4726 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304727 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004728
4729 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
4730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
4731 /* handlers for sub-ioctl */
4732 { WE_SET_WLAN_DBG,
4733 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
4734 0,
4735 "setwlandbg" },
4736
4737 /* handlers for main ioctl */
4738 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
4739 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4740 0,
4741 "" },
4742
4743 /* handlers for sub-ioctl */
4744 { WE_LOG_DUMP_CMD,
4745 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4746 0,
4747 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 { WE_P2P_NOA_CMD,
4749 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4750 0,
4751 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08004752 /* handlers for sub ioctl */
4753 {
4754 WE_MCC_CONFIG_CREDENTIAL,
4755 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4756 0,
4757 "setMccCrdnl" },
4758
4759 /* handlers for sub ioctl */
4760 {
4761 WE_MCC_CONFIG_PARAMS,
4762 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
4763 0,
4764 "setMccConfig" },
4765
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 /* handlers for main ioctl */
4767 { QCSAP_IOCTL_MODIFY_ACL,
4768 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
4769 0,
4770 "modify_acl" },
4771
4772 /* handlers for main ioctl */
4773 { QCSAP_IOCTL_GET_CHANNEL_LIST,
4774 0,
4775 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
4776 "getChannelList" },
4777
Jeff Johnsone7245742012-09-05 17:12:55 -07004778 /* handlers for main ioctl */
4779 { QCSAP_IOCTL_SET_TX_POWER,
4780 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4781 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05304782 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07004783
4784 /* handlers for main ioctl */
4785 { QCSAP_IOCTL_SET_MAX_TX_POWER,
4786 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4787 0,
4788 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05304789
4790 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
4791 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
4792 0,
4793 "dataSnapshot" },
4794
4795 /* handlers for main ioctl */
4796 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
4797 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
4798 0,
4799 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304800 /* handlers for main ioctl */
4801 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
4802 IW_PRIV_TYPE_CHAR| 512,
4803 0,
4804 "" },
4805
4806 /* handlers for sub-ioctl */
4807 { WE_WOWL_ADD_PTRN,
4808 IW_PRIV_TYPE_CHAR| 512,
4809 0,
4810 "wowlAddPtrn" },
4811
4812 { WE_WOWL_DEL_PTRN,
4813 IW_PRIV_TYPE_CHAR| 512,
4814 0,
4815 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004816};
Jeff Johnsone7245742012-09-05 17:12:55 -07004817
Jeff Johnson295189b2012-06-20 16:38:30 -07004818static const iw_handler hostapd_private[] = {
4819 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304820 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
4821 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
4822 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
4825 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
4826 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
4827 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
4828 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
4829 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
4830 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304831 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
4833 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
4834 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
4835 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004836 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07004837 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
4838 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07004839 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05304840 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05304841 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05304842 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
4843 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07004844};
4845const struct iw_handler_def hostapd_handler_def = {
4846 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
4847 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
4848 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
4849 .standard = (iw_handler *)hostapd_handler,
4850 .private = (iw_handler *)hostapd_private,
4851 .private_args = hostapd_private_args,
4852 .get_wireless_stats = NULL,
4853};
4854#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4855struct net_device_ops net_ops_struct = {
4856 .ndo_open = hdd_hostapd_open,
4857 .ndo_stop = hdd_hostapd_stop,
4858 .ndo_uninit = hdd_hostapd_uninit,
4859 .ndo_start_xmit = hdd_softap_hard_start_xmit,
4860 .ndo_tx_timeout = hdd_softap_tx_timeout,
4861 .ndo_get_stats = hdd_softap_stats,
4862 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
4863 .ndo_do_ioctl = hdd_hostapd_ioctl,
4864 .ndo_change_mtu = hdd_hostapd_change_mtu,
4865 .ndo_select_queue = hdd_hostapd_select_queue,
4866 };
4867#endif
4868
4869int hdd_set_hostapd(hdd_adapter_t *pAdapter)
4870{
4871 return VOS_STATUS_SUCCESS;
4872}
4873
4874void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
4875{
4876#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
4877 pWlanHostapdDev->netdev_ops = &net_ops_struct;
4878#else
4879 pWlanHostapdDev->open = hdd_hostapd_open;
4880 pWlanHostapdDev->stop = hdd_hostapd_stop;
4881 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
4882 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
4883 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
4884 pWlanHostapdDev->get_stats = hdd_softap_stats;
4885 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
4886 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
4887#endif
4888}
4889
4890VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304891{
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05304893#ifdef DHCP_SERVER_OFFLOAD
4894 hdd_dhcp_state_t *dhcp_status;
4895#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304896#ifdef MDNS_OFFLOAD
4897 hdd_mdns_state_t *mdns_status;
4898#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004900 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 VOS_STATUS status;
Leo Chang0b0e45a2013-12-15 15:18:55 -08004902#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08004903 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
4904 v_U16_t unsafeChannelCount;
4905#endif /* FEATURE_WLAN_CH_AVOID */
4906
Anand N Sunkad26d71b92014-12-24 18:08:22 +05304907 if (pHddCtx->isLogpInProgress) {
4908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4909 "%s:LOGP in Progress. Ignore!!!",__func__);
4910 status = VOS_STATUS_E_FAILURE;
4911 }
4912
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304914
4915#ifdef SAP_AUTH_OFFLOAD
4916 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05304917 {
4918 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
4919 {
4920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4921 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
4922 return VOS_STATUS_E_FAILURE;
4923 }
4924 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304925#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304926
Agrawal Ashish17ef5082016-10-17 18:33:21 +05304927 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05304929#ifdef DHCP_SERVER_OFFLOAD
4930 dhcp_status = &pAdapter->dhcp_status;
4931#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304932#ifdef MDNS_OFFLOAD
4933 mdns_status = &pAdapter->mdns_status;
4934#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304935
Nirav Shah7e3c8132015-06-22 23:51:42 +05304936 spin_lock_init(&pAdapter->sta_hash_lock);
4937 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
4938
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07004939 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
4940
Leo Chang0b0e45a2013-12-15 15:18:55 -08004941#ifdef FEATURE_WLAN_CH_AVOID
4942 /* Get unsafe cahnnel list from cached location */
4943 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
4944 sizeof(unsafeChannelList),
4945 &unsafeChannelCount);
4946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4947 "%s : Unsafe Channel count %d",
4948 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05304949 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08004950 unsafeChannelList,
4951 unsafeChannelCount);
4952#endif /* FEATURE_WLAN_CH_AVOID */
4953
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 // Zero the memory. This zeros the profile structure.
4955 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05304956#ifdef DHCP_SERVER_OFFLOAD
4957 memset(dhcp_status, 0,sizeof(*dhcp_status));
4958#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304959#ifdef MDNS_OFFLOAD
4960 memset(mdns_status, 0,sizeof(*mdns_status));
4961#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05304962
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 // Set up the pointer to the Wireless Extensions state structure
4964 // NOP
4965 status = hdd_set_hostapd(pAdapter);
4966 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 return status;
4969 }
4970
4971 status = vos_event_init(&phostapdBuf->vosEvent);
4972 if (!VOS_IS_STATUS_SUCCESS(status))
4973 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 return status;
4976 }
Anurag Chouhan83026002016-12-13 22:46:21 +05304977#ifdef DHCP_SERVER_OFFLOAD
4978 status = vos_event_init(&dhcp_status->vos_event);
4979 if (!VOS_IS_STATUS_SUCCESS(status)) {
4980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
4981 return status;
4982 }
4983#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05304984#ifdef MDNS_OFFLOAD
4985 status = vos_event_init(&mdns_status->vos_event);
4986 if (!VOS_IS_STATUS_SUCCESS(status)) {
4987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4988 ("Hostapd HDD vos event init failed!!"));
4989 return status;
4990 }
4991#endif /* MDNS_OFFLOAD */
4992
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
4994
4995 // Register as a wireless device
4996 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
4997
4998 //Initialize the data path module
4999 status = hdd_softap_init_tx_rx(pAdapter);
5000 if ( !VOS_IS_STATUS_SUCCESS( status ))
5001 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005002 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305004
5005 status = hdd_wmm_adapter_init( pAdapter );
5006 if (!VOS_IS_STATUS_SUCCESS(status))
5007 {
5008 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005009 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305010 status, status );
5011 goto error_wmm_init;
5012 }
5013
5014 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5015
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305016 return status;
5017
5018error_wmm_init:
5019 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 EXIT();
5021 return status;
5022}
5023
5024hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5025{
5026 struct net_device *pWlanHostapdDev = NULL;
5027 hdd_adapter_t *pHostapdAdapter = NULL;
5028 v_CONTEXT_t pVosContext= NULL;
5029
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305030 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5031#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5032 NET_NAME_UNKNOWN,
5033#endif
5034 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 if (pWlanHostapdDev != NULL)
5036 {
5037 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5038
5039 //Init the net_device structure
5040 ether_setup(pWlanHostapdDev);
5041
5042 //Initialize the adapter context to zeros.
5043 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5044 pHostapdAdapter->dev = pWlanHostapdDev;
5045 pHostapdAdapter->pHddCtx = pHddCtx;
5046 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5047
5048 //Get the Global VOSS context.
5049 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5050 //Save the adapter context in global context for future.
5051 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5052
5053 //Init the net_device structure
5054 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5055
5056 hdd_set_ap_ops( pHostapdAdapter->dev );
5057
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5059 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5060
5061 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5062 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5063
5064 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5066 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5067 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005068
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5070 }
5071 return pHostapdAdapter;
5072}
5073
5074VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5075{
5076 struct net_device *dev = pAdapter->dev;
5077 VOS_STATUS status = VOS_STATUS_SUCCESS;
5078
5079 ENTER();
5080
5081 if( rtnl_lock_held )
5082 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005083 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 if( dev_alloc_name(dev, dev->name) < 0 )
5085 {
5086 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5087 return VOS_STATUS_E_FAILURE;
5088 }
5089 }
5090 if (register_netdevice(dev))
5091 {
5092 hddLog(VOS_TRACE_LEVEL_FATAL,
5093 "%s:Failed:register_netdevice", __func__);
5094 return VOS_STATUS_E_FAILURE;
5095 }
5096 }
5097 else
5098 {
5099 if (register_netdev(dev))
5100 {
5101 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5102 return VOS_STATUS_E_FAILURE;
5103 }
5104 }
5105 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5106
5107 EXIT();
5108 return status;
5109}
5110
c_hpothu002231a2015-02-05 14:58:51 +05305111VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005112{
5113 ENTER();
5114
5115 hdd_softap_deinit_tx_rx(pAdapter);
5116
5117 /* if we are being called during driver unload, then the dev has already
5118 been invalidated. if we are being called at other times, then we can
5119 detatch the wireless device handlers */
5120 if (pAdapter->dev)
5121 {
c_hpothu002231a2015-02-05 14:58:51 +05305122 if (TRUE == rtnl_held)
5123 {
5124 pAdapter->dev->wireless_handlers = NULL;
5125 }
5126 else
5127 {
5128 rtnl_lock();
5129 pAdapter->dev->wireless_handlers = NULL;
5130 rtnl_unlock();
5131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 }
5133 EXIT();
5134 return 0;
5135}