blob: f350747aac2e298a962e27520402eea73baec701 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sourav Mohapatra5817dc42017-12-18 17:45:16 +05302 * Copyright (c) 2012-2018 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"
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +053084#include "wlan_hdd_request_manager.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085
Leo Chang0b0e45a2013-12-15 15:18:55 -080086#ifdef FEATURE_WLAN_CH_AVOID
87#include "wcnss_wlan.h"
88#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053089#include "wlan_hdd_trace.h"
90#include "vos_types.h"
91#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080092
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define IS_UP(_dev) \
94 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
95#define IS_UP_AUTO(_ic) \
96 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
97#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070098#define WE_GET_STA_INFO_SIZE 30
99/* WEXT limition: MAX allowed buf len for any *
100 * IW_PRIV_TYPE_CHAR is 2Kbytes *
101 */
102#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530104#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700105
Leo Chang0b0e45a2013-12-15 15:18:55 -0800106#ifdef FEATURE_WLAN_CH_AVOID
107/* Channle/Freqency table */
108extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
109safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
110{
111 /*CH , SAFE, default safe */
112 {1 , VOS_TRUE}, //RF_CHAN_1,
113 {2 , VOS_TRUE}, //RF_CHAN_2,
114 {3 , VOS_TRUE}, //RF_CHAN_3,
115 {4 , VOS_TRUE}, //RF_CHAN_4,
116 {5 , VOS_TRUE}, //RF_CHAN_5,
117 {6 , VOS_TRUE}, //RF_CHAN_6,
118 {7 , VOS_TRUE}, //RF_CHAN_7,
119 {8 , VOS_TRUE}, //RF_CHAN_8,
120 {9 , VOS_TRUE}, //RF_CHAN_9,
121 {10 , VOS_TRUE}, //RF_CHAN_10,
122 {11 , VOS_TRUE}, //RF_CHAN_11,
123 {12 , VOS_TRUE}, //RF_CHAN_12,
124 {13 , VOS_TRUE}, //RF_CHAN_13,
125 {14 , VOS_TRUE}, //RF_CHAN_14,
126 {240, VOS_TRUE}, //RF_CHAN_240,
127 {244, VOS_TRUE}, //RF_CHAN_244,
128 {248, VOS_TRUE}, //RF_CHAN_248,
129 {252, VOS_TRUE}, //RF_CHAN_252,
130 {208, VOS_TRUE}, //RF_CHAN_208,
131 {212, VOS_TRUE}, //RF_CHAN_212,
132 {216, VOS_TRUE}, //RF_CHAN_216,
133 {36 , VOS_TRUE}, //RF_CHAN_36,
134 {40 , VOS_TRUE}, //RF_CHAN_40,
135 {44 , VOS_TRUE}, //RF_CHAN_44,
136 {48 , VOS_TRUE}, //RF_CHAN_48,
137 {52 , VOS_TRUE}, //RF_CHAN_52,
138 {56 , VOS_TRUE}, //RF_CHAN_56,
139 {60 , VOS_TRUE}, //RF_CHAN_60,
140 {64 , VOS_TRUE}, //RF_CHAN_64,
141 {100, VOS_TRUE}, //RF_CHAN_100,
142 {104, VOS_TRUE}, //RF_CHAN_104,
143 {108, VOS_TRUE}, //RF_CHAN_108,
144 {112, VOS_TRUE}, //RF_CHAN_112,
145 {116, VOS_TRUE}, //RF_CHAN_116,
146 {120, VOS_TRUE}, //RF_CHAN_120,
147 {124, VOS_TRUE}, //RF_CHAN_124,
148 {128, VOS_TRUE}, //RF_CHAN_128,
149 {132, VOS_TRUE}, //RF_CHAN_132,
150 {136, VOS_TRUE}, //RF_CHAN_136,
151 {140, VOS_TRUE}, //RF_CHAN_140,
152 {149, VOS_TRUE}, //RF_CHAN_149,
153 {153, VOS_TRUE}, //RF_CHAN_153,
154 {157, VOS_TRUE}, //RF_CHAN_157,
155 {161, VOS_TRUE}, //RF_CHAN_161,
156 {165, VOS_TRUE}, //RF_CHAN_165,
157};
158#endif /* FEATURE_WLAN_CH_AVOID */
159
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530160/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 * Function definitions
162 *-------------------------------------------------------------------------*/
163/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530164
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530165 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 This is called in response to ifconfig up
168
169 \param - dev Pointer to net_device structure
170
171 \return - 0 for success non-zero for failure
172
173 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530174int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700175{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530176 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
177
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 ENTER();
179
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530180 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
181 {
182 //WMM_INIT OR BSS_START not completed
183 hddLog( LOGW, "Ignore hostadp open request");
184 EXIT();
185 return 0;
186 }
187
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530188 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
189 TRACE_CODE_HDD_HOSTAPD_OPEN_REQUEST, NO_SESSION, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 //Turn ON carrier state
191 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530192 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530193 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530195
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 EXIT();
197 return 0;
198}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530199
200int hdd_hostapd_open (struct net_device *dev)
201{
202 int ret;
203
204 vos_ssr_protect(__func__);
205 ret = __hdd_hostapd_open(dev);
206 vos_ssr_unprotect(__func__);
207
208 return ret;
209}
210
Jeff Johnson295189b2012-06-20 16:38:30 -0700211/**---------------------------------------------------------------------------
212
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530213 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
215 This is called in response to ifconfig down
216
217 \param - dev Pointer to net_device structure
218
219 \return - 0 for success non-zero for failure
220
221 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530222int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700223{
224 ENTER();
225
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530226 if(NULL != dev) {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530227 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530228 //Stop all tx queues
229 netif_tx_disable(dev);
230
231 //Turn OFF carrier state
232 netif_carrier_off(dev);
233 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
235 EXIT();
236 return 0;
237}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530238
239int hdd_hostapd_stop (struct net_device *dev)
240{
241 int ret;
242
243 vos_ssr_protect(__func__);
244 ret = __hdd_hostapd_stop(dev);
245 vos_ssr_unprotect(__func__);
246
247 return ret;
248}
249
Jeff Johnson295189b2012-06-20 16:38:30 -0700250/**---------------------------------------------------------------------------
251
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530252 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
254 This is called during the netdev unregister to uninitialize all data
255associated with the device
256
257 \param - dev Pointer to net_device structure
258
259 \return - void
260
261 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530262static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700263{
264 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530265 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266
267 ENTER();
268
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530269 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530271 hddLog(VOS_TRACE_LEVEL_ERROR,
272 FL("Invalid magic"));
273 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530275 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
276 if (NULL == pHddCtx)
277 {
278 hddLog(VOS_TRACE_LEVEL_ERROR,
279 FL("NULL pHddCtx"));
280 return;
281 }
282
283 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
284
285 /* after uninit our adapter structure will no longer be valid */
286 pHostapdAdapter->dev = NULL;
287 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289 EXIT();
290}
291
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530292static void hdd_hostapd_uninit (struct net_device *dev)
293{
294 vos_ssr_protect(__func__);
295 __hdd_hostapd_uninit(dev);
296 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700297
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530298 return;
299}
Jeff Johnson295189b2012-06-20 16:38:30 -0700300/**============================================================================
301 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
302 transmitting packets. There are 2 versions of this function. One that uses
303 locked queue and other that uses lockless queues. Both have been retained to
304 do some performance testing
305 @param skb : [in] pointer to OS packet (sk_buff)
306 @param dev : [in] pointer to Libra network device
307
308 @return : NET_XMIT_DROP if packets are dropped
309 : NET_XMIT_SUCCESS if packet is enqueued succesfully
310 ===========================================================================*/
311int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
312{
313 return 0;
314}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530315
316int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700317{
318 return 0;
319}
320
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530321int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
322{
323 int ret;
324 vos_ssr_protect(__func__);
325 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
326 vos_ssr_unprotect(__func__);
327
328 return ret;
329}
330
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700331static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
332 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700333{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700334 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530335 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
336 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700337 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530338 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700339 /*
340 * Note that valid pointers are provided by caller
341 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530343 ENTER();
344
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700345 if (priv_data->total_len <= 0 ||
346 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
347 {
348 /* below we allocate one more byte for command buffer.
349 * To avoid addition overflow total_len should be
350 * smaller than INT_MAX. */
351 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
352 __func__, priv_data->total_len);
353 ret = -EFAULT;
354 goto exit;
355 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530356 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530357 if (0 != status)
358 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530359 return status;
360 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700362 /* Allocate +1 for '\0' */
363 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
364 if (!command)
365 {
366 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
367 ret = -ENOMEM;
368 goto exit;
369 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700370
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700371 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
372 {
373 ret = -EFAULT;
374 goto exit;
375 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800376
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700377 /* Make sure the command is NUL-terminated */
378 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700380 hddLog(VOS_TRACE_LEVEL_INFO,
381 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700382
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700383 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
384 {
385 hdd_setP2pNoa(pAdapter->dev, command);
386 }
387 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
388 {
389 hdd_setP2pOpps(pAdapter->dev, command);
390 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800391#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700392 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
393 {
394 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
395 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800396#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700397 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
398 {
399 /*
400 * command should be a string having format
401 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
402 */
403 hddLog(VOS_TRACE_LEVEL_INFO,
404 "%s: Received Command to Set Preferred Channels for SAP",
405 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800406
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700407 ret = sapSetPreferredChannel(command);
408 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530409 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
410 {
411 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
412 tANI_U8 filterType = 0;
413 tANI_U8 *value;
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530414
415 ret = hdd_drv_cmd_validate(command, 8);
416 if (ret)
417 goto exit;
418
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530419 value = command + 9;
420
421 /* Convert the value from ascii to integer */
422 ret = kstrtou8(value, 10, &filterType);
423 if (ret < 0)
424 {
425 /* If the input value is greater than max value of datatype,
426 * then also kstrtou8 fails
427 */
428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
429 "%s: kstrtou8 failed range ", __func__);
430 ret = -EINVAL;
431 goto exit;
432 }
433 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
434 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
435 {
436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
437 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
438 " 2-Sink ", __func__);
439 ret = -EINVAL;
440 goto exit;
441 }
442 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
443 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530444 pScanInfo = &pHddCtx->scan_info;
445 if (filterType && pScanInfo != NULL &&
446 pHddCtx->scan_info.mScanPending)
447 {
448 /*Miracast Session started. Abort Scan */
449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
450 "%s, Aborting Scan For Miracast",__func__);
451 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
452 eCSR_SCAN_ABORT_DEFAULT);
453 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530454 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
455 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
456 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530457 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
458 {
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530459 ret = hdd_drv_cmd_validate(command, 16);
460 if (ret)
461 goto exit;
462
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530463 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
464 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700465
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530466 /*
467 * command should be a string having format
468 * SET_DISABLE_CHANNEL_LIST <num of channels>
469 * <channels separated by spaces>
470 */
471 else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) {
472 tANI_U8 *ptr = command;
473
474 ret = hdd_drv_cmd_validate(command, 24);
475 if (ret)
476 goto exit;
477
478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
479 " Received Command to disable Channels for in %s",
480 __func__);
481 ret = hdd_parse_disable_chan_cmd(pAdapter, ptr);
482 }
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530483 else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) {
484 char extra[128] = {0};
485 int len;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530486
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
488 " Received Command to get disable Channels list %s",
489 __func__);
490
491 len = hdd_get_disable_ch_list(pHddCtx, extra, sizeof(extra));
492 if (len == 0) {
493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
494 FL("disable channel list are not yet programed"));
495 ret = -EINVAL;
496 goto exit;
497 }
498
499 len = VOS_MIN(priv_data->total_len, len + 1);
500 if (copy_to_user(priv_data->buf, &extra, len)) {
501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
502 "%s: failed to copy data to user buffer", __func__);
503 ret = -EFAULT;
504 goto exit;
505 }
506
507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
508 FL("data:%s"), extra);
509 }
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530510 else {
511 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
512 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
513 pAdapter->sessionId, 0));
514 hddLog(VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"),
515 command);
516 }
517
Jeff Johnson295189b2012-06-20 16:38:30 -0700518exit:
519 if (command)
520 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700521 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530523 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 return ret;
525}
526
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700527#ifdef CONFIG_COMPAT
528static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
529 struct ifreq *ifr)
530{
531 struct {
532 compat_uptr_t buf;
533 int used_len;
534 int total_len;
535 } compat_priv_data;
536 hdd_priv_data_t priv_data;
537 int ret = 0;
538
539 /*
540 * Note that pAdapter and ifr have already been verified by caller,
541 * and HDD context has also been validated
542 */
543 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
544 sizeof(compat_priv_data))) {
545 ret = -EFAULT;
546 goto exit;
547 }
548 priv_data.buf = compat_ptr(compat_priv_data.buf);
549 priv_data.used_len = compat_priv_data.used_len;
550 priv_data.total_len = compat_priv_data.total_len;
551 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
552 exit:
553 return ret;
554}
555#else /* CONFIG_COMPAT */
556static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
557 struct ifreq *ifr)
558{
559 /* will never be invoked */
560 return 0;
561}
562#endif /* CONFIG_COMPAT */
563
564static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
565{
566 hdd_priv_data_t priv_data;
567 int ret = 0;
568
569 /*
570 * Note that pAdapter and ifr have already been verified by caller,
571 * and HDD context has also been validated
572 */
573 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
574 ret = -EFAULT;
575 } else {
576 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
577 }
578 return ret;
579}
580
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530581static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700582 struct ifreq *ifr, int cmd)
583{
584 hdd_adapter_t *pAdapter;
585 hdd_context_t *pHddCtx;
586 int ret;
587
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530588 ENTER();
589
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700590 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
591 if (NULL == pAdapter) {
592 hddLog(VOS_TRACE_LEVEL_ERROR,
593 "%s: HDD adapter context is Null", __func__);
594 ret = -ENODEV;
595 goto exit;
596 }
597 if (dev != pAdapter->dev) {
598 hddLog(VOS_TRACE_LEVEL_ERROR,
599 "%s: HDD adapter/dev inconsistency", __func__);
600 ret = -ENODEV;
601 goto exit;
602 }
603
604 if ((!ifr) || (!ifr->ifr_data)) {
605 ret = -EINVAL;
606 goto exit;
607 }
608
609 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
610 ret = wlan_hdd_validate_context(pHddCtx);
611 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700612 ret = -EBUSY;
613 goto exit;
614 }
615
616 switch (cmd) {
617 case (SIOCDEVPRIVATE + 1):
618 if (is_compat_task())
619 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
620 else
621 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
622 break;
623 default:
624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
625 __func__, cmd);
626 ret = -EINVAL;
627 break;
628 }
629 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530630 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700631 return ret;
632}
633
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530634static int hdd_hostapd_ioctl(struct net_device *dev,
635 struct ifreq *ifr, int cmd)
636{
637 int ret;
638
639 vos_ssr_protect(__func__);
640 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
641 vos_ssr_unprotect(__func__);
642
643 return ret;
644}
645
Jeff Johnson295189b2012-06-20 16:38:30 -0700646/**---------------------------------------------------------------------------
647
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530648 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 This function sets the user specified mac address using
650 the command ifconfig wlanX hw ether <mac adress>.
651
652 \param - dev - Pointer to the net device.
653 - addr - Pointer to the sockaddr.
654 \return - 0 for success, non zero for failure
655
656 --------------------------------------------------------------------------*/
657
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530658static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700659{
660 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530661 hdd_adapter_t *pAdapter;
662 hdd_context_t *pHddCtx;
663 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530664
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
667 if (NULL == pAdapter)
668 {
669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
670 "%s: Adapter is NULL",__func__);
671 return -EINVAL;
672 }
673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
674 ret = wlan_hdd_validate_context(pHddCtx);
675 if (0 != ret)
676 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530677 return ret;
678 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
680 EXIT();
681 return 0;
682}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530683
684static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
685{
686 int ret;
687
688 vos_ssr_protect(__func__);
689 ret = __hdd_hostapd_set_mac_address(dev, addr);
690 vos_ssr_unprotect(__func__);
691
692 return ret;
693}
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
696{
697 struct net_device *dev = (struct net_device *)usrDataForCallback;
698 v_BYTE_t we_custom_event[64];
699 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530701 hdd_context_t *pHddCtx;
702#ifdef DISABLE_CONCURRENCY_AUTOSAVE
703 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 hdd_ap_ctx_t *pHddApCtx;
705#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
706
707 /* event_name space-delimiter driver_module_name */
708 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
709 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
710 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
711
712 ENTER();
713
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530714 pHostapdAdapter = netdev_priv(dev);
715 if ((NULL == pHostapdAdapter) ||
716 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
717 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700718 hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530719 return;
720 }
721 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
722 if (0 != (wlan_hdd_validate_context(pHddCtx)))
723 {
724 return;
725 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530726#ifdef DISABLE_CONCURRENCY_AUTOSAVE
727 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530728 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 /*
730 This timer routine is going to be called only when AP
731 persona is up.
732 If there are concurrent sessions running we do not want
733 to shut down the Bss.Instead we run the timer again so
734 that if Autosave is enabled next time and other session
735 was down only then we bring down AP
736 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
738 vos_status = vos_timer_start(
739 &pHddApCtx->hdd_ap_inactivity_timer,
740 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
741 * 1000);
742 if (!VOS_IS_STATUS_SUCCESS(vos_status))
743 {
744 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
745 }
746 EXIT();
747 return;
748 }
749#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
750 memset(&we_custom_event, '\0', sizeof(we_custom_event));
751 memcpy(&we_custom_event, autoShutEvent, event_len);
752
753 memset(&wrqu, 0, sizeof(wrqu));
754 wrqu.data.length = event_len;
755
756 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
757 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
758
759 EXIT();
760}
761
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800762VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
763{
764 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
765 ptSapContext pSapCtx = NULL;
766 eHalStatus halStatus = eHAL_STATUS_FAILURE;
767 v_PVOID_t hHal = NULL;
768
769 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
770 "%s: UPDATE Beacon Params", __func__);
771
772 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
773 pSapCtx = VOS_GET_SAP_CB(pVosContext);
774 if ( NULL == pSapCtx )
775 {
776 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
777 "%s: Invalid SAP pointer from pvosGCtx", __func__);
778 return VOS_STATUS_E_FAULT;
779 }
780
781 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
782 if ( NULL == hHal ){
783 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
784 "%s: Invalid HAL pointer from pvosGCtx", __func__);
785 return VOS_STATUS_E_FAULT;
786 }
787 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
788 if(halStatus == eHAL_STATUS_FAILURE ){
789 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
790 "%s: Failed to update Beacon Params", __func__);
791 return VOS_STATUS_E_FAILURE;
792 }
793 }
794 return VOS_STATUS_SUCCESS;
795}
796
797void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
798{
799 v_U8_t staId = 0;
800 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530801 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
802 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800803
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530804 dev = (struct net_device *)usrDataForCallback;
805 pSapCtx = VOS_GET_SAP_CB(pVosContext);
806 if(pSapCtx == NULL){
807 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
808 FL("psapCtx is NULL"));
809 return;
810 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800811 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800812 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
813 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530814 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800815 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
816 {
817 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530818 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800819 }
820 }
821}
822
Agarwal Ashish8e538932014-12-24 18:12:52 +0530823static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800824{
825 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530826 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800827 VOS_STATUS status = VOS_STATUS_SUCCESS;
828 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530829
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800830 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530831
832 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
833 status = wlan_hdd_validate_context(pHddCtx);
834
835 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530836 return status;
837 }
838
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800839 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
840 {
841 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
842 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800844 }
845 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530846 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800847 }
848 EXIT();
849 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
850}
Jeff Johnson295189b2012-06-20 16:38:30 -0700851
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530852#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530853bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530854 bool enabled)
855{
856 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530857 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530858
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530859 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530860 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
861
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530862 sap_offload_info.sap_auth_offload_enable = enabled;
863 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530864 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530865 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530866 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
867
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530868 if (sap_offload_info.sap_auth_offload_enable &&
869 sap_offload_info.sap_auth_offload_sec_type)
870 {
871 if (sap_offload_info.key_len < 8 ||
872 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
873 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530874 hddLog(VOS_TRACE_LEVEL_ERROR,
875 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530876 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530877 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530878 }
879 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530880 if (sap_offload_info.key_len)
881 {
882 vos_mem_copy(sap_offload_info.key,
883 pHddCtx->cfg_ini->sap_auth_offload_key,
884 sap_offload_info.key_len);
885 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530886 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530887 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
888 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530889 hddLog(VOS_TRACE_LEVEL_ERROR,
890 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530891 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530892 }
893
894 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
895 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530896 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530897}
898#endif
899
Abhishek Singhe8ebb922017-11-01 13:30:26 +0530900/**
901* wlansap_get_phymode() - get SAP phymode.
902* @pctx: Pointer to the global vos context; a handle to SAP's control block
903* can be extracted from its context. When MBSSID feature is enabled,
904* SAP context is directly passed to SAP APIs.
905*
906* This function provides current phymode of SAP interface.
907*
908* Return: phymode with eCsrPhyMode type.
909*/
910static eCsrPhyMode
911wlansap_get_phymode(v_PVOID_t pctx)
912{
913 ptSapContext psapctx = VOS_GET_SAP_CB(pctx);
914
915 if (!psapctx) {
916 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
917 "%s: Invalid SAP pointer from pCtx", __func__);
918 return eCSR_DOT11_MODE_AUTO;
919 }
920 return psapctx->csrRoamProfile.phyMode;
921}
922
923/**
924 * hdd_update_chandef() - Function to update channel width and center freq
925 * @chandef: cfg80211 chan def
926 * @cb_mode: chan offset
927 *
928 * This function will be called to update channel width and center freq
929 *
930 * Return: None
931 */
932static void
933hdd_update_chandef(struct cfg80211_chan_def *chandef,
934 ePhyChanBondState cb_mode)
935{
936 uint8_t center_chan, chan;
937
938 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
939 return;
940
941 chan = vos_freq_to_chan(chandef->chan->center_freq);
942 chandef->width = NL80211_CHAN_WIDTH_80;
943 switch (cb_mode) {
944 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
945 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
946 center_chan = chan + 2;
947 break;
948 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
949 center_chan = chan + 6;
950 break;
951 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
952 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
953 center_chan = chan - 2;
954 break;
955 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
956 center_chan = chan - 6;
957 break;
958 default:
959 center_chan = chan;
960 break;
961 }
962
963 chandef->center_freq1 = vos_chan_to_freq(center_chan);
964}
965
966/**
967 * hdd_chan_change_notify() - Function to notify hostapd about channel change
968 * @hostapd_adapter: hostapd adapter
969 * @dev: Net device structure
970 * @oper_chan: New operating channel
971 *
972 * This function is used to notify hostapd about the channel change
973 *
974 * Return: Success on intimating userspace
975 *
976 */
977static VOS_STATUS hdd_chan_change_notify(hdd_adapter_t *hostapd_adapter,
978 struct net_device *dev, uint8_t oper_chan)
979{
980 struct ieee80211_channel *chan;
981 struct cfg80211_chan_def chandef;
982 enum nl80211_channel_type channel_type;
983 eCsrPhyMode phy_mode;
984 ePhyChanBondState cb_mode;
985 uint32_t freq;
986 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(hostapd_adapter);
987 tSmeConfigParams sme_config;
988
989 if (!hal) {
990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
991 "%s: hal is NULL", __func__);
992 return VOS_STATUS_E_FAILURE;
993 }
994
995 freq = vos_chan_to_freq(oper_chan);
996
997 chan = __ieee80211_get_channel(hostapd_adapter->wdev.wiphy, freq);
998
999 if (!chan) {
1000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1001 "%s: Invalid input frequency for channel conversion", __func__);
1002 return VOS_STATUS_E_FAILURE;
1003 }
1004
1005 phy_mode = wlansap_get_phymode(
1006 (WLAN_HDD_GET_CTX(hostapd_adapter))->pvosContext);
1007 sme_GetConfigParam(hal, &sme_config);
1008 if (oper_chan <= 14)
1009 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1010 sme_config.csrConfig.channelBondingMode24GHz);
1011 else
1012 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1013 sme_config.csrConfig.channelBondingMode5GHz);
1014
1015 switch (phy_mode) {
1016 case eCSR_DOT11_MODE_11n:
1017 case eCSR_DOT11_MODE_11n_ONLY:
1018 case eCSR_DOT11_MODE_11ac:
1019 case eCSR_DOT11_MODE_11ac_ONLY:
1020 switch (cb_mode) {
1021 case PHY_SINGLE_CHANNEL_CENTERED:
1022 channel_type = NL80211_CHAN_HT20;
1023 break;
1024 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1025 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1026 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1027 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1028 channel_type = NL80211_CHAN_HT40MINUS;
1029 break;
1030 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1031 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1032 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1033 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1034 channel_type = NL80211_CHAN_HT40PLUS;
1035 break;
1036 default:
1037 channel_type = NL80211_CHAN_HT20;
1038 break;
1039 }
1040 break;
1041 default:
1042 channel_type = NL80211_CHAN_NO_HT;
1043 break;
1044 }
1045
1046 cfg80211_chandef_create(&chandef, chan, channel_type);
1047 if ((phy_mode == eCSR_DOT11_MODE_11ac) ||
1048 (phy_mode == eCSR_DOT11_MODE_11ac_ONLY))
1049 hdd_update_chandef(&chandef, cb_mode);
1050
1051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1052 "%s: phy_mode %d cb_mode %d chann_type %d oper_chan %d width %d freq_1 %d",
1053 __func__, phy_mode, cb_mode, channel_type, oper_chan,
1054 chandef.width, chandef.center_freq1);
1055
1056
1057 cfg80211_ch_switch_notify(dev, &chandef);
1058
1059 return VOS_STATUS_SUCCESS;
1060}
1061
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301062/**
1063 * hdd_convert_dot11mode_from_phymode() - get dot11mode to phymode
1064 * @phymode: phy mode
1065 *
1066 * This function is used to get dot11mode to phymode
1067 *
1068 * Return: dot11mode
1069 */
1070static int hdd_convert_dot11mode_from_phymode(int phymode)
1071{
1072 switch (phymode) {
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301073
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301074 case VOS_MODE_11A:
1075 return QCA_WLAN_802_11_MODE_11A;
1076
1077 case VOS_MODE_11B:
1078 return QCA_WLAN_802_11_MODE_11B;
1079
1080 case VOS_MODE_11G:
1081 case VOS_MODE_11GONLY:
1082 return QCA_WLAN_802_11_MODE_11G;
1083
1084 case VOS_MODE_11NA_HT20:
1085 case VOS_MODE_11NG_HT20:
1086 case VOS_MODE_11NA_HT40:
1087 case VOS_MODE_11NG_HT40:
1088 return QCA_WLAN_802_11_MODE_11N;
1089
1090 case VOS_MODE_11AC_VHT20:
1091 case VOS_MODE_11AC_VHT40:
1092 case VOS_MODE_11AC_VHT80:
1093 case VOS_MODE_11AC_VHT20_2G:
1094 case VOS_MODE_11AC_VHT40_2G:
1095 case VOS_MODE_11AC_VHT80_2G:
1096#ifdef CONFIG_160MHZ_SUPPORT
1097 case VOS_MODE_11AC_VHT80_80:
1098 case VOS_MODE_11AC_VHT160:
1099#endif
1100 return QCA_WLAN_802_11_MODE_11AC;
1101
1102 default:
1103 return QCA_WLAN_802_11_MODE_INVALID;
1104 }
1105
1106}
1107
1108/**
1109 * hdd_fill_station_info() - fill station information
1110 * @sap_ctx: sap context
1111 * @event: assoc event
1112 * This function updates sta information from assoc event
1113 *
1114 * Return: none
1115 */
1116static void hdd_fill_station_info(ptSapContext sap_ctx,
1117 tSap_StationAssocReassocCompleteEvent *event)
1118{
1119 struct hdd_cache_sta_info *sta_info = sap_ctx->cache_sta_info;
1120 int i=0;
1121
1122 /* check if there is any dup entry */
1123 while (i < WLAN_MAX_STA_COUNT) {
1124 if (vos_mem_compare(sta_info[i].macAddrSTA.bytes,
1125 event->staMac.bytes,
1126 VOS_MAC_ADDR_SIZE)) {
1127 vos_mem_zero(&sta_info[i], sizeof(*sta_info));
1128 break;
1129 }
1130 i++;
1131 }
1132 if (i >= WLAN_MAX_STA_COUNT) {
1133 i = 0;
1134 while (i < WLAN_MAX_STA_COUNT) {
1135 if (sta_info[i].isUsed != TRUE)
1136 break;
1137 i++;
1138 }
1139 }
1140
1141 if (i < WLAN_MAX_STA_COUNT) {
1142 sta_info[i].isUsed = TRUE;
1143 sta_info[i].ucSTAId = event->staId;
1144 vos_mem_copy(sta_info[i].macAddrSTA.bytes,
1145 event->staMac.bytes,
1146 VOS_MAC_ADDR_SIZE);
1147 sta_info[i].freq = vos_chan_to_freq(event->chan_info.chan_id);
1148 sta_info[i].ch_width = event->ch_width;
1149 sta_info[i].nss = 1;
1150 sta_info[i].dot11_mode = hdd_convert_dot11mode_from_phymode(
1151 event->chan_info.info);
1152 if (event->HTCaps.present) {
1153 sta_info[i].ht_present = TRUE;
1154 hdd_copy_ht_caps(&sta_info[i].ht_caps, &event->HTCaps);
1155 }
1156 if (event->VHTCaps.present) {
1157 sta_info[i].vht_present = TRUE;
1158 hdd_copy_vht_caps(&sta_info[i].vht_caps,
1159 &event->VHTCaps);
1160 }
1161 }
1162 else
1163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "reached max staid, stainfo can't be cached");
1164}
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301165
Jeff Johnson295189b2012-06-20 16:38:30 -07001166VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
1167{
1168 hdd_adapter_t *pHostapdAdapter;
1169 hdd_ap_ctx_t *pHddApCtx;
1170 hdd_hostapd_state_t *pHostapdState;
1171 struct net_device *dev;
1172 eSapHddEvent sapEvent;
1173 union iwreq_data wrqu;
1174 v_BYTE_t *we_custom_event_generic = NULL;
1175 int we_event = 0;
1176 int i = 0;
1177 v_U8_t staId;
1178 VOS_STATUS vos_status;
1179 v_BOOL_t bWPSState;
1180 v_BOOL_t bApActive = FALSE;
1181 v_BOOL_t bAuthRequired = TRUE;
1182 tpSap_AssocMacAddr pAssocStasArray = NULL;
1183 char unknownSTAEvent[IW_CUSTOM_MAX+1];
1184 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
1185 v_BYTE_t we_custom_start_event[64];
1186 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001187 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001188 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -07001189 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301190 v_CONTEXT_t pVosContext = NULL;
1191 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +05301192 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -07001193
1194 dev = (struct net_device *)usrDataForCallback;
1195 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +05301196
1197 if ((NULL == pHostapdAdapter) ||
1198 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
1199 {
1200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1201 "invalid adapter or adapter has invalid magic");
1202 return eHAL_STATUS_FAILURE;
1203 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301204 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1205 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1206 if(pSapCtx == NULL){
1207 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1208 FL("psapCtx is NULL"));
1209 return eHAL_STATUS_FAILURE;
1210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1212 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1213 sapEvent = pSapEvent->sapHddEventCode;
1214 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001215 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +05301216 cfg_param = pHddCtx->cfg_ini;
1217
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 switch(sapEvent)
1219 {
1220 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -08001221 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
1223 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
1224 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
1225
1226 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
1227 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +05301228
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +05301230 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 goto stopbss;
1233 }
1234 else
Deepthi Gowried085092015-10-20 19:30:52 +05301235 {
1236 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1237 {
1238 if ((cfg_param->dynSplitscan) &&
1239 (!pHddCtx->issplitscan_enabled))
1240 {
1241 pHddCtx->issplitscan_enabled = TRUE;
1242 sme_enable_disable_split_scan(
1243 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
1244 cfg_param->nNumStaChanCombinedConc,
1245 cfg_param->nNumP2PChanCombinedConc);
1246 }
1247 }
1248
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1250 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +05301251 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1252 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +05301253 {
c_hpothuffdb5272013-10-02 16:42:35 +05301254 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +05301255 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
1256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 }
Deepthi Gowried085092015-10-20 19:30:52 +05301258
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1260 {
1261 // AP Inactivity timer init and start
1262 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1263 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1264 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001265 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001266
1267 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1268 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001269 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001270
1271 }
1272 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1273 pHostapdState->bssState = BSS_START;
1274
1275 // Send current operating channel of SoftAP to BTC-ES
1276 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1277
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 //Check if there is any group key pending to set.
1279 if( pHddApCtx->groupKey.keyLength )
1280 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001281 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1283 &pHddApCtx->groupKey ) )
1284 {
1285 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1286 "%s: WLANSAP_SetKeySta failed", __func__);
1287 }
1288 pHddApCtx->groupKey.keyLength = 0;
1289 }
1290 else if ( pHddApCtx->wepKey[0].keyLength )
1291 {
1292 int i=0;
1293 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1294 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001295 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1297 &pHddApCtx->wepKey[i] ) )
1298 {
1299 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1300 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 }
1303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1305 startBssEvent = "SOFTAP.enabled";
1306 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1307 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1308 memset(&wrqu, 0, sizeof(wrqu));
1309 wrqu.data.length = strlen(startBssEvent);
1310 we_event = IWEVCUSTOM;
1311 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001312 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 break; //Event will be sent after Switch-Case stmt
1314
1315 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001316 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1318
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001319 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001320 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001321
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301323
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301324 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301325 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301326 hddLog(LOG1,
1327 FL("P2P Go is getting removed and we are trying to re-enable TDLS"));
1328 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301329 }
1330
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 goto stopbss;
1332 case eSAP_STA_SET_KEY_EVENT:
1333 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001334 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1336 return VOS_STATUS_SUCCESS;
1337 case eSAP_STA_DEL_KEY_EVENT:
1338 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001339 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 return VOS_STATUS_SUCCESS;
1341 case eSAP_STA_MIC_FAILURE_EVENT:
1342 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 memset(&msg, '\0', sizeof(msg));
1344 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001345 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001346 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001347 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 msg.flags = IW_MICFAILURE_GROUP;
1349 else
1350 msg.flags = IW_MICFAILURE_PAIRWISE;
1351 memset(&wrqu, 0, sizeof(wrqu));
1352 wrqu.data.length = sizeof(msg);
1353 we_event = IWEVMICHAELMICFAILURE;
1354 we_custom_event_generic = (v_BYTE_t *)&msg;
1355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 /* inform mic failure to nl80211 */
1357 cfg80211_michael_mic_failure(dev,
1358 pSapEvent->sapevt.
1359 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001360 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 NL80211_KEYTYPE_GROUP :
1362 NL80211_KEYTYPE_PAIRWISE),
1363 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1364 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1365 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 break;
1367
1368 case eSAP_STA_ASSOC_EVENT:
1369 case eSAP_STA_REASSOC_EVENT:
1370 wrqu.addr.sa_family = ARPHRD_ETHER;
1371 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001372 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001373 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 we_event = IWEVREGISTERED;
1375
1376 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1377
1378 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1379 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1380 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1381 {
1382 bAuthRequired = FALSE;
1383 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301384 /* fAuthRequiredshould should be false for sap offload */
1385 if ((bAuthRequired || bWPSState)
1386#ifdef SAP_AUTH_OFFLOAD
1387 && !cfg_param->enable_sap_auth_offload
1388#endif
1389 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 {
c_hpothuffdb5272013-10-02 16:42:35 +05301391 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 TRUE,
1393 pHddApCtx->uPrivacy,
1394 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1395 0,
1396 0,
1397 (v_MACADDR_t *)wrqu.addr.sa_data,
1398 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301399
1400 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1401 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1402 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 }
1404 else
1405 {
c_hpothuffdb5272013-10-02 16:42:35 +05301406 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 FALSE,
1408 pHddApCtx->uPrivacy,
1409 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1410 0,
1411 0,
1412 (v_MACADDR_t *)wrqu.addr.sa_data,
1413 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301414 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1415 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1416 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001417 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301418 if (VOS_IS_STATUS_SUCCESS(vos_status))
1419 hdd_fill_station_info(pSapCtx,
1420 &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent);
Amar Singhal6144c002013-05-03 16:11:42 -07001421
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301422 staId =
1423 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1424 if (VOS_IS_STATUS_SUCCESS(vos_status))
1425 {
1426
1427 pSapCtx->aStaInfo[staId].rate_flags =
1428 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1429 }
1430
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 // Stop AP inactivity timer
1432 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1433 {
1434 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1435 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001436 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001438#ifdef WLAN_OPEN_SOURCE
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301439 if (vos_wake_lock_active(&pHddCtx->sap_wake_lock))
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001440 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301441 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1442 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001443 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301444 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1445 HDD_SAP_WAKE_LOCK_DURATION,
1446 WIFI_POWER_EVENT_WAKELOCK_SAP);
1447
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001448#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001449#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1450 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301451 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1453
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301454 staInfo = vos_mem_malloc(sizeof(*staInfo));
1455 if (staInfo == NULL) {
1456 hddLog(LOGE, FL("alloc station_info failed"));
1457 return VOS_STATUS_E_NOMEM;
1458 }
1459
1460 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1462 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301463 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301465 staInfo->assoc_req_ies_len = iesLen;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301466#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) && \
1467 ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
1468 !defined(WITH_BACKPORTS))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301469 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001470#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 cfg80211_new_sta(dev,
1472 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301473 staInfo, GFP_KERNEL);
1474 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 }
1476 else
1477 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001478 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 }
1480 }
1481#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301482 hdd_manage_delack_timer(pHddCtx);
1483
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001484 pScanInfo = &pHddCtx->scan_info;
1485 // Lets do abort scan to ensure smooth authentication for client
1486 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1487 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301488 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301489 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001491
1492 break;
1493 case eSAP_STA_DISASSOC_EVENT:
1494 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001495 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001496 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1498 hddLog(LOG1," User initiated disassociation");
1499 else
1500 hddLog(LOG1," MAC initiated disassociation");
1501 we_event = IWEVEXPIRED;
1502 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1503 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1504 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001505 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 -07001506 return VOS_STATUS_E_FAILURE;
1507 }
1508 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1509
1510 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1511 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301512 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 // Start AP inactivity timer if no stations associated with it
1514 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1515 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301516 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 {
1518 bApActive = TRUE;
1519 break;
1520 }
1521 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301522 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
1524 if (bApActive == FALSE)
1525 {
1526 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1527 {
1528 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1529 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001530 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 }
1532 else
1533 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1534 }
1535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1537 cfg80211_del_sta(dev,
1538 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1539 GFP_KERNEL);
1540#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001541 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301542 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1543 if (VOS_STATUS_SUCCESS != vos_status)
1544 {
1545 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1546 __func__, vos_status);
1547 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301548 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 break;
1550 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1551 {
1552 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1553 union iwreq_data wreq;
1554
1555 down(&pHddApCtx->semWpsPBCOverlapInd);
1556 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1557
1558 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1559 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1560
1561 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001562 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 memset(&wreq, 0, sizeof(wreq));
1564 wreq.data.length = strlen(message); // This is length of message
1565 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1566
1567 return VOS_STATUS_SUCCESS;
1568 }
1569 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1570 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1571 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1572 { // List of associated stations
1573 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1574 {
1575 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1576 i+1,
1577 pAssocStasArray->assocId,
1578 pAssocStasArray->staId,
1579 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1580 pAssocStasArray++;
1581 }
1582 }
1583 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001584 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 case eSAP_REMAIN_CHAN_READY:
1587 hdd_remainChanReadyHandler( pHostapdAdapter );
1588 return VOS_STATUS_SUCCESS;
1589 case eSAP_SEND_ACTION_CNF:
1590 hdd_sendActionCnf( pHostapdAdapter,
1591 ( eSAP_STATUS_SUCCESS ==
1592 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1593 TRUE : FALSE );
1594 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 case eSAP_UNKNOWN_STA_JOIN:
1596 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1597 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1598 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1599 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1600 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1601 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1602 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1603 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1604 wrqu.data.pointer = unknownSTAEvent;
1605 wrqu.data.length = strlen(unknownSTAEvent);
1606 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301607 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 break;
1609
1610 case eSAP_MAX_ASSOC_EXCEEDED:
1611 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1612 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1613 " one or more devices to enable the new device connection",
1614 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1615 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1616 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1617 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1618 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1619 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1620 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1621 wrqu.data.pointer = maxAssocExceededEvent;
1622 wrqu.data.length = strlen(maxAssocExceededEvent);
1623 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001624 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 break;
1626 case eSAP_STA_ASSOC_IND:
1627 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001628
1629 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001630 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001631 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1632 return VOS_STATUS_SUCCESS;
1633
1634 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301635 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301636 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1637 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301638 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301639 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001640 return VOS_STATUS_SUCCESS;
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301641 case eSAP_CHANNEL_CHANGED_EVENT:
1642 hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001643
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301644 return hdd_chan_change_notify(pHostapdAdapter, dev,
1645 pSapEvent->sapevt.sap_chan_selected.new_chan);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301646 case eSAP_STA_LOSTLINK_DETECTED:
1647 {
1648 tSap_StationDisassocCompleteEvent *disassoc_comp =
1649 &pSapEvent->sapevt.sapStationDisassocCompleteEvent;
1650
1651 struct hdd_cache_sta_info *sta_info = hdd_get_cache_stainfo(
1652 pSapCtx->cache_sta_info,
1653 disassoc_comp->staMac.bytes);
1654 if (!sta_info) {
1655 hddLog(LOGE, FL("invalid cache sta info"));
1656 return VOS_STATUS_E_FAILURE;
1657 }
1658
1659 WLANTL_GetSAPStaRSSi(pVosContext, disassoc_comp->staId,
1660 &sta_info->rssi);
1661 sta_info->rx_rate =
1662 wlan_tl_get_sta_rx_rate(pVosContext, disassoc_comp->staId);
1663 if (disassoc_comp->reason != eSAP_USR_INITATED_DISASSOC)
1664 sta_info->reason_code = disassoc_comp->reason;
1665 return VOS_STATUS_SUCCESS;
1666 }
1667
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001669 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 goto stopbss;
1671 return VOS_STATUS_SUCCESS;
1672 }
1673 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1674 return VOS_STATUS_SUCCESS;
1675
1676stopbss :
1677 {
1678 v_BYTE_t we_custom_event[64];
1679 char *stopBssEvent = "STOP-BSS.response";//17
1680 int event_len = strlen(stopBssEvent);
1681
1682 hddLog(LOG1, FL("BSS stop status = %s"),
1683 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1684 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1685
1686 /* Change the BSS state now since, as we are shutting things down,
1687 * we don't want interfaces to become re-enabled */
1688 pHostapdState->bssState = BSS_STOP;
1689
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301690 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1691 {
1692 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1693 {
1694 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1695 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1696 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1697 }
1698
1699 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1700 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1701 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1702 }
1703
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 /* Stop the pkts from n/w stack as we are going to free all of
1705 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301706
1707 /*
1708 * If channel avoidance is in progress means driver is performing SAP
1709 * restart. So don't do carrier off, which may lead framework to do
1710 * driver reload.
1711 */
1712 hddLog(LOG1, FL("ch avoid in progress: %d"),
1713 pHddCtx->is_ch_avoid_in_progress);
1714 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301715 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301716 netif_tx_disable(dev);
1717 else
1718 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001719
1720 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301721 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1722 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1723 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001724
Amar Singhal37e6f052013-03-05 16:16:54 -08001725 /* once the event is set, structure dev/pHostapdAdapter should
1726 * not be touched since they are now subject to being deleted
1727 * by another thread */
1728 if (eSAP_STOP_BSS_EVENT == sapEvent)
1729 vos_event_set(&pHostapdState->vosEvent);
1730
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +05301731 if (hdd_is_any_session_connected(pHddCtx) == VOS_STATUS_E_FAILURE) {
1732 hdd_enable_bmps_imps(pHddCtx);
1733 sme_request_imps(pHddCtx->hHal);
1734 }
1735
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 /* notify userspace that the BSS has stopped */
1737 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1738 memcpy(&we_custom_event, stopBssEvent, event_len);
1739 memset(&wrqu, 0, sizeof(wrqu));
1740 wrqu.data.length = event_len;
1741 we_event = IWEVCUSTOM;
1742 we_custom_event_generic = we_custom_event;
1743 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001744 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 }
1746 return VOS_STATUS_SUCCESS;
1747}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001748
1749int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001751 eCsrEncryptionType *pEncryptType,
1752 eCsrEncryptionType *mcEncryptType,
1753 eCsrAuthType *pAuthType,
1754 v_BOOL_t *pMFPCapable,
1755 v_BOOL_t *pMFPRequired,
1756 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 u_int8_t *gen_ie )
1758{
1759 tDot11fIERSN dot11RSNIE;
1760 tDot11fIEWPA dot11WPAIE;
1761
1762 tANI_U8 *pRsnIe;
1763 tANI_U16 RSNIeLen;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301764 tANI_U32 status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001765
1766 if (NULL == halHandle)
1767 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001768 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 return -EINVAL;
1770 }
1771
1772 // Validity checks
1773 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1774 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1775 return -EINVAL;
1776 // Type check
1777 if ( gen_ie[0] == DOT11F_EID_RSN)
1778 {
1779 // Validity checks
1780 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1781 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1782 {
1783 return VOS_STATUS_E_FAILURE;
1784 }
1785 // Skip past the EID byte and length byte
1786 pRsnIe = gen_ie + 2;
1787 RSNIeLen = gen_ie_len - 2;
1788 // Unpack the RSN IE
1789 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301790 status = dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
1791 pRsnIe,
1792 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 &dot11RSNIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301794 if (DOT11F_FAILED(status))
1795 {
1796 hddLog(LOGE,
1797 FL("unpack failed for RSN IE status:(0x%08x)"),
1798 status);
1799 return -EINVAL;
1800 }
1801
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001803 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001804 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001805 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001806 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 /*Here we have followed the apple base code,
1808 but probably I suspect we can do something different*/
1809 //dot11RSNIE.akm_suite_count
1810 // Just translate the FIRST one
1811 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
1812 //dot11RSNIE.pwise_cipher_suite_count
1813 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1814 //dot11RSNIE.gp_cipher_suite_count
1815 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1816 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001817 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1818 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001819
1820 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1821 } else
1822 if (gen_ie[0] == DOT11F_EID_WPA)
1823 {
1824 // Validity checks
1825 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1826 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1827 {
1828 return VOS_STATUS_E_FAILURE;
1829 }
1830 // Skip past the EID byte and length byte - and four byte WiFi OUI
1831 pRsnIe = gen_ie + 2 + 4;
1832 RSNIeLen = gen_ie_len - (2 + 4);
1833 // Unpack the WPA IE
1834 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301835 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1836 pRsnIe,
1837 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301839 if (DOT11F_FAILED(status))
1840 {
1841 hddLog(LOGE,
1842 FL("unpack failed for WPA IE status:(0x%08x)"),
1843 status);
1844 return -EINVAL;
1845 }
1846
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001848 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001849 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001850 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001851 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 //dot11WPAIE.auth_suite_count
1853 // Just translate the FIRST one
1854 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1855 //dot11WPAIE.unicast_cipher_count
1856 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1857 //dot11WPAIE.unicast_cipher_count
1858 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001859 *pMFPCapable = VOS_FALSE;
1860 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 }
1862 else
1863 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001864 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 return VOS_STATUS_E_FAILURE;
1866 }
1867 return VOS_STATUS_SUCCESS;
1868}
Leo Chang614d2072013-08-22 14:59:44 -07001869
Leo Chang0b0e45a2013-12-15 15:18:55 -08001870#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001871
1872/*==========================================================================
1873 FUNCTION sapUpdateUnsafeChannelList
1874
1875 DESCRIPTION
1876 Function Undate unsafe channel list table
1877
1878 DEPENDENCIES
1879 NA.
1880
1881 PARAMETERS
1882
1883 IN
1884 pSapCtx : SAP context pointer, include unsafe channel list
1885
1886 RETURN VALUE
1887 NONE
1888============================================================================*/
1889void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1890 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1891{
1892 v_U16_t i, j;
1893
1894 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1895 sizeof(pHddCtx->unsafeChannelList));
1896 if (0 == unsafeChannelCount)
1897 {
1898 pHddCtx->unsafeChannelCount = 0;
1899 }
1900 else
1901 {
c_hpothu8de53e42014-08-22 15:00:37 +05301902 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1903 {
1904 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1905 FL("unsafeChannelCount%hd greater than %d"),
1906 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1907 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1908 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001909 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1910 unsafeChannelList,
1911 unsafeChannelCount * sizeof(tANI_U16));
1912 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1913 }
1914
1915 /* Flush, default set all channel safe */
1916 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1917 {
1918 safeChannels[i].isSafe = VOS_TRUE;
1919 }
1920
1921 /* Try to find unsafe channel */
1922 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1923 {
1924 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1925 {
1926 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1927 {
1928 /* Found unsafe channel, update it */
1929 safeChannels[j].isSafe = VOS_FALSE;
1930 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1931 "%s : CH %d is not safe",
1932 __func__, pHddCtx->unsafeChannelList[i]);
1933 break;
1934 }
1935 }
1936 }
1937
1938 return;
1939}
1940
Kapil Gupta137ef892016-12-13 19:38:00 +05301941/**
1942 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1943 * @adapter: hdd ap adapter
1944 *
1945 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1946 * and if ACS is enabled, driver will ask userspace to restart the
1947 * sap. User space on LTE coex indication restart driver.
1948 *
1949 * Return - none
1950 */
1951static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1952 hdd_context_t *hdd_ctx)
1953{
1954
1955 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1956 return;
1957 }
1958
1959 hddLog(LOG1, FL("Current operation channel %d"),
1960 adapter->sessionCtx.ap.operatingChannel);
1961 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1962 hdd_change_ch_avoidance_status(hdd_ctx, true);
1963
1964 vos_flush_work(
1965 &hdd_ctx->sap_start_work);
1966
1967 /*
1968 * current operating channel
1969 * is un-safe channel, restart SAP
1970 */
1971 hddLog(LOG1,
1972 FL("Restarting SAP due to unsafe channel"));
1973
1974 adapter->sessionCtx.ap.sapConfig.channel =
1975 AUTO_CHANNEL_SELECT;
1976
Kapil Gupta137ef892016-12-13 19:38:00 +05301977
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301978 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05301979 netif_tx_disable(adapter->dev);
1980 schedule_work(&hdd_ctx->sap_start_work);
1981 } else {
1982 hdd_hostapd_stop(adapter->dev);
1983 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301984
1985 return;
1986 }
1987 return;
1988}
1989
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05301990void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
1991 hdd_context_t *hdd_ctxt)
1992{
1993 v_U16_t channelLoop;
1994 v_U16_t unsafeChannelCount = 0;
1995 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
1996
1997 /* Get unsafe channel list */
1998 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
1999 &unsafeChannelCount);
2000 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
2001 {
2002 if ((unsafeChannelList[channelLoop] ==
2003 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
2004 if ((AUTO_CHANNEL_SELECT ==
2005 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
2006 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
2007 /*
2008 * current operating channel is un-safe channel
2009 * restart driver
2010 */
2011 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
2012 /*
2013 * On LE, this event is handled by wlan-services to
2014 * restart SAP. On android, this event would be
2015 * ignored.
2016 */
2017 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
2018 NULL, 0);
2019 }
2020 break;
2021 }
2022 }
2023 return;
2024}
2025
2026
Kapil Gupta137ef892016-12-13 19:38:00 +05302027
Leo Chang0b0e45a2013-12-15 15:18:55 -08002028/**---------------------------------------------------------------------------
2029
2030 \brief hdd_hostapd_ch_avoid_cb() -
2031
2032 Avoid channel notification from FW handler.
2033 FW will send un-safe channle list to avoid overwrapping.
2034 hostapd should not use notified channel
2035
2036 \param - pAdapter HDD adapter pointer
2037 indParam channel avoid notification parameter
2038
2039 \return - None
2040
2041 --------------------------------------------------------------------------*/
2042void hdd_hostapd_ch_avoid_cb
2043(
Kapil Gupta137ef892016-12-13 19:38:00 +05302044 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08002045 void *indParam
2046)
2047{
2048 hdd_adapter_t *pHostapdAdapter = NULL;
2049 hdd_context_t *hddCtxt;
2050 tSirChAvoidIndType *chAvoidInd;
2051 v_U8_t rangeLoop;
2052 v_U16_t channelLoop;
2053 v_U16_t dupCheck;
2054 v_U16_t startChannel;
2055 v_U16_t endChannel;
2056 v_U16_t unsafeChannelCount = 0;
2057 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
2058 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002059 tHddAvoidFreqList hddAvoidFreqList;
2060 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302061#ifdef WLAN_FEATURE_AP_HT40_24G
2062 ptSapContext pSapCtx = NULL;
2063 tHalHandle hHal;
2064 v_U8_t cbMode;
2065 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2066 v_U32_t delay;
2067#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002068
2069 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05302070 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002071 {
2072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2073 "%s : Invalid arguments", __func__);
2074 return;
2075 }
2076
Kapil Gupta137ef892016-12-13 19:38:00 +05302077 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08002078 chAvoidInd = (tSirChAvoidIndType *)indParam;
2079 pVosContext = hddCtxt->pvosContext;
2080
2081 /* Make unsafe channel list */
2082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2083 "%s : band count %d",
2084 __func__, chAvoidInd->avoidRangeCount);
2085 vos_mem_zero((void *)unsafeChannelList,
2086 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
2087 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
2088 {
Abhishek Singh57a31542016-01-04 21:01:43 +05302089 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2090 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2091 break;
2092 }
2093 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002094 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05302095 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002096 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
2097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2098 "%s : start %d : %d, end %d : %d",
2099 __func__,
2100 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
2101 startChannel,
2102 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
2103 endChannel);
2104 for (channelLoop = startChannel;
2105 channelLoop < (endChannel + 1);
2106 channelLoop++)
2107 {
2108 /* Channel duplicate check routine */
2109 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
2110 {
2111 if (unsafeChannelList[dupCheck] == channelLoop)
2112 {
2113 /* This channel is duplicated */
2114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2115 "%s : found duplicated channel %d",
2116 __func__, channelLoop);
2117 break;
2118 }
2119 }
2120 if (dupCheck == unsafeChannelCount)
2121 {
c_hpothu8de53e42014-08-22 15:00:37 +05302122 int ii;
2123 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
2124 {
2125 if (channelLoop == safeChannels[ii].channelNumber)
2126 {
2127 unsafeChannelList[unsafeChannelCount] = channelLoop;
2128 unsafeChannelCount++;
2129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2130 "%s : unsafe channel %d, count %d",
2131 __func__,
2132 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05302133 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2134 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2135 break;
2136 }
c_hpothu8de53e42014-08-22 15:00:37 +05302137 }
2138 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08002139 }
2140 else
2141 {
2142 /* DUP, do nothing */
2143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2144 "%s : duplicated channel %d",
2145 __func__, channelLoop);
2146 }
2147 }
2148 }
2149 /* Update unsafe channel cache
2150 * WCN Platform Driver cache */
2151 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
2152 unsafeChannelCount);
2153
2154 /* Store into local cache
2155 * Start with STA and later start SAP
2156 * in this scenario, local cache will be used */
2157 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
2158 unsafeChannelList,
2159 unsafeChannelCount);
2160
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002161 /* generate vendor specific event */
2162 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
2163 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
2164 {
2165 hddAvoidFreqList.avoidFreqRange[i].startFreq =
2166 chAvoidInd->avoidFreqRange[i].startFreq;
2167 hddAvoidFreqList.avoidFreqRange[i].endFreq =
2168 chAvoidInd->avoidFreqRange[i].endFreq;
2169 }
2170 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
2171
2172 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
2173
Leo Chang0b0e45a2013-12-15 15:18:55 -08002174 /* Get SAP context first
2175 * SAP and P2PGO would not concurrent */
2176 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302177#ifdef WLAN_FEATURE_AP_HT40_24G
2178 if (NULL == pHostapdAdapter)
2179 {
2180 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
2181 }
2182#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05302183 if ((pHostapdAdapter) &&
2184 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
2185 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002186 {
2187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2188 "%s : Current operation channel %d",
2189 __func__,
2190 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302191 /* Check and Restart the SAP if it is on unsafe channel */
2192 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
2193
Leo Chang0b0e45a2013-12-15 15:18:55 -08002194 }
2195
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302196#ifdef WLAN_FEATURE_AP_HT40_24G
2197 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
2198 {
2199 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2200
2201 if(pSapCtx == NULL)
2202 {
2203 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
2204 FL("psapCtx is NULL"));
2205 return;
2206 }
2207
2208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2209 FL("SAP Secondary channel: %d "),
2210 pSapCtx->sap_sec_chan);
2211
2212 /* tHalHandle */
2213 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2214
2215 if (NULL == hHal)
2216 {
2217 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2218 FL("In invalid hHal"));
2219 return;
2220 }
2221
2222 cbMode = sme_GetChannelBondingMode24G(hHal);
2223
2224 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2225 FL("Selected Channel bonding : %d"), cbMode);
2226
2227 if (cbMode && (pSapCtx->sap_sec_chan > 0))
2228 {
2229 int i;
2230 eHalStatus halStatus;
2231
2232 for (i = 0; i < unsafeChannelCount; i++)
2233 {
2234 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
2235 {
2236 /* Current SAP Secondary channel is un-safe channel */
2237 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2238 FL("Move SAP from HT40 to HT20"));
2239
2240 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
2241 PHY_SINGLE_CHANNEL_CENTERED);
2242
2243 if (halStatus == eHAL_STATUS_FAILURE)
2244 {
2245 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2246 FL("Failed to change HT20/40 mode"));
2247 return;
2248 }
2249
2250 /* Disable Channel Bonding for 2.4GHz */
2251 sme_UpdateChannelBondingMode24G(hHal,
2252 PHY_SINGLE_CHANNEL_CENTERED);
2253 return;
2254 }
2255 }
2256 }
2257
2258 if ((!pSapCtx->numHT40IntoSta)
2259 && (pHostapdAdapter)
2260 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
2261 {
2262 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
2263 * are Safe then start HT20/40 timer to Move SAP from HT20
2264 * to HT40.
2265 */
2266 if (((!unsafeChannelCount)
2267 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
2268 {
2269 /* Stop Previous Running HT20/40 Timer & Start timer
2270 with (OBSS TransitionDelayFactor * obss interval)
2271 delay after time out move AP from HT20 -> HT40
2272 mode
2273 */
2274 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2275 {
2276 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2277 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2278 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2279 FL("Failed to Stop HT20/40 timer"));
2280 }
2281
2282 delay =
2283 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
2284
2285 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2286 FL("Start HT20/40 transition timer (%d sec)"), delay);
2287
2288 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
2289 (delay * 1000));
2290
2291 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2292 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2293 FL("Failed to Start HT20/40 timer"));
2294 }
2295 else
2296 {
2297 /* Stop HT20/40 Timer */
2298 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2299 {
2300 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2301 FL("Stop HT20/40 transition timer"));
2302 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2303 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2304 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2305 FL("Failed to Stop HT20/40 timer"));
2306 }
2307 }
2308 }
2309 }
2310#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002311 return;
2312}
Leo Chang0b0e45a2013-12-15 15:18:55 -08002313#endif /* FEATURE_WLAN_CH_AVOID */
2314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302316static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 struct iw_request_info *info,
2318 union iwreq_data *wrqu, char *extra)
2319{
2320 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002321 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302322 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 int *value = (int *)extra;
2324 int sub_cmd = value[0];
2325 int set_value = value[1];
2326 eHalStatus status;
2327 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302328 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002329 v_CONTEXT_t pVosContext;
2330
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302331 ENTER();
2332
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302333 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002334 {
2335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302336 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002337 __func__);
2338 return -1;
2339 }
2340
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302341 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2342 ret = wlan_hdd_validate_context(pHddCtx);
2343 if (0 != ret)
2344 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302345 return -1;
2346 }
2347
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002348 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2349 if (!hHal)
2350 {
2351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2352 "%s: Hal ctx is null", __func__);
2353 return -1;
2354 }
2355
2356 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2357 if (!pVosContext)
2358 {
2359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2360 "%s: Vos ctx is null", __func__);
2361 return -1;
2362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002363
2364 switch(sub_cmd)
2365 {
2366
2367 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002368 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302370 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 }
2372 break;
2373
2374 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302375 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2377 {
2378 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2379 ret = -EINVAL;
2380 }
2381 else
2382 {
2383 WLANSAP_SetMode(pVosContext, set_value);
2384 }
2385 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302386
2387 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2388 if ((0 != set_value) && (1 != set_value))
2389 {
2390 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2391 ret = -EINVAL;
2392 }
2393 else
2394 {
2395 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2396 }
2397 break;
2398
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 case QCSAP_PARAM_MAX_ASSOC:
2400 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2401 {
2402 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2403 ret = -EINVAL;
2404 }
2405 else
2406 {
2407 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2408 {
2409 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2410 "Setting it to max allowed and continuing"),
2411 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2412 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2413 }
2414 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2415 set_value, NULL, eANI_BOOLEAN_FALSE);
2416 if ( status != eHAL_STATUS_SUCCESS )
2417 {
2418 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2419 status);
2420 ret = -EIO;
2421 }
2422 }
2423 break;
2424
2425 case QCSAP_PARAM_HIDE_SSID:
2426 {
2427 eHalStatus status = eHAL_STATUS_SUCCESS;
2428 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2429 if(eHAL_STATUS_SUCCESS != status)
2430 {
2431 hddLog(VOS_TRACE_LEVEL_ERROR,
2432 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002433 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 return status;
2435 }
2436 break;
2437 }
2438
Leo Chang614d2072013-08-22 14:59:44 -07002439 case QCSAP_PARAM_SET_MC_RATE:
2440 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002441 tSirRateUpdateInd *rateUpdate;
2442
2443 rateUpdate = (tSirRateUpdateInd *)
2444 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2445 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002446 {
2447 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002448 "%s: SET_MC_RATE indication alloc fail", __func__);
2449 ret = -1;
2450 break;
2451 }
2452 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2453
2454 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2455 /* Ignore unicast */
2456 rateUpdate->ucastDataRate = -1;
2457 rateUpdate->mcastDataRate24GHz = set_value;
2458 rateUpdate->mcastDataRate5GHz = set_value;
2459 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2460 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2461 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2462 if (eHAL_STATUS_SUCCESS != status)
2463 {
2464 hddLog(VOS_TRACE_LEVEL_ERROR,
2465 "%s: SET_MC_RATE failed", __func__);
2466 vos_mem_free(rateUpdate);
2467 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002468 }
2469 break;
2470 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302471 case QCSAP_PARAM_GET_FRAME_LOGS:
2472 {
2473 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2474 != VOS_STATUS_SUCCESS)
2475 {
2476 ret = -EINVAL;
2477 }
2478 break;
2479 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302480 case QCSAP_PARAM_SET_PROXIMITY:
2481 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302482 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302483 break;
2484 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302485 case QCSAP_PARAM_SET_WOWL:
2486 {
2487 if (!pHddCtx->is_ap_mode_wow_supported)
2488 {
2489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2490 "%s: Not supported",__func__);
2491 return -ENOTSUPP;
2492 }
2493 switch (set_value)
2494 {
2495 case 0x00:
2496 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2497 break;
2498 case 0x01:
2499 case 0x02:
2500 case 0x03:
2501 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2502 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2503 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2504 (enable_magic_pkt ? "YES":"NO"),
2505 (enable_pattrn_byte_match ? "YES":"NO"));
2506 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2507 enable_pattrn_byte_match);
2508 break;
2509 default:
2510 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2511 ret = -EINVAL;
2512 break;
2513 }
2514 break;
2515 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302516 case QCSAP_PARAM_CAP_TSF:
2517 {
2518 ret = hdd_capture_tsf(pHostapdAdapter,
2519 (uint32_t *)&set_value, 1);
2520 break;
2521 }
Abhishek Singh02605092017-10-25 14:06:12 +05302522 case QCSAP_PARAM_SET_CHANNEL_CHANGE:
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302523 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) {
2524 ptSapContext sap_ctx;
2525
2526 sap_ctx = VOS_GET_SAP_CB(pVosContext);
2527 if (!sap_ctx) {
2528 hddLog(LOGE, FL("sap_ctx is NULL"));
2529 return -EINVAL;
2530 }
2531 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
2532 if (ret)
2533 return ret;
2534 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
Abhishek Singh02605092017-10-25 14:06:12 +05302535 hddLog(LOG1, FL("ET Channel Change to new channel= %d"),
2536 set_value);
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302537 ret = wlansap_set_channel_change(pVosContext, set_value, false);
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302538 if (ret) {
2539 wlansap_reset_chan_change_in_progress(sap_ctx);
2540 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2541 }
Abhishek Singh02605092017-10-25 14:06:12 +05302542 } else {
2543 hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"),
2544 set_value);
2545 ret = -EINVAL;
2546 }
2547 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 default:
2549 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2550 sub_cmd, set_value);
2551 ret = -EINVAL;
2552 break;
2553 }
2554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302555 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 return ret;
2557}
2558
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302559int
2560static iw_softap_setparam(struct net_device *dev,
2561 struct iw_request_info *info,
2562 union iwreq_data *wrqu, char *extra)
2563{
2564 int ret;
2565
2566 vos_ssr_protect(__func__);
2567 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2568 vos_ssr_unprotect(__func__);
2569
2570 return ret;
2571}
Jeff Johnson295189b2012-06-20 16:38:30 -07002572
2573int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302574static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 struct iw_request_info *info,
2576 union iwreq_data *wrqu, char *extra)
2577{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302578 hdd_adapter_t *pHostapdAdapter;
2579 tHalHandle hHal;
2580 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 int *value = (int *)extra;
2582 int sub_cmd = value[0];
2583 eHalStatus status;
2584 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302585 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002586
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302587 ENTER();
2588
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302589 pHostapdAdapter = (netdev_priv(dev));
2590 if (NULL == pHostapdAdapter)
2591 {
2592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2593 "%s: Adapter is NULL",__func__);
2594 return -EINVAL;
2595 }
2596 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2597 ret = wlan_hdd_validate_context(pHddCtx);
2598 if (0 != ret)
2599 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302600 return ret;
2601 }
2602 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2603 if (NULL == hHal)
2604 {
2605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2606 "%s: Hal Context is NULL",__func__);
2607 return -EINVAL;
2608 }
2609 pVosContext = pHddCtx->pvosContext;
2610 if (NULL == pVosContext)
2611 {
2612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2613 "%s: pVosContext Context is NULL",__func__);
2614 return -EINVAL;
2615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 switch (sub_cmd)
2617 {
2618 case QCSAP_PARAM_MAX_ASSOC:
2619 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2620 if (eHAL_STATUS_SUCCESS != status)
2621 {
c_hpothuffdb5272013-10-02 16:42:35 +05302622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2623 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 ret = -EIO;
2625 }
Girish Gowli385be612014-09-18 11:17:20 +05302626
2627#ifdef WLAN_SOFTAP_VSTA_FEATURE
2628 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2629 {
2630 if (*value > VSTA_NUM_ASSOC_STA)
2631 {
2632 *value = VSTA_NUM_ASSOC_STA;
2633 }
2634 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2635 (*value > (VSTA_NUM_ASSOC_STA -
2636 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2637 {
2638 *value = (VSTA_NUM_ASSOC_STA -
2639 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2640 }
2641 }
2642 else
2643#endif
2644 {
2645 if (*value > NUM_ASSOC_STA)
2646 {
2647 *value = NUM_ASSOC_STA;
2648 }
2649 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2650 (*value > (NUM_ASSOC_STA -
2651 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2652 {
2653 *value = (NUM_ASSOC_STA -
2654 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2655 }
2656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302658
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002660 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 {
c_hpothuffdb5272013-10-02 16:42:35 +05302662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2663 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302664 ret = -EIO;
2665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 *value = 0;
2667 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302668
Jeff Johnson43971f52012-07-17 12:26:56 -07002669 case QCSAP_PARAM_GET_WLAN_DBG:
2670 {
2671 vos_trace_display();
2672 *value = 0;
2673 break;
2674 }
2675
2676 case QCSAP_PARAM_AUTO_CHANNEL:
2677 {
2678 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2679 break;
2680 }
2681
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 default:
2683 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2684 ret = -EINVAL;
2685 break;
2686
2687 }
2688
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302689 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 return ret;
2691}
2692
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302693int
2694static iw_softap_getparam(struct net_device *dev,
2695 struct iw_request_info *info,
2696 union iwreq_data *wrqu, char *extra)
2697{
2698 int ret;
2699
2700 vos_ssr_protect(__func__);
2701 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2702 vos_ssr_unprotect(__func__);
2703
2704 return ret;
2705}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302706
2707int
2708static __iw_softap_setchar_getnone(struct net_device *dev,
2709 struct iw_request_info *info,
2710 union iwreq_data *wrqu, char *extra)
2711{
2712 int sub_cmd;
2713 int ret = 0; /* success */
2714 char *pBuffer = NULL;
2715 hdd_adapter_t *pAdapter;
2716 hdd_context_t *pHddCtx;
2717 struct iw_point s_priv_data;
2718
2719 ENTER();
2720
2721 if (!capable(CAP_NET_ADMIN))
2722 {
2723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2724 FL("permission check failed"));
2725 return -EPERM;
2726 }
2727
2728 pAdapter = (netdev_priv(dev));
2729 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2730 ret = wlan_hdd_validate_context(pHddCtx);
2731 if (0 != ret)
2732 {
2733 return ret;
2734 }
2735
2736 if (!pHddCtx->is_ap_mode_wow_supported)
2737 {
2738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2739 "%s: Not supported",__func__);
2740 return -ENOTSUPP;
2741 }
2742
2743 /* helper function to get iwreq_data with compat handling. */
2744 if (hdd_priv_get_data(&s_priv_data, wrqu))
2745 {
2746 return -EINVAL;
2747 }
2748
2749 /* make sure all params are correctly passed to function */
2750 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2751 {
2752 return -EINVAL;
2753 }
2754
2755 sub_cmd = s_priv_data.flags;
2756
2757 /* ODD number is used for set, copy data using copy_from_user */
2758 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2759 s_priv_data.length);
2760 if (NULL == pBuffer)
2761 {
2762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2763 "mem_alloc_copy_from_user_helper fail");
2764 return -ENOMEM;
2765 }
2766
2767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2768 "%s: Received length %d", __func__, s_priv_data.length);
2769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2770 "%s: Received data %s", __func__, pBuffer);
2771
2772 switch(sub_cmd)
2773 {
2774 case WE_WOWL_ADD_PTRN:
2775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2776 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2777 if (!ret)
2778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2779 "Failed to add pattern :%d", ret);
2780 break;
2781 case WE_WOWL_DEL_PTRN:
2782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2783 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2784 if (!ret)
2785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2786 "Failed to del pattern :%d", ret);
2787 break;
2788 default:
2789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2790 ret = -EINVAL;
2791 break;
2792 }
2793
2794 kfree(pBuffer);
2795 return ret;
2796}
2797
2798int
2799static iw_softap_setchar_getnone(struct net_device *dev,
2800 struct iw_request_info *info,
2801 union iwreq_data *wrqu, char *extra)
2802{
2803 int ret;
2804
2805 vos_ssr_protect(__func__);
2806 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2807 vos_ssr_unprotect(__func__);
2808
2809 return ret;
2810}
2811
Jeff Johnson295189b2012-06-20 16:38:30 -07002812/* Usage:
2813 BLACK_LIST = 0
2814 WHITE_LIST = 1
2815 ADD MAC = 0
2816 REMOVE MAC = 1
2817
2818 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2819 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2820 while using this ioctl
2821
2822 Syntax:
2823 iwpriv softap.0 modify_acl
2824 <6 octet mac addr> <list type> <cmd type>
2825
2826 Examples:
2827 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2828 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2829 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2830 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2831*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302832int __iw_softap_modify_acl(struct net_device *dev,
2833 struct iw_request_info *info,
2834 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002835{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302836 hdd_adapter_t *pHostapdAdapter;
2837 v_CONTEXT_t pVosContext;
2838 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 v_BYTE_t *value = (v_BYTE_t*)extra;
2840 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2841 int listType, cmd, i;
2842 int ret = 0; /* success */
2843
2844 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302845 pHostapdAdapter = (netdev_priv(dev));
2846 if (NULL == pHostapdAdapter)
2847 {
2848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2849 "%s: Adapter is NULL",__func__);
2850 return -EINVAL;
2851 }
2852 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2853 ret = wlan_hdd_validate_context(pHddCtx);
2854 if (0 != ret)
2855 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302856 return ret;
2857 }
2858 pVosContext = pHddCtx->pvosContext;
2859 if (NULL == pVosContext)
2860 {
2861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2862 "%s: Vos Context is NULL",__func__);
2863 return -EINVAL;
2864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2866 {
2867 pPeerStaMac[i] = *(value+i);
2868 }
2869 listType = (int)(*(value+i));
2870 i++;
2871 cmd = (int)(*(value+i));
2872
Arif Hussain24bafea2013-11-15 15:10:03 -08002873 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2874 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002875
2876 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2877 != VOS_STATUS_SUCCESS)
2878 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002879 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 ret = -EIO;
2881 }
2882 EXIT();
2883 return ret;
2884}
2885
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302886int iw_softap_modify_acl(struct net_device *dev,
2887 struct iw_request_info *info,
2888 union iwreq_data *wrqu, char *extra)
2889{
2890 int ret;
2891
2892 vos_ssr_protect(__func__);
2893 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2894 vos_ssr_unprotect(__func__);
2895
2896 return ret;
2897}
2898
Jeff Johnson295189b2012-06-20 16:38:30 -07002899int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302900static __iw_softap_getchannel(struct net_device *dev,
2901 struct iw_request_info *info,
2902 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002903{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302904 hdd_adapter_t *pHostapdAdapter;
2905 hdd_context_t *pHddCtx;
2906 int ret = 0;
2907 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302908
2909 ENTER();
2910
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302911 pHostapdAdapter = (netdev_priv(dev));
2912 if (NULL == pHostapdAdapter)
2913 {
2914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2915 "%s: Adapter is NULL",__func__);
2916 return -EINVAL;
2917 }
2918 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2919 ret = wlan_hdd_validate_context(pHddCtx);
2920 if (0 != ret)
2921 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302922 return ret;
2923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002924
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302925 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
Jeff Johnson43971f52012-07-17 12:26:56 -07002927 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302928
2929 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 return 0;
2931}
2932
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302933
Jeff Johnsone7245742012-09-05 17:12:55 -07002934int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302935static iw_softap_getchannel(struct net_device *dev,
2936 struct iw_request_info *info,
2937 union iwreq_data *wrqu, char *extra)
2938{
2939 int ret;
2940
2941 vos_ssr_protect(__func__);
2942 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
2943 vos_ssr_unprotect(__func__);
2944
2945 return ret;
2946}
2947
2948int
2949static __iw_softap_set_max_tx_power(struct net_device *dev,
2950 struct iw_request_info *info,
2951 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07002952{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302953 hdd_adapter_t *pHostapdAdapter;
2954 tHalHandle hHal;
2955 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07002956 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302957 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002958 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2959 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2960
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302961 ENTER();
2962
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302963 pHostapdAdapter = (netdev_priv(dev));
2964 if (NULL == pHostapdAdapter)
2965 {
2966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2967 "%s: Adapter is NULL",__func__);
2968 return -EINVAL;
2969 }
2970 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2971 ret = wlan_hdd_validate_context(pHddCtx);
2972 if (0 != ret)
2973 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302974 return ret;
2975 }
2976 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2977 if (NULL == hHal)
2978 {
2979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2980 "%s: Hal Context is NULL",__func__);
2981 return -EINVAL;
2982 }
schang86c22c42013-03-13 18:41:24 -07002983 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07002984 return -ENOMEM;
2985
Leo Changd37675a2013-08-01 13:19:45 -07002986 /* Assign correct slef MAC address */
2987 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
2988 VOS_MAC_ADDR_SIZE);
2989 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
2990 VOS_MAC_ADDR_SIZE);
2991
schang86c22c42013-03-13 18:41:24 -07002992 set_value = value[0];
2993 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
2994 {
2995 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002996 __func__);
schang86c22c42013-03-13 18:41:24 -07002997 return -EIO;
2998 }
2999
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303000 EXIT();
schang86c22c42013-03-13 18:41:24 -07003001 return 0;
3002}
3003
3004int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303005static iw_softap_set_max_tx_power(struct net_device *dev,
3006 struct iw_request_info *info,
3007 union iwreq_data *wrqu, char *extra)
3008{
3009 int ret;
3010
3011 vos_ssr_protect(__func__);
3012 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
3013 vos_ssr_unprotect(__func__);
3014
3015 return ret;
3016}
3017
3018
3019int
3020static __iw_display_data_path_snapshot(struct net_device *dev,
3021 struct iw_request_info *info,
3022 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303023{
3024
3025 /* Function intitiating dumping states of
3026 * HDD(WMM Tx Queues)
3027 * TL State (with Per Client infor)
3028 * DXE Snapshot (Called at the end of TL Snapshot)
3029 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303030 hdd_adapter_t *pHostapdAdapter;
3031 hdd_context_t *pHddCtx;
3032 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303033
3034 ENTER();
3035
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303036 pHostapdAdapter = (netdev_priv(dev));
3037 if (NULL == pHostapdAdapter)
3038 {
3039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3040 "%s: Adapter is NULL",__func__);
3041 return -EINVAL;
3042 }
3043 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3044 ret = wlan_hdd_validate_context(pHddCtx);
3045 if (0 != ret)
3046 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303047 return ret;
3048 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303049 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05303050 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303051
3052 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303053 return 0;
3054}
3055
3056int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303057static iw_display_data_path_snapshot(struct net_device *dev,
3058 struct iw_request_info *info,
3059 union iwreq_data *wrqu, char *extra)
3060{
3061 int ret;
3062
3063 vos_ssr_protect(__func__);
3064 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
3065 vos_ssr_unprotect(__func__);
3066
3067 return ret;
3068}
3069
3070int
3071static __iw_softap_set_tx_power(struct net_device *dev,
3072 struct iw_request_info *info,
3073 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07003074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303075 hdd_adapter_t *pHostapdAdapter;
3076 hdd_context_t *pHddCtx;
3077 v_CONTEXT_t pVosContext;
3078 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07003079 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303080 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07003081 ptSapContext pSapCtx = NULL;
3082
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303083 ENTER();
3084
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303085 pHostapdAdapter = (netdev_priv(dev));
3086 if (NULL == pHostapdAdapter)
3087 {
3088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: Adapter is NULL",__func__);
3090 return -EINVAL;
3091 }
3092 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3093 ret = wlan_hdd_validate_context(pHddCtx);
3094 if (0 != ret)
3095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303096 return ret;
3097 }
3098 pVosContext = pHddCtx->pvosContext;
3099 if (NULL == pVosContext)
3100 {
3101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3102 "%s: Vos Context is NULL",__func__);
3103 return -EINVAL;
3104 }
3105 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3106 if (NULL == hHal)
3107 {
3108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3109 "%s: Hal Context is NULL",__func__);
3110 return -EINVAL;
3111 }
schang86c22c42013-03-13 18:41:24 -07003112 if (NULL == value)
3113 return -ENOMEM;
3114
3115 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3116 if (NULL == pSapCtx)
3117 {
3118 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3119 "%s: Invalid SAP pointer from pvosGCtx", __func__);
3120 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003121 }
3122
3123 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07003124 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07003125 {
schang86c22c42013-03-13 18:41:24 -07003126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07003127 __func__);
3128 return -EIO;
3129 }
3130
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303131 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07003132 return 0;
3133}
3134
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303135int
3136static iw_softap_set_tx_power(struct net_device *dev,
3137 struct iw_request_info *info,
3138 union iwreq_data *wrqu, char *extra)
3139{
3140 int ret;
3141
3142 vos_ssr_protect(__func__);
3143 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
3144 vos_ssr_unprotect(__func__);
3145
3146 return ret;
3147}
3148
Kiet Lambcf38522013-10-26 18:28:27 +05303149/**---------------------------------------------------------------------------
3150
3151 \brief iw_softap_set_trafficmonitor() -
3152 This function dynamically enable/disable traffic monitor functonality
3153 the command iwpriv wlanX setTrafficMon <value>.
3154
3155 \param - dev - Pointer to the net device.
3156 - addr - Pointer to the sockaddr.
3157 \return - 0 for success, non zero for failure
3158
3159 --------------------------------------------------------------------------*/
3160
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303161static int __iw_softap_set_trafficmonitor(struct net_device *dev,
3162 struct iw_request_info *info,
3163 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05303164{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303165 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05303166 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05303167 hdd_context_t *pHddCtx;
3168 int status;
3169
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303170 ENTER();
3171
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303172 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05303173 if (NULL == pAdapter)
3174 {
3175 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3176 "%s: HDD adapter is Null", __func__);
3177 return -ENODEV;
3178 }
3179
3180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3181
3182 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05303183 if (0 != status)
3184 {
Kiet Lambcf38522013-10-26 18:28:27 +05303185 return status;
3186 }
3187
3188 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
3189
3190 if (NULL == isSetTrafficMon)
3191 {
3192 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3193 "%s: Invalid SAP pointer from extra", __func__);
3194 return -ENOMEM;
3195 }
3196
3197 if (TRUE == *isSetTrafficMon)
3198 {
3199 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303200 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303201 {
3202 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3203 "%s: failed to Start Traffic Monitor timer ", __func__ );
3204 return -EIO;
3205 }
3206 }
3207 else if (FALSE == *isSetTrafficMon)
3208 {
3209 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303210 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303211 {
3212 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3213 "%s: failed to Stop Traffic Monitor timer ", __func__ );
3214 return -EIO;
3215 }
3216
3217 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303218
3219 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05303220 return 0;
3221}
3222
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303223static int iw_softap_set_trafficmonitor(struct net_device *dev,
3224 struct iw_request_info *info,
3225 union iwreq_data *wrqu, char *extra)
3226{
3227 int ret;
3228
3229 vos_ssr_protect(__func__);
3230 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
3231 vos_ssr_unprotect(__func__);
3232
3233 return ret;
3234}
3235
Jeff Johnson295189b2012-06-20 16:38:30 -07003236#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
3237
3238int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303239static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
3240 struct iw_request_info *info,
3241 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003242{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303243 hdd_adapter_t *pHostapdAdapter;
3244 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303245 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07003246 char *buf;
3247 int cnt = 0;
3248 int left;
3249 int ret = 0;
3250 /* maclist_index must be u32 to match userspace */
3251 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303252 v_CONTEXT_t pVosContext = NULL;
3253 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303254
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303255 ENTER();
3256
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303257 pHostapdAdapter = (netdev_priv(dev));
3258 if (NULL == pHostapdAdapter)
3259 {
3260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3261 "%s: Adapter is NULL",__func__);
3262 return -EINVAL;
3263 }
3264 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3265 ret = wlan_hdd_validate_context(pHddCtx);
3266 if (0 != ret)
3267 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303268 return ret;
3269 }
3270
Jeff Johnson224f3702014-03-26 11:09:47 -07003271 /*
3272 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
3273 * number, and even numbered iocts are supposed to have "set"
3274 * semantics. Hence the wireless extensions support in the kernel
3275 * won't correctly copy the result to userspace, so the ioctl
3276 * handler itself must copy the data. Output format is 32-bit
3277 * record length, followed by 0 or more 6-byte STA MAC addresses.
3278 *
3279 * Further note that due to the incorrect semantics, the "iwpriv"
3280 * userspace application is unable to correctly invoke this API,
3281 * hence it is not registered in the hostapd_private_args. This
3282 * API can only be invoked by directly invoking the ioctl() system
3283 * call.
3284 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003285
Jeff Johnson224f3702014-03-26 11:09:47 -07003286 /* make sure userspace allocated a reasonable buffer size */
3287 if (wrqu->data.length < sizeof(maclist_index)) {
3288 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
3289 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07003290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003291
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303292 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3293 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3294 if(pSapCtx == NULL){
3295 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3296 FL("psapCtx is NULL"));
3297 return -EFAULT;
3298 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05303299
3300 /* allocate local buffer to build the response */
3301 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
3302 if (!buf) {
3303 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
3304 return -ENOMEM;
3305 }
3306
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303307 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07003308 /* start indexing beyond where the record count will be written */
3309 maclist_index = sizeof(maclist_index);
3310 left = wrqu->data.length - maclist_index;
3311
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303312 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003313 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
3314 if ((pStaInfo[cnt].isUsed) &&
3315 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
3316 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
3317 VOS_MAC_ADDR_SIZE);
3318 maclist_index += VOS_MAC_ADDR_SIZE;
3319 left -= VOS_MAC_ADDR_SIZE;
3320 }
3321 cnt++;
3322 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303323 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003324
3325 *((u32 *)buf) = maclist_index;
3326 wrqu->data.length = maclist_index;
3327 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
3328 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
3329 ret = -EFAULT;
3330 }
3331 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303332
3333 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07003334 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003335}
3336
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303337int
3338static iw_softap_getassoc_stamacaddr(struct net_device *dev,
3339 struct iw_request_info *info,
3340 union iwreq_data *wrqu, char *extra)
3341{
3342 int ret;
3343
3344 vos_ssr_protect(__func__);
3345 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
3346 vos_ssr_unprotect(__func__);
3347
3348 return ret;
3349}
3350
Jeff Johnson295189b2012-06-20 16:38:30 -07003351/* Usage:
3352 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3353 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3354 while using this ioctl
3355
3356 Syntax:
3357 iwpriv softap.0 disassoc_sta <6 octet mac address>
3358
3359 e.g.
3360 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
3361 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
3362*/
3363
3364int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303365static __iw_softap_disassoc_sta(struct net_device *dev,
3366 struct iw_request_info *info,
3367 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003368{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303369 hdd_adapter_t *pHostapdAdapter;
3370 hdd_context_t *pHddCtx;
3371 v_U8_t *peerMacAddr;
3372 int ret = 0;
3373
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05303375
3376 if (!capable(CAP_NET_ADMIN)) {
3377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3378 FL("permission check failed"));
3379 return -EPERM;
3380 }
3381
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303382 pHostapdAdapter = (netdev_priv(dev));
3383 if (NULL == pHostapdAdapter)
3384 {
3385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3386 "%s: Adapter is NULL",__func__);
3387 return -EINVAL;
3388 }
3389 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3390 ret = wlan_hdd_validate_context(pHddCtx);
3391 if (0 != ret)
3392 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303393 return ret;
3394 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303395 /* iwpriv tool or framework calls this ioctl with
3396 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303398 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003399
Arif Hussain24bafea2013-11-15 15:10:03 -08003400 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
3401 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
3403 EXIT();
3404 return 0;
3405}
3406
3407int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303408static iw_softap_disassoc_sta(struct net_device *dev,
3409 struct iw_request_info *info,
3410 union iwreq_data *wrqu, char *extra)
3411{
3412 int ret;
3413
3414 vos_ssr_protect(__func__);
3415 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3416 vos_ssr_unprotect(__func__);
3417
3418 return ret;
3419}
3420
3421int
3422static __iw_softap_ap_stats(struct net_device *dev,
3423 struct iw_request_info *info,
3424 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003425{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303426 hdd_adapter_t *pHostapdAdapter;
3427 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 WLANTL_TRANSFER_STA_TYPE statBuffer;
3429 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303430 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003431
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303432 ENTER();
3433
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303434 pHostapdAdapter = (netdev_priv(dev));
3435 if (NULL == pHostapdAdapter)
3436 {
3437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3438 "%s: Adapter is NULL",__func__);
3439 return -EINVAL;
3440 }
3441 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3442 ret = wlan_hdd_validate_context(pHddCtx);
3443 if (0 != ret)
3444 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303445 return ret;
3446 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003447 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003448 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3449 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003450
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303451 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003452 if(NULL == pstatbuf) {
3453 hddLog(LOG1, "unable to allocate memory");
3454 return -ENOMEM;
3455 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303456
3457 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003458 "RUF=%d RMF=%d RBF=%d "
3459 "RUB=%d RMB=%d RBB=%d "
3460 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303461 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003462 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3463 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3464 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3465 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3466 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3467 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003468
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303469 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003470 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3471 kfree(pstatbuf);
3472 return -EFAULT;
3473 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303474
3475 strlcpy(extra, pstatbuf, len);
3476 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003477 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303478
3479 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 return 0;
3481}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303482int
3483static __iw_softap_ap_get_stats(struct net_device *dev,
3484 struct iw_request_info *info,
3485 union iwreq_data *wrqu, char *extra)
3486{
3487 hdd_adapter_t *pAdapter;
3488 hdd_tx_rx_stats_t *pStats;
3489
3490 ENTER();
3491 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3492 if (NULL == pAdapter)
3493 {
3494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3495 "%s: Adapter is NULL",__func__);
3496 return -EINVAL;
3497 }
3498
3499 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3500 snprintf(extra, QCSAP_MAX_STR_LEN,
3501 "\nTransmit"
3502 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3503 "\n dropped BK %u, BE %u, VI %u, VO %u"
3504 "\n classified BK %u, BE %u, VI %u, VO %u"
3505 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3506 "\n queued BK %u, BE %u, VI %u, VO %u"
3507 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3508 "\ndequeued %u, depressured %u, deque-depressured %u,\
3509 completed %u, flushed %u"
3510 "\n fetched BK %u, BE %u, VI %u, VO %u"
3511 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3512 "\n depressured BK %u, BE %u, VI %u, VO %u"
3513 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3514 "\n flushed BK %u, BE %u, VI %u, VO %u"
3515 "\n\nReceive"
3516 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3517 "\n\nResetsStats"
3518 "\n",
3519 pStats->txXmitCalled,
3520 pStats->txXmitDropped,
3521 pStats->txXmitBackPressured,
3522 pStats->txXmitQueued,
3523
3524 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3525 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3526 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3527 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3528
3529 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3530 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3531 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3532 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3533
3534 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3535 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3536 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3537 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3538
3539 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3540 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3541 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3542 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3543
3544 pStats->txFetched,
3545 pStats->txFetchEmpty,
3546 pStats->txFetchLowResources,
3547 pStats->txFetchDequeueError,
3548
3549 pStats->txFetchDequeued,
3550 pStats->txFetchDePressured,
3551 pStats->txDequeDePressured,
3552 pStats->txCompleted,
3553 pStats->txFlushed,
3554
3555 pStats->txFetchedAC[WLANTL_AC_BK],
3556 pStats->txFetchedAC[WLANTL_AC_BE],
3557 pStats->txFetchedAC[WLANTL_AC_VI],
3558 pStats->txFetchedAC[WLANTL_AC_VO],
3559
3560 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3561 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3562 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3563 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3564
3565 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3566 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3567 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3568 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3569
3570 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3571 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3572 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3573 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3574
3575 pStats->txFlushedAC[WLANTL_AC_BK],
3576 pStats->txFlushedAC[WLANTL_AC_BE],
3577 pStats->txFlushedAC[WLANTL_AC_VI],
3578 pStats->txFlushedAC[WLANTL_AC_VO],
3579
3580 pStats->rxChains,
3581 pStats->rxPackets,
3582 pStats->rxDropped,
3583 pStats->rxDelivered,
3584 pStats->rxRefused
3585 );
3586
3587 wrqu->data.length = strlen(extra) + 1;
3588
3589 return 0;
3590}
3591
3592int
3593static __iw_softap_ap_clear_stats(struct net_device *dev,
3594 struct iw_request_info *info,
3595 union iwreq_data *wrqu, char *extra)
3596{
3597 hdd_adapter_t *pAdapter;
3598
3599 ENTER();
3600
3601 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3602 if (NULL == pAdapter)
3603 {
3604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3605 "%s: Adapter is NULL",__func__);
3606 return -EINVAL;
3607 }
3608
3609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3610 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3611 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3612 return 0;
3613}
3614
3615
3616int
3617static iw_softap_get_stats(struct net_device *dev,
3618 struct iw_request_info *info,
3619 union iwreq_data *wrqu, char *extra)
3620{
3621 int ret;
3622 vos_ssr_protect(__func__);
3623 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3624 vos_ssr_unprotect(__func__);
3625 return ret;
3626}
3627
3628int
3629static iw_softap_clear_stats(struct net_device *dev,
3630 struct iw_request_info *info,
3631 union iwreq_data *wrqu, char *extra)
3632{
3633 int ret;
3634 vos_ssr_protect(__func__);
3635 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3636 vos_ssr_unprotect(__func__);
3637 return ret;
3638}
Jeff Johnson295189b2012-06-20 16:38:30 -07003639
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303640int
3641static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 struct iw_request_info *info,
3643 union iwreq_data *wrqu, char *extra)
3644{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303645 int ret;
3646
3647 vos_ssr_protect(__func__);
3648 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3649 vos_ssr_unprotect(__func__);
3650
3651 return ret;
3652}
3653
Manjeet Singh3ed79242017-01-11 19:04:32 +05303654/**
3655 * __iw_softap_get_three() - return three value to upper layer.
3656 *
3657 * @dev: pointer of net_device of this wireless card
3658 * @info: meta data about Request sent
3659 * @wrqu: include request info
3660 * @extra: buf used for in/out
3661 *
3662 * Return: execute result
3663 */
3664static int __iw_softap_get_three(struct net_device *dev,
3665 struct iw_request_info *info,
3666 union iwreq_data *wrqu, char *extra)
3667{
3668 uint32_t *value = (uint32_t *)extra;
3669 uint32_t sub_cmd = value[0];
3670 int ret = 0; /* success */
3671
3672 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3673
3674 switch (sub_cmd) {
3675 case QCSAP_IOCTL_GET_TSF:
3676 ret = hdd_indicate_tsf(padapter, value, 3);
3677 break;
3678 default:
3679 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3680 break;
3681 }
3682 return ret;
3683}
3684
3685
3686/**
3687 * iw_softap_get_three() - return three value to upper layer.
3688 *
3689 * @dev: pointer of net_device of this wireless card
3690 * @info: meta data about Request sent
3691 * @wrqu: include request info
3692 * @extra: buf used for in/Output
3693 *
3694 * Return: execute result
3695 */
3696static int iw_softap_get_three(struct net_device *dev,
3697 struct iw_request_info *info,
3698 union iwreq_data *wrqu, char *extra)
3699{
3700 int ret;
3701
3702 vos_ssr_protect(__func__);
3703 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3704 vos_ssr_unprotect(__func__);
3705
3706 return ret;
3707}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303708static int __iw_softap_set_channel_range(struct net_device *dev,
3709 struct iw_request_info *info,
3710 union iwreq_data *wrqu, char *extra)
3711{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303712 hdd_adapter_t *pHostapdAdapter;
3713 tHalHandle hHal;
3714 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 int *value = (int *)extra;
3716 int startChannel = value[0];
3717 int endChannel = value[1];
3718 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003719 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 int ret = 0; /* success */
3721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303722 ENTER();
3723
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303724 if (!capable(CAP_NET_ADMIN))
3725 {
3726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3727 FL("permission check failed"));
3728 return -EPERM;
3729 }
3730
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303731 pHostapdAdapter = (netdev_priv(dev));
3732 if (NULL == pHostapdAdapter)
3733 {
3734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3735 "%s: Adapter is NULL",__func__);
3736 return -EINVAL;
3737 }
3738 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3739 ret = wlan_hdd_validate_context(pHddCtx);
3740 if (0 != ret)
3741 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303742 return ret;
3743 }
3744 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3745 if (NULL == hHal)
3746 {
3747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3748 "%s: Hal Context is NULL",__func__);
3749 return -EINVAL;
3750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3752 if(status != VOS_STATUS_SUCCESS)
3753 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003754 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 startChannel,endChannel, band);
3756 ret = -EINVAL;
3757 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003758
3759 pHddCtx->is_dynamic_channel_range_set = 1;
3760
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303761 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 return ret;
3763}
3764
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303765static int iw_softap_set_channel_range(struct net_device *dev,
3766 struct iw_request_info *info,
3767 union iwreq_data *wrqu, char *extra)
3768{
3769 int ret;
3770
3771 vos_ssr_protect(__func__);
3772 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3773 vos_ssr_unprotect(__func__);
3774
3775 return ret;
3776}
3777
3778
3779int __iw_softap_get_channel_list(struct net_device *dev,
3780 struct iw_request_info *info,
3781 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003782{
3783 v_U32_t num_channels = 0;
3784 v_U8_t i = 0;
3785 v_U8_t bandStartChannel = RF_CHAN_1;
3786 v_U8_t bandEndChannel = RF_CHAN_165;
3787 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303788 hdd_adapter_t *pHostapdAdapter;
3789 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003792 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303793 hdd_context_t *pHddCtx;
3794 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303795
3796 ENTER();
3797
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303798 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3799 if (NULL == pHostapdAdapter)
3800 {
3801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3802 "%s: Adapter is NULL",__func__);
3803 return -EINVAL;
3804 }
3805 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3806 ret = wlan_hdd_validate_context(pHddCtx);
3807 if (0 != ret)
3808 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303809 return ret;
3810 }
3811 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3812 if (NULL == hHal)
3813 {
3814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3815 "%s: Hal Context is NULL",__func__);
3816 return -EINVAL;
3817 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003818 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3819 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003820 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003821 return -EIO;
3822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 wrqu->data.length = sizeof(tChannelListInfo);
3824 ENTER();
3825
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003826 if (eCSR_BAND_24 == curBand)
3827 {
3828 bandStartChannel = RF_CHAN_1;
3829 bandEndChannel = RF_CHAN_14;
3830 }
3831 else if (eCSR_BAND_5G == curBand)
3832 {
3833 bandStartChannel = RF_CHAN_36;
3834 bandEndChannel = RF_CHAN_165;
3835 }
3836
Arif Hussain6d2a3322013-11-17 19:50:10 -08003837 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303838 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003839 bandStartChannel, bandEndChannel );
3840
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3842 {
3843 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3844 {
3845 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3846 num_channels++;
3847 }
3848 }
3849
3850 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3851
3852 temp_num_channels = num_channels;
3853
3854 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3855 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303856 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003857 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 }
3859
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303860 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3861 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 {
3863 for(i = 0; i < temp_num_channels; i++)
3864 {
3865
3866 if((channel_list->channels[i] > 35) &&
3867 (channel_list->channels[i] < 49))
3868 {
3869 vos_mem_move(&channel_list->channels[i],
3870 &channel_list->channels[i+1],
3871 temp_num_channels - (i-1));
3872 num_channels--;
3873 temp_num_channels--;
3874 i--;
3875 }
3876 }
3877 }
3878
Arif Hussain6d2a3322013-11-17 19:50:10 -08003879 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003880
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 channel_list->num_channels = num_channels;
3882 EXIT();
3883
3884 return 0;
3885}
3886
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303887int iw_softap_get_channel_list(struct net_device *dev,
3888 struct iw_request_info *info,
3889 union iwreq_data *wrqu, char *extra)
3890{
3891 int ret;
3892
3893 vos_ssr_protect(__func__);
3894 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3895 vos_ssr_unprotect(__func__);
3896
3897 return ret;
3898}
3899
3900static
3901int __iw_get_genie(struct net_device *dev,
3902 struct iw_request_info *info,
3903 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003904{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303905 hdd_adapter_t *pHostapdAdapter;
3906 hdd_context_t *pHddCtx;
3907 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303908 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3910 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303911 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303912
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303914
3915 pHostapdAdapter = (netdev_priv(dev));
3916 if (NULL == pHostapdAdapter)
3917 {
3918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3919 "%s: Adapter is NULL",__func__);
3920 return -EINVAL;
3921 }
3922 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3923 ret = wlan_hdd_validate_context(pHddCtx);
3924 if (0 != ret)
3925 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303926 return ret;
3927 }
3928 pVosContext = pHddCtx->pvosContext;
3929 if (NULL == pVosContext)
3930 {
3931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3932 "%s: vos context is not valid ",__func__);
3933 return -EINVAL;
3934 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003935 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
3937 status = WLANSap_getstationIE_information(pVosContext,
3938 &length,
3939 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05303940
3941 if (VOS_STATUS_SUCCESS != status) {
3942 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07003943 return -EFAULT;
3944 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05303945
Arif Hussained667642013-10-27 23:01:14 -07003946 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303947 if (length > DOT11F_IE_RSN_MAX_LEN) {
3948 hddLog(LOGE,
3949 FL("invalid buffer length length:%d"), length);
3950 return -E2BIG;
3951 }
3952
3953 vos_mem_copy(extra, genIeBytes, length);
3954
3955 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
3956
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 EXIT();
3958 return 0;
3959}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303960
3961static
3962int iw_get_genie(struct net_device *dev,
3963 struct iw_request_info *info,
3964 union iwreq_data *wrqu, char *extra)
3965{
3966 int ret;
3967
3968 vos_ssr_protect(__func__);
3969 ret = __iw_get_genie(dev, info, wrqu, extra);
3970 vos_ssr_unprotect(__func__);
3971
3972 return ret;
3973}
3974
3975static
3976int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
3977 struct iw_request_info *info,
3978 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003979{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303980 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07003981 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303982 hdd_ap_ctx_t *pHddApCtx;
3983 hdd_context_t *pHddCtx;
3984 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303985
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07003987
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303988 pHostapdAdapter = (netdev_priv(dev));
3989 if (NULL == pHostapdAdapter)
3990 {
3991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3992 "%s: Adapter is NULL",__func__);
3993 return -EINVAL;
3994 }
3995 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3996 ret = wlan_hdd_validate_context(pHddCtx);
3997 if (0 != ret)
3998 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303999 return ret;
4000 }
4001 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4002 if (NULL == pHddApCtx)
4003 {
4004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4005 "%s: AP context is NULL",__func__);
4006 return -EINVAL;
4007 }
4008
Arif Hussain6d2a3322013-11-17 19:50:10 -08004009 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07004010 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
4011
4012 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
4013 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
4014 pHddApCtx->WPSPBCProbeReq.probeReqIE,
4015 WPSPBCProbeReqIEs.probeReqIELen);
4016 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
4017 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
4018 sizeof(v_MACADDR_t));
4019 if (copy_to_user(wrqu->data.pointer,
4020 (void *)&WPSPBCProbeReqIEs,
4021 sizeof(WPSPBCProbeReqIEs)))
4022 {
4023 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4024 return -EFAULT;
4025 }
4026 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004027 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07004028 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 up(&pHddApCtx->semWpsPBCOverlapInd);
4030 EXIT();
4031 return 0;
4032}
4033
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304034static
4035int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4036 struct iw_request_info *info,
4037 union iwreq_data *wrqu, char *extra)
4038{
4039 int ret;
4040
4041 vos_ssr_protect(__func__);
4042 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
4043 vos_ssr_unprotect(__func__);
4044
4045 return ret;
4046}
4047
Jeff Johnson295189b2012-06-20 16:38:30 -07004048/**---------------------------------------------------------------------------
4049
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304050 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 This function sets the auth type received from the wpa_supplicant.
4052
4053 \param - dev - Pointer to the net device.
4054 - info - Pointer to the iw_request_info.
4055 - wrqu - Pointer to the iwreq_data.
4056 - extra - Pointer to the data.
4057 \return - 0 for success, non zero for failure
4058
4059 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304060int __iw_set_auth_hostap(struct net_device *dev,
4061 struct iw_request_info *info,
4062 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004063{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304064 hdd_adapter_t *pAdapter;
4065 hdd_context_t *pHddCtx;
4066 hdd_wext_state_t *pWextState;
4067 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304070
4071 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4072 if (NULL == pAdapter)
4073 {
4074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4075 "%s: Adapter is NULL",__func__);
4076 return -EINVAL;
4077 }
4078
4079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4080 ret = wlan_hdd_validate_context(pHddCtx);
4081 if (0 != ret)
4082 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304083 return ret;
4084 }
4085 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4086 if (NULL == pWextState)
4087 {
4088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4089 "%s: pWextState is NULL",__func__);
4090 return -EINVAL;
4091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 switch(wrqu->param.flags & IW_AUTH_INDEX)
4093 {
4094 case IW_AUTH_TKIP_COUNTERMEASURES:
4095 {
4096 if(wrqu->param.value) {
4097 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4098 "Counter Measure started %d", wrqu->param.value);
4099 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304100 }
4101 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4103 "Counter Measure stopped=%d", wrqu->param.value);
4104 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4105 }
4106
4107 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
4108 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304111
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304113
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004114 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 wrqu->param.flags & IW_AUTH_INDEX);
4116 break;
4117 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304118
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 EXIT();
4120 return 0;
4121}
4122
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304123int iw_set_auth_hostap(struct net_device *dev,
4124 struct iw_request_info *info,
4125 union iwreq_data *wrqu,char *extra)
4126{
4127 int ret;
4128
4129 vos_ssr_protect(__func__);
4130 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
4131 vos_ssr_unprotect(__func__);
4132
4133 return ret;
4134}
4135
4136static int __iw_set_ap_encodeext(struct net_device *dev,
4137 struct iw_request_info *info,
4138 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004139{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304140 hdd_adapter_t *pHostapdAdapter;
4141 v_CONTEXT_t pVosContext;
4142 hdd_context_t *pHddCtx;
4143 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07004144 int retval = 0;
4145 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4147 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4148 int key_index;
4149 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304150 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07004151// tCsrRoamRemoveKey RemoveKey;
4152 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304153
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304154 ENTER();
4155 pHostapdAdapter = (netdev_priv(dev));
4156 if (NULL == pHostapdAdapter)
4157 {
4158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4159 "%s: Adapter is NULL",__func__);
4160 return -EINVAL;
4161 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004162
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304163 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4164 retval = wlan_hdd_validate_context(pHddCtx);
4165 if (0 != retval)
4166 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304167 return retval;
4168 }
4169 pVosContext = pHddCtx->pvosContext;
4170 if (NULL == pVosContext)
4171 {
4172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4173 "%s: pVosContext is NULL",__func__);
4174 return -EINVAL;
4175 }
4176 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4177 if (NULL == pHddApCtx)
4178 {
4179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4180 "%s: AP Context is NULL",__func__);
4181 return -EINVAL;
4182 }
4183
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304185
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304187
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 /*Convert from 1-based to 0-based keying*/
4189 key_index--;
4190 }
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304191 if(!ext->key_len || ext->key_len > CSR_MAX_KEY_LEN) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304192#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 /*Set the encrytion type to NONE*/
4194#if 0
4195 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4196#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304197
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 RemoveKey.keyId = key_index;
4199 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4200 /*Key direction for group is RX only*/
4201 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4202 }
4203 else {
4204 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4205 }
4206 switch(ext->alg)
4207 {
4208 case IW_ENCODE_ALG_NONE:
4209 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4210 break;
4211 case IW_ENCODE_ALG_WEP:
4212 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4213 break;
4214 case IW_ENCODE_ALG_TKIP:
4215 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07004216 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 case IW_ENCODE_ALG_CCMP:
4218 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
4219 break;
4220 default:
4221 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4222 break;
4223 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004224 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 -07004225 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004227 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 );
Jeff Johnson43971f52012-07-17 12:26:56 -07004229 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
4230 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 {
4232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07004233 __LINE__, vstatus );
4234 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004236#endif
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304237 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004238
Jeff Johnson43971f52012-07-17 12:26:56 -07004239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004240
4241 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4242
4243 setKey.keyId = key_index;
4244 setKey.keyLength = ext->key_len;
4245
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304246 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004247
4248 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4249 /*Key direction for group is RX only*/
4250 setKey.keyDirection = eSIR_RX_ONLY;
4251 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4252 }
4253 else {
4254
4255 setKey.keyDirection = eSIR_TX_RX;
4256 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4257 }
4258 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4259 {
4260 setKey.keyDirection = eSIR_TX_DEFAULT;
4261 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4262 }
4263
4264 /*For supplicant pae role is zero*/
4265 setKey.paeRole = 0;
4266
4267 switch(ext->alg)
4268 {
4269 case IW_ENCODE_ALG_NONE:
4270 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4271 break;
4272
4273 case IW_ENCODE_ALG_WEP:
4274 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4275 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004276 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 break;
4278
4279 case IW_ENCODE_ALG_TKIP:
4280 {
4281 v_U8_t *pKey = &setKey.Key[0];
4282
4283 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4284
4285 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4286
4287 /*Supplicant sends the 32bytes key in this order
4288
4289 |--------------|----------|----------|
4290 | Tk1 |TX-MIC | RX Mic |
4291 |--------------|----------|----------|
4292 <---16bytes---><--8bytes--><--8bytes-->
4293
4294 */
4295 /*Sme expects the 32 bytes key to be in the below order
4296
4297 |--------------|----------|----------|
4298 | Tk1 |RX-MIC | TX Mic |
4299 |--------------|----------|----------|
4300 <---16bytes---><--8bytes--><--8bytes-->
4301 */
4302 /* Copy the Temporal Key 1 (TK1) */
4303 vos_mem_copy(pKey,ext->key,16);
4304
4305 /*Copy the rx mic first*/
4306 vos_mem_copy(&pKey[16],&ext->key[24],8);
4307
4308 /*Copy the tx mic */
4309 vos_mem_copy(&pKey[24],&ext->key[16],8);
4310
4311 }
4312 break;
4313
4314 case IW_ENCODE_ALG_CCMP:
4315 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4316 break;
4317
4318 default:
4319 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4320 break;
4321 }
4322
4323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304324 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 setKey.keyId);
4326 for(i=0; i< ext->key_len; i++)
4327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4328 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07004329
4330 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
4331 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 {
4333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07004334 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
4335 retval = -EINVAL;
4336 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304337
4338 EXIT();
4339 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004340}
Jeff Johnson43971f52012-07-17 12:26:56 -07004341
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304342static int iw_set_ap_encodeext(struct net_device *dev,
4343 struct iw_request_info *info,
4344 union iwreq_data *wrqu, char *extra)
4345{
4346 int ret;
4347
4348 vos_ssr_protect(__func__);
4349 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
4350 vos_ssr_unprotect(__func__);
4351
4352 return ret;
4353}
Jeff Johnson43971f52012-07-17 12:26:56 -07004354
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304355static int __iw_set_ap_mlme(struct net_device *dev,
4356 struct iw_request_info *info,
4357 union iwreq_data *wrqu,
4358 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004359{
4360#if 0
4361 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4362 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4363
4364 ENTER();
4365
4366 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4367 switch (mlme->cmd) {
4368 case IW_MLME_DISASSOC:
4369 case IW_MLME_DEAUTH:
4370 hddLog(LOG1, "Station disassociate");
4371 if( pAdapter->conn_info.connState == eConnectionState_Associated )
4372 {
4373 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4374
4375 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4376 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4377
4378 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
4379
4380 //clear all the reason codes
4381 if (status != 0)
4382 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004383 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 }
4385
4386 netif_stop_queue(dev);
4387 netif_carrier_off(dev);
4388 }
4389 else
4390 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004391 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 -07004392 }
4393 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004394 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 return -EINVAL;
4396 }//end of switch
4397 EXIT();
4398#endif
4399 return 0;
4400// return status;
4401}
4402
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304403static int iw_set_ap_mlme(struct net_device *dev,
4404 struct iw_request_info *info,
4405 union iwreq_data *wrqu,
4406 char *extra)
4407{
4408 int ret;
4409
4410 vos_ssr_protect(__func__);
4411 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4412 vos_ssr_unprotect(__func__);
4413
4414 return ret;
4415}
4416
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304417static int __iw_get_ap_rts_threshold(struct net_device *dev,
4418 struct iw_request_info *info,
4419 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004420{
4421 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4422 v_U32_t status = 0;
4423
4424 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4425
4426 return status;
4427}
4428
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304429static int iw_get_ap_rts_threshold(struct net_device *dev,
4430 struct iw_request_info *info,
4431 union iwreq_data *wrqu, char *extra)
4432{
4433 int ret;
4434
4435 vos_ssr_protect(__func__);
4436 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4437 vos_ssr_unprotect(__func__);
4438
4439 return ret;
4440}
4441
4442static int __iw_get_ap_frag_threshold(struct net_device *dev,
4443 struct iw_request_info *info,
4444 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004445{
4446 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4447 v_U32_t status = 0;
4448
4449 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4450
4451 return status;
4452}
4453
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304454static int iw_get_ap_frag_threshold(struct net_device *dev,
4455 struct iw_request_info *info,
4456 union iwreq_data *wrqu, char *extra)
4457{
4458 int ret;
4459
4460 vos_ssr_protect(__func__);
4461 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4462 vos_ssr_unprotect(__func__);
4463
4464 return ret;
4465}
4466
4467static int __iw_get_ap_freq(struct net_device *dev,
4468 struct iw_request_info *info,
4469 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004470{
Jeff Johnsone7245742012-09-05 17:12:55 -07004471 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304472 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 tHalHandle hHal;
4474 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304475 hdd_ap_ctx_t *pHddApCtx;
4476 hdd_context_t *pHddCtx;
4477 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004478
4479 ENTER();
4480
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304481 pHostapdAdapter = (netdev_priv(dev));
4482 if (NULL == pHostapdAdapter)
4483 {
4484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4485 "%s: Adapter is NULL",__func__);
4486 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304488 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4489 ret = wlan_hdd_validate_context(pHddCtx);
4490 if (0 != ret)
4491 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304492 return ret;
4493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304495 if (NULL == pHostapdState)
4496 {
4497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4498 "%s: pHostapdState is NULL",__func__);
4499 return -EINVAL;
4500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304502 if (NULL == hHal)
4503 {
4504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4505 "%s: Hal Context is NULL",__func__);
4506 return -EINVAL;
4507 }
4508 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4509 if (NULL == pHddApCtx)
4510 {
4511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4512 "%s: AP context is NULL",__func__);
4513 return -EINVAL;
4514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 if(pHostapdState->bssState == BSS_STOP )
4516 {
4517 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4518 != eHAL_STATUS_SUCCESS)
4519 {
c_hpothuffdb5272013-10-02 16:42:35 +05304520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4521 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 return -EIO;
4523 }
4524 else
4525 {
4526 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004527 if( TRUE == status)
4528 {
4529 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4530 * iwlist & iwconfig command shows frequency into proper
4531 * format (2.412 GHz instead of 246.2 MHz)*/
4532 fwrq->m = freq;
4533 fwrq->e = MHZ;
4534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 }
4536 }
4537 else
4538 {
4539 channel = pHddApCtx->operatingChannel;
4540 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07004541 if( TRUE == status)
4542 {
4543 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4544 * iwlist & iwconfig command shows frequency into proper
4545 * format (2.412 GHz instead of 246.2 MHz)*/
4546 fwrq->m = freq;
4547 fwrq->e = MHZ;
4548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304550
4551 EXIT();
4552 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553}
4554
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304555static int iw_get_ap_freq(struct net_device *dev,
4556 struct iw_request_info *info,
4557 struct iw_freq *fwrq, char *extra)
4558{
4559 int ret;
4560
4561 vos_ssr_protect(__func__);
4562 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4563 vos_ssr_unprotect(__func__);
4564
4565 return ret;
4566}
4567
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304568static int __iw_softap_stopbss(struct net_device *dev,
4569 struct iw_request_info *info,
4570 union iwreq_data *wrqu,
4571 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004572{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304573 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304575 hdd_context_t *pHddCtx = NULL;
4576
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304578 pHostapdAdapter = (netdev_priv(dev));
4579 if (NULL == pHostapdAdapter)
4580 {
4581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4582 "%s: Adapter is NULL",__func__);
4583 return -EINVAL;
4584 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304585 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4586 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304587 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304588 return status;
4589 }
4590
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304591 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 {
4593 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4594 {
4595 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4596
4597 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304598
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304600 {
4601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004602 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 VOS_ASSERT(0);
4604 }
4605 }
4606 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304607 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 }
4609 EXIT();
4610 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4611}
4612
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304613static int iw_softap_stopbss(struct net_device *dev,
4614 struct iw_request_info *info,
4615 union iwreq_data *wrqu,
4616 char *extra)
4617{
4618 int ret;
4619
4620 vos_ssr_protect(__func__);
4621 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4622 vos_ssr_unprotect(__func__);
4623
4624 return ret;
4625}
4626
4627static int __iw_softap_version(struct net_device *dev,
4628 struct iw_request_info *info,
4629 union iwreq_data *wrqu,
4630 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004631{
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304633 hdd_context_t *pHddCtx;
4634 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304635
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 pHostapdAdapter = (netdev_priv(dev));
4638 if (NULL == pHostapdAdapter)
4639 {
4640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4641 "%s: Adapter is NULL",__func__);
4642 return -EINVAL;
4643 }
4644 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4645 ret = wlan_hdd_validate_context(pHddCtx);
4646 if (0 != ret)
4647 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304648 return ret;
4649 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004650 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 return 0;
4653}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004654
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304655static int iw_softap_version(struct net_device *dev,
4656 struct iw_request_info *info,
4657 union iwreq_data *wrqu,
4658 char *extra)
4659{
4660 int ret;
4661
4662 vos_ssr_protect(__func__);
4663 ret = __iw_softap_version(dev, info, wrqu, extra);
4664 vos_ssr_unprotect(__func__);
4665
4666 return ret;
4667}
4668
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304669int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004670{
4671 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004672 int len = 0;
4673 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304674 v_CONTEXT_t pVosContext;
4675 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304676 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304677
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304678 ENTER();
4679
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304680 if (NULL == pAdapter)
4681 {
4682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4683 "%s: Adapter is NULL",__func__);
4684 return -EINVAL;
4685 }
4686 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4687 if (0 != wlan_hdd_validate_context(pHddCtx))
4688 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304689 return VOS_STATUS_E_FAULT;
4690 }
4691 pVosContext = pHddCtx->pvosContext;
4692 if (NULL == pVosContext)
4693 {
4694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4695 "%s: VOS context is not valid",__func__);
4696 return VOS_STATUS_E_FAULT;
4697 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304698 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304699 if(pSapCtx == NULL)
4700 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304701 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4702 FL("psapCtx is NULL"));
4703 return VOS_STATUS_E_FAULT;
4704 }
4705
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304706 len = snprintf(pBuf, buf_len, sta_info_header);
4707 if (len >= buf_len) {
4708 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4709 return -E2BIG;
4710 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004711 pBuf += len;
4712 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004713
4714 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4715 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304716 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004717 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004718 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304719 pSapCtx->aStaInfo[i].ucSTAId,
4720 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4721 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4722 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4723 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4724 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4725 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304726 if (len >= buf_len) {
4727 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4728 return -E2BIG;
4729 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004730 pBuf += len;
4731 buf_len -= len;
4732 }
4733 if(WE_GET_STA_INFO_SIZE > buf_len)
4734 {
4735 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004736 }
4737 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304738 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304739 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004740}
4741
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304742static int __iw_softap_get_sta_info(struct net_device *dev,
4743 struct iw_request_info *info,
4744 union iwreq_data *wrqu,
4745 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004746{
4747 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304748 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004749 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304750 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4751 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004752 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304753 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004754 }
4755 wrqu->data.length = strlen(extra);
4756 EXIT();
4757 return 0;
4758}
4759
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304760static int iw_softap_get_sta_info(struct net_device *dev,
4761 struct iw_request_info *info,
4762 union iwreq_data *wrqu,
4763 char *extra)
4764{
4765 int ret;
4766
4767 vos_ssr_protect(__func__);
4768 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4769 vos_ssr_unprotect(__func__);
4770
4771 return ret;
4772}
4773
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304774static int __iw_set_ap_genie(struct net_device *dev,
4775 struct iw_request_info *info,
4776 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004777{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304778
4779 hdd_adapter_t *pHostapdAdapter;
4780 hdd_context_t *pHddCtx;
4781 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004783 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304784 int ret = 0;
4785
Jeff Johnson295189b2012-06-20 16:38:30 -07004786 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304787 pHostapdAdapter = (netdev_priv(dev));
4788 if (NULL == pHostapdAdapter)
4789 {
4790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4791 "%s: Adapter is NULL",__func__);
4792 return -EINVAL;
4793 }
4794 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4795 ret = wlan_hdd_validate_context(pHddCtx);
4796 if (0 != ret)
4797 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304798 return ret;
4799 }
4800 pVosContext = pHddCtx->pvosContext;
4801 if (NULL == pVosContext)
4802 {
4803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4804 "%s: VOS Context is NULL",__func__);
4805 return -EINVAL;
4806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004807 if(!wrqu->data.length)
4808 {
4809 EXIT();
4810 return 0;
4811 }
Arif Hussained667642013-10-27 23:01:14 -07004812
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05304813 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
4814 {
4815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4816 "%s: WPARSN Ie input length is more than max[%d]", __func__,
4817 wrqu->data.length);
4818 return -EINVAL;
4819 }
4820
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304821 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304823 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 case DOT11F_EID_RSN:
4825 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4826 {
4827 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4828 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004831 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304833
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004835 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 halStatus = 0;
4837 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304840 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004841}
4842
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304843static int iw_set_ap_genie(struct net_device *dev,
4844 struct iw_request_info *info,
4845 union iwreq_data *wrqu, char *extra)
4846{
4847 int ret;
4848
4849 vos_ssr_protect(__func__);
4850 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4851 vos_ssr_unprotect(__func__);
4852
4853 return ret;
4854}
4855
Jeff Johnson295189b2012-06-20 16:38:30 -07004856static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4857{
4858 eHalStatus hstatus;
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304859 int ret;
4860 void *cookie;
4861 struct hdd_request *request;
4862 struct stats_class_a_ctx *priv;
4863 static const struct hdd_request_params params = {
4864 .priv_size = sizeof(*priv),
4865 .timeout_ms = WLAN_WAIT_TIME_STATS,
4866 };
4867
Jeff Johnson295189b2012-06-20 16:38:30 -07004868
4869 if (NULL == pAdapter)
4870 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304871 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004872 return VOS_STATUS_E_FAULT;
4873 }
4874
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304875 request = hdd_request_alloc(&params);
4876 if (!request) {
4877 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
4878 return VOS_STATUS_E_NOMEM;
4879 }
4880 cookie = hdd_request_cookie(request);
4881
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4883 eCSR_HDD,
4884 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304885 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 0, // not periodic
4887 FALSE, //non-cached results
4888 staid,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304889 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 if (eHAL_STATUS_SUCCESS != hstatus)
4891 {
4892 hddLog(VOS_TRACE_LEVEL_ERROR,
4893 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004894 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 }
4896 else
4897 {
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304898 ret = hdd_request_wait_for_response(request);
4899 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 {
4901 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304902 FL("SME timeout while retrieving link speed"));
4903 }
4904 else
4905 {
4906 priv = hdd_request_priv(request);
4907 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 }
4909 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004910
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304911 /*
4912 * either we never sent a request, we sent a request and received a
4913 * response or we sent a request and timed out. Regardless we are
4914 * done with the request.
4915 */
4916 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08004917
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 return VOS_STATUS_SUCCESS;
4919}
4920
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304921int __iw_get_softap_linkspeed(struct net_device *dev,
4922 struct iw_request_info *info,
4923 union iwreq_data *wrqu,
4924 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004925
4926{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304927 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304928 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004930 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304931 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304933 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08004935 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304936 int rc, valid;
4937
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304938 ENTER();
4939
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304940 pHostapdAdapter = (netdev_priv(dev));
4941 if (NULL == pHostapdAdapter)
4942 {
4943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4944 "%s: Adapter is NULL",__func__);
4945 return -EINVAL;
4946 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304947 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304948 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304949 if (0 != valid)
4950 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304951 return valid;
4952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004953
Arif Hussain6d2a3322013-11-17 19:50:10 -08004954 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08004955
4956 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07004957 {
Arif Hussaina9571842014-01-15 16:43:41 -08004958 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
4959 if (NULL == pmacAddress) {
4960 hddLog(LOG1, "unable to allocate memory");
4961 return -ENOMEM;
4962 }
4963 if (copy_from_user((void *)pmacAddress,
4964 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
4965 {
4966 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4967 kfree(pmacAddress);
4968 return -EFAULT;
4969 }
Manjeet Singha3739742016-05-03 16:21:46 +05304970 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08004971
4972 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07004973 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08004974
4975 if (!VOS_IS_STATUS_SUCCESS(status ))
4976 {
4977 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
4978 }
Arif Hussained667642013-10-27 23:01:14 -07004979 }
Kiet Lam61589852013-09-19 17:10:58 +05304980 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304981 * link speed for first connected client will be returned.
4982 */
Arif Hussaina9571842014-01-15 16:43:41 -08004983 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05304984 {
4985 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
4986 }
4987 else
4988 {
4989 status = hdd_softap_GetStaId(pHostapdAdapter,
4990 (v_MACADDR_t *)macAddress, (void *)(&staId));
4991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004992
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304993 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304995 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 link_speed = 0;
4997 }
4998 else
4999 {
5000 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305001
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 if (!VOS_IS_STATUS_SUCCESS(status ))
5003 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 return -EINVAL;
5006 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305007
5008 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
5009 staId, &link_speed);
5010
5011 link_speed = link_speed / 10;
5012
5013 if (0 == link_speed)
5014 {
5015 /* The linkspeed returned by HAL is in units of 500kbps.
5016 * converting it to mbps.
5017 * This is required to support legacy firmware which does
5018 * not return link capacity.
5019 */
5020 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
5021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 }
5023
5024 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07005025 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305026
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 if ((rc < 0) || (rc >= len))
5028 {
5029 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305030 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 return -EIO;
5032 }
5033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305034 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 return 0;
5036}
5037
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305038int iw_get_softap_linkspeed(struct net_device *dev,
5039 struct iw_request_info *info,
5040 union iwreq_data *wrqu,
5041 char *extra)
5042{
5043 int ret;
5044
5045 vos_ssr_protect(__func__);
5046 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
5047 vos_ssr_unprotect(__func__);
5048
5049 return ret;
5050}
5051
5052
Jeff Johnson295189b2012-06-20 16:38:30 -07005053static const iw_handler hostapd_handler[] =
5054{
5055 (iw_handler) NULL, /* SIOCSIWCOMMIT */
5056 (iw_handler) NULL, /* SIOCGIWNAME */
5057 (iw_handler) NULL, /* SIOCSIWNWID */
5058 (iw_handler) NULL, /* SIOCGIWNWID */
5059 (iw_handler) NULL, /* SIOCSIWFREQ */
5060 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
5061 (iw_handler) NULL, /* SIOCSIWMODE */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +05305062 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005063 (iw_handler) NULL, /* SIOCSIWSENS */
5064 (iw_handler) NULL, /* SIOCGIWSENS */
5065 (iw_handler) NULL, /* SIOCSIWRANGE */
5066 (iw_handler) NULL, /* SIOCGIWRANGE */
5067 (iw_handler) NULL, /* SIOCSIWPRIV */
5068 (iw_handler) NULL, /* SIOCGIWPRIV */
5069 (iw_handler) NULL, /* SIOCSIWSTATS */
5070 (iw_handler) NULL, /* SIOCGIWSTATS */
5071 (iw_handler) NULL, /* SIOCSIWSPY */
5072 (iw_handler) NULL, /* SIOCGIWSPY */
5073 (iw_handler) NULL, /* SIOCSIWTHRSPY */
5074 (iw_handler) NULL, /* SIOCGIWTHRSPY */
5075 (iw_handler) NULL, /* SIOCSIWAP */
5076 (iw_handler) NULL, /* SIOCGIWAP */
5077 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
5078 (iw_handler) NULL, /* SIOCGIWAPLIST */
5079 (iw_handler) NULL, /* SIOCSIWSCAN */
5080 (iw_handler) NULL, /* SIOCGIWSCAN */
5081 (iw_handler) NULL, /* SIOCSIWESSID */
5082 (iw_handler) NULL, /* SIOCGIWESSID */
5083 (iw_handler) NULL, /* SIOCSIWNICKN */
5084 (iw_handler) NULL, /* SIOCGIWNICKN */
5085 (iw_handler) NULL, /* -- hole -- */
5086 (iw_handler) NULL, /* -- hole -- */
5087 (iw_handler) NULL, /* SIOCSIWRATE */
5088 (iw_handler) NULL, /* SIOCGIWRATE */
5089 (iw_handler) NULL, /* SIOCSIWRTS */
5090 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
5091 (iw_handler) NULL, /* SIOCSIWFRAG */
5092 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
5093 (iw_handler) NULL, /* SIOCSIWTXPOW */
5094 (iw_handler) NULL, /* SIOCGIWTXPOW */
5095 (iw_handler) NULL, /* SIOCSIWRETRY */
5096 (iw_handler) NULL, /* SIOCGIWRETRY */
5097 (iw_handler) NULL, /* SIOCSIWENCODE */
5098 (iw_handler) NULL, /* SIOCGIWENCODE */
5099 (iw_handler) NULL, /* SIOCSIWPOWER */
5100 (iw_handler) NULL, /* SIOCGIWPOWER */
5101 (iw_handler) NULL, /* -- hole -- */
5102 (iw_handler) NULL, /* -- hole -- */
5103 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
5104 (iw_handler) NULL, /* SIOCGIWGENIE */
5105 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
5106 (iw_handler) NULL, /* SIOCGIWAUTH */
5107 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
5108 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
5109 (iw_handler) NULL, /* SIOCSIWPMKSA */
5110};
5111
Jeff Johnson224f3702014-03-26 11:09:47 -07005112/*
5113 * Note that the following ioctls were defined with semantics which
5114 * cannot be handled by the "iwpriv" userspace application and hence
5115 * they are not included in the hostapd_private_args array
5116 * QCSAP_IOCTL_ASSOC_STA_MACADDR
5117 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005118
5119static const struct iw_priv_args hostapd_private_args[] = {
5120 { QCSAP_IOCTL_SETPARAM,
5121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
5122 { QCSAP_IOCTL_SETPARAM,
5123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05305124 { QCSAP_PARAM_GET_FRAME_LOGS,
5125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 { QCSAP_PARAM_MAX_ASSOC,
5127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
5128 { QCSAP_PARAM_HIDE_SSID,
5129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07005130 { QCSAP_PARAM_SET_MC_RATE,
5131 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05305132 { QCSAP_PARAM_SET_PROXIMITY,
5133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305134 { QCSAP_PARAM_CAP_TSF,
5135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Abhishek Singh02605092017-10-25 14:06:12 +05305136 {QCSAP_PARAM_SET_CHANNEL_CHANGE,
5137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"},
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305138 { QCSAP_PARAM_SET_WOWL,
5139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 { QCSAP_IOCTL_GETPARAM,
5141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5142 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
5143 { QCSAP_IOCTL_GETPARAM, 0,
5144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
5145 { QCSAP_PARAM_MAX_ASSOC, 0,
5146 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07005147 { QCSAP_PARAM_GET_WLAN_DBG, 0,
5148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
5149 { QCSAP_PARAM_AUTO_CHANNEL, 0,
5150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05305151 { QCSAP_PARAM_SET_AUTO_CHANNEL,
5152 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 { QCSAP_PARAM_CLR_ACL, 0,
5154 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
5155 { QCSAP_PARAM_ACL_MODE,
5156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05305158 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 { QCSAP_IOCTL_STOPBSS,
5160 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
5161 { QCSAP_IOCTL_VERSION, 0,
5162 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005163 { QCSAP_IOCTL_GET_STA_INFO, 0,
5164 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08005166 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07005168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07005169 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05305171 { QCSAP_IOCTL_AP_STATS, 0,
5172 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305173 /* handlers for main ioctl */
5174 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
5175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
5176#ifdef WLAN_FEATURE_TSF
5177 { QCSAP_IOCTL_GET_TSF, 0,
5178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5179 "get_tsf" },
5180#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05305181 { QCSAP_IOCTL_GET_STATS, 0,
5182 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
5183 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
5185 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305186 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005187
5188 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
5189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
5190 /* handlers for sub-ioctl */
5191 { WE_SET_WLAN_DBG,
5192 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5193 0,
5194 "setwlandbg" },
5195
5196 /* handlers for main ioctl */
5197 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
5198 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5199 0,
5200 "" },
5201
5202 /* handlers for sub-ioctl */
5203 { WE_LOG_DUMP_CMD,
5204 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5205 0,
5206 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 { WE_P2P_NOA_CMD,
5208 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5209 0,
5210 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005211 /* handlers for sub ioctl */
5212 {
5213 WE_MCC_CONFIG_CREDENTIAL,
5214 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5215 0,
5216 "setMccCrdnl" },
5217
5218 /* handlers for sub ioctl */
5219 {
5220 WE_MCC_CONFIG_PARAMS,
5221 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5222 0,
5223 "setMccConfig" },
5224
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 /* handlers for main ioctl */
5226 { QCSAP_IOCTL_MODIFY_ACL,
5227 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
5228 0,
5229 "modify_acl" },
5230
5231 /* handlers for main ioctl */
5232 { QCSAP_IOCTL_GET_CHANNEL_LIST,
5233 0,
5234 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
5235 "getChannelList" },
5236
Jeff Johnsone7245742012-09-05 17:12:55 -07005237 /* handlers for main ioctl */
5238 { QCSAP_IOCTL_SET_TX_POWER,
5239 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5240 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05305241 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07005242
5243 /* handlers for main ioctl */
5244 { QCSAP_IOCTL_SET_MAX_TX_POWER,
5245 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5246 0,
5247 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05305248
5249 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
5250 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
5251 0,
5252 "dataSnapshot" },
5253
5254 /* handlers for main ioctl */
5255 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
5256 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5257 0,
5258 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305259 /* handlers for main ioctl */
5260 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
5261 IW_PRIV_TYPE_CHAR| 512,
5262 0,
5263 "" },
5264
5265 /* handlers for sub-ioctl */
5266 { WE_WOWL_ADD_PTRN,
5267 IW_PRIV_TYPE_CHAR| 512,
5268 0,
5269 "wowlAddPtrn" },
5270
5271 { WE_WOWL_DEL_PTRN,
5272 IW_PRIV_TYPE_CHAR| 512,
5273 0,
5274 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005275};
Jeff Johnsone7245742012-09-05 17:12:55 -07005276
Jeff Johnson295189b2012-06-20 16:38:30 -07005277static const iw_handler hostapd_private[] = {
5278 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305279 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
5280 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
5281 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
5284 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
5285 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
5286 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
5287 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
5288 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
5289 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05305290 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305291 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
5293 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
5294 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
5295 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005296 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07005297 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
5298 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07005299 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305300 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05305301 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05305302 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
5303 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07005304};
5305const struct iw_handler_def hostapd_handler_def = {
5306 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
5307 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
5308 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
5309 .standard = (iw_handler *)hostapd_handler,
5310 .private = (iw_handler *)hostapd_private,
5311 .private_args = hostapd_private_args,
5312 .get_wireless_stats = NULL,
5313};
5314#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5315struct net_device_ops net_ops_struct = {
5316 .ndo_open = hdd_hostapd_open,
5317 .ndo_stop = hdd_hostapd_stop,
5318 .ndo_uninit = hdd_hostapd_uninit,
5319 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5320 .ndo_tx_timeout = hdd_softap_tx_timeout,
5321 .ndo_get_stats = hdd_softap_stats,
5322 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5323 .ndo_do_ioctl = hdd_hostapd_ioctl,
5324 .ndo_change_mtu = hdd_hostapd_change_mtu,
5325 .ndo_select_queue = hdd_hostapd_select_queue,
5326 };
5327#endif
5328
5329int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5330{
5331 return VOS_STATUS_SUCCESS;
5332}
5333
5334void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5335{
5336#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5337 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5338#else
5339 pWlanHostapdDev->open = hdd_hostapd_open;
5340 pWlanHostapdDev->stop = hdd_hostapd_stop;
5341 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5342 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5343 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5344 pWlanHostapdDev->get_stats = hdd_softap_stats;
5345 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5346 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5347#endif
5348}
5349
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305350VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305351{
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05305353#ifdef DHCP_SERVER_OFFLOAD
5354 hdd_dhcp_state_t *dhcp_status;
5355#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305356#ifdef MDNS_OFFLOAD
5357 hdd_mdns_state_t *mdns_status;
5358#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005360 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305362 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005363#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005364 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5365 v_U16_t unsafeChannelCount;
5366#endif /* FEATURE_WLAN_CH_AVOID */
5367
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305368 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5370 "%s:LOGP in Progress. Ignore!!!",__func__);
5371 status = VOS_STATUS_E_FAILURE;
5372 }
5373
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305375
5376#ifdef SAP_AUTH_OFFLOAD
5377 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305378 {
5379 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5380 {
5381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5382 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5383 return VOS_STATUS_E_FAILURE;
5384 }
5385 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305386#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305387
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305388 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305390#ifdef DHCP_SERVER_OFFLOAD
5391 dhcp_status = &pAdapter->dhcp_status;
5392#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305393#ifdef MDNS_OFFLOAD
5394 mdns_status = &pAdapter->mdns_status;
5395#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305396
Nirav Shah7e3c8132015-06-22 23:51:42 +05305397 spin_lock_init(&pAdapter->sta_hash_lock);
5398 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5399
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005400 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5401
Leo Chang0b0e45a2013-12-15 15:18:55 -08005402#ifdef FEATURE_WLAN_CH_AVOID
5403 /* Get unsafe cahnnel list from cached location */
5404 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5405 sizeof(unsafeChannelList),
5406 &unsafeChannelCount);
5407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5408 "%s : Unsafe Channel count %d",
5409 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305410 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005411 unsafeChannelList,
5412 unsafeChannelCount);
5413#endif /* FEATURE_WLAN_CH_AVOID */
5414
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 // Zero the memory. This zeros the profile structure.
5416 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305417#ifdef DHCP_SERVER_OFFLOAD
5418 memset(dhcp_status, 0,sizeof(*dhcp_status));
5419#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305420#ifdef MDNS_OFFLOAD
5421 memset(mdns_status, 0,sizeof(*mdns_status));
5422#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305423
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 // Set up the pointer to the Wireless Extensions state structure
5425 // NOP
5426 status = hdd_set_hostapd(pAdapter);
5427 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 return status;
5430 }
5431
5432 status = vos_event_init(&phostapdBuf->vosEvent);
5433 if (!VOS_IS_STATUS_SUCCESS(status))
5434 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 return status;
5437 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305438#ifdef DHCP_SERVER_OFFLOAD
5439 status = vos_event_init(&dhcp_status->vos_event);
5440 if (!VOS_IS_STATUS_SUCCESS(status)) {
5441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5442 return status;
5443 }
5444#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305445#ifdef MDNS_OFFLOAD
5446 status = vos_event_init(&mdns_status->vos_event);
5447 if (!VOS_IS_STATUS_SUCCESS(status)) {
5448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5449 ("Hostapd HDD vos event init failed!!"));
5450 return status;
5451 }
5452#endif /* MDNS_OFFLOAD */
5453
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5455
5456 // Register as a wireless device
5457 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5458
5459 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305460 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if ( !VOS_IS_STATUS_SUCCESS( status ))
5462 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005463 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305465
5466 status = hdd_wmm_adapter_init( pAdapter );
5467 if (!VOS_IS_STATUS_SUCCESS(status))
5468 {
5469 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005470 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305471 status, status );
5472 goto error_wmm_init;
5473 }
5474
5475 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5476
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305477 ini_cfg = pHddCtx->cfg_ini;
5478 if (re_init && ini_cfg) {
5479 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5480 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5481 ini_cfg->apOperatingBand);
5482 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5483 ini_cfg->apStartChannelNum,
5484 ini_cfg->apEndChannelNum,
5485 ini_cfg->apOperatingBand);
5486 }
5487
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305488 return status;
5489
5490error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305491 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 EXIT();
5493 return status;
5494}
5495
5496hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5497{
5498 struct net_device *pWlanHostapdDev = NULL;
5499 hdd_adapter_t *pHostapdAdapter = NULL;
5500 v_CONTEXT_t pVosContext= NULL;
5501
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305502 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5503#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5504 NET_NAME_UNKNOWN,
5505#endif
5506 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 if (pWlanHostapdDev != NULL)
5508 {
5509 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5510
5511 //Init the net_device structure
5512 ether_setup(pWlanHostapdDev);
5513
5514 //Initialize the adapter context to zeros.
5515 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5516 pHostapdAdapter->dev = pWlanHostapdDev;
5517 pHostapdAdapter->pHddCtx = pHddCtx;
5518 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5519
5520 //Get the Global VOSS context.
5521 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5522 //Save the adapter context in global context for future.
5523 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5524
5525 //Init the net_device structure
5526 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5527
5528 hdd_set_ap_ops( pHostapdAdapter->dev );
5529
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5531 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5532
5533 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5534 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5535
5536 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5538 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5539 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5542 }
5543 return pHostapdAdapter;
5544}
5545
5546VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5547{
5548 struct net_device *dev = pAdapter->dev;
5549 VOS_STATUS status = VOS_STATUS_SUCCESS;
5550
5551 ENTER();
5552
5553 if( rtnl_lock_held )
5554 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005555 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 if( dev_alloc_name(dev, dev->name) < 0 )
5557 {
5558 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5559 return VOS_STATUS_E_FAILURE;
5560 }
5561 }
5562 if (register_netdevice(dev))
5563 {
5564 hddLog(VOS_TRACE_LEVEL_FATAL,
5565 "%s:Failed:register_netdevice", __func__);
5566 return VOS_STATUS_E_FAILURE;
5567 }
5568 }
5569 else
5570 {
5571 if (register_netdev(dev))
5572 {
5573 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5574 return VOS_STATUS_E_FAILURE;
5575 }
5576 }
5577 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5578
5579 EXIT();
5580 return status;
5581}
5582
c_hpothu002231a2015-02-05 14:58:51 +05305583VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005584{
5585 ENTER();
5586
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305587 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005588
5589 /* if we are being called during driver unload, then the dev has already
5590 been invalidated. if we are being called at other times, then we can
5591 detatch the wireless device handlers */
5592 if (pAdapter->dev)
5593 {
c_hpothu002231a2015-02-05 14:58:51 +05305594 if (TRUE == rtnl_held)
5595 {
5596 pAdapter->dev->wireless_handlers = NULL;
5597 }
5598 else
5599 {
5600 rtnl_lock();
5601 pAdapter->dev->wireless_handlers = NULL;
5602 rtnl_unlock();
5603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 }
5605 EXIT();
5606 return 0;
5607}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305608
5609/**
5610 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5611 * to supplicant, if there any clients connected to SAP interface.
5612 * @adapter: sap adapter context
5613 *
5614 * Return: nothing
5615 */
5616void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5617{
5618 tSap_Event sap_event;
5619 int staId;
5620 hdd_context_t *hdd_ctx;
5621 v_CONTEXT_t vos_ctx;
5622 ptSapContext sap_ctx;
5623
5624 ENTER();
5625
5626 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305627 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5628 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5629 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305630 return;
5631 }
5632
5633 vos_ctx = hdd_ctx->pvosContext;
5634 if (NULL == vos_ctx) {
5635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5636 "%s: VOS context is not valid",__func__);
5637 return;
5638 }
5639
5640 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5641 if (!sap_ctx) {
5642 hddLog(LOGE, FL("invalid sap context"));
5643 return;
5644 }
5645
5646 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5647 if (sap_ctx->aStaInfo[staId].isUsed) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07005648 hddLog(LOG1, FL("staId: %d isUsed: %d %pK"),
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305649 staId, sap_ctx->aStaInfo[staId].isUsed,
5650 sap_ctx);
5651
5652 if (vos_is_macaddr_broadcast(
5653 &sap_ctx->aStaInfo[staId].macAddrSTA))
5654 continue;
5655
5656 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5657 vos_mem_copy(
5658 &sap_event.sapevt.
5659 sapStationDisassocCompleteEvent.staMac,
5660 &sap_ctx->aStaInfo[staId].macAddrSTA,
5661 sizeof(v_MACADDR_t));
5662 sap_event.sapevt.sapStationDisassocCompleteEvent.
5663 reason =
5664 eSAP_MAC_INITATED_DISASSOC;
5665 sap_event.sapevt.sapStationDisassocCompleteEvent.
5666 statusCode =
5667 eSIR_SME_RESOURCES_UNAVAILABLE;
5668 hdd_hostapd_SAPEventCB(&sap_event,
5669 sap_ctx->pUsrContext);
5670 }
5671 }
5672
5673 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5674
5675 EXIT();
5676}
5677
5678/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305679 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305680 * @adapter: sap adapter context
5681 *
5682 * Return: nothing
5683 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305684void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305685{
5686 hdd_context_t *hdd_ctx;
5687 v_CONTEXT_t vos_ctx;
5688 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305689 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305690
5691 ENTER();
5692
5693 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305694 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5696 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305697 return;
5698 }
5699
5700 vos_ctx = hdd_ctx->pvosContext;
5701 if (NULL == vos_ctx) {
5702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5703 "%s: VOS context is not valid",__func__);
5704 return;
5705 }
5706
5707 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5708 if (!sap_ctx) {
5709 hddLog(LOGE, FL("invalid sap context"));
5710 return;
5711 }
5712
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305713 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5714 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5715 if (!VOS_IS_STATUS_SUCCESS(status))
5716 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5717 FL("Failed to Stop HT20/40 timer"));
5718 }
5719
5720 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5721 if (!VOS_IS_STATUS_SUCCESS(status))
5722 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5723 FL("Failed to Destroy HT20/40 timer"));
5724
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305725}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305726
5727/**
5728 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5729 * @adapter: hdd ap adapter
5730 *
5731 * hdd_force_scc_restart_sap will choose station channel and will
5732 * schedule work to restart the sap.
5733 *
5734 * Return - none
5735 */
5736void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5737 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5738{
5739 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5740 return;
5741 }
5742
5743 hddLog(LOG1, FL("Current operation channel %d"),
5744 adapter->sessionCtx.ap.operatingChannel);
5745 hddLog(LOG1, FL("STA channel is %d"),
5746 channelId);
5747
5748 vos_flush_work(
5749 &hdd_ctx->sap_start_work);
5750
5751 hddLog(LOGE,
5752 FL("Restarting SAP for force SCC "));
5753
5754 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5755
5756 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5757 netif_tx_disable(adapter->dev);
5758 schedule_work(&hdd_ctx->sap_start_work);
5759 } else {
5760 hdd_hostapd_stop(adapter->dev);
5761 }
5762 return;
5763}
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05305764
5765/**
5766 * hdd_get_cache_stainfo() - get stainfo for the specified peer
5767 * @stainfo: array of station info
5768 * @mac_addr: mac address of requested peer
5769 *
5770 * This function find the stainfo for the peer with mac_addr
5771 *
5772 * Return: stainfo if found, NULL if not found
5773 */
5774struct hdd_cache_sta_info *hdd_get_cache_stainfo(
5775 struct hdd_cache_sta_info *astainfo,
5776 u8 *mac_addr)
5777{
5778 struct hdd_cache_sta_info *stainfo = NULL;
5779 int i;
5780
5781 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
5782 if (vos_mem_compare(&astainfo[i].macAddrSTA,
5783 mac_addr,
5784 HDD_MAC_ADDR_LEN)) {
5785 stainfo = &astainfo[i];
5786 break;
5787 }
5788 }
5789
5790 return stainfo;
5791}
5792