blob: 1728d3f4062c88e40f6b9aa1f0ebefd8806051e7 [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
louisliu462edac2020-06-30 13:33:56 +0800180 if(!test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530181 {
louisliu462edac2020-06-30 13:33:56 +0800182 //WMM_INIT OR BSS_START not completed
183 hddLog( LOGW, "Ignore hostadp open request");
184 EXIT();
185 return 0;
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530186 }
187
louisliu462edac2020-06-30 13:33:56 +0800188 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;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530671 hdd_adapter_t *pAdapter, *adapter_temp;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530672 hdd_context_t *pHddCtx;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530673 int ret = 0, i;
674 v_MACADDR_t mac_addr;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530675
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530677 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
678 if (NULL == pAdapter)
679 {
680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
681 "%s: Adapter is NULL",__func__);
682 return -EINVAL;
683 }
684 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
685 ret = wlan_hdd_validate_context(pHddCtx);
686 if (0 != ret)
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530687 return ret;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530688
689
690 memcpy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr));
691 if(vos_is_macaddr_zero(&mac_addr)) {
692 hddLog(VOS_TRACE_LEVEL_ERROR, "Zero Mac address");
693 return -EINVAL;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530694 }
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530695
696 if (vos_is_macaddr_broadcast(&mac_addr)) {
697 hddLog(VOS_TRACE_LEVEL_ERROR,"MAC is Broadcast");
698 return -EINVAL;
699 }
700
701 if (vos_is_macaddr_multicast(&mac_addr)) {
702 hddLog(VOS_TRACE_LEVEL_ERROR, "Multicast Mac address");
703 return -EINVAL;
704 }
705
706
707 adapter_temp = hdd_get_adapter_by_macaddr(pHddCtx, mac_addr.bytes);
708 if (adapter_temp) {
709 if (!strcmp(adapter_temp->dev->name, dev->name))
710 return 0;
711 hddLog(VOS_TRACE_LEVEL_ERROR,
712 "%s: WLAN Mac Addr: "
713 MAC_ADDRESS_STR, __func__,
714 MAC_ADDR_ARRAY(mac_addr.bytes));
715 return -EINVAL;
716 }
717
718 for (i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) {
719 if (!vos_mem_compare(&pAdapter->macAddressCurrent.bytes,
720 &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], VOS_MAC_ADDR_SIZE)) {
721 memcpy(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], mac_addr.bytes,
722 VOS_MAC_ADDR_SIZE);
723 break;
724 }
725 }
726
727 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530729
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 EXIT();
731 return 0;
732}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530733
734static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
735{
736 int ret;
737
738 vos_ssr_protect(__func__);
739 ret = __hdd_hostapd_set_mac_address(dev, addr);
740 vos_ssr_unprotect(__func__);
741
742 return ret;
743}
744
Jeff Johnson295189b2012-06-20 16:38:30 -0700745void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
746{
747 struct net_device *dev = (struct net_device *)usrDataForCallback;
748 v_BYTE_t we_custom_event[64];
749 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530751 hdd_context_t *pHddCtx;
752#ifdef DISABLE_CONCURRENCY_AUTOSAVE
753 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 hdd_ap_ctx_t *pHddApCtx;
755#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
756
757 /* event_name space-delimiter driver_module_name */
758 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
759 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
760 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
761
762 ENTER();
763
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530764 pHostapdAdapter = netdev_priv(dev);
765 if ((NULL == pHostapdAdapter) ||
766 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
767 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700768 hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530769 return;
770 }
771 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
772 if (0 != (wlan_hdd_validate_context(pHddCtx)))
773 {
774 return;
775 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530776#ifdef DISABLE_CONCURRENCY_AUTOSAVE
777 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530778 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 /*
780 This timer routine is going to be called only when AP
781 persona is up.
782 If there are concurrent sessions running we do not want
783 to shut down the Bss.Instead we run the timer again so
784 that if Autosave is enabled next time and other session
785 was down only then we bring down AP
786 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
788 vos_status = vos_timer_start(
789 &pHddApCtx->hdd_ap_inactivity_timer,
790 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
791 * 1000);
792 if (!VOS_IS_STATUS_SUCCESS(vos_status))
793 {
794 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
795 }
796 EXIT();
797 return;
798 }
799#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
800 memset(&we_custom_event, '\0', sizeof(we_custom_event));
801 memcpy(&we_custom_event, autoShutEvent, event_len);
802
803 memset(&wrqu, 0, sizeof(wrqu));
804 wrqu.data.length = event_len;
805
806 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
807 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
808
809 EXIT();
810}
811
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800812VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
813{
814 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
815 ptSapContext pSapCtx = NULL;
816 eHalStatus halStatus = eHAL_STATUS_FAILURE;
817 v_PVOID_t hHal = NULL;
818
819 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
820 "%s: UPDATE Beacon Params", __func__);
821
822 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
823 pSapCtx = VOS_GET_SAP_CB(pVosContext);
824 if ( NULL == pSapCtx )
825 {
826 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
827 "%s: Invalid SAP pointer from pvosGCtx", __func__);
828 return VOS_STATUS_E_FAULT;
829 }
830
831 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
832 if ( NULL == hHal ){
833 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
834 "%s: Invalid HAL pointer from pvosGCtx", __func__);
835 return VOS_STATUS_E_FAULT;
836 }
837 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
838 if(halStatus == eHAL_STATUS_FAILURE ){
839 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
840 "%s: Failed to update Beacon Params", __func__);
841 return VOS_STATUS_E_FAILURE;
842 }
843 }
844 return VOS_STATUS_SUCCESS;
845}
846
847void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
848{
849 v_U8_t staId = 0;
850 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530851 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
852 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800853
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530854 dev = (struct net_device *)usrDataForCallback;
855 pSapCtx = VOS_GET_SAP_CB(pVosContext);
856 if(pSapCtx == NULL){
857 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
858 FL("psapCtx is NULL"));
859 return;
860 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800861 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800862 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
863 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530864 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800865 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
866 {
867 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530868 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800869 }
870 }
871}
872
Agarwal Ashish8e538932014-12-24 18:12:52 +0530873static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800874{
875 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530876 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800877 VOS_STATUS status = VOS_STATUS_SUCCESS;
878 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530879
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800880 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530881
882 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
883 status = wlan_hdd_validate_context(pHddCtx);
884
885 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530886 return status;
887 }
888
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800889 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
890 {
891 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
892 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800894 }
895 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530896 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800897 }
898 EXIT();
899 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
900}
Jeff Johnson295189b2012-06-20 16:38:30 -0700901
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530902#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530903bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530904 bool enabled)
905{
906 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530907 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530908
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530909 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530910 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
911
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530912 sap_offload_info.sap_auth_offload_enable = enabled;
913 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530914 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530915 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530916 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
917
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530918 if (sap_offload_info.sap_auth_offload_enable &&
919 sap_offload_info.sap_auth_offload_sec_type)
920 {
921 if (sap_offload_info.key_len < 8 ||
922 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
923 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530924 hddLog(VOS_TRACE_LEVEL_ERROR,
925 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530926 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530927 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530928 }
929 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530930 if (sap_offload_info.key_len)
931 {
932 vos_mem_copy(sap_offload_info.key,
933 pHddCtx->cfg_ini->sap_auth_offload_key,
934 sap_offload_info.key_len);
935 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530936 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530937 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
938 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530939 hddLog(VOS_TRACE_LEVEL_ERROR,
940 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530941 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530942 }
943
944 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
945 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530946 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530947}
948#endif
949
Abhishek Singhe8ebb922017-11-01 13:30:26 +0530950/**
951* wlansap_get_phymode() - get SAP phymode.
952* @pctx: Pointer to the global vos context; a handle to SAP's control block
953* can be extracted from its context. When MBSSID feature is enabled,
954* SAP context is directly passed to SAP APIs.
955*
956* This function provides current phymode of SAP interface.
957*
958* Return: phymode with eCsrPhyMode type.
959*/
960static eCsrPhyMode
961wlansap_get_phymode(v_PVOID_t pctx)
962{
963 ptSapContext psapctx = VOS_GET_SAP_CB(pctx);
964
965 if (!psapctx) {
966 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
967 "%s: Invalid SAP pointer from pCtx", __func__);
968 return eCSR_DOT11_MODE_AUTO;
969 }
970 return psapctx->csrRoamProfile.phyMode;
971}
972
973/**
974 * hdd_update_chandef() - Function to update channel width and center freq
975 * @chandef: cfg80211 chan def
976 * @cb_mode: chan offset
977 *
978 * This function will be called to update channel width and center freq
979 *
980 * Return: None
981 */
982static void
983hdd_update_chandef(struct cfg80211_chan_def *chandef,
984 ePhyChanBondState cb_mode)
985{
986 uint8_t center_chan, chan;
987
988 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
989 return;
990
991 chan = vos_freq_to_chan(chandef->chan->center_freq);
992 chandef->width = NL80211_CHAN_WIDTH_80;
993 switch (cb_mode) {
994 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
995 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
996 center_chan = chan + 2;
997 break;
998 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
999 center_chan = chan + 6;
1000 break;
1001 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1002 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1003 center_chan = chan - 2;
1004 break;
1005 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1006 center_chan = chan - 6;
1007 break;
1008 default:
1009 center_chan = chan;
1010 break;
1011 }
1012
1013 chandef->center_freq1 = vos_chan_to_freq(center_chan);
1014}
1015
1016/**
1017 * hdd_chan_change_notify() - Function to notify hostapd about channel change
1018 * @hostapd_adapter: hostapd adapter
1019 * @dev: Net device structure
1020 * @oper_chan: New operating channel
1021 *
1022 * This function is used to notify hostapd about the channel change
1023 *
1024 * Return: Success on intimating userspace
1025 *
1026 */
1027static VOS_STATUS hdd_chan_change_notify(hdd_adapter_t *hostapd_adapter,
1028 struct net_device *dev, uint8_t oper_chan)
1029{
1030 struct ieee80211_channel *chan;
1031 struct cfg80211_chan_def chandef;
1032 enum nl80211_channel_type channel_type;
1033 eCsrPhyMode phy_mode;
1034 ePhyChanBondState cb_mode;
1035 uint32_t freq;
1036 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(hostapd_adapter);
1037 tSmeConfigParams sme_config;
1038
1039 if (!hal) {
1040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1041 "%s: hal is NULL", __func__);
1042 return VOS_STATUS_E_FAILURE;
1043 }
1044
1045 freq = vos_chan_to_freq(oper_chan);
1046
1047 chan = __ieee80211_get_channel(hostapd_adapter->wdev.wiphy, freq);
1048
1049 if (!chan) {
1050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1051 "%s: Invalid input frequency for channel conversion", __func__);
1052 return VOS_STATUS_E_FAILURE;
1053 }
1054
1055 phy_mode = wlansap_get_phymode(
1056 (WLAN_HDD_GET_CTX(hostapd_adapter))->pvosContext);
1057 sme_GetConfigParam(hal, &sme_config);
1058 if (oper_chan <= 14)
1059 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1060 sme_config.csrConfig.channelBondingMode24GHz);
1061 else
1062 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1063 sme_config.csrConfig.channelBondingMode5GHz);
1064
1065 switch (phy_mode) {
1066 case eCSR_DOT11_MODE_11n:
1067 case eCSR_DOT11_MODE_11n_ONLY:
1068 case eCSR_DOT11_MODE_11ac:
1069 case eCSR_DOT11_MODE_11ac_ONLY:
1070 switch (cb_mode) {
1071 case PHY_SINGLE_CHANNEL_CENTERED:
1072 channel_type = NL80211_CHAN_HT20;
1073 break;
1074 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1075 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1076 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1077 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1078 channel_type = NL80211_CHAN_HT40MINUS;
1079 break;
1080 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1081 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1082 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1083 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1084 channel_type = NL80211_CHAN_HT40PLUS;
1085 break;
1086 default:
1087 channel_type = NL80211_CHAN_HT20;
1088 break;
1089 }
1090 break;
1091 default:
1092 channel_type = NL80211_CHAN_NO_HT;
1093 break;
1094 }
1095
1096 cfg80211_chandef_create(&chandef, chan, channel_type);
1097 if ((phy_mode == eCSR_DOT11_MODE_11ac) ||
1098 (phy_mode == eCSR_DOT11_MODE_11ac_ONLY))
1099 hdd_update_chandef(&chandef, cb_mode);
1100
1101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1102 "%s: phy_mode %d cb_mode %d chann_type %d oper_chan %d width %d freq_1 %d",
1103 __func__, phy_mode, cb_mode, channel_type, oper_chan,
1104 chandef.width, chandef.center_freq1);
1105
1106
1107 cfg80211_ch_switch_notify(dev, &chandef);
1108
1109 return VOS_STATUS_SUCCESS;
1110}
1111
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301112/**
1113 * hdd_convert_dot11mode_from_phymode() - get dot11mode to phymode
1114 * @phymode: phy mode
1115 *
1116 * This function is used to get dot11mode to phymode
1117 *
1118 * Return: dot11mode
1119 */
1120static int hdd_convert_dot11mode_from_phymode(int phymode)
1121{
1122 switch (phymode) {
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301123
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301124 case VOS_MODE_11A:
1125 return QCA_WLAN_802_11_MODE_11A;
1126
1127 case VOS_MODE_11B:
1128 return QCA_WLAN_802_11_MODE_11B;
1129
1130 case VOS_MODE_11G:
1131 case VOS_MODE_11GONLY:
1132 return QCA_WLAN_802_11_MODE_11G;
1133
1134 case VOS_MODE_11NA_HT20:
1135 case VOS_MODE_11NG_HT20:
1136 case VOS_MODE_11NA_HT40:
1137 case VOS_MODE_11NG_HT40:
1138 return QCA_WLAN_802_11_MODE_11N;
1139
1140 case VOS_MODE_11AC_VHT20:
1141 case VOS_MODE_11AC_VHT40:
1142 case VOS_MODE_11AC_VHT80:
1143 case VOS_MODE_11AC_VHT20_2G:
1144 case VOS_MODE_11AC_VHT40_2G:
1145 case VOS_MODE_11AC_VHT80_2G:
1146#ifdef CONFIG_160MHZ_SUPPORT
1147 case VOS_MODE_11AC_VHT80_80:
1148 case VOS_MODE_11AC_VHT160:
1149#endif
1150 return QCA_WLAN_802_11_MODE_11AC;
1151
1152 default:
1153 return QCA_WLAN_802_11_MODE_INVALID;
1154 }
1155
1156}
1157
1158/**
1159 * hdd_fill_station_info() - fill station information
1160 * @sap_ctx: sap context
1161 * @event: assoc event
1162 * This function updates sta information from assoc event
1163 *
1164 * Return: none
1165 */
1166static void hdd_fill_station_info(ptSapContext sap_ctx,
1167 tSap_StationAssocReassocCompleteEvent *event)
1168{
1169 struct hdd_cache_sta_info *sta_info = sap_ctx->cache_sta_info;
1170 int i=0;
1171
1172 /* check if there is any dup entry */
1173 while (i < WLAN_MAX_STA_COUNT) {
1174 if (vos_mem_compare(sta_info[i].macAddrSTA.bytes,
1175 event->staMac.bytes,
1176 VOS_MAC_ADDR_SIZE)) {
1177 vos_mem_zero(&sta_info[i], sizeof(*sta_info));
1178 break;
1179 }
1180 i++;
1181 }
1182 if (i >= WLAN_MAX_STA_COUNT) {
1183 i = 0;
1184 while (i < WLAN_MAX_STA_COUNT) {
1185 if (sta_info[i].isUsed != TRUE)
1186 break;
1187 i++;
1188 }
1189 }
1190
1191 if (i < WLAN_MAX_STA_COUNT) {
1192 sta_info[i].isUsed = TRUE;
1193 sta_info[i].ucSTAId = event->staId;
1194 vos_mem_copy(sta_info[i].macAddrSTA.bytes,
1195 event->staMac.bytes,
1196 VOS_MAC_ADDR_SIZE);
1197 sta_info[i].freq = vos_chan_to_freq(event->chan_info.chan_id);
1198 sta_info[i].ch_width = event->ch_width;
1199 sta_info[i].nss = 1;
1200 sta_info[i].dot11_mode = hdd_convert_dot11mode_from_phymode(
1201 event->chan_info.info);
1202 if (event->HTCaps.present) {
1203 sta_info[i].ht_present = TRUE;
1204 hdd_copy_ht_caps(&sta_info[i].ht_caps, &event->HTCaps);
1205 }
1206 if (event->VHTCaps.present) {
1207 sta_info[i].vht_present = TRUE;
1208 hdd_copy_vht_caps(&sta_info[i].vht_caps,
1209 &event->VHTCaps);
1210 }
1211 }
1212 else
1213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "reached max staid, stainfo can't be cached");
1214}
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301215
Jeff Johnson295189b2012-06-20 16:38:30 -07001216VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
1217{
1218 hdd_adapter_t *pHostapdAdapter;
1219 hdd_ap_ctx_t *pHddApCtx;
1220 hdd_hostapd_state_t *pHostapdState;
1221 struct net_device *dev;
1222 eSapHddEvent sapEvent;
1223 union iwreq_data wrqu;
1224 v_BYTE_t *we_custom_event_generic = NULL;
1225 int we_event = 0;
1226 int i = 0;
1227 v_U8_t staId;
1228 VOS_STATUS vos_status;
1229 v_BOOL_t bWPSState;
1230 v_BOOL_t bApActive = FALSE;
1231 v_BOOL_t bAuthRequired = TRUE;
1232 tpSap_AssocMacAddr pAssocStasArray = NULL;
1233 char unknownSTAEvent[IW_CUSTOM_MAX+1];
1234 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
1235 v_BYTE_t we_custom_start_event[64];
1236 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001237 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001238 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -07001239 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301240 v_CONTEXT_t pVosContext = NULL;
1241 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +05301242 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -07001243
1244 dev = (struct net_device *)usrDataForCallback;
1245 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +05301246
1247 if ((NULL == pHostapdAdapter) ||
1248 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
1249 {
1250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1251 "invalid adapter or adapter has invalid magic");
1252 return eHAL_STATUS_FAILURE;
1253 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301254 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1255 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1256 if(pSapCtx == NULL){
1257 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1258 FL("psapCtx is NULL"));
1259 return eHAL_STATUS_FAILURE;
1260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1262 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1263 sapEvent = pSapEvent->sapHddEventCode;
1264 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001265 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +05301266 cfg_param = pHddCtx->cfg_ini;
1267
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 switch(sapEvent)
1269 {
1270 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -08001271 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
1273 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
1274 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
1275
1276 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
1277 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +05301278
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +05301280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 goto stopbss;
1283 }
1284 else
Deepthi Gowried085092015-10-20 19:30:52 +05301285 {
1286 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1287 {
1288 if ((cfg_param->dynSplitscan) &&
1289 (!pHddCtx->issplitscan_enabled))
1290 {
1291 pHddCtx->issplitscan_enabled = TRUE;
1292 sme_enable_disable_split_scan(
1293 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
1294 cfg_param->nNumStaChanCombinedConc,
1295 cfg_param->nNumP2PChanCombinedConc);
1296 }
1297 }
1298
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1300 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +05301301 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1302 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +05301303 {
c_hpothuffdb5272013-10-02 16:42:35 +05301304 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +05301305 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
1306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 }
Deepthi Gowried085092015-10-20 19:30:52 +05301308
Jeff Johnson295189b2012-06-20 16:38:30 -07001309 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1310 {
1311 // AP Inactivity timer init and start
1312 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1313 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1314 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001315 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
1317 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1318 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001319 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
1321 }
1322 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1323 pHostapdState->bssState = BSS_START;
1324
1325 // Send current operating channel of SoftAP to BTC-ES
1326 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1327
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 //Check if there is any group key pending to set.
1329 if( pHddApCtx->groupKey.keyLength )
1330 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001331 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1333 &pHddApCtx->groupKey ) )
1334 {
1335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1336 "%s: WLANSAP_SetKeySta failed", __func__);
1337 }
1338 pHddApCtx->groupKey.keyLength = 0;
1339 }
1340 else if ( pHddApCtx->wepKey[0].keyLength )
1341 {
1342 int i=0;
1343 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1344 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001345 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1347 &pHddApCtx->wepKey[i] ) )
1348 {
1349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1350 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 }
1353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1355 startBssEvent = "SOFTAP.enabled";
1356 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1357 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1358 memset(&wrqu, 0, sizeof(wrqu));
1359 wrqu.data.length = strlen(startBssEvent);
1360 we_event = IWEVCUSTOM;
1361 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001362 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 break; //Event will be sent after Switch-Case stmt
1364
1365 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001366 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1368
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001369 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001370 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001371
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301373
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 goto stopbss;
1375 case eSAP_STA_SET_KEY_EVENT:
1376 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001377 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1379 return VOS_STATUS_SUCCESS;
1380 case eSAP_STA_DEL_KEY_EVENT:
1381 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001382 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 return VOS_STATUS_SUCCESS;
1384 case eSAP_STA_MIC_FAILURE_EVENT:
1385 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 memset(&msg, '\0', sizeof(msg));
1387 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001388 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001389 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001390 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 msg.flags = IW_MICFAILURE_GROUP;
1392 else
1393 msg.flags = IW_MICFAILURE_PAIRWISE;
1394 memset(&wrqu, 0, sizeof(wrqu));
1395 wrqu.data.length = sizeof(msg);
1396 we_event = IWEVMICHAELMICFAILURE;
1397 we_custom_event_generic = (v_BYTE_t *)&msg;
1398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 /* inform mic failure to nl80211 */
1400 cfg80211_michael_mic_failure(dev,
1401 pSapEvent->sapevt.
1402 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001403 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 NL80211_KEYTYPE_GROUP :
1405 NL80211_KEYTYPE_PAIRWISE),
1406 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1407 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1408 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 break;
1410
1411 case eSAP_STA_ASSOC_EVENT:
1412 case eSAP_STA_REASSOC_EVENT:
1413 wrqu.addr.sa_family = ARPHRD_ETHER;
1414 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001415 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001416 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 we_event = IWEVREGISTERED;
1418
1419 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1420
1421 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1422 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1423 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1424 {
1425 bAuthRequired = FALSE;
1426 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301427 /* fAuthRequiredshould should be false for sap offload */
1428 if ((bAuthRequired || bWPSState)
1429#ifdef SAP_AUTH_OFFLOAD
1430 && !cfg_param->enable_sap_auth_offload
1431#endif
1432 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 {
c_hpothuffdb5272013-10-02 16:42:35 +05301434 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 TRUE,
1436 pHddApCtx->uPrivacy,
1437 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1438 0,
1439 0,
1440 (v_MACADDR_t *)wrqu.addr.sa_data,
1441 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301442
1443 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1444 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1445 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 }
1447 else
1448 {
c_hpothuffdb5272013-10-02 16:42:35 +05301449 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 FALSE,
1451 pHddApCtx->uPrivacy,
1452 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1453 0,
1454 0,
1455 (v_MACADDR_t *)wrqu.addr.sa_data,
1456 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301457 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1458 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1459 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001460 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301461 if (VOS_IS_STATUS_SUCCESS(vos_status))
1462 hdd_fill_station_info(pSapCtx,
1463 &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent);
Amar Singhal6144c002013-05-03 16:11:42 -07001464
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301465 staId =
1466 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1467 if (VOS_IS_STATUS_SUCCESS(vos_status))
1468 {
1469
1470 pSapCtx->aStaInfo[staId].rate_flags =
1471 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1472 }
1473
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 // Stop AP inactivity timer
1475 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1476 {
1477 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1478 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001479 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001481#ifdef WLAN_OPEN_SOURCE
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301482 if (vos_wake_lock_active(&pHddCtx->sap_wake_lock))
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001483 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301484 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1485 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001486 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301487 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1488 HDD_SAP_WAKE_LOCK_DURATION,
1489 WIFI_POWER_EVENT_WAKELOCK_SAP);
1490
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001491#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001492#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1493 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301494 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1496
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301497 staInfo = vos_mem_malloc(sizeof(*staInfo));
1498 if (staInfo == NULL) {
1499 hddLog(LOGE, FL("alloc station_info failed"));
1500 return VOS_STATUS_E_NOMEM;
1501 }
1502
1503 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1505 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301506 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301508 staInfo->assoc_req_ies_len = iesLen;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301509#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) && \
1510 ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
1511 !defined(WITH_BACKPORTS))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301512 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001513#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 cfg80211_new_sta(dev,
1515 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301516 staInfo, GFP_KERNEL);
1517 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 }
1519 else
1520 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001521 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 }
1523 }
1524#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301525 hdd_manage_delack_timer(pHddCtx);
1526
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001527 pScanInfo = &pHddCtx->scan_info;
1528 // Lets do abort scan to ensure smooth authentication for client
1529 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1530 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301531 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301532 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001534
1535 break;
1536 case eSAP_STA_DISASSOC_EVENT:
1537 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001538 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001539 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05301540
1541 vos_status = vos_event_set(&pHostapdState->sta_discon_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1543 hddLog(LOG1," User initiated disassociation");
1544 else
1545 hddLog(LOG1," MAC initiated disassociation");
1546 we_event = IWEVEXPIRED;
1547 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1548 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1549 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001550 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 -07001551 return VOS_STATUS_E_FAILURE;
1552 }
1553 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1554
1555 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1556 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301557 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 // Start AP inactivity timer if no stations associated with it
1559 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1560 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301561 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 {
1563 bApActive = TRUE;
1564 break;
1565 }
1566 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301567 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001568
1569 if (bApActive == FALSE)
1570 {
1571 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1572 {
1573 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1574 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001575 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 }
1577 else
1578 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1579 }
1580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001581#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1582 cfg80211_del_sta(dev,
1583 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1584 GFP_KERNEL);
1585#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001586 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301587 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1588 if (VOS_STATUS_SUCCESS != vos_status)
1589 {
1590 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1591 __func__, vos_status);
1592 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301593 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 break;
1595 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1596 {
1597 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1598 union iwreq_data wreq;
1599
1600 down(&pHddApCtx->semWpsPBCOverlapInd);
1601 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1602
1603 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1604 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1605
1606 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001607 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 memset(&wreq, 0, sizeof(wreq));
1609 wreq.data.length = strlen(message); // This is length of message
1610 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1611
1612 return VOS_STATUS_SUCCESS;
1613 }
1614 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1615 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1616 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1617 { // List of associated stations
1618 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1619 {
1620 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1621 i+1,
1622 pAssocStasArray->assocId,
1623 pAssocStasArray->staId,
1624 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1625 pAssocStasArray++;
1626 }
1627 }
1628 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001629 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 case eSAP_REMAIN_CHAN_READY:
1632 hdd_remainChanReadyHandler( pHostapdAdapter );
1633 return VOS_STATUS_SUCCESS;
1634 case eSAP_SEND_ACTION_CNF:
1635 hdd_sendActionCnf( pHostapdAdapter,
1636 ( eSAP_STATUS_SUCCESS ==
1637 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1638 TRUE : FALSE );
1639 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 case eSAP_UNKNOWN_STA_JOIN:
1641 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1642 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1643 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1644 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1645 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1646 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1647 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1648 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1649 wrqu.data.pointer = unknownSTAEvent;
1650 wrqu.data.length = strlen(unknownSTAEvent);
1651 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301652 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 break;
1654
1655 case eSAP_MAX_ASSOC_EXCEEDED:
1656 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1657 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1658 " one or more devices to enable the new device connection",
1659 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1660 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1661 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1662 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1663 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1664 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1665 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1666 wrqu.data.pointer = maxAssocExceededEvent;
1667 wrqu.data.length = strlen(maxAssocExceededEvent);
1668 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001669 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 break;
1671 case eSAP_STA_ASSOC_IND:
1672 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001673
1674 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001675 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001676 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1677 return VOS_STATUS_SUCCESS;
1678
1679 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301680 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301681 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1682 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301683 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301684 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001685 return VOS_STATUS_SUCCESS;
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301686 case eSAP_CHANNEL_CHANGED_EVENT:
1687 hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001688
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301689 return hdd_chan_change_notify(pHostapdAdapter, dev,
1690 pSapEvent->sapevt.sap_chan_selected.new_chan);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301691 case eSAP_STA_LOSTLINK_DETECTED:
1692 {
1693 tSap_StationDisassocCompleteEvent *disassoc_comp =
1694 &pSapEvent->sapevt.sapStationDisassocCompleteEvent;
1695
1696 struct hdd_cache_sta_info *sta_info = hdd_get_cache_stainfo(
1697 pSapCtx->cache_sta_info,
1698 disassoc_comp->staMac.bytes);
1699 if (!sta_info) {
1700 hddLog(LOGE, FL("invalid cache sta info"));
1701 return VOS_STATUS_E_FAILURE;
1702 }
1703
1704 WLANTL_GetSAPStaRSSi(pVosContext, disassoc_comp->staId,
1705 &sta_info->rssi);
1706 sta_info->rx_rate =
1707 wlan_tl_get_sta_rx_rate(pVosContext, disassoc_comp->staId);
1708 if (disassoc_comp->reason != eSAP_USR_INITATED_DISASSOC)
1709 sta_info->reason_code = disassoc_comp->reason;
1710 return VOS_STATUS_SUCCESS;
1711 }
1712
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001714 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 goto stopbss;
1716 return VOS_STATUS_SUCCESS;
1717 }
1718 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1719 return VOS_STATUS_SUCCESS;
1720
1721stopbss :
1722 {
1723 v_BYTE_t we_custom_event[64];
1724 char *stopBssEvent = "STOP-BSS.response";//17
1725 int event_len = strlen(stopBssEvent);
1726
1727 hddLog(LOG1, FL("BSS stop status = %s"),
1728 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1729 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1730
1731 /* Change the BSS state now since, as we are shutting things down,
1732 * we don't want interfaces to become re-enabled */
1733 pHostapdState->bssState = BSS_STOP;
1734
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301735 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1736 {
1737 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1738 {
1739 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1740 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1741 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1742 }
1743
1744 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1745 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1746 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1747 }
1748
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 /* Stop the pkts from n/w stack as we are going to free all of
1750 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301751
1752 /*
1753 * If channel avoidance is in progress means driver is performing SAP
1754 * restart. So don't do carrier off, which may lead framework to do
1755 * driver reload.
1756 */
1757 hddLog(LOG1, FL("ch avoid in progress: %d"),
1758 pHddCtx->is_ch_avoid_in_progress);
1759 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301760 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301761 netif_tx_disable(dev);
1762 else
1763 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301766 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1767 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1768 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
Amar Singhal37e6f052013-03-05 16:16:54 -08001770 /* once the event is set, structure dev/pHostapdAdapter should
1771 * not be touched since they are now subject to being deleted
1772 * by another thread */
1773 if (eSAP_STOP_BSS_EVENT == sapEvent)
1774 vos_event_set(&pHostapdState->vosEvent);
1775
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +05301776 if (hdd_is_any_session_connected(pHddCtx) == VOS_STATUS_E_FAILURE) {
1777 hdd_enable_bmps_imps(pHddCtx);
1778 sme_request_imps(pHddCtx->hHal);
1779 }
1780
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 /* notify userspace that the BSS has stopped */
1782 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1783 memcpy(&we_custom_event, stopBssEvent, event_len);
1784 memset(&wrqu, 0, sizeof(wrqu));
1785 wrqu.data.length = event_len;
1786 we_event = IWEVCUSTOM;
1787 we_custom_event_generic = we_custom_event;
1788 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001789 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 }
Bala Venkatesh5c06a252018-07-12 16:08:04 +05301791 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO ||
1792 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
1793 {
1794 hddLog(LOG1,
1795 FL("SAP or Go is getting removed and we are trying to re-enable TDLS"));
1796 wlan_hdd_tdls_reenable(pHddCtx);
1797 }
1798
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 return VOS_STATUS_SUCCESS;
1800}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001801
1802int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001804 eCsrEncryptionType *pEncryptType,
1805 eCsrEncryptionType *mcEncryptType,
1806 eCsrAuthType *pAuthType,
1807 v_BOOL_t *pMFPCapable,
1808 v_BOOL_t *pMFPRequired,
1809 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 u_int8_t *gen_ie )
1811{
1812 tDot11fIERSN dot11RSNIE;
1813 tDot11fIEWPA dot11WPAIE;
1814
1815 tANI_U8 *pRsnIe;
1816 tANI_U16 RSNIeLen;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301817 tANI_U32 status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001818
1819 if (NULL == halHandle)
1820 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001821 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 return -EINVAL;
1823 }
1824
1825 // Validity checks
1826 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1827 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1828 return -EINVAL;
1829 // Type check
1830 if ( gen_ie[0] == DOT11F_EID_RSN)
1831 {
1832 // Validity checks
1833 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1834 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1835 {
1836 return VOS_STATUS_E_FAILURE;
1837 }
1838 // Skip past the EID byte and length byte
1839 pRsnIe = gen_ie + 2;
1840 RSNIeLen = gen_ie_len - 2;
1841 // Unpack the RSN IE
1842 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301843
1844 status = sme_unpack_rsn_ie(halHandle,
1845 pRsnIe,
1846 RSNIeLen,
1847 &dot11RSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05301848 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301849 {
1850 hddLog(LOGE,
1851 FL("unpack failed for RSN IE status:(0x%08x)"),
1852 status);
1853 return -EINVAL;
1854 }
1855
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001857 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001858 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001859 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301860 __func__, dot11RSNIE.akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 /*Here we have followed the apple base code,
1862 but probably I suspect we can do something different*/
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301863 //dot11RSNIE.akm_suite_cnt
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301865 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 //dot11RSNIE.pwise_cipher_suite_count
1867 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1868 //dot11RSNIE.gp_cipher_suite_count
1869 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1870 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001871 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1872 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001873
1874 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1875 } else
1876 if (gen_ie[0] == DOT11F_EID_WPA)
1877 {
1878 // Validity checks
1879 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1880 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1881 {
1882 return VOS_STATUS_E_FAILURE;
1883 }
1884 // Skip past the EID byte and length byte - and four byte WiFi OUI
1885 pRsnIe = gen_ie + 2 + 4;
1886 RSNIeLen = gen_ie_len - (2 + 4);
1887 // Unpack the WPA IE
1888 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301889 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1890 pRsnIe,
1891 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301893 if (DOT11F_FAILED(status))
1894 {
1895 hddLog(LOGE,
1896 FL("unpack failed for WPA IE status:(0x%08x)"),
1897 status);
1898 return -EINVAL;
1899 }
1900
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001902 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001903 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001904 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001905 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 //dot11WPAIE.auth_suite_count
1907 // Just translate the FIRST one
1908 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1909 //dot11WPAIE.unicast_cipher_count
1910 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1911 //dot11WPAIE.unicast_cipher_count
1912 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001913 *pMFPCapable = VOS_FALSE;
1914 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 }
1916 else
1917 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001918 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 return VOS_STATUS_E_FAILURE;
1920 }
1921 return VOS_STATUS_SUCCESS;
1922}
Leo Chang614d2072013-08-22 14:59:44 -07001923
Leo Chang0b0e45a2013-12-15 15:18:55 -08001924#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001925
1926/*==========================================================================
1927 FUNCTION sapUpdateUnsafeChannelList
1928
1929 DESCRIPTION
1930 Function Undate unsafe channel list table
1931
1932 DEPENDENCIES
1933 NA.
1934
1935 PARAMETERS
1936
1937 IN
1938 pSapCtx : SAP context pointer, include unsafe channel list
1939
1940 RETURN VALUE
1941 NONE
1942============================================================================*/
1943void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1944 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1945{
1946 v_U16_t i, j;
1947
1948 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1949 sizeof(pHddCtx->unsafeChannelList));
1950 if (0 == unsafeChannelCount)
1951 {
1952 pHddCtx->unsafeChannelCount = 0;
1953 }
1954 else
1955 {
c_hpothu8de53e42014-08-22 15:00:37 +05301956 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1957 {
1958 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1959 FL("unsafeChannelCount%hd greater than %d"),
1960 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1961 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1962 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001963 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1964 unsafeChannelList,
1965 unsafeChannelCount * sizeof(tANI_U16));
1966 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1967 }
1968
1969 /* Flush, default set all channel safe */
1970 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1971 {
1972 safeChannels[i].isSafe = VOS_TRUE;
1973 }
1974
1975 /* Try to find unsafe channel */
1976 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1977 {
1978 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1979 {
1980 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1981 {
1982 /* Found unsafe channel, update it */
1983 safeChannels[j].isSafe = VOS_FALSE;
1984 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1985 "%s : CH %d is not safe",
1986 __func__, pHddCtx->unsafeChannelList[i]);
1987 break;
1988 }
1989 }
1990 }
1991
1992 return;
1993}
1994
Kapil Gupta137ef892016-12-13 19:38:00 +05301995/**
1996 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1997 * @adapter: hdd ap adapter
1998 *
1999 * hdd_unsafe_channel_restart_sap check all unsafe channel list
2000 * and if ACS is enabled, driver will ask userspace to restart the
2001 * sap. User space on LTE coex indication restart driver.
2002 *
2003 * Return - none
2004 */
2005static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
2006 hdd_context_t *hdd_ctx)
2007{
2008
2009 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
2010 return;
2011 }
2012
2013 hddLog(LOG1, FL("Current operation channel %d"),
2014 adapter->sessionCtx.ap.operatingChannel);
2015 if (false == hdd_ctx->is_ch_avoid_in_progress) {
2016 hdd_change_ch_avoidance_status(hdd_ctx, true);
2017
2018 vos_flush_work(
2019 &hdd_ctx->sap_start_work);
2020
2021 /*
2022 * current operating channel
2023 * is un-safe channel, restart SAP
2024 */
2025 hddLog(LOG1,
2026 FL("Restarting SAP due to unsafe channel"));
2027
2028 adapter->sessionCtx.ap.sapConfig.channel =
2029 AUTO_CHANNEL_SELECT;
2030
Kapil Gupta137ef892016-12-13 19:38:00 +05302031
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302032 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05302033 netif_tx_disable(adapter->dev);
2034 schedule_work(&hdd_ctx->sap_start_work);
2035 } else {
2036 hdd_hostapd_stop(adapter->dev);
2037 }
Kapil Gupta137ef892016-12-13 19:38:00 +05302038
2039 return;
2040 }
2041 return;
2042}
2043
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302044static v_U16_t hdd_get_safe_channel_from_acs_range(hdd_context_t *hdd_ctx,
2045 hdd_adapter_t *sap_adapter, v_U16_t *unsafeChannelList,
2046 v_U16_t unsafeChannelCount)
2047{
2048 v_U8_t valid_channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2049 v_U32_t startChannelNum;
2050 v_U32_t endChannelNum;
2051 v_U32_t valid_channel_count = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2052 v_U16_t i, j;
2053 eHalStatus status;
2054 bool found;
2055
2056 status = sme_GetCfgValidChannels(hdd_ctx->hHal, valid_channels,
2057 &valid_channel_count);
2058 if (!HAL_STATUS_SUCCESS(status))
2059 return 0;
2060
2061 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL,
2062 &startChannelNum);
2063 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL,
2064 &endChannelNum);
2065
2066 for (i = 0; i < valid_channel_count; i++) {
2067 found = false;
2068 for (j = 0; j < unsafeChannelCount; j++) {
2069 if (valid_channels[i] == unsafeChannelList[j]) {
2070 found = true;
2071 break;
2072 }
2073 }
2074
2075 if (found)
2076 continue;
2077
2078 if ((valid_channels[i] >= startChannelNum) &&
2079 (valid_channels[i] <= endChannelNum)) {
2080 return valid_channels[i];
2081 }
2082 }
2083
2084 return 0;
2085}
2086
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302087void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
2088 hdd_context_t *hdd_ctxt)
2089{
2090 v_U16_t channelLoop;
2091 v_U16_t unsafeChannelCount = 0;
2092 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302093 v_U16_t sta_chan;
2094 v_U16_t restart_chan;
2095 v_CONTEXT_t vos_ctx;
2096 ptSapContext sap_ctx;
2097
2098 vos_ctx = hdd_ctxt->pvosContext;
2099 if (!vos_ctx) {
2100 hddLog(LOGE, FL("vos_ctx is NULL"));
2101 return;
2102 }
2103
2104 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
2105 if (!sap_ctx) {
2106 hddLog(LOGE, FL("sap_ctx is NULL"));
2107 return;
2108 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302109
2110 /* Get unsafe channel list */
2111 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
2112 &unsafeChannelCount);
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302113 sta_chan = hdd_get_operating_channel(hdd_ctxt, WLAN_HDD_INFRA_STATION);
2114
2115 if (sta_chan) {
2116 hddLog(LOG1, FL("Only SCC supported for STA+SAP"));
2117 return;
2118 }
2119
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302120 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
2121 {
2122 if ((unsafeChannelList[channelLoop] ==
2123 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
2124 if ((AUTO_CHANNEL_SELECT ==
2125 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
2126 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
2127 /*
2128 * current operating channel is un-safe channel
2129 * restart driver
2130 */
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302131 if (hdd_ctxt->cfg_ini->force_scc_with_ecsa) {
2132 restart_chan = hdd_get_safe_channel_from_acs_range(hdd_ctxt,
2133 phostapd_adapter, unsafeChannelList,
2134 unsafeChannelCount);
2135
2136 if (!restart_chan) {
2137 hddLog(LOGE, FL("Failed to restart SAP as no safe channel found"));
2138 return;
2139 } else {
2140 if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx))
2141 return;
2142 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
2143 if (wlansap_set_channel_change(vos_ctx, restart_chan,
2144 false)) {
2145 wlansap_reset_chan_change_in_progress(sap_ctx);
2146 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2147 return;
2148 }
2149 }
2150 } else {
2151 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
2152 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302153 /*
2154 * On LE, this event is handled by wlan-services to
2155 * restart SAP. On android, this event would be
2156 * ignored.
2157 */
2158 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
2159 NULL, 0);
2160 }
2161 break;
2162 }
2163 }
2164 return;
2165}
2166
2167
Kapil Gupta137ef892016-12-13 19:38:00 +05302168
Leo Chang0b0e45a2013-12-15 15:18:55 -08002169/**---------------------------------------------------------------------------
2170
2171 \brief hdd_hostapd_ch_avoid_cb() -
2172
2173 Avoid channel notification from FW handler.
2174 FW will send un-safe channle list to avoid overwrapping.
2175 hostapd should not use notified channel
2176
2177 \param - pAdapter HDD adapter pointer
2178 indParam channel avoid notification parameter
2179
2180 \return - None
2181
2182 --------------------------------------------------------------------------*/
2183void hdd_hostapd_ch_avoid_cb
2184(
Kapil Gupta137ef892016-12-13 19:38:00 +05302185 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08002186 void *indParam
2187)
2188{
2189 hdd_adapter_t *pHostapdAdapter = NULL;
2190 hdd_context_t *hddCtxt;
2191 tSirChAvoidIndType *chAvoidInd;
2192 v_U8_t rangeLoop;
2193 v_U16_t channelLoop;
2194 v_U16_t dupCheck;
2195 v_U16_t startChannel;
2196 v_U16_t endChannel;
2197 v_U16_t unsafeChannelCount = 0;
2198 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
2199 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002200 tHddAvoidFreqList hddAvoidFreqList;
2201 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302202#ifdef WLAN_FEATURE_AP_HT40_24G
2203 ptSapContext pSapCtx = NULL;
2204 tHalHandle hHal;
2205 v_U8_t cbMode;
2206 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2207 v_U32_t delay;
2208#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002209
2210 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05302211 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002212 {
2213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2214 "%s : Invalid arguments", __func__);
2215 return;
2216 }
2217
Kapil Gupta137ef892016-12-13 19:38:00 +05302218 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08002219 chAvoidInd = (tSirChAvoidIndType *)indParam;
2220 pVosContext = hddCtxt->pvosContext;
2221
2222 /* Make unsafe channel list */
2223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2224 "%s : band count %d",
2225 __func__, chAvoidInd->avoidRangeCount);
2226 vos_mem_zero((void *)unsafeChannelList,
2227 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
2228 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
2229 {
Abhishek Singh57a31542016-01-04 21:01:43 +05302230 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2231 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2232 break;
2233 }
2234 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002235 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05302236 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002237 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
2238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2239 "%s : start %d : %d, end %d : %d",
2240 __func__,
2241 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
2242 startChannel,
2243 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
2244 endChannel);
2245 for (channelLoop = startChannel;
2246 channelLoop < (endChannel + 1);
2247 channelLoop++)
2248 {
2249 /* Channel duplicate check routine */
2250 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
2251 {
2252 if (unsafeChannelList[dupCheck] == channelLoop)
2253 {
2254 /* This channel is duplicated */
2255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2256 "%s : found duplicated channel %d",
2257 __func__, channelLoop);
2258 break;
2259 }
2260 }
2261 if (dupCheck == unsafeChannelCount)
2262 {
c_hpothu8de53e42014-08-22 15:00:37 +05302263 int ii;
2264 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
2265 {
2266 if (channelLoop == safeChannels[ii].channelNumber)
2267 {
2268 unsafeChannelList[unsafeChannelCount] = channelLoop;
2269 unsafeChannelCount++;
2270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2271 "%s : unsafe channel %d, count %d",
2272 __func__,
2273 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05302274 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2275 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2276 break;
2277 }
c_hpothu8de53e42014-08-22 15:00:37 +05302278 }
2279 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08002280 }
2281 else
2282 {
2283 /* DUP, do nothing */
2284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2285 "%s : duplicated channel %d",
2286 __func__, channelLoop);
2287 }
2288 }
2289 }
2290 /* Update unsafe channel cache
2291 * WCN Platform Driver cache */
2292 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
2293 unsafeChannelCount);
2294
2295 /* Store into local cache
2296 * Start with STA and later start SAP
2297 * in this scenario, local cache will be used */
2298 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
2299 unsafeChannelList,
2300 unsafeChannelCount);
2301
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002302 /* generate vendor specific event */
2303 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
2304 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
2305 {
2306 hddAvoidFreqList.avoidFreqRange[i].startFreq =
2307 chAvoidInd->avoidFreqRange[i].startFreq;
2308 hddAvoidFreqList.avoidFreqRange[i].endFreq =
2309 chAvoidInd->avoidFreqRange[i].endFreq;
2310 }
2311 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
2312
2313 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
2314
Leo Chang0b0e45a2013-12-15 15:18:55 -08002315 /* Get SAP context first
2316 * SAP and P2PGO would not concurrent */
2317 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302318#ifdef WLAN_FEATURE_AP_HT40_24G
2319 if (NULL == pHostapdAdapter)
2320 {
2321 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
2322 }
2323#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05302324 if ((pHostapdAdapter) &&
2325 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
2326 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002327 {
2328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2329 "%s : Current operation channel %d",
2330 __func__,
2331 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302332 /* Check and Restart the SAP if it is on unsafe channel */
2333 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
2334
Leo Chang0b0e45a2013-12-15 15:18:55 -08002335 }
2336
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302337#ifdef WLAN_FEATURE_AP_HT40_24G
2338 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
2339 {
2340 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2341
2342 if(pSapCtx == NULL)
2343 {
2344 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
2345 FL("psapCtx is NULL"));
2346 return;
2347 }
2348
2349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2350 FL("SAP Secondary channel: %d "),
2351 pSapCtx->sap_sec_chan);
2352
2353 /* tHalHandle */
2354 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2355
2356 if (NULL == hHal)
2357 {
2358 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2359 FL("In invalid hHal"));
2360 return;
2361 }
2362
2363 cbMode = sme_GetChannelBondingMode24G(hHal);
2364
2365 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2366 FL("Selected Channel bonding : %d"), cbMode);
2367
2368 if (cbMode && (pSapCtx->sap_sec_chan > 0))
2369 {
2370 int i;
2371 eHalStatus halStatus;
2372
2373 for (i = 0; i < unsafeChannelCount; i++)
2374 {
2375 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
2376 {
2377 /* Current SAP Secondary channel is un-safe channel */
2378 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2379 FL("Move SAP from HT40 to HT20"));
2380
2381 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
2382 PHY_SINGLE_CHANNEL_CENTERED);
2383
2384 if (halStatus == eHAL_STATUS_FAILURE)
2385 {
2386 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2387 FL("Failed to change HT20/40 mode"));
2388 return;
2389 }
2390
2391 /* Disable Channel Bonding for 2.4GHz */
2392 sme_UpdateChannelBondingMode24G(hHal,
2393 PHY_SINGLE_CHANNEL_CENTERED);
2394 return;
2395 }
2396 }
2397 }
2398
2399 if ((!pSapCtx->numHT40IntoSta)
2400 && (pHostapdAdapter)
2401 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
2402 {
2403 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
2404 * are Safe then start HT20/40 timer to Move SAP from HT20
2405 * to HT40.
2406 */
2407 if (((!unsafeChannelCount)
2408 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
2409 {
2410 /* Stop Previous Running HT20/40 Timer & Start timer
2411 with (OBSS TransitionDelayFactor * obss interval)
2412 delay after time out move AP from HT20 -> HT40
2413 mode
2414 */
2415 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2416 {
2417 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2418 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2419 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2420 FL("Failed to Stop HT20/40 timer"));
2421 }
2422
2423 delay =
2424 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
2425
2426 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2427 FL("Start HT20/40 transition timer (%d sec)"), delay);
2428
2429 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
2430 (delay * 1000));
2431
2432 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2433 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2434 FL("Failed to Start HT20/40 timer"));
2435 }
2436 else
2437 {
2438 /* Stop HT20/40 Timer */
2439 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2440 {
2441 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2442 FL("Stop HT20/40 transition timer"));
2443 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2444 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2445 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2446 FL("Failed to Stop HT20/40 timer"));
2447 }
2448 }
2449 }
2450 }
2451#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002452 return;
2453}
Leo Chang0b0e45a2013-12-15 15:18:55 -08002454#endif /* FEATURE_WLAN_CH_AVOID */
2455
Jeff Johnson295189b2012-06-20 16:38:30 -07002456int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302457static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 struct iw_request_info *info,
2459 union iwreq_data *wrqu, char *extra)
2460{
2461 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002462 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302463 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 int *value = (int *)extra;
2465 int sub_cmd = value[0];
2466 int set_value = value[1];
2467 eHalStatus status;
2468 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302469 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002470 v_CONTEXT_t pVosContext;
2471
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302472 ENTER();
2473
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302474 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002475 {
2476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302477 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002478 __func__);
2479 return -1;
2480 }
2481
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302482 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2483 ret = wlan_hdd_validate_context(pHddCtx);
2484 if (0 != ret)
2485 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302486 return -1;
2487 }
2488
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002489 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2490 if (!hHal)
2491 {
2492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2493 "%s: Hal ctx is null", __func__);
2494 return -1;
2495 }
2496
2497 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2498 if (!pVosContext)
2499 {
2500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2501 "%s: Vos ctx is null", __func__);
2502 return -1;
2503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002504
2505 switch(sub_cmd)
2506 {
2507
2508 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002509 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302511 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 }
2513 break;
2514
2515 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302516 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2518 {
2519 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2520 ret = -EINVAL;
2521 }
2522 else
2523 {
2524 WLANSAP_SetMode(pVosContext, set_value);
2525 }
2526 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302527
2528 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2529 if ((0 != set_value) && (1 != set_value))
2530 {
2531 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2532 ret = -EINVAL;
2533 }
2534 else
2535 {
2536 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2537 }
2538 break;
2539
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 case QCSAP_PARAM_MAX_ASSOC:
2541 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2542 {
2543 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2544 ret = -EINVAL;
2545 }
2546 else
2547 {
2548 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2549 {
2550 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2551 "Setting it to max allowed and continuing"),
2552 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2553 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2554 }
2555 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2556 set_value, NULL, eANI_BOOLEAN_FALSE);
2557 if ( status != eHAL_STATUS_SUCCESS )
2558 {
2559 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2560 status);
2561 ret = -EIO;
2562 }
2563 }
2564 break;
2565
2566 case QCSAP_PARAM_HIDE_SSID:
2567 {
2568 eHalStatus status = eHAL_STATUS_SUCCESS;
2569 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2570 if(eHAL_STATUS_SUCCESS != status)
2571 {
2572 hddLog(VOS_TRACE_LEVEL_ERROR,
2573 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002574 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 return status;
2576 }
2577 break;
2578 }
2579
Leo Chang614d2072013-08-22 14:59:44 -07002580 case QCSAP_PARAM_SET_MC_RATE:
2581 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002582 tSirRateUpdateInd *rateUpdate;
2583
2584 rateUpdate = (tSirRateUpdateInd *)
2585 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2586 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002587 {
2588 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002589 "%s: SET_MC_RATE indication alloc fail", __func__);
2590 ret = -1;
2591 break;
2592 }
2593 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2594
2595 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2596 /* Ignore unicast */
2597 rateUpdate->ucastDataRate = -1;
2598 rateUpdate->mcastDataRate24GHz = set_value;
2599 rateUpdate->mcastDataRate5GHz = set_value;
2600 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2601 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2602 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2603 if (eHAL_STATUS_SUCCESS != status)
2604 {
2605 hddLog(VOS_TRACE_LEVEL_ERROR,
2606 "%s: SET_MC_RATE failed", __func__);
2607 vos_mem_free(rateUpdate);
2608 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002609 }
2610 break;
2611 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302612 case QCSAP_PARAM_GET_FRAME_LOGS:
2613 {
2614 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2615 != VOS_STATUS_SUCCESS)
2616 {
2617 ret = -EINVAL;
2618 }
2619 break;
2620 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302621 case QCSAP_PARAM_SET_PROXIMITY:
2622 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302623 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302624 break;
2625 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302626 case QCSAP_PARAM_SET_WOWL:
2627 {
2628 if (!pHddCtx->is_ap_mode_wow_supported)
2629 {
2630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2631 "%s: Not supported",__func__);
2632 return -ENOTSUPP;
2633 }
2634 switch (set_value)
2635 {
2636 case 0x00:
2637 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2638 break;
2639 case 0x01:
2640 case 0x02:
2641 case 0x03:
2642 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2643 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2644 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2645 (enable_magic_pkt ? "YES":"NO"),
2646 (enable_pattrn_byte_match ? "YES":"NO"));
2647 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2648 enable_pattrn_byte_match);
2649 break;
2650 default:
2651 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2652 ret = -EINVAL;
2653 break;
2654 }
2655 break;
2656 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302657 case QCSAP_PARAM_CAP_TSF:
2658 {
2659 ret = hdd_capture_tsf(pHostapdAdapter,
2660 (uint32_t *)&set_value, 1);
2661 break;
2662 }
Abhishek Singh02605092017-10-25 14:06:12 +05302663 case QCSAP_PARAM_SET_CHANNEL_CHANGE:
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302664 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) {
2665 ptSapContext sap_ctx;
2666
2667 sap_ctx = VOS_GET_SAP_CB(pVosContext);
2668 if (!sap_ctx) {
2669 hddLog(LOGE, FL("sap_ctx is NULL"));
2670 return -EINVAL;
2671 }
2672 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
2673 if (ret)
2674 return ret;
2675 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
Abhishek Singh02605092017-10-25 14:06:12 +05302676 hddLog(LOG1, FL("ET Channel Change to new channel= %d"),
2677 set_value);
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302678 ret = wlansap_set_channel_change(pVosContext, set_value, false);
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302679 if (ret) {
2680 wlansap_reset_chan_change_in_progress(sap_ctx);
2681 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2682 }
Abhishek Singh02605092017-10-25 14:06:12 +05302683 } else {
2684 hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"),
2685 set_value);
2686 ret = -EINVAL;
2687 }
2688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 default:
2690 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2691 sub_cmd, set_value);
2692 ret = -EINVAL;
2693 break;
2694 }
2695
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302696 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 return ret;
2698}
2699
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302700int
2701static iw_softap_setparam(struct net_device *dev,
2702 struct iw_request_info *info,
2703 union iwreq_data *wrqu, char *extra)
2704{
2705 int ret;
2706
2707 vos_ssr_protect(__func__);
2708 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2709 vos_ssr_unprotect(__func__);
2710
2711 return ret;
2712}
Jeff Johnson295189b2012-06-20 16:38:30 -07002713
2714int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302715static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 struct iw_request_info *info,
2717 union iwreq_data *wrqu, char *extra)
2718{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302719 hdd_adapter_t *pHostapdAdapter;
2720 tHalHandle hHal;
2721 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 int *value = (int *)extra;
2723 int sub_cmd = value[0];
2724 eHalStatus status;
2725 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302726 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002727
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302728 ENTER();
2729
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302730 pHostapdAdapter = (netdev_priv(dev));
2731 if (NULL == pHostapdAdapter)
2732 {
2733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2734 "%s: Adapter is NULL",__func__);
2735 return -EINVAL;
2736 }
2737 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2738 ret = wlan_hdd_validate_context(pHddCtx);
2739 if (0 != ret)
2740 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302741 return ret;
2742 }
2743 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2744 if (NULL == hHal)
2745 {
2746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2747 "%s: Hal Context is NULL",__func__);
2748 return -EINVAL;
2749 }
2750 pVosContext = pHddCtx->pvosContext;
2751 if (NULL == pVosContext)
2752 {
2753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2754 "%s: pVosContext Context is NULL",__func__);
2755 return -EINVAL;
2756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 switch (sub_cmd)
2758 {
2759 case QCSAP_PARAM_MAX_ASSOC:
2760 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2761 if (eHAL_STATUS_SUCCESS != status)
2762 {
c_hpothuffdb5272013-10-02 16:42:35 +05302763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2764 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 ret = -EIO;
2766 }
Girish Gowli385be612014-09-18 11:17:20 +05302767
2768#ifdef WLAN_SOFTAP_VSTA_FEATURE
2769 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2770 {
2771 if (*value > VSTA_NUM_ASSOC_STA)
2772 {
2773 *value = VSTA_NUM_ASSOC_STA;
2774 }
2775 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2776 (*value > (VSTA_NUM_ASSOC_STA -
2777 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2778 {
2779 *value = (VSTA_NUM_ASSOC_STA -
2780 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2781 }
2782 }
2783 else
2784#endif
2785 {
2786 if (*value > NUM_ASSOC_STA)
2787 {
2788 *value = NUM_ASSOC_STA;
2789 }
2790 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2791 (*value > (NUM_ASSOC_STA -
2792 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2793 {
2794 *value = (NUM_ASSOC_STA -
2795 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2796 }
2797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302799
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002801 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 {
c_hpothuffdb5272013-10-02 16:42:35 +05302803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2804 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302805 ret = -EIO;
2806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 *value = 0;
2808 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302809
Jeff Johnson43971f52012-07-17 12:26:56 -07002810 case QCSAP_PARAM_GET_WLAN_DBG:
2811 {
2812 vos_trace_display();
2813 *value = 0;
2814 break;
2815 }
2816
2817 case QCSAP_PARAM_AUTO_CHANNEL:
2818 {
2819 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2820 break;
2821 }
2822
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 default:
2824 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2825 ret = -EINVAL;
2826 break;
2827
2828 }
2829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302830 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 return ret;
2832}
2833
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302834int
2835static iw_softap_getparam(struct net_device *dev,
2836 struct iw_request_info *info,
2837 union iwreq_data *wrqu, char *extra)
2838{
2839 int ret;
2840
2841 vos_ssr_protect(__func__);
2842 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2843 vos_ssr_unprotect(__func__);
2844
2845 return ret;
2846}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302847
2848int
2849static __iw_softap_setchar_getnone(struct net_device *dev,
2850 struct iw_request_info *info,
2851 union iwreq_data *wrqu, char *extra)
2852{
2853 int sub_cmd;
2854 int ret = 0; /* success */
2855 char *pBuffer = NULL;
2856 hdd_adapter_t *pAdapter;
2857 hdd_context_t *pHddCtx;
2858 struct iw_point s_priv_data;
2859
2860 ENTER();
2861
2862 if (!capable(CAP_NET_ADMIN))
2863 {
2864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2865 FL("permission check failed"));
2866 return -EPERM;
2867 }
2868
2869 pAdapter = (netdev_priv(dev));
2870 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2871 ret = wlan_hdd_validate_context(pHddCtx);
2872 if (0 != ret)
2873 {
2874 return ret;
2875 }
2876
2877 if (!pHddCtx->is_ap_mode_wow_supported)
2878 {
2879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2880 "%s: Not supported",__func__);
2881 return -ENOTSUPP;
2882 }
2883
2884 /* helper function to get iwreq_data with compat handling. */
2885 if (hdd_priv_get_data(&s_priv_data, wrqu))
2886 {
2887 return -EINVAL;
2888 }
2889
2890 /* make sure all params are correctly passed to function */
2891 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2892 {
2893 return -EINVAL;
2894 }
2895
2896 sub_cmd = s_priv_data.flags;
2897
2898 /* ODD number is used for set, copy data using copy_from_user */
2899 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2900 s_priv_data.length);
2901 if (NULL == pBuffer)
2902 {
2903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2904 "mem_alloc_copy_from_user_helper fail");
2905 return -ENOMEM;
2906 }
2907
2908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2909 "%s: Received length %d", __func__, s_priv_data.length);
2910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2911 "%s: Received data %s", __func__, pBuffer);
2912
2913 switch(sub_cmd)
2914 {
2915 case WE_WOWL_ADD_PTRN:
2916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2917 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2918 if (!ret)
2919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2920 "Failed to add pattern :%d", ret);
2921 break;
2922 case WE_WOWL_DEL_PTRN:
2923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2924 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2925 if (!ret)
2926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2927 "Failed to del pattern :%d", ret);
2928 break;
2929 default:
2930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2931 ret = -EINVAL;
2932 break;
2933 }
2934
2935 kfree(pBuffer);
2936 return ret;
2937}
2938
2939int
2940static iw_softap_setchar_getnone(struct net_device *dev,
2941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
2943{
2944 int ret;
2945
2946 vos_ssr_protect(__func__);
2947 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2948 vos_ssr_unprotect(__func__);
2949
2950 return ret;
2951}
2952
Jeff Johnson295189b2012-06-20 16:38:30 -07002953/* Usage:
2954 BLACK_LIST = 0
2955 WHITE_LIST = 1
2956 ADD MAC = 0
2957 REMOVE MAC = 1
2958
2959 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2960 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2961 while using this ioctl
2962
2963 Syntax:
2964 iwpriv softap.0 modify_acl
2965 <6 octet mac addr> <list type> <cmd type>
2966
2967 Examples:
2968 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2969 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2970 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2971 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2972*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302973int __iw_softap_modify_acl(struct net_device *dev,
2974 struct iw_request_info *info,
2975 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002976{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302977 hdd_adapter_t *pHostapdAdapter;
2978 v_CONTEXT_t pVosContext;
2979 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 v_BYTE_t *value = (v_BYTE_t*)extra;
2981 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2982 int listType, cmd, i;
2983 int ret = 0; /* success */
2984
2985 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302986 pHostapdAdapter = (netdev_priv(dev));
2987 if (NULL == pHostapdAdapter)
2988 {
2989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2990 "%s: Adapter is NULL",__func__);
2991 return -EINVAL;
2992 }
2993 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2994 ret = wlan_hdd_validate_context(pHddCtx);
2995 if (0 != ret)
2996 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302997 return ret;
2998 }
2999 pVosContext = pHddCtx->pvosContext;
3000 if (NULL == pVosContext)
3001 {
3002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3003 "%s: Vos Context is NULL",__func__);
3004 return -EINVAL;
3005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
3007 {
3008 pPeerStaMac[i] = *(value+i);
3009 }
3010 listType = (int)(*(value+i));
3011 i++;
3012 cmd = (int)(*(value+i));
3013
Arif Hussain24bafea2013-11-15 15:10:03 -08003014 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
3015 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003016
3017 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
3018 != VOS_STATUS_SUCCESS)
3019 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003020 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 ret = -EIO;
3022 }
3023 EXIT();
3024 return ret;
3025}
3026
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303027int iw_softap_modify_acl(struct net_device *dev,
3028 struct iw_request_info *info,
3029 union iwreq_data *wrqu, char *extra)
3030{
3031 int ret;
3032
3033 vos_ssr_protect(__func__);
3034 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
3035 vos_ssr_unprotect(__func__);
3036
3037 return ret;
3038}
3039
Jeff Johnson295189b2012-06-20 16:38:30 -07003040int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303041static __iw_softap_getchannel(struct net_device *dev,
3042 struct iw_request_info *info,
3043 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003044{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303045 hdd_adapter_t *pHostapdAdapter;
3046 hdd_context_t *pHddCtx;
3047 int ret = 0;
3048 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303049
3050 ENTER();
3051
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303052 pHostapdAdapter = (netdev_priv(dev));
3053 if (NULL == pHostapdAdapter)
3054 {
3055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3056 "%s: Adapter is NULL",__func__);
3057 return -EINVAL;
3058 }
3059 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3060 ret = wlan_hdd_validate_context(pHddCtx);
3061 if (0 != ret)
3062 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303063 return ret;
3064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003065
Mukul Sharma6d0762c2015-03-05 17:13:47 +05303066 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003067
Jeff Johnson43971f52012-07-17 12:26:56 -07003068 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303069
3070 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 return 0;
3072}
3073
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303074
Jeff Johnsone7245742012-09-05 17:12:55 -07003075int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303076static iw_softap_getchannel(struct net_device *dev,
3077 struct iw_request_info *info,
3078 union iwreq_data *wrqu, char *extra)
3079{
3080 int ret;
3081
3082 vos_ssr_protect(__func__);
3083 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
3084 vos_ssr_unprotect(__func__);
3085
3086 return ret;
3087}
3088
3089int
3090static __iw_softap_set_max_tx_power(struct net_device *dev,
3091 struct iw_request_info *info,
3092 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07003093{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303094 hdd_adapter_t *pHostapdAdapter;
3095 tHalHandle hHal;
3096 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07003097 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303098 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003099 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3100 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303102 ENTER();
3103
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303104 pHostapdAdapter = (netdev_priv(dev));
3105 if (NULL == pHostapdAdapter)
3106 {
3107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3108 "%s: Adapter is NULL",__func__);
3109 return -EINVAL;
3110 }
3111 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3112 ret = wlan_hdd_validate_context(pHddCtx);
3113 if (0 != ret)
3114 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303115 return ret;
3116 }
3117 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3118 if (NULL == hHal)
3119 {
3120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3121 "%s: Hal Context is NULL",__func__);
3122 return -EINVAL;
3123 }
schang86c22c42013-03-13 18:41:24 -07003124 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07003125 return -ENOMEM;
3126
Leo Changd37675a2013-08-01 13:19:45 -07003127 /* Assign correct slef MAC address */
3128 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
3129 VOS_MAC_ADDR_SIZE);
3130 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
3131 VOS_MAC_ADDR_SIZE);
3132
schang86c22c42013-03-13 18:41:24 -07003133 set_value = value[0];
3134 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
3135 {
3136 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003137 __func__);
schang86c22c42013-03-13 18:41:24 -07003138 return -EIO;
3139 }
3140
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303141 EXIT();
schang86c22c42013-03-13 18:41:24 -07003142 return 0;
3143}
3144
3145int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303146static iw_softap_set_max_tx_power(struct net_device *dev,
3147 struct iw_request_info *info,
3148 union iwreq_data *wrqu, char *extra)
3149{
3150 int ret;
3151
3152 vos_ssr_protect(__func__);
3153 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
3154 vos_ssr_unprotect(__func__);
3155
3156 return ret;
3157}
3158
3159
3160int
3161static __iw_display_data_path_snapshot(struct net_device *dev,
3162 struct iw_request_info *info,
3163 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303164{
3165
3166 /* Function intitiating dumping states of
3167 * HDD(WMM Tx Queues)
3168 * TL State (with Per Client infor)
3169 * DXE Snapshot (Called at the end of TL Snapshot)
3170 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303171 hdd_adapter_t *pHostapdAdapter;
3172 hdd_context_t *pHddCtx;
3173 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303174
3175 ENTER();
3176
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303177 pHostapdAdapter = (netdev_priv(dev));
3178 if (NULL == pHostapdAdapter)
3179 {
3180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3181 "%s: Adapter is NULL",__func__);
3182 return -EINVAL;
3183 }
3184 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3185 ret = wlan_hdd_validate_context(pHddCtx);
3186 if (0 != ret)
3187 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303188 return ret;
3189 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303190 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05303191 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303192
3193 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303194 return 0;
3195}
3196
3197int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303198static iw_display_data_path_snapshot(struct net_device *dev,
3199 struct iw_request_info *info,
3200 union iwreq_data *wrqu, char *extra)
3201{
3202 int ret;
3203
3204 vos_ssr_protect(__func__);
3205 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
3206 vos_ssr_unprotect(__func__);
3207
3208 return ret;
3209}
3210
3211int
3212static __iw_softap_set_tx_power(struct net_device *dev,
3213 struct iw_request_info *info,
3214 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07003215{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303216 hdd_adapter_t *pHostapdAdapter;
3217 hdd_context_t *pHddCtx;
3218 v_CONTEXT_t pVosContext;
3219 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07003220 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303221 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07003222 ptSapContext pSapCtx = NULL;
3223
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303224 ENTER();
3225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303226 pHostapdAdapter = (netdev_priv(dev));
3227 if (NULL == pHostapdAdapter)
3228 {
3229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3230 "%s: Adapter is NULL",__func__);
3231 return -EINVAL;
3232 }
3233 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3234 ret = wlan_hdd_validate_context(pHddCtx);
3235 if (0 != ret)
3236 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303237 return ret;
3238 }
3239 pVosContext = pHddCtx->pvosContext;
3240 if (NULL == pVosContext)
3241 {
3242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3243 "%s: Vos Context is NULL",__func__);
3244 return -EINVAL;
3245 }
3246 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3247 if (NULL == hHal)
3248 {
3249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3250 "%s: Hal Context is NULL",__func__);
3251 return -EINVAL;
3252 }
schang86c22c42013-03-13 18:41:24 -07003253 if (NULL == value)
3254 return -ENOMEM;
3255
3256 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3257 if (NULL == pSapCtx)
3258 {
3259 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3260 "%s: Invalid SAP pointer from pvosGCtx", __func__);
3261 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003262 }
3263
3264 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07003265 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07003266 {
schang86c22c42013-03-13 18:41:24 -07003267 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07003268 __func__);
3269 return -EIO;
3270 }
3271
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303272 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07003273 return 0;
3274}
3275
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303276int
3277static iw_softap_set_tx_power(struct net_device *dev,
3278 struct iw_request_info *info,
3279 union iwreq_data *wrqu, char *extra)
3280{
3281 int ret;
3282
3283 vos_ssr_protect(__func__);
3284 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
3285 vos_ssr_unprotect(__func__);
3286
3287 return ret;
3288}
3289
Kiet Lambcf38522013-10-26 18:28:27 +05303290/**---------------------------------------------------------------------------
3291
3292 \brief iw_softap_set_trafficmonitor() -
3293 This function dynamically enable/disable traffic monitor functonality
3294 the command iwpriv wlanX setTrafficMon <value>.
3295
3296 \param - dev - Pointer to the net device.
3297 - addr - Pointer to the sockaddr.
3298 \return - 0 for success, non zero for failure
3299
3300 --------------------------------------------------------------------------*/
3301
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303302static int __iw_softap_set_trafficmonitor(struct net_device *dev,
3303 struct iw_request_info *info,
3304 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05303305{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303306 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05303307 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05303308 hdd_context_t *pHddCtx;
3309 int status;
3310
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303311 ENTER();
3312
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303313 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05303314 if (NULL == pAdapter)
3315 {
3316 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3317 "%s: HDD adapter is Null", __func__);
3318 return -ENODEV;
3319 }
3320
3321 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3322
3323 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05303324 if (0 != status)
3325 {
Kiet Lambcf38522013-10-26 18:28:27 +05303326 return status;
3327 }
3328
3329 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
3330
3331 if (NULL == isSetTrafficMon)
3332 {
3333 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3334 "%s: Invalid SAP pointer from extra", __func__);
3335 return -ENOMEM;
3336 }
3337
3338 if (TRUE == *isSetTrafficMon)
3339 {
3340 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303341 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303342 {
3343 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3344 "%s: failed to Start Traffic Monitor timer ", __func__ );
3345 return -EIO;
3346 }
3347 }
3348 else if (FALSE == *isSetTrafficMon)
3349 {
3350 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303351 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303352 {
3353 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3354 "%s: failed to Stop Traffic Monitor timer ", __func__ );
3355 return -EIO;
3356 }
3357
3358 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303359
3360 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05303361 return 0;
3362}
3363
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303364static int iw_softap_set_trafficmonitor(struct net_device *dev,
3365 struct iw_request_info *info,
3366 union iwreq_data *wrqu, char *extra)
3367{
3368 int ret;
3369
3370 vos_ssr_protect(__func__);
3371 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
3372 vos_ssr_unprotect(__func__);
3373
3374 return ret;
3375}
3376
Jeff Johnson295189b2012-06-20 16:38:30 -07003377#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
3378
3379int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303380static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
3381 struct iw_request_info *info,
3382 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003383{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303384 hdd_adapter_t *pHostapdAdapter;
3385 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303386 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07003387 char *buf;
3388 int cnt = 0;
3389 int left;
3390 int ret = 0;
3391 /* maclist_index must be u32 to match userspace */
3392 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303393 v_CONTEXT_t pVosContext = NULL;
3394 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303396 ENTER();
3397
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303398 pHostapdAdapter = (netdev_priv(dev));
3399 if (NULL == pHostapdAdapter)
3400 {
3401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3402 "%s: Adapter is NULL",__func__);
3403 return -EINVAL;
3404 }
3405 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3406 ret = wlan_hdd_validate_context(pHddCtx);
3407 if (0 != ret)
3408 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303409 return ret;
3410 }
3411
Jeff Johnson224f3702014-03-26 11:09:47 -07003412 /*
3413 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
3414 * number, and even numbered iocts are supposed to have "set"
3415 * semantics. Hence the wireless extensions support in the kernel
3416 * won't correctly copy the result to userspace, so the ioctl
3417 * handler itself must copy the data. Output format is 32-bit
3418 * record length, followed by 0 or more 6-byte STA MAC addresses.
3419 *
3420 * Further note that due to the incorrect semantics, the "iwpriv"
3421 * userspace application is unable to correctly invoke this API,
3422 * hence it is not registered in the hostapd_private_args. This
3423 * API can only be invoked by directly invoking the ioctl() system
3424 * call.
3425 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003426
Jeff Johnson224f3702014-03-26 11:09:47 -07003427 /* make sure userspace allocated a reasonable buffer size */
3428 if (wrqu->data.length < sizeof(maclist_index)) {
3429 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
3430 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07003431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003432
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303433 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3434 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3435 if(pSapCtx == NULL){
3436 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3437 FL("psapCtx is NULL"));
3438 return -EFAULT;
3439 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05303440
3441 /* allocate local buffer to build the response */
3442 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
3443 if (!buf) {
3444 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
3445 return -ENOMEM;
3446 }
3447
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303448 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07003449 /* start indexing beyond where the record count will be written */
3450 maclist_index = sizeof(maclist_index);
3451 left = wrqu->data.length - maclist_index;
3452
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303453 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003454 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
3455 if ((pStaInfo[cnt].isUsed) &&
3456 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
3457 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
3458 VOS_MAC_ADDR_SIZE);
3459 maclist_index += VOS_MAC_ADDR_SIZE;
3460 left -= VOS_MAC_ADDR_SIZE;
3461 }
3462 cnt++;
3463 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303464 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003465
3466 *((u32 *)buf) = maclist_index;
3467 wrqu->data.length = maclist_index;
3468 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
3469 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
3470 ret = -EFAULT;
3471 }
3472 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303473
3474 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07003475 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003476}
3477
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303478int
3479static iw_softap_getassoc_stamacaddr(struct net_device *dev,
3480 struct iw_request_info *info,
3481 union iwreq_data *wrqu, char *extra)
3482{
3483 int ret;
3484
3485 vos_ssr_protect(__func__);
3486 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
3487 vos_ssr_unprotect(__func__);
3488
3489 return ret;
3490}
3491
Jeff Johnson295189b2012-06-20 16:38:30 -07003492/* Usage:
3493 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3494 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3495 while using this ioctl
3496
3497 Syntax:
3498 iwpriv softap.0 disassoc_sta <6 octet mac address>
3499
3500 e.g.
3501 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
3502 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
3503*/
3504
3505int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303506static __iw_softap_disassoc_sta(struct net_device *dev,
3507 struct iw_request_info *info,
3508 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003509{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303510 hdd_adapter_t *pHostapdAdapter;
3511 hdd_context_t *pHddCtx;
3512 v_U8_t *peerMacAddr;
3513 int ret = 0;
3514
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05303516
3517 if (!capable(CAP_NET_ADMIN)) {
3518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3519 FL("permission check failed"));
3520 return -EPERM;
3521 }
3522
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303523 pHostapdAdapter = (netdev_priv(dev));
3524 if (NULL == pHostapdAdapter)
3525 {
3526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3527 "%s: Adapter is NULL",__func__);
3528 return -EINVAL;
3529 }
3530 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3531 ret = wlan_hdd_validate_context(pHddCtx);
3532 if (0 != ret)
3533 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303534 return ret;
3535 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303536 /* iwpriv tool or framework calls this ioctl with
3537 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303539 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540
Arif Hussain24bafea2013-11-15 15:10:03 -08003541 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
3542 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
3544 EXIT();
3545 return 0;
3546}
3547
3548int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303549static iw_softap_disassoc_sta(struct net_device *dev,
3550 struct iw_request_info *info,
3551 union iwreq_data *wrqu, char *extra)
3552{
3553 int ret;
3554
3555 vos_ssr_protect(__func__);
3556 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3557 vos_ssr_unprotect(__func__);
3558
3559 return ret;
3560}
3561
3562int
3563static __iw_softap_ap_stats(struct net_device *dev,
3564 struct iw_request_info *info,
3565 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003566{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303567 hdd_adapter_t *pHostapdAdapter;
3568 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 WLANTL_TRANSFER_STA_TYPE statBuffer;
3570 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303571 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003572
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303573 ENTER();
3574
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303575 pHostapdAdapter = (netdev_priv(dev));
3576 if (NULL == pHostapdAdapter)
3577 {
3578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3579 "%s: Adapter is NULL",__func__);
3580 return -EINVAL;
3581 }
3582 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3583 ret = wlan_hdd_validate_context(pHddCtx);
3584 if (0 != ret)
3585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303586 return ret;
3587 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003588 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003589 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3590 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003591
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303592 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003593 if(NULL == pstatbuf) {
3594 hddLog(LOG1, "unable to allocate memory");
3595 return -ENOMEM;
3596 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303597
3598 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003599 "RUF=%d RMF=%d RBF=%d "
3600 "RUB=%d RMB=%d RBB=%d "
3601 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303602 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003603 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3604 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3605 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3606 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3607 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3608 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003609
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303610 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003611 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3612 kfree(pstatbuf);
3613 return -EFAULT;
3614 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303615
3616 strlcpy(extra, pstatbuf, len);
3617 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003618 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303619
3620 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 return 0;
3622}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303623int
3624static __iw_softap_ap_get_stats(struct net_device *dev,
3625 struct iw_request_info *info,
3626 union iwreq_data *wrqu, char *extra)
3627{
3628 hdd_adapter_t *pAdapter;
3629 hdd_tx_rx_stats_t *pStats;
3630
3631 ENTER();
3632 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3633 if (NULL == pAdapter)
3634 {
3635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3636 "%s: Adapter is NULL",__func__);
3637 return -EINVAL;
3638 }
3639
3640 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3641 snprintf(extra, QCSAP_MAX_STR_LEN,
3642 "\nTransmit"
3643 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3644 "\n dropped BK %u, BE %u, VI %u, VO %u"
3645 "\n classified BK %u, BE %u, VI %u, VO %u"
3646 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3647 "\n queued BK %u, BE %u, VI %u, VO %u"
3648 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3649 "\ndequeued %u, depressured %u, deque-depressured %u,\
3650 completed %u, flushed %u"
3651 "\n fetched BK %u, BE %u, VI %u, VO %u"
3652 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3653 "\n depressured BK %u, BE %u, VI %u, VO %u"
3654 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3655 "\n flushed BK %u, BE %u, VI %u, VO %u"
3656 "\n\nReceive"
3657 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3658 "\n\nResetsStats"
3659 "\n",
3660 pStats->txXmitCalled,
3661 pStats->txXmitDropped,
3662 pStats->txXmitBackPressured,
3663 pStats->txXmitQueued,
3664
3665 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3666 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3667 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3668 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3669
3670 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3671 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3672 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3673 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3674
3675 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3676 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3677 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3678 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3679
3680 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3681 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3682 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3683 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3684
3685 pStats->txFetched,
3686 pStats->txFetchEmpty,
3687 pStats->txFetchLowResources,
3688 pStats->txFetchDequeueError,
3689
3690 pStats->txFetchDequeued,
3691 pStats->txFetchDePressured,
3692 pStats->txDequeDePressured,
3693 pStats->txCompleted,
3694 pStats->txFlushed,
3695
3696 pStats->txFetchedAC[WLANTL_AC_BK],
3697 pStats->txFetchedAC[WLANTL_AC_BE],
3698 pStats->txFetchedAC[WLANTL_AC_VI],
3699 pStats->txFetchedAC[WLANTL_AC_VO],
3700
3701 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3702 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3703 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3704 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3705
3706 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3707 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3708 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3709 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3710
3711 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3712 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3713 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3714 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3715
3716 pStats->txFlushedAC[WLANTL_AC_BK],
3717 pStats->txFlushedAC[WLANTL_AC_BE],
3718 pStats->txFlushedAC[WLANTL_AC_VI],
3719 pStats->txFlushedAC[WLANTL_AC_VO],
3720
3721 pStats->rxChains,
3722 pStats->rxPackets,
3723 pStats->rxDropped,
3724 pStats->rxDelivered,
3725 pStats->rxRefused
3726 );
3727
3728 wrqu->data.length = strlen(extra) + 1;
3729
3730 return 0;
3731}
3732
3733int
3734static __iw_softap_ap_clear_stats(struct net_device *dev,
3735 struct iw_request_info *info,
3736 union iwreq_data *wrqu, char *extra)
3737{
3738 hdd_adapter_t *pAdapter;
3739
3740 ENTER();
3741
3742 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3743 if (NULL == pAdapter)
3744 {
3745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3746 "%s: Adapter is NULL",__func__);
3747 return -EINVAL;
3748 }
3749
3750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3751 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3752 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3753 return 0;
3754}
3755
3756
3757int
3758static iw_softap_get_stats(struct net_device *dev,
3759 struct iw_request_info *info,
3760 union iwreq_data *wrqu, char *extra)
3761{
3762 int ret;
3763 vos_ssr_protect(__func__);
3764 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3765 vos_ssr_unprotect(__func__);
3766 return ret;
3767}
3768
3769int
3770static iw_softap_clear_stats(struct net_device *dev,
3771 struct iw_request_info *info,
3772 union iwreq_data *wrqu, char *extra)
3773{
3774 int ret;
3775 vos_ssr_protect(__func__);
3776 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3777 vos_ssr_unprotect(__func__);
3778 return ret;
3779}
Jeff Johnson295189b2012-06-20 16:38:30 -07003780
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303781int
3782static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 struct iw_request_info *info,
3784 union iwreq_data *wrqu, char *extra)
3785{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303786 int ret;
3787
3788 vos_ssr_protect(__func__);
3789 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3790 vos_ssr_unprotect(__func__);
3791
3792 return ret;
3793}
3794
Manjeet Singh3ed79242017-01-11 19:04:32 +05303795/**
3796 * __iw_softap_get_three() - return three value to upper layer.
3797 *
3798 * @dev: pointer of net_device of this wireless card
3799 * @info: meta data about Request sent
3800 * @wrqu: include request info
3801 * @extra: buf used for in/out
3802 *
3803 * Return: execute result
3804 */
3805static int __iw_softap_get_three(struct net_device *dev,
3806 struct iw_request_info *info,
3807 union iwreq_data *wrqu, char *extra)
3808{
3809 uint32_t *value = (uint32_t *)extra;
3810 uint32_t sub_cmd = value[0];
3811 int ret = 0; /* success */
3812
3813 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3814
3815 switch (sub_cmd) {
3816 case QCSAP_IOCTL_GET_TSF:
3817 ret = hdd_indicate_tsf(padapter, value, 3);
3818 break;
3819 default:
3820 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3821 break;
3822 }
3823 return ret;
3824}
3825
3826
3827/**
3828 * iw_softap_get_three() - return three value to upper layer.
3829 *
3830 * @dev: pointer of net_device of this wireless card
3831 * @info: meta data about Request sent
3832 * @wrqu: include request info
3833 * @extra: buf used for in/Output
3834 *
3835 * Return: execute result
3836 */
3837static int iw_softap_get_three(struct net_device *dev,
3838 struct iw_request_info *info,
3839 union iwreq_data *wrqu, char *extra)
3840{
3841 int ret;
3842
3843 vos_ssr_protect(__func__);
3844 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3845 vos_ssr_unprotect(__func__);
3846
3847 return ret;
3848}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303849static int __iw_softap_set_channel_range(struct net_device *dev,
3850 struct iw_request_info *info,
3851 union iwreq_data *wrqu, char *extra)
3852{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303853 hdd_adapter_t *pHostapdAdapter;
3854 tHalHandle hHal;
3855 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 int *value = (int *)extra;
3857 int startChannel = value[0];
3858 int endChannel = value[1];
3859 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003860 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 int ret = 0; /* success */
3862
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303863 ENTER();
3864
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303865 if (!capable(CAP_NET_ADMIN))
3866 {
3867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3868 FL("permission check failed"));
3869 return -EPERM;
3870 }
3871
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303872 pHostapdAdapter = (netdev_priv(dev));
3873 if (NULL == pHostapdAdapter)
3874 {
3875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3876 "%s: Adapter is NULL",__func__);
3877 return -EINVAL;
3878 }
3879 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3880 ret = wlan_hdd_validate_context(pHddCtx);
3881 if (0 != ret)
3882 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303883 return ret;
3884 }
3885 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3886 if (NULL == hHal)
3887 {
3888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3889 "%s: Hal Context is NULL",__func__);
3890 return -EINVAL;
3891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3893 if(status != VOS_STATUS_SUCCESS)
3894 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003895 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 startChannel,endChannel, band);
3897 ret = -EINVAL;
3898 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003899
3900 pHddCtx->is_dynamic_channel_range_set = 1;
3901
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303902 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 return ret;
3904}
3905
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303906static int iw_softap_set_channel_range(struct net_device *dev,
3907 struct iw_request_info *info,
3908 union iwreq_data *wrqu, char *extra)
3909{
3910 int ret;
3911
3912 vos_ssr_protect(__func__);
3913 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3914 vos_ssr_unprotect(__func__);
3915
3916 return ret;
3917}
3918
3919
3920int __iw_softap_get_channel_list(struct net_device *dev,
3921 struct iw_request_info *info,
3922 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003923{
3924 v_U32_t num_channels = 0;
3925 v_U8_t i = 0;
3926 v_U8_t bandStartChannel = RF_CHAN_1;
3927 v_U8_t bandEndChannel = RF_CHAN_165;
3928 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303929 hdd_adapter_t *pHostapdAdapter;
3930 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003933 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303934 hdd_context_t *pHddCtx;
3935 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303936
3937 ENTER();
3938
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303939 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3940 if (NULL == pHostapdAdapter)
3941 {
3942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3943 "%s: Adapter is NULL",__func__);
3944 return -EINVAL;
3945 }
3946 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3947 ret = wlan_hdd_validate_context(pHddCtx);
3948 if (0 != ret)
3949 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303950 return ret;
3951 }
3952 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3953 if (NULL == hHal)
3954 {
3955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3956 "%s: Hal Context is NULL",__func__);
3957 return -EINVAL;
3958 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003959 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3960 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003961 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003962 return -EIO;
3963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 wrqu->data.length = sizeof(tChannelListInfo);
3965 ENTER();
3966
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003967 if (eCSR_BAND_24 == curBand)
3968 {
3969 bandStartChannel = RF_CHAN_1;
3970 bandEndChannel = RF_CHAN_14;
3971 }
3972 else if (eCSR_BAND_5G == curBand)
3973 {
3974 bandStartChannel = RF_CHAN_36;
3975 bandEndChannel = RF_CHAN_165;
3976 }
3977
Arif Hussain6d2a3322013-11-17 19:50:10 -08003978 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303979 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003980 bandStartChannel, bandEndChannel );
3981
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3983 {
3984 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3985 {
3986 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3987 num_channels++;
3988 }
3989 }
3990
3991 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3992
3993 temp_num_channels = num_channels;
3994
3995 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3996 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303997 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003998 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 }
4000
Agarwal Ashish7b557c02014-07-02 12:32:39 +05304001 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
4002 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 {
4004 for(i = 0; i < temp_num_channels; i++)
4005 {
4006
4007 if((channel_list->channels[i] > 35) &&
4008 (channel_list->channels[i] < 49))
4009 {
4010 vos_mem_move(&channel_list->channels[i],
4011 &channel_list->channels[i+1],
4012 temp_num_channels - (i-1));
4013 num_channels--;
4014 temp_num_channels--;
4015 i--;
4016 }
4017 }
4018 }
4019
Arif Hussain6d2a3322013-11-17 19:50:10 -08004020 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 channel_list->num_channels = num_channels;
4023 EXIT();
4024
4025 return 0;
4026}
4027
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304028int iw_softap_get_channel_list(struct net_device *dev,
4029 struct iw_request_info *info,
4030 union iwreq_data *wrqu, char *extra)
4031{
4032 int ret;
4033
4034 vos_ssr_protect(__func__);
4035 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
4036 vos_ssr_unprotect(__func__);
4037
4038 return ret;
4039}
4040
4041static
4042int __iw_get_genie(struct net_device *dev,
4043 struct iw_request_info *info,
4044 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004045{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304046 hdd_adapter_t *pHostapdAdapter;
4047 hdd_context_t *pHddCtx;
4048 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304049 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
4051 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304052 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304055
4056 pHostapdAdapter = (netdev_priv(dev));
4057 if (NULL == pHostapdAdapter)
4058 {
4059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4060 "%s: Adapter is NULL",__func__);
4061 return -EINVAL;
4062 }
4063 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4064 ret = wlan_hdd_validate_context(pHddCtx);
4065 if (0 != ret)
4066 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304067 return ret;
4068 }
4069 pVosContext = pHddCtx->pvosContext;
4070 if (NULL == pVosContext)
4071 {
4072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4073 "%s: vos context is not valid ",__func__);
4074 return -EINVAL;
4075 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004076 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
4078 status = WLANSap_getstationIE_information(pVosContext,
4079 &length,
4080 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05304081
4082 if (VOS_STATUS_SUCCESS != status) {
4083 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07004084 return -EFAULT;
4085 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05304086
Arif Hussained667642013-10-27 23:01:14 -07004087 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304088 if (length > DOT11F_IE_RSN_MAX_LEN) {
4089 hddLog(LOGE,
4090 FL("invalid buffer length length:%d"), length);
4091 return -E2BIG;
4092 }
4093
4094 vos_mem_copy(extra, genIeBytes, length);
4095
4096 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
4097
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 EXIT();
4099 return 0;
4100}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304101
4102static
4103int iw_get_genie(struct net_device *dev,
4104 struct iw_request_info *info,
4105 union iwreq_data *wrqu, char *extra)
4106{
4107 int ret;
4108
4109 vos_ssr_protect(__func__);
4110 ret = __iw_get_genie(dev, info, wrqu, extra);
4111 vos_ssr_unprotect(__func__);
4112
4113 return ret;
4114}
4115
4116static
4117int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4118 struct iw_request_info *info,
4119 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004120{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304121 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07004122 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304123 hdd_ap_ctx_t *pHddApCtx;
4124 hdd_context_t *pHddCtx;
4125 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304126
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07004128
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304129 pHostapdAdapter = (netdev_priv(dev));
4130 if (NULL == pHostapdAdapter)
4131 {
4132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4133 "%s: Adapter is NULL",__func__);
4134 return -EINVAL;
4135 }
4136 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4137 ret = wlan_hdd_validate_context(pHddCtx);
4138 if (0 != ret)
4139 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304140 return ret;
4141 }
4142 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4143 if (NULL == pHddApCtx)
4144 {
4145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4146 "%s: AP context is NULL",__func__);
4147 return -EINVAL;
4148 }
4149
Arif Hussain6d2a3322013-11-17 19:50:10 -08004150 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07004151 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
4152
4153 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
4154 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
4155 pHddApCtx->WPSPBCProbeReq.probeReqIE,
4156 WPSPBCProbeReqIEs.probeReqIELen);
4157 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
4158 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
4159 sizeof(v_MACADDR_t));
4160 if (copy_to_user(wrqu->data.pointer,
4161 (void *)&WPSPBCProbeReqIEs,
4162 sizeof(WPSPBCProbeReqIEs)))
4163 {
4164 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4165 return -EFAULT;
4166 }
4167 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004168 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07004169 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 up(&pHddApCtx->semWpsPBCOverlapInd);
4171 EXIT();
4172 return 0;
4173}
4174
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304175static
4176int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4177 struct iw_request_info *info,
4178 union iwreq_data *wrqu, char *extra)
4179{
4180 int ret;
4181
4182 vos_ssr_protect(__func__);
4183 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
4184 vos_ssr_unprotect(__func__);
4185
4186 return ret;
4187}
4188
Jeff Johnson295189b2012-06-20 16:38:30 -07004189/**---------------------------------------------------------------------------
4190
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304191 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 This function sets the auth type received from the wpa_supplicant.
4193
4194 \param - dev - Pointer to the net device.
4195 - info - Pointer to the iw_request_info.
4196 - wrqu - Pointer to the iwreq_data.
4197 - extra - Pointer to the data.
4198 \return - 0 for success, non zero for failure
4199
4200 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304201int __iw_set_auth_hostap(struct net_device *dev,
4202 struct iw_request_info *info,
4203 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004204{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304205 hdd_adapter_t *pAdapter;
4206 hdd_context_t *pHddCtx;
4207 hdd_wext_state_t *pWextState;
4208 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304209
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304211
4212 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4213 if (NULL == pAdapter)
4214 {
4215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4216 "%s: Adapter is NULL",__func__);
4217 return -EINVAL;
4218 }
4219
4220 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4221 ret = wlan_hdd_validate_context(pHddCtx);
4222 if (0 != ret)
4223 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304224 return ret;
4225 }
4226 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4227 if (NULL == pWextState)
4228 {
4229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4230 "%s: pWextState is NULL",__func__);
4231 return -EINVAL;
4232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 switch(wrqu->param.flags & IW_AUTH_INDEX)
4234 {
4235 case IW_AUTH_TKIP_COUNTERMEASURES:
4236 {
4237 if(wrqu->param.value) {
4238 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4239 "Counter Measure started %d", wrqu->param.value);
4240 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304241 }
4242 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4244 "Counter Measure stopped=%d", wrqu->param.value);
4245 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4246 }
4247
4248 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
4249 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304252
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304254
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004255 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 wrqu->param.flags & IW_AUTH_INDEX);
4257 break;
4258 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304259
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 EXIT();
4261 return 0;
4262}
4263
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304264int iw_set_auth_hostap(struct net_device *dev,
4265 struct iw_request_info *info,
4266 union iwreq_data *wrqu,char *extra)
4267{
4268 int ret;
4269
4270 vos_ssr_protect(__func__);
4271 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
4272 vos_ssr_unprotect(__func__);
4273
4274 return ret;
4275}
4276
4277static int __iw_set_ap_encodeext(struct net_device *dev,
4278 struct iw_request_info *info,
4279 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004280{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304281 hdd_adapter_t *pHostapdAdapter;
4282 v_CONTEXT_t pVosContext;
4283 hdd_context_t *pHddCtx;
4284 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07004285 int retval = 0;
4286 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4288 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4289 int key_index;
4290 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304291 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07004292// tCsrRoamRemoveKey RemoveKey;
4293 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304294
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304295 ENTER();
4296 pHostapdAdapter = (netdev_priv(dev));
4297 if (NULL == pHostapdAdapter)
4298 {
4299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4300 "%s: Adapter is NULL",__func__);
4301 return -EINVAL;
4302 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004303
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304304 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4305 retval = wlan_hdd_validate_context(pHddCtx);
4306 if (0 != retval)
4307 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304308 return retval;
4309 }
4310 pVosContext = pHddCtx->pvosContext;
4311 if (NULL == pVosContext)
4312 {
4313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4314 "%s: pVosContext is NULL",__func__);
4315 return -EINVAL;
4316 }
4317 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4318 if (NULL == pHddApCtx)
4319 {
4320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4321 "%s: AP Context is NULL",__func__);
4322 return -EINVAL;
4323 }
4324
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304326
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304328
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 /*Convert from 1-based to 0-based keying*/
4330 key_index--;
4331 }
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304332 if(!ext->key_len || ext->key_len > CSR_MAX_KEY_LEN) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304333#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 /*Set the encrytion type to NONE*/
4335#if 0
4336 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4337#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304338
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 RemoveKey.keyId = key_index;
4340 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4341 /*Key direction for group is RX only*/
4342 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4343 }
4344 else {
4345 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4346 }
4347 switch(ext->alg)
4348 {
4349 case IW_ENCODE_ALG_NONE:
4350 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4351 break;
4352 case IW_ENCODE_ALG_WEP:
4353 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4354 break;
4355 case IW_ENCODE_ALG_TKIP:
4356 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07004357 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 case IW_ENCODE_ALG_CCMP:
4359 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
4360 break;
4361 default:
4362 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4363 break;
4364 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004365 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 -07004366 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004368 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 );
Jeff Johnson43971f52012-07-17 12:26:56 -07004370 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
4371 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 {
4373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07004374 __LINE__, vstatus );
4375 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004377#endif
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304378 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004379
Jeff Johnson43971f52012-07-17 12:26:56 -07004380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004381
4382 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4383
4384 setKey.keyId = key_index;
4385 setKey.keyLength = ext->key_len;
4386
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304387 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004388
4389 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4390 /*Key direction for group is RX only*/
4391 setKey.keyDirection = eSIR_RX_ONLY;
4392 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4393 }
4394 else {
4395
4396 setKey.keyDirection = eSIR_TX_RX;
4397 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4398 }
4399 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4400 {
4401 setKey.keyDirection = eSIR_TX_DEFAULT;
4402 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4403 }
4404
4405 /*For supplicant pae role is zero*/
4406 setKey.paeRole = 0;
4407
4408 switch(ext->alg)
4409 {
4410 case IW_ENCODE_ALG_NONE:
4411 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4412 break;
4413
4414 case IW_ENCODE_ALG_WEP:
4415 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4416 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004417 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 break;
4419
4420 case IW_ENCODE_ALG_TKIP:
4421 {
4422 v_U8_t *pKey = &setKey.Key[0];
4423
4424 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4425
4426 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4427
4428 /*Supplicant sends the 32bytes key in this order
4429
4430 |--------------|----------|----------|
4431 | Tk1 |TX-MIC | RX Mic |
4432 |--------------|----------|----------|
4433 <---16bytes---><--8bytes--><--8bytes-->
4434
4435 */
4436 /*Sme expects the 32 bytes key to be in the below order
4437
4438 |--------------|----------|----------|
4439 | Tk1 |RX-MIC | TX Mic |
4440 |--------------|----------|----------|
4441 <---16bytes---><--8bytes--><--8bytes-->
4442 */
4443 /* Copy the Temporal Key 1 (TK1) */
4444 vos_mem_copy(pKey,ext->key,16);
4445
4446 /*Copy the rx mic first*/
4447 vos_mem_copy(&pKey[16],&ext->key[24],8);
4448
4449 /*Copy the tx mic */
4450 vos_mem_copy(&pKey[24],&ext->key[16],8);
4451
4452 }
4453 break;
4454
4455 case IW_ENCODE_ALG_CCMP:
4456 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4457 break;
4458
4459 default:
4460 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4461 break;
4462 }
4463
4464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304465 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 setKey.keyId);
4467 for(i=0; i< ext->key_len; i++)
4468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4469 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07004470
4471 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
4472 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 {
4474 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07004475 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
4476 retval = -EINVAL;
4477 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304478
4479 EXIT();
4480 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004481}
Jeff Johnson43971f52012-07-17 12:26:56 -07004482
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304483static int iw_set_ap_encodeext(struct net_device *dev,
4484 struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
4486{
4487 int ret;
4488
4489 vos_ssr_protect(__func__);
4490 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
4491 vos_ssr_unprotect(__func__);
4492
4493 return ret;
4494}
Jeff Johnson43971f52012-07-17 12:26:56 -07004495
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304496static int __iw_set_ap_mlme(struct net_device *dev,
4497 struct iw_request_info *info,
4498 union iwreq_data *wrqu,
4499 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004500{
4501#if 0
4502 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4503 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4504
4505 ENTER();
4506
4507 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4508 switch (mlme->cmd) {
4509 case IW_MLME_DISASSOC:
4510 case IW_MLME_DEAUTH:
4511 hddLog(LOG1, "Station disassociate");
4512 if( pAdapter->conn_info.connState == eConnectionState_Associated )
4513 {
4514 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4515
4516 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4517 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4518
4519 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
4520
4521 //clear all the reason codes
4522 if (status != 0)
4523 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004524 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 }
4526
4527 netif_stop_queue(dev);
4528 netif_carrier_off(dev);
4529 }
4530 else
4531 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004532 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 -07004533 }
4534 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004535 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 return -EINVAL;
4537 }//end of switch
4538 EXIT();
4539#endif
4540 return 0;
4541// return status;
4542}
4543
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304544static int iw_set_ap_mlme(struct net_device *dev,
4545 struct iw_request_info *info,
4546 union iwreq_data *wrqu,
4547 char *extra)
4548{
4549 int ret;
4550
4551 vos_ssr_protect(__func__);
4552 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4553 vos_ssr_unprotect(__func__);
4554
4555 return ret;
4556}
4557
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304558static int __iw_get_ap_rts_threshold(struct net_device *dev,
4559 struct iw_request_info *info,
4560 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004561{
4562 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4563 v_U32_t status = 0;
4564
4565 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4566
4567 return status;
4568}
4569
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304570static int iw_get_ap_rts_threshold(struct net_device *dev,
4571 struct iw_request_info *info,
4572 union iwreq_data *wrqu, char *extra)
4573{
4574 int ret;
4575
4576 vos_ssr_protect(__func__);
4577 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4578 vos_ssr_unprotect(__func__);
4579
4580 return ret;
4581}
4582
4583static int __iw_get_ap_frag_threshold(struct net_device *dev,
4584 struct iw_request_info *info,
4585 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004586{
4587 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4588 v_U32_t status = 0;
4589
4590 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4591
4592 return status;
4593}
4594
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304595static int iw_get_ap_frag_threshold(struct net_device *dev,
4596 struct iw_request_info *info,
4597 union iwreq_data *wrqu, char *extra)
4598{
4599 int ret;
4600
4601 vos_ssr_protect(__func__);
4602 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4603 vos_ssr_unprotect(__func__);
4604
4605 return ret;
4606}
4607
4608static int __iw_get_ap_freq(struct net_device *dev,
4609 struct iw_request_info *info,
4610 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004611{
Jeff Johnsone7245742012-09-05 17:12:55 -07004612 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304613 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 tHalHandle hHal;
4615 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304616 hdd_ap_ctx_t *pHddApCtx;
4617 hdd_context_t *pHddCtx;
4618 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004619
4620 ENTER();
4621
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304622 pHostapdAdapter = (netdev_priv(dev));
4623 if (NULL == pHostapdAdapter)
4624 {
4625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4626 "%s: Adapter is NULL",__func__);
4627 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304629 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4630 ret = wlan_hdd_validate_context(pHddCtx);
4631 if (0 != ret)
4632 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304633 return ret;
4634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304636 if (NULL == pHostapdState)
4637 {
4638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4639 "%s: pHostapdState is NULL",__func__);
4640 return -EINVAL;
4641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304643 if (NULL == hHal)
4644 {
4645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4646 "%s: Hal Context is NULL",__func__);
4647 return -EINVAL;
4648 }
4649 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4650 if (NULL == pHddApCtx)
4651 {
4652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4653 "%s: AP context is NULL",__func__);
4654 return -EINVAL;
4655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 if(pHostapdState->bssState == BSS_STOP )
4657 {
4658 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4659 != eHAL_STATUS_SUCCESS)
4660 {
c_hpothuffdb5272013-10-02 16:42:35 +05304661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4662 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 return -EIO;
4664 }
4665 else
4666 {
4667 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304668 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004669 {
4670 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4671 * iwlist & iwconfig command shows frequency into proper
4672 * format (2.412 GHz instead of 246.2 MHz)*/
4673 fwrq->m = freq;
4674 fwrq->e = MHZ;
4675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 }
4677 }
4678 else
4679 {
4680 channel = pHddApCtx->operatingChannel;
4681 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304682 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004683 {
4684 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4685 * iwlist & iwconfig command shows frequency into proper
4686 * format (2.412 GHz instead of 246.2 MHz)*/
4687 fwrq->m = freq;
4688 fwrq->e = MHZ;
4689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304691
4692 EXIT();
4693 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004694}
4695
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304696static int iw_get_ap_freq(struct net_device *dev,
4697 struct iw_request_info *info,
4698 struct iw_freq *fwrq, char *extra)
4699{
4700 int ret;
4701
4702 vos_ssr_protect(__func__);
4703 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4704 vos_ssr_unprotect(__func__);
4705
4706 return ret;
4707}
4708
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304709static int __iw_softap_stopbss(struct net_device *dev,
4710 struct iw_request_info *info,
4711 union iwreq_data *wrqu,
4712 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004713{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304714 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304716 hdd_context_t *pHddCtx = NULL;
4717
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304719 pHostapdAdapter = (netdev_priv(dev));
4720 if (NULL == pHostapdAdapter)
4721 {
4722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4723 "%s: Adapter is NULL",__func__);
4724 return -EINVAL;
4725 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304726 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4727 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304728 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304729 return status;
4730 }
4731
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304732 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +05304734 hdd_hostapd_state_t *pHostapdState =
4735 WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4736
4737 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4739 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304741
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304743 {
4744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004745 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 VOS_ASSERT(0);
4747 }
4748 }
4749 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304750 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 }
4752 EXIT();
4753 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4754}
4755
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304756static int iw_softap_stopbss(struct net_device *dev,
4757 struct iw_request_info *info,
4758 union iwreq_data *wrqu,
4759 char *extra)
4760{
4761 int ret;
4762
4763 vos_ssr_protect(__func__);
4764 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4765 vos_ssr_unprotect(__func__);
4766
4767 return ret;
4768}
4769
4770static int __iw_softap_version(struct net_device *dev,
4771 struct iw_request_info *info,
4772 union iwreq_data *wrqu,
4773 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004774{
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304776 hdd_context_t *pHddCtx;
4777 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304778
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304780 pHostapdAdapter = (netdev_priv(dev));
4781 if (NULL == pHostapdAdapter)
4782 {
4783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4784 "%s: Adapter is NULL",__func__);
4785 return -EINVAL;
4786 }
4787 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4788 ret = wlan_hdd_validate_context(pHddCtx);
4789 if (0 != ret)
4790 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304791 return ret;
4792 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004793 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 return 0;
4796}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004797
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304798static int iw_softap_version(struct net_device *dev,
4799 struct iw_request_info *info,
4800 union iwreq_data *wrqu,
4801 char *extra)
4802{
4803 int ret;
4804
4805 vos_ssr_protect(__func__);
4806 ret = __iw_softap_version(dev, info, wrqu, extra);
4807 vos_ssr_unprotect(__func__);
4808
4809 return ret;
4810}
4811
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304812int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004813{
4814 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004815 int len = 0;
4816 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304817 v_CONTEXT_t pVosContext;
4818 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304819 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304820
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304821 ENTER();
4822
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304823 if (NULL == pAdapter)
4824 {
4825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4826 "%s: Adapter is NULL",__func__);
4827 return -EINVAL;
4828 }
4829 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4830 if (0 != wlan_hdd_validate_context(pHddCtx))
4831 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304832 return VOS_STATUS_E_FAULT;
4833 }
4834 pVosContext = pHddCtx->pvosContext;
4835 if (NULL == pVosContext)
4836 {
4837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4838 "%s: VOS context is not valid",__func__);
4839 return VOS_STATUS_E_FAULT;
4840 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304841 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304842 if(pSapCtx == NULL)
4843 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304844 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4845 FL("psapCtx is NULL"));
4846 return VOS_STATUS_E_FAULT;
4847 }
4848
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304849 len = snprintf(pBuf, buf_len, sta_info_header);
4850 if (len >= buf_len) {
4851 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4852 return -E2BIG;
4853 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004854 pBuf += len;
4855 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004856
4857 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4858 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304859 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004860 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004861 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304862 pSapCtx->aStaInfo[i].ucSTAId,
4863 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4864 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4865 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4866 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4867 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4868 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304869 if (len >= buf_len) {
4870 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4871 return -E2BIG;
4872 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004873 pBuf += len;
4874 buf_len -= len;
4875 }
4876 if(WE_GET_STA_INFO_SIZE > buf_len)
4877 {
4878 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004879 }
4880 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304881 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304882 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004883}
4884
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304885static int __iw_softap_get_sta_info(struct net_device *dev,
4886 struct iw_request_info *info,
4887 union iwreq_data *wrqu,
4888 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004889{
4890 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304891 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004892 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304893 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4894 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004895 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304896 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004897 }
4898 wrqu->data.length = strlen(extra);
4899 EXIT();
4900 return 0;
4901}
4902
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304903static int iw_softap_get_sta_info(struct net_device *dev,
4904 struct iw_request_info *info,
4905 union iwreq_data *wrqu,
4906 char *extra)
4907{
4908 int ret;
4909
4910 vos_ssr_protect(__func__);
4911 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4912 vos_ssr_unprotect(__func__);
4913
4914 return ret;
4915}
4916
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304917static int __iw_set_ap_genie(struct net_device *dev,
4918 struct iw_request_info *info,
4919 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004920{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304921
4922 hdd_adapter_t *pHostapdAdapter;
4923 hdd_context_t *pHddCtx;
4924 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004926 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304927 int ret = 0;
4928
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304930 pHostapdAdapter = (netdev_priv(dev));
4931 if (NULL == pHostapdAdapter)
4932 {
4933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4934 "%s: Adapter is NULL",__func__);
4935 return -EINVAL;
4936 }
4937 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4938 ret = wlan_hdd_validate_context(pHddCtx);
4939 if (0 != ret)
4940 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304941 return ret;
4942 }
4943 pVosContext = pHddCtx->pvosContext;
4944 if (NULL == pVosContext)
4945 {
4946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4947 "%s: VOS Context is NULL",__func__);
4948 return -EINVAL;
4949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 if(!wrqu->data.length)
4951 {
4952 EXIT();
4953 return 0;
4954 }
Arif Hussained667642013-10-27 23:01:14 -07004955
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05304956 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
4957 {
4958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4959 "%s: WPARSN Ie input length is more than max[%d]", __func__,
4960 wrqu->data.length);
4961 return -EINVAL;
4962 }
4963
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304964 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304966 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 case DOT11F_EID_RSN:
4968 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4969 {
4970 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4971 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004974 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304976
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004978 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 halStatus = 0;
4980 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304983 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004984}
4985
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304986static int iw_set_ap_genie(struct net_device *dev,
4987 struct iw_request_info *info,
4988 union iwreq_data *wrqu, char *extra)
4989{
4990 int ret;
4991
4992 vos_ssr_protect(__func__);
4993 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4994 vos_ssr_unprotect(__func__);
4995
4996 return ret;
4997}
4998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
5000{
5001 eHalStatus hstatus;
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305002 int ret;
5003 void *cookie;
5004 struct hdd_request *request;
5005 struct stats_class_a_ctx *priv;
5006 static const struct hdd_request_params params = {
5007 .priv_size = sizeof(*priv),
5008 .timeout_ms = WLAN_WAIT_TIME_STATS,
5009 };
5010
Jeff Johnson295189b2012-06-20 16:38:30 -07005011
5012 if (NULL == pAdapter)
5013 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305014 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 return VOS_STATUS_E_FAULT;
5016 }
5017
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305018 request = hdd_request_alloc(&params);
5019 if (!request) {
5020 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
5021 return VOS_STATUS_E_NOMEM;
5022 }
5023 cookie = hdd_request_cookie(request);
5024
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
5026 eCSR_HDD,
5027 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305028 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 0, // not periodic
5030 FALSE, //non-cached results
5031 staid,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305032 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 if (eHAL_STATUS_SUCCESS != hstatus)
5034 {
5035 hddLog(VOS_TRACE_LEVEL_ERROR,
5036 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005037 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 }
5039 else
5040 {
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305041 ret = hdd_request_wait_for_response(request);
5042 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 {
5044 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305045 FL("SME timeout while retrieving link speed"));
5046 }
5047 else
5048 {
5049 priv = hdd_request_priv(request);
5050 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 }
5052 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005053
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305054 /*
5055 * either we never sent a request, we sent a request and received a
5056 * response or we sent a request and timed out. Regardless we are
5057 * done with the request.
5058 */
5059 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005060
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 return VOS_STATUS_SUCCESS;
5062}
5063
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305064int __iw_get_softap_linkspeed(struct net_device *dev,
5065 struct iw_request_info *info,
5066 union iwreq_data *wrqu,
5067 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005068
5069{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305070 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305071 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07005073 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305074 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305076 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08005078 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305079 int rc, valid;
5080
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305081 ENTER();
5082
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305083 pHostapdAdapter = (netdev_priv(dev));
5084 if (NULL == pHostapdAdapter)
5085 {
5086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5087 "%s: Adapter is NULL",__func__);
5088 return -EINVAL;
5089 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305090 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305091 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305092 if (0 != valid)
5093 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305094 return valid;
5095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005096
Arif Hussain6d2a3322013-11-17 19:50:10 -08005097 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08005098
5099 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07005100 {
Arif Hussaina9571842014-01-15 16:43:41 -08005101 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
5102 if (NULL == pmacAddress) {
5103 hddLog(LOG1, "unable to allocate memory");
5104 return -ENOMEM;
5105 }
5106 if (copy_from_user((void *)pmacAddress,
5107 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
5108 {
5109 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
5110 kfree(pmacAddress);
5111 return -EFAULT;
5112 }
Manjeet Singha3739742016-05-03 16:21:46 +05305113 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08005114
5115 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07005116 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08005117
5118 if (!VOS_IS_STATUS_SUCCESS(status ))
5119 {
5120 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
5121 }
Arif Hussained667642013-10-27 23:01:14 -07005122 }
Kiet Lam61589852013-09-19 17:10:58 +05305123 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305124 * link speed for first connected client will be returned.
5125 */
Arif Hussaina9571842014-01-15 16:43:41 -08005126 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305127 {
5128 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
5129 }
5130 else
5131 {
5132 status = hdd_softap_GetStaId(pHostapdAdapter,
5133 (v_MACADDR_t *)macAddress, (void *)(&staId));
5134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305136 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 link_speed = 0;
5140 }
5141 else
5142 {
5143 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305144
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 if (!VOS_IS_STATUS_SUCCESS(status ))
5146 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 return -EINVAL;
5149 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305150
5151 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
5152 staId, &link_speed);
5153
5154 link_speed = link_speed / 10;
5155
5156 if (0 == link_speed)
5157 {
5158 /* The linkspeed returned by HAL is in units of 500kbps.
5159 * converting it to mbps.
5160 * This is required to support legacy firmware which does
5161 * not return link capacity.
5162 */
5163 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
5164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 }
5166
5167 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07005168 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305169
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 if ((rc < 0) || (rc >= len))
5171 {
5172 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305173 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 return -EIO;
5175 }
5176
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305177 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 return 0;
5179}
5180
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305181int iw_get_softap_linkspeed(struct net_device *dev,
5182 struct iw_request_info *info,
5183 union iwreq_data *wrqu,
5184 char *extra)
5185{
5186 int ret;
5187
5188 vos_ssr_protect(__func__);
5189 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
5190 vos_ssr_unprotect(__func__);
5191
5192 return ret;
5193}
5194
5195
Jeff Johnson295189b2012-06-20 16:38:30 -07005196static const iw_handler hostapd_handler[] =
5197{
5198 (iw_handler) NULL, /* SIOCSIWCOMMIT */
5199 (iw_handler) NULL, /* SIOCGIWNAME */
5200 (iw_handler) NULL, /* SIOCSIWNWID */
5201 (iw_handler) NULL, /* SIOCGIWNWID */
5202 (iw_handler) NULL, /* SIOCSIWFREQ */
5203 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
5204 (iw_handler) NULL, /* SIOCSIWMODE */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +05305205 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 (iw_handler) NULL, /* SIOCSIWSENS */
5207 (iw_handler) NULL, /* SIOCGIWSENS */
5208 (iw_handler) NULL, /* SIOCSIWRANGE */
5209 (iw_handler) NULL, /* SIOCGIWRANGE */
5210 (iw_handler) NULL, /* SIOCSIWPRIV */
5211 (iw_handler) NULL, /* SIOCGIWPRIV */
5212 (iw_handler) NULL, /* SIOCSIWSTATS */
5213 (iw_handler) NULL, /* SIOCGIWSTATS */
5214 (iw_handler) NULL, /* SIOCSIWSPY */
5215 (iw_handler) NULL, /* SIOCGIWSPY */
5216 (iw_handler) NULL, /* SIOCSIWTHRSPY */
5217 (iw_handler) NULL, /* SIOCGIWTHRSPY */
5218 (iw_handler) NULL, /* SIOCSIWAP */
5219 (iw_handler) NULL, /* SIOCGIWAP */
5220 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
5221 (iw_handler) NULL, /* SIOCGIWAPLIST */
5222 (iw_handler) NULL, /* SIOCSIWSCAN */
5223 (iw_handler) NULL, /* SIOCGIWSCAN */
5224 (iw_handler) NULL, /* SIOCSIWESSID */
5225 (iw_handler) NULL, /* SIOCGIWESSID */
5226 (iw_handler) NULL, /* SIOCSIWNICKN */
5227 (iw_handler) NULL, /* SIOCGIWNICKN */
5228 (iw_handler) NULL, /* -- hole -- */
5229 (iw_handler) NULL, /* -- hole -- */
5230 (iw_handler) NULL, /* SIOCSIWRATE */
5231 (iw_handler) NULL, /* SIOCGIWRATE */
5232 (iw_handler) NULL, /* SIOCSIWRTS */
5233 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
5234 (iw_handler) NULL, /* SIOCSIWFRAG */
5235 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
5236 (iw_handler) NULL, /* SIOCSIWTXPOW */
5237 (iw_handler) NULL, /* SIOCGIWTXPOW */
5238 (iw_handler) NULL, /* SIOCSIWRETRY */
5239 (iw_handler) NULL, /* SIOCGIWRETRY */
5240 (iw_handler) NULL, /* SIOCSIWENCODE */
5241 (iw_handler) NULL, /* SIOCGIWENCODE */
5242 (iw_handler) NULL, /* SIOCSIWPOWER */
5243 (iw_handler) NULL, /* SIOCGIWPOWER */
5244 (iw_handler) NULL, /* -- hole -- */
5245 (iw_handler) NULL, /* -- hole -- */
5246 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
5247 (iw_handler) NULL, /* SIOCGIWGENIE */
5248 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
5249 (iw_handler) NULL, /* SIOCGIWAUTH */
5250 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
5251 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
5252 (iw_handler) NULL, /* SIOCSIWPMKSA */
5253};
5254
Jeff Johnson224f3702014-03-26 11:09:47 -07005255/*
5256 * Note that the following ioctls were defined with semantics which
5257 * cannot be handled by the "iwpriv" userspace application and hence
5258 * they are not included in the hostapd_private_args array
5259 * QCSAP_IOCTL_ASSOC_STA_MACADDR
5260 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005261
5262static const struct iw_priv_args hostapd_private_args[] = {
5263 { QCSAP_IOCTL_SETPARAM,
5264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
5265 { QCSAP_IOCTL_SETPARAM,
5266 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05305267 { QCSAP_PARAM_GET_FRAME_LOGS,
5268 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 { QCSAP_PARAM_MAX_ASSOC,
5270 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
5271 { QCSAP_PARAM_HIDE_SSID,
5272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07005273 { QCSAP_PARAM_SET_MC_RATE,
5274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05305275 { QCSAP_PARAM_SET_PROXIMITY,
5276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305277 { QCSAP_PARAM_CAP_TSF,
5278 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Abhishek Singh02605092017-10-25 14:06:12 +05305279 {QCSAP_PARAM_SET_CHANNEL_CHANGE,
5280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"},
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305281 { QCSAP_PARAM_SET_WOWL,
5282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 { QCSAP_IOCTL_GETPARAM,
5284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
5286 { QCSAP_IOCTL_GETPARAM, 0,
5287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
5288 { QCSAP_PARAM_MAX_ASSOC, 0,
5289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07005290 { QCSAP_PARAM_GET_WLAN_DBG, 0,
5291 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
5292 { QCSAP_PARAM_AUTO_CHANNEL, 0,
5293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05305294 { QCSAP_PARAM_SET_AUTO_CHANNEL,
5295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 { QCSAP_PARAM_CLR_ACL, 0,
5297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
5298 { QCSAP_PARAM_ACL_MODE,
5299 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05305301 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 { QCSAP_IOCTL_STOPBSS,
5303 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
5304 { QCSAP_IOCTL_VERSION, 0,
5305 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005306 { QCSAP_IOCTL_GET_STA_INFO, 0,
5307 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08005309 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07005311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07005312 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05305314 { QCSAP_IOCTL_AP_STATS, 0,
5315 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305316 /* handlers for main ioctl */
5317 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
5318 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
5319#ifdef WLAN_FEATURE_TSF
5320 { QCSAP_IOCTL_GET_TSF, 0,
5321 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5322 "get_tsf" },
5323#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05305324 { QCSAP_IOCTL_GET_STATS, 0,
5325 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
5326 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
5328 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305329 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005330
5331 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
5332 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
5333 /* handlers for sub-ioctl */
5334 { WE_SET_WLAN_DBG,
5335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5336 0,
5337 "setwlandbg" },
5338
5339 /* handlers for main ioctl */
5340 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
5341 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5342 0,
5343 "" },
5344
5345 /* handlers for sub-ioctl */
5346 { WE_LOG_DUMP_CMD,
5347 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5348 0,
5349 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 { WE_P2P_NOA_CMD,
5351 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5352 0,
5353 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005354 /* handlers for sub ioctl */
5355 {
5356 WE_MCC_CONFIG_CREDENTIAL,
5357 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5358 0,
5359 "setMccCrdnl" },
5360
5361 /* handlers for sub ioctl */
5362 {
5363 WE_MCC_CONFIG_PARAMS,
5364 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5365 0,
5366 "setMccConfig" },
5367
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 /* handlers for main ioctl */
5369 { QCSAP_IOCTL_MODIFY_ACL,
5370 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
5371 0,
5372 "modify_acl" },
5373
5374 /* handlers for main ioctl */
5375 { QCSAP_IOCTL_GET_CHANNEL_LIST,
5376 0,
5377 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
5378 "getChannelList" },
5379
Jeff Johnsone7245742012-09-05 17:12:55 -07005380 /* handlers for main ioctl */
5381 { QCSAP_IOCTL_SET_TX_POWER,
5382 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5383 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05305384 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07005385
5386 /* handlers for main ioctl */
5387 { QCSAP_IOCTL_SET_MAX_TX_POWER,
5388 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5389 0,
5390 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05305391
5392 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
5393 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
5394 0,
5395 "dataSnapshot" },
5396
5397 /* handlers for main ioctl */
5398 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
5399 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5400 0,
5401 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305402 /* handlers for main ioctl */
5403 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
5404 IW_PRIV_TYPE_CHAR| 512,
5405 0,
5406 "" },
5407
5408 /* handlers for sub-ioctl */
5409 { WE_WOWL_ADD_PTRN,
5410 IW_PRIV_TYPE_CHAR| 512,
5411 0,
5412 "wowlAddPtrn" },
5413
5414 { WE_WOWL_DEL_PTRN,
5415 IW_PRIV_TYPE_CHAR| 512,
5416 0,
5417 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005418};
Jeff Johnsone7245742012-09-05 17:12:55 -07005419
Jeff Johnson295189b2012-06-20 16:38:30 -07005420static const iw_handler hostapd_private[] = {
5421 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305422 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
5423 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
5424 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
5427 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
5428 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
5429 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
5430 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
5431 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
5432 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05305433 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305434 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
5436 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
5437 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
5438 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005439 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07005440 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
5441 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07005442 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305443 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05305444 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05305445 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
5446 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07005447};
5448const struct iw_handler_def hostapd_handler_def = {
5449 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
5450 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
5451 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
5452 .standard = (iw_handler *)hostapd_handler,
5453 .private = (iw_handler *)hostapd_private,
5454 .private_args = hostapd_private_args,
5455 .get_wireless_stats = NULL,
5456};
5457#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5458struct net_device_ops net_ops_struct = {
5459 .ndo_open = hdd_hostapd_open,
5460 .ndo_stop = hdd_hostapd_stop,
5461 .ndo_uninit = hdd_hostapd_uninit,
5462 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5463 .ndo_tx_timeout = hdd_softap_tx_timeout,
5464 .ndo_get_stats = hdd_softap_stats,
5465 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5466 .ndo_do_ioctl = hdd_hostapd_ioctl,
5467 .ndo_change_mtu = hdd_hostapd_change_mtu,
5468 .ndo_select_queue = hdd_hostapd_select_queue,
5469 };
5470#endif
5471
5472int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5473{
5474 return VOS_STATUS_SUCCESS;
5475}
5476
5477void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5478{
5479#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5480 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5481#else
5482 pWlanHostapdDev->open = hdd_hostapd_open;
5483 pWlanHostapdDev->stop = hdd_hostapd_stop;
5484 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5485 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5486 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5487 pWlanHostapdDev->get_stats = hdd_softap_stats;
5488 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5489 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5490#endif
5491}
5492
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305493VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305494{
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05305496#ifdef DHCP_SERVER_OFFLOAD
5497 hdd_dhcp_state_t *dhcp_status;
5498#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305499#ifdef MDNS_OFFLOAD
5500 hdd_mdns_state_t *mdns_status;
5501#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005503 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305505 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005506#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005507 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5508 v_U16_t unsafeChannelCount;
5509#endif /* FEATURE_WLAN_CH_AVOID */
5510
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305511 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5513 "%s:LOGP in Progress. Ignore!!!",__func__);
5514 status = VOS_STATUS_E_FAILURE;
5515 }
5516
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305518
5519#ifdef SAP_AUTH_OFFLOAD
5520 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305521 {
5522 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5523 {
5524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5525 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5526 return VOS_STATUS_E_FAILURE;
5527 }
5528 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305529#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305530
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305531 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305533#ifdef DHCP_SERVER_OFFLOAD
5534 dhcp_status = &pAdapter->dhcp_status;
5535#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305536#ifdef MDNS_OFFLOAD
5537 mdns_status = &pAdapter->mdns_status;
5538#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305539
Nirav Shah7e3c8132015-06-22 23:51:42 +05305540 spin_lock_init(&pAdapter->sta_hash_lock);
5541 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5542
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005543 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5544
Leo Chang0b0e45a2013-12-15 15:18:55 -08005545#ifdef FEATURE_WLAN_CH_AVOID
5546 /* Get unsafe cahnnel list from cached location */
5547 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5548 sizeof(unsafeChannelList),
5549 &unsafeChannelCount);
5550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5551 "%s : Unsafe Channel count %d",
5552 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305553 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005554 unsafeChannelList,
5555 unsafeChannelCount);
5556#endif /* FEATURE_WLAN_CH_AVOID */
5557
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 // Zero the memory. This zeros the profile structure.
5559 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305560#ifdef DHCP_SERVER_OFFLOAD
5561 memset(dhcp_status, 0,sizeof(*dhcp_status));
5562#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305563#ifdef MDNS_OFFLOAD
5564 memset(mdns_status, 0,sizeof(*mdns_status));
5565#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305566
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 // Set up the pointer to the Wireless Extensions state structure
5568 // NOP
5569 status = hdd_set_hostapd(pAdapter);
5570 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 return status;
5573 }
5574
5575 status = vos_event_init(&phostapdBuf->vosEvent);
5576 if (!VOS_IS_STATUS_SUCCESS(status))
5577 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 return status;
5580 }
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05305581 status = vos_event_init(&phostapdBuf->sta_discon_event);
5582 if (!VOS_IS_STATUS_SUCCESS(status))
5583 {
5584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ERROR: Hostapd HDD sta disassoc event init failed!!");
5585 return status;
5586 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305587#ifdef DHCP_SERVER_OFFLOAD
5588 status = vos_event_init(&dhcp_status->vos_event);
5589 if (!VOS_IS_STATUS_SUCCESS(status)) {
5590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5591 return status;
5592 }
5593#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305594#ifdef MDNS_OFFLOAD
5595 status = vos_event_init(&mdns_status->vos_event);
5596 if (!VOS_IS_STATUS_SUCCESS(status)) {
5597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5598 ("Hostapd HDD vos event init failed!!"));
5599 return status;
5600 }
5601#endif /* MDNS_OFFLOAD */
5602
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5604
5605 // Register as a wireless device
5606 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5607
5608 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305609 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 if ( !VOS_IS_STATUS_SUCCESS( status ))
5611 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005612 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305614
5615 status = hdd_wmm_adapter_init( pAdapter );
5616 if (!VOS_IS_STATUS_SUCCESS(status))
5617 {
5618 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005619 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305620 status, status );
5621 goto error_wmm_init;
5622 }
5623
5624 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5625
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305626 ini_cfg = pHddCtx->cfg_ini;
5627 if (re_init && ini_cfg) {
5628 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5629 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5630 ini_cfg->apOperatingBand);
5631 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5632 ini_cfg->apStartChannelNum,
5633 ini_cfg->apEndChannelNum,
5634 ini_cfg->apOperatingBand);
5635 }
5636
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305637 return status;
5638
5639error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305640 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 EXIT();
5642 return status;
5643}
5644
5645hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5646{
5647 struct net_device *pWlanHostapdDev = NULL;
5648 hdd_adapter_t *pHostapdAdapter = NULL;
5649 v_CONTEXT_t pVosContext= NULL;
5650
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305651 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5652#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5653 NET_NAME_UNKNOWN,
5654#endif
5655 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 if (pWlanHostapdDev != NULL)
5657 {
5658 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5659
5660 //Init the net_device structure
5661 ether_setup(pWlanHostapdDev);
5662
5663 //Initialize the adapter context to zeros.
5664 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5665 pHostapdAdapter->dev = pWlanHostapdDev;
5666 pHostapdAdapter->pHddCtx = pHddCtx;
5667 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5668
5669 //Get the Global VOSS context.
5670 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5671 //Save the adapter context in global context for future.
5672 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5673
5674 //Init the net_device structure
5675 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5676
5677 hdd_set_ap_ops( pHostapdAdapter->dev );
5678
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5680 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5681
5682 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5683 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5684
5685 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5687 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5688 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005689
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5691 }
5692 return pHostapdAdapter;
5693}
5694
5695VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5696{
5697 struct net_device *dev = pAdapter->dev;
5698 VOS_STATUS status = VOS_STATUS_SUCCESS;
5699
5700 ENTER();
5701
5702 if( rtnl_lock_held )
5703 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005704 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 if( dev_alloc_name(dev, dev->name) < 0 )
5706 {
5707 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5708 return VOS_STATUS_E_FAILURE;
5709 }
5710 }
5711 if (register_netdevice(dev))
5712 {
5713 hddLog(VOS_TRACE_LEVEL_FATAL,
5714 "%s:Failed:register_netdevice", __func__);
5715 return VOS_STATUS_E_FAILURE;
5716 }
5717 }
5718 else
5719 {
5720 if (register_netdev(dev))
5721 {
5722 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5723 return VOS_STATUS_E_FAILURE;
5724 }
5725 }
5726 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5727
5728 EXIT();
5729 return status;
5730}
5731
c_hpothu002231a2015-02-05 14:58:51 +05305732VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005733{
5734 ENTER();
5735
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305736 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005737
5738 /* if we are being called during driver unload, then the dev has already
5739 been invalidated. if we are being called at other times, then we can
5740 detatch the wireless device handlers */
5741 if (pAdapter->dev)
5742 {
c_hpothu002231a2015-02-05 14:58:51 +05305743 if (TRUE == rtnl_held)
5744 {
5745 pAdapter->dev->wireless_handlers = NULL;
5746 }
5747 else
5748 {
5749 rtnl_lock();
5750 pAdapter->dev->wireless_handlers = NULL;
5751 rtnl_unlock();
5752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 }
5754 EXIT();
5755 return 0;
5756}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305757
5758/**
5759 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5760 * to supplicant, if there any clients connected to SAP interface.
5761 * @adapter: sap adapter context
5762 *
5763 * Return: nothing
5764 */
5765void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5766{
5767 tSap_Event sap_event;
5768 int staId;
5769 hdd_context_t *hdd_ctx;
5770 v_CONTEXT_t vos_ctx;
5771 ptSapContext sap_ctx;
5772
5773 ENTER();
5774
5775 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305776 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5778 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305779 return;
5780 }
5781
5782 vos_ctx = hdd_ctx->pvosContext;
5783 if (NULL == vos_ctx) {
5784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5785 "%s: VOS context is not valid",__func__);
5786 return;
5787 }
5788
5789 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5790 if (!sap_ctx) {
5791 hddLog(LOGE, FL("invalid sap context"));
5792 return;
5793 }
5794
5795 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5796 if (sap_ctx->aStaInfo[staId].isUsed) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07005797 hddLog(LOG1, FL("staId: %d isUsed: %d %pK"),
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305798 staId, sap_ctx->aStaInfo[staId].isUsed,
5799 sap_ctx);
5800
5801 if (vos_is_macaddr_broadcast(
5802 &sap_ctx->aStaInfo[staId].macAddrSTA))
5803 continue;
5804
5805 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5806 vos_mem_copy(
5807 &sap_event.sapevt.
5808 sapStationDisassocCompleteEvent.staMac,
5809 &sap_ctx->aStaInfo[staId].macAddrSTA,
5810 sizeof(v_MACADDR_t));
5811 sap_event.sapevt.sapStationDisassocCompleteEvent.
5812 reason =
5813 eSAP_MAC_INITATED_DISASSOC;
5814 sap_event.sapevt.sapStationDisassocCompleteEvent.
5815 statusCode =
5816 eSIR_SME_RESOURCES_UNAVAILABLE;
5817 hdd_hostapd_SAPEventCB(&sap_event,
5818 sap_ctx->pUsrContext);
5819 }
5820 }
5821
5822 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5823
5824 EXIT();
5825}
5826
5827/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305828 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305829 * @adapter: sap adapter context
5830 *
5831 * Return: nothing
5832 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305833void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305834{
5835 hdd_context_t *hdd_ctx;
5836 v_CONTEXT_t vos_ctx;
5837 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305838 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305839
5840 ENTER();
5841
5842 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305843 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5845 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305846 return;
5847 }
5848
5849 vos_ctx = hdd_ctx->pvosContext;
5850 if (NULL == vos_ctx) {
5851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5852 "%s: VOS context is not valid",__func__);
5853 return;
5854 }
5855
5856 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5857 if (!sap_ctx) {
5858 hddLog(LOGE, FL("invalid sap context"));
5859 return;
5860 }
5861
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305862 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5863 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5864 if (!VOS_IS_STATUS_SUCCESS(status))
5865 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5866 FL("Failed to Stop HT20/40 timer"));
5867 }
5868
5869 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5870 if (!VOS_IS_STATUS_SUCCESS(status))
5871 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5872 FL("Failed to Destroy HT20/40 timer"));
5873
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305874}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305875
5876/**
5877 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5878 * @adapter: hdd ap adapter
5879 *
5880 * hdd_force_scc_restart_sap will choose station channel and will
5881 * schedule work to restart the sap.
5882 *
5883 * Return - none
5884 */
5885void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5886 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5887{
5888 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5889 return;
5890 }
5891
5892 hddLog(LOG1, FL("Current operation channel %d"),
5893 adapter->sessionCtx.ap.operatingChannel);
5894 hddLog(LOG1, FL("STA channel is %d"),
5895 channelId);
5896
5897 vos_flush_work(
5898 &hdd_ctx->sap_start_work);
5899
5900 hddLog(LOGE,
5901 FL("Restarting SAP for force SCC "));
5902
5903 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5904
5905 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5906 netif_tx_disable(adapter->dev);
5907 schedule_work(&hdd_ctx->sap_start_work);
5908 } else {
5909 hdd_hostapd_stop(adapter->dev);
5910 }
5911 return;
5912}
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05305913
5914/**
5915 * hdd_get_cache_stainfo() - get stainfo for the specified peer
5916 * @stainfo: array of station info
5917 * @mac_addr: mac address of requested peer
5918 *
5919 * This function find the stainfo for the peer with mac_addr
5920 *
5921 * Return: stainfo if found, NULL if not found
5922 */
5923struct hdd_cache_sta_info *hdd_get_cache_stainfo(
5924 struct hdd_cache_sta_info *astainfo,
5925 u8 *mac_addr)
5926{
5927 struct hdd_cache_sta_info *stainfo = NULL;
5928 int i;
5929
5930 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
5931 if (vos_mem_compare(&astainfo[i].macAddrSTA,
5932 mac_addr,
5933 HDD_MAC_ADDR_LEN)) {
5934 stainfo = &astainfo[i];
5935 break;
5936 }
5937 }
5938
5939 return stainfo;
5940}
5941