blob: 8115be823798060d72084fb592f943d9bc8f11a8 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Pankaj Singh45e66bb2020-06-11 20:42:32 +05302 * Copyright (c) 2012-2018, 2020 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);
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530177 hdd_context_t *pHddCtx;
178 VOS_STATUS status;
179 v_BOOL_t in_standby = TRUE;
180 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530181
Jeff Johnson295189b2012-06-20 16:38:30 -0700182 ENTER();
183
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530184 if (test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) {
185 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: session already opened for the adapter",
186 __func__);
187 return 0;
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530188 }
189
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530190 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
191 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST,
192 pAdapter->sessionId, pAdapter->device_mode));
Ashish Kumar Dhanotiyac2206dd2020-11-12 11:57:44 +0530193 if (wlan_hdd_validate_context(pHddCtx))
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530194 {
195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Ashish Kumar Dhanotiyac2206dd2020-11-12 11:57:44 +0530196 "%s: HDD context is Invalid", __func__);
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530197 return -ENODEV;
198 }
Ashish Kumar Dhanotiyac2206dd2020-11-12 11:57:44 +0530199
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530200 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
201 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
202 {
203 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
204 {
205 hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby",
206 __func__);
207 in_standby = FALSE;
208 break;
209 }
210 else
211 {
212 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
213 pAdapterNode = pNext;
214 }
215 }
216
217 if (TRUE == in_standby)
218 {
219 if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter))
220 {
221 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring "
222 "wlan out of power save", __func__);
223 return -EINVAL;
224 }
225 }
226
Bapiraju Allad119da32020-09-28 23:01:24 +0530227 if (!test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) {
228 status = hdd_init_ap_mode( pAdapter, false);
229 if( VOS_STATUS_SUCCESS != status ) {
230 hddLog(VOS_TRACE_LEVEL_ERROR,
231 "%s: Failed to create session for station mode",
232 __func__);
233 return -EINVAL;
234 }
235 set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
236
237 //Turn ON carrier state
238 netif_carrier_on(dev);
239 //Enable all Tx queues
240 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
241 netif_tx_start_all_queues(dev);
242 } else {
243 hddLog(VOS_TRACE_LEVEL_DEBUG,
244 "%s: session already exist for AP mode", __func__);
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530245 }
246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 EXIT();
248 return 0;
249}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530250
251int hdd_hostapd_open (struct net_device *dev)
252{
253 int ret;
254
255 vos_ssr_protect(__func__);
256 ret = __hdd_hostapd_open(dev);
257 vos_ssr_unprotect(__func__);
258
259 return ret;
260}
261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262/**---------------------------------------------------------------------------
263
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530264 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266 This is called in response to ifconfig down
267
268 \param - dev Pointer to net_device structure
269
270 \return - 0 for success non-zero for failure
271
272 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530273int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700274{
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530275 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
276 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
277 int ret;
278
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 ENTER();
280
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530281 ret = wlan_hdd_validate_context(hdd_ctx);
282 if (0 != ret)
283 return ret;
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530284
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530285 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
286
287 //Stop all tx queues
288 netif_tx_disable(dev);
289
290 //Turn OFF carrier state
291 netif_carrier_off(dev);
292
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530293 if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) {
294 hdd_stop_adapter(hdd_ctx, adapter, VOS_TRUE);
295 hdd_deinit_adapter(hdd_ctx, adapter, TRUE);
296 }
297
298 clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags);
299 adapter->dev->wireless_handlers = NULL;
300
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530301 if (!hdd_is_cli_iface_up(hdd_ctx))
302 sme_ScanFlushResult(hdd_ctx->hHal, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
304 EXIT();
305 return 0;
306}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530307
308int hdd_hostapd_stop (struct net_device *dev)
309{
310 int ret;
311
312 vos_ssr_protect(__func__);
313 ret = __hdd_hostapd_stop(dev);
314 vos_ssr_unprotect(__func__);
315
316 return ret;
317}
318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319/**---------------------------------------------------------------------------
320
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530321 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700322
323 This is called during the netdev unregister to uninitialize all data
324associated with the device
325
326 \param - dev Pointer to net_device structure
327
328 \return - void
329
330 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530331static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332{
333 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530334 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700335
336 ENTER();
337
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530338 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530340 hddLog(VOS_TRACE_LEVEL_ERROR,
341 FL("Invalid magic"));
342 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530344 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
345 if (NULL == pHddCtx)
346 {
347 hddLog(VOS_TRACE_LEVEL_ERROR,
348 FL("NULL pHddCtx"));
349 return;
350 }
351
352 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
353
354 /* after uninit our adapter structure will no longer be valid */
355 pHostapdAdapter->dev = NULL;
356 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700357
358 EXIT();
359}
360
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530361static void hdd_hostapd_uninit (struct net_device *dev)
362{
363 vos_ssr_protect(__func__);
364 __hdd_hostapd_uninit(dev);
365 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530367 return;
368}
Jeff Johnson295189b2012-06-20 16:38:30 -0700369/**============================================================================
370 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
371 transmitting packets. There are 2 versions of this function. One that uses
372 locked queue and other that uses lockless queues. Both have been retained to
373 do some performance testing
374 @param skb : [in] pointer to OS packet (sk_buff)
375 @param dev : [in] pointer to Libra network device
376
377 @return : NET_XMIT_DROP if packets are dropped
378 : NET_XMIT_SUCCESS if packet is enqueued succesfully
379 ===========================================================================*/
380int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
381{
382 return 0;
383}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530384
385int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700386{
387 return 0;
388}
389
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530390int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
391{
392 int ret;
393 vos_ssr_protect(__func__);
394 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
395 vos_ssr_unprotect(__func__);
396
397 return ret;
398}
399
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700400static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
401 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700402{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700403 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530404 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
405 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700406 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530407 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700408 /*
409 * Note that valid pointers are provided by caller
410 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530412 ENTER();
413
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700414 if (priv_data->total_len <= 0 ||
415 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
416 {
417 /* below we allocate one more byte for command buffer.
418 * To avoid addition overflow total_len should be
419 * smaller than INT_MAX. */
420 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
421 __func__, priv_data->total_len);
422 ret = -EFAULT;
423 goto exit;
424 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530425 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530426 if (0 != status)
427 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530428 return status;
429 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700430
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700431 /* Allocate +1 for '\0' */
432 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
433 if (!command)
434 {
435 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
436 ret = -ENOMEM;
437 goto exit;
438 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700440 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
441 {
442 ret = -EFAULT;
443 goto exit;
444 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800445
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700446 /* Make sure the command is NUL-terminated */
447 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700448
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700449 hddLog(VOS_TRACE_LEVEL_INFO,
450 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700451
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700452 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
453 {
454 hdd_setP2pNoa(pAdapter->dev, command);
455 }
456 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
457 {
458 hdd_setP2pOpps(pAdapter->dev, command);
459 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800460#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700461 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
462 {
463 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
464 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800465#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700466 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
467 {
468 /*
469 * command should be a string having format
470 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
471 */
472 hddLog(VOS_TRACE_LEVEL_INFO,
473 "%s: Received Command to Set Preferred Channels for SAP",
474 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800475
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700476 ret = sapSetPreferredChannel(command);
477 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530478 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
479 {
480 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
481 tANI_U8 filterType = 0;
482 tANI_U8 *value;
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530483
484 ret = hdd_drv_cmd_validate(command, 8);
485 if (ret)
486 goto exit;
487
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530488 value = command + 9;
489
490 /* Convert the value from ascii to integer */
491 ret = kstrtou8(value, 10, &filterType);
492 if (ret < 0)
493 {
494 /* If the input value is greater than max value of datatype,
495 * then also kstrtou8 fails
496 */
497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
498 "%s: kstrtou8 failed range ", __func__);
499 ret = -EINVAL;
500 goto exit;
501 }
502 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
503 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
504 {
505 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
506 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
507 " 2-Sink ", __func__);
508 ret = -EINVAL;
509 goto exit;
510 }
511 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
512 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530513 pScanInfo = &pHddCtx->scan_info;
514 if (filterType && pScanInfo != NULL &&
515 pHddCtx->scan_info.mScanPending)
516 {
517 /*Miracast Session started. Abort Scan */
518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
519 "%s, Aborting Scan For Miracast",__func__);
520 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
521 eCSR_SCAN_ABORT_DEFAULT);
522 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530523 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
524 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
525 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530526 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
527 {
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530528 ret = hdd_drv_cmd_validate(command, 16);
529 if (ret)
530 goto exit;
531
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530532 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
533 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700534
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530535 /*
536 * command should be a string having format
537 * SET_DISABLE_CHANNEL_LIST <num of channels>
538 * <channels separated by spaces>
539 */
540 else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) {
541 tANI_U8 *ptr = command;
542
543 ret = hdd_drv_cmd_validate(command, 24);
544 if (ret)
545 goto exit;
546
547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
548 " Received Command to disable Channels for in %s",
549 __func__);
550 ret = hdd_parse_disable_chan_cmd(pAdapter, ptr);
551 }
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530552 else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) {
553 char extra[128] = {0};
554 int len;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530555
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
557 " Received Command to get disable Channels list %s",
558 __func__);
559
560 len = hdd_get_disable_ch_list(pHddCtx, extra, sizeof(extra));
561 if (len == 0) {
562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
563 FL("disable channel list are not yet programed"));
564 ret = -EINVAL;
565 goto exit;
566 }
567
568 len = VOS_MIN(priv_data->total_len, len + 1);
569 if (copy_to_user(priv_data->buf, &extra, len)) {
570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
571 "%s: failed to copy data to user buffer", __func__);
572 ret = -EFAULT;
573 goto exit;
574 }
575
576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
577 FL("data:%s"), extra);
578 }
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530579 else {
580 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
581 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
582 pAdapter->sessionId, 0));
583 hddLog(VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"),
584 command);
585 }
586
Jeff Johnson295189b2012-06-20 16:38:30 -0700587exit:
588 if (command)
589 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700590 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530592 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 return ret;
594}
595
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700596#ifdef CONFIG_COMPAT
597static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
598 struct ifreq *ifr)
599{
600 struct {
601 compat_uptr_t buf;
602 int used_len;
603 int total_len;
604 } compat_priv_data;
605 hdd_priv_data_t priv_data;
606 int ret = 0;
607
608 /*
609 * Note that pAdapter and ifr have already been verified by caller,
610 * and HDD context has also been validated
611 */
612 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
613 sizeof(compat_priv_data))) {
614 ret = -EFAULT;
615 goto exit;
616 }
617 priv_data.buf = compat_ptr(compat_priv_data.buf);
618 priv_data.used_len = compat_priv_data.used_len;
619 priv_data.total_len = compat_priv_data.total_len;
620 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
621 exit:
622 return ret;
623}
624#else /* CONFIG_COMPAT */
625static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
626 struct ifreq *ifr)
627{
628 /* will never be invoked */
629 return 0;
630}
631#endif /* CONFIG_COMPAT */
632
633static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
634{
635 hdd_priv_data_t priv_data;
636 int ret = 0;
637
638 /*
639 * Note that pAdapter and ifr have already been verified by caller,
640 * and HDD context has also been validated
641 */
642 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
643 ret = -EFAULT;
644 } else {
645 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
646 }
647 return ret;
648}
649
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530650static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700651 struct ifreq *ifr, int cmd)
652{
653 hdd_adapter_t *pAdapter;
654 hdd_context_t *pHddCtx;
655 int ret;
656
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530657 ENTER();
658
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700659 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
660 if (NULL == pAdapter) {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 "%s: HDD adapter context is Null", __func__);
663 ret = -ENODEV;
664 goto exit;
665 }
666 if (dev != pAdapter->dev) {
667 hddLog(VOS_TRACE_LEVEL_ERROR,
668 "%s: HDD adapter/dev inconsistency", __func__);
669 ret = -ENODEV;
670 goto exit;
671 }
672
673 if ((!ifr) || (!ifr->ifr_data)) {
674 ret = -EINVAL;
675 goto exit;
676 }
677
678 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
679 ret = wlan_hdd_validate_context(pHddCtx);
680 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700681 ret = -EBUSY;
682 goto exit;
683 }
684
685 switch (cmd) {
686 case (SIOCDEVPRIVATE + 1):
687 if (is_compat_task())
688 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
689 else
690 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
691 break;
692 default:
693 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
694 __func__, cmd);
695 ret = -EINVAL;
696 break;
697 }
698 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530699 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700700 return ret;
701}
702
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530703static int hdd_hostapd_ioctl(struct net_device *dev,
704 struct ifreq *ifr, int cmd)
705{
706 int ret;
707
708 vos_ssr_protect(__func__);
709 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
710 vos_ssr_unprotect(__func__);
711
712 return ret;
713}
714
Jeff Johnson295189b2012-06-20 16:38:30 -0700715/**---------------------------------------------------------------------------
716
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530717 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 This function sets the user specified mac address using
719 the command ifconfig wlanX hw ether <mac adress>.
720
721 \param - dev - Pointer to the net device.
722 - addr - Pointer to the sockaddr.
723 \return - 0 for success, non zero for failure
724
725 --------------------------------------------------------------------------*/
726
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530727static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700728{
729 struct sockaddr *psta_mac_addr = addr;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530730 hdd_adapter_t *pAdapter, *adapter_temp;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530731 hdd_context_t *pHddCtx;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530732 int ret = 0, i;
733 v_MACADDR_t mac_addr;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530736 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
737 if (NULL == pAdapter)
738 {
739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
740 "%s: Adapter is NULL",__func__);
741 return -EINVAL;
742 }
743 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
744 ret = wlan_hdd_validate_context(pHddCtx);
745 if (0 != ret)
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530746 return ret;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530747
748
749 memcpy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr));
750 if(vos_is_macaddr_zero(&mac_addr)) {
751 hddLog(VOS_TRACE_LEVEL_ERROR, "Zero Mac address");
752 return -EINVAL;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530753 }
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530754
755 if (vos_is_macaddr_broadcast(&mac_addr)) {
756 hddLog(VOS_TRACE_LEVEL_ERROR,"MAC is Broadcast");
757 return -EINVAL;
758 }
759
760 if (vos_is_macaddr_multicast(&mac_addr)) {
761 hddLog(VOS_TRACE_LEVEL_ERROR, "Multicast Mac address");
762 return -EINVAL;
763 }
764
765
766 adapter_temp = hdd_get_adapter_by_macaddr(pHddCtx, mac_addr.bytes);
767 if (adapter_temp) {
768 if (!strcmp(adapter_temp->dev->name, dev->name))
769 return 0;
770 hddLog(VOS_TRACE_LEVEL_ERROR,
771 "%s: WLAN Mac Addr: "
772 MAC_ADDRESS_STR, __func__,
773 MAC_ADDR_ARRAY(mac_addr.bytes));
774 return -EINVAL;
775 }
776
777 for (i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) {
778 if (!vos_mem_compare(&pAdapter->macAddressCurrent.bytes,
779 &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], VOS_MAC_ADDR_SIZE)) {
780 memcpy(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], mac_addr.bytes,
781 VOS_MAC_ADDR_SIZE);
782 break;
783 }
784 }
785
786 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530788
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 EXIT();
790 return 0;
791}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530792
793static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
794{
795 int ret;
796
797 vos_ssr_protect(__func__);
798 ret = __hdd_hostapd_set_mac_address(dev, addr);
799 vos_ssr_unprotect(__func__);
800
801 return ret;
802}
803
Jeff Johnson295189b2012-06-20 16:38:30 -0700804void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
805{
806 struct net_device *dev = (struct net_device *)usrDataForCallback;
807 v_BYTE_t we_custom_event[64];
808 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530810 hdd_context_t *pHddCtx;
811#ifdef DISABLE_CONCURRENCY_AUTOSAVE
812 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 hdd_ap_ctx_t *pHddApCtx;
814#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
815
816 /* event_name space-delimiter driver_module_name */
817 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
818 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
819 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
820
821 ENTER();
822
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530823 pHostapdAdapter = netdev_priv(dev);
824 if ((NULL == pHostapdAdapter) ||
825 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
826 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700827 hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530828 return;
829 }
830 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
831 if (0 != (wlan_hdd_validate_context(pHddCtx)))
832 {
833 return;
834 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530835#ifdef DISABLE_CONCURRENCY_AUTOSAVE
836 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530837 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 /*
839 This timer routine is going to be called only when AP
840 persona is up.
841 If there are concurrent sessions running we do not want
842 to shut down the Bss.Instead we run the timer again so
843 that if Autosave is enabled next time and other session
844 was down only then we bring down AP
845 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
847 vos_status = vos_timer_start(
848 &pHddApCtx->hdd_ap_inactivity_timer,
849 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
850 * 1000);
851 if (!VOS_IS_STATUS_SUCCESS(vos_status))
852 {
853 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
854 }
855 EXIT();
856 return;
857 }
858#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
859 memset(&we_custom_event, '\0', sizeof(we_custom_event));
860 memcpy(&we_custom_event, autoShutEvent, event_len);
861
862 memset(&wrqu, 0, sizeof(wrqu));
863 wrqu.data.length = event_len;
864
865 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
866 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
867
868 EXIT();
869}
870
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800871VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
872{
873 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
874 ptSapContext pSapCtx = NULL;
875 eHalStatus halStatus = eHAL_STATUS_FAILURE;
876 v_PVOID_t hHal = NULL;
877
878 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
879 "%s: UPDATE Beacon Params", __func__);
880
881 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
882 pSapCtx = VOS_GET_SAP_CB(pVosContext);
883 if ( NULL == pSapCtx )
884 {
885 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
886 "%s: Invalid SAP pointer from pvosGCtx", __func__);
887 return VOS_STATUS_E_FAULT;
888 }
889
890 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
891 if ( NULL == hHal ){
892 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
893 "%s: Invalid HAL pointer from pvosGCtx", __func__);
894 return VOS_STATUS_E_FAULT;
895 }
896 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
897 if(halStatus == eHAL_STATUS_FAILURE ){
898 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
899 "%s: Failed to update Beacon Params", __func__);
900 return VOS_STATUS_E_FAILURE;
901 }
902 }
903 return VOS_STATUS_SUCCESS;
904}
905
906void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
907{
908 v_U8_t staId = 0;
909 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530910 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
911 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800912
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530913 dev = (struct net_device *)usrDataForCallback;
914 pSapCtx = VOS_GET_SAP_CB(pVosContext);
915 if(pSapCtx == NULL){
916 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
917 FL("psapCtx is NULL"));
918 return;
919 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800920 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800921 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
922 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530923 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800924 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
925 {
926 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530927 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800928 }
929 }
930}
931
Agarwal Ashish8e538932014-12-24 18:12:52 +0530932static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800933{
934 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530935 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800936 VOS_STATUS status = VOS_STATUS_SUCCESS;
937 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530938
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800939 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530940
941 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
942 status = wlan_hdd_validate_context(pHddCtx);
943
944 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530945 return status;
946 }
947
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800948 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
949 {
950 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
951 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800953 }
954 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530955 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800956 }
957 EXIT();
958 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
959}
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530961#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530962bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530963 bool enabled)
964{
965 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530966 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530967
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530968 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530969 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
970
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530971 sap_offload_info.sap_auth_offload_enable = enabled;
972 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530973 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530974 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530975 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
976
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530977 if (sap_offload_info.sap_auth_offload_enable &&
978 sap_offload_info.sap_auth_offload_sec_type)
979 {
980 if (sap_offload_info.key_len < 8 ||
981 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
982 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530983 hddLog(VOS_TRACE_LEVEL_ERROR,
984 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530985 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530986 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530987 }
988 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530989 if (sap_offload_info.key_len)
990 {
991 vos_mem_copy(sap_offload_info.key,
992 pHddCtx->cfg_ini->sap_auth_offload_key,
993 sap_offload_info.key_len);
994 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530995 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530996 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
997 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530998 hddLog(VOS_TRACE_LEVEL_ERROR,
999 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +05301000 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +05301001 }
1002
1003 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1004 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +05301005 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +05301006}
1007#endif
1008
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301009/**
1010* wlansap_get_phymode() - get SAP phymode.
1011* @pctx: Pointer to the global vos context; a handle to SAP's control block
1012* can be extracted from its context. When MBSSID feature is enabled,
1013* SAP context is directly passed to SAP APIs.
1014*
1015* This function provides current phymode of SAP interface.
1016*
1017* Return: phymode with eCsrPhyMode type.
1018*/
1019static eCsrPhyMode
1020wlansap_get_phymode(v_PVOID_t pctx)
1021{
1022 ptSapContext psapctx = VOS_GET_SAP_CB(pctx);
1023
1024 if (!psapctx) {
1025 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1026 "%s: Invalid SAP pointer from pCtx", __func__);
1027 return eCSR_DOT11_MODE_AUTO;
1028 }
1029 return psapctx->csrRoamProfile.phyMode;
1030}
1031
1032/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301033 * hdd_convert_dot11mode_from_phymode() - get dot11mode to phymode
1034 * @phymode: phy mode
1035 *
1036 * This function is used to get dot11mode to phymode
1037 *
1038 * Return: dot11mode
1039 */
1040static int hdd_convert_dot11mode_from_phymode(int phymode)
1041{
1042 switch (phymode) {
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301043
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301044 case VOS_MODE_11A:
1045 return QCA_WLAN_802_11_MODE_11A;
1046
1047 case VOS_MODE_11B:
1048 return QCA_WLAN_802_11_MODE_11B;
1049
1050 case VOS_MODE_11G:
1051 case VOS_MODE_11GONLY:
1052 return QCA_WLAN_802_11_MODE_11G;
1053
1054 case VOS_MODE_11NA_HT20:
1055 case VOS_MODE_11NG_HT20:
1056 case VOS_MODE_11NA_HT40:
1057 case VOS_MODE_11NG_HT40:
1058 return QCA_WLAN_802_11_MODE_11N;
1059
1060 case VOS_MODE_11AC_VHT20:
1061 case VOS_MODE_11AC_VHT40:
1062 case VOS_MODE_11AC_VHT80:
1063 case VOS_MODE_11AC_VHT20_2G:
1064 case VOS_MODE_11AC_VHT40_2G:
1065 case VOS_MODE_11AC_VHT80_2G:
1066#ifdef CONFIG_160MHZ_SUPPORT
1067 case VOS_MODE_11AC_VHT80_80:
1068 case VOS_MODE_11AC_VHT160:
1069#endif
1070 return QCA_WLAN_802_11_MODE_11AC;
1071
1072 default:
1073 return QCA_WLAN_802_11_MODE_INVALID;
1074 }
1075
1076}
1077
1078/**
1079 * hdd_fill_station_info() - fill station information
1080 * @sap_ctx: sap context
1081 * @event: assoc event
1082 * This function updates sta information from assoc event
1083 *
1084 * Return: none
1085 */
1086static void hdd_fill_station_info(ptSapContext sap_ctx,
1087 tSap_StationAssocReassocCompleteEvent *event)
1088{
1089 struct hdd_cache_sta_info *sta_info = sap_ctx->cache_sta_info;
1090 int i=0;
1091
1092 /* check if there is any dup entry */
1093 while (i < WLAN_MAX_STA_COUNT) {
1094 if (vos_mem_compare(sta_info[i].macAddrSTA.bytes,
1095 event->staMac.bytes,
1096 VOS_MAC_ADDR_SIZE)) {
1097 vos_mem_zero(&sta_info[i], sizeof(*sta_info));
1098 break;
1099 }
1100 i++;
1101 }
1102 if (i >= WLAN_MAX_STA_COUNT) {
1103 i = 0;
1104 while (i < WLAN_MAX_STA_COUNT) {
1105 if (sta_info[i].isUsed != TRUE)
1106 break;
1107 i++;
1108 }
1109 }
1110
1111 if (i < WLAN_MAX_STA_COUNT) {
1112 sta_info[i].isUsed = TRUE;
1113 sta_info[i].ucSTAId = event->staId;
1114 vos_mem_copy(sta_info[i].macAddrSTA.bytes,
1115 event->staMac.bytes,
1116 VOS_MAC_ADDR_SIZE);
1117 sta_info[i].freq = vos_chan_to_freq(event->chan_info.chan_id);
1118 sta_info[i].ch_width = event->ch_width;
1119 sta_info[i].nss = 1;
1120 sta_info[i].dot11_mode = hdd_convert_dot11mode_from_phymode(
1121 event->chan_info.info);
1122 if (event->HTCaps.present) {
1123 sta_info[i].ht_present = TRUE;
1124 hdd_copy_ht_caps(&sta_info[i].ht_caps, &event->HTCaps);
1125 }
1126 if (event->VHTCaps.present) {
1127 sta_info[i].vht_present = TRUE;
1128 hdd_copy_vht_caps(&sta_info[i].vht_caps,
1129 &event->VHTCaps);
1130 }
1131 }
1132 else
1133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "reached max staid, stainfo can't be cached");
1134}
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301135
Jeff Johnson295189b2012-06-20 16:38:30 -07001136VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
1137{
1138 hdd_adapter_t *pHostapdAdapter;
1139 hdd_ap_ctx_t *pHddApCtx;
1140 hdd_hostapd_state_t *pHostapdState;
1141 struct net_device *dev;
1142 eSapHddEvent sapEvent;
1143 union iwreq_data wrqu;
1144 v_BYTE_t *we_custom_event_generic = NULL;
1145 int we_event = 0;
1146 int i = 0;
1147 v_U8_t staId;
1148 VOS_STATUS vos_status;
1149 v_BOOL_t bWPSState;
1150 v_BOOL_t bApActive = FALSE;
1151 v_BOOL_t bAuthRequired = TRUE;
1152 tpSap_AssocMacAddr pAssocStasArray = NULL;
1153 char unknownSTAEvent[IW_CUSTOM_MAX+1];
1154 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
1155 v_BYTE_t we_custom_start_event[64];
1156 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001157 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001158 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -07001159 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301160 v_CONTEXT_t pVosContext = NULL;
1161 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +05301162 hdd_config_t *cfg_param;
Pankaj Singhd11efa42020-06-15 12:36:00 +05301163 tSap_StationAssocReassocCompleteEvent *event;
Jeff Johnson295189b2012-06-20 16:38:30 -07001164
1165 dev = (struct net_device *)usrDataForCallback;
1166 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +05301167
1168 if ((NULL == pHostapdAdapter) ||
1169 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
1170 {
1171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1172 "invalid adapter or adapter has invalid magic");
1173 return eHAL_STATUS_FAILURE;
1174 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301175 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1176 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1177 if(pSapCtx == NULL){
1178 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1179 FL("psapCtx is NULL"));
1180 return eHAL_STATUS_FAILURE;
1181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1183 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1184 sapEvent = pSapEvent->sapHddEventCode;
1185 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001186 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +05301187 cfg_param = pHddCtx->cfg_ini;
1188
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 switch(sapEvent)
1190 {
1191 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -08001192 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
1194 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
1195 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
1196
1197 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
1198 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +05301199
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +05301201 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 goto stopbss;
1204 }
1205 else
Deepthi Gowried085092015-10-20 19:30:52 +05301206 {
1207 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1208 {
1209 if ((cfg_param->dynSplitscan) &&
1210 (!pHddCtx->issplitscan_enabled))
1211 {
1212 pHddCtx->issplitscan_enabled = TRUE;
1213 sme_enable_disable_split_scan(
1214 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
1215 cfg_param->nNumStaChanCombinedConc,
1216 cfg_param->nNumP2PChanCombinedConc);
1217 }
1218 }
1219
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1221 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +05301222 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1223 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +05301224 {
c_hpothuffdb5272013-10-02 16:42:35 +05301225 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +05301226 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
1227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 }
Deepthi Gowried085092015-10-20 19:30:52 +05301229
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1231 {
1232 // AP Inactivity timer init and start
1233 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1234 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1235 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001236 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001237
1238 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1239 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001240 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
1242 }
1243 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1244 pHostapdState->bssState = BSS_START;
1245
1246 // Send current operating channel of SoftAP to BTC-ES
1247 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1248
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 //Check if there is any group key pending to set.
1250 if( pHddApCtx->groupKey.keyLength )
1251 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001252 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1254 &pHddApCtx->groupKey ) )
1255 {
1256 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1257 "%s: WLANSAP_SetKeySta failed", __func__);
1258 }
1259 pHddApCtx->groupKey.keyLength = 0;
1260 }
1261 else if ( pHddApCtx->wepKey[0].keyLength )
1262 {
1263 int i=0;
1264 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1265 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001266 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1268 &pHddApCtx->wepKey[i] ) )
1269 {
1270 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1271 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 }
1274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1276 startBssEvent = "SOFTAP.enabled";
1277 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1278 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1279 memset(&wrqu, 0, sizeof(wrqu));
1280 wrqu.data.length = strlen(startBssEvent);
1281 we_event = IWEVCUSTOM;
1282 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001283 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 break; //Event will be sent after Switch-Case stmt
1285
1286 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001287 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1289
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001290 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001291 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301294
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 goto stopbss;
1296 case eSAP_STA_SET_KEY_EVENT:
1297 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001298 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1300 return VOS_STATUS_SUCCESS;
1301 case eSAP_STA_DEL_KEY_EVENT:
1302 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001303 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 return VOS_STATUS_SUCCESS;
1305 case eSAP_STA_MIC_FAILURE_EVENT:
1306 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 memset(&msg, '\0', sizeof(msg));
1308 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001309 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001310 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001311 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 msg.flags = IW_MICFAILURE_GROUP;
1313 else
1314 msg.flags = IW_MICFAILURE_PAIRWISE;
1315 memset(&wrqu, 0, sizeof(wrqu));
1316 wrqu.data.length = sizeof(msg);
1317 we_event = IWEVMICHAELMICFAILURE;
1318 we_custom_event_generic = (v_BYTE_t *)&msg;
1319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 /* inform mic failure to nl80211 */
1321 cfg80211_michael_mic_failure(dev,
1322 pSapEvent->sapevt.
1323 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001324 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 NL80211_KEYTYPE_GROUP :
1326 NL80211_KEYTYPE_PAIRWISE),
1327 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1328 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1329 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 break;
1331
1332 case eSAP_STA_ASSOC_EVENT:
1333 case eSAP_STA_REASSOC_EVENT:
Pankaj Singhd11efa42020-06-15 12:36:00 +05301334 event = &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent;
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 wrqu.addr.sa_family = ARPHRD_ETHER;
1336 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001337 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001338 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 we_event = IWEVREGISTERED;
1340
1341 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1342
1343 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1344 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1345 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1346 {
1347 bAuthRequired = FALSE;
1348 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301349 /* fAuthRequiredshould should be false for sap offload */
1350 if ((bAuthRequired || bWPSState)
1351#ifdef SAP_AUTH_OFFLOAD
1352 && !cfg_param->enable_sap_auth_offload
1353#endif
1354 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 {
c_hpothuffdb5272013-10-02 16:42:35 +05301356 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 TRUE,
1358 pHddApCtx->uPrivacy,
1359 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1360 0,
1361 0,
1362 (v_MACADDR_t *)wrqu.addr.sa_data,
1363 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301364
1365 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1366 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1367 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 }
1369 else
1370 {
c_hpothuffdb5272013-10-02 16:42:35 +05301371 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 FALSE,
1373 pHddApCtx->uPrivacy,
1374 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1375 0,
1376 0,
1377 (v_MACADDR_t *)wrqu.addr.sa_data,
1378 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301379 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1380 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1381 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001382 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301383 if (VOS_IS_STATUS_SUCCESS(vos_status))
1384 hdd_fill_station_info(pSapCtx,
1385 &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent);
Amar Singhal6144c002013-05-03 16:11:42 -07001386
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301387 staId =
1388 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1389 if (VOS_IS_STATUS_SUCCESS(vos_status))
1390 {
1391
1392 pSapCtx->aStaInfo[staId].rate_flags =
1393 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1394 }
1395
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 // Stop AP inactivity timer
1397 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1398 {
1399 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1400 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001401 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001403#ifdef WLAN_OPEN_SOURCE
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301404 if (vos_wake_lock_active(&pHddCtx->sap_wake_lock))
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001405 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301406 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1407 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001408 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301409 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1410 HDD_SAP_WAKE_LOCK_DURATION,
1411 WIFI_POWER_EVENT_WAKELOCK_SAP);
1412
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001414#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1415 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301416 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1418
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301419 staInfo = vos_mem_malloc(sizeof(*staInfo));
1420 if (staInfo == NULL) {
1421 hddLog(LOGE, FL("alloc station_info failed"));
1422 return VOS_STATUS_E_NOMEM;
1423 }
1424
1425 memset(staInfo, 0, sizeof(*staInfo));
Pankaj Singhd11efa42020-06-15 12:36:00 +05301426 staInfo->assoc_req_ies = event->ies;
1427 staInfo->assoc_req_ies_len = iesLen;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) && \
1429 ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
1430 !defined(WITH_BACKPORTS))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301431 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001432#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 cfg80211_new_sta(dev,
1434 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301435 staInfo, GFP_KERNEL);
1436 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 }
1438#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301439 hdd_manage_delack_timer(pHddCtx);
1440
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001441 pScanInfo = &pHddCtx->scan_info;
1442 // Lets do abort scan to ensure smooth authentication for client
1443 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1444 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301445 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301446 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001448
1449 break;
1450 case eSAP_STA_DISASSOC_EVENT:
1451 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001452 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001453 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05301454
1455 vos_status = vos_event_set(&pHostapdState->sta_discon_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1457 hddLog(LOG1," User initiated disassociation");
1458 else
1459 hddLog(LOG1," MAC initiated disassociation");
1460 we_event = IWEVEXPIRED;
1461 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1462 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1463 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001464 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 -07001465 return VOS_STATUS_E_FAILURE;
1466 }
1467 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1468
1469 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1470 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301471 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 // Start AP inactivity timer if no stations associated with it
1473 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1474 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301475 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 {
1477 bApActive = TRUE;
1478 break;
1479 }
1480 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301481 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
1483 if (bApActive == FALSE)
1484 {
1485 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1486 {
1487 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1488 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001489 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 }
1491 else
1492 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1493 }
1494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001495#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1496 cfg80211_del_sta(dev,
1497 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1498 GFP_KERNEL);
1499#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001500 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301501 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1502 if (VOS_STATUS_SUCCESS != vos_status)
1503 {
1504 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1505 __func__, vos_status);
1506 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301507 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 break;
1509 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1510 {
1511 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1512 union iwreq_data wreq;
1513
1514 down(&pHddApCtx->semWpsPBCOverlapInd);
1515 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1516
1517 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1518 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1519
1520 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001521 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 memset(&wreq, 0, sizeof(wreq));
1523 wreq.data.length = strlen(message); // This is length of message
1524 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1525
1526 return VOS_STATUS_SUCCESS;
1527 }
1528 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1529 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1530 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1531 { // List of associated stations
1532 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1533 {
1534 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1535 i+1,
1536 pAssocStasArray->assocId,
1537 pAssocStasArray->staId,
1538 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1539 pAssocStasArray++;
1540 }
1541 }
1542 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001543 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 case eSAP_REMAIN_CHAN_READY:
1546 hdd_remainChanReadyHandler( pHostapdAdapter );
1547 return VOS_STATUS_SUCCESS;
1548 case eSAP_SEND_ACTION_CNF:
1549 hdd_sendActionCnf( pHostapdAdapter,
1550 ( eSAP_STATUS_SUCCESS ==
1551 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1552 TRUE : FALSE );
1553 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 case eSAP_UNKNOWN_STA_JOIN:
1555 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1556 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1557 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1558 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1559 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1560 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1561 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1562 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1563 wrqu.data.pointer = unknownSTAEvent;
1564 wrqu.data.length = strlen(unknownSTAEvent);
1565 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301566 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 break;
1568
1569 case eSAP_MAX_ASSOC_EXCEEDED:
1570 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1571 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1572 " one or more devices to enable the new device connection",
1573 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1574 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1575 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1576 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1577 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1578 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1579 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1580 wrqu.data.pointer = maxAssocExceededEvent;
1581 wrqu.data.length = strlen(maxAssocExceededEvent);
1582 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001583 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 break;
1585 case eSAP_STA_ASSOC_IND:
1586 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001587
1588 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001589 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001590 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1591 return VOS_STATUS_SUCCESS;
1592
1593 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301594 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301595 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1596 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301597 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301598 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001599 return VOS_STATUS_SUCCESS;
Abhishekaa17c3a2020-09-18 14:15:18 +05301600 case eSAP_CHANNEL_CHANGED_EVENT:
1601 {
1602 eCsrPhyMode phy_mode = wlansap_get_phymode(
1603 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext);
1604
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301605 hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001606
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301607 return hdd_chan_change_notify(pHostapdAdapter, dev,
Abhishekaa17c3a2020-09-18 14:15:18 +05301608 pSapEvent->sapevt.sap_chan_selected.new_chan, phy_mode);
1609 }
1610 case eSAP_STA_LOSTLINK_DETECTED:
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301611 {
1612 tSap_StationDisassocCompleteEvent *disassoc_comp =
1613 &pSapEvent->sapevt.sapStationDisassocCompleteEvent;
1614
1615 struct hdd_cache_sta_info *sta_info = hdd_get_cache_stainfo(
1616 pSapCtx->cache_sta_info,
1617 disassoc_comp->staMac.bytes);
1618 if (!sta_info) {
1619 hddLog(LOGE, FL("invalid cache sta info"));
1620 return VOS_STATUS_E_FAILURE;
1621 }
1622
1623 WLANTL_GetSAPStaRSSi(pVosContext, disassoc_comp->staId,
1624 &sta_info->rssi);
1625 sta_info->rx_rate =
1626 wlan_tl_get_sta_rx_rate(pVosContext, disassoc_comp->staId);
1627 if (disassoc_comp->reason != eSAP_USR_INITATED_DISASSOC)
1628 sta_info->reason_code = disassoc_comp->reason;
1629 return VOS_STATUS_SUCCESS;
1630 }
1631
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001633 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 goto stopbss;
1635 return VOS_STATUS_SUCCESS;
1636 }
1637 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1638 return VOS_STATUS_SUCCESS;
1639
1640stopbss :
1641 {
1642 v_BYTE_t we_custom_event[64];
1643 char *stopBssEvent = "STOP-BSS.response";//17
1644 int event_len = strlen(stopBssEvent);
1645
1646 hddLog(LOG1, FL("BSS stop status = %s"),
1647 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1648 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1649
1650 /* Change the BSS state now since, as we are shutting things down,
1651 * we don't want interfaces to become re-enabled */
1652 pHostapdState->bssState = BSS_STOP;
1653
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301654 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1655 {
1656 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1657 {
1658 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1659 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1660 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1661 }
1662
1663 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1664 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1665 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1666 }
1667
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 /* Stop the pkts from n/w stack as we are going to free all of
1669 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301670
1671 /*
1672 * If channel avoidance is in progress means driver is performing SAP
1673 * restart. So don't do carrier off, which may lead framework to do
1674 * driver reload.
1675 */
1676 hddLog(LOG1, FL("ch avoid in progress: %d"),
1677 pHddCtx->is_ch_avoid_in_progress);
1678 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301679 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301680 netif_tx_disable(dev);
1681 else
1682 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001683
1684 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301685 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1686 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1687 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
Amar Singhal37e6f052013-03-05 16:16:54 -08001689 /* once the event is set, structure dev/pHostapdAdapter should
1690 * not be touched since they are now subject to being deleted
1691 * by another thread */
1692 if (eSAP_STOP_BSS_EVENT == sapEvent)
1693 vos_event_set(&pHostapdState->vosEvent);
1694
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +05301695 if (hdd_is_any_session_connected(pHddCtx) == VOS_STATUS_E_FAILURE) {
1696 hdd_enable_bmps_imps(pHddCtx);
1697 sme_request_imps(pHddCtx->hHal);
1698 }
1699
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 /* notify userspace that the BSS has stopped */
1701 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1702 memcpy(&we_custom_event, stopBssEvent, event_len);
1703 memset(&wrqu, 0, sizeof(wrqu));
1704 wrqu.data.length = event_len;
1705 we_event = IWEVCUSTOM;
1706 we_custom_event_generic = we_custom_event;
1707 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001708 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 }
Bala Venkatesh5c06a252018-07-12 16:08:04 +05301710 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO ||
1711 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
1712 {
1713 hddLog(LOG1,
1714 FL("SAP or Go is getting removed and we are trying to re-enable TDLS"));
1715 wlan_hdd_tdls_reenable(pHddCtx);
1716 }
1717
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 return VOS_STATUS_SUCCESS;
1719}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001720
1721int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001723 eCsrEncryptionType *pEncryptType,
1724 eCsrEncryptionType *mcEncryptType,
Pankaj Singh45e66bb2020-06-11 20:42:32 +05301725 tCsrAuthList *akm_list,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001726 v_BOOL_t *pMFPCapable,
1727 v_BOOL_t *pMFPRequired,
1728 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 u_int8_t *gen_ie )
1730{
1731 tDot11fIERSN dot11RSNIE;
1732 tDot11fIEWPA dot11WPAIE;
1733
1734 tANI_U8 *pRsnIe;
Pankaj Singh45e66bb2020-06-11 20:42:32 +05301735 tANI_U16 RSNIeLen, i;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301736 tANI_U32 status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001737
1738 if (NULL == halHandle)
1739 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001740 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 return -EINVAL;
1742 }
1743
1744 // Validity checks
1745 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1746 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1747 return -EINVAL;
1748 // Type check
1749 if ( gen_ie[0] == DOT11F_EID_RSN)
1750 {
1751 // Validity checks
1752 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1753 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1754 {
1755 return VOS_STATUS_E_FAILURE;
1756 }
1757 // Skip past the EID byte and length byte
1758 pRsnIe = gen_ie + 2;
1759 RSNIeLen = gen_ie_len - 2;
1760 // Unpack the RSN IE
1761 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301762
1763 status = sme_unpack_rsn_ie(halHandle,
1764 pRsnIe,
1765 RSNIeLen,
1766 &dot11RSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05301767 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301768 {
1769 hddLog(LOGE,
1770 FL("unpack failed for RSN IE status:(0x%08x)"),
1771 status);
1772 return -EINVAL;
1773 }
1774
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001776 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001777 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001778 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301779 __func__, dot11RSNIE.akm_suite_cnt);
Pankaj Singh45e66bb2020-06-11 20:42:32 +05301780
1781 //Translate akms in akm suite
1782 for (i = 0; i < dot11RSNIE.akm_suite_cnt; i++)
1783 akm_list->authType[i] =
1784 hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[i]);
1785 akm_list->numEntries = dot11RSNIE.akm_suite_cnt;
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 //dot11RSNIE.pwise_cipher_suite_count
1787 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1788 //dot11RSNIE.gp_cipher_suite_count
1789 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1790 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001791 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1792 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001793
1794 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1795 } else
1796 if (gen_ie[0] == DOT11F_EID_WPA)
1797 {
1798 // Validity checks
1799 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1800 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1801 {
1802 return VOS_STATUS_E_FAILURE;
1803 }
1804 // Skip past the EID byte and length byte - and four byte WiFi OUI
1805 pRsnIe = gen_ie + 2 + 4;
1806 RSNIeLen = gen_ie_len - (2 + 4);
1807 // Unpack the WPA IE
1808 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301809 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1810 pRsnIe,
1811 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301813 if (DOT11F_FAILED(status))
1814 {
1815 hddLog(LOGE,
1816 FL("unpack failed for WPA IE status:(0x%08x)"),
1817 status);
1818 return -EINVAL;
1819 }
1820
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001822 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001823 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001824 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001825 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 //dot11WPAIE.auth_suite_count
Pankaj Singh45e66bb2020-06-11 20:42:32 +05301827 //Translate akms in akm suite
1828 for (i = 0; i < dot11WPAIE.auth_suite_count; i++)
1829 akm_list->authType[i] =
1830 hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[i]);
1831 akm_list->numEntries = dot11WPAIE.auth_suite_count;
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 //dot11WPAIE.unicast_cipher_count
1833 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1834 //dot11WPAIE.unicast_cipher_count
1835 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001836 *pMFPCapable = VOS_FALSE;
1837 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 }
1839 else
1840 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001841 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 return VOS_STATUS_E_FAILURE;
1843 }
1844 return VOS_STATUS_SUCCESS;
1845}
Leo Chang614d2072013-08-22 14:59:44 -07001846
Leo Chang0b0e45a2013-12-15 15:18:55 -08001847#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001848
1849/*==========================================================================
1850 FUNCTION sapUpdateUnsafeChannelList
1851
1852 DESCRIPTION
1853 Function Undate unsafe channel list table
1854
1855 DEPENDENCIES
1856 NA.
1857
1858 PARAMETERS
1859
1860 IN
1861 pSapCtx : SAP context pointer, include unsafe channel list
1862
1863 RETURN VALUE
1864 NONE
1865============================================================================*/
1866void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1867 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1868{
1869 v_U16_t i, j;
1870
1871 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
1872 sizeof(pHddCtx->unsafeChannelList));
1873 if (0 == unsafeChannelCount)
1874 {
1875 pHddCtx->unsafeChannelCount = 0;
1876 }
1877 else
1878 {
c_hpothu8de53e42014-08-22 15:00:37 +05301879 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
1880 {
1881 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1882 FL("unsafeChannelCount%hd greater than %d"),
1883 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
1884 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
1885 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08001886 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
1887 unsafeChannelList,
1888 unsafeChannelCount * sizeof(tANI_U16));
1889 pHddCtx->unsafeChannelCount = unsafeChannelCount;
1890 }
1891
1892 /* Flush, default set all channel safe */
1893 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
1894 {
1895 safeChannels[i].isSafe = VOS_TRUE;
1896 }
1897
1898 /* Try to find unsafe channel */
1899 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
1900 {
1901 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
1902 {
1903 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
1904 {
1905 /* Found unsafe channel, update it */
1906 safeChannels[j].isSafe = VOS_FALSE;
1907 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1908 "%s : CH %d is not safe",
1909 __func__, pHddCtx->unsafeChannelList[i]);
1910 break;
1911 }
1912 }
1913 }
1914
1915 return;
1916}
1917
Kapil Gupta137ef892016-12-13 19:38:00 +05301918/**
1919 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
1920 * @adapter: hdd ap adapter
1921 *
1922 * hdd_unsafe_channel_restart_sap check all unsafe channel list
1923 * and if ACS is enabled, driver will ask userspace to restart the
1924 * sap. User space on LTE coex indication restart driver.
1925 *
1926 * Return - none
1927 */
1928static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
1929 hdd_context_t *hdd_ctx)
1930{
1931
1932 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
1933 return;
1934 }
1935
1936 hddLog(LOG1, FL("Current operation channel %d"),
1937 adapter->sessionCtx.ap.operatingChannel);
1938 if (false == hdd_ctx->is_ch_avoid_in_progress) {
1939 hdd_change_ch_avoidance_status(hdd_ctx, true);
1940
1941 vos_flush_work(
1942 &hdd_ctx->sap_start_work);
1943
1944 /*
1945 * current operating channel
1946 * is un-safe channel, restart SAP
1947 */
1948 hddLog(LOG1,
1949 FL("Restarting SAP due to unsafe channel"));
1950
1951 adapter->sessionCtx.ap.sapConfig.channel =
1952 AUTO_CHANNEL_SELECT;
1953
Kapil Gupta137ef892016-12-13 19:38:00 +05301954
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301955 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05301956 netif_tx_disable(adapter->dev);
1957 schedule_work(&hdd_ctx->sap_start_work);
1958 } else {
1959 hdd_hostapd_stop(adapter->dev);
1960 }
Kapil Gupta137ef892016-12-13 19:38:00 +05301961
1962 return;
1963 }
1964 return;
1965}
1966
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05301967static v_U16_t hdd_get_safe_channel_from_acs_range(hdd_context_t *hdd_ctx,
1968 hdd_adapter_t *sap_adapter, v_U16_t *unsafeChannelList,
1969 v_U16_t unsafeChannelCount)
1970{
1971 v_U8_t valid_channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1972 v_U32_t startChannelNum;
1973 v_U32_t endChannelNum;
1974 v_U32_t valid_channel_count = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1975 v_U16_t i, j;
1976 eHalStatus status;
1977 bool found;
1978
1979 status = sme_GetCfgValidChannels(hdd_ctx->hHal, valid_channels,
1980 &valid_channel_count);
1981 if (!HAL_STATUS_SUCCESS(status))
1982 return 0;
1983
1984 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL,
1985 &startChannelNum);
1986 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL,
1987 &endChannelNum);
1988
1989 for (i = 0; i < valid_channel_count; i++) {
1990 found = false;
1991 for (j = 0; j < unsafeChannelCount; j++) {
1992 if (valid_channels[i] == unsafeChannelList[j]) {
1993 found = true;
1994 break;
1995 }
1996 }
1997
1998 if (found)
1999 continue;
2000
2001 if ((valid_channels[i] >= startChannelNum) &&
2002 (valid_channels[i] <= endChannelNum)) {
2003 return valid_channels[i];
2004 }
2005 }
2006
2007 return 0;
2008}
2009
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302010void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
2011 hdd_context_t *hdd_ctxt)
2012{
2013 v_U16_t channelLoop;
2014 v_U16_t unsafeChannelCount = 0;
2015 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302016 v_U16_t sta_chan;
2017 v_U16_t restart_chan;
2018 v_CONTEXT_t vos_ctx;
2019 ptSapContext sap_ctx;
2020
2021 vos_ctx = hdd_ctxt->pvosContext;
2022 if (!vos_ctx) {
2023 hddLog(LOGE, FL("vos_ctx is NULL"));
2024 return;
2025 }
2026
2027 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
2028 if (!sap_ctx) {
2029 hddLog(LOGE, FL("sap_ctx is NULL"));
2030 return;
2031 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302032
2033 /* Get unsafe channel list */
2034 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
2035 &unsafeChannelCount);
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302036 sta_chan = hdd_get_operating_channel(hdd_ctxt, WLAN_HDD_INFRA_STATION);
2037
2038 if (sta_chan) {
2039 hddLog(LOG1, FL("Only SCC supported for STA+SAP"));
2040 return;
2041 }
2042
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302043 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
2044 {
2045 if ((unsafeChannelList[channelLoop] ==
2046 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
2047 if ((AUTO_CHANNEL_SELECT ==
2048 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
2049 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
2050 /*
2051 * current operating channel is un-safe channel
2052 * restart driver
2053 */
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302054 if (hdd_ctxt->cfg_ini->force_scc_with_ecsa) {
2055 restart_chan = hdd_get_safe_channel_from_acs_range(hdd_ctxt,
2056 phostapd_adapter, unsafeChannelList,
2057 unsafeChannelCount);
2058
2059 if (!restart_chan) {
2060 hddLog(LOGE, FL("Failed to restart SAP as no safe channel found"));
2061 return;
2062 } else {
2063 if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx))
2064 return;
2065 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
2066 if (wlansap_set_channel_change(vos_ctx, restart_chan,
2067 false)) {
2068 wlansap_reset_chan_change_in_progress(sap_ctx);
2069 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2070 return;
2071 }
2072 }
2073 } else {
2074 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
2075 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302076 /*
2077 * On LE, this event is handled by wlan-services to
2078 * restart SAP. On android, this event would be
2079 * ignored.
2080 */
2081 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
2082 NULL, 0);
2083 }
2084 break;
2085 }
2086 }
2087 return;
2088}
2089
2090
Kapil Gupta137ef892016-12-13 19:38:00 +05302091
Leo Chang0b0e45a2013-12-15 15:18:55 -08002092/**---------------------------------------------------------------------------
2093
2094 \brief hdd_hostapd_ch_avoid_cb() -
2095
2096 Avoid channel notification from FW handler.
2097 FW will send un-safe channle list to avoid overwrapping.
2098 hostapd should not use notified channel
2099
2100 \param - pAdapter HDD adapter pointer
2101 indParam channel avoid notification parameter
2102
2103 \return - None
2104
2105 --------------------------------------------------------------------------*/
2106void hdd_hostapd_ch_avoid_cb
2107(
Kapil Gupta137ef892016-12-13 19:38:00 +05302108 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08002109 void *indParam
2110)
2111{
2112 hdd_adapter_t *pHostapdAdapter = NULL;
2113 hdd_context_t *hddCtxt;
2114 tSirChAvoidIndType *chAvoidInd;
2115 v_U8_t rangeLoop;
2116 v_U16_t channelLoop;
2117 v_U16_t dupCheck;
2118 v_U16_t startChannel;
2119 v_U16_t endChannel;
2120 v_U16_t unsafeChannelCount = 0;
2121 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
2122 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002123 tHddAvoidFreqList hddAvoidFreqList;
2124 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302125#ifdef WLAN_FEATURE_AP_HT40_24G
2126 ptSapContext pSapCtx = NULL;
2127 tHalHandle hHal;
2128 v_U8_t cbMode;
2129 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2130 v_U32_t delay;
2131#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002132
2133 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05302134 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002135 {
2136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2137 "%s : Invalid arguments", __func__);
2138 return;
2139 }
2140
Kapil Gupta137ef892016-12-13 19:38:00 +05302141 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08002142 chAvoidInd = (tSirChAvoidIndType *)indParam;
2143 pVosContext = hddCtxt->pvosContext;
2144
2145 /* Make unsafe channel list */
2146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2147 "%s : band count %d",
2148 __func__, chAvoidInd->avoidRangeCount);
2149 vos_mem_zero((void *)unsafeChannelList,
2150 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
2151 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
2152 {
Abhishek Singh57a31542016-01-04 21:01:43 +05302153 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2154 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2155 break;
2156 }
2157 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002158 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05302159 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002160 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
2161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2162 "%s : start %d : %d, end %d : %d",
2163 __func__,
2164 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
2165 startChannel,
2166 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
2167 endChannel);
2168 for (channelLoop = startChannel;
2169 channelLoop < (endChannel + 1);
2170 channelLoop++)
2171 {
2172 /* Channel duplicate check routine */
2173 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
2174 {
2175 if (unsafeChannelList[dupCheck] == channelLoop)
2176 {
2177 /* This channel is duplicated */
2178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2179 "%s : found duplicated channel %d",
2180 __func__, channelLoop);
2181 break;
2182 }
2183 }
2184 if (dupCheck == unsafeChannelCount)
2185 {
c_hpothu8de53e42014-08-22 15:00:37 +05302186 int ii;
2187 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
2188 {
2189 if (channelLoop == safeChannels[ii].channelNumber)
2190 {
2191 unsafeChannelList[unsafeChannelCount] = channelLoop;
2192 unsafeChannelCount++;
2193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2194 "%s : unsafe channel %d, count %d",
2195 __func__,
2196 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05302197 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2198 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2199 break;
2200 }
c_hpothu8de53e42014-08-22 15:00:37 +05302201 }
2202 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08002203 }
2204 else
2205 {
2206 /* DUP, do nothing */
2207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2208 "%s : duplicated channel %d",
2209 __func__, channelLoop);
2210 }
2211 }
2212 }
2213 /* Update unsafe channel cache
2214 * WCN Platform Driver cache */
2215 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
2216 unsafeChannelCount);
2217
2218 /* Store into local cache
2219 * Start with STA and later start SAP
2220 * in this scenario, local cache will be used */
2221 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
2222 unsafeChannelList,
2223 unsafeChannelCount);
2224
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002225 /* generate vendor specific event */
2226 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
2227 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
2228 {
2229 hddAvoidFreqList.avoidFreqRange[i].startFreq =
2230 chAvoidInd->avoidFreqRange[i].startFreq;
2231 hddAvoidFreqList.avoidFreqRange[i].endFreq =
2232 chAvoidInd->avoidFreqRange[i].endFreq;
2233 }
2234 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
2235
2236 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
2237
Leo Chang0b0e45a2013-12-15 15:18:55 -08002238 /* Get SAP context first
2239 * SAP and P2PGO would not concurrent */
2240 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302241#ifdef WLAN_FEATURE_AP_HT40_24G
2242 if (NULL == pHostapdAdapter)
2243 {
2244 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
2245 }
2246#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05302247 if ((pHostapdAdapter) &&
2248 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
2249 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002250 {
2251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2252 "%s : Current operation channel %d",
2253 __func__,
2254 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302255 /* Check and Restart the SAP if it is on unsafe channel */
2256 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
2257
Leo Chang0b0e45a2013-12-15 15:18:55 -08002258 }
2259
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302260#ifdef WLAN_FEATURE_AP_HT40_24G
2261 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
2262 {
2263 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2264
2265 if(pSapCtx == NULL)
2266 {
2267 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
2268 FL("psapCtx is NULL"));
2269 return;
2270 }
2271
2272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2273 FL("SAP Secondary channel: %d "),
2274 pSapCtx->sap_sec_chan);
2275
2276 /* tHalHandle */
2277 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2278
2279 if (NULL == hHal)
2280 {
2281 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2282 FL("In invalid hHal"));
2283 return;
2284 }
2285
2286 cbMode = sme_GetChannelBondingMode24G(hHal);
2287
2288 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2289 FL("Selected Channel bonding : %d"), cbMode);
2290
2291 if (cbMode && (pSapCtx->sap_sec_chan > 0))
2292 {
2293 int i;
2294 eHalStatus halStatus;
2295
2296 for (i = 0; i < unsafeChannelCount; i++)
2297 {
2298 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
2299 {
2300 /* Current SAP Secondary channel is un-safe channel */
2301 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2302 FL("Move SAP from HT40 to HT20"));
2303
2304 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
2305 PHY_SINGLE_CHANNEL_CENTERED);
2306
2307 if (halStatus == eHAL_STATUS_FAILURE)
2308 {
2309 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2310 FL("Failed to change HT20/40 mode"));
2311 return;
2312 }
2313
2314 /* Disable Channel Bonding for 2.4GHz */
2315 sme_UpdateChannelBondingMode24G(hHal,
2316 PHY_SINGLE_CHANNEL_CENTERED);
2317 return;
2318 }
2319 }
2320 }
2321
2322 if ((!pSapCtx->numHT40IntoSta)
2323 && (pHostapdAdapter)
2324 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
2325 {
2326 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
2327 * are Safe then start HT20/40 timer to Move SAP from HT20
2328 * to HT40.
2329 */
2330 if (((!unsafeChannelCount)
2331 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
2332 {
2333 /* Stop Previous Running HT20/40 Timer & Start timer
2334 with (OBSS TransitionDelayFactor * obss interval)
2335 delay after time out move AP from HT20 -> HT40
2336 mode
2337 */
2338 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2339 {
2340 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2341 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2342 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2343 FL("Failed to Stop HT20/40 timer"));
2344 }
2345
2346 delay =
2347 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
2348
2349 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2350 FL("Start HT20/40 transition timer (%d sec)"), delay);
2351
2352 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
2353 (delay * 1000));
2354
2355 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2356 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2357 FL("Failed to Start HT20/40 timer"));
2358 }
2359 else
2360 {
2361 /* Stop HT20/40 Timer */
2362 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2363 {
2364 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2365 FL("Stop HT20/40 transition timer"));
2366 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2367 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2368 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2369 FL("Failed to Stop HT20/40 timer"));
2370 }
2371 }
2372 }
2373 }
2374#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002375 return;
2376}
Leo Chang0b0e45a2013-12-15 15:18:55 -08002377#endif /* FEATURE_WLAN_CH_AVOID */
2378
Jeff Johnson295189b2012-06-20 16:38:30 -07002379int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302380static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 struct iw_request_info *info,
2382 union iwreq_data *wrqu, char *extra)
2383{
2384 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002385 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302386 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 int *value = (int *)extra;
2388 int sub_cmd = value[0];
2389 int set_value = value[1];
2390 eHalStatus status;
2391 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302392 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002393 v_CONTEXT_t pVosContext;
2394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302395 ENTER();
2396
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302397 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002398 {
2399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302400 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002401 __func__);
2402 return -1;
2403 }
2404
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302405 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2406 ret = wlan_hdd_validate_context(pHddCtx);
2407 if (0 != ret)
2408 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302409 return -1;
2410 }
2411
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002412 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2413 if (!hHal)
2414 {
2415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2416 "%s: Hal ctx is null", __func__);
2417 return -1;
2418 }
2419
2420 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2421 if (!pVosContext)
2422 {
2423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2424 "%s: Vos ctx is null", __func__);
2425 return -1;
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427
2428 switch(sub_cmd)
2429 {
2430
2431 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002432 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302434 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 }
2436 break;
2437
2438 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302439 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2441 {
2442 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2443 ret = -EINVAL;
2444 }
2445 else
2446 {
2447 WLANSAP_SetMode(pVosContext, set_value);
2448 }
2449 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302450
2451 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2452 if ((0 != set_value) && (1 != set_value))
2453 {
2454 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2455 ret = -EINVAL;
2456 }
2457 else
2458 {
2459 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2460 }
2461 break;
2462
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 case QCSAP_PARAM_MAX_ASSOC:
2464 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2465 {
2466 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2467 ret = -EINVAL;
2468 }
2469 else
2470 {
2471 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2472 {
2473 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2474 "Setting it to max allowed and continuing"),
2475 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2476 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2477 }
2478 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2479 set_value, NULL, eANI_BOOLEAN_FALSE);
2480 if ( status != eHAL_STATUS_SUCCESS )
2481 {
2482 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2483 status);
2484 ret = -EIO;
2485 }
2486 }
2487 break;
2488
2489 case QCSAP_PARAM_HIDE_SSID:
2490 {
2491 eHalStatus status = eHAL_STATUS_SUCCESS;
2492 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2493 if(eHAL_STATUS_SUCCESS != status)
2494 {
2495 hddLog(VOS_TRACE_LEVEL_ERROR,
2496 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002497 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 return status;
2499 }
2500 break;
2501 }
2502
Leo Chang614d2072013-08-22 14:59:44 -07002503 case QCSAP_PARAM_SET_MC_RATE:
2504 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002505 tSirRateUpdateInd *rateUpdate;
2506
2507 rateUpdate = (tSirRateUpdateInd *)
2508 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2509 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002510 {
2511 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002512 "%s: SET_MC_RATE indication alloc fail", __func__);
2513 ret = -1;
2514 break;
2515 }
2516 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2517
2518 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2519 /* Ignore unicast */
2520 rateUpdate->ucastDataRate = -1;
2521 rateUpdate->mcastDataRate24GHz = set_value;
2522 rateUpdate->mcastDataRate5GHz = set_value;
2523 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2524 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2525 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2526 if (eHAL_STATUS_SUCCESS != status)
2527 {
2528 hddLog(VOS_TRACE_LEVEL_ERROR,
2529 "%s: SET_MC_RATE failed", __func__);
2530 vos_mem_free(rateUpdate);
2531 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002532 }
2533 break;
2534 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302535 case QCSAP_PARAM_GET_FRAME_LOGS:
2536 {
2537 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2538 != VOS_STATUS_SUCCESS)
2539 {
2540 ret = -EINVAL;
2541 }
2542 break;
2543 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302544 case QCSAP_PARAM_SET_PROXIMITY:
2545 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302546 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302547 break;
2548 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302549 case QCSAP_PARAM_SET_WOWL:
2550 {
2551 if (!pHddCtx->is_ap_mode_wow_supported)
2552 {
2553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2554 "%s: Not supported",__func__);
2555 return -ENOTSUPP;
2556 }
2557 switch (set_value)
2558 {
2559 case 0x00:
2560 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2561 break;
2562 case 0x01:
2563 case 0x02:
2564 case 0x03:
2565 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2566 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2567 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2568 (enable_magic_pkt ? "YES":"NO"),
2569 (enable_pattrn_byte_match ? "YES":"NO"));
2570 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2571 enable_pattrn_byte_match);
2572 break;
2573 default:
2574 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2575 ret = -EINVAL;
2576 break;
2577 }
2578 break;
2579 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302580 case QCSAP_PARAM_CAP_TSF:
2581 {
2582 ret = hdd_capture_tsf(pHostapdAdapter,
2583 (uint32_t *)&set_value, 1);
2584 break;
2585 }
Abhishek Singh02605092017-10-25 14:06:12 +05302586 case QCSAP_PARAM_SET_CHANNEL_CHANGE:
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302587 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) {
2588 ptSapContext sap_ctx;
2589
2590 sap_ctx = VOS_GET_SAP_CB(pVosContext);
2591 if (!sap_ctx) {
2592 hddLog(LOGE, FL("sap_ctx is NULL"));
2593 return -EINVAL;
2594 }
2595 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
2596 if (ret)
2597 return ret;
2598 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
Abhishek Singh02605092017-10-25 14:06:12 +05302599 hddLog(LOG1, FL("ET Channel Change to new channel= %d"),
2600 set_value);
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302601 ret = wlansap_set_channel_change(pVosContext, set_value, false);
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302602 if (ret) {
2603 wlansap_reset_chan_change_in_progress(sap_ctx);
2604 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2605 }
Abhishek Singh02605092017-10-25 14:06:12 +05302606 } else {
2607 hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"),
2608 set_value);
2609 ret = -EINVAL;
2610 }
2611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 default:
2613 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2614 sub_cmd, set_value);
2615 ret = -EINVAL;
2616 break;
2617 }
2618
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302619 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 return ret;
2621}
2622
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302623int
2624static iw_softap_setparam(struct net_device *dev,
2625 struct iw_request_info *info,
2626 union iwreq_data *wrqu, char *extra)
2627{
2628 int ret;
2629
2630 vos_ssr_protect(__func__);
2631 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2632 vos_ssr_unprotect(__func__);
2633
2634 return ret;
2635}
Jeff Johnson295189b2012-06-20 16:38:30 -07002636
2637int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302638static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 struct iw_request_info *info,
2640 union iwreq_data *wrqu, char *extra)
2641{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302642 hdd_adapter_t *pHostapdAdapter;
2643 tHalHandle hHal;
2644 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 int *value = (int *)extra;
2646 int sub_cmd = value[0];
2647 eHalStatus status;
2648 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302649 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002650
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302651 ENTER();
2652
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302653 pHostapdAdapter = (netdev_priv(dev));
2654 if (NULL == pHostapdAdapter)
2655 {
2656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2657 "%s: Adapter is NULL",__func__);
2658 return -EINVAL;
2659 }
2660 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2661 ret = wlan_hdd_validate_context(pHddCtx);
2662 if (0 != ret)
2663 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302664 return ret;
2665 }
2666 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2667 if (NULL == hHal)
2668 {
2669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2670 "%s: Hal Context is NULL",__func__);
2671 return -EINVAL;
2672 }
2673 pVosContext = pHddCtx->pvosContext;
2674 if (NULL == pVosContext)
2675 {
2676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2677 "%s: pVosContext Context is NULL",__func__);
2678 return -EINVAL;
2679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 switch (sub_cmd)
2681 {
2682 case QCSAP_PARAM_MAX_ASSOC:
2683 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2684 if (eHAL_STATUS_SUCCESS != status)
2685 {
c_hpothuffdb5272013-10-02 16:42:35 +05302686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2687 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 ret = -EIO;
2689 }
Girish Gowli385be612014-09-18 11:17:20 +05302690
2691#ifdef WLAN_SOFTAP_VSTA_FEATURE
2692 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2693 {
2694 if (*value > VSTA_NUM_ASSOC_STA)
2695 {
2696 *value = VSTA_NUM_ASSOC_STA;
2697 }
2698 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2699 (*value > (VSTA_NUM_ASSOC_STA -
2700 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2701 {
2702 *value = (VSTA_NUM_ASSOC_STA -
2703 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2704 }
2705 }
2706 else
2707#endif
2708 {
2709 if (*value > NUM_ASSOC_STA)
2710 {
2711 *value = NUM_ASSOC_STA;
2712 }
2713 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2714 (*value > (NUM_ASSOC_STA -
2715 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2716 {
2717 *value = (NUM_ASSOC_STA -
2718 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2719 }
2720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302722
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002724 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 {
c_hpothuffdb5272013-10-02 16:42:35 +05302726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2727 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302728 ret = -EIO;
2729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 *value = 0;
2731 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302732
Jeff Johnson43971f52012-07-17 12:26:56 -07002733 case QCSAP_PARAM_GET_WLAN_DBG:
2734 {
2735 vos_trace_display();
2736 *value = 0;
2737 break;
2738 }
2739
2740 case QCSAP_PARAM_AUTO_CHANNEL:
2741 {
2742 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2743 break;
2744 }
2745
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 default:
2747 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2748 ret = -EINVAL;
2749 break;
2750
2751 }
2752
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302753 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 return ret;
2755}
2756
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302757int
2758static iw_softap_getparam(struct net_device *dev,
2759 struct iw_request_info *info,
2760 union iwreq_data *wrqu, char *extra)
2761{
2762 int ret;
2763
2764 vos_ssr_protect(__func__);
2765 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2766 vos_ssr_unprotect(__func__);
2767
2768 return ret;
2769}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302770
2771int
2772static __iw_softap_setchar_getnone(struct net_device *dev,
2773 struct iw_request_info *info,
2774 union iwreq_data *wrqu, char *extra)
2775{
2776 int sub_cmd;
2777 int ret = 0; /* success */
2778 char *pBuffer = NULL;
2779 hdd_adapter_t *pAdapter;
2780 hdd_context_t *pHddCtx;
2781 struct iw_point s_priv_data;
2782
2783 ENTER();
2784
2785 if (!capable(CAP_NET_ADMIN))
2786 {
2787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2788 FL("permission check failed"));
2789 return -EPERM;
2790 }
2791
2792 pAdapter = (netdev_priv(dev));
2793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2794 ret = wlan_hdd_validate_context(pHddCtx);
2795 if (0 != ret)
2796 {
2797 return ret;
2798 }
2799
2800 if (!pHddCtx->is_ap_mode_wow_supported)
2801 {
2802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2803 "%s: Not supported",__func__);
2804 return -ENOTSUPP;
2805 }
2806
2807 /* helper function to get iwreq_data with compat handling. */
2808 if (hdd_priv_get_data(&s_priv_data, wrqu))
2809 {
2810 return -EINVAL;
2811 }
2812
2813 /* make sure all params are correctly passed to function */
2814 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2815 {
2816 return -EINVAL;
2817 }
2818
2819 sub_cmd = s_priv_data.flags;
2820
2821 /* ODD number is used for set, copy data using copy_from_user */
2822 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2823 s_priv_data.length);
2824 if (NULL == pBuffer)
2825 {
2826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2827 "mem_alloc_copy_from_user_helper fail");
2828 return -ENOMEM;
2829 }
2830
2831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2832 "%s: Received length %d", __func__, s_priv_data.length);
2833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2834 "%s: Received data %s", __func__, pBuffer);
2835
2836 switch(sub_cmd)
2837 {
2838 case WE_WOWL_ADD_PTRN:
2839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2840 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2841 if (!ret)
2842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2843 "Failed to add pattern :%d", ret);
2844 break;
2845 case WE_WOWL_DEL_PTRN:
2846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2847 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2848 if (!ret)
2849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2850 "Failed to del pattern :%d", ret);
2851 break;
2852 default:
2853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2854 ret = -EINVAL;
2855 break;
2856 }
2857
2858 kfree(pBuffer);
2859 return ret;
2860}
2861
2862int
2863static iw_softap_setchar_getnone(struct net_device *dev,
2864 struct iw_request_info *info,
2865 union iwreq_data *wrqu, char *extra)
2866{
2867 int ret;
2868
2869 vos_ssr_protect(__func__);
2870 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
2871 vos_ssr_unprotect(__func__);
2872
2873 return ret;
2874}
2875
Jeff Johnson295189b2012-06-20 16:38:30 -07002876/* Usage:
2877 BLACK_LIST = 0
2878 WHITE_LIST = 1
2879 ADD MAC = 0
2880 REMOVE MAC = 1
2881
2882 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
2883 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
2884 while using this ioctl
2885
2886 Syntax:
2887 iwpriv softap.0 modify_acl
2888 <6 octet mac addr> <list type> <cmd type>
2889
2890 Examples:
2891 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
2892 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
2893 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
2894 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
2895*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302896int __iw_softap_modify_acl(struct net_device *dev,
2897 struct iw_request_info *info,
2898 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002899{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302900 hdd_adapter_t *pHostapdAdapter;
2901 v_CONTEXT_t pVosContext;
2902 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 v_BYTE_t *value = (v_BYTE_t*)extra;
2904 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
2905 int listType, cmd, i;
2906 int ret = 0; /* success */
2907
2908 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302909 pHostapdAdapter = (netdev_priv(dev));
2910 if (NULL == pHostapdAdapter)
2911 {
2912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2913 "%s: Adapter is NULL",__func__);
2914 return -EINVAL;
2915 }
2916 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2917 ret = wlan_hdd_validate_context(pHddCtx);
2918 if (0 != ret)
2919 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302920 return ret;
2921 }
2922 pVosContext = pHddCtx->pvosContext;
2923 if (NULL == pVosContext)
2924 {
2925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2926 "%s: Vos Context is NULL",__func__);
2927 return -EINVAL;
2928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
2930 {
2931 pPeerStaMac[i] = *(value+i);
2932 }
2933 listType = (int)(*(value+i));
2934 i++;
2935 cmd = (int)(*(value+i));
2936
Arif Hussain24bafea2013-11-15 15:10:03 -08002937 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
2938 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002939
2940 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
2941 != VOS_STATUS_SUCCESS)
2942 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002943 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 ret = -EIO;
2945 }
2946 EXIT();
2947 return ret;
2948}
2949
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302950int iw_softap_modify_acl(struct net_device *dev,
2951 struct iw_request_info *info,
2952 union iwreq_data *wrqu, char *extra)
2953{
2954 int ret;
2955
2956 vos_ssr_protect(__func__);
2957 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
2958 vos_ssr_unprotect(__func__);
2959
2960 return ret;
2961}
2962
Jeff Johnson295189b2012-06-20 16:38:30 -07002963int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302964static __iw_softap_getchannel(struct net_device *dev,
2965 struct iw_request_info *info,
2966 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002967{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302968 hdd_adapter_t *pHostapdAdapter;
2969 hdd_context_t *pHddCtx;
2970 int ret = 0;
2971 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302972
2973 ENTER();
2974
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302975 pHostapdAdapter = (netdev_priv(dev));
2976 if (NULL == pHostapdAdapter)
2977 {
2978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2979 "%s: Adapter is NULL",__func__);
2980 return -EINVAL;
2981 }
2982 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2983 ret = wlan_hdd_validate_context(pHddCtx);
2984 if (0 != ret)
2985 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302986 return ret;
2987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002988
Mukul Sharma6d0762c2015-03-05 17:13:47 +05302989 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002990
Jeff Johnson43971f52012-07-17 12:26:56 -07002991 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992
2993 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 return 0;
2995}
2996
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302997
Jeff Johnsone7245742012-09-05 17:12:55 -07002998int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302999static iw_softap_getchannel(struct net_device *dev,
3000 struct iw_request_info *info,
3001 union iwreq_data *wrqu, char *extra)
3002{
3003 int ret;
3004
3005 vos_ssr_protect(__func__);
3006 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
3007 vos_ssr_unprotect(__func__);
3008
3009 return ret;
3010}
3011
3012int
3013static __iw_softap_set_max_tx_power(struct net_device *dev,
3014 struct iw_request_info *info,
3015 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07003016{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303017 hdd_adapter_t *pHostapdAdapter;
3018 tHalHandle hHal;
3019 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07003020 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303021 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003022 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3023 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303025 ENTER();
3026
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303027 pHostapdAdapter = (netdev_priv(dev));
3028 if (NULL == pHostapdAdapter)
3029 {
3030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3031 "%s: Adapter is NULL",__func__);
3032 return -EINVAL;
3033 }
3034 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3035 ret = wlan_hdd_validate_context(pHddCtx);
3036 if (0 != ret)
3037 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303038 return ret;
3039 }
3040 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3041 if (NULL == hHal)
3042 {
3043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3044 "%s: Hal Context is NULL",__func__);
3045 return -EINVAL;
3046 }
schang86c22c42013-03-13 18:41:24 -07003047 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07003048 return -ENOMEM;
3049
Leo Changd37675a2013-08-01 13:19:45 -07003050 /* Assign correct slef MAC address */
3051 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
3052 VOS_MAC_ADDR_SIZE);
3053 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
3054 VOS_MAC_ADDR_SIZE);
3055
schang86c22c42013-03-13 18:41:24 -07003056 set_value = value[0];
3057 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
3058 {
3059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003060 __func__);
schang86c22c42013-03-13 18:41:24 -07003061 return -EIO;
3062 }
3063
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303064 EXIT();
schang86c22c42013-03-13 18:41:24 -07003065 return 0;
3066}
3067
3068int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303069static iw_softap_set_max_tx_power(struct net_device *dev,
3070 struct iw_request_info *info,
3071 union iwreq_data *wrqu, char *extra)
3072{
3073 int ret;
3074
3075 vos_ssr_protect(__func__);
3076 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
3077 vos_ssr_unprotect(__func__);
3078
3079 return ret;
3080}
3081
3082
3083int
3084static __iw_display_data_path_snapshot(struct net_device *dev,
3085 struct iw_request_info *info,
3086 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303087{
3088
3089 /* Function intitiating dumping states of
3090 * HDD(WMM Tx Queues)
3091 * TL State (with Per Client infor)
3092 * DXE Snapshot (Called at the end of TL Snapshot)
3093 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303094 hdd_adapter_t *pHostapdAdapter;
3095 hdd_context_t *pHddCtx;
3096 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303097
3098 ENTER();
3099
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303100 pHostapdAdapter = (netdev_priv(dev));
3101 if (NULL == pHostapdAdapter)
3102 {
3103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3104 "%s: Adapter is NULL",__func__);
3105 return -EINVAL;
3106 }
3107 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3108 ret = wlan_hdd_validate_context(pHddCtx);
3109 if (0 != ret)
3110 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303111 return ret;
3112 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303113 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05303114 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303115
3116 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303117 return 0;
3118}
3119
3120int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303121static iw_display_data_path_snapshot(struct net_device *dev,
3122 struct iw_request_info *info,
3123 union iwreq_data *wrqu, char *extra)
3124{
3125 int ret;
3126
3127 vos_ssr_protect(__func__);
3128 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
3129 vos_ssr_unprotect(__func__);
3130
3131 return ret;
3132}
3133
3134int
3135static __iw_softap_set_tx_power(struct net_device *dev,
3136 struct iw_request_info *info,
3137 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07003138{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303139 hdd_adapter_t *pHostapdAdapter;
3140 hdd_context_t *pHddCtx;
3141 v_CONTEXT_t pVosContext;
3142 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07003143 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303144 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07003145 ptSapContext pSapCtx = NULL;
3146
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303147 ENTER();
3148
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303149 pHostapdAdapter = (netdev_priv(dev));
3150 if (NULL == pHostapdAdapter)
3151 {
3152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3153 "%s: Adapter is NULL",__func__);
3154 return -EINVAL;
3155 }
3156 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3157 ret = wlan_hdd_validate_context(pHddCtx);
3158 if (0 != ret)
3159 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303160 return ret;
3161 }
3162 pVosContext = pHddCtx->pvosContext;
3163 if (NULL == pVosContext)
3164 {
3165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3166 "%s: Vos Context is NULL",__func__);
3167 return -EINVAL;
3168 }
3169 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3170 if (NULL == hHal)
3171 {
3172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3173 "%s: Hal Context is NULL",__func__);
3174 return -EINVAL;
3175 }
schang86c22c42013-03-13 18:41:24 -07003176 if (NULL == value)
3177 return -ENOMEM;
3178
3179 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3180 if (NULL == pSapCtx)
3181 {
3182 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3183 "%s: Invalid SAP pointer from pvosGCtx", __func__);
3184 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003185 }
3186
3187 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07003188 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07003189 {
schang86c22c42013-03-13 18:41:24 -07003190 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07003191 __func__);
3192 return -EIO;
3193 }
3194
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303195 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07003196 return 0;
3197}
3198
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303199int
3200static iw_softap_set_tx_power(struct net_device *dev,
3201 struct iw_request_info *info,
3202 union iwreq_data *wrqu, char *extra)
3203{
3204 int ret;
3205
3206 vos_ssr_protect(__func__);
3207 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
3208 vos_ssr_unprotect(__func__);
3209
3210 return ret;
3211}
3212
Kiet Lambcf38522013-10-26 18:28:27 +05303213/**---------------------------------------------------------------------------
3214
3215 \brief iw_softap_set_trafficmonitor() -
3216 This function dynamically enable/disable traffic monitor functonality
3217 the command iwpriv wlanX setTrafficMon <value>.
3218
3219 \param - dev - Pointer to the net device.
3220 - addr - Pointer to the sockaddr.
3221 \return - 0 for success, non zero for failure
3222
3223 --------------------------------------------------------------------------*/
3224
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303225static int __iw_softap_set_trafficmonitor(struct net_device *dev,
3226 struct iw_request_info *info,
3227 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05303228{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303229 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05303230 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05303231 hdd_context_t *pHddCtx;
3232 int status;
3233
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303234 ENTER();
3235
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303236 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05303237 if (NULL == pAdapter)
3238 {
3239 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3240 "%s: HDD adapter is Null", __func__);
3241 return -ENODEV;
3242 }
3243
3244 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3245
3246 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05303247 if (0 != status)
3248 {
Kiet Lambcf38522013-10-26 18:28:27 +05303249 return status;
3250 }
3251
3252 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
3253
3254 if (NULL == isSetTrafficMon)
3255 {
3256 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3257 "%s: Invalid SAP pointer from extra", __func__);
3258 return -ENOMEM;
3259 }
3260
3261 if (TRUE == *isSetTrafficMon)
3262 {
3263 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303264 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303265 {
3266 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3267 "%s: failed to Start Traffic Monitor timer ", __func__ );
3268 return -EIO;
3269 }
3270 }
3271 else if (FALSE == *isSetTrafficMon)
3272 {
3273 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303274 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303275 {
3276 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3277 "%s: failed to Stop Traffic Monitor timer ", __func__ );
3278 return -EIO;
3279 }
3280
3281 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303282
3283 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05303284 return 0;
3285}
3286
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303287static int iw_softap_set_trafficmonitor(struct net_device *dev,
3288 struct iw_request_info *info,
3289 union iwreq_data *wrqu, char *extra)
3290{
3291 int ret;
3292
3293 vos_ssr_protect(__func__);
3294 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
3295 vos_ssr_unprotect(__func__);
3296
3297 return ret;
3298}
3299
Jeff Johnson295189b2012-06-20 16:38:30 -07003300#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
3301
3302int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303303static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
3304 struct iw_request_info *info,
3305 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003306{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303307 hdd_adapter_t *pHostapdAdapter;
3308 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303309 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07003310 char *buf;
3311 int cnt = 0;
3312 int left;
3313 int ret = 0;
3314 /* maclist_index must be u32 to match userspace */
3315 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303316 v_CONTEXT_t pVosContext = NULL;
3317 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303318
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303319 ENTER();
3320
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303321 pHostapdAdapter = (netdev_priv(dev));
3322 if (NULL == pHostapdAdapter)
3323 {
3324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3325 "%s: Adapter is NULL",__func__);
3326 return -EINVAL;
3327 }
3328 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3329 ret = wlan_hdd_validate_context(pHddCtx);
3330 if (0 != ret)
3331 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303332 return ret;
3333 }
3334
Jeff Johnson224f3702014-03-26 11:09:47 -07003335 /*
3336 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
3337 * number, and even numbered iocts are supposed to have "set"
3338 * semantics. Hence the wireless extensions support in the kernel
3339 * won't correctly copy the result to userspace, so the ioctl
3340 * handler itself must copy the data. Output format is 32-bit
3341 * record length, followed by 0 or more 6-byte STA MAC addresses.
3342 *
3343 * Further note that due to the incorrect semantics, the "iwpriv"
3344 * userspace application is unable to correctly invoke this API,
3345 * hence it is not registered in the hostapd_private_args. This
3346 * API can only be invoked by directly invoking the ioctl() system
3347 * call.
3348 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003349
Jeff Johnson224f3702014-03-26 11:09:47 -07003350 /* make sure userspace allocated a reasonable buffer size */
3351 if (wrqu->data.length < sizeof(maclist_index)) {
3352 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
3353 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07003354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303356 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3357 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3358 if(pSapCtx == NULL){
3359 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3360 FL("psapCtx is NULL"));
3361 return -EFAULT;
3362 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05303363
3364 /* allocate local buffer to build the response */
3365 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
3366 if (!buf) {
3367 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
3368 return -ENOMEM;
3369 }
3370
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303371 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07003372 /* start indexing beyond where the record count will be written */
3373 maclist_index = sizeof(maclist_index);
3374 left = wrqu->data.length - maclist_index;
3375
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303376 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003377 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
3378 if ((pStaInfo[cnt].isUsed) &&
3379 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
3380 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
3381 VOS_MAC_ADDR_SIZE);
3382 maclist_index += VOS_MAC_ADDR_SIZE;
3383 left -= VOS_MAC_ADDR_SIZE;
3384 }
3385 cnt++;
3386 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303387 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003388
3389 *((u32 *)buf) = maclist_index;
3390 wrqu->data.length = maclist_index;
3391 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
3392 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
3393 ret = -EFAULT;
3394 }
3395 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303396
3397 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07003398 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003399}
3400
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303401int
3402static iw_softap_getassoc_stamacaddr(struct net_device *dev,
3403 struct iw_request_info *info,
3404 union iwreq_data *wrqu, char *extra)
3405{
3406 int ret;
3407
3408 vos_ssr_protect(__func__);
3409 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
3410 vos_ssr_unprotect(__func__);
3411
3412 return ret;
3413}
3414
Jeff Johnson295189b2012-06-20 16:38:30 -07003415/* Usage:
3416 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3417 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3418 while using this ioctl
3419
3420 Syntax:
3421 iwpriv softap.0 disassoc_sta <6 octet mac address>
3422
3423 e.g.
3424 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
3425 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
3426*/
3427
3428int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303429static __iw_softap_disassoc_sta(struct net_device *dev,
3430 struct iw_request_info *info,
3431 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003432{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303433 hdd_adapter_t *pHostapdAdapter;
3434 hdd_context_t *pHddCtx;
3435 v_U8_t *peerMacAddr;
3436 int ret = 0;
3437
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05303439
3440 if (!capable(CAP_NET_ADMIN)) {
3441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3442 FL("permission check failed"));
3443 return -EPERM;
3444 }
3445
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303446 pHostapdAdapter = (netdev_priv(dev));
3447 if (NULL == pHostapdAdapter)
3448 {
3449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3450 "%s: Adapter is NULL",__func__);
3451 return -EINVAL;
3452 }
3453 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3454 ret = wlan_hdd_validate_context(pHddCtx);
3455 if (0 != ret)
3456 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303457 return ret;
3458 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303459 /* iwpriv tool or framework calls this ioctl with
3460 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303462 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003463
Arif Hussain24bafea2013-11-15 15:10:03 -08003464 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
3465 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
3467 EXIT();
3468 return 0;
3469}
3470
3471int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303472static iw_softap_disassoc_sta(struct net_device *dev,
3473 struct iw_request_info *info,
3474 union iwreq_data *wrqu, char *extra)
3475{
3476 int ret;
3477
3478 vos_ssr_protect(__func__);
3479 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3480 vos_ssr_unprotect(__func__);
3481
3482 return ret;
3483}
3484
3485int
3486static __iw_softap_ap_stats(struct net_device *dev,
3487 struct iw_request_info *info,
3488 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003489{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303490 hdd_adapter_t *pHostapdAdapter;
3491 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 WLANTL_TRANSFER_STA_TYPE statBuffer;
3493 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303494 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003495
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303496 ENTER();
3497
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303498 pHostapdAdapter = (netdev_priv(dev));
3499 if (NULL == pHostapdAdapter)
3500 {
3501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3502 "%s: Adapter is NULL",__func__);
3503 return -EINVAL;
3504 }
3505 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3506 ret = wlan_hdd_validate_context(pHddCtx);
3507 if (0 != ret)
3508 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303509 return ret;
3510 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003511 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003512 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3513 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003514
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303515 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003516 if(NULL == pstatbuf) {
3517 hddLog(LOG1, "unable to allocate memory");
3518 return -ENOMEM;
3519 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303520
3521 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003522 "RUF=%d RMF=%d RBF=%d "
3523 "RUB=%d RMB=%d RBB=%d "
3524 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303525 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003526 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3527 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3528 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3529 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3530 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3531 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003532
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303533 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003534 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3535 kfree(pstatbuf);
3536 return -EFAULT;
3537 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303538
3539 strlcpy(extra, pstatbuf, len);
3540 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003541 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303542
3543 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 return 0;
3545}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303546int
3547static __iw_softap_ap_get_stats(struct net_device *dev,
3548 struct iw_request_info *info,
3549 union iwreq_data *wrqu, char *extra)
3550{
3551 hdd_adapter_t *pAdapter;
3552 hdd_tx_rx_stats_t *pStats;
3553
3554 ENTER();
3555 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3556 if (NULL == pAdapter)
3557 {
3558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3559 "%s: Adapter is NULL",__func__);
3560 return -EINVAL;
3561 }
3562
3563 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3564 snprintf(extra, QCSAP_MAX_STR_LEN,
3565 "\nTransmit"
3566 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3567 "\n dropped BK %u, BE %u, VI %u, VO %u"
3568 "\n classified BK %u, BE %u, VI %u, VO %u"
3569 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3570 "\n queued BK %u, BE %u, VI %u, VO %u"
3571 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3572 "\ndequeued %u, depressured %u, deque-depressured %u,\
3573 completed %u, flushed %u"
3574 "\n fetched BK %u, BE %u, VI %u, VO %u"
3575 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3576 "\n depressured BK %u, BE %u, VI %u, VO %u"
3577 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3578 "\n flushed BK %u, BE %u, VI %u, VO %u"
3579 "\n\nReceive"
3580 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3581 "\n\nResetsStats"
3582 "\n",
3583 pStats->txXmitCalled,
3584 pStats->txXmitDropped,
3585 pStats->txXmitBackPressured,
3586 pStats->txXmitQueued,
3587
3588 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3589 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3590 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3591 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3592
3593 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3594 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3595 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3596 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3597
3598 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3599 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3600 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3601 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3602
3603 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3604 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3605 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3606 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3607
3608 pStats->txFetched,
3609 pStats->txFetchEmpty,
3610 pStats->txFetchLowResources,
3611 pStats->txFetchDequeueError,
3612
3613 pStats->txFetchDequeued,
3614 pStats->txFetchDePressured,
3615 pStats->txDequeDePressured,
3616 pStats->txCompleted,
3617 pStats->txFlushed,
3618
3619 pStats->txFetchedAC[WLANTL_AC_BK],
3620 pStats->txFetchedAC[WLANTL_AC_BE],
3621 pStats->txFetchedAC[WLANTL_AC_VI],
3622 pStats->txFetchedAC[WLANTL_AC_VO],
3623
3624 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3625 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3626 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3627 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3628
3629 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3630 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3631 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3632 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3633
3634 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3635 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3636 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3637 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3638
3639 pStats->txFlushedAC[WLANTL_AC_BK],
3640 pStats->txFlushedAC[WLANTL_AC_BE],
3641 pStats->txFlushedAC[WLANTL_AC_VI],
3642 pStats->txFlushedAC[WLANTL_AC_VO],
3643
3644 pStats->rxChains,
3645 pStats->rxPackets,
3646 pStats->rxDropped,
3647 pStats->rxDelivered,
3648 pStats->rxRefused
3649 );
3650
3651 wrqu->data.length = strlen(extra) + 1;
3652
3653 return 0;
3654}
3655
3656int
3657static __iw_softap_ap_clear_stats(struct net_device *dev,
3658 struct iw_request_info *info,
3659 union iwreq_data *wrqu, char *extra)
3660{
3661 hdd_adapter_t *pAdapter;
3662
3663 ENTER();
3664
3665 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3666 if (NULL == pAdapter)
3667 {
3668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3669 "%s: Adapter is NULL",__func__);
3670 return -EINVAL;
3671 }
3672
3673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3674 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3675 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3676 return 0;
3677}
3678
3679
3680int
3681static iw_softap_get_stats(struct net_device *dev,
3682 struct iw_request_info *info,
3683 union iwreq_data *wrqu, char *extra)
3684{
3685 int ret;
3686 vos_ssr_protect(__func__);
3687 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3688 vos_ssr_unprotect(__func__);
3689 return ret;
3690}
3691
3692int
3693static iw_softap_clear_stats(struct net_device *dev,
3694 struct iw_request_info *info,
3695 union iwreq_data *wrqu, char *extra)
3696{
3697 int ret;
3698 vos_ssr_protect(__func__);
3699 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3700 vos_ssr_unprotect(__func__);
3701 return ret;
3702}
Jeff Johnson295189b2012-06-20 16:38:30 -07003703
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303704int
3705static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 struct iw_request_info *info,
3707 union iwreq_data *wrqu, char *extra)
3708{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303709 int ret;
3710
3711 vos_ssr_protect(__func__);
3712 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3713 vos_ssr_unprotect(__func__);
3714
3715 return ret;
3716}
3717
Manjeet Singh3ed79242017-01-11 19:04:32 +05303718/**
3719 * __iw_softap_get_three() - return three value to upper layer.
3720 *
3721 * @dev: pointer of net_device of this wireless card
3722 * @info: meta data about Request sent
3723 * @wrqu: include request info
3724 * @extra: buf used for in/out
3725 *
3726 * Return: execute result
3727 */
3728static int __iw_softap_get_three(struct net_device *dev,
3729 struct iw_request_info *info,
3730 union iwreq_data *wrqu, char *extra)
3731{
3732 uint32_t *value = (uint32_t *)extra;
3733 uint32_t sub_cmd = value[0];
3734 int ret = 0; /* success */
3735
3736 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3737
3738 switch (sub_cmd) {
3739 case QCSAP_IOCTL_GET_TSF:
3740 ret = hdd_indicate_tsf(padapter, value, 3);
3741 break;
3742 default:
3743 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3744 break;
3745 }
3746 return ret;
3747}
3748
3749
3750/**
3751 * iw_softap_get_three() - return three value to upper layer.
3752 *
3753 * @dev: pointer of net_device of this wireless card
3754 * @info: meta data about Request sent
3755 * @wrqu: include request info
3756 * @extra: buf used for in/Output
3757 *
3758 * Return: execute result
3759 */
3760static int iw_softap_get_three(struct net_device *dev,
3761 struct iw_request_info *info,
3762 union iwreq_data *wrqu, char *extra)
3763{
3764 int ret;
3765
3766 vos_ssr_protect(__func__);
3767 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3768 vos_ssr_unprotect(__func__);
3769
3770 return ret;
3771}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303772static int __iw_softap_set_channel_range(struct net_device *dev,
3773 struct iw_request_info *info,
3774 union iwreq_data *wrqu, char *extra)
3775{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303776 hdd_adapter_t *pHostapdAdapter;
3777 tHalHandle hHal;
3778 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 int *value = (int *)extra;
3780 int startChannel = value[0];
3781 int endChannel = value[1];
3782 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003783 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 int ret = 0; /* success */
3785
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303786 ENTER();
3787
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303788 if (!capable(CAP_NET_ADMIN))
3789 {
3790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3791 FL("permission check failed"));
3792 return -EPERM;
3793 }
3794
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303795 pHostapdAdapter = (netdev_priv(dev));
3796 if (NULL == pHostapdAdapter)
3797 {
3798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3799 "%s: Adapter is NULL",__func__);
3800 return -EINVAL;
3801 }
3802 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3803 ret = wlan_hdd_validate_context(pHddCtx);
3804 if (0 != ret)
3805 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303806 return ret;
3807 }
3808 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3809 if (NULL == hHal)
3810 {
3811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3812 "%s: Hal Context is NULL",__func__);
3813 return -EINVAL;
3814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3816 if(status != VOS_STATUS_SUCCESS)
3817 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003818 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 startChannel,endChannel, band);
3820 ret = -EINVAL;
3821 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003822
3823 pHddCtx->is_dynamic_channel_range_set = 1;
3824
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303825 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 return ret;
3827}
3828
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303829static int iw_softap_set_channel_range(struct net_device *dev,
3830 struct iw_request_info *info,
3831 union iwreq_data *wrqu, char *extra)
3832{
3833 int ret;
3834
3835 vos_ssr_protect(__func__);
3836 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3837 vos_ssr_unprotect(__func__);
3838
3839 return ret;
3840}
3841
3842
3843int __iw_softap_get_channel_list(struct net_device *dev,
3844 struct iw_request_info *info,
3845 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003846{
3847 v_U32_t num_channels = 0;
3848 v_U8_t i = 0;
3849 v_U8_t bandStartChannel = RF_CHAN_1;
3850 v_U8_t bandEndChannel = RF_CHAN_165;
3851 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303852 hdd_adapter_t *pHostapdAdapter;
3853 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003856 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303857 hdd_context_t *pHddCtx;
3858 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303859
3860 ENTER();
3861
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303862 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3863 if (NULL == pHostapdAdapter)
3864 {
3865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3866 "%s: Adapter is NULL",__func__);
3867 return -EINVAL;
3868 }
3869 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3870 ret = wlan_hdd_validate_context(pHddCtx);
3871 if (0 != ret)
3872 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303873 return ret;
3874 }
3875 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3876 if (NULL == hHal)
3877 {
3878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3879 "%s: Hal Context is NULL",__func__);
3880 return -EINVAL;
3881 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003882 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
3883 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003884 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003885 return -EIO;
3886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 wrqu->data.length = sizeof(tChannelListInfo);
3888 ENTER();
3889
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003890 if (eCSR_BAND_24 == curBand)
3891 {
3892 bandStartChannel = RF_CHAN_1;
3893 bandEndChannel = RF_CHAN_14;
3894 }
3895 else if (eCSR_BAND_5G == curBand)
3896 {
3897 bandStartChannel = RF_CHAN_36;
3898 bandEndChannel = RF_CHAN_165;
3899 }
3900
Arif Hussain6d2a3322013-11-17 19:50:10 -08003901 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05303902 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003903 bandStartChannel, bandEndChannel );
3904
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 for( i = bandStartChannel; i <= bandEndChannel; i++ )
3906 {
3907 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
3908 {
3909 channel_list->channels[num_channels] = rfChannels[i].channelNum;
3910 num_channels++;
3911 }
3912 }
3913
3914 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
3915
3916 temp_num_channels = num_channels;
3917
3918 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
3919 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303920 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08003921 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 }
3923
Agarwal Ashish7b557c02014-07-02 12:32:39 +05303924 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
3925 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 {
3927 for(i = 0; i < temp_num_channels; i++)
3928 {
3929
3930 if((channel_list->channels[i] > 35) &&
3931 (channel_list->channels[i] < 49))
3932 {
3933 vos_mem_move(&channel_list->channels[i],
3934 &channel_list->channels[i+1],
3935 temp_num_channels - (i-1));
3936 num_channels--;
3937 temp_num_channels--;
3938 i--;
3939 }
3940 }
3941 }
3942
Arif Hussain6d2a3322013-11-17 19:50:10 -08003943 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07003944
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 channel_list->num_channels = num_channels;
3946 EXIT();
3947
3948 return 0;
3949}
3950
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303951int iw_softap_get_channel_list(struct net_device *dev,
3952 struct iw_request_info *info,
3953 union iwreq_data *wrqu, char *extra)
3954{
3955 int ret;
3956
3957 vos_ssr_protect(__func__);
3958 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
3959 vos_ssr_unprotect(__func__);
3960
3961 return ret;
3962}
3963
3964static
3965int __iw_get_genie(struct net_device *dev,
3966 struct iw_request_info *info,
3967 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003968{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303969 hdd_adapter_t *pHostapdAdapter;
3970 hdd_context_t *pHddCtx;
3971 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05303972 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
3974 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303975 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303976
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303978
3979 pHostapdAdapter = (netdev_priv(dev));
3980 if (NULL == pHostapdAdapter)
3981 {
3982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3983 "%s: Adapter is NULL",__func__);
3984 return -EINVAL;
3985 }
3986 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3987 ret = wlan_hdd_validate_context(pHddCtx);
3988 if (0 != ret)
3989 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303990 return ret;
3991 }
3992 pVosContext = pHddCtx->pvosContext;
3993 if (NULL == pVosContext)
3994 {
3995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3996 "%s: vos context is not valid ",__func__);
3997 return -EINVAL;
3998 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08003999 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
4001 status = WLANSap_getstationIE_information(pVosContext,
4002 &length,
4003 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05304004
4005 if (VOS_STATUS_SUCCESS != status) {
4006 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07004007 return -EFAULT;
4008 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05304009
Arif Hussained667642013-10-27 23:01:14 -07004010 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304011 if (length > DOT11F_IE_RSN_MAX_LEN) {
4012 hddLog(LOGE,
4013 FL("invalid buffer length length:%d"), length);
4014 return -E2BIG;
4015 }
4016
4017 vos_mem_copy(extra, genIeBytes, length);
4018
4019 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
4020
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 EXIT();
4022 return 0;
4023}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304024
4025static
4026int iw_get_genie(struct net_device *dev,
4027 struct iw_request_info *info,
4028 union iwreq_data *wrqu, char *extra)
4029{
4030 int ret;
4031
4032 vos_ssr_protect(__func__);
4033 ret = __iw_get_genie(dev, info, wrqu, extra);
4034 vos_ssr_unprotect(__func__);
4035
4036 return ret;
4037}
4038
4039static
4040int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4041 struct iw_request_info *info,
4042 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004043{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304044 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07004045 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304046 hdd_ap_ctx_t *pHddApCtx;
4047 hdd_context_t *pHddCtx;
4048 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304049
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07004051
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304052 pHostapdAdapter = (netdev_priv(dev));
4053 if (NULL == pHostapdAdapter)
4054 {
4055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4056 "%s: Adapter is NULL",__func__);
4057 return -EINVAL;
4058 }
4059 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4060 ret = wlan_hdd_validate_context(pHddCtx);
4061 if (0 != ret)
4062 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304063 return ret;
4064 }
4065 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4066 if (NULL == pHddApCtx)
4067 {
4068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4069 "%s: AP context is NULL",__func__);
4070 return -EINVAL;
4071 }
4072
Arif Hussain6d2a3322013-11-17 19:50:10 -08004073 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07004074 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
4075
4076 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
4077 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
4078 pHddApCtx->WPSPBCProbeReq.probeReqIE,
4079 WPSPBCProbeReqIEs.probeReqIELen);
4080 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
4081 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
4082 sizeof(v_MACADDR_t));
4083 if (copy_to_user(wrqu->data.pointer,
4084 (void *)&WPSPBCProbeReqIEs,
4085 sizeof(WPSPBCProbeReqIEs)))
4086 {
4087 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4088 return -EFAULT;
4089 }
4090 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004091 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07004092 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 up(&pHddApCtx->semWpsPBCOverlapInd);
4094 EXIT();
4095 return 0;
4096}
4097
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304098static
4099int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4100 struct iw_request_info *info,
4101 union iwreq_data *wrqu, char *extra)
4102{
4103 int ret;
4104
4105 vos_ssr_protect(__func__);
4106 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
4107 vos_ssr_unprotect(__func__);
4108
4109 return ret;
4110}
4111
Jeff Johnson295189b2012-06-20 16:38:30 -07004112/**---------------------------------------------------------------------------
4113
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304114 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 This function sets the auth type received from the wpa_supplicant.
4116
4117 \param - dev - Pointer to the net device.
4118 - info - Pointer to the iw_request_info.
4119 - wrqu - Pointer to the iwreq_data.
4120 - extra - Pointer to the data.
4121 \return - 0 for success, non zero for failure
4122
4123 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304124int __iw_set_auth_hostap(struct net_device *dev,
4125 struct iw_request_info *info,
4126 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004127{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304128 hdd_adapter_t *pAdapter;
4129 hdd_context_t *pHddCtx;
4130 hdd_wext_state_t *pWextState;
4131 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304132
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304134
4135 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4136 if (NULL == pAdapter)
4137 {
4138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4139 "%s: Adapter is NULL",__func__);
4140 return -EINVAL;
4141 }
4142
4143 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4144 ret = wlan_hdd_validate_context(pHddCtx);
4145 if (0 != ret)
4146 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304147 return ret;
4148 }
4149 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4150 if (NULL == pWextState)
4151 {
4152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4153 "%s: pWextState is NULL",__func__);
4154 return -EINVAL;
4155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 switch(wrqu->param.flags & IW_AUTH_INDEX)
4157 {
4158 case IW_AUTH_TKIP_COUNTERMEASURES:
4159 {
4160 if(wrqu->param.value) {
4161 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4162 "Counter Measure started %d", wrqu->param.value);
4163 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304164 }
4165 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4167 "Counter Measure stopped=%d", wrqu->param.value);
4168 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4169 }
4170
4171 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
4172 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304175
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304177
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004178 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 wrqu->param.flags & IW_AUTH_INDEX);
4180 break;
4181 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304182
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 EXIT();
4184 return 0;
4185}
4186
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304187int iw_set_auth_hostap(struct net_device *dev,
4188 struct iw_request_info *info,
4189 union iwreq_data *wrqu,char *extra)
4190{
4191 int ret;
4192
4193 vos_ssr_protect(__func__);
4194 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
4195 vos_ssr_unprotect(__func__);
4196
4197 return ret;
4198}
4199
4200static int __iw_set_ap_encodeext(struct net_device *dev,
4201 struct iw_request_info *info,
4202 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004203{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304204 hdd_adapter_t *pHostapdAdapter;
4205 v_CONTEXT_t pVosContext;
4206 hdd_context_t *pHddCtx;
4207 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07004208 int retval = 0;
4209 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4211 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4212 int key_index;
4213 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304214 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07004215// tCsrRoamRemoveKey RemoveKey;
4216 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304217
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304218 ENTER();
4219 pHostapdAdapter = (netdev_priv(dev));
4220 if (NULL == pHostapdAdapter)
4221 {
4222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4223 "%s: Adapter is NULL",__func__);
4224 return -EINVAL;
4225 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004226
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304227 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4228 retval = wlan_hdd_validate_context(pHddCtx);
4229 if (0 != retval)
4230 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304231 return retval;
4232 }
4233 pVosContext = pHddCtx->pvosContext;
4234 if (NULL == pVosContext)
4235 {
4236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4237 "%s: pVosContext is NULL",__func__);
4238 return -EINVAL;
4239 }
4240 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4241 if (NULL == pHddApCtx)
4242 {
4243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4244 "%s: AP Context is NULL",__func__);
4245 return -EINVAL;
4246 }
4247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304249
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304251
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 /*Convert from 1-based to 0-based keying*/
4253 key_index--;
4254 }
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304255 if(!ext->key_len || ext->key_len > CSR_MAX_KEY_LEN) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304256#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 /*Set the encrytion type to NONE*/
4258#if 0
4259 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4260#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304261
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 RemoveKey.keyId = key_index;
4263 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4264 /*Key direction for group is RX only*/
4265 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4266 }
4267 else {
4268 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4269 }
4270 switch(ext->alg)
4271 {
4272 case IW_ENCODE_ALG_NONE:
4273 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4274 break;
4275 case IW_ENCODE_ALG_WEP:
4276 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4277 break;
4278 case IW_ENCODE_ALG_TKIP:
4279 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07004280 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 case IW_ENCODE_ALG_CCMP:
4282 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
4283 break;
4284 default:
4285 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4286 break;
4287 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004288 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 -07004289 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004291 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 );
Jeff Johnson43971f52012-07-17 12:26:56 -07004293 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
4294 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 {
4296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07004297 __LINE__, vstatus );
4298 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004300#endif
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304301 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004302
Jeff Johnson43971f52012-07-17 12:26:56 -07004303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004304
4305 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4306
4307 setKey.keyId = key_index;
4308 setKey.keyLength = ext->key_len;
4309
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304310 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311
4312 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4313 /*Key direction for group is RX only*/
4314 setKey.keyDirection = eSIR_RX_ONLY;
4315 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4316 }
4317 else {
4318
4319 setKey.keyDirection = eSIR_TX_RX;
4320 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4321 }
4322 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4323 {
4324 setKey.keyDirection = eSIR_TX_DEFAULT;
4325 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4326 }
4327
4328 /*For supplicant pae role is zero*/
4329 setKey.paeRole = 0;
4330
4331 switch(ext->alg)
4332 {
4333 case IW_ENCODE_ALG_NONE:
4334 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4335 break;
4336
4337 case IW_ENCODE_ALG_WEP:
4338 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4339 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004340 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 break;
4342
4343 case IW_ENCODE_ALG_TKIP:
4344 {
4345 v_U8_t *pKey = &setKey.Key[0];
4346
4347 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4348
4349 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4350
4351 /*Supplicant sends the 32bytes key in this order
4352
4353 |--------------|----------|----------|
4354 | Tk1 |TX-MIC | RX Mic |
4355 |--------------|----------|----------|
4356 <---16bytes---><--8bytes--><--8bytes-->
4357
4358 */
4359 /*Sme expects the 32 bytes key to be in the below order
4360
4361 |--------------|----------|----------|
4362 | Tk1 |RX-MIC | TX Mic |
4363 |--------------|----------|----------|
4364 <---16bytes---><--8bytes--><--8bytes-->
4365 */
4366 /* Copy the Temporal Key 1 (TK1) */
4367 vos_mem_copy(pKey,ext->key,16);
4368
4369 /*Copy the rx mic first*/
4370 vos_mem_copy(&pKey[16],&ext->key[24],8);
4371
4372 /*Copy the tx mic */
4373 vos_mem_copy(&pKey[24],&ext->key[16],8);
4374
4375 }
4376 break;
4377
4378 case IW_ENCODE_ALG_CCMP:
4379 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4380 break;
4381
4382 default:
4383 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4384 break;
4385 }
4386
4387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304388 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 setKey.keyId);
4390 for(i=0; i< ext->key_len; i++)
4391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4392 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07004393
4394 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
4395 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 {
4397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07004398 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
4399 retval = -EINVAL;
4400 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304401
4402 EXIT();
4403 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004404}
Jeff Johnson43971f52012-07-17 12:26:56 -07004405
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304406static int iw_set_ap_encodeext(struct net_device *dev,
4407 struct iw_request_info *info,
4408 union iwreq_data *wrqu, char *extra)
4409{
4410 int ret;
4411
4412 vos_ssr_protect(__func__);
4413 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
4414 vos_ssr_unprotect(__func__);
4415
4416 return ret;
4417}
Jeff Johnson43971f52012-07-17 12:26:56 -07004418
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304419static int __iw_set_ap_mlme(struct net_device *dev,
4420 struct iw_request_info *info,
4421 union iwreq_data *wrqu,
4422 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004423{
4424#if 0
4425 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4426 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4427
4428 ENTER();
4429
4430 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4431 switch (mlme->cmd) {
4432 case IW_MLME_DISASSOC:
4433 case IW_MLME_DEAUTH:
4434 hddLog(LOG1, "Station disassociate");
4435 if( pAdapter->conn_info.connState == eConnectionState_Associated )
4436 {
4437 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4438
4439 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4440 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4441
4442 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
4443
4444 //clear all the reason codes
4445 if (status != 0)
4446 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004447 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 }
4449
4450 netif_stop_queue(dev);
4451 netif_carrier_off(dev);
4452 }
4453 else
4454 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004455 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 -07004456 }
4457 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004458 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 return -EINVAL;
4460 }//end of switch
4461 EXIT();
4462#endif
4463 return 0;
4464// return status;
4465}
4466
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304467static int iw_set_ap_mlme(struct net_device *dev,
4468 struct iw_request_info *info,
4469 union iwreq_data *wrqu,
4470 char *extra)
4471{
4472 int ret;
4473
4474 vos_ssr_protect(__func__);
4475 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4476 vos_ssr_unprotect(__func__);
4477
4478 return ret;
4479}
4480
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304481static int __iw_get_ap_rts_threshold(struct net_device *dev,
4482 struct iw_request_info *info,
4483 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004484{
4485 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4486 v_U32_t status = 0;
4487
4488 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4489
4490 return status;
4491}
4492
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304493static int iw_get_ap_rts_threshold(struct net_device *dev,
4494 struct iw_request_info *info,
4495 union iwreq_data *wrqu, char *extra)
4496{
4497 int ret;
4498
4499 vos_ssr_protect(__func__);
4500 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4501 vos_ssr_unprotect(__func__);
4502
4503 return ret;
4504}
4505
4506static int __iw_get_ap_frag_threshold(struct net_device *dev,
4507 struct iw_request_info *info,
4508 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004509{
4510 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4511 v_U32_t status = 0;
4512
4513 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4514
4515 return status;
4516}
4517
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304518static int iw_get_ap_frag_threshold(struct net_device *dev,
4519 struct iw_request_info *info,
4520 union iwreq_data *wrqu, char *extra)
4521{
4522 int ret;
4523
4524 vos_ssr_protect(__func__);
4525 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4526 vos_ssr_unprotect(__func__);
4527
4528 return ret;
4529}
4530
4531static int __iw_get_ap_freq(struct net_device *dev,
4532 struct iw_request_info *info,
4533 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004534{
Jeff Johnsone7245742012-09-05 17:12:55 -07004535 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304536 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 tHalHandle hHal;
4538 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304539 hdd_ap_ctx_t *pHddApCtx;
4540 hdd_context_t *pHddCtx;
4541 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004542
4543 ENTER();
4544
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304545 pHostapdAdapter = (netdev_priv(dev));
4546 if (NULL == pHostapdAdapter)
4547 {
4548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4549 "%s: Adapter is NULL",__func__);
4550 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304552 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4553 ret = wlan_hdd_validate_context(pHddCtx);
4554 if (0 != ret)
4555 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304556 return ret;
4557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304559 if (NULL == pHostapdState)
4560 {
4561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4562 "%s: pHostapdState is NULL",__func__);
4563 return -EINVAL;
4564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304566 if (NULL == hHal)
4567 {
4568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4569 "%s: Hal Context is NULL",__func__);
4570 return -EINVAL;
4571 }
4572 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4573 if (NULL == pHddApCtx)
4574 {
4575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4576 "%s: AP context is NULL",__func__);
4577 return -EINVAL;
4578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 if(pHostapdState->bssState == BSS_STOP )
4580 {
4581 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4582 != eHAL_STATUS_SUCCESS)
4583 {
c_hpothuffdb5272013-10-02 16:42:35 +05304584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4585 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 return -EIO;
4587 }
4588 else
4589 {
4590 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304591 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004592 {
4593 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4594 * iwlist & iwconfig command shows frequency into proper
4595 * format (2.412 GHz instead of 246.2 MHz)*/
4596 fwrq->m = freq;
4597 fwrq->e = MHZ;
4598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 }
4600 }
4601 else
4602 {
4603 channel = pHddApCtx->operatingChannel;
4604 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304605 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004606 {
4607 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4608 * iwlist & iwconfig command shows frequency into proper
4609 * format (2.412 GHz instead of 246.2 MHz)*/
4610 fwrq->m = freq;
4611 fwrq->e = MHZ;
4612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304614
4615 EXIT();
4616 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004617}
4618
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304619static int iw_get_ap_freq(struct net_device *dev,
4620 struct iw_request_info *info,
4621 struct iw_freq *fwrq, char *extra)
4622{
4623 int ret;
4624
4625 vos_ssr_protect(__func__);
4626 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4627 vos_ssr_unprotect(__func__);
4628
4629 return ret;
4630}
4631
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304632static int __iw_softap_stopbss(struct net_device *dev,
4633 struct iw_request_info *info,
4634 union iwreq_data *wrqu,
4635 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004636{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304639 hdd_context_t *pHddCtx = NULL;
4640
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304642 pHostapdAdapter = (netdev_priv(dev));
4643 if (NULL == pHostapdAdapter)
4644 {
4645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4646 "%s: Adapter is NULL",__func__);
4647 return -EINVAL;
4648 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304649 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4650 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304651 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304652 return status;
4653 }
4654
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304655 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +05304657 hdd_hostapd_state_t *pHostapdState =
4658 WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4659
4660 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4662 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304664
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304666 {
4667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004668 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 VOS_ASSERT(0);
4670 }
4671 }
4672 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304673 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 }
4675 EXIT();
4676 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4677}
4678
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304679static int iw_softap_stopbss(struct net_device *dev,
4680 struct iw_request_info *info,
4681 union iwreq_data *wrqu,
4682 char *extra)
4683{
4684 int ret;
4685
4686 vos_ssr_protect(__func__);
4687 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4688 vos_ssr_unprotect(__func__);
4689
4690 return ret;
4691}
4692
4693static int __iw_softap_version(struct net_device *dev,
4694 struct iw_request_info *info,
4695 union iwreq_data *wrqu,
4696 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004697{
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304699 hdd_context_t *pHddCtx;
4700 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304701
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304703 pHostapdAdapter = (netdev_priv(dev));
4704 if (NULL == pHostapdAdapter)
4705 {
4706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4707 "%s: Adapter is NULL",__func__);
4708 return -EINVAL;
4709 }
4710 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4711 ret = wlan_hdd_validate_context(pHddCtx);
4712 if (0 != ret)
4713 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304714 return ret;
4715 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004716 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 return 0;
4719}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004720
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304721static int iw_softap_version(struct net_device *dev,
4722 struct iw_request_info *info,
4723 union iwreq_data *wrqu,
4724 char *extra)
4725{
4726 int ret;
4727
4728 vos_ssr_protect(__func__);
4729 ret = __iw_softap_version(dev, info, wrqu, extra);
4730 vos_ssr_unprotect(__func__);
4731
4732 return ret;
4733}
4734
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304735int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004736{
4737 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004738 int len = 0;
4739 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304740 v_CONTEXT_t pVosContext;
4741 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304742 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304743
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304744 ENTER();
4745
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304746 if (NULL == pAdapter)
4747 {
4748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4749 "%s: Adapter is NULL",__func__);
4750 return -EINVAL;
4751 }
4752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4753 if (0 != wlan_hdd_validate_context(pHddCtx))
4754 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304755 return VOS_STATUS_E_FAULT;
4756 }
4757 pVosContext = pHddCtx->pvosContext;
4758 if (NULL == pVosContext)
4759 {
4760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4761 "%s: VOS context is not valid",__func__);
4762 return VOS_STATUS_E_FAULT;
4763 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304764 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304765 if(pSapCtx == NULL)
4766 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304767 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4768 FL("psapCtx is NULL"));
4769 return VOS_STATUS_E_FAULT;
4770 }
4771
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304772 len = snprintf(pBuf, buf_len, sta_info_header);
4773 if (len >= buf_len) {
4774 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4775 return -E2BIG;
4776 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004777 pBuf += len;
4778 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004779
4780 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4781 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304782 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004783 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004784 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304785 pSapCtx->aStaInfo[i].ucSTAId,
4786 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4787 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4788 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4789 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4790 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4791 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304792 if (len >= buf_len) {
4793 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4794 return -E2BIG;
4795 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004796 pBuf += len;
4797 buf_len -= len;
4798 }
4799 if(WE_GET_STA_INFO_SIZE > buf_len)
4800 {
4801 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004802 }
4803 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304804 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304805 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004806}
4807
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304808static int __iw_softap_get_sta_info(struct net_device *dev,
4809 struct iw_request_info *info,
4810 union iwreq_data *wrqu,
4811 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004812{
4813 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304814 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004815 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304816 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4817 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004818 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304819 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004820 }
4821 wrqu->data.length = strlen(extra);
4822 EXIT();
4823 return 0;
4824}
4825
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304826static int iw_softap_get_sta_info(struct net_device *dev,
4827 struct iw_request_info *info,
4828 union iwreq_data *wrqu,
4829 char *extra)
4830{
4831 int ret;
4832
4833 vos_ssr_protect(__func__);
4834 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4835 vos_ssr_unprotect(__func__);
4836
4837 return ret;
4838}
4839
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304840static int __iw_set_ap_genie(struct net_device *dev,
4841 struct iw_request_info *info,
4842 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004843{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304844
4845 hdd_adapter_t *pHostapdAdapter;
4846 hdd_context_t *pHddCtx;
4847 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004849 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304850 int ret = 0;
4851
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304853 pHostapdAdapter = (netdev_priv(dev));
4854 if (NULL == pHostapdAdapter)
4855 {
4856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4857 "%s: Adapter is NULL",__func__);
4858 return -EINVAL;
4859 }
4860 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4861 ret = wlan_hdd_validate_context(pHddCtx);
4862 if (0 != ret)
4863 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304864 return ret;
4865 }
4866 pVosContext = pHddCtx->pvosContext;
4867 if (NULL == pVosContext)
4868 {
4869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4870 "%s: VOS Context is NULL",__func__);
4871 return -EINVAL;
4872 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 if(!wrqu->data.length)
4874 {
4875 EXIT();
4876 return 0;
4877 }
Arif Hussained667642013-10-27 23:01:14 -07004878
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05304879 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
4880 {
4881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4882 "%s: WPARSN Ie input length is more than max[%d]", __func__,
4883 wrqu->data.length);
4884 return -EINVAL;
4885 }
4886
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304887 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304889 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 case DOT11F_EID_RSN:
4891 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
4892 {
4893 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
4894 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07004897 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304899
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004901 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 halStatus = 0;
4903 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304904
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304906 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004907}
4908
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304909static int iw_set_ap_genie(struct net_device *dev,
4910 struct iw_request_info *info,
4911 union iwreq_data *wrqu, char *extra)
4912{
4913 int ret;
4914
4915 vos_ssr_protect(__func__);
4916 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
4917 vos_ssr_unprotect(__func__);
4918
4919 return ret;
4920}
4921
Jeff Johnson295189b2012-06-20 16:38:30 -07004922static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
4923{
4924 eHalStatus hstatus;
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304925 int ret;
4926 void *cookie;
4927 struct hdd_request *request;
4928 struct stats_class_a_ctx *priv;
4929 static const struct hdd_request_params params = {
4930 .priv_size = sizeof(*priv),
4931 .timeout_ms = WLAN_WAIT_TIME_STATS,
4932 };
4933
Jeff Johnson295189b2012-06-20 16:38:30 -07004934
4935 if (NULL == pAdapter)
4936 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304937 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 return VOS_STATUS_E_FAULT;
4939 }
4940
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304941 request = hdd_request_alloc(&params);
4942 if (!request) {
4943 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
4944 return VOS_STATUS_E_NOMEM;
4945 }
4946 cookie = hdd_request_cookie(request);
4947
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
4949 eCSR_HDD,
4950 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304951 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 0, // not periodic
4953 FALSE, //non-cached results
4954 staid,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304955 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 if (eHAL_STATUS_SUCCESS != hstatus)
4957 {
4958 hddLog(VOS_TRACE_LEVEL_ERROR,
4959 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004960 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 }
4962 else
4963 {
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304964 ret = hdd_request_wait_for_response(request);
4965 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 {
4967 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304968 FL("SME timeout while retrieving link speed"));
4969 }
4970 else
4971 {
4972 priv = hdd_request_priv(request);
4973 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 }
4975 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004976
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05304977 /*
4978 * either we never sent a request, we sent a request and received a
4979 * response or we sent a request and timed out. Regardless we are
4980 * done with the request.
4981 */
4982 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08004983
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 return VOS_STATUS_SUCCESS;
4985}
4986
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304987int __iw_get_softap_linkspeed(struct net_device *dev,
4988 struct iw_request_info *info,
4989 union iwreq_data *wrqu,
4990 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004991
4992{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304993 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304994 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07004996 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304997 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05304999 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08005001 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305002 int rc, valid;
5003
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305004 ENTER();
5005
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305006 pHostapdAdapter = (netdev_priv(dev));
5007 if (NULL == pHostapdAdapter)
5008 {
5009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5010 "%s: Adapter is NULL",__func__);
5011 return -EINVAL;
5012 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305013 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305014 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305015 if (0 != valid)
5016 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305017 return valid;
5018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005019
Arif Hussain6d2a3322013-11-17 19:50:10 -08005020 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08005021
5022 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07005023 {
Arif Hussaina9571842014-01-15 16:43:41 -08005024 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
5025 if (NULL == pmacAddress) {
5026 hddLog(LOG1, "unable to allocate memory");
5027 return -ENOMEM;
5028 }
5029 if (copy_from_user((void *)pmacAddress,
5030 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
5031 {
5032 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
5033 kfree(pmacAddress);
5034 return -EFAULT;
5035 }
Manjeet Singha3739742016-05-03 16:21:46 +05305036 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08005037
5038 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07005039 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08005040
5041 if (!VOS_IS_STATUS_SUCCESS(status ))
5042 {
5043 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
5044 }
Arif Hussained667642013-10-27 23:01:14 -07005045 }
Kiet Lam61589852013-09-19 17:10:58 +05305046 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305047 * link speed for first connected client will be returned.
5048 */
Arif Hussaina9571842014-01-15 16:43:41 -08005049 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305050 {
5051 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
5052 }
5053 else
5054 {
5055 status = hdd_softap_GetStaId(pHostapdAdapter,
5056 (v_MACADDR_t *)macAddress, (void *)(&staId));
5057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005058
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305059 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305061 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 link_speed = 0;
5063 }
5064 else
5065 {
5066 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305067
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 if (!VOS_IS_STATUS_SUCCESS(status ))
5069 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 return -EINVAL;
5072 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305073
5074 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
5075 staId, &link_speed);
5076
5077 link_speed = link_speed / 10;
5078
5079 if (0 == link_speed)
5080 {
5081 /* The linkspeed returned by HAL is in units of 500kbps.
5082 * converting it to mbps.
5083 * This is required to support legacy firmware which does
5084 * not return link capacity.
5085 */
5086 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
5087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 }
5089
5090 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07005091 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305092
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 if ((rc < 0) || (rc >= len))
5094 {
5095 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305096 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 return -EIO;
5098 }
5099
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305100 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 return 0;
5102}
5103
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305104int iw_get_softap_linkspeed(struct net_device *dev,
5105 struct iw_request_info *info,
5106 union iwreq_data *wrqu,
5107 char *extra)
5108{
5109 int ret;
5110
5111 vos_ssr_protect(__func__);
5112 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
5113 vos_ssr_unprotect(__func__);
5114
5115 return ret;
5116}
5117
5118
Jeff Johnson295189b2012-06-20 16:38:30 -07005119static const iw_handler hostapd_handler[] =
5120{
5121 (iw_handler) NULL, /* SIOCSIWCOMMIT */
5122 (iw_handler) NULL, /* SIOCGIWNAME */
5123 (iw_handler) NULL, /* SIOCSIWNWID */
5124 (iw_handler) NULL, /* SIOCGIWNWID */
5125 (iw_handler) NULL, /* SIOCSIWFREQ */
5126 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
5127 (iw_handler) NULL, /* SIOCSIWMODE */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +05305128 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 (iw_handler) NULL, /* SIOCSIWSENS */
5130 (iw_handler) NULL, /* SIOCGIWSENS */
5131 (iw_handler) NULL, /* SIOCSIWRANGE */
5132 (iw_handler) NULL, /* SIOCGIWRANGE */
5133 (iw_handler) NULL, /* SIOCSIWPRIV */
5134 (iw_handler) NULL, /* SIOCGIWPRIV */
5135 (iw_handler) NULL, /* SIOCSIWSTATS */
5136 (iw_handler) NULL, /* SIOCGIWSTATS */
5137 (iw_handler) NULL, /* SIOCSIWSPY */
5138 (iw_handler) NULL, /* SIOCGIWSPY */
5139 (iw_handler) NULL, /* SIOCSIWTHRSPY */
5140 (iw_handler) NULL, /* SIOCGIWTHRSPY */
5141 (iw_handler) NULL, /* SIOCSIWAP */
5142 (iw_handler) NULL, /* SIOCGIWAP */
5143 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
5144 (iw_handler) NULL, /* SIOCGIWAPLIST */
5145 (iw_handler) NULL, /* SIOCSIWSCAN */
5146 (iw_handler) NULL, /* SIOCGIWSCAN */
5147 (iw_handler) NULL, /* SIOCSIWESSID */
5148 (iw_handler) NULL, /* SIOCGIWESSID */
5149 (iw_handler) NULL, /* SIOCSIWNICKN */
5150 (iw_handler) NULL, /* SIOCGIWNICKN */
5151 (iw_handler) NULL, /* -- hole -- */
5152 (iw_handler) NULL, /* -- hole -- */
5153 (iw_handler) NULL, /* SIOCSIWRATE */
5154 (iw_handler) NULL, /* SIOCGIWRATE */
5155 (iw_handler) NULL, /* SIOCSIWRTS */
5156 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
5157 (iw_handler) NULL, /* SIOCSIWFRAG */
5158 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
5159 (iw_handler) NULL, /* SIOCSIWTXPOW */
5160 (iw_handler) NULL, /* SIOCGIWTXPOW */
5161 (iw_handler) NULL, /* SIOCSIWRETRY */
5162 (iw_handler) NULL, /* SIOCGIWRETRY */
5163 (iw_handler) NULL, /* SIOCSIWENCODE */
5164 (iw_handler) NULL, /* SIOCGIWENCODE */
5165 (iw_handler) NULL, /* SIOCSIWPOWER */
5166 (iw_handler) NULL, /* SIOCGIWPOWER */
5167 (iw_handler) NULL, /* -- hole -- */
5168 (iw_handler) NULL, /* -- hole -- */
5169 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
5170 (iw_handler) NULL, /* SIOCGIWGENIE */
5171 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
5172 (iw_handler) NULL, /* SIOCGIWAUTH */
5173 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
5174 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
5175 (iw_handler) NULL, /* SIOCSIWPMKSA */
5176};
5177
Jeff Johnson224f3702014-03-26 11:09:47 -07005178/*
5179 * Note that the following ioctls were defined with semantics which
5180 * cannot be handled by the "iwpriv" userspace application and hence
5181 * they are not included in the hostapd_private_args array
5182 * QCSAP_IOCTL_ASSOC_STA_MACADDR
5183 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005184
5185static const struct iw_priv_args hostapd_private_args[] = {
5186 { QCSAP_IOCTL_SETPARAM,
5187 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
5188 { QCSAP_IOCTL_SETPARAM,
5189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05305190 { QCSAP_PARAM_GET_FRAME_LOGS,
5191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 { QCSAP_PARAM_MAX_ASSOC,
5193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
5194 { QCSAP_PARAM_HIDE_SSID,
5195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07005196 { QCSAP_PARAM_SET_MC_RATE,
5197 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05305198 { QCSAP_PARAM_SET_PROXIMITY,
5199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305200 { QCSAP_PARAM_CAP_TSF,
5201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Abhishek Singh02605092017-10-25 14:06:12 +05305202 {QCSAP_PARAM_SET_CHANNEL_CHANGE,
5203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"},
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305204 { QCSAP_PARAM_SET_WOWL,
5205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 { QCSAP_IOCTL_GETPARAM,
5207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
5209 { QCSAP_IOCTL_GETPARAM, 0,
5210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
5211 { QCSAP_PARAM_MAX_ASSOC, 0,
5212 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07005213 { QCSAP_PARAM_GET_WLAN_DBG, 0,
5214 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
5215 { QCSAP_PARAM_AUTO_CHANNEL, 0,
5216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05305217 { QCSAP_PARAM_SET_AUTO_CHANNEL,
5218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 { QCSAP_PARAM_CLR_ACL, 0,
5220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
5221 { QCSAP_PARAM_ACL_MODE,
5222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05305224 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 { QCSAP_IOCTL_STOPBSS,
5226 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
5227 { QCSAP_IOCTL_VERSION, 0,
5228 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005229 { QCSAP_IOCTL_GET_STA_INFO, 0,
5230 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08005232 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07005234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07005235 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05305237 { QCSAP_IOCTL_AP_STATS, 0,
5238 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305239 /* handlers for main ioctl */
5240 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
5241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
5242#ifdef WLAN_FEATURE_TSF
5243 { QCSAP_IOCTL_GET_TSF, 0,
5244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5245 "get_tsf" },
5246#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05305247 { QCSAP_IOCTL_GET_STATS, 0,
5248 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
5249 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
5251 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305252 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005253
5254 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
5255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
5256 /* handlers for sub-ioctl */
5257 { WE_SET_WLAN_DBG,
5258 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5259 0,
5260 "setwlandbg" },
5261
5262 /* handlers for main ioctl */
5263 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
5264 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5265 0,
5266 "" },
5267
5268 /* handlers for sub-ioctl */
5269 { WE_LOG_DUMP_CMD,
5270 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5271 0,
5272 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 { WE_P2P_NOA_CMD,
5274 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5275 0,
5276 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005277 /* handlers for sub ioctl */
5278 {
5279 WE_MCC_CONFIG_CREDENTIAL,
5280 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5281 0,
5282 "setMccCrdnl" },
5283
5284 /* handlers for sub ioctl */
5285 {
5286 WE_MCC_CONFIG_PARAMS,
5287 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5288 0,
5289 "setMccConfig" },
5290
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 /* handlers for main ioctl */
5292 { QCSAP_IOCTL_MODIFY_ACL,
5293 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
5294 0,
5295 "modify_acl" },
5296
5297 /* handlers for main ioctl */
5298 { QCSAP_IOCTL_GET_CHANNEL_LIST,
5299 0,
5300 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
5301 "getChannelList" },
5302
Jeff Johnsone7245742012-09-05 17:12:55 -07005303 /* handlers for main ioctl */
5304 { QCSAP_IOCTL_SET_TX_POWER,
5305 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5306 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05305307 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07005308
5309 /* handlers for main ioctl */
5310 { QCSAP_IOCTL_SET_MAX_TX_POWER,
5311 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5312 0,
5313 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05305314
5315 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
5316 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
5317 0,
5318 "dataSnapshot" },
5319
5320 /* handlers for main ioctl */
5321 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
5322 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5323 0,
5324 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305325 /* handlers for main ioctl */
5326 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
5327 IW_PRIV_TYPE_CHAR| 512,
5328 0,
5329 "" },
5330
5331 /* handlers for sub-ioctl */
5332 { WE_WOWL_ADD_PTRN,
5333 IW_PRIV_TYPE_CHAR| 512,
5334 0,
5335 "wowlAddPtrn" },
5336
5337 { WE_WOWL_DEL_PTRN,
5338 IW_PRIV_TYPE_CHAR| 512,
5339 0,
5340 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005341};
Jeff Johnsone7245742012-09-05 17:12:55 -07005342
Jeff Johnson295189b2012-06-20 16:38:30 -07005343static const iw_handler hostapd_private[] = {
5344 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305345 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
5346 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
5347 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
5350 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
5351 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
5352 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
5353 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
5354 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
5355 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05305356 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305357 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
5359 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
5360 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
5361 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005362 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07005363 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
5364 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07005365 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305366 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05305367 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05305368 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
5369 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07005370};
5371const struct iw_handler_def hostapd_handler_def = {
5372 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
5373 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
5374 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
5375 .standard = (iw_handler *)hostapd_handler,
5376 .private = (iw_handler *)hostapd_private,
5377 .private_args = hostapd_private_args,
5378 .get_wireless_stats = NULL,
5379};
5380#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5381struct net_device_ops net_ops_struct = {
5382 .ndo_open = hdd_hostapd_open,
5383 .ndo_stop = hdd_hostapd_stop,
5384 .ndo_uninit = hdd_hostapd_uninit,
5385 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5386 .ndo_tx_timeout = hdd_softap_tx_timeout,
5387 .ndo_get_stats = hdd_softap_stats,
5388 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5389 .ndo_do_ioctl = hdd_hostapd_ioctl,
5390 .ndo_change_mtu = hdd_hostapd_change_mtu,
5391 .ndo_select_queue = hdd_hostapd_select_queue,
5392 };
5393#endif
5394
5395int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5396{
5397 return VOS_STATUS_SUCCESS;
5398}
5399
5400void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5401{
5402#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5403 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5404#else
5405 pWlanHostapdDev->open = hdd_hostapd_open;
5406 pWlanHostapdDev->stop = hdd_hostapd_stop;
5407 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5408 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5409 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5410 pWlanHostapdDev->get_stats = hdd_softap_stats;
5411 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5412 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5413#endif
5414}
5415
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305416VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305417{
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05305419#ifdef DHCP_SERVER_OFFLOAD
5420 hdd_dhcp_state_t *dhcp_status;
5421#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305422#ifdef MDNS_OFFLOAD
5423 hdd_mdns_state_t *mdns_status;
5424#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005426 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305428 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005429#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005430 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5431 v_U16_t unsafeChannelCount;
5432#endif /* FEATURE_WLAN_CH_AVOID */
5433
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305434 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5436 "%s:LOGP in Progress. Ignore!!!",__func__);
5437 status = VOS_STATUS_E_FAILURE;
5438 }
5439
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305441
5442#ifdef SAP_AUTH_OFFLOAD
5443 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305444 {
5445 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5446 {
5447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5448 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5449 return VOS_STATUS_E_FAILURE;
5450 }
5451 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305452#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305453
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305454 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305456#ifdef DHCP_SERVER_OFFLOAD
5457 dhcp_status = &pAdapter->dhcp_status;
5458#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305459#ifdef MDNS_OFFLOAD
5460 mdns_status = &pAdapter->mdns_status;
5461#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305462
Nirav Shah7e3c8132015-06-22 23:51:42 +05305463 spin_lock_init(&pAdapter->sta_hash_lock);
5464 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5465
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005466 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5467
Leo Chang0b0e45a2013-12-15 15:18:55 -08005468#ifdef FEATURE_WLAN_CH_AVOID
5469 /* Get unsafe cahnnel list from cached location */
5470 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5471 sizeof(unsafeChannelList),
5472 &unsafeChannelCount);
5473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5474 "%s : Unsafe Channel count %d",
5475 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305476 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005477 unsafeChannelList,
5478 unsafeChannelCount);
5479#endif /* FEATURE_WLAN_CH_AVOID */
5480
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 // Zero the memory. This zeros the profile structure.
5482 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305483#ifdef DHCP_SERVER_OFFLOAD
5484 memset(dhcp_status, 0,sizeof(*dhcp_status));
5485#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305486#ifdef MDNS_OFFLOAD
5487 memset(mdns_status, 0,sizeof(*mdns_status));
5488#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305489
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 // Set up the pointer to the Wireless Extensions state structure
5491 // NOP
5492 status = hdd_set_hostapd(pAdapter);
5493 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 return status;
5496 }
5497
5498 status = vos_event_init(&phostapdBuf->vosEvent);
5499 if (!VOS_IS_STATUS_SUCCESS(status))
5500 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 return status;
5503 }
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05305504 status = vos_event_init(&phostapdBuf->sta_discon_event);
5505 if (!VOS_IS_STATUS_SUCCESS(status))
5506 {
5507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ERROR: Hostapd HDD sta disassoc event init failed!!");
5508 return status;
5509 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305510#ifdef DHCP_SERVER_OFFLOAD
5511 status = vos_event_init(&dhcp_status->vos_event);
5512 if (!VOS_IS_STATUS_SUCCESS(status)) {
5513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5514 return status;
5515 }
5516#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305517#ifdef MDNS_OFFLOAD
5518 status = vos_event_init(&mdns_status->vos_event);
5519 if (!VOS_IS_STATUS_SUCCESS(status)) {
5520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5521 ("Hostapd HDD vos event init failed!!"));
5522 return status;
5523 }
5524#endif /* MDNS_OFFLOAD */
5525
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5527
5528 // Register as a wireless device
5529 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5530
5531 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305532 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 if ( !VOS_IS_STATUS_SUCCESS( status ))
5534 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005535 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305537
5538 status = hdd_wmm_adapter_init( pAdapter );
5539 if (!VOS_IS_STATUS_SUCCESS(status))
5540 {
5541 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005542 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305543 status, status );
5544 goto error_wmm_init;
5545 }
5546
5547 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5548
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305549 ini_cfg = pHddCtx->cfg_ini;
5550 if (re_init && ini_cfg) {
5551 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5552 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5553 ini_cfg->apOperatingBand);
5554 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5555 ini_cfg->apStartChannelNum,
5556 ini_cfg->apEndChannelNum,
5557 ini_cfg->apOperatingBand);
5558 }
Bapiraju Allaa8f68d72020-11-26 23:25:08 +05305559
5560 status = hdd_sta_id_hash_attach(pAdapter);
5561 if (VOS_STATUS_SUCCESS != status)
5562 {
5563 hddLog(VOS_TRACE_LEVEL_ERROR,
5564 FL("Failed to initialize hash for AP"));
5565 goto error_wmm_init;
5566 }
5567
Arun Kumar Khandavalli2225e3b2020-08-03 10:23:22 +05305568 /* Action frame registered in one adapter which will
5569 * applicable to all interfaces
5570 */
5571 wlan_hdd_cfg80211_register_frames(pAdapter);
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305572
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305573 return status;
5574
5575error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305576 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 EXIT();
5578 return status;
5579}
5580
5581hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5582{
5583 struct net_device *pWlanHostapdDev = NULL;
5584 hdd_adapter_t *pHostapdAdapter = NULL;
5585 v_CONTEXT_t pVosContext= NULL;
5586
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305587 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5589 NET_NAME_UNKNOWN,
5590#endif
5591 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 if (pWlanHostapdDev != NULL)
5593 {
5594 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5595
5596 //Init the net_device structure
5597 ether_setup(pWlanHostapdDev);
5598
5599 //Initialize the adapter context to zeros.
5600 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5601 pHostapdAdapter->dev = pWlanHostapdDev;
5602 pHostapdAdapter->pHddCtx = pHddCtx;
5603 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5604
5605 //Get the Global VOSS context.
5606 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5607 //Save the adapter context in global context for future.
5608 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5609
5610 //Init the net_device structure
5611 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5612
5613 hdd_set_ap_ops( pHostapdAdapter->dev );
5614
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5616 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5617
5618 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5619 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
Ramanasarvesh Sadulacab51182020-05-20 17:44:27 +05305620 hdd_dev_setup_destructor(pWlanHostapdDev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5622 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5623 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005624
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5626 }
5627 return pHostapdAdapter;
5628}
5629
5630VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5631{
5632 struct net_device *dev = pAdapter->dev;
5633 VOS_STATUS status = VOS_STATUS_SUCCESS;
5634
5635 ENTER();
5636
5637 if( rtnl_lock_held )
5638 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005639 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 if( dev_alloc_name(dev, dev->name) < 0 )
5641 {
5642 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5643 return VOS_STATUS_E_FAILURE;
5644 }
5645 }
5646 if (register_netdevice(dev))
5647 {
5648 hddLog(VOS_TRACE_LEVEL_FATAL,
5649 "%s:Failed:register_netdevice", __func__);
5650 return VOS_STATUS_E_FAILURE;
5651 }
5652 }
5653 else
5654 {
5655 if (register_netdev(dev))
5656 {
5657 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5658 return VOS_STATUS_E_FAILURE;
5659 }
5660 }
5661 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5662
5663 EXIT();
5664 return status;
5665}
5666
c_hpothu002231a2015-02-05 14:58:51 +05305667VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005668{
5669 ENTER();
5670
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305671 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
5673 /* if we are being called during driver unload, then the dev has already
5674 been invalidated. if we are being called at other times, then we can
5675 detatch the wireless device handlers */
5676 if (pAdapter->dev)
5677 {
c_hpothu002231a2015-02-05 14:58:51 +05305678 if (TRUE == rtnl_held)
5679 {
5680 pAdapter->dev->wireless_handlers = NULL;
5681 }
5682 else
5683 {
5684 rtnl_lock();
5685 pAdapter->dev->wireless_handlers = NULL;
5686 rtnl_unlock();
5687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 }
5689 EXIT();
5690 return 0;
5691}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305692
5693/**
5694 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5695 * to supplicant, if there any clients connected to SAP interface.
5696 * @adapter: sap adapter context
5697 *
5698 * Return: nothing
5699 */
5700void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5701{
5702 tSap_Event sap_event;
5703 int staId;
5704 hdd_context_t *hdd_ctx;
5705 v_CONTEXT_t vos_ctx;
5706 ptSapContext sap_ctx;
5707
5708 ENTER();
5709
5710 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305711 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5712 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5713 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305714 return;
5715 }
5716
5717 vos_ctx = hdd_ctx->pvosContext;
5718 if (NULL == vos_ctx) {
5719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5720 "%s: VOS context is not valid",__func__);
5721 return;
5722 }
5723
5724 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5725 if (!sap_ctx) {
5726 hddLog(LOGE, FL("invalid sap context"));
5727 return;
5728 }
5729
5730 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5731 if (sap_ctx->aStaInfo[staId].isUsed) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07005732 hddLog(LOG1, FL("staId: %d isUsed: %d %pK"),
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305733 staId, sap_ctx->aStaInfo[staId].isUsed,
5734 sap_ctx);
5735
5736 if (vos_is_macaddr_broadcast(
5737 &sap_ctx->aStaInfo[staId].macAddrSTA))
5738 continue;
5739
5740 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5741 vos_mem_copy(
5742 &sap_event.sapevt.
5743 sapStationDisassocCompleteEvent.staMac,
5744 &sap_ctx->aStaInfo[staId].macAddrSTA,
5745 sizeof(v_MACADDR_t));
5746 sap_event.sapevt.sapStationDisassocCompleteEvent.
5747 reason =
5748 eSAP_MAC_INITATED_DISASSOC;
5749 sap_event.sapevt.sapStationDisassocCompleteEvent.
5750 statusCode =
5751 eSIR_SME_RESOURCES_UNAVAILABLE;
5752 hdd_hostapd_SAPEventCB(&sap_event,
5753 sap_ctx->pUsrContext);
5754 }
5755 }
5756
5757 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5758
5759 EXIT();
5760}
5761
5762/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305763 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305764 * @adapter: sap adapter context
5765 *
5766 * Return: nothing
5767 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305768void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305769{
5770 hdd_context_t *hdd_ctx;
5771 v_CONTEXT_t vos_ctx;
5772 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305773 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305774
5775 ENTER();
5776
5777 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305778 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5780 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305781 return;
5782 }
5783
5784 vos_ctx = hdd_ctx->pvosContext;
5785 if (NULL == vos_ctx) {
5786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5787 "%s: VOS context is not valid",__func__);
5788 return;
5789 }
5790
5791 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5792 if (!sap_ctx) {
5793 hddLog(LOGE, FL("invalid sap context"));
5794 return;
5795 }
5796
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305797 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5798 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5799 if (!VOS_IS_STATUS_SUCCESS(status))
5800 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5801 FL("Failed to Stop HT20/40 timer"));
5802 }
5803
5804 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5805 if (!VOS_IS_STATUS_SUCCESS(status))
5806 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5807 FL("Failed to Destroy HT20/40 timer"));
5808
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305809}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305810
5811/**
5812 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5813 * @adapter: hdd ap adapter
5814 *
5815 * hdd_force_scc_restart_sap will choose station channel and will
5816 * schedule work to restart the sap.
5817 *
5818 * Return - none
5819 */
5820void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5821 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5822{
5823 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5824 return;
5825 }
5826
5827 hddLog(LOG1, FL("Current operation channel %d"),
5828 adapter->sessionCtx.ap.operatingChannel);
5829 hddLog(LOG1, FL("STA channel is %d"),
5830 channelId);
5831
5832 vos_flush_work(
5833 &hdd_ctx->sap_start_work);
5834
5835 hddLog(LOGE,
5836 FL("Restarting SAP for force SCC "));
5837
5838 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5839
5840 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5841 netif_tx_disable(adapter->dev);
5842 schedule_work(&hdd_ctx->sap_start_work);
5843 } else {
5844 hdd_hostapd_stop(adapter->dev);
5845 }
5846 return;
5847}
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05305848
5849/**
5850 * hdd_get_cache_stainfo() - get stainfo for the specified peer
5851 * @stainfo: array of station info
5852 * @mac_addr: mac address of requested peer
5853 *
5854 * This function find the stainfo for the peer with mac_addr
5855 *
5856 * Return: stainfo if found, NULL if not found
5857 */
5858struct hdd_cache_sta_info *hdd_get_cache_stainfo(
5859 struct hdd_cache_sta_info *astainfo,
5860 u8 *mac_addr)
5861{
5862 struct hdd_cache_sta_info *stainfo = NULL;
5863 int i;
5864
5865 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
5866 if (vos_mem_compare(&astainfo[i].macAddrSTA,
5867 mac_addr,
5868 HDD_MAC_ADDR_LEN)) {
5869 stainfo = &astainfo[i];
5870 break;
5871 }
5872 }
5873
5874 return stainfo;
5875}
5876