blob: 2a5e376397b995084a4465b5e367d80f731aa22b [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;
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530413
414 ret = hdd_drv_cmd_validate(command, 8);
415 if (ret)
416 goto exit;
417
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530418 value = command + 9;
419
420 /* Convert the value from ascii to integer */
421 ret = kstrtou8(value, 10, &filterType);
422 if (ret < 0)
423 {
424 /* If the input value is greater than max value of datatype,
425 * then also kstrtou8 fails
426 */
427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
428 "%s: kstrtou8 failed range ", __func__);
429 ret = -EINVAL;
430 goto exit;
431 }
432 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
433 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
434 {
435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
436 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
437 " 2-Sink ", __func__);
438 ret = -EINVAL;
439 goto exit;
440 }
441 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
442 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530443 pScanInfo = &pHddCtx->scan_info;
444 if (filterType && pScanInfo != NULL &&
445 pHddCtx->scan_info.mScanPending)
446 {
447 /*Miracast Session started. Abort Scan */
448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
449 "%s, Aborting Scan For Miracast",__func__);
450 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
451 eCSR_SCAN_ABORT_DEFAULT);
452 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530453 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
454 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
455 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530456 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
457 {
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530458 ret = hdd_drv_cmd_validate(command, 16);
459 if (ret)
460 goto exit;
461
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530462 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
463 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700464
Jeff Johnson295189b2012-06-20 16:38:30 -0700465exit:
466 if (command)
467 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700468 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530470 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return ret;
472}
473
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700474#ifdef CONFIG_COMPAT
475static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
476 struct ifreq *ifr)
477{
478 struct {
479 compat_uptr_t buf;
480 int used_len;
481 int total_len;
482 } compat_priv_data;
483 hdd_priv_data_t priv_data;
484 int ret = 0;
485
486 /*
487 * Note that pAdapter and ifr have already been verified by caller,
488 * and HDD context has also been validated
489 */
490 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
491 sizeof(compat_priv_data))) {
492 ret = -EFAULT;
493 goto exit;
494 }
495 priv_data.buf = compat_ptr(compat_priv_data.buf);
496 priv_data.used_len = compat_priv_data.used_len;
497 priv_data.total_len = compat_priv_data.total_len;
498 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
499 exit:
500 return ret;
501}
502#else /* CONFIG_COMPAT */
503static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
504 struct ifreq *ifr)
505{
506 /* will never be invoked */
507 return 0;
508}
509#endif /* CONFIG_COMPAT */
510
511static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
512{
513 hdd_priv_data_t priv_data;
514 int ret = 0;
515
516 /*
517 * Note that pAdapter and ifr have already been verified by caller,
518 * and HDD context has also been validated
519 */
520 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
521 ret = -EFAULT;
522 } else {
523 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
524 }
525 return ret;
526}
527
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530528static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700529 struct ifreq *ifr, int cmd)
530{
531 hdd_adapter_t *pAdapter;
532 hdd_context_t *pHddCtx;
533 int ret;
534
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530535 ENTER();
536
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700537 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
538 if (NULL == pAdapter) {
539 hddLog(VOS_TRACE_LEVEL_ERROR,
540 "%s: HDD adapter context is Null", __func__);
541 ret = -ENODEV;
542 goto exit;
543 }
544 if (dev != pAdapter->dev) {
545 hddLog(VOS_TRACE_LEVEL_ERROR,
546 "%s: HDD adapter/dev inconsistency", __func__);
547 ret = -ENODEV;
548 goto exit;
549 }
550
551 if ((!ifr) || (!ifr->ifr_data)) {
552 ret = -EINVAL;
553 goto exit;
554 }
555
556 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
557 ret = wlan_hdd_validate_context(pHddCtx);
558 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700559 ret = -EBUSY;
560 goto exit;
561 }
562
563 switch (cmd) {
564 case (SIOCDEVPRIVATE + 1):
565 if (is_compat_task())
566 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
567 else
568 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
569 break;
570 default:
571 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
572 __func__, cmd);
573 ret = -EINVAL;
574 break;
575 }
576 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530577 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700578 return ret;
579}
580
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530581static int hdd_hostapd_ioctl(struct net_device *dev,
582 struct ifreq *ifr, int cmd)
583{
584 int ret;
585
586 vos_ssr_protect(__func__);
587 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
588 vos_ssr_unprotect(__func__);
589
590 return ret;
591}
592
Jeff Johnson295189b2012-06-20 16:38:30 -0700593/**---------------------------------------------------------------------------
594
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530595 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 This function sets the user specified mac address using
597 the command ifconfig wlanX hw ether <mac adress>.
598
599 \param - dev - Pointer to the net device.
600 - addr - Pointer to the sockaddr.
601 \return - 0 for success, non zero for failure
602
603 --------------------------------------------------------------------------*/
604
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530605static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700606{
607 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530608 hdd_adapter_t *pAdapter;
609 hdd_context_t *pHddCtx;
610 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530611
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530613 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
614 if (NULL == pAdapter)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: Adapter is NULL",__func__);
618 return -EINVAL;
619 }
620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
621 ret = wlan_hdd_validate_context(pHddCtx);
622 if (0 != ret)
623 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530624 return ret;
625 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
627 EXIT();
628 return 0;
629}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530630
631static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
632{
633 int ret;
634
635 vos_ssr_protect(__func__);
636 ret = __hdd_hostapd_set_mac_address(dev, addr);
637 vos_ssr_unprotect(__func__);
638
639 return ret;
640}
641
Jeff Johnson295189b2012-06-20 16:38:30 -0700642void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
643{
644 struct net_device *dev = (struct net_device *)usrDataForCallback;
645 v_BYTE_t we_custom_event[64];
646 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530648 hdd_context_t *pHddCtx;
649#ifdef DISABLE_CONCURRENCY_AUTOSAVE
650 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 hdd_ap_ctx_t *pHddApCtx;
652#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
653
654 /* event_name space-delimiter driver_module_name */
655 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
656 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
657 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
658
659 ENTER();
660
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530661 pHostapdAdapter = netdev_priv(dev);
662 if ((NULL == pHostapdAdapter) ||
663 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
664 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700665 hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530666 return;
667 }
668 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
669 if (0 != (wlan_hdd_validate_context(pHddCtx)))
670 {
671 return;
672 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530673#ifdef DISABLE_CONCURRENCY_AUTOSAVE
674 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530675 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 /*
677 This timer routine is going to be called only when AP
678 persona is up.
679 If there are concurrent sessions running we do not want
680 to shut down the Bss.Instead we run the timer again so
681 that if Autosave is enabled next time and other session
682 was down only then we bring down AP
683 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
685 vos_status = vos_timer_start(
686 &pHddApCtx->hdd_ap_inactivity_timer,
687 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
688 * 1000);
689 if (!VOS_IS_STATUS_SUCCESS(vos_status))
690 {
691 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
692 }
693 EXIT();
694 return;
695 }
696#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
697 memset(&we_custom_event, '\0', sizeof(we_custom_event));
698 memcpy(&we_custom_event, autoShutEvent, event_len);
699
700 memset(&wrqu, 0, sizeof(wrqu));
701 wrqu.data.length = event_len;
702
703 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
704 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
705
706 EXIT();
707}
708
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800709VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
710{
711 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
712 ptSapContext pSapCtx = NULL;
713 eHalStatus halStatus = eHAL_STATUS_FAILURE;
714 v_PVOID_t hHal = NULL;
715
716 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
717 "%s: UPDATE Beacon Params", __func__);
718
719 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
720 pSapCtx = VOS_GET_SAP_CB(pVosContext);
721 if ( NULL == pSapCtx )
722 {
723 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
724 "%s: Invalid SAP pointer from pvosGCtx", __func__);
725 return VOS_STATUS_E_FAULT;
726 }
727
728 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
729 if ( NULL == hHal ){
730 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
731 "%s: Invalid HAL pointer from pvosGCtx", __func__);
732 return VOS_STATUS_E_FAULT;
733 }
734 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
735 if(halStatus == eHAL_STATUS_FAILURE ){
736 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
737 "%s: Failed to update Beacon Params", __func__);
738 return VOS_STATUS_E_FAILURE;
739 }
740 }
741 return VOS_STATUS_SUCCESS;
742}
743
744void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
745{
746 v_U8_t staId = 0;
747 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530748 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
749 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800750
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530751 dev = (struct net_device *)usrDataForCallback;
752 pSapCtx = VOS_GET_SAP_CB(pVosContext);
753 if(pSapCtx == NULL){
754 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
755 FL("psapCtx is NULL"));
756 return;
757 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800758 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800759 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
760 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530761 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
763 {
764 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530765 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800766 }
767 }
768}
769
Agarwal Ashish8e538932014-12-24 18:12:52 +0530770static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800771{
772 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530773 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800774 VOS_STATUS status = VOS_STATUS_SUCCESS;
775 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530776
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800777 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530778
779 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
780 status = wlan_hdd_validate_context(pHddCtx);
781
782 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530783 return status;
784 }
785
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800786 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
787 {
788 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
789 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800791 }
792 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530793 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800794 }
795 EXIT();
796 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
797}
Jeff Johnson295189b2012-06-20 16:38:30 -0700798
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530799#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530800bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530801 bool enabled)
802{
803 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530804 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530805
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530806 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530807 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
808
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530809 sap_offload_info.sap_auth_offload_enable = enabled;
810 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530811 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530812 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530813 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
814
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530815 if (sap_offload_info.sap_auth_offload_enable &&
816 sap_offload_info.sap_auth_offload_sec_type)
817 {
818 if (sap_offload_info.key_len < 8 ||
819 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
820 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530821 hddLog(VOS_TRACE_LEVEL_ERROR,
822 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530823 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530824 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530825 }
826 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530827 if (sap_offload_info.key_len)
828 {
829 vos_mem_copy(sap_offload_info.key,
830 pHddCtx->cfg_ini->sap_auth_offload_key,
831 sap_offload_info.key_len);
832 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530833 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530834 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
835 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530836 hddLog(VOS_TRACE_LEVEL_ERROR,
837 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530838 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530839 }
840
841 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
842 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530843 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530844}
845#endif
846
Abhishek Singhe8ebb922017-11-01 13:30:26 +0530847/**
848* wlansap_get_phymode() - get SAP phymode.
849* @pctx: Pointer to the global vos context; a handle to SAP's control block
850* can be extracted from its context. When MBSSID feature is enabled,
851* SAP context is directly passed to SAP APIs.
852*
853* This function provides current phymode of SAP interface.
854*
855* Return: phymode with eCsrPhyMode type.
856*/
857static eCsrPhyMode
858wlansap_get_phymode(v_PVOID_t pctx)
859{
860 ptSapContext psapctx = VOS_GET_SAP_CB(pctx);
861
862 if (!psapctx) {
863 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
864 "%s: Invalid SAP pointer from pCtx", __func__);
865 return eCSR_DOT11_MODE_AUTO;
866 }
867 return psapctx->csrRoamProfile.phyMode;
868}
869
870/**
871 * hdd_update_chandef() - Function to update channel width and center freq
872 * @chandef: cfg80211 chan def
873 * @cb_mode: chan offset
874 *
875 * This function will be called to update channel width and center freq
876 *
877 * Return: None
878 */
879static void
880hdd_update_chandef(struct cfg80211_chan_def *chandef,
881 ePhyChanBondState cb_mode)
882{
883 uint8_t center_chan, chan;
884
885 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
886 return;
887
888 chan = vos_freq_to_chan(chandef->chan->center_freq);
889 chandef->width = NL80211_CHAN_WIDTH_80;
890 switch (cb_mode) {
891 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
892 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
893 center_chan = chan + 2;
894 break;
895 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
896 center_chan = chan + 6;
897 break;
898 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
899 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
900 center_chan = chan - 2;
901 break;
902 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
903 center_chan = chan - 6;
904 break;
905 default:
906 center_chan = chan;
907 break;
908 }
909
910 chandef->center_freq1 = vos_chan_to_freq(center_chan);
911}
912
913/**
914 * hdd_chan_change_notify() - Function to notify hostapd about channel change
915 * @hostapd_adapter: hostapd adapter
916 * @dev: Net device structure
917 * @oper_chan: New operating channel
918 *
919 * This function is used to notify hostapd about the channel change
920 *
921 * Return: Success on intimating userspace
922 *
923 */
924static VOS_STATUS hdd_chan_change_notify(hdd_adapter_t *hostapd_adapter,
925 struct net_device *dev, uint8_t oper_chan)
926{
927 struct ieee80211_channel *chan;
928 struct cfg80211_chan_def chandef;
929 enum nl80211_channel_type channel_type;
930 eCsrPhyMode phy_mode;
931 ePhyChanBondState cb_mode;
932 uint32_t freq;
933 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(hostapd_adapter);
934 tSmeConfigParams sme_config;
935
936 if (!hal) {
937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
938 "%s: hal is NULL", __func__);
939 return VOS_STATUS_E_FAILURE;
940 }
941
942 freq = vos_chan_to_freq(oper_chan);
943
944 chan = __ieee80211_get_channel(hostapd_adapter->wdev.wiphy, freq);
945
946 if (!chan) {
947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
948 "%s: Invalid input frequency for channel conversion", __func__);
949 return VOS_STATUS_E_FAILURE;
950 }
951
952 phy_mode = wlansap_get_phymode(
953 (WLAN_HDD_GET_CTX(hostapd_adapter))->pvosContext);
954 sme_GetConfigParam(hal, &sme_config);
955 if (oper_chan <= 14)
956 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
957 sme_config.csrConfig.channelBondingMode24GHz);
958 else
959 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
960 sme_config.csrConfig.channelBondingMode5GHz);
961
962 switch (phy_mode) {
963 case eCSR_DOT11_MODE_11n:
964 case eCSR_DOT11_MODE_11n_ONLY:
965 case eCSR_DOT11_MODE_11ac:
966 case eCSR_DOT11_MODE_11ac_ONLY:
967 switch (cb_mode) {
968 case PHY_SINGLE_CHANNEL_CENTERED:
969 channel_type = NL80211_CHAN_HT20;
970 break;
971 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
972 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
973 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
974 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
975 channel_type = NL80211_CHAN_HT40MINUS;
976 break;
977 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
978 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
979 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
980 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
981 channel_type = NL80211_CHAN_HT40PLUS;
982 break;
983 default:
984 channel_type = NL80211_CHAN_HT20;
985 break;
986 }
987 break;
988 default:
989 channel_type = NL80211_CHAN_NO_HT;
990 break;
991 }
992
993 cfg80211_chandef_create(&chandef, chan, channel_type);
994 if ((phy_mode == eCSR_DOT11_MODE_11ac) ||
995 (phy_mode == eCSR_DOT11_MODE_11ac_ONLY))
996 hdd_update_chandef(&chandef, cb_mode);
997
998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
999 "%s: phy_mode %d cb_mode %d chann_type %d oper_chan %d width %d freq_1 %d",
1000 __func__, phy_mode, cb_mode, channel_type, oper_chan,
1001 chandef.width, chandef.center_freq1);
1002
1003
1004 cfg80211_ch_switch_notify(dev, &chandef);
1005
1006 return VOS_STATUS_SUCCESS;
1007}
1008
1009
1010
Jeff Johnson295189b2012-06-20 16:38:30 -07001011VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
1012{
1013 hdd_adapter_t *pHostapdAdapter;
1014 hdd_ap_ctx_t *pHddApCtx;
1015 hdd_hostapd_state_t *pHostapdState;
1016 struct net_device *dev;
1017 eSapHddEvent sapEvent;
1018 union iwreq_data wrqu;
1019 v_BYTE_t *we_custom_event_generic = NULL;
1020 int we_event = 0;
1021 int i = 0;
1022 v_U8_t staId;
1023 VOS_STATUS vos_status;
1024 v_BOOL_t bWPSState;
1025 v_BOOL_t bApActive = FALSE;
1026 v_BOOL_t bAuthRequired = TRUE;
1027 tpSap_AssocMacAddr pAssocStasArray = NULL;
1028 char unknownSTAEvent[IW_CUSTOM_MAX+1];
1029 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
1030 v_BYTE_t we_custom_start_event[64];
1031 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001032 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001033 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -07001034 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301035 v_CONTEXT_t pVosContext = NULL;
1036 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +05301037 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -07001038
1039 dev = (struct net_device *)usrDataForCallback;
1040 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +05301041
1042 if ((NULL == pHostapdAdapter) ||
1043 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
1044 {
1045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1046 "invalid adapter or adapter has invalid magic");
1047 return eHAL_STATUS_FAILURE;
1048 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301049 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1050 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1051 if(pSapCtx == NULL){
1052 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1053 FL("psapCtx is NULL"));
1054 return eHAL_STATUS_FAILURE;
1055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1057 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1058 sapEvent = pSapEvent->sapHddEventCode;
1059 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001060 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +05301061 cfg_param = pHddCtx->cfg_ini;
1062
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
1064 switch(sapEvent)
1065 {
1066 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -08001067 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
1069 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
1070 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
1071
1072 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
1073 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +05301074
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +05301076 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 goto stopbss;
1079 }
1080 else
Deepthi Gowried085092015-10-20 19:30:52 +05301081 {
1082 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1083 {
1084 if ((cfg_param->dynSplitscan) &&
1085 (!pHddCtx->issplitscan_enabled))
1086 {
1087 pHddCtx->issplitscan_enabled = TRUE;
1088 sme_enable_disable_split_scan(
1089 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
1090 cfg_param->nNumStaChanCombinedConc,
1091 cfg_param->nNumP2PChanCombinedConc);
1092 }
1093 }
1094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1096 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +05301097 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1098 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +05301099 {
c_hpothuffdb5272013-10-02 16:42:35 +05301100 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +05301101 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
1102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 }
Deepthi Gowried085092015-10-20 19:30:52 +05301104
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1106 {
1107 // AP Inactivity timer init and start
1108 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1109 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1110 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001111 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
1113 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1114 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001115 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001116
1117 }
1118 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1119 pHostapdState->bssState = BSS_START;
1120
1121 // Send current operating channel of SoftAP to BTC-ES
1122 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1123
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 //Check if there is any group key pending to set.
1125 if( pHddApCtx->groupKey.keyLength )
1126 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001127 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1129 &pHddApCtx->groupKey ) )
1130 {
1131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1132 "%s: WLANSAP_SetKeySta failed", __func__);
1133 }
1134 pHddApCtx->groupKey.keyLength = 0;
1135 }
1136 else if ( pHddApCtx->wepKey[0].keyLength )
1137 {
1138 int i=0;
1139 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1140 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001141 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1143 &pHddApCtx->wepKey[i] ) )
1144 {
1145 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1146 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 }
1149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1151 startBssEvent = "SOFTAP.enabled";
1152 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1153 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1154 memset(&wrqu, 0, sizeof(wrqu));
1155 wrqu.data.length = strlen(startBssEvent);
1156 we_event = IWEVCUSTOM;
1157 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001158 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 break; //Event will be sent after Switch-Case stmt
1160
1161 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001162 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1164
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001165 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001166 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301169
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301170 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301171 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301172 hddLog(LOG1,
1173 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1174 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301175 }
1176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 goto stopbss;
1178 case eSAP_STA_SET_KEY_EVENT:
1179 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001180 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1182 return VOS_STATUS_SUCCESS;
1183 case eSAP_STA_DEL_KEY_EVENT:
1184 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001185 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 return VOS_STATUS_SUCCESS;
1187 case eSAP_STA_MIC_FAILURE_EVENT:
1188 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 memset(&msg, '\0', sizeof(msg));
1190 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001191 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001192 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001193 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 msg.flags = IW_MICFAILURE_GROUP;
1195 else
1196 msg.flags = IW_MICFAILURE_PAIRWISE;
1197 memset(&wrqu, 0, sizeof(wrqu));
1198 wrqu.data.length = sizeof(msg);
1199 we_event = IWEVMICHAELMICFAILURE;
1200 we_custom_event_generic = (v_BYTE_t *)&msg;
1201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 /* inform mic failure to nl80211 */
1203 cfg80211_michael_mic_failure(dev,
1204 pSapEvent->sapevt.
1205 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001206 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 NL80211_KEYTYPE_GROUP :
1208 NL80211_KEYTYPE_PAIRWISE),
1209 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1210 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1211 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 break;
1213
1214 case eSAP_STA_ASSOC_EVENT:
1215 case eSAP_STA_REASSOC_EVENT:
1216 wrqu.addr.sa_family = ARPHRD_ETHER;
1217 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001218 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001219 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 we_event = IWEVREGISTERED;
1221
1222 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1223
1224 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1225 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1226 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1227 {
1228 bAuthRequired = FALSE;
1229 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301230 /* fAuthRequiredshould should be false for sap offload */
1231 if ((bAuthRequired || bWPSState)
1232#ifdef SAP_AUTH_OFFLOAD
1233 && !cfg_param->enable_sap_auth_offload
1234#endif
1235 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 {
c_hpothuffdb5272013-10-02 16:42:35 +05301237 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 TRUE,
1239 pHddApCtx->uPrivacy,
1240 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1241 0,
1242 0,
1243 (v_MACADDR_t *)wrqu.addr.sa_data,
1244 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301245
1246 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1247 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1248 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 }
1250 else
1251 {
c_hpothuffdb5272013-10-02 16:42:35 +05301252 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 FALSE,
1254 pHddApCtx->uPrivacy,
1255 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1256 0,
1257 0,
1258 (v_MACADDR_t *)wrqu.addr.sa_data,
1259 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301260 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1261 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1262 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001263 }
1264
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301265 staId =
1266 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1267 if (VOS_IS_STATUS_SUCCESS(vos_status))
1268 {
1269
1270 pSapCtx->aStaInfo[staId].rate_flags =
1271 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1272 }
1273
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 // Stop AP inactivity timer
1275 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1276 {
1277 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1278 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001279 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001281#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001282 if (wake_lock_active(&pHddCtx->sap_wake_lock))
1283 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301284 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1285 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001286 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301287 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1288 HDD_SAP_WAKE_LOCK_DURATION,
1289 WIFI_POWER_EVENT_WAKELOCK_SAP);
1290
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001291#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001292#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1293 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301294 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1296
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301297 staInfo = vos_mem_malloc(sizeof(*staInfo));
1298 if (staInfo == NULL) {
1299 hddLog(LOGE, FL("alloc station_info failed"));
1300 return VOS_STATUS_E_NOMEM;
1301 }
1302
1303 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1305 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301306 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301308 staInfo->assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07001309#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301310 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001311#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 cfg80211_new_sta(dev,
1313 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301314 staInfo, GFP_KERNEL);
1315 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317 else
1318 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001319 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
1321 }
1322#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301323 hdd_manage_delack_timer(pHddCtx);
1324
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001325 pScanInfo = &pHddCtx->scan_info;
1326 // Lets do abort scan to ensure smooth authentication for client
1327 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1328 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301329 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301330 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001332
1333 break;
1334 case eSAP_STA_DISASSOC_EVENT:
1335 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001336 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001337 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1339 hddLog(LOG1," User initiated disassociation");
1340 else
1341 hddLog(LOG1," MAC initiated disassociation");
1342 we_event = IWEVEXPIRED;
1343 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1344 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1345 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001346 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 -07001347 return VOS_STATUS_E_FAILURE;
1348 }
1349 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1350
1351 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1352 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301353 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 // Start AP inactivity timer if no stations associated with it
1355 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1356 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301357 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 {
1359 bApActive = TRUE;
1360 break;
1361 }
1362 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301363 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001364
1365 if (bApActive == FALSE)
1366 {
1367 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1368 {
1369 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1370 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001371 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 }
1373 else
1374 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1375 }
1376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001377#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1378 cfg80211_del_sta(dev,
1379 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1380 GFP_KERNEL);
1381#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001382 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301383 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1384 if (VOS_STATUS_SUCCESS != vos_status)
1385 {
1386 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1387 __func__, vos_status);
1388 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301389 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 break;
1391 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1392 {
1393 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1394 union iwreq_data wreq;
1395
1396 down(&pHddApCtx->semWpsPBCOverlapInd);
1397 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1398
1399 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1400 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1401
1402 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001403 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 memset(&wreq, 0, sizeof(wreq));
1405 wreq.data.length = strlen(message); // This is length of message
1406 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1407
1408 return VOS_STATUS_SUCCESS;
1409 }
1410 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1411 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1412 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1413 { // List of associated stations
1414 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1415 {
1416 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1417 i+1,
1418 pAssocStasArray->assocId,
1419 pAssocStasArray->staId,
1420 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1421 pAssocStasArray++;
1422 }
1423 }
1424 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001425 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 case eSAP_REMAIN_CHAN_READY:
1428 hdd_remainChanReadyHandler( pHostapdAdapter );
1429 return VOS_STATUS_SUCCESS;
1430 case eSAP_SEND_ACTION_CNF:
1431 hdd_sendActionCnf( pHostapdAdapter,
1432 ( eSAP_STATUS_SUCCESS ==
1433 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1434 TRUE : FALSE );
1435 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 case eSAP_UNKNOWN_STA_JOIN:
1437 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1438 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1439 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1440 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1441 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1442 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1443 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1444 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1445 wrqu.data.pointer = unknownSTAEvent;
1446 wrqu.data.length = strlen(unknownSTAEvent);
1447 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301448 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 break;
1450
1451 case eSAP_MAX_ASSOC_EXCEEDED:
1452 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1453 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1454 " one or more devices to enable the new device connection",
1455 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1456 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1457 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1458 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1459 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1460 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1461 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1462 wrqu.data.pointer = maxAssocExceededEvent;
1463 wrqu.data.length = strlen(maxAssocExceededEvent);
1464 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001465 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 break;
1467 case eSAP_STA_ASSOC_IND:
1468 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001469
1470 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001471 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001472 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1473 return VOS_STATUS_SUCCESS;
1474
1475 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301476 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301477 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1478 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301479 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301480 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001481 return VOS_STATUS_SUCCESS;
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301482 case eSAP_CHANNEL_CHANGED_EVENT:
1483 hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001484
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301485 return hdd_chan_change_notify(pHostapdAdapter, dev,
1486 pSapEvent->sapevt.sap_chan_selected.new_chan);
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001488 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 goto stopbss;
1490 return VOS_STATUS_SUCCESS;
1491 }
1492 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1493 return VOS_STATUS_SUCCESS;
1494
1495stopbss :
1496 {
1497 v_BYTE_t we_custom_event[64];
1498 char *stopBssEvent = "STOP-BSS.response";//17
1499 int event_len = strlen(stopBssEvent);
1500
1501 hddLog(LOG1, FL("BSS stop status = %s"),
1502 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1503 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1504
1505 /* Change the BSS state now since, as we are shutting things down,
1506 * we don't want interfaces to become re-enabled */
1507 pHostapdState->bssState = BSS_STOP;
1508
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301509 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1510 {
1511 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1512 {
1513 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1514 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1515 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1516 }
1517
1518 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1519 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1520 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1521 }
1522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 /* Stop the pkts from n/w stack as we are going to free all of
1524 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301525
1526 /*
1527 * If channel avoidance is in progress means driver is performing SAP
1528 * restart. So don't do carrier off, which may lead framework to do
1529 * driver reload.
1530 */
1531 hddLog(LOG1, FL("ch avoid in progress: %d"),
1532 pHddCtx->is_ch_avoid_in_progress);
1533 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301534 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301535 netif_tx_disable(dev);
1536 else
1537 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001538
1539 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301540 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1541 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1542 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001543
Amar Singhal37e6f052013-03-05 16:16:54 -08001544 /* once the event is set, structure dev/pHostapdAdapter should
1545 * not be touched since they are now subject to being deleted
1546 * by another thread */
1547 if (eSAP_STOP_BSS_EVENT == sapEvent)
1548 vos_event_set(&pHostapdState->vosEvent);
1549
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 /* notify userspace that the BSS has stopped */
1551 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1552 memcpy(&we_custom_event, stopBssEvent, event_len);
1553 memset(&wrqu, 0, sizeof(wrqu));
1554 wrqu.data.length = event_len;
1555 we_event = IWEVCUSTOM;
1556 we_custom_event_generic = we_custom_event;
1557 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001558 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 }
1560 return VOS_STATUS_SUCCESS;
1561}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001562
1563int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001565 eCsrEncryptionType *pEncryptType,
1566 eCsrEncryptionType *mcEncryptType,
1567 eCsrAuthType *pAuthType,
1568 v_BOOL_t *pMFPCapable,
1569 v_BOOL_t *pMFPRequired,
1570 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 u_int8_t *gen_ie )
1572{
1573 tDot11fIERSN dot11RSNIE;
1574 tDot11fIEWPA dot11WPAIE;
1575
1576 tANI_U8 *pRsnIe;
1577 tANI_U16 RSNIeLen;
1578
1579 if (NULL == halHandle)
1580 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001581 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 return -EINVAL;
1583 }
1584
1585 // Validity checks
1586 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1587 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1588 return -EINVAL;
1589 // Type check
1590 if ( gen_ie[0] == DOT11F_EID_RSN)
1591 {
1592 // Validity checks
1593 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1594 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1595 {
1596 return VOS_STATUS_E_FAILURE;
1597 }
1598 // Skip past the EID byte and length byte
1599 pRsnIe = gen_ie + 2;
1600 RSNIeLen = gen_ie_len - 2;
1601 // Unpack the RSN IE
1602 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
1603 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1604 pRsnIe,
1605 RSNIeLen,
1606 &dot11RSNIE);
1607 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001608 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001609 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001610 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001611 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 /*Here we have followed the apple base code,
1613 but probably I suspect we can do something different*/
1614 //dot11RSNIE.akm_suite_count
1615 // Just translate the FIRST one
1616 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1617 //dot11RSNIE.pwise_cipher_suite_count
1618 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1619 //dot11RSNIE.gp_cipher_suite_count
1620 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1621 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001622 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1623 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001624
1625 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1626 } else
1627 if (gen_ie[0] == DOT11F_EID_WPA)
1628 {
1629 // Validity checks
1630 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1631 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1632 {
1633 return VOS_STATUS_E_FAILURE;
1634 }
1635 // Skip past the EID byte and length byte - and four byte WiFi OUI
1636 pRsnIe = gen_ie + 2 + 4;
1637 RSNIeLen = gen_ie_len - (2 + 4);
1638 // Unpack the WPA IE
1639 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
1640 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1641 pRsnIe,
1642 RSNIeLen,
1643 &dot11WPAIE);
1644 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001645 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001646 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001647 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001648 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 //dot11WPAIE.auth_suite_count
1650 // Just translate the FIRST one
1651 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1652 //dot11WPAIE.unicast_cipher_count
1653 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1654 //dot11WPAIE.unicast_cipher_count
1655 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001656 *pMFPCapable = VOS_FALSE;
1657 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 }
1659 else
1660 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001661 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 return VOS_STATUS_E_FAILURE;
1663 }
1664 return VOS_STATUS_SUCCESS;
1665}
Leo Chang614d2072013-08-22 14:59:44 -07001666
Leo Chang0b0e45a2013-12-15 15:18:55 -08001667#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001668
1669/*==========================================================================
1670 FUNCTION sapUpdateUnsafeChannelList
1671
1672 DESCRIPTION
1673 Function Undate unsafe channel list table
1674
1675 DEPENDENCIES
1676 NA.
1677
1678 PARAMETERS
1679
1680 IN
1681 pSapCtx : SAP context pointer, include unsafe channel list
1682
1683 RETURN VALUE
1684 NONE
1685============================================================================*/
1686void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1687 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1688{
1689 v_U16_t i, j;
1690
1691 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1692 sizeof(pHddCtx->unsafeChannelList));
1693 if (0 == unsafeChannelCount)
1694 {
1695 pHddCtx->unsafeChannelCount = 0;
1696 }
1697 else
1698 {
c_hpothu8de53e42014-08-22 15:00:37 +05301699 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1700 {
1701 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1702 FL("unsafeChannelCount%hd greater than %d"),
1703 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1704 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1705 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001706 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1707 unsafeChannelList,
1708 unsafeChannelCount * sizeof(tANI_U16));
1709 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1710 }
1711
1712 /* Flush, default set all channel safe */
1713 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1714 {
1715 safeChannels[i].isSafe = VOS_TRUE;
1716 }
1717
1718 /* Try to find unsafe channel */
1719 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1720 {
1721 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1722 {
1723 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1724 {
1725 /* Found unsafe channel, update it */
1726 safeChannels[j].isSafe = VOS_FALSE;
1727 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1728 "%s : CH %d is not safe",
1729 __func__, pHddCtx->unsafeChannelList[i]);
1730 break;
1731 }
1732 }
1733 }
1734
1735 return;
1736}
1737
Kapil Gupta137ef892016-12-13 19:38:00 +05301738/**
1739 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1740 * @adapter: hdd ap adapter
1741 *
1742 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1743 * and if ACS is enabled, driver will ask userspace to restart the
1744 * sap. User space on LTE coex indication restart driver.
1745 *
1746 * Return - none
1747 */
1748static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1749 hdd_context_t *hdd_ctx)
1750{
1751
1752 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1753 return;
1754 }
1755
1756 hddLog(LOG1, FL("Current operation channel %d"),
1757 adapter->sessionCtx.ap.operatingChannel);
1758 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1759 hdd_change_ch_avoidance_status(hdd_ctx, true);
1760
1761 vos_flush_work(
1762 &hdd_ctx->sap_start_work);
1763
1764 /*
1765 * current operating channel
1766 * is un-safe channel, restart SAP
1767 */
1768 hddLog(LOG1,
1769 FL("Restarting SAP due to unsafe channel"));
1770
1771 adapter->sessionCtx.ap.sapConfig.channel =
1772 AUTO_CHANNEL_SELECT;
1773
Kapil Gupta137ef892016-12-13 19:38:00 +05301774
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301775 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05301776 netif_tx_disable(adapter->dev);
1777 schedule_work(&hdd_ctx->sap_start_work);
1778 } else {
1779 hdd_hostapd_stop(adapter->dev);
1780 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301781
1782 return;
1783 }
1784 return;
1785}
1786
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301787void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
1788 hdd_context_t *hdd_ctxt)
1789{
1790 v_U16_t channelLoop;
1791 v_U16_t unsafeChannelCount = 0;
1792 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1793
1794 /* Get unsafe channel list */
1795 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
1796 &unsafeChannelCount);
1797 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
1798 {
1799 if ((unsafeChannelList[channelLoop] ==
1800 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
1801 if ((AUTO_CHANNEL_SELECT ==
1802 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
1803 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
1804 /*
1805 * current operating channel is un-safe channel
1806 * restart driver
1807 */
1808 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
1809 /*
1810 * On LE, this event is handled by wlan-services to
1811 * restart SAP. On android, this event would be
1812 * ignored.
1813 */
1814 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
1815 NULL, 0);
1816 }
1817 break;
1818 }
1819 }
1820 return;
1821}
1822
1823
Kapil Gupta137ef892016-12-13 19:38:00 +05301824
Leo Chang0b0e45a2013-12-15 15:18:55 -08001825/**---------------------------------------------------------------------------
1826
1827 \brief hdd_hostapd_ch_avoid_cb() -
1828
1829 Avoid channel notification from FW handler.
1830 FW will send un-safe channle list to avoid overwrapping.
1831 hostapd should not use notified channel
1832
1833 \param - pAdapter HDD adapter pointer
1834 indParam channel avoid notification parameter
1835
1836 \return - None
1837
1838 --------------------------------------------------------------------------*/
1839void hdd_hostapd_ch_avoid_cb
1840(
Kapil Gupta137ef892016-12-13 19:38:00 +05301841 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08001842 void *indParam
1843)
1844{
1845 hdd_adapter_t *pHostapdAdapter = NULL;
1846 hdd_context_t *hddCtxt;
1847 tSirChAvoidIndType *chAvoidInd;
1848 v_U8_t rangeLoop;
1849 v_U16_t channelLoop;
1850 v_U16_t dupCheck;
1851 v_U16_t startChannel;
1852 v_U16_t endChannel;
1853 v_U16_t unsafeChannelCount = 0;
1854 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1855 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001856 tHddAvoidFreqList hddAvoidFreqList;
1857 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301858#ifdef WLAN_FEATURE_AP_HT40_24G
1859 ptSapContext pSapCtx = NULL;
1860 tHalHandle hHal;
1861 v_U8_t cbMode;
1862 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1863 v_U32_t delay;
1864#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08001865
1866 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05301867 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001868 {
1869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1870 "%s : Invalid arguments", __func__);
1871 return;
1872 }
1873
Kapil Gupta137ef892016-12-13 19:38:00 +05301874 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08001875 chAvoidInd = (tSirChAvoidIndType *)indParam;
1876 pVosContext = hddCtxt->pvosContext;
1877
1878 /* Make unsafe channel list */
1879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1880 "%s : band count %d",
1881 __func__, chAvoidInd->avoidRangeCount);
1882 vos_mem_zero((void *)unsafeChannelList,
1883 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
1884 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
1885 {
Abhishek Singh57a31542016-01-04 21:01:43 +05301886 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1887 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1888 break;
1889 }
1890 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001891 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05301892 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08001893 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
1894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1895 "%s : start %d : %d, end %d : %d",
1896 __func__,
1897 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
1898 startChannel,
1899 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
1900 endChannel);
1901 for (channelLoop = startChannel;
1902 channelLoop < (endChannel + 1);
1903 channelLoop++)
1904 {
1905 /* Channel duplicate check routine */
1906 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
1907 {
1908 if (unsafeChannelList[dupCheck] == channelLoop)
1909 {
1910 /* This channel is duplicated */
1911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1912 "%s : found duplicated channel %d",
1913 __func__, channelLoop);
1914 break;
1915 }
1916 }
1917 if (dupCheck == unsafeChannelCount)
1918 {
c_hpothu8de53e42014-08-22 15:00:37 +05301919 int ii;
1920 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
1921 {
1922 if (channelLoop == safeChannels[ii].channelNumber)
1923 {
1924 unsafeChannelList[unsafeChannelCount] = channelLoop;
1925 unsafeChannelCount++;
1926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1927 "%s : unsafe channel %d, count %d",
1928 __func__,
1929 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05301930 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
1931 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
1932 break;
1933 }
c_hpothu8de53e42014-08-22 15:00:37 +05301934 }
1935 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001936 }
1937 else
1938 {
1939 /* DUP, do nothing */
1940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1941 "%s : duplicated channel %d",
1942 __func__, channelLoop);
1943 }
1944 }
1945 }
1946 /* Update unsafe channel cache
1947 * WCN Platform Driver cache */
1948 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
1949 unsafeChannelCount);
1950
1951 /* Store into local cache
1952 * Start with STA and later start SAP
1953 * in this scenario, local cache will be used */
1954 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
1955 unsafeChannelList,
1956 unsafeChannelCount);
1957
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001958 /* generate vendor specific event */
1959 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
1960 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
1961 {
1962 hddAvoidFreqList.avoidFreqRange[i].startFreq =
1963 chAvoidInd->avoidFreqRange[i].startFreq;
1964 hddAvoidFreqList.avoidFreqRange[i].endFreq =
1965 chAvoidInd->avoidFreqRange[i].endFreq;
1966 }
1967 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
1968
1969 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
1970
Leo Chang0b0e45a2013-12-15 15:18:55 -08001971 /* Get SAP context first
1972 * SAP and P2PGO would not concurrent */
1973 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301974#ifdef WLAN_FEATURE_AP_HT40_24G
1975 if (NULL == pHostapdAdapter)
1976 {
1977 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
1978 }
1979#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05301980 if ((pHostapdAdapter) &&
1981 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
1982 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08001983 {
1984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1985 "%s : Current operation channel %d",
1986 __func__,
1987 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301988 /* Check and Restart the SAP if it is on unsafe channel */
1989 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
1990
Leo Chang0b0e45a2013-12-15 15:18:55 -08001991 }
1992
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05301993#ifdef WLAN_FEATURE_AP_HT40_24G
1994 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
1995 {
1996 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1997
1998 if(pSapCtx == NULL)
1999 {
2000 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
2001 FL("psapCtx is NULL"));
2002 return;
2003 }
2004
2005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2006 FL("SAP Secondary channel: %d "),
2007 pSapCtx->sap_sec_chan);
2008
2009 /* tHalHandle */
2010 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2011
2012 if (NULL == hHal)
2013 {
2014 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2015 FL("In invalid hHal"));
2016 return;
2017 }
2018
2019 cbMode = sme_GetChannelBondingMode24G(hHal);
2020
2021 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2022 FL("Selected Channel bonding : %d"), cbMode);
2023
2024 if (cbMode && (pSapCtx->sap_sec_chan > 0))
2025 {
2026 int i;
2027 eHalStatus halStatus;
2028
2029 for (i = 0; i < unsafeChannelCount; i++)
2030 {
2031 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
2032 {
2033 /* Current SAP Secondary channel is un-safe channel */
2034 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2035 FL("Move SAP from HT40 to HT20"));
2036
2037 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
2038 PHY_SINGLE_CHANNEL_CENTERED);
2039
2040 if (halStatus == eHAL_STATUS_FAILURE)
2041 {
2042 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2043 FL("Failed to change HT20/40 mode"));
2044 return;
2045 }
2046
2047 /* Disable Channel Bonding for 2.4GHz */
2048 sme_UpdateChannelBondingMode24G(hHal,
2049 PHY_SINGLE_CHANNEL_CENTERED);
2050 return;
2051 }
2052 }
2053 }
2054
2055 if ((!pSapCtx->numHT40IntoSta)
2056 && (pHostapdAdapter)
2057 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
2058 {
2059 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
2060 * are Safe then start HT20/40 timer to Move SAP from HT20
2061 * to HT40.
2062 */
2063 if (((!unsafeChannelCount)
2064 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
2065 {
2066 /* Stop Previous Running HT20/40 Timer & Start timer
2067 with (OBSS TransitionDelayFactor * obss interval)
2068 delay after time out move AP from HT20 -> HT40
2069 mode
2070 */
2071 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2072 {
2073 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2074 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2075 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2076 FL("Failed to Stop HT20/40 timer"));
2077 }
2078
2079 delay =
2080 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
2081
2082 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2083 FL("Start HT20/40 transition timer (%d sec)"), delay);
2084
2085 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
2086 (delay * 1000));
2087
2088 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2089 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2090 FL("Failed to Start HT20/40 timer"));
2091 }
2092 else
2093 {
2094 /* Stop HT20/40 Timer */
2095 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2096 {
2097 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2098 FL("Stop HT20/40 transition timer"));
2099 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2100 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2101 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2102 FL("Failed to Stop HT20/40 timer"));
2103 }
2104 }
2105 }
2106 }
2107#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002108 return;
2109}
Leo Chang0b0e45a2013-12-15 15:18:55 -08002110#endif /* FEATURE_WLAN_CH_AVOID */
2111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302113static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 struct iw_request_info *info,
2115 union iwreq_data *wrqu, char *extra)
2116{
2117 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002118 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302119 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 int *value = (int *)extra;
2121 int sub_cmd = value[0];
2122 int set_value = value[1];
2123 eHalStatus status;
2124 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302125 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002126 v_CONTEXT_t pVosContext;
2127
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302128 ENTER();
2129
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302130 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002131 {
2132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302133 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002134 __func__);
2135 return -1;
2136 }
2137
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302138 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2139 ret = wlan_hdd_validate_context(pHddCtx);
2140 if (0 != ret)
2141 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302142 return -1;
2143 }
2144
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002145 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2146 if (!hHal)
2147 {
2148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2149 "%s: Hal ctx is null", __func__);
2150 return -1;
2151 }
2152
2153 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2154 if (!pVosContext)
2155 {
2156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2157 "%s: Vos ctx is null", __func__);
2158 return -1;
2159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161 switch(sub_cmd)
2162 {
2163
2164 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002165 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302167 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 }
2169 break;
2170
2171 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302172 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2174 {
2175 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2176 ret = -EINVAL;
2177 }
2178 else
2179 {
2180 WLANSAP_SetMode(pVosContext, set_value);
2181 }
2182 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302183
2184 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2185 if ((0 != set_value) && (1 != set_value))
2186 {
2187 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2188 ret = -EINVAL;
2189 }
2190 else
2191 {
2192 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2193 }
2194 break;
2195
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 case QCSAP_PARAM_MAX_ASSOC:
2197 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2198 {
2199 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2200 ret = -EINVAL;
2201 }
2202 else
2203 {
2204 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2205 {
2206 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2207 "Setting it to max allowed and continuing"),
2208 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2209 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2210 }
2211 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2212 set_value, NULL, eANI_BOOLEAN_FALSE);
2213 if ( status != eHAL_STATUS_SUCCESS )
2214 {
2215 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2216 status);
2217 ret = -EIO;
2218 }
2219 }
2220 break;
2221
2222 case QCSAP_PARAM_HIDE_SSID:
2223 {
2224 eHalStatus status = eHAL_STATUS_SUCCESS;
2225 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2226 if(eHAL_STATUS_SUCCESS != status)
2227 {
2228 hddLog(VOS_TRACE_LEVEL_ERROR,
2229 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002230 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 return status;
2232 }
2233 break;
2234 }
2235
Leo Chang614d2072013-08-22 14:59:44 -07002236 case QCSAP_PARAM_SET_MC_RATE:
2237 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002238 tSirRateUpdateInd *rateUpdate;
2239
2240 rateUpdate = (tSirRateUpdateInd *)
2241 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2242 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002243 {
2244 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002245 "%s: SET_MC_RATE indication alloc fail", __func__);
2246 ret = -1;
2247 break;
2248 }
2249 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2250
2251 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2252 /* Ignore unicast */
2253 rateUpdate->ucastDataRate = -1;
2254 rateUpdate->mcastDataRate24GHz = set_value;
2255 rateUpdate->mcastDataRate5GHz = set_value;
2256 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2257 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2258 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2259 if (eHAL_STATUS_SUCCESS != status)
2260 {
2261 hddLog(VOS_TRACE_LEVEL_ERROR,
2262 "%s: SET_MC_RATE failed", __func__);
2263 vos_mem_free(rateUpdate);
2264 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002265 }
2266 break;
2267 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302268 case QCSAP_PARAM_GET_FRAME_LOGS:
2269 {
2270 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2271 != VOS_STATUS_SUCCESS)
2272 {
2273 ret = -EINVAL;
2274 }
2275 break;
2276 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302277 case QCSAP_PARAM_SET_PROXIMITY:
2278 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302279 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302280 break;
2281 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302282 case QCSAP_PARAM_SET_WOWL:
2283 {
2284 if (!pHddCtx->is_ap_mode_wow_supported)
2285 {
2286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2287 "%s: Not supported",__func__);
2288 return -ENOTSUPP;
2289 }
2290 switch (set_value)
2291 {
2292 case 0x00:
2293 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2294 break;
2295 case 0x01:
2296 case 0x02:
2297 case 0x03:
2298 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2299 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2300 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2301 (enable_magic_pkt ? "YES":"NO"),
2302 (enable_pattrn_byte_match ? "YES":"NO"));
2303 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2304 enable_pattrn_byte_match);
2305 break;
2306 default:
2307 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2308 ret = -EINVAL;
2309 break;
2310 }
2311 break;
2312 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302313 case QCSAP_PARAM_CAP_TSF:
2314 {
2315 ret = hdd_capture_tsf(pHostapdAdapter,
2316 (uint32_t *)&set_value, 1);
2317 break;
2318 }
Abhishek Singh02605092017-10-25 14:06:12 +05302319 case QCSAP_PARAM_SET_CHANNEL_CHANGE:
2320 if ((WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) ||
2321 (WLAN_HDD_P2P_GO == pHostapdAdapter->device_mode)) {
2322 hddLog(LOG1, FL("ET Channel Change to new channel= %d"),
2323 set_value);
2324 ret = wlansap_set_channel_change(pVosContext, set_value);
2325 } else {
2326 hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"),
2327 set_value);
2328 ret = -EINVAL;
2329 }
2330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 default:
2332 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2333 sub_cmd, set_value);
2334 ret = -EINVAL;
2335 break;
2336 }
2337
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302338 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 return ret;
2340}
2341
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302342int
2343static iw_softap_setparam(struct net_device *dev,
2344 struct iw_request_info *info,
2345 union iwreq_data *wrqu, char *extra)
2346{
2347 int ret;
2348
2349 vos_ssr_protect(__func__);
2350 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2351 vos_ssr_unprotect(__func__);
2352
2353 return ret;
2354}
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
2356int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302357static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 struct iw_request_info *info,
2359 union iwreq_data *wrqu, char *extra)
2360{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302361 hdd_adapter_t *pHostapdAdapter;
2362 tHalHandle hHal;
2363 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 int *value = (int *)extra;
2365 int sub_cmd = value[0];
2366 eHalStatus status;
2367 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302368 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002369
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302370 ENTER();
2371
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302372 pHostapdAdapter = (netdev_priv(dev));
2373 if (NULL == pHostapdAdapter)
2374 {
2375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2376 "%s: Adapter is NULL",__func__);
2377 return -EINVAL;
2378 }
2379 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2380 ret = wlan_hdd_validate_context(pHddCtx);
2381 if (0 != ret)
2382 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302383 return ret;
2384 }
2385 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2386 if (NULL == hHal)
2387 {
2388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2389 "%s: Hal Context is NULL",__func__);
2390 return -EINVAL;
2391 }
2392 pVosContext = pHddCtx->pvosContext;
2393 if (NULL == pVosContext)
2394 {
2395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2396 "%s: pVosContext Context is NULL",__func__);
2397 return -EINVAL;
2398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 switch (sub_cmd)
2400 {
2401 case QCSAP_PARAM_MAX_ASSOC:
2402 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2403 if (eHAL_STATUS_SUCCESS != status)
2404 {
c_hpothuffdb5272013-10-02 16:42:35 +05302405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2406 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 ret = -EIO;
2408 }
Girish Gowli385be612014-09-18 11:17:20 +05302409
2410#ifdef WLAN_SOFTAP_VSTA_FEATURE
2411 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2412 {
2413 if (*value > VSTA_NUM_ASSOC_STA)
2414 {
2415 *value = VSTA_NUM_ASSOC_STA;
2416 }
2417 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2418 (*value > (VSTA_NUM_ASSOC_STA -
2419 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2420 {
2421 *value = (VSTA_NUM_ASSOC_STA -
2422 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2423 }
2424 }
2425 else
2426#endif
2427 {
2428 if (*value > NUM_ASSOC_STA)
2429 {
2430 *value = NUM_ASSOC_STA;
2431 }
2432 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2433 (*value > (NUM_ASSOC_STA -
2434 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2435 {
2436 *value = (NUM_ASSOC_STA -
2437 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2438 }
2439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302441
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002443 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 {
c_hpothuffdb5272013-10-02 16:42:35 +05302445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2446 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302447 ret = -EIO;
2448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 *value = 0;
2450 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302451
Jeff Johnson43971f52012-07-17 12:26:56 -07002452 case QCSAP_PARAM_GET_WLAN_DBG:
2453 {
2454 vos_trace_display();
2455 *value = 0;
2456 break;
2457 }
2458
2459 case QCSAP_PARAM_AUTO_CHANNEL:
2460 {
2461 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2462 break;
2463 }
2464
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 default:
2466 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2467 ret = -EINVAL;
2468 break;
2469
2470 }
2471
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302472 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 return ret;
2474}
2475
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302476int
2477static iw_softap_getparam(struct net_device *dev,
2478 struct iw_request_info *info,
2479 union iwreq_data *wrqu, char *extra)
2480{
2481 int ret;
2482
2483 vos_ssr_protect(__func__);
2484 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2485 vos_ssr_unprotect(__func__);
2486
2487 return ret;
2488}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302489
2490int
2491static __iw_softap_setchar_getnone(struct net_device *dev,
2492 struct iw_request_info *info,
2493 union iwreq_data *wrqu, char *extra)
2494{
2495 int sub_cmd;
2496 int ret = 0; /* success */
2497 char *pBuffer = NULL;
2498 hdd_adapter_t *pAdapter;
2499 hdd_context_t *pHddCtx;
2500 struct iw_point s_priv_data;
2501
2502 ENTER();
2503
2504 if (!capable(CAP_NET_ADMIN))
2505 {
2506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2507 FL("permission check failed"));
2508 return -EPERM;
2509 }
2510
2511 pAdapter = (netdev_priv(dev));
2512 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2513 ret = wlan_hdd_validate_context(pHddCtx);
2514 if (0 != ret)
2515 {
2516 return ret;
2517 }
2518
2519 if (!pHddCtx->is_ap_mode_wow_supported)
2520 {
2521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2522 "%s: Not supported",__func__);
2523 return -ENOTSUPP;
2524 }
2525
2526 /* helper function to get iwreq_data with compat handling. */
2527 if (hdd_priv_get_data(&s_priv_data, wrqu))
2528 {
2529 return -EINVAL;
2530 }
2531
2532 /* make sure all params are correctly passed to function */
2533 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2534 {
2535 return -EINVAL;
2536 }
2537
2538 sub_cmd = s_priv_data.flags;
2539
2540 /* ODD number is used for set, copy data using copy_from_user */
2541 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2542 s_priv_data.length);
2543 if (NULL == pBuffer)
2544 {
2545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2546 "mem_alloc_copy_from_user_helper fail");
2547 return -ENOMEM;
2548 }
2549
2550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2551 "%s: Received length %d", __func__, s_priv_data.length);
2552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2553 "%s: Received data %s", __func__, pBuffer);
2554
2555 switch(sub_cmd)
2556 {
2557 case WE_WOWL_ADD_PTRN:
2558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2559 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2560 if (!ret)
2561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2562 "Failed to add pattern :%d", ret);
2563 break;
2564 case WE_WOWL_DEL_PTRN:
2565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2566 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2567 if (!ret)
2568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2569 "Failed to del pattern :%d", ret);
2570 break;
2571 default:
2572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2573 ret = -EINVAL;
2574 break;
2575 }
2576
2577 kfree(pBuffer);
2578 return ret;
2579}
2580
2581int
2582static iw_softap_setchar_getnone(struct net_device *dev,
2583 struct iw_request_info *info,
2584 union iwreq_data *wrqu, char *extra)
2585{
2586 int ret;
2587
2588 vos_ssr_protect(__func__);
2589 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2590 vos_ssr_unprotect(__func__);
2591
2592 return ret;
2593}
2594
Jeff Johnson295189b2012-06-20 16:38:30 -07002595/* Usage:
2596 BLACK_LIST = 0
2597 WHITE_LIST = 1
2598 ADD MAC = 0
2599 REMOVE MAC = 1
2600
2601 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2602 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2603 while using this ioctl
2604
2605 Syntax:
2606 iwpriv softap.0 modify_acl
2607 <6 octet mac addr> <list type> <cmd type>
2608
2609 Examples:
2610 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2611 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2612 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2613 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2614*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302615int __iw_softap_modify_acl(struct net_device *dev,
2616 struct iw_request_info *info,
2617 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002618{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302619 hdd_adapter_t *pHostapdAdapter;
2620 v_CONTEXT_t pVosContext;
2621 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 v_BYTE_t *value = (v_BYTE_t*)extra;
2623 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2624 int listType, cmd, i;
2625 int ret = 0; /* success */
2626
2627 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302628 pHostapdAdapter = (netdev_priv(dev));
2629 if (NULL == pHostapdAdapter)
2630 {
2631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2632 "%s: Adapter is NULL",__func__);
2633 return -EINVAL;
2634 }
2635 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2636 ret = wlan_hdd_validate_context(pHddCtx);
2637 if (0 != ret)
2638 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302639 return ret;
2640 }
2641 pVosContext = pHddCtx->pvosContext;
2642 if (NULL == pVosContext)
2643 {
2644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2645 "%s: Vos Context is NULL",__func__);
2646 return -EINVAL;
2647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2649 {
2650 pPeerStaMac[i] = *(value+i);
2651 }
2652 listType = (int)(*(value+i));
2653 i++;
2654 cmd = (int)(*(value+i));
2655
Arif Hussain24bafea2013-11-15 15:10:03 -08002656 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2657 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002658
2659 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2660 != VOS_STATUS_SUCCESS)
2661 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002662 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 ret = -EIO;
2664 }
2665 EXIT();
2666 return ret;
2667}
2668
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302669int iw_softap_modify_acl(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
2672{
2673 int ret;
2674
2675 vos_ssr_protect(__func__);
2676 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2677 vos_ssr_unprotect(__func__);
2678
2679 return ret;
2680}
2681
Jeff Johnson295189b2012-06-20 16:38:30 -07002682int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302683static __iw_softap_getchannel(struct net_device *dev,
2684 struct iw_request_info *info,
2685 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002686{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302687 hdd_adapter_t *pHostapdAdapter;
2688 hdd_context_t *pHddCtx;
2689 int ret = 0;
2690 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302691
2692 ENTER();
2693
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302694 pHostapdAdapter = (netdev_priv(dev));
2695 if (NULL == pHostapdAdapter)
2696 {
2697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2698 "%s: Adapter is NULL",__func__);
2699 return -EINVAL;
2700 }
2701 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2702 ret = wlan_hdd_validate_context(pHddCtx);
2703 if (0 != ret)
2704 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302705 return ret;
2706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002707
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302708 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002709
Jeff Johnson43971f52012-07-17 12:26:56 -07002710 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302711
2712 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 return 0;
2714}
2715
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302716
Jeff Johnsone7245742012-09-05 17:12:55 -07002717int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302718static iw_softap_getchannel(struct net_device *dev,
2719 struct iw_request_info *info,
2720 union iwreq_data *wrqu, char *extra)
2721{
2722 int ret;
2723
2724 vos_ssr_protect(__func__);
2725 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2726 vos_ssr_unprotect(__func__);
2727
2728 return ret;
2729}
2730
2731int
2732static __iw_softap_set_max_tx_power(struct net_device *dev,
2733 struct iw_request_info *info,
2734 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002735{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302736 hdd_adapter_t *pHostapdAdapter;
2737 tHalHandle hHal;
2738 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002739 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002741 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2742 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2743
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302744 ENTER();
2745
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302746 pHostapdAdapter = (netdev_priv(dev));
2747 if (NULL == pHostapdAdapter)
2748 {
2749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2750 "%s: Adapter is NULL",__func__);
2751 return -EINVAL;
2752 }
2753 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2754 ret = wlan_hdd_validate_context(pHddCtx);
2755 if (0 != ret)
2756 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302757 return ret;
2758 }
2759 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2760 if (NULL == hHal)
2761 {
2762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2763 "%s: Hal Context is NULL",__func__);
2764 return -EINVAL;
2765 }
schang86c22c42013-03-13 18:41:24 -07002766 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002767 return -ENOMEM;
2768
Leo Changd37675a2013-08-01 13:19:45 -07002769 /* Assign correct slef MAC address */
2770 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2771 VOS_MAC_ADDR_SIZE);
2772 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2773 VOS_MAC_ADDR_SIZE);
2774
schang86c22c42013-03-13 18:41:24 -07002775 set_value = value[0];
2776 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2777 {
2778 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002779 __func__);
schang86c22c42013-03-13 18:41:24 -07002780 return -EIO;
2781 }
2782
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302783 EXIT();
schang86c22c42013-03-13 18:41:24 -07002784 return 0;
2785}
2786
2787int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302788static iw_softap_set_max_tx_power(struct net_device *dev,
2789 struct iw_request_info *info,
2790 union iwreq_data *wrqu, char *extra)
2791{
2792 int ret;
2793
2794 vos_ssr_protect(__func__);
2795 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
2796 vos_ssr_unprotect(__func__);
2797
2798 return ret;
2799}
2800
2801
2802int
2803static __iw_display_data_path_snapshot(struct net_device *dev,
2804 struct iw_request_info *info,
2805 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302806{
2807
2808 /* Function intitiating dumping states of
2809 * HDD(WMM Tx Queues)
2810 * TL State (with Per Client infor)
2811 * DXE Snapshot (Called at the end of TL Snapshot)
2812 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302813 hdd_adapter_t *pHostapdAdapter;
2814 hdd_context_t *pHddCtx;
2815 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302816
2817 ENTER();
2818
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302819 pHostapdAdapter = (netdev_priv(dev));
2820 if (NULL == pHostapdAdapter)
2821 {
2822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2823 "%s: Adapter is NULL",__func__);
2824 return -EINVAL;
2825 }
2826 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2827 ret = wlan_hdd_validate_context(pHddCtx);
2828 if (0 != ret)
2829 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302830 return ret;
2831 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302832 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05302833 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302834
2835 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05302836 return 0;
2837}
2838
2839int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302840static iw_display_data_path_snapshot(struct net_device *dev,
2841 struct iw_request_info *info,
2842 union iwreq_data *wrqu, char *extra)
2843{
2844 int ret;
2845
2846 vos_ssr_protect(__func__);
2847 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
2848 vos_ssr_unprotect(__func__);
2849
2850 return ret;
2851}
2852
2853int
2854static __iw_softap_set_tx_power(struct net_device *dev,
2855 struct iw_request_info *info,
2856 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07002857{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302858 hdd_adapter_t *pHostapdAdapter;
2859 hdd_context_t *pHddCtx;
2860 v_CONTEXT_t pVosContext;
2861 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07002862 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302863 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07002864 ptSapContext pSapCtx = NULL;
2865
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302866 ENTER();
2867
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302868 pHostapdAdapter = (netdev_priv(dev));
2869 if (NULL == pHostapdAdapter)
2870 {
2871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2872 "%s: Adapter is NULL",__func__);
2873 return -EINVAL;
2874 }
2875 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2876 ret = wlan_hdd_validate_context(pHddCtx);
2877 if (0 != ret)
2878 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302879 return ret;
2880 }
2881 pVosContext = pHddCtx->pvosContext;
2882 if (NULL == pVosContext)
2883 {
2884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2885 "%s: Vos Context is NULL",__func__);
2886 return -EINVAL;
2887 }
2888 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2889 if (NULL == hHal)
2890 {
2891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2892 "%s: Hal Context is NULL",__func__);
2893 return -EINVAL;
2894 }
schang86c22c42013-03-13 18:41:24 -07002895 if (NULL == value)
2896 return -ENOMEM;
2897
2898 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2899 if (NULL == pSapCtx)
2900 {
2901 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2902 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2903 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002904 }
2905
2906 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07002907 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07002908 {
schang86c22c42013-03-13 18:41:24 -07002909 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07002910 __func__);
2911 return -EIO;
2912 }
2913
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302914 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07002915 return 0;
2916}
2917
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302918int
2919static iw_softap_set_tx_power(struct net_device *dev,
2920 struct iw_request_info *info,
2921 union iwreq_data *wrqu, char *extra)
2922{
2923 int ret;
2924
2925 vos_ssr_protect(__func__);
2926 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
2927 vos_ssr_unprotect(__func__);
2928
2929 return ret;
2930}
2931
Kiet Lambcf38522013-10-26 18:28:27 +05302932/**---------------------------------------------------------------------------
2933
2934 \brief iw_softap_set_trafficmonitor() -
2935 This function dynamically enable/disable traffic monitor functonality
2936 the command iwpriv wlanX setTrafficMon <value>.
2937
2938 \param - dev - Pointer to the net device.
2939 - addr - Pointer to the sockaddr.
2940 \return - 0 for success, non zero for failure
2941
2942 --------------------------------------------------------------------------*/
2943
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302944static int __iw_softap_set_trafficmonitor(struct net_device *dev,
2945 struct iw_request_info *info,
2946 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05302947{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302948 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05302949 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05302950 hdd_context_t *pHddCtx;
2951 int status;
2952
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302953 ENTER();
2954
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302955 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05302956 if (NULL == pAdapter)
2957 {
2958 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2959 "%s: HDD adapter is Null", __func__);
2960 return -ENODEV;
2961 }
2962
2963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2964
2965 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05302966 if (0 != status)
2967 {
Kiet Lambcf38522013-10-26 18:28:27 +05302968 return status;
2969 }
2970
2971 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
2972
2973 if (NULL == isSetTrafficMon)
2974 {
2975 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2976 "%s: Invalid SAP pointer from extra", __func__);
2977 return -ENOMEM;
2978 }
2979
2980 if (TRUE == *isSetTrafficMon)
2981 {
2982 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05302983 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05302984 {
2985 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2986 "%s: failed to Start Traffic Monitor timer ", __func__ );
2987 return -EIO;
2988 }
2989 }
2990 else if (FALSE == *isSetTrafficMon)
2991 {
2992 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05302993 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05302994 {
2995 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2996 "%s: failed to Stop Traffic Monitor timer ", __func__ );
2997 return -EIO;
2998 }
2999
3000 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303001
3002 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05303003 return 0;
3004}
3005
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303006static int iw_softap_set_trafficmonitor(struct net_device *dev,
3007 struct iw_request_info *info,
3008 union iwreq_data *wrqu, char *extra)
3009{
3010 int ret;
3011
3012 vos_ssr_protect(__func__);
3013 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
3014 vos_ssr_unprotect(__func__);
3015
3016 return ret;
3017}
3018
Jeff Johnson295189b2012-06-20 16:38:30 -07003019#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
3020
3021int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303022static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
3023 struct iw_request_info *info,
3024 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003025{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303026 hdd_adapter_t *pHostapdAdapter;
3027 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303028 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07003029 char *buf;
3030 int cnt = 0;
3031 int left;
3032 int ret = 0;
3033 /* maclist_index must be u32 to match userspace */
3034 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303035 v_CONTEXT_t pVosContext = NULL;
3036 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303037
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303038 ENTER();
3039
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303040 pHostapdAdapter = (netdev_priv(dev));
3041 if (NULL == pHostapdAdapter)
3042 {
3043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3044 "%s: Adapter is NULL",__func__);
3045 return -EINVAL;
3046 }
3047 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3048 ret = wlan_hdd_validate_context(pHddCtx);
3049 if (0 != ret)
3050 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303051 return ret;
3052 }
3053
Jeff Johnson224f3702014-03-26 11:09:47 -07003054 /*
3055 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
3056 * number, and even numbered iocts are supposed to have "set"
3057 * semantics. Hence the wireless extensions support in the kernel
3058 * won't correctly copy the result to userspace, so the ioctl
3059 * handler itself must copy the data. Output format is 32-bit
3060 * record length, followed by 0 or more 6-byte STA MAC addresses.
3061 *
3062 * Further note that due to the incorrect semantics, the "iwpriv"
3063 * userspace application is unable to correctly invoke this API,
3064 * hence it is not registered in the hostapd_private_args. This
3065 * API can only be invoked by directly invoking the ioctl() system
3066 * call.
3067 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003068
Jeff Johnson224f3702014-03-26 11:09:47 -07003069 /* make sure userspace allocated a reasonable buffer size */
3070 if (wrqu->data.length < sizeof(maclist_index)) {
3071 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
3072 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07003073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003074
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303075 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3076 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3077 if(pSapCtx == NULL){
3078 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3079 FL("psapCtx is NULL"));
3080 return -EFAULT;
3081 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05303082
3083 /* allocate local buffer to build the response */
3084 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
3085 if (!buf) {
3086 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
3087 return -ENOMEM;
3088 }
3089
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303090 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07003091 /* start indexing beyond where the record count will be written */
3092 maclist_index = sizeof(maclist_index);
3093 left = wrqu->data.length - maclist_index;
3094
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303095 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003096 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
3097 if ((pStaInfo[cnt].isUsed) &&
3098 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
3099 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
3100 VOS_MAC_ADDR_SIZE);
3101 maclist_index += VOS_MAC_ADDR_SIZE;
3102 left -= VOS_MAC_ADDR_SIZE;
3103 }
3104 cnt++;
3105 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303106 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003107
3108 *((u32 *)buf) = maclist_index;
3109 wrqu->data.length = maclist_index;
3110 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
3111 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
3112 ret = -EFAULT;
3113 }
3114 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303115
3116 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07003117 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003118}
3119
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303120int
3121static iw_softap_getassoc_stamacaddr(struct net_device *dev,
3122 struct iw_request_info *info,
3123 union iwreq_data *wrqu, char *extra)
3124{
3125 int ret;
3126
3127 vos_ssr_protect(__func__);
3128 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
3129 vos_ssr_unprotect(__func__);
3130
3131 return ret;
3132}
3133
Jeff Johnson295189b2012-06-20 16:38:30 -07003134/* Usage:
3135 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3136 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3137 while using this ioctl
3138
3139 Syntax:
3140 iwpriv softap.0 disassoc_sta <6 octet mac address>
3141
3142 e.g.
3143 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
3144 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
3145*/
3146
3147int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303148static __iw_softap_disassoc_sta(struct net_device *dev,
3149 struct iw_request_info *info,
3150 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003151{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303152 hdd_adapter_t *pHostapdAdapter;
3153 hdd_context_t *pHddCtx;
3154 v_U8_t *peerMacAddr;
3155 int ret = 0;
3156
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05303158
3159 if (!capable(CAP_NET_ADMIN)) {
3160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3161 FL("permission check failed"));
3162 return -EPERM;
3163 }
3164
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303165 pHostapdAdapter = (netdev_priv(dev));
3166 if (NULL == pHostapdAdapter)
3167 {
3168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3169 "%s: Adapter is NULL",__func__);
3170 return -EINVAL;
3171 }
3172 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3173 ret = wlan_hdd_validate_context(pHddCtx);
3174 if (0 != ret)
3175 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303176 return ret;
3177 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303178 /* iwpriv tool or framework calls this ioctl with
3179 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303181 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182
Arif Hussain24bafea2013-11-15 15:10:03 -08003183 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
3184 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
3186 EXIT();
3187 return 0;
3188}
3189
3190int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303191static iw_softap_disassoc_sta(struct net_device *dev,
3192 struct iw_request_info *info,
3193 union iwreq_data *wrqu, char *extra)
3194{
3195 int ret;
3196
3197 vos_ssr_protect(__func__);
3198 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3199 vos_ssr_unprotect(__func__);
3200
3201 return ret;
3202}
3203
3204int
3205static __iw_softap_ap_stats(struct net_device *dev,
3206 struct iw_request_info *info,
3207 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003208{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303209 hdd_adapter_t *pHostapdAdapter;
3210 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 WLANTL_TRANSFER_STA_TYPE statBuffer;
3212 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303213 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003214
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303215 ENTER();
3216
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303217 pHostapdAdapter = (netdev_priv(dev));
3218 if (NULL == pHostapdAdapter)
3219 {
3220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3221 "%s: Adapter is NULL",__func__);
3222 return -EINVAL;
3223 }
3224 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3225 ret = wlan_hdd_validate_context(pHddCtx);
3226 if (0 != ret)
3227 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303228 return ret;
3229 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003230 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003231 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3232 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303234 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003235 if(NULL == pstatbuf) {
3236 hddLog(LOG1, "unable to allocate memory");
3237 return -ENOMEM;
3238 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303239
3240 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003241 "RUF=%d RMF=%d RBF=%d "
3242 "RUB=%d RMB=%d RBB=%d "
3243 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303244 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003245 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3246 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3247 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3248 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3249 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3250 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003251
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303252 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003253 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3254 kfree(pstatbuf);
3255 return -EFAULT;
3256 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303257
3258 strlcpy(extra, pstatbuf, len);
3259 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003260 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303261
3262 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 return 0;
3264}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303265int
3266static __iw_softap_ap_get_stats(struct net_device *dev,
3267 struct iw_request_info *info,
3268 union iwreq_data *wrqu, char *extra)
3269{
3270 hdd_adapter_t *pAdapter;
3271 hdd_tx_rx_stats_t *pStats;
3272
3273 ENTER();
3274 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3275 if (NULL == pAdapter)
3276 {
3277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3278 "%s: Adapter is NULL",__func__);
3279 return -EINVAL;
3280 }
3281
3282 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3283 snprintf(extra, QCSAP_MAX_STR_LEN,
3284 "\nTransmit"
3285 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3286 "\n dropped BK %u, BE %u, VI %u, VO %u"
3287 "\n classified BK %u, BE %u, VI %u, VO %u"
3288 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3289 "\n queued BK %u, BE %u, VI %u, VO %u"
3290 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3291 "\ndequeued %u, depressured %u, deque-depressured %u,\
3292 completed %u, flushed %u"
3293 "\n fetched BK %u, BE %u, VI %u, VO %u"
3294 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3295 "\n depressured BK %u, BE %u, VI %u, VO %u"
3296 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3297 "\n flushed BK %u, BE %u, VI %u, VO %u"
3298 "\n\nReceive"
3299 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3300 "\n\nResetsStats"
3301 "\n",
3302 pStats->txXmitCalled,
3303 pStats->txXmitDropped,
3304 pStats->txXmitBackPressured,
3305 pStats->txXmitQueued,
3306
3307 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3308 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3309 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3310 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3311
3312 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3313 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3314 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3315 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3316
3317 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3318 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3319 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3320 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3321
3322 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3323 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3324 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3325 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3326
3327 pStats->txFetched,
3328 pStats->txFetchEmpty,
3329 pStats->txFetchLowResources,
3330 pStats->txFetchDequeueError,
3331
3332 pStats->txFetchDequeued,
3333 pStats->txFetchDePressured,
3334 pStats->txDequeDePressured,
3335 pStats->txCompleted,
3336 pStats->txFlushed,
3337
3338 pStats->txFetchedAC[WLANTL_AC_BK],
3339 pStats->txFetchedAC[WLANTL_AC_BE],
3340 pStats->txFetchedAC[WLANTL_AC_VI],
3341 pStats->txFetchedAC[WLANTL_AC_VO],
3342
3343 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3344 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3345 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3346 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3347
3348 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3349 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3350 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3351 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3352
3353 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3354 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3355 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3356 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3357
3358 pStats->txFlushedAC[WLANTL_AC_BK],
3359 pStats->txFlushedAC[WLANTL_AC_BE],
3360 pStats->txFlushedAC[WLANTL_AC_VI],
3361 pStats->txFlushedAC[WLANTL_AC_VO],
3362
3363 pStats->rxChains,
3364 pStats->rxPackets,
3365 pStats->rxDropped,
3366 pStats->rxDelivered,
3367 pStats->rxRefused
3368 );
3369
3370 wrqu->data.length = strlen(extra) + 1;
3371
3372 return 0;
3373}
3374
3375int
3376static __iw_softap_ap_clear_stats(struct net_device *dev,
3377 struct iw_request_info *info,
3378 union iwreq_data *wrqu, char *extra)
3379{
3380 hdd_adapter_t *pAdapter;
3381
3382 ENTER();
3383
3384 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3385 if (NULL == pAdapter)
3386 {
3387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3388 "%s: Adapter is NULL",__func__);
3389 return -EINVAL;
3390 }
3391
3392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3393 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3394 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3395 return 0;
3396}
3397
3398
3399int
3400static iw_softap_get_stats(struct net_device *dev,
3401 struct iw_request_info *info,
3402 union iwreq_data *wrqu, char *extra)
3403{
3404 int ret;
3405 vos_ssr_protect(__func__);
3406 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3407 vos_ssr_unprotect(__func__);
3408 return ret;
3409}
3410
3411int
3412static iw_softap_clear_stats(struct net_device *dev,
3413 struct iw_request_info *info,
3414 union iwreq_data *wrqu, char *extra)
3415{
3416 int ret;
3417 vos_ssr_protect(__func__);
3418 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3419 vos_ssr_unprotect(__func__);
3420 return ret;
3421}
Jeff Johnson295189b2012-06-20 16:38:30 -07003422
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303423int
3424static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 struct iw_request_info *info,
3426 union iwreq_data *wrqu, char *extra)
3427{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303428 int ret;
3429
3430 vos_ssr_protect(__func__);
3431 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3432 vos_ssr_unprotect(__func__);
3433
3434 return ret;
3435}
3436
Manjeet Singh3ed79242017-01-11 19:04:32 +05303437/**
3438 * __iw_softap_get_three() - return three value to upper layer.
3439 *
3440 * @dev: pointer of net_device of this wireless card
3441 * @info: meta data about Request sent
3442 * @wrqu: include request info
3443 * @extra: buf used for in/out
3444 *
3445 * Return: execute result
3446 */
3447static int __iw_softap_get_three(struct net_device *dev,
3448 struct iw_request_info *info,
3449 union iwreq_data *wrqu, char *extra)
3450{
3451 uint32_t *value = (uint32_t *)extra;
3452 uint32_t sub_cmd = value[0];
3453 int ret = 0; /* success */
3454
3455 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3456
3457 switch (sub_cmd) {
3458 case QCSAP_IOCTL_GET_TSF:
3459 ret = hdd_indicate_tsf(padapter, value, 3);
3460 break;
3461 default:
3462 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3463 break;
3464 }
3465 return ret;
3466}
3467
3468
3469/**
3470 * iw_softap_get_three() - return three value to upper layer.
3471 *
3472 * @dev: pointer of net_device of this wireless card
3473 * @info: meta data about Request sent
3474 * @wrqu: include request info
3475 * @extra: buf used for in/Output
3476 *
3477 * Return: execute result
3478 */
3479static int iw_softap_get_three(struct net_device *dev,
3480 struct iw_request_info *info,
3481 union iwreq_data *wrqu, char *extra)
3482{
3483 int ret;
3484
3485 vos_ssr_protect(__func__);
3486 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3487 vos_ssr_unprotect(__func__);
3488
3489 return ret;
3490}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303491static int __iw_softap_set_channel_range(struct net_device *dev,
3492 struct iw_request_info *info,
3493 union iwreq_data *wrqu, char *extra)
3494{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303495 hdd_adapter_t *pHostapdAdapter;
3496 tHalHandle hHal;
3497 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 int *value = (int *)extra;
3499 int startChannel = value[0];
3500 int endChannel = value[1];
3501 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003502 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 int ret = 0; /* success */
3504
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303505 ENTER();
3506
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303507 if (!capable(CAP_NET_ADMIN))
3508 {
3509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3510 FL("permission check failed"));
3511 return -EPERM;
3512 }
3513
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303514 pHostapdAdapter = (netdev_priv(dev));
3515 if (NULL == pHostapdAdapter)
3516 {
3517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3518 "%s: Adapter is NULL",__func__);
3519 return -EINVAL;
3520 }
3521 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3522 ret = wlan_hdd_validate_context(pHddCtx);
3523 if (0 != ret)
3524 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303525 return ret;
3526 }
3527 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3528 if (NULL == hHal)
3529 {
3530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3531 "%s: Hal Context is NULL",__func__);
3532 return -EINVAL;
3533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3535 if(status != VOS_STATUS_SUCCESS)
3536 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003537 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 startChannel,endChannel, band);
3539 ret = -EINVAL;
3540 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003541
3542 pHddCtx->is_dynamic_channel_range_set = 1;
3543
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303544 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 return ret;
3546}
3547
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303548static int iw_softap_set_channel_range(struct net_device *dev,
3549 struct iw_request_info *info,
3550 union iwreq_data *wrqu, char *extra)
3551{
3552 int ret;
3553
3554 vos_ssr_protect(__func__);
3555 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3556 vos_ssr_unprotect(__func__);
3557
3558 return ret;
3559}
3560
3561
3562int __iw_softap_get_channel_list(struct net_device *dev,
3563 struct iw_request_info *info,
3564 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003565{
3566 v_U32_t num_channels = 0;
3567 v_U8_t i = 0;
3568 v_U8_t bandStartChannel = RF_CHAN_1;
3569 v_U8_t bandEndChannel = RF_CHAN_165;
3570 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303571 hdd_adapter_t *pHostapdAdapter;
3572 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003575 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303576 hdd_context_t *pHddCtx;
3577 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303578
3579 ENTER();
3580
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303581 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3582 if (NULL == pHostapdAdapter)
3583 {
3584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3585 "%s: Adapter is NULL",__func__);
3586 return -EINVAL;
3587 }
3588 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3589 ret = wlan_hdd_validate_context(pHddCtx);
3590 if (0 != ret)
3591 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303592 return ret;
3593 }
3594 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3595 if (NULL == hHal)
3596 {
3597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3598 "%s: Hal Context is NULL",__func__);
3599 return -EINVAL;
3600 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003601 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3602 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003603 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003604 return -EIO;
3605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 wrqu->data.length = sizeof(tChannelListInfo);
3607 ENTER();
3608
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003609 if (eCSR_BAND_24 == curBand)
3610 {
3611 bandStartChannel = RF_CHAN_1;
3612 bandEndChannel = RF_CHAN_14;
3613 }
3614 else if (eCSR_BAND_5G == curBand)
3615 {
3616 bandStartChannel = RF_CHAN_36;
3617 bandEndChannel = RF_CHAN_165;
3618 }
3619
Arif Hussain6d2a3322013-11-17 19:50:10 -08003620 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303621 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003622 bandStartChannel, bandEndChannel );
3623
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3625 {
3626 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3627 {
3628 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3629 num_channels++;
3630 }
3631 }
3632
3633 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3634
3635 temp_num_channels = num_channels;
3636
3637 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3638 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303639 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003640 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 }
3642
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303643 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3644 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 {
3646 for(i = 0; i < temp_num_channels; i++)
3647 {
3648
3649 if((channel_list->channels[i] > 35) &&
3650 (channel_list->channels[i] < 49))
3651 {
3652 vos_mem_move(&channel_list->channels[i],
3653 &channel_list->channels[i+1],
3654 temp_num_channels - (i-1));
3655 num_channels--;
3656 temp_num_channels--;
3657 i--;
3658 }
3659 }
3660 }
3661
Arif Hussain6d2a3322013-11-17 19:50:10 -08003662 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003663
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 channel_list->num_channels = num_channels;
3665 EXIT();
3666
3667 return 0;
3668}
3669
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303670int iw_softap_get_channel_list(struct net_device *dev,
3671 struct iw_request_info *info,
3672 union iwreq_data *wrqu, char *extra)
3673{
3674 int ret;
3675
3676 vos_ssr_protect(__func__);
3677 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3678 vos_ssr_unprotect(__func__);
3679
3680 return ret;
3681}
3682
3683static
3684int __iw_get_genie(struct net_device *dev,
3685 struct iw_request_info *info,
3686 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003687{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303688 hdd_adapter_t *pHostapdAdapter;
3689 hdd_context_t *pHddCtx;
3690 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303691 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3693 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303694 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303695
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303697
3698 pHostapdAdapter = (netdev_priv(dev));
3699 if (NULL == pHostapdAdapter)
3700 {
3701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3702 "%s: Adapter is NULL",__func__);
3703 return -EINVAL;
3704 }
3705 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3706 ret = wlan_hdd_validate_context(pHddCtx);
3707 if (0 != ret)
3708 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303709 return ret;
3710 }
3711 pVosContext = pHddCtx->pvosContext;
3712 if (NULL == pVosContext)
3713 {
3714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3715 "%s: vos context is not valid ",__func__);
3716 return -EINVAL;
3717 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003718 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3720 status = WLANSap_getstationIE_information(pVosContext,
3721 &length,
3722 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303723
3724 if (VOS_STATUS_SUCCESS != status) {
3725 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003726 return -EFAULT;
3727 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303728
Arif Hussained667642013-10-27 23:01:14 -07003729 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303730 if (length > DOT11F_IE_RSN_MAX_LEN) {
3731 hddLog(LOGE,
3732 FL("invalid buffer length length:%d"), length);
3733 return -E2BIG;
3734 }
3735
3736 vos_mem_copy(extra, genIeBytes, length);
3737
3738 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3739
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 EXIT();
3741 return 0;
3742}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303743
3744static
3745int iw_get_genie(struct net_device *dev,
3746 struct iw_request_info *info,
3747 union iwreq_data *wrqu, char *extra)
3748{
3749 int ret;
3750
3751 vos_ssr_protect(__func__);
3752 ret = __iw_get_genie(dev, info, wrqu, extra);
3753 vos_ssr_unprotect(__func__);
3754
3755 return ret;
3756}
3757
3758static
3759int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3760 struct iw_request_info *info,
3761 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003762{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303763 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003764 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303765 hdd_ap_ctx_t *pHddApCtx;
3766 hdd_context_t *pHddCtx;
3767 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303768
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003770
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303771 pHostapdAdapter = (netdev_priv(dev));
3772 if (NULL == pHostapdAdapter)
3773 {
3774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3775 "%s: Adapter is NULL",__func__);
3776 return -EINVAL;
3777 }
3778 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3779 ret = wlan_hdd_validate_context(pHddCtx);
3780 if (0 != ret)
3781 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303782 return ret;
3783 }
3784 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3785 if (NULL == pHddApCtx)
3786 {
3787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3788 "%s: AP context is NULL",__func__);
3789 return -EINVAL;
3790 }
3791
Arif Hussain6d2a3322013-11-17 19:50:10 -08003792 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07003793 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
3794
3795 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
3796 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
3797 pHddApCtx->WPSPBCProbeReq.probeReqIE,
3798 WPSPBCProbeReqIEs.probeReqIELen);
3799 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
3800 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
3801 sizeof(v_MACADDR_t));
3802 if (copy_to_user(wrqu->data.pointer,
3803 (void *)&WPSPBCProbeReqIEs,
3804 sizeof(WPSPBCProbeReqIEs)))
3805 {
3806 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3807 return -EFAULT;
3808 }
3809 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003810 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07003811 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 up(&pHddApCtx->semWpsPBCOverlapInd);
3813 EXIT();
3814 return 0;
3815}
3816
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303817static
3818int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3819 struct iw_request_info *info,
3820 union iwreq_data *wrqu, char *extra)
3821{
3822 int ret;
3823
3824 vos_ssr_protect(__func__);
3825 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
3826 vos_ssr_unprotect(__func__);
3827
3828 return ret;
3829}
3830
Jeff Johnson295189b2012-06-20 16:38:30 -07003831/**---------------------------------------------------------------------------
3832
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303833 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 This function sets the auth type received from the wpa_supplicant.
3835
3836 \param - dev - Pointer to the net device.
3837 - info - Pointer to the iw_request_info.
3838 - wrqu - Pointer to the iwreq_data.
3839 - extra - Pointer to the data.
3840 \return - 0 for success, non zero for failure
3841
3842 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303843int __iw_set_auth_hostap(struct net_device *dev,
3844 struct iw_request_info *info,
3845 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003846{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303847 hdd_adapter_t *pAdapter;
3848 hdd_context_t *pHddCtx;
3849 hdd_wext_state_t *pWextState;
3850 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303853
3854 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3855 if (NULL == pAdapter)
3856 {
3857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3858 "%s: Adapter is NULL",__func__);
3859 return -EINVAL;
3860 }
3861
3862 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3863 ret = wlan_hdd_validate_context(pHddCtx);
3864 if (0 != ret)
3865 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303866 return ret;
3867 }
3868 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3869 if (NULL == pWextState)
3870 {
3871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3872 "%s: pWextState is NULL",__func__);
3873 return -EINVAL;
3874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 switch(wrqu->param.flags & IW_AUTH_INDEX)
3876 {
3877 case IW_AUTH_TKIP_COUNTERMEASURES:
3878 {
3879 if(wrqu->param.value) {
3880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3881 "Counter Measure started %d", wrqu->param.value);
3882 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303883 }
3884 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3886 "Counter Measure stopped=%d", wrqu->param.value);
3887 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3888 }
3889
3890 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
3891 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303894
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303896
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003897 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 wrqu->param.flags & IW_AUTH_INDEX);
3899 break;
3900 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 EXIT();
3903 return 0;
3904}
3905
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05303906int iw_set_auth_hostap(struct net_device *dev,
3907 struct iw_request_info *info,
3908 union iwreq_data *wrqu,char *extra)
3909{
3910 int ret;
3911
3912 vos_ssr_protect(__func__);
3913 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
3914 vos_ssr_unprotect(__func__);
3915
3916 return ret;
3917}
3918
3919static int __iw_set_ap_encodeext(struct net_device *dev,
3920 struct iw_request_info *info,
3921 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003922{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303923 hdd_adapter_t *pHostapdAdapter;
3924 v_CONTEXT_t pVosContext;
3925 hdd_context_t *pHddCtx;
3926 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07003927 int retval = 0;
3928 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3930 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3931 int key_index;
3932 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303933 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07003934// tCsrRoamRemoveKey RemoveKey;
3935 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303936
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303937 ENTER();
3938 pHostapdAdapter = (netdev_priv(dev));
3939 if (NULL == pHostapdAdapter)
3940 {
3941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3942 "%s: Adapter is NULL",__func__);
3943 return -EINVAL;
3944 }
Jeff Johnson43971f52012-07-17 12:26:56 -07003945
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303946 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3947 retval = wlan_hdd_validate_context(pHddCtx);
3948 if (0 != retval)
3949 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303950 return retval;
3951 }
3952 pVosContext = pHddCtx->pvosContext;
3953 if (NULL == pVosContext)
3954 {
3955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3956 "%s: pVosContext is NULL",__func__);
3957 return -EINVAL;
3958 }
3959 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
3960 if (NULL == pHddApCtx)
3961 {
3962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3963 "%s: AP Context is NULL",__func__);
3964 return -EINVAL;
3965 }
3966
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303968
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303970
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 /*Convert from 1-based to 0-based keying*/
3972 key_index--;
3973 }
3974 if(!ext->key_len) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303975#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 /*Set the encrytion type to NONE*/
3977#if 0
3978 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3979#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303980
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 RemoveKey.keyId = key_index;
3982 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3983 /*Key direction for group is RX only*/
3984 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3985 }
3986 else {
3987 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3988 }
3989 switch(ext->alg)
3990 {
3991 case IW_ENCODE_ALG_NONE:
3992 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3993 break;
3994 case IW_ENCODE_ALG_WEP:
3995 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3996 break;
3997 case IW_ENCODE_ALG_TKIP:
3998 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07003999 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 case IW_ENCODE_ALG_CCMP:
4001 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
4002 break;
4003 default:
4004 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4005 break;
4006 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004007 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 -07004008 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004010 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 );
Jeff Johnson43971f52012-07-17 12:26:56 -07004012 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
4013 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 {
4015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07004016 __LINE__, vstatus );
4017 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004019#endif
4020 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
Jeff Johnson43971f52012-07-17 12:26:56 -07004022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004023
4024 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4025
4026 setKey.keyId = key_index;
4027 setKey.keyLength = ext->key_len;
4028
4029 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4030 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4031 }
4032
4033 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4034 /*Key direction for group is RX only*/
4035 setKey.keyDirection = eSIR_RX_ONLY;
4036 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4037 }
4038 else {
4039
4040 setKey.keyDirection = eSIR_TX_RX;
4041 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4042 }
4043 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4044 {
4045 setKey.keyDirection = eSIR_TX_DEFAULT;
4046 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4047 }
4048
4049 /*For supplicant pae role is zero*/
4050 setKey.paeRole = 0;
4051
4052 switch(ext->alg)
4053 {
4054 case IW_ENCODE_ALG_NONE:
4055 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4056 break;
4057
4058 case IW_ENCODE_ALG_WEP:
4059 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4060 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004061 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 break;
4063
4064 case IW_ENCODE_ALG_TKIP:
4065 {
4066 v_U8_t *pKey = &setKey.Key[0];
4067
4068 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4069
4070 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4071
4072 /*Supplicant sends the 32bytes key in this order
4073
4074 |--------------|----------|----------|
4075 | Tk1 |TX-MIC | RX Mic |
4076 |--------------|----------|----------|
4077 <---16bytes---><--8bytes--><--8bytes-->
4078
4079 */
4080 /*Sme expects the 32 bytes key to be in the below order
4081
4082 |--------------|----------|----------|
4083 | Tk1 |RX-MIC | TX Mic |
4084 |--------------|----------|----------|
4085 <---16bytes---><--8bytes--><--8bytes-->
4086 */
4087 /* Copy the Temporal Key 1 (TK1) */
4088 vos_mem_copy(pKey,ext->key,16);
4089
4090 /*Copy the rx mic first*/
4091 vos_mem_copy(&pKey[16],&ext->key[24],8);
4092
4093 /*Copy the tx mic */
4094 vos_mem_copy(&pKey[24],&ext->key[16],8);
4095
4096 }
4097 break;
4098
4099 case IW_ENCODE_ALG_CCMP:
4100 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4101 break;
4102
4103 default:
4104 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4105 break;
4106 }
4107
4108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304109 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 setKey.keyId);
4111 for(i=0; i< ext->key_len; i++)
4112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4113 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07004114
4115 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
4116 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 {
4118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07004119 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
4120 retval = -EINVAL;
4121 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304122
4123 EXIT();
4124 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004125}
Jeff Johnson43971f52012-07-17 12:26:56 -07004126
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304127static int iw_set_ap_encodeext(struct net_device *dev,
4128 struct iw_request_info *info,
4129 union iwreq_data *wrqu, char *extra)
4130{
4131 int ret;
4132
4133 vos_ssr_protect(__func__);
4134 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
4135 vos_ssr_unprotect(__func__);
4136
4137 return ret;
4138}
Jeff Johnson43971f52012-07-17 12:26:56 -07004139
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304140static int __iw_set_ap_mlme(struct net_device *dev,
4141 struct iw_request_info *info,
4142 union iwreq_data *wrqu,
4143 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004144{
4145#if 0
4146 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4147 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4148
4149 ENTER();
4150
4151 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4152 switch (mlme->cmd) {
4153 case IW_MLME_DISASSOC:
4154 case IW_MLME_DEAUTH:
4155 hddLog(LOG1, "Station disassociate");
4156 if( pAdapter->conn_info.connState == eConnectionState_Associated )
4157 {
4158 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4159
4160 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4161 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4162
4163 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
4164
4165 //clear all the reason codes
4166 if (status != 0)
4167 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004168 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 }
4170
4171 netif_stop_queue(dev);
4172 netif_carrier_off(dev);
4173 }
4174 else
4175 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004176 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 -07004177 }
4178 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004179 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 return -EINVAL;
4181 }//end of switch
4182 EXIT();
4183#endif
4184 return 0;
4185// return status;
4186}
4187
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304188static int iw_set_ap_mlme(struct net_device *dev,
4189 struct iw_request_info *info,
4190 union iwreq_data *wrqu,
4191 char *extra)
4192{
4193 int ret;
4194
4195 vos_ssr_protect(__func__);
4196 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4197 vos_ssr_unprotect(__func__);
4198
4199 return ret;
4200}
4201
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304202static int __iw_get_ap_rts_threshold(struct net_device *dev,
4203 struct iw_request_info *info,
4204 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004205{
4206 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4207 v_U32_t status = 0;
4208
4209 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4210
4211 return status;
4212}
4213
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304214static int iw_get_ap_rts_threshold(struct net_device *dev,
4215 struct iw_request_info *info,
4216 union iwreq_data *wrqu, char *extra)
4217{
4218 int ret;
4219
4220 vos_ssr_protect(__func__);
4221 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4222 vos_ssr_unprotect(__func__);
4223
4224 return ret;
4225}
4226
4227static int __iw_get_ap_frag_threshold(struct net_device *dev,
4228 struct iw_request_info *info,
4229 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004230{
4231 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4232 v_U32_t status = 0;
4233
4234 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4235
4236 return status;
4237}
4238
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304239static int iw_get_ap_frag_threshold(struct net_device *dev,
4240 struct iw_request_info *info,
4241 union iwreq_data *wrqu, char *extra)
4242{
4243 int ret;
4244
4245 vos_ssr_protect(__func__);
4246 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4247 vos_ssr_unprotect(__func__);
4248
4249 return ret;
4250}
4251
4252static int __iw_get_ap_freq(struct net_device *dev,
4253 struct iw_request_info *info,
4254 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004255{
Jeff Johnsone7245742012-09-05 17:12:55 -07004256 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304257 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 tHalHandle hHal;
4259 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304260 hdd_ap_ctx_t *pHddApCtx;
4261 hdd_context_t *pHddCtx;
4262 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004263
4264 ENTER();
4265
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304266 pHostapdAdapter = (netdev_priv(dev));
4267 if (NULL == pHostapdAdapter)
4268 {
4269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4270 "%s: Adapter is NULL",__func__);
4271 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304273 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4274 ret = wlan_hdd_validate_context(pHddCtx);
4275 if (0 != ret)
4276 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304277 return ret;
4278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304280 if (NULL == pHostapdState)
4281 {
4282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4283 "%s: pHostapdState is NULL",__func__);
4284 return -EINVAL;
4285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304287 if (NULL == hHal)
4288 {
4289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4290 "%s: Hal Context is NULL",__func__);
4291 return -EINVAL;
4292 }
4293 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4294 if (NULL == pHddApCtx)
4295 {
4296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4297 "%s: AP context is NULL",__func__);
4298 return -EINVAL;
4299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 if(pHostapdState->bssState == BSS_STOP )
4301 {
4302 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4303 != eHAL_STATUS_SUCCESS)
4304 {
c_hpothuffdb5272013-10-02 16:42:35 +05304305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4306 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 return -EIO;
4308 }
4309 else
4310 {
4311 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004312 if( TRUE == status)
4313 {
4314 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4315 * iwlist & iwconfig command shows frequency into proper
4316 * format (2.412 GHz instead of 246.2 MHz)*/
4317 fwrq->m = freq;
4318 fwrq->e = MHZ;
4319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 }
4321 }
4322 else
4323 {
4324 channel = pHddApCtx->operatingChannel;
4325 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004326 if( TRUE == status)
4327 {
4328 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4329 * iwlist & iwconfig command shows frequency into proper
4330 * format (2.412 GHz instead of 246.2 MHz)*/
4331 fwrq->m = freq;
4332 fwrq->e = MHZ;
4333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304335
4336 EXIT();
4337 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004338}
4339
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304340static int iw_get_ap_freq(struct net_device *dev,
4341 struct iw_request_info *info,
4342 struct iw_freq *fwrq, char *extra)
4343{
4344 int ret;
4345
4346 vos_ssr_protect(__func__);
4347 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4348 vos_ssr_unprotect(__func__);
4349
4350 return ret;
4351}
4352
4353static int __iw_get_mode(struct net_device *dev,
4354 struct iw_request_info *info,
4355 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304356{
4357 int status = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304358 hdd_adapter_t *pAdapter;
4359 hdd_context_t *pHddCtx;
4360
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304361 ENTER();
4362
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304363 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4364 if (NULL == pAdapter)
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4367 "%s: Adapter is NULL",__func__);
4368 return -EINVAL;
4369 }
4370 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4371 status = wlan_hdd_validate_context(pHddCtx);
4372 if (0 != status)
4373 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304374 return status;
4375 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304376
4377 wrqu->mode = IW_MODE_MASTER;
4378
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304379 EXIT();
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304380 return status;
4381}
4382
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304383static int iw_get_mode(struct net_device *dev,
4384 struct iw_request_info *info,
4385 union iwreq_data *wrqu, char *extra)
4386{
4387 int ret;
4388
4389 vos_ssr_protect(__func__);
4390 ret = __iw_get_mode(dev, info, wrqu, extra);
4391 vos_ssr_unprotect(__func__);
4392
4393 return ret;
4394}
4395
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304396
4397static int __iw_softap_stopbss(struct net_device *dev,
4398 struct iw_request_info *info,
4399 union iwreq_data *wrqu,
4400 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004401{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304402 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304404 hdd_context_t *pHddCtx = NULL;
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304407 pHostapdAdapter = (netdev_priv(dev));
4408 if (NULL == pHostapdAdapter)
4409 {
4410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4411 "%s: Adapter is NULL",__func__);
4412 return -EINVAL;
4413 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304414 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4415 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304416 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304417 return status;
4418 }
4419
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304420 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 {
4422 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4423 {
4424 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4425
4426 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304427
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304429 {
4430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004431 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 VOS_ASSERT(0);
4433 }
4434 }
4435 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304436 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 }
4438 EXIT();
4439 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4440}
4441
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304442static int iw_softap_stopbss(struct net_device *dev,
4443 struct iw_request_info *info,
4444 union iwreq_data *wrqu,
4445 char *extra)
4446{
4447 int ret;
4448
4449 vos_ssr_protect(__func__);
4450 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4451 vos_ssr_unprotect(__func__);
4452
4453 return ret;
4454}
4455
4456static int __iw_softap_version(struct net_device *dev,
4457 struct iw_request_info *info,
4458 union iwreq_data *wrqu,
4459 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004460{
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304462 hdd_context_t *pHddCtx;
4463 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304464
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304466 pHostapdAdapter = (netdev_priv(dev));
4467 if (NULL == pHostapdAdapter)
4468 {
4469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4470 "%s: Adapter is NULL",__func__);
4471 return -EINVAL;
4472 }
4473 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4474 ret = wlan_hdd_validate_context(pHddCtx);
4475 if (0 != ret)
4476 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304477 return ret;
4478 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004479 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 return 0;
4482}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004483
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304484static int iw_softap_version(struct net_device *dev,
4485 struct iw_request_info *info,
4486 union iwreq_data *wrqu,
4487 char *extra)
4488{
4489 int ret;
4490
4491 vos_ssr_protect(__func__);
4492 ret = __iw_softap_version(dev, info, wrqu, extra);
4493 vos_ssr_unprotect(__func__);
4494
4495 return ret;
4496}
4497
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304498int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004499{
4500 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004501 int len = 0;
4502 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304503 v_CONTEXT_t pVosContext;
4504 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304505 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304506
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304507 ENTER();
4508
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304509 if (NULL == pAdapter)
4510 {
4511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4512 "%s: Adapter is NULL",__func__);
4513 return -EINVAL;
4514 }
4515 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4516 if (0 != wlan_hdd_validate_context(pHddCtx))
4517 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304518 return VOS_STATUS_E_FAULT;
4519 }
4520 pVosContext = pHddCtx->pvosContext;
4521 if (NULL == pVosContext)
4522 {
4523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4524 "%s: VOS context is not valid",__func__);
4525 return VOS_STATUS_E_FAULT;
4526 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304527 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304528 if(pSapCtx == NULL)
4529 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304530 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4531 FL("psapCtx is NULL"));
4532 return VOS_STATUS_E_FAULT;
4533 }
4534
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304535 len = snprintf(pBuf, buf_len, sta_info_header);
4536 if (len >= buf_len) {
4537 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4538 return -E2BIG;
4539 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004540 pBuf += len;
4541 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004542
4543 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4544 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304545 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004546 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004547 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304548 pSapCtx->aStaInfo[i].ucSTAId,
4549 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4550 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4551 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4552 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4553 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4554 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304555 if (len >= buf_len) {
4556 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4557 return -E2BIG;
4558 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004559 pBuf += len;
4560 buf_len -= len;
4561 }
4562 if(WE_GET_STA_INFO_SIZE > buf_len)
4563 {
4564 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004565 }
4566 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304567 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304568 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004569}
4570
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304571static int __iw_softap_get_sta_info(struct net_device *dev,
4572 struct iw_request_info *info,
4573 union iwreq_data *wrqu,
4574 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004575{
4576 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304577 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004578 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304579 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4580 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004581 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304582 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004583 }
4584 wrqu->data.length = strlen(extra);
4585 EXIT();
4586 return 0;
4587}
4588
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304589static int iw_softap_get_sta_info(struct net_device *dev,
4590 struct iw_request_info *info,
4591 union iwreq_data *wrqu,
4592 char *extra)
4593{
4594 int ret;
4595
4596 vos_ssr_protect(__func__);
4597 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4598 vos_ssr_unprotect(__func__);
4599
4600 return ret;
4601}
4602
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304603static int __iw_set_ap_genie(struct net_device *dev,
4604 struct iw_request_info *info,
4605 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304607
4608 hdd_adapter_t *pHostapdAdapter;
4609 hdd_context_t *pHddCtx;
4610 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004612 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304613 int ret = 0;
4614
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304616 pHostapdAdapter = (netdev_priv(dev));
4617 if (NULL == pHostapdAdapter)
4618 {
4619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4620 "%s: Adapter is NULL",__func__);
4621 return -EINVAL;
4622 }
4623 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4624 ret = wlan_hdd_validate_context(pHddCtx);
4625 if (0 != ret)
4626 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304627 return ret;
4628 }
4629 pVosContext = pHddCtx->pvosContext;
4630 if (NULL == pVosContext)
4631 {
4632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4633 "%s: VOS Context is NULL",__func__);
4634 return -EINVAL;
4635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 if(!wrqu->data.length)
4637 {
4638 EXIT();
4639 return 0;
4640 }
Arif Hussained667642013-10-27 23:01:14 -07004641
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05304642 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
4643 {
4644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4645 "%s: WPARSN Ie input length is more than max[%d]", __func__,
4646 wrqu->data.length);
4647 return -EINVAL;
4648 }
4649
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304650 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304652 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 case DOT11F_EID_RSN:
4654 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4655 {
4656 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4657 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004660 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304662
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004664 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 halStatus = 0;
4666 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304669 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004670}
4671
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304672static int iw_set_ap_genie(struct net_device *dev,
4673 struct iw_request_info *info,
4674 union iwreq_data *wrqu, char *extra)
4675{
4676 int ret;
4677
4678 vos_ssr_protect(__func__);
4679 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4680 vos_ssr_unprotect(__func__);
4681
4682 return ret;
4683}
4684
Jeff Johnson295189b2012-06-20 16:38:30 -07004685static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4686{
4687 eHalStatus hstatus;
4688 long lrc;
4689 struct statsContext context;
4690
4691 if (NULL == pAdapter)
4692 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304693 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 return VOS_STATUS_E_FAULT;
4695 }
4696
4697 init_completion(&context.completion);
4698 context.pAdapter = pAdapter;
4699 context.magic = STATS_CONTEXT_MAGIC;
4700 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4701 eCSR_HDD,
4702 SME_GLOBAL_CLASSA_STATS,
4703 hdd_GetClassA_statisticsCB,
4704 0, // not periodic
4705 FALSE, //non-cached results
4706 staid,
4707 &context);
4708 if (eHAL_STATUS_SUCCESS != hstatus)
4709 {
4710 hddLog(VOS_TRACE_LEVEL_ERROR,
4711 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004712 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 }
4714 else
4715 {
4716 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4717 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 if (lrc <= 0)
4719 {
4720 hddLog(VOS_TRACE_LEVEL_ERROR,
4721 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004722 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 }
4724 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004725
4726 /* either we never sent a request, we sent a request and received a
4727 response or we sent a request and timed out. if we never sent a
4728 request or if we sent a request and got a response, we want to
4729 clear the magic out of paranoia. if we timed out there is a
4730 race condition such that the callback function could be
4731 executing at the same time we are. of primary concern is if the
4732 callback function had already verified the "magic" but had not
4733 yet set the completion variable when a timeout occurred. we
4734 serialize these activities by invalidating the magic while
4735 holding a shared spinlock which will cause us to block if the
4736 callback is currently executing */
4737 spin_lock(&hdd_context_lock);
4738 context.magic = 0;
4739 spin_unlock(&hdd_context_lock);
4740
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 return VOS_STATUS_SUCCESS;
4742}
4743
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304744int __iw_get_softap_linkspeed(struct net_device *dev,
4745 struct iw_request_info *info,
4746 union iwreq_data *wrqu,
4747 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004748
4749{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304750 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304751 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004753 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304754 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304756 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004758 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304759 int rc, valid;
4760
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304761 ENTER();
4762
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304763 pHostapdAdapter = (netdev_priv(dev));
4764 if (NULL == pHostapdAdapter)
4765 {
4766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4767 "%s: Adapter is NULL",__func__);
4768 return -EINVAL;
4769 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304770 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304771 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304772 if (0 != valid)
4773 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304774 return valid;
4775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004776
Arif Hussain6d2a3322013-11-17 19:50:10 -08004777 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004778
4779 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004780 {
Arif Hussaina9571842014-01-15 16:43:41 -08004781 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4782 if (NULL == pmacAddress) {
4783 hddLog(LOG1, "unable to allocate memory");
4784 return -ENOMEM;
4785 }
4786 if (copy_from_user((void *)pmacAddress,
4787 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4788 {
4789 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4790 kfree(pmacAddress);
4791 return -EFAULT;
4792 }
Manjeet Singha3739742016-05-03 16:21:46 +05304793 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004794
4795 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004796 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004797
4798 if (!VOS_IS_STATUS_SUCCESS(status ))
4799 {
4800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4801 }
Arif Hussained667642013-10-27 23:01:14 -07004802 }
Kiet Lam61589852013-09-19 17:10:58 +05304803 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304804 * link speed for first connected client will be returned.
4805 */
Arif Hussaina9571842014-01-15 16:43:41 -08004806 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304807 {
4808 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4809 }
4810 else
4811 {
4812 status = hdd_softap_GetStaId(pHostapdAdapter,
4813 (v_MACADDR_t *)macAddress, (void *)(&staId));
4814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004815
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304816 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 link_speed = 0;
4820 }
4821 else
4822 {
4823 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 if (!VOS_IS_STATUS_SUCCESS(status ))
4826 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304827 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 return -EINVAL;
4829 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304830
4831 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
4832 staId, &link_speed);
4833
4834 link_speed = link_speed / 10;
4835
4836 if (0 == link_speed)
4837 {
4838 /* The linkspeed returned by HAL is in units of 500kbps.
4839 * converting it to mbps.
4840 * This is required to support legacy firmware which does
4841 * not return link capacity.
4842 */
4843 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
4844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 }
4846
4847 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07004848 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304849
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 if ((rc < 0) || (rc >= len))
4851 {
4852 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304853 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 return -EIO;
4855 }
4856
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304857 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 return 0;
4859}
4860
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304861int iw_get_softap_linkspeed(struct net_device *dev,
4862 struct iw_request_info *info,
4863 union iwreq_data *wrqu,
4864 char *extra)
4865{
4866 int ret;
4867
4868 vos_ssr_protect(__func__);
4869 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
4870 vos_ssr_unprotect(__func__);
4871
4872 return ret;
4873}
4874
4875
Jeff Johnson295189b2012-06-20 16:38:30 -07004876static const iw_handler hostapd_handler[] =
4877{
4878 (iw_handler) NULL, /* SIOCSIWCOMMIT */
4879 (iw_handler) NULL, /* SIOCGIWNAME */
4880 (iw_handler) NULL, /* SIOCSIWNWID */
4881 (iw_handler) NULL, /* SIOCGIWNWID */
4882 (iw_handler) NULL, /* SIOCSIWFREQ */
4883 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
4884 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05304885 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 (iw_handler) NULL, /* SIOCSIWSENS */
4887 (iw_handler) NULL, /* SIOCGIWSENS */
4888 (iw_handler) NULL, /* SIOCSIWRANGE */
4889 (iw_handler) NULL, /* SIOCGIWRANGE */
4890 (iw_handler) NULL, /* SIOCSIWPRIV */
4891 (iw_handler) NULL, /* SIOCGIWPRIV */
4892 (iw_handler) NULL, /* SIOCSIWSTATS */
4893 (iw_handler) NULL, /* SIOCGIWSTATS */
4894 (iw_handler) NULL, /* SIOCSIWSPY */
4895 (iw_handler) NULL, /* SIOCGIWSPY */
4896 (iw_handler) NULL, /* SIOCSIWTHRSPY */
4897 (iw_handler) NULL, /* SIOCGIWTHRSPY */
4898 (iw_handler) NULL, /* SIOCSIWAP */
4899 (iw_handler) NULL, /* SIOCGIWAP */
4900 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
4901 (iw_handler) NULL, /* SIOCGIWAPLIST */
4902 (iw_handler) NULL, /* SIOCSIWSCAN */
4903 (iw_handler) NULL, /* SIOCGIWSCAN */
4904 (iw_handler) NULL, /* SIOCSIWESSID */
4905 (iw_handler) NULL, /* SIOCGIWESSID */
4906 (iw_handler) NULL, /* SIOCSIWNICKN */
4907 (iw_handler) NULL, /* SIOCGIWNICKN */
4908 (iw_handler) NULL, /* -- hole -- */
4909 (iw_handler) NULL, /* -- hole -- */
4910 (iw_handler) NULL, /* SIOCSIWRATE */
4911 (iw_handler) NULL, /* SIOCGIWRATE */
4912 (iw_handler) NULL, /* SIOCSIWRTS */
4913 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
4914 (iw_handler) NULL, /* SIOCSIWFRAG */
4915 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
4916 (iw_handler) NULL, /* SIOCSIWTXPOW */
4917 (iw_handler) NULL, /* SIOCGIWTXPOW */
4918 (iw_handler) NULL, /* SIOCSIWRETRY */
4919 (iw_handler) NULL, /* SIOCGIWRETRY */
4920 (iw_handler) NULL, /* SIOCSIWENCODE */
4921 (iw_handler) NULL, /* SIOCGIWENCODE */
4922 (iw_handler) NULL, /* SIOCSIWPOWER */
4923 (iw_handler) NULL, /* SIOCGIWPOWER */
4924 (iw_handler) NULL, /* -- hole -- */
4925 (iw_handler) NULL, /* -- hole -- */
4926 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
4927 (iw_handler) NULL, /* SIOCGIWGENIE */
4928 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
4929 (iw_handler) NULL, /* SIOCGIWAUTH */
4930 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
4931 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
4932 (iw_handler) NULL, /* SIOCSIWPMKSA */
4933};
4934
Jeff Johnson224f3702014-03-26 11:09:47 -07004935/*
4936 * Note that the following ioctls were defined with semantics which
4937 * cannot be handled by the "iwpriv" userspace application and hence
4938 * they are not included in the hostapd_private_args array
4939 * QCSAP_IOCTL_ASSOC_STA_MACADDR
4940 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004941
4942static const struct iw_priv_args hostapd_private_args[] = {
4943 { QCSAP_IOCTL_SETPARAM,
4944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
4945 { QCSAP_IOCTL_SETPARAM,
4946 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05304947 { QCSAP_PARAM_GET_FRAME_LOGS,
4948 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 { QCSAP_PARAM_MAX_ASSOC,
4950 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
4951 { QCSAP_PARAM_HIDE_SSID,
4952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07004953 { QCSAP_PARAM_SET_MC_RATE,
4954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05304955 { QCSAP_PARAM_SET_PROXIMITY,
4956 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05304957 { QCSAP_PARAM_CAP_TSF,
4958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Abhishek Singh02605092017-10-25 14:06:12 +05304959 {QCSAP_PARAM_SET_CHANNEL_CHANGE,
4960 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"},
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05304961 { QCSAP_PARAM_SET_WOWL,
4962 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 { QCSAP_IOCTL_GETPARAM,
4964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
4965 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
4966 { QCSAP_IOCTL_GETPARAM, 0,
4967 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
4968 { QCSAP_PARAM_MAX_ASSOC, 0,
4969 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07004970 { QCSAP_PARAM_GET_WLAN_DBG, 0,
4971 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
4972 { QCSAP_PARAM_AUTO_CHANNEL, 0,
4973 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05304974 { QCSAP_PARAM_SET_AUTO_CHANNEL,
4975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 { QCSAP_PARAM_CLR_ACL, 0,
4977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
4978 { QCSAP_PARAM_ACL_MODE,
4979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05304981 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 { QCSAP_IOCTL_STOPBSS,
4983 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
4984 { QCSAP_IOCTL_VERSION, 0,
4985 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004986 { QCSAP_IOCTL_GET_STA_INFO, 0,
4987 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08004989 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07004991 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07004992 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05304994 { QCSAP_IOCTL_AP_STATS, 0,
4995 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05304996 /* handlers for main ioctl */
4997 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
4998 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
4999#ifdef WLAN_FEATURE_TSF
5000 { QCSAP_IOCTL_GET_TSF, 0,
5001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5002 "get_tsf" },
5003#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05305004 { QCSAP_IOCTL_GET_STATS, 0,
5005 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
5006 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
5008 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305009 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005010
5011 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
5012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
5013 /* handlers for sub-ioctl */
5014 { WE_SET_WLAN_DBG,
5015 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5016 0,
5017 "setwlandbg" },
5018
5019 /* handlers for main ioctl */
5020 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
5021 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5022 0,
5023 "" },
5024
5025 /* handlers for sub-ioctl */
5026 { WE_LOG_DUMP_CMD,
5027 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5028 0,
5029 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 { WE_P2P_NOA_CMD,
5031 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5032 0,
5033 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005034 /* handlers for sub ioctl */
5035 {
5036 WE_MCC_CONFIG_CREDENTIAL,
5037 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5038 0,
5039 "setMccCrdnl" },
5040
5041 /* handlers for sub ioctl */
5042 {
5043 WE_MCC_CONFIG_PARAMS,
5044 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5045 0,
5046 "setMccConfig" },
5047
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 /* handlers for main ioctl */
5049 { QCSAP_IOCTL_MODIFY_ACL,
5050 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
5051 0,
5052 "modify_acl" },
5053
5054 /* handlers for main ioctl */
5055 { QCSAP_IOCTL_GET_CHANNEL_LIST,
5056 0,
5057 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
5058 "getChannelList" },
5059
Jeff Johnsone7245742012-09-05 17:12:55 -07005060 /* handlers for main ioctl */
5061 { QCSAP_IOCTL_SET_TX_POWER,
5062 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5063 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05305064 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07005065
5066 /* handlers for main ioctl */
5067 { QCSAP_IOCTL_SET_MAX_TX_POWER,
5068 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5069 0,
5070 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05305071
5072 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
5073 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
5074 0,
5075 "dataSnapshot" },
5076
5077 /* handlers for main ioctl */
5078 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
5079 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5080 0,
5081 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305082 /* handlers for main ioctl */
5083 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
5084 IW_PRIV_TYPE_CHAR| 512,
5085 0,
5086 "" },
5087
5088 /* handlers for sub-ioctl */
5089 { WE_WOWL_ADD_PTRN,
5090 IW_PRIV_TYPE_CHAR| 512,
5091 0,
5092 "wowlAddPtrn" },
5093
5094 { WE_WOWL_DEL_PTRN,
5095 IW_PRIV_TYPE_CHAR| 512,
5096 0,
5097 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005098};
Jeff Johnsone7245742012-09-05 17:12:55 -07005099
Jeff Johnson295189b2012-06-20 16:38:30 -07005100static const iw_handler hostapd_private[] = {
5101 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305102 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
5103 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
5104 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
5107 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
5108 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
5109 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
5110 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
5111 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
5112 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05305113 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305114 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
5116 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
5117 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
5118 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005119 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07005120 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
5121 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07005122 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305123 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05305124 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05305125 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
5126 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07005127};
5128const struct iw_handler_def hostapd_handler_def = {
5129 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
5130 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
5131 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
5132 .standard = (iw_handler *)hostapd_handler,
5133 .private = (iw_handler *)hostapd_private,
5134 .private_args = hostapd_private_args,
5135 .get_wireless_stats = NULL,
5136};
5137#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5138struct net_device_ops net_ops_struct = {
5139 .ndo_open = hdd_hostapd_open,
5140 .ndo_stop = hdd_hostapd_stop,
5141 .ndo_uninit = hdd_hostapd_uninit,
5142 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5143 .ndo_tx_timeout = hdd_softap_tx_timeout,
5144 .ndo_get_stats = hdd_softap_stats,
5145 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5146 .ndo_do_ioctl = hdd_hostapd_ioctl,
5147 .ndo_change_mtu = hdd_hostapd_change_mtu,
5148 .ndo_select_queue = hdd_hostapd_select_queue,
5149 };
5150#endif
5151
5152int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5153{
5154 return VOS_STATUS_SUCCESS;
5155}
5156
5157void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5158{
5159#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5160 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5161#else
5162 pWlanHostapdDev->open = hdd_hostapd_open;
5163 pWlanHostapdDev->stop = hdd_hostapd_stop;
5164 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5165 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5166 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5167 pWlanHostapdDev->get_stats = hdd_softap_stats;
5168 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5169 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5170#endif
5171}
5172
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305173VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305174{
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05305176#ifdef DHCP_SERVER_OFFLOAD
5177 hdd_dhcp_state_t *dhcp_status;
5178#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305179#ifdef MDNS_OFFLOAD
5180 hdd_mdns_state_t *mdns_status;
5181#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005183 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305185 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005186#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005187 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5188 v_U16_t unsafeChannelCount;
5189#endif /* FEATURE_WLAN_CH_AVOID */
5190
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305191 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5193 "%s:LOGP in Progress. Ignore!!!",__func__);
5194 status = VOS_STATUS_E_FAILURE;
5195 }
5196
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305198
5199#ifdef SAP_AUTH_OFFLOAD
5200 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305201 {
5202 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5203 {
5204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5205 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5206 return VOS_STATUS_E_FAILURE;
5207 }
5208 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305209#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305210
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305211 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305213#ifdef DHCP_SERVER_OFFLOAD
5214 dhcp_status = &pAdapter->dhcp_status;
5215#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305216#ifdef MDNS_OFFLOAD
5217 mdns_status = &pAdapter->mdns_status;
5218#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305219
Nirav Shah7e3c8132015-06-22 23:51:42 +05305220 spin_lock_init(&pAdapter->sta_hash_lock);
5221 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5222
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005223 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5224
Leo Chang0b0e45a2013-12-15 15:18:55 -08005225#ifdef FEATURE_WLAN_CH_AVOID
5226 /* Get unsafe cahnnel list from cached location */
5227 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5228 sizeof(unsafeChannelList),
5229 &unsafeChannelCount);
5230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5231 "%s : Unsafe Channel count %d",
5232 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305233 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005234 unsafeChannelList,
5235 unsafeChannelCount);
5236#endif /* FEATURE_WLAN_CH_AVOID */
5237
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 // Zero the memory. This zeros the profile structure.
5239 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305240#ifdef DHCP_SERVER_OFFLOAD
5241 memset(dhcp_status, 0,sizeof(*dhcp_status));
5242#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305243#ifdef MDNS_OFFLOAD
5244 memset(mdns_status, 0,sizeof(*mdns_status));
5245#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305246
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 // Set up the pointer to the Wireless Extensions state structure
5248 // NOP
5249 status = hdd_set_hostapd(pAdapter);
5250 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 return status;
5253 }
5254
5255 status = vos_event_init(&phostapdBuf->vosEvent);
5256 if (!VOS_IS_STATUS_SUCCESS(status))
5257 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 return status;
5260 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305261#ifdef DHCP_SERVER_OFFLOAD
5262 status = vos_event_init(&dhcp_status->vos_event);
5263 if (!VOS_IS_STATUS_SUCCESS(status)) {
5264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5265 return status;
5266 }
5267#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305268#ifdef MDNS_OFFLOAD
5269 status = vos_event_init(&mdns_status->vos_event);
5270 if (!VOS_IS_STATUS_SUCCESS(status)) {
5271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5272 ("Hostapd HDD vos event init failed!!"));
5273 return status;
5274 }
5275#endif /* MDNS_OFFLOAD */
5276
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5278
5279 // Register as a wireless device
5280 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5281
5282 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305283 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 if ( !VOS_IS_STATUS_SUCCESS( status ))
5285 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005286 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305288
5289 status = hdd_wmm_adapter_init( pAdapter );
5290 if (!VOS_IS_STATUS_SUCCESS(status))
5291 {
5292 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005293 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305294 status, status );
5295 goto error_wmm_init;
5296 }
5297
5298 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5299
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305300 ini_cfg = pHddCtx->cfg_ini;
5301 if (re_init && ini_cfg) {
5302 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5303 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5304 ini_cfg->apOperatingBand);
5305 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5306 ini_cfg->apStartChannelNum,
5307 ini_cfg->apEndChannelNum,
5308 ini_cfg->apOperatingBand);
5309 }
5310
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305311 return status;
5312
5313error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305314 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 EXIT();
5316 return status;
5317}
5318
5319hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5320{
5321 struct net_device *pWlanHostapdDev = NULL;
5322 hdd_adapter_t *pHostapdAdapter = NULL;
5323 v_CONTEXT_t pVosContext= NULL;
5324
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305325 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5326#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5327 NET_NAME_UNKNOWN,
5328#endif
5329 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 if (pWlanHostapdDev != NULL)
5331 {
5332 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5333
5334 //Init the net_device structure
5335 ether_setup(pWlanHostapdDev);
5336
5337 //Initialize the adapter context to zeros.
5338 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5339 pHostapdAdapter->dev = pWlanHostapdDev;
5340 pHostapdAdapter->pHddCtx = pHddCtx;
5341 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5342
5343 //Get the Global VOSS context.
5344 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5345 //Save the adapter context in global context for future.
5346 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5347
5348 //Init the net_device structure
5349 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5350
5351 hdd_set_ap_ops( pHostapdAdapter->dev );
5352
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5354 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5355
5356 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5357 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5358
5359 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5361 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5362 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005363
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5365 }
5366 return pHostapdAdapter;
5367}
5368
5369VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5370{
5371 struct net_device *dev = pAdapter->dev;
5372 VOS_STATUS status = VOS_STATUS_SUCCESS;
5373
5374 ENTER();
5375
5376 if( rtnl_lock_held )
5377 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005378 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 if( dev_alloc_name(dev, dev->name) < 0 )
5380 {
5381 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5382 return VOS_STATUS_E_FAILURE;
5383 }
5384 }
5385 if (register_netdevice(dev))
5386 {
5387 hddLog(VOS_TRACE_LEVEL_FATAL,
5388 "%s:Failed:register_netdevice", __func__);
5389 return VOS_STATUS_E_FAILURE;
5390 }
5391 }
5392 else
5393 {
5394 if (register_netdev(dev))
5395 {
5396 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5397 return VOS_STATUS_E_FAILURE;
5398 }
5399 }
5400 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5401
5402 EXIT();
5403 return status;
5404}
5405
c_hpothu002231a2015-02-05 14:58:51 +05305406VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005407{
5408 ENTER();
5409
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305410 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005411
5412 /* if we are being called during driver unload, then the dev has already
5413 been invalidated. if we are being called at other times, then we can
5414 detatch the wireless device handlers */
5415 if (pAdapter->dev)
5416 {
c_hpothu002231a2015-02-05 14:58:51 +05305417 if (TRUE == rtnl_held)
5418 {
5419 pAdapter->dev->wireless_handlers = NULL;
5420 }
5421 else
5422 {
5423 rtnl_lock();
5424 pAdapter->dev->wireless_handlers = NULL;
5425 rtnl_unlock();
5426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 }
5428 EXIT();
5429 return 0;
5430}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305431
5432/**
5433 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5434 * to supplicant, if there any clients connected to SAP interface.
5435 * @adapter: sap adapter context
5436 *
5437 * Return: nothing
5438 */
5439void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5440{
5441 tSap_Event sap_event;
5442 int staId;
5443 hdd_context_t *hdd_ctx;
5444 v_CONTEXT_t vos_ctx;
5445 ptSapContext sap_ctx;
5446
5447 ENTER();
5448
5449 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305450 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5451 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5452 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305453 return;
5454 }
5455
5456 vos_ctx = hdd_ctx->pvosContext;
5457 if (NULL == vos_ctx) {
5458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5459 "%s: VOS context is not valid",__func__);
5460 return;
5461 }
5462
5463 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5464 if (!sap_ctx) {
5465 hddLog(LOGE, FL("invalid sap context"));
5466 return;
5467 }
5468
5469 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5470 if (sap_ctx->aStaInfo[staId].isUsed) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07005471 hddLog(LOG1, FL("staId: %d isUsed: %d %pK"),
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305472 staId, sap_ctx->aStaInfo[staId].isUsed,
5473 sap_ctx);
5474
5475 if (vos_is_macaddr_broadcast(
5476 &sap_ctx->aStaInfo[staId].macAddrSTA))
5477 continue;
5478
5479 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5480 vos_mem_copy(
5481 &sap_event.sapevt.
5482 sapStationDisassocCompleteEvent.staMac,
5483 &sap_ctx->aStaInfo[staId].macAddrSTA,
5484 sizeof(v_MACADDR_t));
5485 sap_event.sapevt.sapStationDisassocCompleteEvent.
5486 reason =
5487 eSAP_MAC_INITATED_DISASSOC;
5488 sap_event.sapevt.sapStationDisassocCompleteEvent.
5489 statusCode =
5490 eSIR_SME_RESOURCES_UNAVAILABLE;
5491 hdd_hostapd_SAPEventCB(&sap_event,
5492 sap_ctx->pUsrContext);
5493 }
5494 }
5495
5496 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5497
5498 EXIT();
5499}
5500
5501/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305502 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305503 * @adapter: sap adapter context
5504 *
5505 * Return: nothing
5506 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305507void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305508{
5509 hdd_context_t *hdd_ctx;
5510 v_CONTEXT_t vos_ctx;
5511 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305512 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305513
5514 ENTER();
5515
5516 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305517 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5519 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305520 return;
5521 }
5522
5523 vos_ctx = hdd_ctx->pvosContext;
5524 if (NULL == vos_ctx) {
5525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5526 "%s: VOS context is not valid",__func__);
5527 return;
5528 }
5529
5530 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5531 if (!sap_ctx) {
5532 hddLog(LOGE, FL("invalid sap context"));
5533 return;
5534 }
5535
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305536 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5537 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5538 if (!VOS_IS_STATUS_SUCCESS(status))
5539 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5540 FL("Failed to Stop HT20/40 timer"));
5541 }
5542
5543 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5544 if (!VOS_IS_STATUS_SUCCESS(status))
5545 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5546 FL("Failed to Destroy HT20/40 timer"));
5547
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305548}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305549
5550/**
5551 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5552 * @adapter: hdd ap adapter
5553 *
5554 * hdd_force_scc_restart_sap will choose station channel and will
5555 * schedule work to restart the sap.
5556 *
5557 * Return - none
5558 */
5559void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5560 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5561{
5562 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5563 return;
5564 }
5565
5566 hddLog(LOG1, FL("Current operation channel %d"),
5567 adapter->sessionCtx.ap.operatingChannel);
5568 hddLog(LOG1, FL("STA channel is %d"),
5569 channelId);
5570
5571 vos_flush_work(
5572 &hdd_ctx->sap_start_work);
5573
5574 hddLog(LOGE,
5575 FL("Restarting SAP for force SCC "));
5576
5577 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5578
5579 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5580 netif_tx_disable(adapter->dev);
5581 schedule_work(&hdd_ctx->sap_start_work);
5582 } else {
5583 hdd_hostapd_stop(adapter->dev);
5584 }
5585 return;
5586}