blob: 29daf50a80cf6fac28448152c73c4dfdb3e999f7 [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{
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530224 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
225 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
226 int ret;
227
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 ENTER();
229
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530230 ret = wlan_hdd_validate_context(hdd_ctx);
231 if (0 != ret)
232 return ret;
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530233
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530234 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
235
236 //Stop all tx queues
237 netif_tx_disable(dev);
238
239 //Turn OFF carrier state
240 netif_carrier_off(dev);
241
242 if (!hdd_is_cli_iface_up(hdd_ctx))
243 sme_ScanFlushResult(hdd_ctx->hHal, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244
245 EXIT();
246 return 0;
247}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530248
249int hdd_hostapd_stop (struct net_device *dev)
250{
251 int ret;
252
253 vos_ssr_protect(__func__);
254 ret = __hdd_hostapd_stop(dev);
255 vos_ssr_unprotect(__func__);
256
257 return ret;
258}
259
Jeff Johnson295189b2012-06-20 16:38:30 -0700260/**---------------------------------------------------------------------------
261
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530262 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264 This is called during the netdev unregister to uninitialize all data
265associated with the device
266
267 \param - dev Pointer to net_device structure
268
269 \return - void
270
271 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530272static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700273{
274 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530275 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
277 ENTER();
278
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530279 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530281 hddLog(VOS_TRACE_LEVEL_ERROR,
282 FL("Invalid magic"));
283 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530285 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
286 if (NULL == pHddCtx)
287 {
288 hddLog(VOS_TRACE_LEVEL_ERROR,
289 FL("NULL pHddCtx"));
290 return;
291 }
292
293 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
294
295 /* after uninit our adapter structure will no longer be valid */
296 pHostapdAdapter->dev = NULL;
297 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700298
299 EXIT();
300}
301
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530302static void hdd_hostapd_uninit (struct net_device *dev)
303{
304 vos_ssr_protect(__func__);
305 __hdd_hostapd_uninit(dev);
306 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700307
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530308 return;
309}
Jeff Johnson295189b2012-06-20 16:38:30 -0700310/**============================================================================
311 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
312 transmitting packets. There are 2 versions of this function. One that uses
313 locked queue and other that uses lockless queues. Both have been retained to
314 do some performance testing
315 @param skb : [in] pointer to OS packet (sk_buff)
316 @param dev : [in] pointer to Libra network device
317
318 @return : NET_XMIT_DROP if packets are dropped
319 : NET_XMIT_SUCCESS if packet is enqueued succesfully
320 ===========================================================================*/
321int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
322{
323 return 0;
324}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530325
326int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700327{
328 return 0;
329}
330
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530331int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
332{
333 int ret;
334 vos_ssr_protect(__func__);
335 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
336 vos_ssr_unprotect(__func__);
337
338 return ret;
339}
340
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700341static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
342 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700343{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700344 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530345 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
346 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700347 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530348 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700349 /*
350 * Note that valid pointers are provided by caller
351 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530353 ENTER();
354
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700355 if (priv_data->total_len <= 0 ||
356 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
357 {
358 /* below we allocate one more byte for command buffer.
359 * To avoid addition overflow total_len should be
360 * smaller than INT_MAX. */
361 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
362 __func__, priv_data->total_len);
363 ret = -EFAULT;
364 goto exit;
365 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530366 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530367 if (0 != status)
368 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530369 return status;
370 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700371
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700372 /* Allocate +1 for '\0' */
373 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
374 if (!command)
375 {
376 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
377 ret = -ENOMEM;
378 goto exit;
379 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700380
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700381 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
382 {
383 ret = -EFAULT;
384 goto exit;
385 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800386
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700387 /* Make sure the command is NUL-terminated */
388 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700390 hddLog(VOS_TRACE_LEVEL_INFO,
391 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700392
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700393 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
394 {
395 hdd_setP2pNoa(pAdapter->dev, command);
396 }
397 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
398 {
399 hdd_setP2pOpps(pAdapter->dev, command);
400 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800401#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700402 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
403 {
404 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
405 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800406#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700407 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
408 {
409 /*
410 * command should be a string having format
411 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
412 */
413 hddLog(VOS_TRACE_LEVEL_INFO,
414 "%s: Received Command to Set Preferred Channels for SAP",
415 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800416
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700417 ret = sapSetPreferredChannel(command);
418 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530419 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
420 {
421 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
422 tANI_U8 filterType = 0;
423 tANI_U8 *value;
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530424
425 ret = hdd_drv_cmd_validate(command, 8);
426 if (ret)
427 goto exit;
428
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530429 value = command + 9;
430
431 /* Convert the value from ascii to integer */
432 ret = kstrtou8(value, 10, &filterType);
433 if (ret < 0)
434 {
435 /* If the input value is greater than max value of datatype,
436 * then also kstrtou8 fails
437 */
438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
439 "%s: kstrtou8 failed range ", __func__);
440 ret = -EINVAL;
441 goto exit;
442 }
443 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
444 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
445 {
446 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
447 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
448 " 2-Sink ", __func__);
449 ret = -EINVAL;
450 goto exit;
451 }
452 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
453 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530454 pScanInfo = &pHddCtx->scan_info;
455 if (filterType && pScanInfo != NULL &&
456 pHddCtx->scan_info.mScanPending)
457 {
458 /*Miracast Session started. Abort Scan */
459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
460 "%s, Aborting Scan For Miracast",__func__);
461 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
462 eCSR_SCAN_ABORT_DEFAULT);
463 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530464 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
465 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
466 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530467 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
468 {
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530469 ret = hdd_drv_cmd_validate(command, 16);
470 if (ret)
471 goto exit;
472
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530473 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
474 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700475
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530476 /*
477 * command should be a string having format
478 * SET_DISABLE_CHANNEL_LIST <num of channels>
479 * <channels separated by spaces>
480 */
481 else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) {
482 tANI_U8 *ptr = command;
483
484 ret = hdd_drv_cmd_validate(command, 24);
485 if (ret)
486 goto exit;
487
488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
489 " Received Command to disable Channels for in %s",
490 __func__);
491 ret = hdd_parse_disable_chan_cmd(pAdapter, ptr);
492 }
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530493 else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) {
494 char extra[128] = {0};
495 int len;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530496
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
498 " Received Command to get disable Channels list %s",
499 __func__);
500
501 len = hdd_get_disable_ch_list(pHddCtx, extra, sizeof(extra));
502 if (len == 0) {
503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
504 FL("disable channel list are not yet programed"));
505 ret = -EINVAL;
506 goto exit;
507 }
508
509 len = VOS_MIN(priv_data->total_len, len + 1);
510 if (copy_to_user(priv_data->buf, &extra, len)) {
511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
512 "%s: failed to copy data to user buffer", __func__);
513 ret = -EFAULT;
514 goto exit;
515 }
516
517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
518 FL("data:%s"), extra);
519 }
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530520 else {
521 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
522 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
523 pAdapter->sessionId, 0));
524 hddLog(VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"),
525 command);
526 }
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528exit:
529 if (command)
530 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700531 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530533 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 return ret;
535}
536
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700537#ifdef CONFIG_COMPAT
538static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
539 struct ifreq *ifr)
540{
541 struct {
542 compat_uptr_t buf;
543 int used_len;
544 int total_len;
545 } compat_priv_data;
546 hdd_priv_data_t priv_data;
547 int ret = 0;
548
549 /*
550 * Note that pAdapter and ifr have already been verified by caller,
551 * and HDD context has also been validated
552 */
553 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
554 sizeof(compat_priv_data))) {
555 ret = -EFAULT;
556 goto exit;
557 }
558 priv_data.buf = compat_ptr(compat_priv_data.buf);
559 priv_data.used_len = compat_priv_data.used_len;
560 priv_data.total_len = compat_priv_data.total_len;
561 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
562 exit:
563 return ret;
564}
565#else /* CONFIG_COMPAT */
566static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
567 struct ifreq *ifr)
568{
569 /* will never be invoked */
570 return 0;
571}
572#endif /* CONFIG_COMPAT */
573
574static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
575{
576 hdd_priv_data_t priv_data;
577 int ret = 0;
578
579 /*
580 * Note that pAdapter and ifr have already been verified by caller,
581 * and HDD context has also been validated
582 */
583 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
584 ret = -EFAULT;
585 } else {
586 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
587 }
588 return ret;
589}
590
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530591static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700592 struct ifreq *ifr, int cmd)
593{
594 hdd_adapter_t *pAdapter;
595 hdd_context_t *pHddCtx;
596 int ret;
597
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530598 ENTER();
599
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700600 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
601 if (NULL == pAdapter) {
602 hddLog(VOS_TRACE_LEVEL_ERROR,
603 "%s: HDD adapter context is Null", __func__);
604 ret = -ENODEV;
605 goto exit;
606 }
607 if (dev != pAdapter->dev) {
608 hddLog(VOS_TRACE_LEVEL_ERROR,
609 "%s: HDD adapter/dev inconsistency", __func__);
610 ret = -ENODEV;
611 goto exit;
612 }
613
614 if ((!ifr) || (!ifr->ifr_data)) {
615 ret = -EINVAL;
616 goto exit;
617 }
618
619 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
620 ret = wlan_hdd_validate_context(pHddCtx);
621 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700622 ret = -EBUSY;
623 goto exit;
624 }
625
626 switch (cmd) {
627 case (SIOCDEVPRIVATE + 1):
628 if (is_compat_task())
629 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
630 else
631 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
632 break;
633 default:
634 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
635 __func__, cmd);
636 ret = -EINVAL;
637 break;
638 }
639 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530640 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700641 return ret;
642}
643
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530644static int hdd_hostapd_ioctl(struct net_device *dev,
645 struct ifreq *ifr, int cmd)
646{
647 int ret;
648
649 vos_ssr_protect(__func__);
650 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
651 vos_ssr_unprotect(__func__);
652
653 return ret;
654}
655
Jeff Johnson295189b2012-06-20 16:38:30 -0700656/**---------------------------------------------------------------------------
657
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530658 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 This function sets the user specified mac address using
660 the command ifconfig wlanX hw ether <mac adress>.
661
662 \param - dev - Pointer to the net device.
663 - addr - Pointer to the sockaddr.
664 \return - 0 for success, non zero for failure
665
666 --------------------------------------------------------------------------*/
667
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530668static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700669{
670 struct sockaddr *psta_mac_addr = addr;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530671 hdd_adapter_t *pAdapter;
672 hdd_context_t *pHddCtx;
673 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530674
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530676 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
677 if (NULL == pAdapter)
678 {
679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
680 "%s: Adapter is NULL",__func__);
681 return -EINVAL;
682 }
683 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
684 ret = wlan_hdd_validate_context(pHddCtx);
685 if (0 != ret)
686 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530687 return ret;
688 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
690 EXIT();
691 return 0;
692}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530693
694static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
695{
696 int ret;
697
698 vos_ssr_protect(__func__);
699 ret = __hdd_hostapd_set_mac_address(dev, addr);
700 vos_ssr_unprotect(__func__);
701
702 return ret;
703}
704
Jeff Johnson295189b2012-06-20 16:38:30 -0700705void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
706{
707 struct net_device *dev = (struct net_device *)usrDataForCallback;
708 v_BYTE_t we_custom_event[64];
709 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530711 hdd_context_t *pHddCtx;
712#ifdef DISABLE_CONCURRENCY_AUTOSAVE
713 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 hdd_ap_ctx_t *pHddApCtx;
715#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
716
717 /* event_name space-delimiter driver_module_name */
718 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
719 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
720 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
721
722 ENTER();
723
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530724 pHostapdAdapter = netdev_priv(dev);
725 if ((NULL == pHostapdAdapter) ||
726 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
727 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700728 hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530729 return;
730 }
731 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
732 if (0 != (wlan_hdd_validate_context(pHddCtx)))
733 {
734 return;
735 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530736#ifdef DISABLE_CONCURRENCY_AUTOSAVE
737 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530738 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 /*
740 This timer routine is going to be called only when AP
741 persona is up.
742 If there are concurrent sessions running we do not want
743 to shut down the Bss.Instead we run the timer again so
744 that if Autosave is enabled next time and other session
745 was down only then we bring down AP
746 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
748 vos_status = vos_timer_start(
749 &pHddApCtx->hdd_ap_inactivity_timer,
750 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
751 * 1000);
752 if (!VOS_IS_STATUS_SUCCESS(vos_status))
753 {
754 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
755 }
756 EXIT();
757 return;
758 }
759#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
760 memset(&we_custom_event, '\0', sizeof(we_custom_event));
761 memcpy(&we_custom_event, autoShutEvent, event_len);
762
763 memset(&wrqu, 0, sizeof(wrqu));
764 wrqu.data.length = event_len;
765
766 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
767 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
768
769 EXIT();
770}
771
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800772VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
773{
774 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
775 ptSapContext pSapCtx = NULL;
776 eHalStatus halStatus = eHAL_STATUS_FAILURE;
777 v_PVOID_t hHal = NULL;
778
779 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
780 "%s: UPDATE Beacon Params", __func__);
781
782 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
783 pSapCtx = VOS_GET_SAP_CB(pVosContext);
784 if ( NULL == pSapCtx )
785 {
786 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
787 "%s: Invalid SAP pointer from pvosGCtx", __func__);
788 return VOS_STATUS_E_FAULT;
789 }
790
791 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
792 if ( NULL == hHal ){
793 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
794 "%s: Invalid HAL pointer from pvosGCtx", __func__);
795 return VOS_STATUS_E_FAULT;
796 }
797 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
798 if(halStatus == eHAL_STATUS_FAILURE ){
799 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
800 "%s: Failed to update Beacon Params", __func__);
801 return VOS_STATUS_E_FAILURE;
802 }
803 }
804 return VOS_STATUS_SUCCESS;
805}
806
807void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
808{
809 v_U8_t staId = 0;
810 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530811 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
812 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800813
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530814 dev = (struct net_device *)usrDataForCallback;
815 pSapCtx = VOS_GET_SAP_CB(pVosContext);
816 if(pSapCtx == NULL){
817 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
818 FL("psapCtx is NULL"));
819 return;
820 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800821 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800822 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
823 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530824 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800825 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
826 {
827 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530828 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800829 }
830 }
831}
832
Agarwal Ashish8e538932014-12-24 18:12:52 +0530833static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800834{
835 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530836 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800837 VOS_STATUS status = VOS_STATUS_SUCCESS;
838 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530839
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800840 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530841
842 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
843 status = wlan_hdd_validate_context(pHddCtx);
844
845 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530846 return status;
847 }
848
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800849 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
850 {
851 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
852 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800854 }
855 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530856 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800857 }
858 EXIT();
859 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
860}
Jeff Johnson295189b2012-06-20 16:38:30 -0700861
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530862#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530863bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530864 bool enabled)
865{
866 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530867 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530868
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530869 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530870 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
871
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530872 sap_offload_info.sap_auth_offload_enable = enabled;
873 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530874 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530875 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530876 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
877
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530878 if (sap_offload_info.sap_auth_offload_enable &&
879 sap_offload_info.sap_auth_offload_sec_type)
880 {
881 if (sap_offload_info.key_len < 8 ||
882 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
883 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530884 hddLog(VOS_TRACE_LEVEL_ERROR,
885 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530886 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530887 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530888 }
889 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530890 if (sap_offload_info.key_len)
891 {
892 vos_mem_copy(sap_offload_info.key,
893 pHddCtx->cfg_ini->sap_auth_offload_key,
894 sap_offload_info.key_len);
895 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530896 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530897 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
898 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530899 hddLog(VOS_TRACE_LEVEL_ERROR,
900 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530901 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530902 }
903
904 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
905 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530906 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530907}
908#endif
909
Abhishek Singhe8ebb922017-11-01 13:30:26 +0530910/**
911* wlansap_get_phymode() - get SAP phymode.
912* @pctx: Pointer to the global vos context; a handle to SAP's control block
913* can be extracted from its context. When MBSSID feature is enabled,
914* SAP context is directly passed to SAP APIs.
915*
916* This function provides current phymode of SAP interface.
917*
918* Return: phymode with eCsrPhyMode type.
919*/
920static eCsrPhyMode
921wlansap_get_phymode(v_PVOID_t pctx)
922{
923 ptSapContext psapctx = VOS_GET_SAP_CB(pctx);
924
925 if (!psapctx) {
926 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
927 "%s: Invalid SAP pointer from pCtx", __func__);
928 return eCSR_DOT11_MODE_AUTO;
929 }
930 return psapctx->csrRoamProfile.phyMode;
931}
932
933/**
934 * hdd_update_chandef() - Function to update channel width and center freq
935 * @chandef: cfg80211 chan def
936 * @cb_mode: chan offset
937 *
938 * This function will be called to update channel width and center freq
939 *
940 * Return: None
941 */
942static void
943hdd_update_chandef(struct cfg80211_chan_def *chandef,
944 ePhyChanBondState cb_mode)
945{
946 uint8_t center_chan, chan;
947
948 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
949 return;
950
951 chan = vos_freq_to_chan(chandef->chan->center_freq);
952 chandef->width = NL80211_CHAN_WIDTH_80;
953 switch (cb_mode) {
954 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
955 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
956 center_chan = chan + 2;
957 break;
958 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
959 center_chan = chan + 6;
960 break;
961 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
962 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
963 center_chan = chan - 2;
964 break;
965 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
966 center_chan = chan - 6;
967 break;
968 default:
969 center_chan = chan;
970 break;
971 }
972
973 chandef->center_freq1 = vos_chan_to_freq(center_chan);
974}
975
976/**
977 * hdd_chan_change_notify() - Function to notify hostapd about channel change
978 * @hostapd_adapter: hostapd adapter
979 * @dev: Net device structure
980 * @oper_chan: New operating channel
981 *
982 * This function is used to notify hostapd about the channel change
983 *
984 * Return: Success on intimating userspace
985 *
986 */
987static VOS_STATUS hdd_chan_change_notify(hdd_adapter_t *hostapd_adapter,
988 struct net_device *dev, uint8_t oper_chan)
989{
990 struct ieee80211_channel *chan;
991 struct cfg80211_chan_def chandef;
992 enum nl80211_channel_type channel_type;
993 eCsrPhyMode phy_mode;
994 ePhyChanBondState cb_mode;
995 uint32_t freq;
996 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(hostapd_adapter);
997 tSmeConfigParams sme_config;
998
999 if (!hal) {
1000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1001 "%s: hal is NULL", __func__);
1002 return VOS_STATUS_E_FAILURE;
1003 }
1004
1005 freq = vos_chan_to_freq(oper_chan);
1006
1007 chan = __ieee80211_get_channel(hostapd_adapter->wdev.wiphy, freq);
1008
1009 if (!chan) {
1010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1011 "%s: Invalid input frequency for channel conversion", __func__);
1012 return VOS_STATUS_E_FAILURE;
1013 }
1014
1015 phy_mode = wlansap_get_phymode(
1016 (WLAN_HDD_GET_CTX(hostapd_adapter))->pvosContext);
1017 sme_GetConfigParam(hal, &sme_config);
1018 if (oper_chan <= 14)
1019 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1020 sme_config.csrConfig.channelBondingMode24GHz);
1021 else
1022 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1023 sme_config.csrConfig.channelBondingMode5GHz);
1024
1025 switch (phy_mode) {
1026 case eCSR_DOT11_MODE_11n:
1027 case eCSR_DOT11_MODE_11n_ONLY:
1028 case eCSR_DOT11_MODE_11ac:
1029 case eCSR_DOT11_MODE_11ac_ONLY:
1030 switch (cb_mode) {
1031 case PHY_SINGLE_CHANNEL_CENTERED:
1032 channel_type = NL80211_CHAN_HT20;
1033 break;
1034 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1035 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1036 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1037 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1038 channel_type = NL80211_CHAN_HT40MINUS;
1039 break;
1040 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1041 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1042 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1043 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1044 channel_type = NL80211_CHAN_HT40PLUS;
1045 break;
1046 default:
1047 channel_type = NL80211_CHAN_HT20;
1048 break;
1049 }
1050 break;
1051 default:
1052 channel_type = NL80211_CHAN_NO_HT;
1053 break;
1054 }
1055
1056 cfg80211_chandef_create(&chandef, chan, channel_type);
1057 if ((phy_mode == eCSR_DOT11_MODE_11ac) ||
1058 (phy_mode == eCSR_DOT11_MODE_11ac_ONLY))
1059 hdd_update_chandef(&chandef, cb_mode);
1060
1061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1062 "%s: phy_mode %d cb_mode %d chann_type %d oper_chan %d width %d freq_1 %d",
1063 __func__, phy_mode, cb_mode, channel_type, oper_chan,
1064 chandef.width, chandef.center_freq1);
1065
1066
1067 cfg80211_ch_switch_notify(dev, &chandef);
1068
1069 return VOS_STATUS_SUCCESS;
1070}
1071
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301072/**
1073 * hdd_convert_dot11mode_from_phymode() - get dot11mode to phymode
1074 * @phymode: phy mode
1075 *
1076 * This function is used to get dot11mode to phymode
1077 *
1078 * Return: dot11mode
1079 */
1080static int hdd_convert_dot11mode_from_phymode(int phymode)
1081{
1082 switch (phymode) {
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301083
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301084 case VOS_MODE_11A:
1085 return QCA_WLAN_802_11_MODE_11A;
1086
1087 case VOS_MODE_11B:
1088 return QCA_WLAN_802_11_MODE_11B;
1089
1090 case VOS_MODE_11G:
1091 case VOS_MODE_11GONLY:
1092 return QCA_WLAN_802_11_MODE_11G;
1093
1094 case VOS_MODE_11NA_HT20:
1095 case VOS_MODE_11NG_HT20:
1096 case VOS_MODE_11NA_HT40:
1097 case VOS_MODE_11NG_HT40:
1098 return QCA_WLAN_802_11_MODE_11N;
1099
1100 case VOS_MODE_11AC_VHT20:
1101 case VOS_MODE_11AC_VHT40:
1102 case VOS_MODE_11AC_VHT80:
1103 case VOS_MODE_11AC_VHT20_2G:
1104 case VOS_MODE_11AC_VHT40_2G:
1105 case VOS_MODE_11AC_VHT80_2G:
1106#ifdef CONFIG_160MHZ_SUPPORT
1107 case VOS_MODE_11AC_VHT80_80:
1108 case VOS_MODE_11AC_VHT160:
1109#endif
1110 return QCA_WLAN_802_11_MODE_11AC;
1111
1112 default:
1113 return QCA_WLAN_802_11_MODE_INVALID;
1114 }
1115
1116}
1117
1118/**
1119 * hdd_fill_station_info() - fill station information
1120 * @sap_ctx: sap context
1121 * @event: assoc event
1122 * This function updates sta information from assoc event
1123 *
1124 * Return: none
1125 */
1126static void hdd_fill_station_info(ptSapContext sap_ctx,
1127 tSap_StationAssocReassocCompleteEvent *event)
1128{
1129 struct hdd_cache_sta_info *sta_info = sap_ctx->cache_sta_info;
1130 int i=0;
1131
1132 /* check if there is any dup entry */
1133 while (i < WLAN_MAX_STA_COUNT) {
1134 if (vos_mem_compare(sta_info[i].macAddrSTA.bytes,
1135 event->staMac.bytes,
1136 VOS_MAC_ADDR_SIZE)) {
1137 vos_mem_zero(&sta_info[i], sizeof(*sta_info));
1138 break;
1139 }
1140 i++;
1141 }
1142 if (i >= WLAN_MAX_STA_COUNT) {
1143 i = 0;
1144 while (i < WLAN_MAX_STA_COUNT) {
1145 if (sta_info[i].isUsed != TRUE)
1146 break;
1147 i++;
1148 }
1149 }
1150
1151 if (i < WLAN_MAX_STA_COUNT) {
1152 sta_info[i].isUsed = TRUE;
1153 sta_info[i].ucSTAId = event->staId;
1154 vos_mem_copy(sta_info[i].macAddrSTA.bytes,
1155 event->staMac.bytes,
1156 VOS_MAC_ADDR_SIZE);
1157 sta_info[i].freq = vos_chan_to_freq(event->chan_info.chan_id);
1158 sta_info[i].ch_width = event->ch_width;
1159 sta_info[i].nss = 1;
1160 sta_info[i].dot11_mode = hdd_convert_dot11mode_from_phymode(
1161 event->chan_info.info);
1162 if (event->HTCaps.present) {
1163 sta_info[i].ht_present = TRUE;
1164 hdd_copy_ht_caps(&sta_info[i].ht_caps, &event->HTCaps);
1165 }
1166 if (event->VHTCaps.present) {
1167 sta_info[i].vht_present = TRUE;
1168 hdd_copy_vht_caps(&sta_info[i].vht_caps,
1169 &event->VHTCaps);
1170 }
1171 }
1172 else
1173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "reached max staid, stainfo can't be cached");
1174}
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301175
Jeff Johnson295189b2012-06-20 16:38:30 -07001176VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
1177{
1178 hdd_adapter_t *pHostapdAdapter;
1179 hdd_ap_ctx_t *pHddApCtx;
1180 hdd_hostapd_state_t *pHostapdState;
1181 struct net_device *dev;
1182 eSapHddEvent sapEvent;
1183 union iwreq_data wrqu;
1184 v_BYTE_t *we_custom_event_generic = NULL;
1185 int we_event = 0;
1186 int i = 0;
1187 v_U8_t staId;
1188 VOS_STATUS vos_status;
1189 v_BOOL_t bWPSState;
1190 v_BOOL_t bApActive = FALSE;
1191 v_BOOL_t bAuthRequired = TRUE;
1192 tpSap_AssocMacAddr pAssocStasArray = NULL;
1193 char unknownSTAEvent[IW_CUSTOM_MAX+1];
1194 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
1195 v_BYTE_t we_custom_start_event[64];
1196 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001197 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001198 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -07001199 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301200 v_CONTEXT_t pVosContext = NULL;
1201 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +05301202 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -07001203
1204 dev = (struct net_device *)usrDataForCallback;
1205 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +05301206
1207 if ((NULL == pHostapdAdapter) ||
1208 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
1209 {
1210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1211 "invalid adapter or adapter has invalid magic");
1212 return eHAL_STATUS_FAILURE;
1213 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301214 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1215 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1216 if(pSapCtx == NULL){
1217 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1218 FL("psapCtx is NULL"));
1219 return eHAL_STATUS_FAILURE;
1220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1222 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1223 sapEvent = pSapEvent->sapHddEventCode;
1224 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001225 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +05301226 cfg_param = pHddCtx->cfg_ini;
1227
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 switch(sapEvent)
1229 {
1230 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -08001231 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
1233 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
1234 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
1235
1236 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
1237 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +05301238
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +05301240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 goto stopbss;
1243 }
1244 else
Deepthi Gowried085092015-10-20 19:30:52 +05301245 {
1246 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1247 {
1248 if ((cfg_param->dynSplitscan) &&
1249 (!pHddCtx->issplitscan_enabled))
1250 {
1251 pHddCtx->issplitscan_enabled = TRUE;
1252 sme_enable_disable_split_scan(
1253 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
1254 cfg_param->nNumStaChanCombinedConc,
1255 cfg_param->nNumP2PChanCombinedConc);
1256 }
1257 }
1258
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1260 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +05301261 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1262 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +05301263 {
c_hpothuffdb5272013-10-02 16:42:35 +05301264 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +05301265 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
1266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 }
Deepthi Gowried085092015-10-20 19:30:52 +05301268
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1270 {
1271 // AP Inactivity timer init and start
1272 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1273 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1274 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001275 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001276
1277 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1278 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001279 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001280
1281 }
1282 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1283 pHostapdState->bssState = BSS_START;
1284
1285 // Send current operating channel of SoftAP to BTC-ES
1286 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1287
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 //Check if there is any group key pending to set.
1289 if( pHddApCtx->groupKey.keyLength )
1290 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001291 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1293 &pHddApCtx->groupKey ) )
1294 {
1295 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1296 "%s: WLANSAP_SetKeySta failed", __func__);
1297 }
1298 pHddApCtx->groupKey.keyLength = 0;
1299 }
1300 else if ( pHddApCtx->wepKey[0].keyLength )
1301 {
1302 int i=0;
1303 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1304 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001305 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001306 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1307 &pHddApCtx->wepKey[i] ) )
1308 {
1309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1310 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 }
1313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1315 startBssEvent = "SOFTAP.enabled";
1316 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1317 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1318 memset(&wrqu, 0, sizeof(wrqu));
1319 wrqu.data.length = strlen(startBssEvent);
1320 we_event = IWEVCUSTOM;
1321 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001322 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 break; //Event will be sent after Switch-Case stmt
1324
1325 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001326 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1328
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001329 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001330 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001331
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301333
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 goto stopbss;
1335 case eSAP_STA_SET_KEY_EVENT:
1336 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001337 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1339 return VOS_STATUS_SUCCESS;
1340 case eSAP_STA_DEL_KEY_EVENT:
1341 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001342 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 return VOS_STATUS_SUCCESS;
1344 case eSAP_STA_MIC_FAILURE_EVENT:
1345 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 memset(&msg, '\0', sizeof(msg));
1347 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001348 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001349 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001350 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 msg.flags = IW_MICFAILURE_GROUP;
1352 else
1353 msg.flags = IW_MICFAILURE_PAIRWISE;
1354 memset(&wrqu, 0, sizeof(wrqu));
1355 wrqu.data.length = sizeof(msg);
1356 we_event = IWEVMICHAELMICFAILURE;
1357 we_custom_event_generic = (v_BYTE_t *)&msg;
1358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 /* inform mic failure to nl80211 */
1360 cfg80211_michael_mic_failure(dev,
1361 pSapEvent->sapevt.
1362 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001363 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 NL80211_KEYTYPE_GROUP :
1365 NL80211_KEYTYPE_PAIRWISE),
1366 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1367 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1368 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 break;
1370
1371 case eSAP_STA_ASSOC_EVENT:
1372 case eSAP_STA_REASSOC_EVENT:
1373 wrqu.addr.sa_family = ARPHRD_ETHER;
1374 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001375 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001376 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 we_event = IWEVREGISTERED;
1378
1379 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1380
1381 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1382 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1383 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1384 {
1385 bAuthRequired = FALSE;
1386 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301387 /* fAuthRequiredshould should be false for sap offload */
1388 if ((bAuthRequired || bWPSState)
1389#ifdef SAP_AUTH_OFFLOAD
1390 && !cfg_param->enable_sap_auth_offload
1391#endif
1392 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 {
c_hpothuffdb5272013-10-02 16:42:35 +05301394 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 TRUE,
1396 pHddApCtx->uPrivacy,
1397 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1398 0,
1399 0,
1400 (v_MACADDR_t *)wrqu.addr.sa_data,
1401 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301402
1403 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1404 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1405 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 }
1407 else
1408 {
c_hpothuffdb5272013-10-02 16:42:35 +05301409 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 FALSE,
1411 pHddApCtx->uPrivacy,
1412 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1413 0,
1414 0,
1415 (v_MACADDR_t *)wrqu.addr.sa_data,
1416 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301417 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1418 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1419 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001420 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301421 if (VOS_IS_STATUS_SUCCESS(vos_status))
1422 hdd_fill_station_info(pSapCtx,
1423 &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent);
Amar Singhal6144c002013-05-03 16:11:42 -07001424
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301425 staId =
1426 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1427 if (VOS_IS_STATUS_SUCCESS(vos_status))
1428 {
1429
1430 pSapCtx->aStaInfo[staId].rate_flags =
1431 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1432 }
1433
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 // Stop AP inactivity timer
1435 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1436 {
1437 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1438 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001439 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001441#ifdef WLAN_OPEN_SOURCE
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301442 if (vos_wake_lock_active(&pHddCtx->sap_wake_lock))
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001443 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301444 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1445 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001446 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301447 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1448 HDD_SAP_WAKE_LOCK_DURATION,
1449 WIFI_POWER_EVENT_WAKELOCK_SAP);
1450
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001451#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001452#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1453 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301454 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1456
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301457 staInfo = vos_mem_malloc(sizeof(*staInfo));
1458 if (staInfo == NULL) {
1459 hddLog(LOGE, FL("alloc station_info failed"));
1460 return VOS_STATUS_E_NOMEM;
1461 }
1462
1463 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1465 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301466 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301468 staInfo->assoc_req_ies_len = iesLen;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301469#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) && \
1470 ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
1471 !defined(WITH_BACKPORTS))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301472 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001473#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 cfg80211_new_sta(dev,
1475 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301476 staInfo, GFP_KERNEL);
1477 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 }
1479 else
1480 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001481 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 }
1483 }
1484#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301485 hdd_manage_delack_timer(pHddCtx);
1486
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001487 pScanInfo = &pHddCtx->scan_info;
1488 // Lets do abort scan to ensure smooth authentication for client
1489 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1490 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301491 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301492 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001494
1495 break;
1496 case eSAP_STA_DISASSOC_EVENT:
1497 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001498 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001499 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05301500
1501 vos_status = vos_event_set(&pHostapdState->sta_discon_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1503 hddLog(LOG1," User initiated disassociation");
1504 else
1505 hddLog(LOG1," MAC initiated disassociation");
1506 we_event = IWEVEXPIRED;
1507 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1508 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1509 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001510 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 -07001511 return VOS_STATUS_E_FAILURE;
1512 }
1513 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1514
1515 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1516 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301517 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 // Start AP inactivity timer if no stations associated with it
1519 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1520 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301521 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 {
1523 bApActive = TRUE;
1524 break;
1525 }
1526 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301527 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001528
1529 if (bApActive == FALSE)
1530 {
1531 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1532 {
1533 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1534 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001535 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 }
1537 else
1538 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1539 }
1540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001541#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1542 cfg80211_del_sta(dev,
1543 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1544 GFP_KERNEL);
1545#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001546 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301547 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1548 if (VOS_STATUS_SUCCESS != vos_status)
1549 {
1550 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1551 __func__, vos_status);
1552 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301553 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 break;
1555 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1556 {
1557 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1558 union iwreq_data wreq;
1559
1560 down(&pHddApCtx->semWpsPBCOverlapInd);
1561 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1562
1563 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1564 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1565
1566 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001567 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 memset(&wreq, 0, sizeof(wreq));
1569 wreq.data.length = strlen(message); // This is length of message
1570 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1571
1572 return VOS_STATUS_SUCCESS;
1573 }
1574 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1575 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1576 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1577 { // List of associated stations
1578 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1579 {
1580 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1581 i+1,
1582 pAssocStasArray->assocId,
1583 pAssocStasArray->staId,
1584 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1585 pAssocStasArray++;
1586 }
1587 }
1588 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001589 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 case eSAP_REMAIN_CHAN_READY:
1592 hdd_remainChanReadyHandler( pHostapdAdapter );
1593 return VOS_STATUS_SUCCESS;
1594 case eSAP_SEND_ACTION_CNF:
1595 hdd_sendActionCnf( pHostapdAdapter,
1596 ( eSAP_STATUS_SUCCESS ==
1597 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1598 TRUE : FALSE );
1599 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 case eSAP_UNKNOWN_STA_JOIN:
1601 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1602 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1603 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1604 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1605 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1606 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1607 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1608 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1609 wrqu.data.pointer = unknownSTAEvent;
1610 wrqu.data.length = strlen(unknownSTAEvent);
1611 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301612 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 break;
1614
1615 case eSAP_MAX_ASSOC_EXCEEDED:
1616 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1617 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1618 " one or more devices to enable the new device connection",
1619 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1620 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1621 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1622 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1623 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1624 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1625 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1626 wrqu.data.pointer = maxAssocExceededEvent;
1627 wrqu.data.length = strlen(maxAssocExceededEvent);
1628 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001629 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 break;
1631 case eSAP_STA_ASSOC_IND:
1632 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001633
1634 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001635 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001636 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1637 return VOS_STATUS_SUCCESS;
1638
1639 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301640 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301641 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1642 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301643 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301644 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001645 return VOS_STATUS_SUCCESS;
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301646 case eSAP_CHANNEL_CHANGED_EVENT:
1647 hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001648
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301649 return hdd_chan_change_notify(pHostapdAdapter, dev,
1650 pSapEvent->sapevt.sap_chan_selected.new_chan);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301651 case eSAP_STA_LOSTLINK_DETECTED:
1652 {
1653 tSap_StationDisassocCompleteEvent *disassoc_comp =
1654 &pSapEvent->sapevt.sapStationDisassocCompleteEvent;
1655
1656 struct hdd_cache_sta_info *sta_info = hdd_get_cache_stainfo(
1657 pSapCtx->cache_sta_info,
1658 disassoc_comp->staMac.bytes);
1659 if (!sta_info) {
1660 hddLog(LOGE, FL("invalid cache sta info"));
1661 return VOS_STATUS_E_FAILURE;
1662 }
1663
1664 WLANTL_GetSAPStaRSSi(pVosContext, disassoc_comp->staId,
1665 &sta_info->rssi);
1666 sta_info->rx_rate =
1667 wlan_tl_get_sta_rx_rate(pVosContext, disassoc_comp->staId);
1668 if (disassoc_comp->reason != eSAP_USR_INITATED_DISASSOC)
1669 sta_info->reason_code = disassoc_comp->reason;
1670 return VOS_STATUS_SUCCESS;
1671 }
1672
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001674 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 goto stopbss;
1676 return VOS_STATUS_SUCCESS;
1677 }
1678 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1679 return VOS_STATUS_SUCCESS;
1680
1681stopbss :
1682 {
1683 v_BYTE_t we_custom_event[64];
1684 char *stopBssEvent = "STOP-BSS.response";//17
1685 int event_len = strlen(stopBssEvent);
1686
1687 hddLog(LOG1, FL("BSS stop status = %s"),
1688 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1689 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1690
1691 /* Change the BSS state now since, as we are shutting things down,
1692 * we don't want interfaces to become re-enabled */
1693 pHostapdState->bssState = BSS_STOP;
1694
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301695 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1696 {
1697 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1698 {
1699 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1700 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1701 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1702 }
1703
1704 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1705 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1706 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1707 }
1708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 /* Stop the pkts from n/w stack as we are going to free all of
1710 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301711
1712 /*
1713 * If channel avoidance is in progress means driver is performing SAP
1714 * restart. So don't do carrier off, which may lead framework to do
1715 * driver reload.
1716 */
1717 hddLog(LOG1, FL("ch avoid in progress: %d"),
1718 pHddCtx->is_ch_avoid_in_progress);
1719 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301720 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301721 netif_tx_disable(dev);
1722 else
1723 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001724
1725 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301726 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1727 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1728 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001729
Amar Singhal37e6f052013-03-05 16:16:54 -08001730 /* once the event is set, structure dev/pHostapdAdapter should
1731 * not be touched since they are now subject to being deleted
1732 * by another thread */
1733 if (eSAP_STOP_BSS_EVENT == sapEvent)
1734 vos_event_set(&pHostapdState->vosEvent);
1735
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +05301736 if (hdd_is_any_session_connected(pHddCtx) == VOS_STATUS_E_FAILURE) {
1737 hdd_enable_bmps_imps(pHddCtx);
1738 sme_request_imps(pHddCtx->hHal);
1739 }
1740
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 /* notify userspace that the BSS has stopped */
1742 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1743 memcpy(&we_custom_event, stopBssEvent, event_len);
1744 memset(&wrqu, 0, sizeof(wrqu));
1745 wrqu.data.length = event_len;
1746 we_event = IWEVCUSTOM;
1747 we_custom_event_generic = we_custom_event;
1748 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001749 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 }
Bala Venkatesh5c06a252018-07-12 16:08:04 +05301751 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO ||
1752 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
1753 {
1754 hddLog(LOG1,
1755 FL("SAP or Go is getting removed and we are trying to re-enable TDLS"));
1756 wlan_hdd_tdls_reenable(pHddCtx);
1757 }
1758
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 return VOS_STATUS_SUCCESS;
1760}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001761
1762int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001764 eCsrEncryptionType *pEncryptType,
1765 eCsrEncryptionType *mcEncryptType,
1766 eCsrAuthType *pAuthType,
1767 v_BOOL_t *pMFPCapable,
1768 v_BOOL_t *pMFPRequired,
1769 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 u_int8_t *gen_ie )
1771{
1772 tDot11fIERSN dot11RSNIE;
1773 tDot11fIEWPA dot11WPAIE;
1774
1775 tANI_U8 *pRsnIe;
1776 tANI_U16 RSNIeLen;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301777 tANI_U32 status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778
1779 if (NULL == halHandle)
1780 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001781 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 return -EINVAL;
1783 }
1784
1785 // Validity checks
1786 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1787 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1788 return -EINVAL;
1789 // Type check
1790 if ( gen_ie[0] == DOT11F_EID_RSN)
1791 {
1792 // Validity checks
1793 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1794 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1795 {
1796 return VOS_STATUS_E_FAILURE;
1797 }
1798 // Skip past the EID byte and length byte
1799 pRsnIe = gen_ie + 2;
1800 RSNIeLen = gen_ie_len - 2;
1801 // Unpack the RSN IE
1802 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301803
1804 status = sme_unpack_rsn_ie(halHandle,
1805 pRsnIe,
1806 RSNIeLen,
1807 &dot11RSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05301808 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301809 {
1810 hddLog(LOGE,
1811 FL("unpack failed for RSN IE status:(0x%08x)"),
1812 status);
1813 return -EINVAL;
1814 }
1815
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001817 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001818 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001819 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301820 __func__, dot11RSNIE.akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 /*Here we have followed the apple base code,
1822 but probably I suspect we can do something different*/
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301823 //dot11RSNIE.akm_suite_cnt
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301825 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 //dot11RSNIE.pwise_cipher_suite_count
1827 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1828 //dot11RSNIE.gp_cipher_suite_count
1829 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1830 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001831 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1832 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833
1834 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1835 } else
1836 if (gen_ie[0] == DOT11F_EID_WPA)
1837 {
1838 // Validity checks
1839 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1840 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1841 {
1842 return VOS_STATUS_E_FAILURE;
1843 }
1844 // Skip past the EID byte and length byte - and four byte WiFi OUI
1845 pRsnIe = gen_ie + 2 + 4;
1846 RSNIeLen = gen_ie_len - (2 + 4);
1847 // Unpack the WPA IE
1848 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301849 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1850 pRsnIe,
1851 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301853 if (DOT11F_FAILED(status))
1854 {
1855 hddLog(LOGE,
1856 FL("unpack failed for WPA IE status:(0x%08x)"),
1857 status);
1858 return -EINVAL;
1859 }
1860
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001862 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001863 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001864 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001865 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 //dot11WPAIE.auth_suite_count
1867 // Just translate the FIRST one
1868 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1869 //dot11WPAIE.unicast_cipher_count
1870 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1871 //dot11WPAIE.unicast_cipher_count
1872 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001873 *pMFPCapable = VOS_FALSE;
1874 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 }
1876 else
1877 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001878 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 return VOS_STATUS_E_FAILURE;
1880 }
1881 return VOS_STATUS_SUCCESS;
1882}
Leo Chang614d2072013-08-22 14:59:44 -07001883
Leo Chang0b0e45a2013-12-15 15:18:55 -08001884#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001885
1886/*==========================================================================
1887 FUNCTION sapUpdateUnsafeChannelList
1888
1889 DESCRIPTION
1890 Function Undate unsafe channel list table
1891
1892 DEPENDENCIES
1893 NA.
1894
1895 PARAMETERS
1896
1897 IN
1898 pSapCtx : SAP context pointer, include unsafe channel list
1899
1900 RETURN VALUE
1901 NONE
1902============================================================================*/
1903void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1904 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1905{
1906 v_U16_t i, j;
1907
1908 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1909 sizeof(pHddCtx->unsafeChannelList));
1910 if (0 == unsafeChannelCount)
1911 {
1912 pHddCtx->unsafeChannelCount = 0;
1913 }
1914 else
1915 {
c_hpothu8de53e42014-08-22 15:00:37 +05301916 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1917 {
1918 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1919 FL("unsafeChannelCount%hd greater than %d"),
1920 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1921 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1922 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001923 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1924 unsafeChannelList,
1925 unsafeChannelCount * sizeof(tANI_U16));
1926 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1927 }
1928
1929 /* Flush, default set all channel safe */
1930 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1931 {
1932 safeChannels[i].isSafe = VOS_TRUE;
1933 }
1934
1935 /* Try to find unsafe channel */
1936 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1937 {
1938 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1939 {
1940 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1941 {
1942 /* Found unsafe channel, update it */
1943 safeChannels[j].isSafe = VOS_FALSE;
1944 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1945 "%s : CH %d is not safe",
1946 __func__, pHddCtx->unsafeChannelList[i]);
1947 break;
1948 }
1949 }
1950 }
1951
1952 return;
1953}
1954
Kapil Gupta137ef892016-12-13 19:38:00 +05301955/**
1956 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1957 * @adapter: hdd ap adapter
1958 *
1959 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1960 * and if ACS is enabled, driver will ask userspace to restart the
1961 * sap. User space on LTE coex indication restart driver.
1962 *
1963 * Return - none
1964 */
1965static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1966 hdd_context_t *hdd_ctx)
1967{
1968
1969 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1970 return;
1971 }
1972
1973 hddLog(LOG1, FL("Current operation channel %d"),
1974 adapter->sessionCtx.ap.operatingChannel);
1975 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1976 hdd_change_ch_avoidance_status(hdd_ctx, true);
1977
1978 vos_flush_work(
1979 &hdd_ctx->sap_start_work);
1980
1981 /*
1982 * current operating channel
1983 * is un-safe channel, restart SAP
1984 */
1985 hddLog(LOG1,
1986 FL("Restarting SAP due to unsafe channel"));
1987
1988 adapter->sessionCtx.ap.sapConfig.channel =
1989 AUTO_CHANNEL_SELECT;
1990
Kapil Gupta137ef892016-12-13 19:38:00 +05301991
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301992 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05301993 netif_tx_disable(adapter->dev);
1994 schedule_work(&hdd_ctx->sap_start_work);
1995 } else {
1996 hdd_hostapd_stop(adapter->dev);
1997 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301998
1999 return;
2000 }
2001 return;
2002}
2003
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302004static v_U16_t hdd_get_safe_channel_from_acs_range(hdd_context_t *hdd_ctx,
2005 hdd_adapter_t *sap_adapter, v_U16_t *unsafeChannelList,
2006 v_U16_t unsafeChannelCount)
2007{
2008 v_U8_t valid_channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2009 v_U32_t startChannelNum;
2010 v_U32_t endChannelNum;
2011 v_U32_t valid_channel_count = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2012 v_U16_t i, j;
2013 eHalStatus status;
2014 bool found;
2015
2016 status = sme_GetCfgValidChannels(hdd_ctx->hHal, valid_channels,
2017 &valid_channel_count);
2018 if (!HAL_STATUS_SUCCESS(status))
2019 return 0;
2020
2021 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL,
2022 &startChannelNum);
2023 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL,
2024 &endChannelNum);
2025
2026 for (i = 0; i < valid_channel_count; i++) {
2027 found = false;
2028 for (j = 0; j < unsafeChannelCount; j++) {
2029 if (valid_channels[i] == unsafeChannelList[j]) {
2030 found = true;
2031 break;
2032 }
2033 }
2034
2035 if (found)
2036 continue;
2037
2038 if ((valid_channels[i] >= startChannelNum) &&
2039 (valid_channels[i] <= endChannelNum)) {
2040 return valid_channels[i];
2041 }
2042 }
2043
2044 return 0;
2045}
2046
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302047void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
2048 hdd_context_t *hdd_ctxt)
2049{
2050 v_U16_t channelLoop;
2051 v_U16_t unsafeChannelCount = 0;
2052 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302053 v_U16_t sta_chan;
2054 v_U16_t restart_chan;
2055 v_CONTEXT_t vos_ctx;
2056 ptSapContext sap_ctx;
2057
2058 vos_ctx = hdd_ctxt->pvosContext;
2059 if (!vos_ctx) {
2060 hddLog(LOGE, FL("vos_ctx is NULL"));
2061 return;
2062 }
2063
2064 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
2065 if (!sap_ctx) {
2066 hddLog(LOGE, FL("sap_ctx is NULL"));
2067 return;
2068 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302069
2070 /* Get unsafe channel list */
2071 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
2072 &unsafeChannelCount);
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302073 sta_chan = hdd_get_operating_channel(hdd_ctxt, WLAN_HDD_INFRA_STATION);
2074
2075 if (sta_chan) {
2076 hddLog(LOG1, FL("Only SCC supported for STA+SAP"));
2077 return;
2078 }
2079
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302080 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
2081 {
2082 if ((unsafeChannelList[channelLoop] ==
2083 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
2084 if ((AUTO_CHANNEL_SELECT ==
2085 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
2086 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
2087 /*
2088 * current operating channel is un-safe channel
2089 * restart driver
2090 */
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302091 if (hdd_ctxt->cfg_ini->force_scc_with_ecsa) {
2092 restart_chan = hdd_get_safe_channel_from_acs_range(hdd_ctxt,
2093 phostapd_adapter, unsafeChannelList,
2094 unsafeChannelCount);
2095
2096 if (!restart_chan) {
2097 hddLog(LOGE, FL("Failed to restart SAP as no safe channel found"));
2098 return;
2099 } else {
2100 if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx))
2101 return;
2102 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
2103 if (wlansap_set_channel_change(vos_ctx, restart_chan,
2104 false)) {
2105 wlansap_reset_chan_change_in_progress(sap_ctx);
2106 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2107 return;
2108 }
2109 }
2110 } else {
2111 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
2112 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302113 /*
2114 * On LE, this event is handled by wlan-services to
2115 * restart SAP. On android, this event would be
2116 * ignored.
2117 */
2118 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
2119 NULL, 0);
2120 }
2121 break;
2122 }
2123 }
2124 return;
2125}
2126
2127
Kapil Gupta137ef892016-12-13 19:38:00 +05302128
Leo Chang0b0e45a2013-12-15 15:18:55 -08002129/**---------------------------------------------------------------------------
2130
2131 \brief hdd_hostapd_ch_avoid_cb() -
2132
2133 Avoid channel notification from FW handler.
2134 FW will send un-safe channle list to avoid overwrapping.
2135 hostapd should not use notified channel
2136
2137 \param - pAdapter HDD adapter pointer
2138 indParam channel avoid notification parameter
2139
2140 \return - None
2141
2142 --------------------------------------------------------------------------*/
2143void hdd_hostapd_ch_avoid_cb
2144(
Kapil Gupta137ef892016-12-13 19:38:00 +05302145 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08002146 void *indParam
2147)
2148{
2149 hdd_adapter_t *pHostapdAdapter = NULL;
2150 hdd_context_t *hddCtxt;
2151 tSirChAvoidIndType *chAvoidInd;
2152 v_U8_t rangeLoop;
2153 v_U16_t channelLoop;
2154 v_U16_t dupCheck;
2155 v_U16_t startChannel;
2156 v_U16_t endChannel;
2157 v_U16_t unsafeChannelCount = 0;
2158 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
2159 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002160 tHddAvoidFreqList hddAvoidFreqList;
2161 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302162#ifdef WLAN_FEATURE_AP_HT40_24G
2163 ptSapContext pSapCtx = NULL;
2164 tHalHandle hHal;
2165 v_U8_t cbMode;
2166 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2167 v_U32_t delay;
2168#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002169
2170 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05302171 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002172 {
2173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2174 "%s : Invalid arguments", __func__);
2175 return;
2176 }
2177
Kapil Gupta137ef892016-12-13 19:38:00 +05302178 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08002179 chAvoidInd = (tSirChAvoidIndType *)indParam;
2180 pVosContext = hddCtxt->pvosContext;
2181
2182 /* Make unsafe channel list */
2183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2184 "%s : band count %d",
2185 __func__, chAvoidInd->avoidRangeCount);
2186 vos_mem_zero((void *)unsafeChannelList,
2187 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
2188 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
2189 {
Abhishek Singh57a31542016-01-04 21:01:43 +05302190 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2191 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2192 break;
2193 }
2194 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002195 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05302196 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002197 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
2198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2199 "%s : start %d : %d, end %d : %d",
2200 __func__,
2201 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
2202 startChannel,
2203 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
2204 endChannel);
2205 for (channelLoop = startChannel;
2206 channelLoop < (endChannel + 1);
2207 channelLoop++)
2208 {
2209 /* Channel duplicate check routine */
2210 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
2211 {
2212 if (unsafeChannelList[dupCheck] == channelLoop)
2213 {
2214 /* This channel is duplicated */
2215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2216 "%s : found duplicated channel %d",
2217 __func__, channelLoop);
2218 break;
2219 }
2220 }
2221 if (dupCheck == unsafeChannelCount)
2222 {
c_hpothu8de53e42014-08-22 15:00:37 +05302223 int ii;
2224 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
2225 {
2226 if (channelLoop == safeChannels[ii].channelNumber)
2227 {
2228 unsafeChannelList[unsafeChannelCount] = channelLoop;
2229 unsafeChannelCount++;
2230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2231 "%s : unsafe channel %d, count %d",
2232 __func__,
2233 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05302234 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2235 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2236 break;
2237 }
c_hpothu8de53e42014-08-22 15:00:37 +05302238 }
2239 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08002240 }
2241 else
2242 {
2243 /* DUP, do nothing */
2244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2245 "%s : duplicated channel %d",
2246 __func__, channelLoop);
2247 }
2248 }
2249 }
2250 /* Update unsafe channel cache
2251 * WCN Platform Driver cache */
2252 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
2253 unsafeChannelCount);
2254
2255 /* Store into local cache
2256 * Start with STA and later start SAP
2257 * in this scenario, local cache will be used */
2258 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
2259 unsafeChannelList,
2260 unsafeChannelCount);
2261
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002262 /* generate vendor specific event */
2263 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
2264 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
2265 {
2266 hddAvoidFreqList.avoidFreqRange[i].startFreq =
2267 chAvoidInd->avoidFreqRange[i].startFreq;
2268 hddAvoidFreqList.avoidFreqRange[i].endFreq =
2269 chAvoidInd->avoidFreqRange[i].endFreq;
2270 }
2271 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
2272
2273 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
2274
Leo Chang0b0e45a2013-12-15 15:18:55 -08002275 /* Get SAP context first
2276 * SAP and P2PGO would not concurrent */
2277 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302278#ifdef WLAN_FEATURE_AP_HT40_24G
2279 if (NULL == pHostapdAdapter)
2280 {
2281 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
2282 }
2283#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05302284 if ((pHostapdAdapter) &&
2285 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
2286 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002287 {
2288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2289 "%s : Current operation channel %d",
2290 __func__,
2291 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302292 /* Check and Restart the SAP if it is on unsafe channel */
2293 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
2294
Leo Chang0b0e45a2013-12-15 15:18:55 -08002295 }
2296
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302297#ifdef WLAN_FEATURE_AP_HT40_24G
2298 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
2299 {
2300 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2301
2302 if(pSapCtx == NULL)
2303 {
2304 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
2305 FL("psapCtx is NULL"));
2306 return;
2307 }
2308
2309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2310 FL("SAP Secondary channel: %d "),
2311 pSapCtx->sap_sec_chan);
2312
2313 /* tHalHandle */
2314 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2315
2316 if (NULL == hHal)
2317 {
2318 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2319 FL("In invalid hHal"));
2320 return;
2321 }
2322
2323 cbMode = sme_GetChannelBondingMode24G(hHal);
2324
2325 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2326 FL("Selected Channel bonding : %d"), cbMode);
2327
2328 if (cbMode && (pSapCtx->sap_sec_chan > 0))
2329 {
2330 int i;
2331 eHalStatus halStatus;
2332
2333 for (i = 0; i < unsafeChannelCount; i++)
2334 {
2335 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
2336 {
2337 /* Current SAP Secondary channel is un-safe channel */
2338 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2339 FL("Move SAP from HT40 to HT20"));
2340
2341 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
2342 PHY_SINGLE_CHANNEL_CENTERED);
2343
2344 if (halStatus == eHAL_STATUS_FAILURE)
2345 {
2346 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2347 FL("Failed to change HT20/40 mode"));
2348 return;
2349 }
2350
2351 /* Disable Channel Bonding for 2.4GHz */
2352 sme_UpdateChannelBondingMode24G(hHal,
2353 PHY_SINGLE_CHANNEL_CENTERED);
2354 return;
2355 }
2356 }
2357 }
2358
2359 if ((!pSapCtx->numHT40IntoSta)
2360 && (pHostapdAdapter)
2361 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
2362 {
2363 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
2364 * are Safe then start HT20/40 timer to Move SAP from HT20
2365 * to HT40.
2366 */
2367 if (((!unsafeChannelCount)
2368 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
2369 {
2370 /* Stop Previous Running HT20/40 Timer & Start timer
2371 with (OBSS TransitionDelayFactor * obss interval)
2372 delay after time out move AP from HT20 -> HT40
2373 mode
2374 */
2375 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2376 {
2377 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2378 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2379 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2380 FL("Failed to Stop HT20/40 timer"));
2381 }
2382
2383 delay =
2384 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
2385
2386 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2387 FL("Start HT20/40 transition timer (%d sec)"), delay);
2388
2389 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
2390 (delay * 1000));
2391
2392 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2393 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2394 FL("Failed to Start HT20/40 timer"));
2395 }
2396 else
2397 {
2398 /* Stop HT20/40 Timer */
2399 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2400 {
2401 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2402 FL("Stop HT20/40 transition timer"));
2403 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2404 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2405 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2406 FL("Failed to Stop HT20/40 timer"));
2407 }
2408 }
2409 }
2410 }
2411#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002412 return;
2413}
Leo Chang0b0e45a2013-12-15 15:18:55 -08002414#endif /* FEATURE_WLAN_CH_AVOID */
2415
Jeff Johnson295189b2012-06-20 16:38:30 -07002416int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302417static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 struct iw_request_info *info,
2419 union iwreq_data *wrqu, char *extra)
2420{
2421 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002422 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302423 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 int *value = (int *)extra;
2425 int sub_cmd = value[0];
2426 int set_value = value[1];
2427 eHalStatus status;
2428 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302429 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002430 v_CONTEXT_t pVosContext;
2431
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302432 ENTER();
2433
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302434 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002435 {
2436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302437 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002438 __func__);
2439 return -1;
2440 }
2441
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302442 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2443 ret = wlan_hdd_validate_context(pHddCtx);
2444 if (0 != ret)
2445 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302446 return -1;
2447 }
2448
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002449 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2450 if (!hHal)
2451 {
2452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2453 "%s: Hal ctx is null", __func__);
2454 return -1;
2455 }
2456
2457 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2458 if (!pVosContext)
2459 {
2460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2461 "%s: Vos ctx is null", __func__);
2462 return -1;
2463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002464
2465 switch(sub_cmd)
2466 {
2467
2468 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002469 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302471 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 }
2473 break;
2474
2475 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302476 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2478 {
2479 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2480 ret = -EINVAL;
2481 }
2482 else
2483 {
2484 WLANSAP_SetMode(pVosContext, set_value);
2485 }
2486 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302487
2488 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2489 if ((0 != set_value) && (1 != set_value))
2490 {
2491 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2492 ret = -EINVAL;
2493 }
2494 else
2495 {
2496 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2497 }
2498 break;
2499
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 case QCSAP_PARAM_MAX_ASSOC:
2501 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2502 {
2503 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2504 ret = -EINVAL;
2505 }
2506 else
2507 {
2508 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2509 {
2510 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2511 "Setting it to max allowed and continuing"),
2512 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2513 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2514 }
2515 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2516 set_value, NULL, eANI_BOOLEAN_FALSE);
2517 if ( status != eHAL_STATUS_SUCCESS )
2518 {
2519 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2520 status);
2521 ret = -EIO;
2522 }
2523 }
2524 break;
2525
2526 case QCSAP_PARAM_HIDE_SSID:
2527 {
2528 eHalStatus status = eHAL_STATUS_SUCCESS;
2529 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2530 if(eHAL_STATUS_SUCCESS != status)
2531 {
2532 hddLog(VOS_TRACE_LEVEL_ERROR,
2533 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002534 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 return status;
2536 }
2537 break;
2538 }
2539
Leo Chang614d2072013-08-22 14:59:44 -07002540 case QCSAP_PARAM_SET_MC_RATE:
2541 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002542 tSirRateUpdateInd *rateUpdate;
2543
2544 rateUpdate = (tSirRateUpdateInd *)
2545 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2546 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002547 {
2548 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002549 "%s: SET_MC_RATE indication alloc fail", __func__);
2550 ret = -1;
2551 break;
2552 }
2553 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2554
2555 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2556 /* Ignore unicast */
2557 rateUpdate->ucastDataRate = -1;
2558 rateUpdate->mcastDataRate24GHz = set_value;
2559 rateUpdate->mcastDataRate5GHz = set_value;
2560 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2561 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2562 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2563 if (eHAL_STATUS_SUCCESS != status)
2564 {
2565 hddLog(VOS_TRACE_LEVEL_ERROR,
2566 "%s: SET_MC_RATE failed", __func__);
2567 vos_mem_free(rateUpdate);
2568 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002569 }
2570 break;
2571 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302572 case QCSAP_PARAM_GET_FRAME_LOGS:
2573 {
2574 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2575 != VOS_STATUS_SUCCESS)
2576 {
2577 ret = -EINVAL;
2578 }
2579 break;
2580 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302581 case QCSAP_PARAM_SET_PROXIMITY:
2582 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302583 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302584 break;
2585 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302586 case QCSAP_PARAM_SET_WOWL:
2587 {
2588 if (!pHddCtx->is_ap_mode_wow_supported)
2589 {
2590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2591 "%s: Not supported",__func__);
2592 return -ENOTSUPP;
2593 }
2594 switch (set_value)
2595 {
2596 case 0x00:
2597 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2598 break;
2599 case 0x01:
2600 case 0x02:
2601 case 0x03:
2602 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2603 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2604 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2605 (enable_magic_pkt ? "YES":"NO"),
2606 (enable_pattrn_byte_match ? "YES":"NO"));
2607 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2608 enable_pattrn_byte_match);
2609 break;
2610 default:
2611 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2612 ret = -EINVAL;
2613 break;
2614 }
2615 break;
2616 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302617 case QCSAP_PARAM_CAP_TSF:
2618 {
2619 ret = hdd_capture_tsf(pHostapdAdapter,
2620 (uint32_t *)&set_value, 1);
2621 break;
2622 }
Abhishek Singh02605092017-10-25 14:06:12 +05302623 case QCSAP_PARAM_SET_CHANNEL_CHANGE:
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302624 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) {
2625 ptSapContext sap_ctx;
2626
2627 sap_ctx = VOS_GET_SAP_CB(pVosContext);
2628 if (!sap_ctx) {
2629 hddLog(LOGE, FL("sap_ctx is NULL"));
2630 return -EINVAL;
2631 }
2632 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
2633 if (ret)
2634 return ret;
2635 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
Abhishek Singh02605092017-10-25 14:06:12 +05302636 hddLog(LOG1, FL("ET Channel Change to new channel= %d"),
2637 set_value);
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302638 ret = wlansap_set_channel_change(pVosContext, set_value, false);
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302639 if (ret) {
2640 wlansap_reset_chan_change_in_progress(sap_ctx);
2641 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2642 }
Abhishek Singh02605092017-10-25 14:06:12 +05302643 } else {
2644 hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"),
2645 set_value);
2646 ret = -EINVAL;
2647 }
2648 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 default:
2650 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2651 sub_cmd, set_value);
2652 ret = -EINVAL;
2653 break;
2654 }
2655
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302656 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 return ret;
2658}
2659
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302660int
2661static iw_softap_setparam(struct net_device *dev,
2662 struct iw_request_info *info,
2663 union iwreq_data *wrqu, char *extra)
2664{
2665 int ret;
2666
2667 vos_ssr_protect(__func__);
2668 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2669 vos_ssr_unprotect(__func__);
2670
2671 return ret;
2672}
Jeff Johnson295189b2012-06-20 16:38:30 -07002673
2674int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302675static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 struct iw_request_info *info,
2677 union iwreq_data *wrqu, char *extra)
2678{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302679 hdd_adapter_t *pHostapdAdapter;
2680 tHalHandle hHal;
2681 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 int *value = (int *)extra;
2683 int sub_cmd = value[0];
2684 eHalStatus status;
2685 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302686 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302688 ENTER();
2689
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302690 pHostapdAdapter = (netdev_priv(dev));
2691 if (NULL == pHostapdAdapter)
2692 {
2693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2694 "%s: Adapter is NULL",__func__);
2695 return -EINVAL;
2696 }
2697 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2698 ret = wlan_hdd_validate_context(pHddCtx);
2699 if (0 != ret)
2700 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302701 return ret;
2702 }
2703 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2704 if (NULL == hHal)
2705 {
2706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2707 "%s: Hal Context is NULL",__func__);
2708 return -EINVAL;
2709 }
2710 pVosContext = pHddCtx->pvosContext;
2711 if (NULL == pVosContext)
2712 {
2713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2714 "%s: pVosContext Context is NULL",__func__);
2715 return -EINVAL;
2716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 switch (sub_cmd)
2718 {
2719 case QCSAP_PARAM_MAX_ASSOC:
2720 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2721 if (eHAL_STATUS_SUCCESS != status)
2722 {
c_hpothuffdb5272013-10-02 16:42:35 +05302723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2724 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 ret = -EIO;
2726 }
Girish Gowli385be612014-09-18 11:17:20 +05302727
2728#ifdef WLAN_SOFTAP_VSTA_FEATURE
2729 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2730 {
2731 if (*value > VSTA_NUM_ASSOC_STA)
2732 {
2733 *value = VSTA_NUM_ASSOC_STA;
2734 }
2735 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2736 (*value > (VSTA_NUM_ASSOC_STA -
2737 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2738 {
2739 *value = (VSTA_NUM_ASSOC_STA -
2740 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2741 }
2742 }
2743 else
2744#endif
2745 {
2746 if (*value > NUM_ASSOC_STA)
2747 {
2748 *value = NUM_ASSOC_STA;
2749 }
2750 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2751 (*value > (NUM_ASSOC_STA -
2752 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2753 {
2754 *value = (NUM_ASSOC_STA -
2755 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2756 }
2757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002761 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 {
c_hpothuffdb5272013-10-02 16:42:35 +05302763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2764 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302765 ret = -EIO;
2766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 *value = 0;
2768 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302769
Jeff Johnson43971f52012-07-17 12:26:56 -07002770 case QCSAP_PARAM_GET_WLAN_DBG:
2771 {
2772 vos_trace_display();
2773 *value = 0;
2774 break;
2775 }
2776
2777 case QCSAP_PARAM_AUTO_CHANNEL:
2778 {
2779 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2780 break;
2781 }
2782
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 default:
2784 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2785 ret = -EINVAL;
2786 break;
2787
2788 }
2789
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302790 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 return ret;
2792}
2793
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302794int
2795static iw_softap_getparam(struct net_device *dev,
2796 struct iw_request_info *info,
2797 union iwreq_data *wrqu, char *extra)
2798{
2799 int ret;
2800
2801 vos_ssr_protect(__func__);
2802 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2803 vos_ssr_unprotect(__func__);
2804
2805 return ret;
2806}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302807
2808int
2809static __iw_softap_setchar_getnone(struct net_device *dev,
2810 struct iw_request_info *info,
2811 union iwreq_data *wrqu, char *extra)
2812{
2813 int sub_cmd;
2814 int ret = 0; /* success */
2815 char *pBuffer = NULL;
2816 hdd_adapter_t *pAdapter;
2817 hdd_context_t *pHddCtx;
2818 struct iw_point s_priv_data;
2819
2820 ENTER();
2821
2822 if (!capable(CAP_NET_ADMIN))
2823 {
2824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2825 FL("permission check failed"));
2826 return -EPERM;
2827 }
2828
2829 pAdapter = (netdev_priv(dev));
2830 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2831 ret = wlan_hdd_validate_context(pHddCtx);
2832 if (0 != ret)
2833 {
2834 return ret;
2835 }
2836
2837 if (!pHddCtx->is_ap_mode_wow_supported)
2838 {
2839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2840 "%s: Not supported",__func__);
2841 return -ENOTSUPP;
2842 }
2843
2844 /* helper function to get iwreq_data with compat handling. */
2845 if (hdd_priv_get_data(&s_priv_data, wrqu))
2846 {
2847 return -EINVAL;
2848 }
2849
2850 /* make sure all params are correctly passed to function */
2851 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2852 {
2853 return -EINVAL;
2854 }
2855
2856 sub_cmd = s_priv_data.flags;
2857
2858 /* ODD number is used for set, copy data using copy_from_user */
2859 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2860 s_priv_data.length);
2861 if (NULL == pBuffer)
2862 {
2863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2864 "mem_alloc_copy_from_user_helper fail");
2865 return -ENOMEM;
2866 }
2867
2868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2869 "%s: Received length %d", __func__, s_priv_data.length);
2870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2871 "%s: Received data %s", __func__, pBuffer);
2872
2873 switch(sub_cmd)
2874 {
2875 case WE_WOWL_ADD_PTRN:
2876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2877 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2878 if (!ret)
2879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2880 "Failed to add pattern :%d", ret);
2881 break;
2882 case WE_WOWL_DEL_PTRN:
2883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2884 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2885 if (!ret)
2886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2887 "Failed to del pattern :%d", ret);
2888 break;
2889 default:
2890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2891 ret = -EINVAL;
2892 break;
2893 }
2894
2895 kfree(pBuffer);
2896 return ret;
2897}
2898
2899int
2900static iw_softap_setchar_getnone(struct net_device *dev,
2901 struct iw_request_info *info,
2902 union iwreq_data *wrqu, char *extra)
2903{
2904 int ret;
2905
2906 vos_ssr_protect(__func__);
2907 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2908 vos_ssr_unprotect(__func__);
2909
2910 return ret;
2911}
2912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913/* Usage:
2914 BLACK_LIST = 0
2915 WHITE_LIST = 1
2916 ADD MAC = 0
2917 REMOVE MAC = 1
2918
2919 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2920 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2921 while using this ioctl
2922
2923 Syntax:
2924 iwpriv softap.0 modify_acl
2925 <6 octet mac addr> <list type> <cmd type>
2926
2927 Examples:
2928 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2929 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2930 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2931 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2932*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302933int __iw_softap_modify_acl(struct net_device *dev,
2934 struct iw_request_info *info,
2935 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002936{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302937 hdd_adapter_t *pHostapdAdapter;
2938 v_CONTEXT_t pVosContext;
2939 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 v_BYTE_t *value = (v_BYTE_t*)extra;
2941 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2942 int listType, cmd, i;
2943 int ret = 0; /* success */
2944
2945 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302946 pHostapdAdapter = (netdev_priv(dev));
2947 if (NULL == pHostapdAdapter)
2948 {
2949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2950 "%s: Adapter is NULL",__func__);
2951 return -EINVAL;
2952 }
2953 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2954 ret = wlan_hdd_validate_context(pHddCtx);
2955 if (0 != ret)
2956 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302957 return ret;
2958 }
2959 pVosContext = pHddCtx->pvosContext;
2960 if (NULL == pVosContext)
2961 {
2962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2963 "%s: Vos Context is NULL",__func__);
2964 return -EINVAL;
2965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2967 {
2968 pPeerStaMac[i] = *(value+i);
2969 }
2970 listType = (int)(*(value+i));
2971 i++;
2972 cmd = (int)(*(value+i));
2973
Arif Hussain24bafea2013-11-15 15:10:03 -08002974 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2975 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002976
2977 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2978 != VOS_STATUS_SUCCESS)
2979 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002980 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 ret = -EIO;
2982 }
2983 EXIT();
2984 return ret;
2985}
2986
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302987int iw_softap_modify_acl(struct net_device *dev,
2988 struct iw_request_info *info,
2989 union iwreq_data *wrqu, char *extra)
2990{
2991 int ret;
2992
2993 vos_ssr_protect(__func__);
2994 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2995 vos_ssr_unprotect(__func__);
2996
2997 return ret;
2998}
2999
Jeff Johnson295189b2012-06-20 16:38:30 -07003000int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303001static __iw_softap_getchannel(struct net_device *dev,
3002 struct iw_request_info *info,
3003 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003004{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303005 hdd_adapter_t *pHostapdAdapter;
3006 hdd_context_t *pHddCtx;
3007 int ret = 0;
3008 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303009
3010 ENTER();
3011
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303012 pHostapdAdapter = (netdev_priv(dev));
3013 if (NULL == pHostapdAdapter)
3014 {
3015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3016 "%s: Adapter is NULL",__func__);
3017 return -EINVAL;
3018 }
3019 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3020 ret = wlan_hdd_validate_context(pHddCtx);
3021 if (0 != ret)
3022 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303023 return ret;
3024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
Mukul Sharma6d0762c2015-03-05 17:13:47 +05303026 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003027
Jeff Johnson43971f52012-07-17 12:26:56 -07003028 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303029
3030 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 return 0;
3032}
3033
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303034
Jeff Johnsone7245742012-09-05 17:12:55 -07003035int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303036static iw_softap_getchannel(struct net_device *dev,
3037 struct iw_request_info *info,
3038 union iwreq_data *wrqu, char *extra)
3039{
3040 int ret;
3041
3042 vos_ssr_protect(__func__);
3043 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
3044 vos_ssr_unprotect(__func__);
3045
3046 return ret;
3047}
3048
3049int
3050static __iw_softap_set_max_tx_power(struct net_device *dev,
3051 struct iw_request_info *info,
3052 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07003053{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303054 hdd_adapter_t *pHostapdAdapter;
3055 tHalHandle hHal;
3056 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07003057 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303058 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003059 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3060 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3061
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303062 ENTER();
3063
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303064 pHostapdAdapter = (netdev_priv(dev));
3065 if (NULL == pHostapdAdapter)
3066 {
3067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3068 "%s: Adapter is NULL",__func__);
3069 return -EINVAL;
3070 }
3071 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3072 ret = wlan_hdd_validate_context(pHddCtx);
3073 if (0 != ret)
3074 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303075 return ret;
3076 }
3077 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3078 if (NULL == hHal)
3079 {
3080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3081 "%s: Hal Context is NULL",__func__);
3082 return -EINVAL;
3083 }
schang86c22c42013-03-13 18:41:24 -07003084 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07003085 return -ENOMEM;
3086
Leo Changd37675a2013-08-01 13:19:45 -07003087 /* Assign correct slef MAC address */
3088 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
3089 VOS_MAC_ADDR_SIZE);
3090 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
3091 VOS_MAC_ADDR_SIZE);
3092
schang86c22c42013-03-13 18:41:24 -07003093 set_value = value[0];
3094 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
3095 {
3096 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003097 __func__);
schang86c22c42013-03-13 18:41:24 -07003098 return -EIO;
3099 }
3100
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303101 EXIT();
schang86c22c42013-03-13 18:41:24 -07003102 return 0;
3103}
3104
3105int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303106static iw_softap_set_max_tx_power(struct net_device *dev,
3107 struct iw_request_info *info,
3108 union iwreq_data *wrqu, char *extra)
3109{
3110 int ret;
3111
3112 vos_ssr_protect(__func__);
3113 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
3114 vos_ssr_unprotect(__func__);
3115
3116 return ret;
3117}
3118
3119
3120int
3121static __iw_display_data_path_snapshot(struct net_device *dev,
3122 struct iw_request_info *info,
3123 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303124{
3125
3126 /* Function intitiating dumping states of
3127 * HDD(WMM Tx Queues)
3128 * TL State (with Per Client infor)
3129 * DXE Snapshot (Called at the end of TL Snapshot)
3130 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303131 hdd_adapter_t *pHostapdAdapter;
3132 hdd_context_t *pHddCtx;
3133 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303134
3135 ENTER();
3136
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303137 pHostapdAdapter = (netdev_priv(dev));
3138 if (NULL == pHostapdAdapter)
3139 {
3140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3141 "%s: Adapter is NULL",__func__);
3142 return -EINVAL;
3143 }
3144 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3145 ret = wlan_hdd_validate_context(pHddCtx);
3146 if (0 != ret)
3147 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303148 return ret;
3149 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303150 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05303151 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303152
3153 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303154 return 0;
3155}
3156
3157int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303158static iw_display_data_path_snapshot(struct net_device *dev,
3159 struct iw_request_info *info,
3160 union iwreq_data *wrqu, char *extra)
3161{
3162 int ret;
3163
3164 vos_ssr_protect(__func__);
3165 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
3166 vos_ssr_unprotect(__func__);
3167
3168 return ret;
3169}
3170
3171int
3172static __iw_softap_set_tx_power(struct net_device *dev,
3173 struct iw_request_info *info,
3174 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07003175{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303176 hdd_adapter_t *pHostapdAdapter;
3177 hdd_context_t *pHddCtx;
3178 v_CONTEXT_t pVosContext;
3179 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07003180 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303181 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07003182 ptSapContext pSapCtx = NULL;
3183
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303184 ENTER();
3185
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303186 pHostapdAdapter = (netdev_priv(dev));
3187 if (NULL == pHostapdAdapter)
3188 {
3189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3190 "%s: Adapter is NULL",__func__);
3191 return -EINVAL;
3192 }
3193 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3194 ret = wlan_hdd_validate_context(pHddCtx);
3195 if (0 != ret)
3196 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303197 return ret;
3198 }
3199 pVosContext = pHddCtx->pvosContext;
3200 if (NULL == pVosContext)
3201 {
3202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3203 "%s: Vos Context is NULL",__func__);
3204 return -EINVAL;
3205 }
3206 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3207 if (NULL == hHal)
3208 {
3209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3210 "%s: Hal Context is NULL",__func__);
3211 return -EINVAL;
3212 }
schang86c22c42013-03-13 18:41:24 -07003213 if (NULL == value)
3214 return -ENOMEM;
3215
3216 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3217 if (NULL == pSapCtx)
3218 {
3219 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3220 "%s: Invalid SAP pointer from pvosGCtx", __func__);
3221 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003222 }
3223
3224 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07003225 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07003226 {
schang86c22c42013-03-13 18:41:24 -07003227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07003228 __func__);
3229 return -EIO;
3230 }
3231
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303232 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07003233 return 0;
3234}
3235
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303236int
3237static iw_softap_set_tx_power(struct net_device *dev,
3238 struct iw_request_info *info,
3239 union iwreq_data *wrqu, char *extra)
3240{
3241 int ret;
3242
3243 vos_ssr_protect(__func__);
3244 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
3245 vos_ssr_unprotect(__func__);
3246
3247 return ret;
3248}
3249
Kiet Lambcf38522013-10-26 18:28:27 +05303250/**---------------------------------------------------------------------------
3251
3252 \brief iw_softap_set_trafficmonitor() -
3253 This function dynamically enable/disable traffic monitor functonality
3254 the command iwpriv wlanX setTrafficMon <value>.
3255
3256 \param - dev - Pointer to the net device.
3257 - addr - Pointer to the sockaddr.
3258 \return - 0 for success, non zero for failure
3259
3260 --------------------------------------------------------------------------*/
3261
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303262static int __iw_softap_set_trafficmonitor(struct net_device *dev,
3263 struct iw_request_info *info,
3264 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05303265{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303266 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05303267 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05303268 hdd_context_t *pHddCtx;
3269 int status;
3270
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303271 ENTER();
3272
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303273 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05303274 if (NULL == pAdapter)
3275 {
3276 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3277 "%s: HDD adapter is Null", __func__);
3278 return -ENODEV;
3279 }
3280
3281 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3282
3283 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05303284 if (0 != status)
3285 {
Kiet Lambcf38522013-10-26 18:28:27 +05303286 return status;
3287 }
3288
3289 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
3290
3291 if (NULL == isSetTrafficMon)
3292 {
3293 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3294 "%s: Invalid SAP pointer from extra", __func__);
3295 return -ENOMEM;
3296 }
3297
3298 if (TRUE == *isSetTrafficMon)
3299 {
3300 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303301 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303302 {
3303 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3304 "%s: failed to Start Traffic Monitor timer ", __func__ );
3305 return -EIO;
3306 }
3307 }
3308 else if (FALSE == *isSetTrafficMon)
3309 {
3310 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303311 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303312 {
3313 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3314 "%s: failed to Stop Traffic Monitor timer ", __func__ );
3315 return -EIO;
3316 }
3317
3318 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303319
3320 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05303321 return 0;
3322}
3323
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303324static int iw_softap_set_trafficmonitor(struct net_device *dev,
3325 struct iw_request_info *info,
3326 union iwreq_data *wrqu, char *extra)
3327{
3328 int ret;
3329
3330 vos_ssr_protect(__func__);
3331 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
3332 vos_ssr_unprotect(__func__);
3333
3334 return ret;
3335}
3336
Jeff Johnson295189b2012-06-20 16:38:30 -07003337#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
3338
3339int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303340static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
3341 struct iw_request_info *info,
3342 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003343{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303344 hdd_adapter_t *pHostapdAdapter;
3345 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303346 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07003347 char *buf;
3348 int cnt = 0;
3349 int left;
3350 int ret = 0;
3351 /* maclist_index must be u32 to match userspace */
3352 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303353 v_CONTEXT_t pVosContext = NULL;
3354 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303356 ENTER();
3357
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303358 pHostapdAdapter = (netdev_priv(dev));
3359 if (NULL == pHostapdAdapter)
3360 {
3361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3362 "%s: Adapter is NULL",__func__);
3363 return -EINVAL;
3364 }
3365 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3366 ret = wlan_hdd_validate_context(pHddCtx);
3367 if (0 != ret)
3368 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303369 return ret;
3370 }
3371
Jeff Johnson224f3702014-03-26 11:09:47 -07003372 /*
3373 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
3374 * number, and even numbered iocts are supposed to have "set"
3375 * semantics. Hence the wireless extensions support in the kernel
3376 * won't correctly copy the result to userspace, so the ioctl
3377 * handler itself must copy the data. Output format is 32-bit
3378 * record length, followed by 0 or more 6-byte STA MAC addresses.
3379 *
3380 * Further note that due to the incorrect semantics, the "iwpriv"
3381 * userspace application is unable to correctly invoke this API,
3382 * hence it is not registered in the hostapd_private_args. This
3383 * API can only be invoked by directly invoking the ioctl() system
3384 * call.
3385 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003386
Jeff Johnson224f3702014-03-26 11:09:47 -07003387 /* make sure userspace allocated a reasonable buffer size */
3388 if (wrqu->data.length < sizeof(maclist_index)) {
3389 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
3390 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07003391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003392
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303393 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3394 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3395 if(pSapCtx == NULL){
3396 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3397 FL("psapCtx is NULL"));
3398 return -EFAULT;
3399 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05303400
3401 /* allocate local buffer to build the response */
3402 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
3403 if (!buf) {
3404 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
3405 return -ENOMEM;
3406 }
3407
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303408 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07003409 /* start indexing beyond where the record count will be written */
3410 maclist_index = sizeof(maclist_index);
3411 left = wrqu->data.length - maclist_index;
3412
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303413 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003414 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
3415 if ((pStaInfo[cnt].isUsed) &&
3416 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
3417 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
3418 VOS_MAC_ADDR_SIZE);
3419 maclist_index += VOS_MAC_ADDR_SIZE;
3420 left -= VOS_MAC_ADDR_SIZE;
3421 }
3422 cnt++;
3423 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303424 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003425
3426 *((u32 *)buf) = maclist_index;
3427 wrqu->data.length = maclist_index;
3428 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
3429 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
3430 ret = -EFAULT;
3431 }
3432 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303433
3434 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07003435 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003436}
3437
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303438int
3439static iw_softap_getassoc_stamacaddr(struct net_device *dev,
3440 struct iw_request_info *info,
3441 union iwreq_data *wrqu, char *extra)
3442{
3443 int ret;
3444
3445 vos_ssr_protect(__func__);
3446 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
3447 vos_ssr_unprotect(__func__);
3448
3449 return ret;
3450}
3451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452/* Usage:
3453 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3454 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3455 while using this ioctl
3456
3457 Syntax:
3458 iwpriv softap.0 disassoc_sta <6 octet mac address>
3459
3460 e.g.
3461 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
3462 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
3463*/
3464
3465int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303466static __iw_softap_disassoc_sta(struct net_device *dev,
3467 struct iw_request_info *info,
3468 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003469{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303470 hdd_adapter_t *pHostapdAdapter;
3471 hdd_context_t *pHddCtx;
3472 v_U8_t *peerMacAddr;
3473 int ret = 0;
3474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05303476
3477 if (!capable(CAP_NET_ADMIN)) {
3478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3479 FL("permission check failed"));
3480 return -EPERM;
3481 }
3482
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303483 pHostapdAdapter = (netdev_priv(dev));
3484 if (NULL == pHostapdAdapter)
3485 {
3486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3487 "%s: Adapter is NULL",__func__);
3488 return -EINVAL;
3489 }
3490 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3491 ret = wlan_hdd_validate_context(pHddCtx);
3492 if (0 != ret)
3493 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303494 return ret;
3495 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303496 /* iwpriv tool or framework calls this ioctl with
3497 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303499 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003500
Arif Hussain24bafea2013-11-15 15:10:03 -08003501 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
3502 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
3504 EXIT();
3505 return 0;
3506}
3507
3508int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303509static iw_softap_disassoc_sta(struct net_device *dev,
3510 struct iw_request_info *info,
3511 union iwreq_data *wrqu, char *extra)
3512{
3513 int ret;
3514
3515 vos_ssr_protect(__func__);
3516 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3517 vos_ssr_unprotect(__func__);
3518
3519 return ret;
3520}
3521
3522int
3523static __iw_softap_ap_stats(struct net_device *dev,
3524 struct iw_request_info *info,
3525 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003526{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303527 hdd_adapter_t *pHostapdAdapter;
3528 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 WLANTL_TRANSFER_STA_TYPE statBuffer;
3530 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303531 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303533 ENTER();
3534
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303535 pHostapdAdapter = (netdev_priv(dev));
3536 if (NULL == pHostapdAdapter)
3537 {
3538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3539 "%s: Adapter is NULL",__func__);
3540 return -EINVAL;
3541 }
3542 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3543 ret = wlan_hdd_validate_context(pHddCtx);
3544 if (0 != ret)
3545 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303546 return ret;
3547 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003548 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003549 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3550 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303552 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003553 if(NULL == pstatbuf) {
3554 hddLog(LOG1, "unable to allocate memory");
3555 return -ENOMEM;
3556 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303557
3558 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003559 "RUF=%d RMF=%d RBF=%d "
3560 "RUB=%d RMB=%d RBB=%d "
3561 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303562 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003563 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3564 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3565 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3566 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3567 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3568 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003569
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303570 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003571 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3572 kfree(pstatbuf);
3573 return -EFAULT;
3574 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303575
3576 strlcpy(extra, pstatbuf, len);
3577 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003578 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303579
3580 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 return 0;
3582}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303583int
3584static __iw_softap_ap_get_stats(struct net_device *dev,
3585 struct iw_request_info *info,
3586 union iwreq_data *wrqu, char *extra)
3587{
3588 hdd_adapter_t *pAdapter;
3589 hdd_tx_rx_stats_t *pStats;
3590
3591 ENTER();
3592 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3593 if (NULL == pAdapter)
3594 {
3595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3596 "%s: Adapter is NULL",__func__);
3597 return -EINVAL;
3598 }
3599
3600 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3601 snprintf(extra, QCSAP_MAX_STR_LEN,
3602 "\nTransmit"
3603 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3604 "\n dropped BK %u, BE %u, VI %u, VO %u"
3605 "\n classified BK %u, BE %u, VI %u, VO %u"
3606 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3607 "\n queued BK %u, BE %u, VI %u, VO %u"
3608 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3609 "\ndequeued %u, depressured %u, deque-depressured %u,\
3610 completed %u, flushed %u"
3611 "\n fetched BK %u, BE %u, VI %u, VO %u"
3612 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3613 "\n depressured BK %u, BE %u, VI %u, VO %u"
3614 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3615 "\n flushed BK %u, BE %u, VI %u, VO %u"
3616 "\n\nReceive"
3617 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3618 "\n\nResetsStats"
3619 "\n",
3620 pStats->txXmitCalled,
3621 pStats->txXmitDropped,
3622 pStats->txXmitBackPressured,
3623 pStats->txXmitQueued,
3624
3625 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3626 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3627 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3628 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3629
3630 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3631 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3632 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3633 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3634
3635 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3636 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3637 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3638 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3639
3640 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3641 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3642 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3643 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3644
3645 pStats->txFetched,
3646 pStats->txFetchEmpty,
3647 pStats->txFetchLowResources,
3648 pStats->txFetchDequeueError,
3649
3650 pStats->txFetchDequeued,
3651 pStats->txFetchDePressured,
3652 pStats->txDequeDePressured,
3653 pStats->txCompleted,
3654 pStats->txFlushed,
3655
3656 pStats->txFetchedAC[WLANTL_AC_BK],
3657 pStats->txFetchedAC[WLANTL_AC_BE],
3658 pStats->txFetchedAC[WLANTL_AC_VI],
3659 pStats->txFetchedAC[WLANTL_AC_VO],
3660
3661 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3662 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3663 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3664 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3665
3666 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3667 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3668 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3669 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3670
3671 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3672 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3673 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3674 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3675
3676 pStats->txFlushedAC[WLANTL_AC_BK],
3677 pStats->txFlushedAC[WLANTL_AC_BE],
3678 pStats->txFlushedAC[WLANTL_AC_VI],
3679 pStats->txFlushedAC[WLANTL_AC_VO],
3680
3681 pStats->rxChains,
3682 pStats->rxPackets,
3683 pStats->rxDropped,
3684 pStats->rxDelivered,
3685 pStats->rxRefused
3686 );
3687
3688 wrqu->data.length = strlen(extra) + 1;
3689
3690 return 0;
3691}
3692
3693int
3694static __iw_softap_ap_clear_stats(struct net_device *dev,
3695 struct iw_request_info *info,
3696 union iwreq_data *wrqu, char *extra)
3697{
3698 hdd_adapter_t *pAdapter;
3699
3700 ENTER();
3701
3702 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3703 if (NULL == pAdapter)
3704 {
3705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3706 "%s: Adapter is NULL",__func__);
3707 return -EINVAL;
3708 }
3709
3710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3711 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3712 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3713 return 0;
3714}
3715
3716
3717int
3718static iw_softap_get_stats(struct net_device *dev,
3719 struct iw_request_info *info,
3720 union iwreq_data *wrqu, char *extra)
3721{
3722 int ret;
3723 vos_ssr_protect(__func__);
3724 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3725 vos_ssr_unprotect(__func__);
3726 return ret;
3727}
3728
3729int
3730static iw_softap_clear_stats(struct net_device *dev,
3731 struct iw_request_info *info,
3732 union iwreq_data *wrqu, char *extra)
3733{
3734 int ret;
3735 vos_ssr_protect(__func__);
3736 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3737 vos_ssr_unprotect(__func__);
3738 return ret;
3739}
Jeff Johnson295189b2012-06-20 16:38:30 -07003740
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303741int
3742static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 struct iw_request_info *info,
3744 union iwreq_data *wrqu, char *extra)
3745{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303746 int ret;
3747
3748 vos_ssr_protect(__func__);
3749 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3750 vos_ssr_unprotect(__func__);
3751
3752 return ret;
3753}
3754
Manjeet Singh3ed79242017-01-11 19:04:32 +05303755/**
3756 * __iw_softap_get_three() - return three value to upper layer.
3757 *
3758 * @dev: pointer of net_device of this wireless card
3759 * @info: meta data about Request sent
3760 * @wrqu: include request info
3761 * @extra: buf used for in/out
3762 *
3763 * Return: execute result
3764 */
3765static int __iw_softap_get_three(struct net_device *dev,
3766 struct iw_request_info *info,
3767 union iwreq_data *wrqu, char *extra)
3768{
3769 uint32_t *value = (uint32_t *)extra;
3770 uint32_t sub_cmd = value[0];
3771 int ret = 0; /* success */
3772
3773 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3774
3775 switch (sub_cmd) {
3776 case QCSAP_IOCTL_GET_TSF:
3777 ret = hdd_indicate_tsf(padapter, value, 3);
3778 break;
3779 default:
3780 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3781 break;
3782 }
3783 return ret;
3784}
3785
3786
3787/**
3788 * iw_softap_get_three() - return three value to upper layer.
3789 *
3790 * @dev: pointer of net_device of this wireless card
3791 * @info: meta data about Request sent
3792 * @wrqu: include request info
3793 * @extra: buf used for in/Output
3794 *
3795 * Return: execute result
3796 */
3797static int iw_softap_get_three(struct net_device *dev,
3798 struct iw_request_info *info,
3799 union iwreq_data *wrqu, char *extra)
3800{
3801 int ret;
3802
3803 vos_ssr_protect(__func__);
3804 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3805 vos_ssr_unprotect(__func__);
3806
3807 return ret;
3808}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303809static int __iw_softap_set_channel_range(struct net_device *dev,
3810 struct iw_request_info *info,
3811 union iwreq_data *wrqu, char *extra)
3812{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303813 hdd_adapter_t *pHostapdAdapter;
3814 tHalHandle hHal;
3815 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 int *value = (int *)extra;
3817 int startChannel = value[0];
3818 int endChannel = value[1];
3819 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003820 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 int ret = 0; /* success */
3822
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303823 ENTER();
3824
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303825 if (!capable(CAP_NET_ADMIN))
3826 {
3827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3828 FL("permission check failed"));
3829 return -EPERM;
3830 }
3831
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303832 pHostapdAdapter = (netdev_priv(dev));
3833 if (NULL == pHostapdAdapter)
3834 {
3835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3836 "%s: Adapter is NULL",__func__);
3837 return -EINVAL;
3838 }
3839 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3840 ret = wlan_hdd_validate_context(pHddCtx);
3841 if (0 != ret)
3842 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303843 return ret;
3844 }
3845 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3846 if (NULL == hHal)
3847 {
3848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3849 "%s: Hal Context is NULL",__func__);
3850 return -EINVAL;
3851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3853 if(status != VOS_STATUS_SUCCESS)
3854 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003855 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 startChannel,endChannel, band);
3857 ret = -EINVAL;
3858 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003859
3860 pHddCtx->is_dynamic_channel_range_set = 1;
3861
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303862 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 return ret;
3864}
3865
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303866static int iw_softap_set_channel_range(struct net_device *dev,
3867 struct iw_request_info *info,
3868 union iwreq_data *wrqu, char *extra)
3869{
3870 int ret;
3871
3872 vos_ssr_protect(__func__);
3873 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3874 vos_ssr_unprotect(__func__);
3875
3876 return ret;
3877}
3878
3879
3880int __iw_softap_get_channel_list(struct net_device *dev,
3881 struct iw_request_info *info,
3882 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003883{
3884 v_U32_t num_channels = 0;
3885 v_U8_t i = 0;
3886 v_U8_t bandStartChannel = RF_CHAN_1;
3887 v_U8_t bandEndChannel = RF_CHAN_165;
3888 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303889 hdd_adapter_t *pHostapdAdapter;
3890 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003893 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303894 hdd_context_t *pHddCtx;
3895 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303896
3897 ENTER();
3898
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303899 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3900 if (NULL == pHostapdAdapter)
3901 {
3902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3903 "%s: Adapter is NULL",__func__);
3904 return -EINVAL;
3905 }
3906 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3907 ret = wlan_hdd_validate_context(pHddCtx);
3908 if (0 != ret)
3909 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303910 return ret;
3911 }
3912 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3913 if (NULL == hHal)
3914 {
3915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3916 "%s: Hal Context is NULL",__func__);
3917 return -EINVAL;
3918 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003919 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3920 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003921 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003922 return -EIO;
3923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 wrqu->data.length = sizeof(tChannelListInfo);
3925 ENTER();
3926
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003927 if (eCSR_BAND_24 == curBand)
3928 {
3929 bandStartChannel = RF_CHAN_1;
3930 bandEndChannel = RF_CHAN_14;
3931 }
3932 else if (eCSR_BAND_5G == curBand)
3933 {
3934 bandStartChannel = RF_CHAN_36;
3935 bandEndChannel = RF_CHAN_165;
3936 }
3937
Arif Hussain6d2a3322013-11-17 19:50:10 -08003938 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303939 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003940 bandStartChannel, bandEndChannel );
3941
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3943 {
3944 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3945 {
3946 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3947 num_channels++;
3948 }
3949 }
3950
3951 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3952
3953 temp_num_channels = num_channels;
3954
3955 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3956 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303957 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003958 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 }
3960
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303961 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3962 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 {
3964 for(i = 0; i < temp_num_channels; i++)
3965 {
3966
3967 if((channel_list->channels[i] > 35) &&
3968 (channel_list->channels[i] < 49))
3969 {
3970 vos_mem_move(&channel_list->channels[i],
3971 &channel_list->channels[i+1],
3972 temp_num_channels - (i-1));
3973 num_channels--;
3974 temp_num_channels--;
3975 i--;
3976 }
3977 }
3978 }
3979
Arif Hussain6d2a3322013-11-17 19:50:10 -08003980 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 channel_list->num_channels = num_channels;
3983 EXIT();
3984
3985 return 0;
3986}
3987
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303988int iw_softap_get_channel_list(struct net_device *dev,
3989 struct iw_request_info *info,
3990 union iwreq_data *wrqu, char *extra)
3991{
3992 int ret;
3993
3994 vos_ssr_protect(__func__);
3995 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3996 vos_ssr_unprotect(__func__);
3997
3998 return ret;
3999}
4000
4001static
4002int __iw_get_genie(struct net_device *dev,
4003 struct iw_request_info *info,
4004 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004005{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304006 hdd_adapter_t *pHostapdAdapter;
4007 hdd_context_t *pHddCtx;
4008 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304009 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
4011 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304012 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304013
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304015
4016 pHostapdAdapter = (netdev_priv(dev));
4017 if (NULL == pHostapdAdapter)
4018 {
4019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4020 "%s: Adapter is NULL",__func__);
4021 return -EINVAL;
4022 }
4023 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4024 ret = wlan_hdd_validate_context(pHddCtx);
4025 if (0 != ret)
4026 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304027 return ret;
4028 }
4029 pVosContext = pHddCtx->pvosContext;
4030 if (NULL == pVosContext)
4031 {
4032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4033 "%s: vos context is not valid ",__func__);
4034 return -EINVAL;
4035 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004036 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
4038 status = WLANSap_getstationIE_information(pVosContext,
4039 &length,
4040 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05304041
4042 if (VOS_STATUS_SUCCESS != status) {
4043 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07004044 return -EFAULT;
4045 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05304046
Arif Hussained667642013-10-27 23:01:14 -07004047 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304048 if (length > DOT11F_IE_RSN_MAX_LEN) {
4049 hddLog(LOGE,
4050 FL("invalid buffer length length:%d"), length);
4051 return -E2BIG;
4052 }
4053
4054 vos_mem_copy(extra, genIeBytes, length);
4055
4056 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
4057
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 EXIT();
4059 return 0;
4060}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304061
4062static
4063int iw_get_genie(struct net_device *dev,
4064 struct iw_request_info *info,
4065 union iwreq_data *wrqu, char *extra)
4066{
4067 int ret;
4068
4069 vos_ssr_protect(__func__);
4070 ret = __iw_get_genie(dev, info, wrqu, extra);
4071 vos_ssr_unprotect(__func__);
4072
4073 return ret;
4074}
4075
4076static
4077int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4078 struct iw_request_info *info,
4079 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004080{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304081 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07004082 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304083 hdd_ap_ctx_t *pHddApCtx;
4084 hdd_context_t *pHddCtx;
4085 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304086
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07004088
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304089 pHostapdAdapter = (netdev_priv(dev));
4090 if (NULL == pHostapdAdapter)
4091 {
4092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4093 "%s: Adapter is NULL",__func__);
4094 return -EINVAL;
4095 }
4096 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4097 ret = wlan_hdd_validate_context(pHddCtx);
4098 if (0 != ret)
4099 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304100 return ret;
4101 }
4102 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4103 if (NULL == pHddApCtx)
4104 {
4105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4106 "%s: AP context is NULL",__func__);
4107 return -EINVAL;
4108 }
4109
Arif Hussain6d2a3322013-11-17 19:50:10 -08004110 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07004111 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
4112
4113 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
4114 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
4115 pHddApCtx->WPSPBCProbeReq.probeReqIE,
4116 WPSPBCProbeReqIEs.probeReqIELen);
4117 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
4118 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
4119 sizeof(v_MACADDR_t));
4120 if (copy_to_user(wrqu->data.pointer,
4121 (void *)&WPSPBCProbeReqIEs,
4122 sizeof(WPSPBCProbeReqIEs)))
4123 {
4124 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4125 return -EFAULT;
4126 }
4127 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004128 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07004129 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 up(&pHddApCtx->semWpsPBCOverlapInd);
4131 EXIT();
4132 return 0;
4133}
4134
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304135static
4136int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4137 struct iw_request_info *info,
4138 union iwreq_data *wrqu, char *extra)
4139{
4140 int ret;
4141
4142 vos_ssr_protect(__func__);
4143 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
4144 vos_ssr_unprotect(__func__);
4145
4146 return ret;
4147}
4148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149/**---------------------------------------------------------------------------
4150
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304151 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 This function sets the auth type received from the wpa_supplicant.
4153
4154 \param - dev - Pointer to the net device.
4155 - info - Pointer to the iw_request_info.
4156 - wrqu - Pointer to the iwreq_data.
4157 - extra - Pointer to the data.
4158 \return - 0 for success, non zero for failure
4159
4160 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304161int __iw_set_auth_hostap(struct net_device *dev,
4162 struct iw_request_info *info,
4163 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004164{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304165 hdd_adapter_t *pAdapter;
4166 hdd_context_t *pHddCtx;
4167 hdd_wext_state_t *pWextState;
4168 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304169
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304171
4172 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4173 if (NULL == pAdapter)
4174 {
4175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4176 "%s: Adapter is NULL",__func__);
4177 return -EINVAL;
4178 }
4179
4180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4181 ret = wlan_hdd_validate_context(pHddCtx);
4182 if (0 != ret)
4183 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304184 return ret;
4185 }
4186 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4187 if (NULL == pWextState)
4188 {
4189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4190 "%s: pWextState is NULL",__func__);
4191 return -EINVAL;
4192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 switch(wrqu->param.flags & IW_AUTH_INDEX)
4194 {
4195 case IW_AUTH_TKIP_COUNTERMEASURES:
4196 {
4197 if(wrqu->param.value) {
4198 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4199 "Counter Measure started %d", wrqu->param.value);
4200 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304201 }
4202 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4204 "Counter Measure stopped=%d", wrqu->param.value);
4205 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4206 }
4207
4208 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
4209 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304214
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004215 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 wrqu->param.flags & IW_AUTH_INDEX);
4217 break;
4218 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304219
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 EXIT();
4221 return 0;
4222}
4223
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304224int iw_set_auth_hostap(struct net_device *dev,
4225 struct iw_request_info *info,
4226 union iwreq_data *wrqu,char *extra)
4227{
4228 int ret;
4229
4230 vos_ssr_protect(__func__);
4231 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
4232 vos_ssr_unprotect(__func__);
4233
4234 return ret;
4235}
4236
4237static int __iw_set_ap_encodeext(struct net_device *dev,
4238 struct iw_request_info *info,
4239 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004240{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304241 hdd_adapter_t *pHostapdAdapter;
4242 v_CONTEXT_t pVosContext;
4243 hdd_context_t *pHddCtx;
4244 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07004245 int retval = 0;
4246 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4248 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4249 int key_index;
4250 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304251 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07004252// tCsrRoamRemoveKey RemoveKey;
4253 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304254
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304255 ENTER();
4256 pHostapdAdapter = (netdev_priv(dev));
4257 if (NULL == pHostapdAdapter)
4258 {
4259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4260 "%s: Adapter is NULL",__func__);
4261 return -EINVAL;
4262 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004263
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304264 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4265 retval = wlan_hdd_validate_context(pHddCtx);
4266 if (0 != retval)
4267 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304268 return retval;
4269 }
4270 pVosContext = pHddCtx->pvosContext;
4271 if (NULL == pVosContext)
4272 {
4273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4274 "%s: pVosContext is NULL",__func__);
4275 return -EINVAL;
4276 }
4277 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4278 if (NULL == pHddApCtx)
4279 {
4280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4281 "%s: AP Context is NULL",__func__);
4282 return -EINVAL;
4283 }
4284
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304286
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304288
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 /*Convert from 1-based to 0-based keying*/
4290 key_index--;
4291 }
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304292 if(!ext->key_len || ext->key_len > CSR_MAX_KEY_LEN) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304293#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 /*Set the encrytion type to NONE*/
4295#if 0
4296 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4297#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304298
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 RemoveKey.keyId = key_index;
4300 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4301 /*Key direction for group is RX only*/
4302 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4303 }
4304 else {
4305 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4306 }
4307 switch(ext->alg)
4308 {
4309 case IW_ENCODE_ALG_NONE:
4310 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4311 break;
4312 case IW_ENCODE_ALG_WEP:
4313 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4314 break;
4315 case IW_ENCODE_ALG_TKIP:
4316 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07004317 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 case IW_ENCODE_ALG_CCMP:
4319 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
4320 break;
4321 default:
4322 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4323 break;
4324 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004325 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 -07004326 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004328 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 );
Jeff Johnson43971f52012-07-17 12:26:56 -07004330 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
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, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07004334 __LINE__, vstatus );
4335 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004337#endif
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304338 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004339
Jeff Johnson43971f52012-07-17 12:26:56 -07004340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004341
4342 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4343
4344 setKey.keyId = key_index;
4345 setKey.keyLength = ext->key_len;
4346
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304347 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004348
4349 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4350 /*Key direction for group is RX only*/
4351 setKey.keyDirection = eSIR_RX_ONLY;
4352 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4353 }
4354 else {
4355
4356 setKey.keyDirection = eSIR_TX_RX;
4357 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4358 }
4359 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4360 {
4361 setKey.keyDirection = eSIR_TX_DEFAULT;
4362 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4363 }
4364
4365 /*For supplicant pae role is zero*/
4366 setKey.paeRole = 0;
4367
4368 switch(ext->alg)
4369 {
4370 case IW_ENCODE_ALG_NONE:
4371 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4372 break;
4373
4374 case IW_ENCODE_ALG_WEP:
4375 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4376 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004377 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 break;
4379
4380 case IW_ENCODE_ALG_TKIP:
4381 {
4382 v_U8_t *pKey = &setKey.Key[0];
4383
4384 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4385
4386 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4387
4388 /*Supplicant sends the 32bytes key in this order
4389
4390 |--------------|----------|----------|
4391 | Tk1 |TX-MIC | RX Mic |
4392 |--------------|----------|----------|
4393 <---16bytes---><--8bytes--><--8bytes-->
4394
4395 */
4396 /*Sme expects the 32 bytes key to be in the below order
4397
4398 |--------------|----------|----------|
4399 | Tk1 |RX-MIC | TX Mic |
4400 |--------------|----------|----------|
4401 <---16bytes---><--8bytes--><--8bytes-->
4402 */
4403 /* Copy the Temporal Key 1 (TK1) */
4404 vos_mem_copy(pKey,ext->key,16);
4405
4406 /*Copy the rx mic first*/
4407 vos_mem_copy(&pKey[16],&ext->key[24],8);
4408
4409 /*Copy the tx mic */
4410 vos_mem_copy(&pKey[24],&ext->key[16],8);
4411
4412 }
4413 break;
4414
4415 case IW_ENCODE_ALG_CCMP:
4416 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4417 break;
4418
4419 default:
4420 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4421 break;
4422 }
4423
4424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304425 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 setKey.keyId);
4427 for(i=0; i< ext->key_len; i++)
4428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4429 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07004430
4431 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
4432 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 {
4434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07004435 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
4436 retval = -EINVAL;
4437 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304438
4439 EXIT();
4440 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004441}
Jeff Johnson43971f52012-07-17 12:26:56 -07004442
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304443static int iw_set_ap_encodeext(struct net_device *dev,
4444 struct iw_request_info *info,
4445 union iwreq_data *wrqu, char *extra)
4446{
4447 int ret;
4448
4449 vos_ssr_protect(__func__);
4450 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
4451 vos_ssr_unprotect(__func__);
4452
4453 return ret;
4454}
Jeff Johnson43971f52012-07-17 12:26:56 -07004455
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304456static int __iw_set_ap_mlme(struct net_device *dev,
4457 struct iw_request_info *info,
4458 union iwreq_data *wrqu,
4459 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004460{
4461#if 0
4462 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4463 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4464
4465 ENTER();
4466
4467 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4468 switch (mlme->cmd) {
4469 case IW_MLME_DISASSOC:
4470 case IW_MLME_DEAUTH:
4471 hddLog(LOG1, "Station disassociate");
4472 if( pAdapter->conn_info.connState == eConnectionState_Associated )
4473 {
4474 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4475
4476 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4477 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4478
4479 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
4480
4481 //clear all the reason codes
4482 if (status != 0)
4483 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004484 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 }
4486
4487 netif_stop_queue(dev);
4488 netif_carrier_off(dev);
4489 }
4490 else
4491 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004492 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 -07004493 }
4494 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004495 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 return -EINVAL;
4497 }//end of switch
4498 EXIT();
4499#endif
4500 return 0;
4501// return status;
4502}
4503
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304504static int iw_set_ap_mlme(struct net_device *dev,
4505 struct iw_request_info *info,
4506 union iwreq_data *wrqu,
4507 char *extra)
4508{
4509 int ret;
4510
4511 vos_ssr_protect(__func__);
4512 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4513 vos_ssr_unprotect(__func__);
4514
4515 return ret;
4516}
4517
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304518static int __iw_get_ap_rts_threshold(struct net_device *dev,
4519 struct iw_request_info *info,
4520 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004521{
4522 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4523 v_U32_t status = 0;
4524
4525 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4526
4527 return status;
4528}
4529
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304530static int iw_get_ap_rts_threshold(struct net_device *dev,
4531 struct iw_request_info *info,
4532 union iwreq_data *wrqu, char *extra)
4533{
4534 int ret;
4535
4536 vos_ssr_protect(__func__);
4537 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4538 vos_ssr_unprotect(__func__);
4539
4540 return ret;
4541}
4542
4543static int __iw_get_ap_frag_threshold(struct net_device *dev,
4544 struct iw_request_info *info,
4545 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004546{
4547 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4548 v_U32_t status = 0;
4549
4550 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4551
4552 return status;
4553}
4554
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304555static int iw_get_ap_frag_threshold(struct net_device *dev,
4556 struct iw_request_info *info,
4557 union iwreq_data *wrqu, char *extra)
4558{
4559 int ret;
4560
4561 vos_ssr_protect(__func__);
4562 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4563 vos_ssr_unprotect(__func__);
4564
4565 return ret;
4566}
4567
4568static int __iw_get_ap_freq(struct net_device *dev,
4569 struct iw_request_info *info,
4570 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004571{
Jeff Johnsone7245742012-09-05 17:12:55 -07004572 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304573 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 tHalHandle hHal;
4575 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304576 hdd_ap_ctx_t *pHddApCtx;
4577 hdd_context_t *pHddCtx;
4578 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004579
4580 ENTER();
4581
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304582 pHostapdAdapter = (netdev_priv(dev));
4583 if (NULL == pHostapdAdapter)
4584 {
4585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4586 "%s: Adapter is NULL",__func__);
4587 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304589 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4590 ret = wlan_hdd_validate_context(pHddCtx);
4591 if (0 != ret)
4592 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304593 return ret;
4594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304596 if (NULL == pHostapdState)
4597 {
4598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4599 "%s: pHostapdState is NULL",__func__);
4600 return -EINVAL;
4601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304603 if (NULL == hHal)
4604 {
4605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4606 "%s: Hal Context is NULL",__func__);
4607 return -EINVAL;
4608 }
4609 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4610 if (NULL == pHddApCtx)
4611 {
4612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4613 "%s: AP context is NULL",__func__);
4614 return -EINVAL;
4615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 if(pHostapdState->bssState == BSS_STOP )
4617 {
4618 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4619 != eHAL_STATUS_SUCCESS)
4620 {
c_hpothuffdb5272013-10-02 16:42:35 +05304621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4622 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 return -EIO;
4624 }
4625 else
4626 {
4627 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304628 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004629 {
4630 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4631 * iwlist & iwconfig command shows frequency into proper
4632 * format (2.412 GHz instead of 246.2 MHz)*/
4633 fwrq->m = freq;
4634 fwrq->e = MHZ;
4635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 }
4637 }
4638 else
4639 {
4640 channel = pHddApCtx->operatingChannel;
4641 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304642 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004643 {
4644 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4645 * iwlist & iwconfig command shows frequency into proper
4646 * format (2.412 GHz instead of 246.2 MHz)*/
4647 fwrq->m = freq;
4648 fwrq->e = MHZ;
4649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304651
4652 EXIT();
4653 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004654}
4655
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304656static int iw_get_ap_freq(struct net_device *dev,
4657 struct iw_request_info *info,
4658 struct iw_freq *fwrq, char *extra)
4659{
4660 int ret;
4661
4662 vos_ssr_protect(__func__);
4663 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4664 vos_ssr_unprotect(__func__);
4665
4666 return ret;
4667}
4668
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304669static int __iw_softap_stopbss(struct net_device *dev,
4670 struct iw_request_info *info,
4671 union iwreq_data *wrqu,
4672 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004673{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304674 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304676 hdd_context_t *pHddCtx = NULL;
4677
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304679 pHostapdAdapter = (netdev_priv(dev));
4680 if (NULL == pHostapdAdapter)
4681 {
4682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4683 "%s: Adapter is NULL",__func__);
4684 return -EINVAL;
4685 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304686 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4687 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304688 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304689 return status;
4690 }
4691
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304692 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +05304694 hdd_hostapd_state_t *pHostapdState =
4695 WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4696
4697 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4699 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304701
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304703 {
4704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004705 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 VOS_ASSERT(0);
4707 }
4708 }
4709 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304710 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 }
4712 EXIT();
4713 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4714}
4715
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304716static int iw_softap_stopbss(struct net_device *dev,
4717 struct iw_request_info *info,
4718 union iwreq_data *wrqu,
4719 char *extra)
4720{
4721 int ret;
4722
4723 vos_ssr_protect(__func__);
4724 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4725 vos_ssr_unprotect(__func__);
4726
4727 return ret;
4728}
4729
4730static int __iw_softap_version(struct net_device *dev,
4731 struct iw_request_info *info,
4732 union iwreq_data *wrqu,
4733 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004734{
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304736 hdd_context_t *pHddCtx;
4737 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304738
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304740 pHostapdAdapter = (netdev_priv(dev));
4741 if (NULL == pHostapdAdapter)
4742 {
4743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4744 "%s: Adapter is NULL",__func__);
4745 return -EINVAL;
4746 }
4747 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4748 ret = wlan_hdd_validate_context(pHddCtx);
4749 if (0 != ret)
4750 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304751 return ret;
4752 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004753 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 return 0;
4756}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004757
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304758static int iw_softap_version(struct net_device *dev,
4759 struct iw_request_info *info,
4760 union iwreq_data *wrqu,
4761 char *extra)
4762{
4763 int ret;
4764
4765 vos_ssr_protect(__func__);
4766 ret = __iw_softap_version(dev, info, wrqu, extra);
4767 vos_ssr_unprotect(__func__);
4768
4769 return ret;
4770}
4771
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304772int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004773{
4774 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004775 int len = 0;
4776 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304777 v_CONTEXT_t pVosContext;
4778 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304779 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304780
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304781 ENTER();
4782
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304783 if (NULL == pAdapter)
4784 {
4785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4786 "%s: Adapter is NULL",__func__);
4787 return -EINVAL;
4788 }
4789 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4790 if (0 != wlan_hdd_validate_context(pHddCtx))
4791 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304792 return VOS_STATUS_E_FAULT;
4793 }
4794 pVosContext = pHddCtx->pvosContext;
4795 if (NULL == pVosContext)
4796 {
4797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4798 "%s: VOS context is not valid",__func__);
4799 return VOS_STATUS_E_FAULT;
4800 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304801 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304802 if(pSapCtx == NULL)
4803 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304804 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4805 FL("psapCtx is NULL"));
4806 return VOS_STATUS_E_FAULT;
4807 }
4808
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304809 len = snprintf(pBuf, buf_len, sta_info_header);
4810 if (len >= buf_len) {
4811 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4812 return -E2BIG;
4813 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004814 pBuf += len;
4815 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004816
4817 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4818 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304819 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004820 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004821 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304822 pSapCtx->aStaInfo[i].ucSTAId,
4823 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4824 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4825 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4826 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4827 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4828 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304829 if (len >= buf_len) {
4830 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4831 return -E2BIG;
4832 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004833 pBuf += len;
4834 buf_len -= len;
4835 }
4836 if(WE_GET_STA_INFO_SIZE > buf_len)
4837 {
4838 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004839 }
4840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304841 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304842 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004843}
4844
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304845static int __iw_softap_get_sta_info(struct net_device *dev,
4846 struct iw_request_info *info,
4847 union iwreq_data *wrqu,
4848 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004849{
4850 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304851 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004852 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304853 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4854 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004855 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304856 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004857 }
4858 wrqu->data.length = strlen(extra);
4859 EXIT();
4860 return 0;
4861}
4862
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304863static int iw_softap_get_sta_info(struct net_device *dev,
4864 struct iw_request_info *info,
4865 union iwreq_data *wrqu,
4866 char *extra)
4867{
4868 int ret;
4869
4870 vos_ssr_protect(__func__);
4871 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4872 vos_ssr_unprotect(__func__);
4873
4874 return ret;
4875}
4876
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304877static int __iw_set_ap_genie(struct net_device *dev,
4878 struct iw_request_info *info,
4879 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004880{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304881
4882 hdd_adapter_t *pHostapdAdapter;
4883 hdd_context_t *pHddCtx;
4884 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004886 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304887 int ret = 0;
4888
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304890 pHostapdAdapter = (netdev_priv(dev));
4891 if (NULL == pHostapdAdapter)
4892 {
4893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4894 "%s: Adapter is NULL",__func__);
4895 return -EINVAL;
4896 }
4897 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4898 ret = wlan_hdd_validate_context(pHddCtx);
4899 if (0 != ret)
4900 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304901 return ret;
4902 }
4903 pVosContext = pHddCtx->pvosContext;
4904 if (NULL == pVosContext)
4905 {
4906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4907 "%s: VOS Context is NULL",__func__);
4908 return -EINVAL;
4909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 if(!wrqu->data.length)
4911 {
4912 EXIT();
4913 return 0;
4914 }
Arif Hussained667642013-10-27 23:01:14 -07004915
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05304916 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
4917 {
4918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4919 "%s: WPARSN Ie input length is more than max[%d]", __func__,
4920 wrqu->data.length);
4921 return -EINVAL;
4922 }
4923
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304924 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304926 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 case DOT11F_EID_RSN:
4928 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4929 {
4930 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4931 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004934 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304936
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004938 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 halStatus = 0;
4940 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304941
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304943 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004944}
4945
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304946static int iw_set_ap_genie(struct net_device *dev,
4947 struct iw_request_info *info,
4948 union iwreq_data *wrqu, char *extra)
4949{
4950 int ret;
4951
4952 vos_ssr_protect(__func__);
4953 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4954 vos_ssr_unprotect(__func__);
4955
4956 return ret;
4957}
4958
Jeff Johnson295189b2012-06-20 16:38:30 -07004959static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4960{
4961 eHalStatus hstatus;
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304962 int ret;
4963 void *cookie;
4964 struct hdd_request *request;
4965 struct stats_class_a_ctx *priv;
4966 static const struct hdd_request_params params = {
4967 .priv_size = sizeof(*priv),
4968 .timeout_ms = WLAN_WAIT_TIME_STATS,
4969 };
4970
Jeff Johnson295189b2012-06-20 16:38:30 -07004971
4972 if (NULL == pAdapter)
4973 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304974 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 return VOS_STATUS_E_FAULT;
4976 }
4977
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304978 request = hdd_request_alloc(&params);
4979 if (!request) {
4980 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
4981 return VOS_STATUS_E_NOMEM;
4982 }
4983 cookie = hdd_request_cookie(request);
4984
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4986 eCSR_HDD,
4987 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304988 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 0, // not periodic
4990 FALSE, //non-cached results
4991 staid,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304992 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 if (eHAL_STATUS_SUCCESS != hstatus)
4994 {
4995 hddLog(VOS_TRACE_LEVEL_ERROR,
4996 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004997 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 }
4999 else
5000 {
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305001 ret = hdd_request_wait_for_response(request);
5002 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 {
5004 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305005 FL("SME timeout while retrieving link speed"));
5006 }
5007 else
5008 {
5009 priv = hdd_request_priv(request);
5010 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 }
5012 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005013
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305014 /*
5015 * either we never sent a request, we sent a request and received a
5016 * response or we sent a request and timed out. Regardless we are
5017 * done with the request.
5018 */
5019 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005020
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 return VOS_STATUS_SUCCESS;
5022}
5023
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305024int __iw_get_softap_linkspeed(struct net_device *dev,
5025 struct iw_request_info *info,
5026 union iwreq_data *wrqu,
5027 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005028
5029{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305030 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305031 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07005033 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305034 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305036 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08005038 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305039 int rc, valid;
5040
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305041 ENTER();
5042
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305043 pHostapdAdapter = (netdev_priv(dev));
5044 if (NULL == pHostapdAdapter)
5045 {
5046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5047 "%s: Adapter is NULL",__func__);
5048 return -EINVAL;
5049 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305050 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305051 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305052 if (0 != valid)
5053 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305054 return valid;
5055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005056
Arif Hussain6d2a3322013-11-17 19:50:10 -08005057 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08005058
5059 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07005060 {
Arif Hussaina9571842014-01-15 16:43:41 -08005061 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
5062 if (NULL == pmacAddress) {
5063 hddLog(LOG1, "unable to allocate memory");
5064 return -ENOMEM;
5065 }
5066 if (copy_from_user((void *)pmacAddress,
5067 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
5068 {
5069 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
5070 kfree(pmacAddress);
5071 return -EFAULT;
5072 }
Manjeet Singha3739742016-05-03 16:21:46 +05305073 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08005074
5075 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07005076 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08005077
5078 if (!VOS_IS_STATUS_SUCCESS(status ))
5079 {
5080 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
5081 }
Arif Hussained667642013-10-27 23:01:14 -07005082 }
Kiet Lam61589852013-09-19 17:10:58 +05305083 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305084 * link speed for first connected client will be returned.
5085 */
Arif Hussaina9571842014-01-15 16:43:41 -08005086 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305087 {
5088 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
5089 }
5090 else
5091 {
5092 status = hdd_softap_GetStaId(pHostapdAdapter,
5093 (v_MACADDR_t *)macAddress, (void *)(&staId));
5094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005095
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305096 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305098 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 link_speed = 0;
5100 }
5101 else
5102 {
5103 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305104
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 if (!VOS_IS_STATUS_SUCCESS(status ))
5106 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305107 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 return -EINVAL;
5109 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305110
5111 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
5112 staId, &link_speed);
5113
5114 link_speed = link_speed / 10;
5115
5116 if (0 == link_speed)
5117 {
5118 /* The linkspeed returned by HAL is in units of 500kbps.
5119 * converting it to mbps.
5120 * This is required to support legacy firmware which does
5121 * not return link capacity.
5122 */
5123 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
5124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 }
5126
5127 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07005128 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305129
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 if ((rc < 0) || (rc >= len))
5131 {
5132 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305133 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 return -EIO;
5135 }
5136
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305137 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 return 0;
5139}
5140
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305141int iw_get_softap_linkspeed(struct net_device *dev,
5142 struct iw_request_info *info,
5143 union iwreq_data *wrqu,
5144 char *extra)
5145{
5146 int ret;
5147
5148 vos_ssr_protect(__func__);
5149 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
5150 vos_ssr_unprotect(__func__);
5151
5152 return ret;
5153}
5154
5155
Jeff Johnson295189b2012-06-20 16:38:30 -07005156static const iw_handler hostapd_handler[] =
5157{
5158 (iw_handler) NULL, /* SIOCSIWCOMMIT */
5159 (iw_handler) NULL, /* SIOCGIWNAME */
5160 (iw_handler) NULL, /* SIOCSIWNWID */
5161 (iw_handler) NULL, /* SIOCGIWNWID */
5162 (iw_handler) NULL, /* SIOCSIWFREQ */
5163 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
5164 (iw_handler) NULL, /* SIOCSIWMODE */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +05305165 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 (iw_handler) NULL, /* SIOCSIWSENS */
5167 (iw_handler) NULL, /* SIOCGIWSENS */
5168 (iw_handler) NULL, /* SIOCSIWRANGE */
5169 (iw_handler) NULL, /* SIOCGIWRANGE */
5170 (iw_handler) NULL, /* SIOCSIWPRIV */
5171 (iw_handler) NULL, /* SIOCGIWPRIV */
5172 (iw_handler) NULL, /* SIOCSIWSTATS */
5173 (iw_handler) NULL, /* SIOCGIWSTATS */
5174 (iw_handler) NULL, /* SIOCSIWSPY */
5175 (iw_handler) NULL, /* SIOCGIWSPY */
5176 (iw_handler) NULL, /* SIOCSIWTHRSPY */
5177 (iw_handler) NULL, /* SIOCGIWTHRSPY */
5178 (iw_handler) NULL, /* SIOCSIWAP */
5179 (iw_handler) NULL, /* SIOCGIWAP */
5180 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
5181 (iw_handler) NULL, /* SIOCGIWAPLIST */
5182 (iw_handler) NULL, /* SIOCSIWSCAN */
5183 (iw_handler) NULL, /* SIOCGIWSCAN */
5184 (iw_handler) NULL, /* SIOCSIWESSID */
5185 (iw_handler) NULL, /* SIOCGIWESSID */
5186 (iw_handler) NULL, /* SIOCSIWNICKN */
5187 (iw_handler) NULL, /* SIOCGIWNICKN */
5188 (iw_handler) NULL, /* -- hole -- */
5189 (iw_handler) NULL, /* -- hole -- */
5190 (iw_handler) NULL, /* SIOCSIWRATE */
5191 (iw_handler) NULL, /* SIOCGIWRATE */
5192 (iw_handler) NULL, /* SIOCSIWRTS */
5193 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
5194 (iw_handler) NULL, /* SIOCSIWFRAG */
5195 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
5196 (iw_handler) NULL, /* SIOCSIWTXPOW */
5197 (iw_handler) NULL, /* SIOCGIWTXPOW */
5198 (iw_handler) NULL, /* SIOCSIWRETRY */
5199 (iw_handler) NULL, /* SIOCGIWRETRY */
5200 (iw_handler) NULL, /* SIOCSIWENCODE */
5201 (iw_handler) NULL, /* SIOCGIWENCODE */
5202 (iw_handler) NULL, /* SIOCSIWPOWER */
5203 (iw_handler) NULL, /* SIOCGIWPOWER */
5204 (iw_handler) NULL, /* -- hole -- */
5205 (iw_handler) NULL, /* -- hole -- */
5206 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
5207 (iw_handler) NULL, /* SIOCGIWGENIE */
5208 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
5209 (iw_handler) NULL, /* SIOCGIWAUTH */
5210 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
5211 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
5212 (iw_handler) NULL, /* SIOCSIWPMKSA */
5213};
5214
Jeff Johnson224f3702014-03-26 11:09:47 -07005215/*
5216 * Note that the following ioctls were defined with semantics which
5217 * cannot be handled by the "iwpriv" userspace application and hence
5218 * they are not included in the hostapd_private_args array
5219 * QCSAP_IOCTL_ASSOC_STA_MACADDR
5220 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005221
5222static const struct iw_priv_args hostapd_private_args[] = {
5223 { QCSAP_IOCTL_SETPARAM,
5224 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
5225 { QCSAP_IOCTL_SETPARAM,
5226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05305227 { QCSAP_PARAM_GET_FRAME_LOGS,
5228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 { QCSAP_PARAM_MAX_ASSOC,
5230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
5231 { QCSAP_PARAM_HIDE_SSID,
5232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07005233 { QCSAP_PARAM_SET_MC_RATE,
5234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05305235 { QCSAP_PARAM_SET_PROXIMITY,
5236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305237 { QCSAP_PARAM_CAP_TSF,
5238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Abhishek Singh02605092017-10-25 14:06:12 +05305239 {QCSAP_PARAM_SET_CHANNEL_CHANGE,
5240 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"},
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305241 { QCSAP_PARAM_SET_WOWL,
5242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 { QCSAP_IOCTL_GETPARAM,
5244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
5246 { QCSAP_IOCTL_GETPARAM, 0,
5247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
5248 { QCSAP_PARAM_MAX_ASSOC, 0,
5249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07005250 { QCSAP_PARAM_GET_WLAN_DBG, 0,
5251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
5252 { QCSAP_PARAM_AUTO_CHANNEL, 0,
5253 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05305254 { QCSAP_PARAM_SET_AUTO_CHANNEL,
5255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 { QCSAP_PARAM_CLR_ACL, 0,
5257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
5258 { QCSAP_PARAM_ACL_MODE,
5259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05305261 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 { QCSAP_IOCTL_STOPBSS,
5263 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
5264 { QCSAP_IOCTL_VERSION, 0,
5265 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005266 { QCSAP_IOCTL_GET_STA_INFO, 0,
5267 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08005269 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07005271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07005272 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05305274 { QCSAP_IOCTL_AP_STATS, 0,
5275 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305276 /* handlers for main ioctl */
5277 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
5278 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
5279#ifdef WLAN_FEATURE_TSF
5280 { QCSAP_IOCTL_GET_TSF, 0,
5281 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5282 "get_tsf" },
5283#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05305284 { QCSAP_IOCTL_GET_STATS, 0,
5285 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
5286 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
5288 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305289 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005290
5291 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
5292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
5293 /* handlers for sub-ioctl */
5294 { WE_SET_WLAN_DBG,
5295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5296 0,
5297 "setwlandbg" },
5298
5299 /* handlers for main ioctl */
5300 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
5301 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5302 0,
5303 "" },
5304
5305 /* handlers for sub-ioctl */
5306 { WE_LOG_DUMP_CMD,
5307 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5308 0,
5309 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 { WE_P2P_NOA_CMD,
5311 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5312 0,
5313 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005314 /* handlers for sub ioctl */
5315 {
5316 WE_MCC_CONFIG_CREDENTIAL,
5317 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5318 0,
5319 "setMccCrdnl" },
5320
5321 /* handlers for sub ioctl */
5322 {
5323 WE_MCC_CONFIG_PARAMS,
5324 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5325 0,
5326 "setMccConfig" },
5327
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 /* handlers for main ioctl */
5329 { QCSAP_IOCTL_MODIFY_ACL,
5330 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
5331 0,
5332 "modify_acl" },
5333
5334 /* handlers for main ioctl */
5335 { QCSAP_IOCTL_GET_CHANNEL_LIST,
5336 0,
5337 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
5338 "getChannelList" },
5339
Jeff Johnsone7245742012-09-05 17:12:55 -07005340 /* handlers for main ioctl */
5341 { QCSAP_IOCTL_SET_TX_POWER,
5342 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5343 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05305344 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07005345
5346 /* handlers for main ioctl */
5347 { QCSAP_IOCTL_SET_MAX_TX_POWER,
5348 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5349 0,
5350 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05305351
5352 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
5353 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
5354 0,
5355 "dataSnapshot" },
5356
5357 /* handlers for main ioctl */
5358 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
5359 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5360 0,
5361 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305362 /* handlers for main ioctl */
5363 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
5364 IW_PRIV_TYPE_CHAR| 512,
5365 0,
5366 "" },
5367
5368 /* handlers for sub-ioctl */
5369 { WE_WOWL_ADD_PTRN,
5370 IW_PRIV_TYPE_CHAR| 512,
5371 0,
5372 "wowlAddPtrn" },
5373
5374 { WE_WOWL_DEL_PTRN,
5375 IW_PRIV_TYPE_CHAR| 512,
5376 0,
5377 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005378};
Jeff Johnsone7245742012-09-05 17:12:55 -07005379
Jeff Johnson295189b2012-06-20 16:38:30 -07005380static const iw_handler hostapd_private[] = {
5381 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305382 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
5383 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
5384 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
5387 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
5388 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
5389 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
5390 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
5391 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
5392 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05305393 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305394 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
5396 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
5397 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
5398 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005399 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07005400 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
5401 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07005402 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305403 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05305404 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05305405 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
5406 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07005407};
5408const struct iw_handler_def hostapd_handler_def = {
5409 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
5410 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
5411 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
5412 .standard = (iw_handler *)hostapd_handler,
5413 .private = (iw_handler *)hostapd_private,
5414 .private_args = hostapd_private_args,
5415 .get_wireless_stats = NULL,
5416};
5417#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5418struct net_device_ops net_ops_struct = {
5419 .ndo_open = hdd_hostapd_open,
5420 .ndo_stop = hdd_hostapd_stop,
5421 .ndo_uninit = hdd_hostapd_uninit,
5422 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5423 .ndo_tx_timeout = hdd_softap_tx_timeout,
5424 .ndo_get_stats = hdd_softap_stats,
5425 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5426 .ndo_do_ioctl = hdd_hostapd_ioctl,
5427 .ndo_change_mtu = hdd_hostapd_change_mtu,
5428 .ndo_select_queue = hdd_hostapd_select_queue,
5429 };
5430#endif
5431
5432int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5433{
5434 return VOS_STATUS_SUCCESS;
5435}
5436
5437void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5438{
5439#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5440 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5441#else
5442 pWlanHostapdDev->open = hdd_hostapd_open;
5443 pWlanHostapdDev->stop = hdd_hostapd_stop;
5444 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5445 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5446 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5447 pWlanHostapdDev->get_stats = hdd_softap_stats;
5448 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5449 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5450#endif
5451}
5452
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305453VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305454{
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05305456#ifdef DHCP_SERVER_OFFLOAD
5457 hdd_dhcp_state_t *dhcp_status;
5458#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305459#ifdef MDNS_OFFLOAD
5460 hdd_mdns_state_t *mdns_status;
5461#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005463 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305465 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005466#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005467 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5468 v_U16_t unsafeChannelCount;
5469#endif /* FEATURE_WLAN_CH_AVOID */
5470
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305471 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5473 "%s:LOGP in Progress. Ignore!!!",__func__);
5474 status = VOS_STATUS_E_FAILURE;
5475 }
5476
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305478
5479#ifdef SAP_AUTH_OFFLOAD
5480 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305481 {
5482 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5483 {
5484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5485 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5486 return VOS_STATUS_E_FAILURE;
5487 }
5488 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305489#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305490
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305491 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305493#ifdef DHCP_SERVER_OFFLOAD
5494 dhcp_status = &pAdapter->dhcp_status;
5495#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305496#ifdef MDNS_OFFLOAD
5497 mdns_status = &pAdapter->mdns_status;
5498#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305499
Nirav Shah7e3c8132015-06-22 23:51:42 +05305500 spin_lock_init(&pAdapter->sta_hash_lock);
5501 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5502
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005503 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5504
Leo Chang0b0e45a2013-12-15 15:18:55 -08005505#ifdef FEATURE_WLAN_CH_AVOID
5506 /* Get unsafe cahnnel list from cached location */
5507 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5508 sizeof(unsafeChannelList),
5509 &unsafeChannelCount);
5510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5511 "%s : Unsafe Channel count %d",
5512 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305513 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005514 unsafeChannelList,
5515 unsafeChannelCount);
5516#endif /* FEATURE_WLAN_CH_AVOID */
5517
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 // Zero the memory. This zeros the profile structure.
5519 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305520#ifdef DHCP_SERVER_OFFLOAD
5521 memset(dhcp_status, 0,sizeof(*dhcp_status));
5522#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305523#ifdef MDNS_OFFLOAD
5524 memset(mdns_status, 0,sizeof(*mdns_status));
5525#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305526
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 // Set up the pointer to the Wireless Extensions state structure
5528 // NOP
5529 status = hdd_set_hostapd(pAdapter);
5530 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 return status;
5533 }
5534
5535 status = vos_event_init(&phostapdBuf->vosEvent);
5536 if (!VOS_IS_STATUS_SUCCESS(status))
5537 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 return status;
5540 }
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05305541 status = vos_event_init(&phostapdBuf->sta_discon_event);
5542 if (!VOS_IS_STATUS_SUCCESS(status))
5543 {
5544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ERROR: Hostapd HDD sta disassoc event init failed!!");
5545 return status;
5546 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305547#ifdef DHCP_SERVER_OFFLOAD
5548 status = vos_event_init(&dhcp_status->vos_event);
5549 if (!VOS_IS_STATUS_SUCCESS(status)) {
5550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5551 return status;
5552 }
5553#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305554#ifdef MDNS_OFFLOAD
5555 status = vos_event_init(&mdns_status->vos_event);
5556 if (!VOS_IS_STATUS_SUCCESS(status)) {
5557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5558 ("Hostapd HDD vos event init failed!!"));
5559 return status;
5560 }
5561#endif /* MDNS_OFFLOAD */
5562
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5564
5565 // Register as a wireless device
5566 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5567
5568 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305569 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 if ( !VOS_IS_STATUS_SUCCESS( status ))
5571 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005572 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305574
5575 status = hdd_wmm_adapter_init( pAdapter );
5576 if (!VOS_IS_STATUS_SUCCESS(status))
5577 {
5578 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005579 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305580 status, status );
5581 goto error_wmm_init;
5582 }
5583
5584 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5585
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305586 ini_cfg = pHddCtx->cfg_ini;
5587 if (re_init && ini_cfg) {
5588 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5589 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5590 ini_cfg->apOperatingBand);
5591 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5592 ini_cfg->apStartChannelNum,
5593 ini_cfg->apEndChannelNum,
5594 ini_cfg->apOperatingBand);
5595 }
5596
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305597 return status;
5598
5599error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305600 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 EXIT();
5602 return status;
5603}
5604
5605hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5606{
5607 struct net_device *pWlanHostapdDev = NULL;
5608 hdd_adapter_t *pHostapdAdapter = NULL;
5609 v_CONTEXT_t pVosContext= NULL;
5610
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305611 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5612#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5613 NET_NAME_UNKNOWN,
5614#endif
5615 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 if (pWlanHostapdDev != NULL)
5617 {
5618 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5619
5620 //Init the net_device structure
5621 ether_setup(pWlanHostapdDev);
5622
5623 //Initialize the adapter context to zeros.
5624 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5625 pHostapdAdapter->dev = pWlanHostapdDev;
5626 pHostapdAdapter->pHddCtx = pHddCtx;
5627 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5628
5629 //Get the Global VOSS context.
5630 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5631 //Save the adapter context in global context for future.
5632 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5633
5634 //Init the net_device structure
5635 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5636
5637 hdd_set_ap_ops( pHostapdAdapter->dev );
5638
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5640 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5641
5642 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5643 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5644
5645 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5647 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5648 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5651 }
5652 return pHostapdAdapter;
5653}
5654
5655VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5656{
5657 struct net_device *dev = pAdapter->dev;
5658 VOS_STATUS status = VOS_STATUS_SUCCESS;
5659
5660 ENTER();
5661
5662 if( rtnl_lock_held )
5663 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005664 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 if( dev_alloc_name(dev, dev->name) < 0 )
5666 {
5667 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5668 return VOS_STATUS_E_FAILURE;
5669 }
5670 }
5671 if (register_netdevice(dev))
5672 {
5673 hddLog(VOS_TRACE_LEVEL_FATAL,
5674 "%s:Failed:register_netdevice", __func__);
5675 return VOS_STATUS_E_FAILURE;
5676 }
5677 }
5678 else
5679 {
5680 if (register_netdev(dev))
5681 {
5682 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5683 return VOS_STATUS_E_FAILURE;
5684 }
5685 }
5686 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5687
5688 EXIT();
5689 return status;
5690}
5691
c_hpothu002231a2015-02-05 14:58:51 +05305692VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005693{
5694 ENTER();
5695
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305696 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005697
5698 /* if we are being called during driver unload, then the dev has already
5699 been invalidated. if we are being called at other times, then we can
5700 detatch the wireless device handlers */
5701 if (pAdapter->dev)
5702 {
c_hpothu002231a2015-02-05 14:58:51 +05305703 if (TRUE == rtnl_held)
5704 {
5705 pAdapter->dev->wireless_handlers = NULL;
5706 }
5707 else
5708 {
5709 rtnl_lock();
5710 pAdapter->dev->wireless_handlers = NULL;
5711 rtnl_unlock();
5712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 }
5714 EXIT();
5715 return 0;
5716}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305717
5718/**
5719 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5720 * to supplicant, if there any clients connected to SAP interface.
5721 * @adapter: sap adapter context
5722 *
5723 * Return: nothing
5724 */
5725void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5726{
5727 tSap_Event sap_event;
5728 int staId;
5729 hdd_context_t *hdd_ctx;
5730 v_CONTEXT_t vos_ctx;
5731 ptSapContext sap_ctx;
5732
5733 ENTER();
5734
5735 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305736 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5738 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305739 return;
5740 }
5741
5742 vos_ctx = hdd_ctx->pvosContext;
5743 if (NULL == vos_ctx) {
5744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5745 "%s: VOS context is not valid",__func__);
5746 return;
5747 }
5748
5749 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5750 if (!sap_ctx) {
5751 hddLog(LOGE, FL("invalid sap context"));
5752 return;
5753 }
5754
5755 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5756 if (sap_ctx->aStaInfo[staId].isUsed) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07005757 hddLog(LOG1, FL("staId: %d isUsed: %d %pK"),
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305758 staId, sap_ctx->aStaInfo[staId].isUsed,
5759 sap_ctx);
5760
5761 if (vos_is_macaddr_broadcast(
5762 &sap_ctx->aStaInfo[staId].macAddrSTA))
5763 continue;
5764
5765 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5766 vos_mem_copy(
5767 &sap_event.sapevt.
5768 sapStationDisassocCompleteEvent.staMac,
5769 &sap_ctx->aStaInfo[staId].macAddrSTA,
5770 sizeof(v_MACADDR_t));
5771 sap_event.sapevt.sapStationDisassocCompleteEvent.
5772 reason =
5773 eSAP_MAC_INITATED_DISASSOC;
5774 sap_event.sapevt.sapStationDisassocCompleteEvent.
5775 statusCode =
5776 eSIR_SME_RESOURCES_UNAVAILABLE;
5777 hdd_hostapd_SAPEventCB(&sap_event,
5778 sap_ctx->pUsrContext);
5779 }
5780 }
5781
5782 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5783
5784 EXIT();
5785}
5786
5787/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305788 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305789 * @adapter: sap adapter context
5790 *
5791 * Return: nothing
5792 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305793void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305794{
5795 hdd_context_t *hdd_ctx;
5796 v_CONTEXT_t vos_ctx;
5797 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305798 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305799
5800 ENTER();
5801
5802 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305803 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5805 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305806 return;
5807 }
5808
5809 vos_ctx = hdd_ctx->pvosContext;
5810 if (NULL == vos_ctx) {
5811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5812 "%s: VOS context is not valid",__func__);
5813 return;
5814 }
5815
5816 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5817 if (!sap_ctx) {
5818 hddLog(LOGE, FL("invalid sap context"));
5819 return;
5820 }
5821
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305822 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5823 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5824 if (!VOS_IS_STATUS_SUCCESS(status))
5825 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5826 FL("Failed to Stop HT20/40 timer"));
5827 }
5828
5829 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5830 if (!VOS_IS_STATUS_SUCCESS(status))
5831 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5832 FL("Failed to Destroy HT20/40 timer"));
5833
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305834}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305835
5836/**
5837 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5838 * @adapter: hdd ap adapter
5839 *
5840 * hdd_force_scc_restart_sap will choose station channel and will
5841 * schedule work to restart the sap.
5842 *
5843 * Return - none
5844 */
5845void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5846 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5847{
5848 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5849 return;
5850 }
5851
5852 hddLog(LOG1, FL("Current operation channel %d"),
5853 adapter->sessionCtx.ap.operatingChannel);
5854 hddLog(LOG1, FL("STA channel is %d"),
5855 channelId);
5856
5857 vos_flush_work(
5858 &hdd_ctx->sap_start_work);
5859
5860 hddLog(LOGE,
5861 FL("Restarting SAP for force SCC "));
5862
5863 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5864
5865 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5866 netif_tx_disable(adapter->dev);
5867 schedule_work(&hdd_ctx->sap_start_work);
5868 } else {
5869 hdd_hostapd_stop(adapter->dev);
5870 }
5871 return;
5872}
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05305873
5874/**
5875 * hdd_get_cache_stainfo() - get stainfo for the specified peer
5876 * @stainfo: array of station info
5877 * @mac_addr: mac address of requested peer
5878 *
5879 * This function find the stainfo for the peer with mac_addr
5880 *
5881 * Return: stainfo if found, NULL if not found
5882 */
5883struct hdd_cache_sta_info *hdd_get_cache_stainfo(
5884 struct hdd_cache_sta_info *astainfo,
5885 u8 *mac_addr)
5886{
5887 struct hdd_cache_sta_info *stainfo = NULL;
5888 int i;
5889
5890 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
5891 if (vos_mem_compare(&astainfo[i].macAddrSTA,
5892 mac_addr,
5893 HDD_MAC_ADDR_LEN)) {
5894 stainfo = &astainfo[i];
5895 break;
5896 }
5897 }
5898
5899 return stainfo;
5900}
5901