blob: 750edef8b2c569f51a9563053093f4a26e8c3461 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sourav Mohapatra5817dc42017-12-18 17:45:16 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
Jeff Johnson295189b2012-06-20 16:38:30 -070027
28/**========================================================================
29
30 \file wlan_hdd_hostapd.c
31 \brief WLAN Host Device Driver implementation
32
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 ========================================================================*/
35/**=========================================================================
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
46 -------- --- --------------------------------------------------------
47 04/5/09 Shailender Created module.
48 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
49 ==========================================================================*/
50/*--------------------------------------------------------------------------
51 Include Files
52 ------------------------------------------------------------------------*/
53
54#include <linux/version.h>
55#include <linux/module.h>
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/wireless.h>
59#include <linux/semaphore.h>
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -070060#include <linux/compat.h>
c_hpothu002231a2015-02-05 14:58:51 +053061#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include <vos_api.h>
63#include <vos_sched.h>
64#include <linux/etherdevice.h>
65#include <wlan_hdd_includes.h>
66#include <qc_sap_ioctl.h>
67#include <wlan_hdd_hostapd.h>
68#include <sapApi.h>
69#include <sapInternal.h>
70#include <wlan_qct_tl.h>
71#include <wlan_hdd_softap_tx_rx.h>
72#include <wlan_hdd_main.h>
73#include <linux/netdevice.h>
74#include <linux/mmc/sdio_func.h>
75#include "wlan_nlink_common.h"
76#include "wlan_btc_svc.h"
77#include <bap_hdd_main.h>
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +053078#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070080#include "cfgApi.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053081#include "wniCfg.h"
Arun Khandavalli08bcafd2016-11-08 14:45:48 +053082#include <wlan_hdd_wowl.h>
Agrawal Ashish17ef5082016-10-17 18:33:21 +053083#include "wlan_hdd_hostapd.h"
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +053084#include "wlan_hdd_request_manager.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085
Leo Chang0b0e45a2013-12-15 15:18:55 -080086#ifdef FEATURE_WLAN_CH_AVOID
87#include "wcnss_wlan.h"
88#endif /* FEATURE_WLAN_CH_AVOID */
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053089#include "wlan_hdd_trace.h"
90#include "vos_types.h"
91#include "vos_trace.h"
Leo Chang0b0e45a2013-12-15 15:18:55 -080092
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define IS_UP(_dev) \
94 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
95#define IS_UP_AUTO(_ic) \
96 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
97#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -070098#define WE_GET_STA_INFO_SIZE 30
99/* WEXT limition: MAX allowed buf len for any *
100 * IW_PRIV_TYPE_CHAR is 2Kbytes *
101 */
102#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530104#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700105
Leo Chang0b0e45a2013-12-15 15:18:55 -0800106#ifdef FEATURE_WLAN_CH_AVOID
107/* Channle/Freqency table */
108extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
109safeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] =
110{
111 /*CH , SAFE, default safe */
112 {1 , VOS_TRUE}, //RF_CHAN_1,
113 {2 , VOS_TRUE}, //RF_CHAN_2,
114 {3 , VOS_TRUE}, //RF_CHAN_3,
115 {4 , VOS_TRUE}, //RF_CHAN_4,
116 {5 , VOS_TRUE}, //RF_CHAN_5,
117 {6 , VOS_TRUE}, //RF_CHAN_6,
118 {7 , VOS_TRUE}, //RF_CHAN_7,
119 {8 , VOS_TRUE}, //RF_CHAN_8,
120 {9 , VOS_TRUE}, //RF_CHAN_9,
121 {10 , VOS_TRUE}, //RF_CHAN_10,
122 {11 , VOS_TRUE}, //RF_CHAN_11,
123 {12 , VOS_TRUE}, //RF_CHAN_12,
124 {13 , VOS_TRUE}, //RF_CHAN_13,
125 {14 , VOS_TRUE}, //RF_CHAN_14,
126 {240, VOS_TRUE}, //RF_CHAN_240,
127 {244, VOS_TRUE}, //RF_CHAN_244,
128 {248, VOS_TRUE}, //RF_CHAN_248,
129 {252, VOS_TRUE}, //RF_CHAN_252,
130 {208, VOS_TRUE}, //RF_CHAN_208,
131 {212, VOS_TRUE}, //RF_CHAN_212,
132 {216, VOS_TRUE}, //RF_CHAN_216,
133 {36 , VOS_TRUE}, //RF_CHAN_36,
134 {40 , VOS_TRUE}, //RF_CHAN_40,
135 {44 , VOS_TRUE}, //RF_CHAN_44,
136 {48 , VOS_TRUE}, //RF_CHAN_48,
137 {52 , VOS_TRUE}, //RF_CHAN_52,
138 {56 , VOS_TRUE}, //RF_CHAN_56,
139 {60 , VOS_TRUE}, //RF_CHAN_60,
140 {64 , VOS_TRUE}, //RF_CHAN_64,
141 {100, VOS_TRUE}, //RF_CHAN_100,
142 {104, VOS_TRUE}, //RF_CHAN_104,
143 {108, VOS_TRUE}, //RF_CHAN_108,
144 {112, VOS_TRUE}, //RF_CHAN_112,
145 {116, VOS_TRUE}, //RF_CHAN_116,
146 {120, VOS_TRUE}, //RF_CHAN_120,
147 {124, VOS_TRUE}, //RF_CHAN_124,
148 {128, VOS_TRUE}, //RF_CHAN_128,
149 {132, VOS_TRUE}, //RF_CHAN_132,
150 {136, VOS_TRUE}, //RF_CHAN_136,
151 {140, VOS_TRUE}, //RF_CHAN_140,
152 {149, VOS_TRUE}, //RF_CHAN_149,
153 {153, VOS_TRUE}, //RF_CHAN_153,
154 {157, VOS_TRUE}, //RF_CHAN_157,
155 {161, VOS_TRUE}, //RF_CHAN_161,
156 {165, VOS_TRUE}, //RF_CHAN_165,
157};
158#endif /* FEATURE_WLAN_CH_AVOID */
159
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530160/*---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 * Function definitions
162 *-------------------------------------------------------------------------*/
163/**---------------------------------------------------------------------------
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530164
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530165 \brief __hdd_hostapd_open() - HDD Open function for hostapd interface
Sushant Kaushik4b7cb302014-01-06 17:45:01 +0530166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 This is called in response to ifconfig up
168
169 \param - dev Pointer to net_device structure
170
171 \return - 0 for success non-zero for failure
172
173 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530174int __hdd_hostapd_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700175{
Siddharth Bhal2db319d2014-12-03 12:37:18 +0530176 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
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));
193 if (NULL == pHddCtx)
194 {
195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
196 "%s: HDD context is Null", __func__);
197 return -ENODEV;
198 }
199 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
200 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
201 {
202 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
203 {
204 hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby",
205 __func__);
206 in_standby = FALSE;
207 break;
208 }
209 else
210 {
211 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
212 pAdapterNode = pNext;
213 }
214 }
215
216 if (TRUE == in_standby)
217 {
218 if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter))
219 {
220 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring "
221 "wlan out of power save", __func__);
222 return -EINVAL;
223 }
224 }
225
226 status = hdd_init_ap_mode( pAdapter, false);
227 if( VOS_STATUS_SUCCESS != status ) {
228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to create session for station mode",
229 __func__);
230 return -EINVAL;
231 }
232
233 set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
234
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 //Turn ON carrier state
236 netif_carrier_on(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530237 //Enable all Tx queues
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530238 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 netif_tx_start_all_queues(dev);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530240
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 EXIT();
242 return 0;
243}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530244
245int hdd_hostapd_open (struct net_device *dev)
246{
247 int ret;
248
249 vos_ssr_protect(__func__);
250 ret = __hdd_hostapd_open(dev);
251 vos_ssr_unprotect(__func__);
252
253 return ret;
254}
255
Jeff Johnson295189b2012-06-20 16:38:30 -0700256/**---------------------------------------------------------------------------
257
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530258 \brief __hdd_hostapd_stop() - HDD stop function for hostapd interface
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
260 This is called in response to ifconfig down
261
262 \param - dev Pointer to net_device structure
263
264 \return - 0 for success non-zero for failure
265
266 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530267int __hdd_hostapd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700268{
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530269 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
270 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
271 int ret;
272
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 ENTER();
274
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530275 ret = wlan_hdd_validate_context(hdd_ctx);
276 if (0 != ret)
277 return ret;
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +0530278
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530279 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
280
281 //Stop all tx queues
282 netif_tx_disable(dev);
283
284 //Turn OFF carrier state
285 netif_carrier_off(dev);
286
Arun Kumar Khandavalli9113aee2020-02-26 10:54:02 +0530287 if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) {
288 hdd_stop_adapter(hdd_ctx, adapter, VOS_TRUE);
289 hdd_deinit_adapter(hdd_ctx, adapter, TRUE);
290 }
291
292 clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags);
293 adapter->dev->wireless_handlers = NULL;
294
Hanumanth Reddy Pothula972e1df2018-06-14 13:33:47 +0530295 if (!hdd_is_cli_iface_up(hdd_ctx))
296 sme_ScanFlushResult(hdd_ctx->hHal, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700297
298 EXIT();
299 return 0;
300}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530301
302int hdd_hostapd_stop (struct net_device *dev)
303{
304 int ret;
305
306 vos_ssr_protect(__func__);
307 ret = __hdd_hostapd_stop(dev);
308 vos_ssr_unprotect(__func__);
309
310 return ret;
311}
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313/**---------------------------------------------------------------------------
314
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530315 \brief __hdd_hostapd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -0700316
317 This is called during the netdev unregister to uninitialize all data
318associated with the device
319
320 \param - dev Pointer to net_device structure
321
322 \return - void
323
324 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530325static void __hdd_hostapd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -0700326{
327 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530328 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700329
330 ENTER();
331
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530332 if (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 {
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530334 hddLog(VOS_TRACE_LEVEL_ERROR,
335 FL("Invalid magic"));
336 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 }
Mukul Sharmafe1959a2015-02-28 20:02:55 +0530338 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
339 if (NULL == pHddCtx)
340 {
341 hddLog(VOS_TRACE_LEVEL_ERROR,
342 FL("NULL pHddCtx"));
343 return;
344 }
345
346 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter, TRUE);
347
348 /* after uninit our adapter structure will no longer be valid */
349 pHostapdAdapter->dev = NULL;
350 pHostapdAdapter->magic = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700351
352 EXIT();
353}
354
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530355static void hdd_hostapd_uninit (struct net_device *dev)
356{
357 vos_ssr_protect(__func__);
358 __hdd_hostapd_uninit(dev);
359 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530361 return;
362}
Jeff Johnson295189b2012-06-20 16:38:30 -0700363/**============================================================================
364 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
365 transmitting packets. There are 2 versions of this function. One that uses
366 locked queue and other that uses lockless queues. Both have been retained to
367 do some performance testing
368 @param skb : [in] pointer to OS packet (sk_buff)
369 @param dev : [in] pointer to Libra network device
370
371 @return : NET_XMIT_DROP if packets are dropped
372 : NET_XMIT_SUCCESS if packet is enqueued succesfully
373 ===========================================================================*/
374int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
375{
376 return 0;
377}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530378
379int __hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
Jeff Johnson295189b2012-06-20 16:38:30 -0700380{
381 return 0;
382}
383
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530384int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
385{
386 int ret;
387 vos_ssr_protect(__func__);
388 ret = __hdd_hostapd_change_mtu(dev, new_mtu);
389 vos_ssr_unprotect(__func__);
390
391 return ret;
392}
393
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700394static int hdd_hostapd_driver_command(hdd_adapter_t *pAdapter,
395 hdd_priv_data_t *priv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -0700396{
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700397 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530398 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
399 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700400 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530401 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700402 /*
403 * Note that valid pointers are provided by caller
404 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700405
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530406 ENTER();
407
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700408 if (priv_data->total_len <= 0 ||
409 priv_data->total_len > HOSTAPD_IOCTL_COMMAND_STRLEN_MAX)
410 {
411 /* below we allocate one more byte for command buffer.
412 * To avoid addition overflow total_len should be
413 * smaller than INT_MAX. */
414 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: integer out of range len %d",
415 __func__, priv_data->total_len);
416 ret = -EFAULT;
417 goto exit;
418 }
Kaushik, Sushant96122442014-10-21 16:40:18 +0530419 status = wlan_hdd_validate_context(pHddCtx);
Kaushik, Sushant96122442014-10-21 16:40:18 +0530420 if (0 != status)
421 {
Kaushik, Sushant96122442014-10-21 16:40:18 +0530422 return status;
423 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700424
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700425 /* Allocate +1 for '\0' */
426 command = kmalloc((priv_data->total_len + 1), GFP_KERNEL);
427 if (!command)
428 {
429 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to allocate memory", __func__);
430 ret = -ENOMEM;
431 goto exit;
432 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700433
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700434 if (copy_from_user(command, priv_data->buf, priv_data->total_len))
435 {
436 ret = -EFAULT;
437 goto exit;
438 }
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800439
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700440 /* Make sure the command is NUL-terminated */
441 command[priv_data->total_len] = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -0700442
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700443 hddLog(VOS_TRACE_LEVEL_INFO,
444 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700445
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700446 if (strncmp(command, "P2P_SET_NOA", 11) == 0)
447 {
448 hdd_setP2pNoa(pAdapter->dev, command);
449 }
450 else if (strncmp(command, "P2P_SET_PS", 10) == 0)
451 {
452 hdd_setP2pOpps(pAdapter->dev, command);
453 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800454#ifdef FEATURE_WLAN_BATCH_SCAN
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700455 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
456 {
457 ret = hdd_handle_batch_scan_ioctl(pAdapter, priv_data, command);
458 }
Rajeev Kumar8b373292014-01-08 20:36:55 -0800459#endif
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700460 else if (strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
461 {
462 /*
463 * command should be a string having format
464 * SET_SAP_CHANNEL_LIST <num channels> <channels seperated by spaces>
465 */
466 hddLog(VOS_TRACE_LEVEL_INFO,
467 "%s: Received Command to Set Preferred Channels for SAP",
468 __func__);
Rajeev Kumar8b373292014-01-08 20:36:55 -0800469
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700470 ret = sapSetPreferredChannel(command);
471 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530472 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
473 {
474 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
475 tANI_U8 filterType = 0;
476 tANI_U8 *value;
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530477
478 ret = hdd_drv_cmd_validate(command, 8);
479 if (ret)
480 goto exit;
481
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530482 value = command + 9;
483
484 /* Convert the value from ascii to integer */
485 ret = kstrtou8(value, 10, &filterType);
486 if (ret < 0)
487 {
488 /* If the input value is greater than max value of datatype,
489 * then also kstrtou8 fails
490 */
491 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
492 "%s: kstrtou8 failed range ", __func__);
493 ret = -EINVAL;
494 goto exit;
495 }
496 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
497 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
498 {
499 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
500 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
501 " 2-Sink ", __func__);
502 ret = -EINVAL;
503 goto exit;
504 }
505 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
506 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +0530507 pScanInfo = &pHddCtx->scan_info;
508 if (filterType && pScanInfo != NULL &&
509 pHddCtx->scan_info.mScanPending)
510 {
511 /*Miracast Session started. Abort Scan */
512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
513 "%s, Aborting Scan For Miracast",__func__);
514 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
515 eCSR_SCAN_ABORT_DEFAULT);
516 }
Ganesh Kondabattini2d7c7f02014-09-04 22:21:39 +0530517 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
518 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
519 }
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530520 else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0)
521 {
Rajeev Kumar Sirasanagandlaf740b1e2017-08-23 18:07:01 +0530522 ret = hdd_drv_cmd_validate(command, 16);
523 if (ret)
524 goto exit;
525
Mahesh A Saptasagarbeca12c2015-09-07 16:21:06 +0530526 ret = hdd_enable_disable_ca_event(pHddCtx, command, 16);
527 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700528
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530529 /*
530 * command should be a string having format
531 * SET_DISABLE_CHANNEL_LIST <num of channels>
532 * <channels separated by spaces>
533 */
534 else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) {
535 tANI_U8 *ptr = command;
536
537 ret = hdd_drv_cmd_validate(command, 24);
538 if (ret)
539 goto exit;
540
541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
542 " Received Command to disable Channels for in %s",
543 __func__);
544 ret = hdd_parse_disable_chan_cmd(pAdapter, ptr);
545 }
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530546 else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) {
547 char extra[128] = {0};
548 int len;
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530549
Hanumanth Reddy Pothula8ae38bb2018-03-07 18:59:30 +0530550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
551 " Received Command to get disable Channels list %s",
552 __func__);
553
554 len = hdd_get_disable_ch_list(pHddCtx, extra, sizeof(extra));
555 if (len == 0) {
556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
557 FL("disable channel list are not yet programed"));
558 ret = -EINVAL;
559 goto exit;
560 }
561
562 len = VOS_MIN(priv_data->total_len, len + 1);
563 if (copy_to_user(priv_data->buf, &extra, len)) {
564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
565 "%s: failed to copy data to user buffer", __func__);
566 ret = -EFAULT;
567 goto exit;
568 }
569
570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
571 FL("data:%s"), extra);
572 }
Ashish Kumar Dhanotiya32d092b2018-02-20 21:43:57 +0530573 else {
574 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
575 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
576 pAdapter->sessionId, 0));
577 hddLog(VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"),
578 command);
579 }
580
Jeff Johnson295189b2012-06-20 16:38:30 -0700581exit:
582 if (command)
583 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700584 kfree(command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530586 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return ret;
588}
589
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700590#ifdef CONFIG_COMPAT
591static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
592 struct ifreq *ifr)
593{
594 struct {
595 compat_uptr_t buf;
596 int used_len;
597 int total_len;
598 } compat_priv_data;
599 hdd_priv_data_t priv_data;
600 int ret = 0;
601
602 /*
603 * Note that pAdapter and ifr have already been verified by caller,
604 * and HDD context has also been validated
605 */
606 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
607 sizeof(compat_priv_data))) {
608 ret = -EFAULT;
609 goto exit;
610 }
611 priv_data.buf = compat_ptr(compat_priv_data.buf);
612 priv_data.used_len = compat_priv_data.used_len;
613 priv_data.total_len = compat_priv_data.total_len;
614 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
615 exit:
616 return ret;
617}
618#else /* CONFIG_COMPAT */
619static int hdd_hostapd_driver_compat_ioctl(hdd_adapter_t *pAdapter,
620 struct ifreq *ifr)
621{
622 /* will never be invoked */
623 return 0;
624}
625#endif /* CONFIG_COMPAT */
626
627static int hdd_hostapd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
628{
629 hdd_priv_data_t priv_data;
630 int ret = 0;
631
632 /*
633 * Note that pAdapter and ifr have already been verified by caller,
634 * and HDD context has also been validated
635 */
636 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
637 ret = -EFAULT;
638 } else {
639 ret = hdd_hostapd_driver_command(pAdapter, &priv_data);
640 }
641 return ret;
642}
643
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530644static int __hdd_hostapd_ioctl(struct net_device *dev,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700645 struct ifreq *ifr, int cmd)
646{
647 hdd_adapter_t *pAdapter;
648 hdd_context_t *pHddCtx;
649 int ret;
650
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530651 ENTER();
652
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700653 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
654 if (NULL == pAdapter) {
655 hddLog(VOS_TRACE_LEVEL_ERROR,
656 "%s: HDD adapter context is Null", __func__);
657 ret = -ENODEV;
658 goto exit;
659 }
660 if (dev != pAdapter->dev) {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 "%s: HDD adapter/dev inconsistency", __func__);
663 ret = -ENODEV;
664 goto exit;
665 }
666
667 if ((!ifr) || (!ifr->ifr_data)) {
668 ret = -EINVAL;
669 goto exit;
670 }
671
672 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
673 ret = wlan_hdd_validate_context(pHddCtx);
674 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700675 ret = -EBUSY;
676 goto exit;
677 }
678
679 switch (cmd) {
680 case (SIOCDEVPRIVATE + 1):
681 if (is_compat_task())
682 ret = hdd_hostapd_driver_compat_ioctl(pAdapter, ifr);
683 else
684 ret = hdd_hostapd_driver_ioctl(pAdapter, ifr);
685 break;
686 default:
687 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
688 __func__, cmd);
689 ret = -EINVAL;
690 break;
691 }
692 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530693 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -0700694 return ret;
695}
696
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530697static int hdd_hostapd_ioctl(struct net_device *dev,
698 struct ifreq *ifr, int cmd)
699{
700 int ret;
701
702 vos_ssr_protect(__func__);
703 ret = __hdd_hostapd_ioctl(dev, ifr, cmd);
704 vos_ssr_unprotect(__func__);
705
706 return ret;
707}
708
Jeff Johnson295189b2012-06-20 16:38:30 -0700709/**---------------------------------------------------------------------------
710
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530711 \brief __hdd_hostapd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 This function sets the user specified mac address using
713 the command ifconfig wlanX hw ether <mac adress>.
714
715 \param - dev - Pointer to the net device.
716 - addr - Pointer to the sockaddr.
717 \return - 0 for success, non zero for failure
718
719 --------------------------------------------------------------------------*/
720
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530721static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700722{
723 struct sockaddr *psta_mac_addr = addr;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530724 hdd_adapter_t *pAdapter, *adapter_temp;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530725 hdd_context_t *pHddCtx;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530726 int ret = 0, i;
727 v_MACADDR_t mac_addr;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530730 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
731 if (NULL == pAdapter)
732 {
733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
734 "%s: Adapter is NULL",__func__);
735 return -EINVAL;
736 }
737 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
738 ret = wlan_hdd_validate_context(pHddCtx);
739 if (0 != ret)
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530740 return ret;
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530741
742
743 memcpy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr));
744 if(vos_is_macaddr_zero(&mac_addr)) {
745 hddLog(VOS_TRACE_LEVEL_ERROR, "Zero Mac address");
746 return -EINVAL;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +0530747 }
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530748
749 if (vos_is_macaddr_broadcast(&mac_addr)) {
750 hddLog(VOS_TRACE_LEVEL_ERROR,"MAC is Broadcast");
751 return -EINVAL;
752 }
753
754 if (vos_is_macaddr_multicast(&mac_addr)) {
755 hddLog(VOS_TRACE_LEVEL_ERROR, "Multicast Mac address");
756 return -EINVAL;
757 }
758
759
760 adapter_temp = hdd_get_adapter_by_macaddr(pHddCtx, mac_addr.bytes);
761 if (adapter_temp) {
762 if (!strcmp(adapter_temp->dev->name, dev->name))
763 return 0;
764 hddLog(VOS_TRACE_LEVEL_ERROR,
765 "%s: WLAN Mac Addr: "
766 MAC_ADDRESS_STR, __func__,
767 MAC_ADDR_ARRAY(mac_addr.bytes));
768 return -EINVAL;
769 }
770
771 for (i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) {
772 if (!vos_mem_compare(&pAdapter->macAddressCurrent.bytes,
773 &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], VOS_MAC_ADDR_SIZE)) {
774 memcpy(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], mac_addr.bytes,
775 VOS_MAC_ADDR_SIZE);
776 break;
777 }
778 }
779
780 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
Arun Kumar Khandavalli18303eb2020-01-22 20:44:09 +0530782
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 EXIT();
784 return 0;
785}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +0530786
787static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
788{
789 int ret;
790
791 vos_ssr_protect(__func__);
792 ret = __hdd_hostapd_set_mac_address(dev, addr);
793 vos_ssr_unprotect(__func__);
794
795 return ret;
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
799{
800 struct net_device *dev = (struct net_device *)usrDataForCallback;
801 v_BYTE_t we_custom_event[64];
802 union iwreq_data wrqu;
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 hdd_adapter_t *pHostapdAdapter;
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530804 hdd_context_t *pHddCtx;
805#ifdef DISABLE_CONCURRENCY_AUTOSAVE
806 VOS_STATUS vos_status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 hdd_ap_ctx_t *pHddApCtx;
808#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
809
810 /* event_name space-delimiter driver_module_name */
811 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
812 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
813 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
814
815 ENTER();
816
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530817 pHostapdAdapter = netdev_priv(dev);
818 if ((NULL == pHostapdAdapter) ||
819 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
820 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700821 hddLog(LOGE, FL("invalid adapter: %pK"), pHostapdAdapter);
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530822 return;
823 }
824 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
825 if (0 != (wlan_hdd_validate_context(pHddCtx)))
826 {
827 return;
828 }
Agarwal Ashish51325b52014-06-16 16:50:49 +0530829#ifdef DISABLE_CONCURRENCY_AUTOSAVE
830 if (vos_concurrent_open_sessions_running())
Mahesh A Saptasagar4534e2b2015-03-05 20:45:41 +0530831 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 /*
833 This timer routine is going to be called only when AP
834 persona is up.
835 If there are concurrent sessions running we do not want
836 to shut down the Bss.Instead we run the timer again so
837 that if Autosave is enabled next time and other session
838 was down only then we bring down AP
839 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
841 vos_status = vos_timer_start(
842 &pHddApCtx->hdd_ap_inactivity_timer,
843 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
844 * 1000);
845 if (!VOS_IS_STATUS_SUCCESS(vos_status))
846 {
847 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
848 }
849 EXIT();
850 return;
851 }
852#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
853 memset(&we_custom_event, '\0', sizeof(we_custom_event));
854 memcpy(&we_custom_event, autoShutEvent, event_len);
855
856 memset(&wrqu, 0, sizeof(wrqu));
857 wrqu.data.length = event_len;
858
859 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
860 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
861
862 EXIT();
863}
864
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800865VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
866{
867 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
868 ptSapContext pSapCtx = NULL;
869 eHalStatus halStatus = eHAL_STATUS_FAILURE;
870 v_PVOID_t hHal = NULL;
871
872 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
873 "%s: UPDATE Beacon Params", __func__);
874
875 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
876 pSapCtx = VOS_GET_SAP_CB(pVosContext);
877 if ( NULL == pSapCtx )
878 {
879 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
880 "%s: Invalid SAP pointer from pvosGCtx", __func__);
881 return VOS_STATUS_E_FAULT;
882 }
883
884 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
885 if ( NULL == hHal ){
886 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
887 "%s: Invalid HAL pointer from pvosGCtx", __func__);
888 return VOS_STATUS_E_FAULT;
889 }
890 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
891 if(halStatus == eHAL_STATUS_FAILURE ){
892 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
893 "%s: Failed to update Beacon Params", __func__);
894 return VOS_STATUS_E_FAILURE;
895 }
896 }
897 return VOS_STATUS_SUCCESS;
898}
899
900void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
901{
902 v_U8_t staId = 0;
903 struct net_device *dev;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530904 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
905 ptSapContext pSapCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800906
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530907 dev = (struct net_device *)usrDataForCallback;
908 pSapCtx = VOS_GET_SAP_CB(pVosContext);
909 if(pSapCtx == NULL){
910 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
911 FL("psapCtx is NULL"));
912 return;
913 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800914 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800915 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
916 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530917 if ( pSapCtx->aStaInfo[staId].isUsed &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800918 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
919 {
920 //Disconnect all the stations
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530921 hdd_softap_sta_disassoc(pHostapdAdapter, &pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800922 }
923 }
924}
925
Agarwal Ashish8e538932014-12-24 18:12:52 +0530926static int hdd_stop_bss_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800927{
928 struct net_device *dev;
Agarwal Ashish51325b52014-06-16 16:50:49 +0530929 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800930 VOS_STATUS status = VOS_STATUS_SUCCESS;
931 dev = (struct net_device *)usrDataForCallback;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530932
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800933 ENTER();
Agarwal Ashish51325b52014-06-16 16:50:49 +0530934
935 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
936 status = wlan_hdd_validate_context(pHddCtx);
937
938 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530939 return status;
940 }
941
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800942 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
943 {
944 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
945 {
Agarwal Ashish8e538932014-12-24 18:12:52 +0530946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting SAP/P2P link!!!!!!"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800947 }
948 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +0530949 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800950 }
951 EXIT();
952 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
953}
Jeff Johnson295189b2012-06-20 16:38:30 -0700954
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530955#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashish6773c902017-01-06 19:45:03 +0530956bool hdd_set_sap_auth_offload(hdd_adapter_t *pHostapdAdapter,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530957 bool enabled)
958{
959 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530960 struct tSirSapOffloadInfo sap_offload_info;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530961
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530962 vos_mem_copy( &sap_offload_info.macAddr,
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530963 pHostapdAdapter->macAddressCurrent.bytes, VOS_MAC_ADDR_SIZE);
964
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530965 sap_offload_info.sap_auth_offload_enable = enabled;
966 sap_offload_info.sap_auth_offload_sec_type =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530967 pHddCtx->cfg_ini->sap_auth_offload_sec_type;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530968 sap_offload_info.key_len =
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530969 strlen(pHddCtx->cfg_ini->sap_auth_offload_key);
970
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530971 if (sap_offload_info.sap_auth_offload_enable &&
972 sap_offload_info.sap_auth_offload_sec_type)
973 {
974 if (sap_offload_info.key_len < 8 ||
975 sap_offload_info.key_len > WLAN_PSK_STRING_LENGTH)
976 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530977 hddLog(VOS_TRACE_LEVEL_ERROR,
978 "%s: invalid key length(%d) of WPA security!", __func__,
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530979 sap_offload_info.key_len);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530980 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530981 }
982 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530983 if (sap_offload_info.key_len)
984 {
985 vos_mem_copy(sap_offload_info.key,
986 pHddCtx->cfg_ini->sap_auth_offload_key,
987 sap_offload_info.key_len);
988 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530989 if (eHAL_STATUS_SUCCESS !=
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530990 sme_set_sap_auth_offload(pHddCtx->hHal, &sap_offload_info))
991 {
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530992 hddLog(VOS_TRACE_LEVEL_ERROR,
993 "%s: sme_set_sap_auth_offload fail!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530994 return false;
Agrawal Ashish17ef5082016-10-17 18:33:21 +0530995 }
996
997 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
998 "%s: sme_set_sap_auth_offload successfully!", __func__);
Agrawal Ashish6773c902017-01-06 19:45:03 +0530999 return true;
Agrawal Ashish17ef5082016-10-17 18:33:21 +05301000}
1001#endif
1002
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301003/**
1004* wlansap_get_phymode() - get SAP phymode.
1005* @pctx: Pointer to the global vos context; a handle to SAP's control block
1006* can be extracted from its context. When MBSSID feature is enabled,
1007* SAP context is directly passed to SAP APIs.
1008*
1009* This function provides current phymode of SAP interface.
1010*
1011* Return: phymode with eCsrPhyMode type.
1012*/
1013static eCsrPhyMode
1014wlansap_get_phymode(v_PVOID_t pctx)
1015{
1016 ptSapContext psapctx = VOS_GET_SAP_CB(pctx);
1017
1018 if (!psapctx) {
1019 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1020 "%s: Invalid SAP pointer from pCtx", __func__);
1021 return eCSR_DOT11_MODE_AUTO;
1022 }
1023 return psapctx->csrRoamProfile.phyMode;
1024}
1025
1026/**
1027 * hdd_update_chandef() - Function to update channel width and center freq
1028 * @chandef: cfg80211 chan def
1029 * @cb_mode: chan offset
1030 *
1031 * This function will be called to update channel width and center freq
1032 *
1033 * Return: None
1034 */
1035static void
1036hdd_update_chandef(struct cfg80211_chan_def *chandef,
1037 ePhyChanBondState cb_mode)
1038{
1039 uint8_t center_chan, chan;
1040
1041 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
1042 return;
1043
1044 chan = vos_freq_to_chan(chandef->chan->center_freq);
1045 chandef->width = NL80211_CHAN_WIDTH_80;
1046 switch (cb_mode) {
1047 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1048 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1049 center_chan = chan + 2;
1050 break;
1051 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1052 center_chan = chan + 6;
1053 break;
1054 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1055 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1056 center_chan = chan - 2;
1057 break;
1058 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1059 center_chan = chan - 6;
1060 break;
1061 default:
1062 center_chan = chan;
1063 break;
1064 }
1065
1066 chandef->center_freq1 = vos_chan_to_freq(center_chan);
1067}
1068
1069/**
1070 * hdd_chan_change_notify() - Function to notify hostapd about channel change
1071 * @hostapd_adapter: hostapd adapter
1072 * @dev: Net device structure
1073 * @oper_chan: New operating channel
1074 *
1075 * This function is used to notify hostapd about the channel change
1076 *
1077 * Return: Success on intimating userspace
1078 *
1079 */
1080static VOS_STATUS hdd_chan_change_notify(hdd_adapter_t *hostapd_adapter,
1081 struct net_device *dev, uint8_t oper_chan)
1082{
1083 struct ieee80211_channel *chan;
1084 struct cfg80211_chan_def chandef;
1085 enum nl80211_channel_type channel_type;
1086 eCsrPhyMode phy_mode;
1087 ePhyChanBondState cb_mode;
1088 uint32_t freq;
1089 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(hostapd_adapter);
1090 tSmeConfigParams sme_config;
1091
1092 if (!hal) {
1093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1094 "%s: hal is NULL", __func__);
1095 return VOS_STATUS_E_FAILURE;
1096 }
1097
1098 freq = vos_chan_to_freq(oper_chan);
1099
1100 chan = __ieee80211_get_channel(hostapd_adapter->wdev.wiphy, freq);
1101
1102 if (!chan) {
1103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1104 "%s: Invalid input frequency for channel conversion", __func__);
1105 return VOS_STATUS_E_FAILURE;
1106 }
1107
1108 phy_mode = wlansap_get_phymode(
1109 (WLAN_HDD_GET_CTX(hostapd_adapter))->pvosContext);
1110 sme_GetConfigParam(hal, &sme_config);
1111 if (oper_chan <= 14)
1112 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1113 sme_config.csrConfig.channelBondingMode24GHz);
1114 else
1115 cb_mode = sme_get_cb_phy_mode_from_cb_ini_mode(
1116 sme_config.csrConfig.channelBondingMode5GHz);
1117
1118 switch (phy_mode) {
1119 case eCSR_DOT11_MODE_11n:
1120 case eCSR_DOT11_MODE_11n_ONLY:
1121 case eCSR_DOT11_MODE_11ac:
1122 case eCSR_DOT11_MODE_11ac_ONLY:
1123 switch (cb_mode) {
1124 case PHY_SINGLE_CHANNEL_CENTERED:
1125 channel_type = NL80211_CHAN_HT20;
1126 break;
1127 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1128 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1129 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1130 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1131 channel_type = NL80211_CHAN_HT40MINUS;
1132 break;
1133 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1134 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1135 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1136 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1137 channel_type = NL80211_CHAN_HT40PLUS;
1138 break;
1139 default:
1140 channel_type = NL80211_CHAN_HT20;
1141 break;
1142 }
1143 break;
1144 default:
1145 channel_type = NL80211_CHAN_NO_HT;
1146 break;
1147 }
1148
1149 cfg80211_chandef_create(&chandef, chan, channel_type);
1150 if ((phy_mode == eCSR_DOT11_MODE_11ac) ||
1151 (phy_mode == eCSR_DOT11_MODE_11ac_ONLY))
1152 hdd_update_chandef(&chandef, cb_mode);
1153
1154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1155 "%s: phy_mode %d cb_mode %d chann_type %d oper_chan %d width %d freq_1 %d",
1156 __func__, phy_mode, cb_mode, channel_type, oper_chan,
1157 chandef.width, chandef.center_freq1);
1158
1159
1160 cfg80211_ch_switch_notify(dev, &chandef);
1161
1162 return VOS_STATUS_SUCCESS;
1163}
1164
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301165/**
1166 * hdd_convert_dot11mode_from_phymode() - get dot11mode to phymode
1167 * @phymode: phy mode
1168 *
1169 * This function is used to get dot11mode to phymode
1170 *
1171 * Return: dot11mode
1172 */
1173static int hdd_convert_dot11mode_from_phymode(int phymode)
1174{
1175 switch (phymode) {
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301176
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301177 case VOS_MODE_11A:
1178 return QCA_WLAN_802_11_MODE_11A;
1179
1180 case VOS_MODE_11B:
1181 return QCA_WLAN_802_11_MODE_11B;
1182
1183 case VOS_MODE_11G:
1184 case VOS_MODE_11GONLY:
1185 return QCA_WLAN_802_11_MODE_11G;
1186
1187 case VOS_MODE_11NA_HT20:
1188 case VOS_MODE_11NG_HT20:
1189 case VOS_MODE_11NA_HT40:
1190 case VOS_MODE_11NG_HT40:
1191 return QCA_WLAN_802_11_MODE_11N;
1192
1193 case VOS_MODE_11AC_VHT20:
1194 case VOS_MODE_11AC_VHT40:
1195 case VOS_MODE_11AC_VHT80:
1196 case VOS_MODE_11AC_VHT20_2G:
1197 case VOS_MODE_11AC_VHT40_2G:
1198 case VOS_MODE_11AC_VHT80_2G:
1199#ifdef CONFIG_160MHZ_SUPPORT
1200 case VOS_MODE_11AC_VHT80_80:
1201 case VOS_MODE_11AC_VHT160:
1202#endif
1203 return QCA_WLAN_802_11_MODE_11AC;
1204
1205 default:
1206 return QCA_WLAN_802_11_MODE_INVALID;
1207 }
1208
1209}
1210
1211/**
1212 * hdd_fill_station_info() - fill station information
1213 * @sap_ctx: sap context
1214 * @event: assoc event
1215 * This function updates sta information from assoc event
1216 *
1217 * Return: none
1218 */
1219static void hdd_fill_station_info(ptSapContext sap_ctx,
1220 tSap_StationAssocReassocCompleteEvent *event)
1221{
1222 struct hdd_cache_sta_info *sta_info = sap_ctx->cache_sta_info;
1223 int i=0;
1224
1225 /* check if there is any dup entry */
1226 while (i < WLAN_MAX_STA_COUNT) {
1227 if (vos_mem_compare(sta_info[i].macAddrSTA.bytes,
1228 event->staMac.bytes,
1229 VOS_MAC_ADDR_SIZE)) {
1230 vos_mem_zero(&sta_info[i], sizeof(*sta_info));
1231 break;
1232 }
1233 i++;
1234 }
1235 if (i >= WLAN_MAX_STA_COUNT) {
1236 i = 0;
1237 while (i < WLAN_MAX_STA_COUNT) {
1238 if (sta_info[i].isUsed != TRUE)
1239 break;
1240 i++;
1241 }
1242 }
1243
1244 if (i < WLAN_MAX_STA_COUNT) {
1245 sta_info[i].isUsed = TRUE;
1246 sta_info[i].ucSTAId = event->staId;
1247 vos_mem_copy(sta_info[i].macAddrSTA.bytes,
1248 event->staMac.bytes,
1249 VOS_MAC_ADDR_SIZE);
1250 sta_info[i].freq = vos_chan_to_freq(event->chan_info.chan_id);
1251 sta_info[i].ch_width = event->ch_width;
1252 sta_info[i].nss = 1;
1253 sta_info[i].dot11_mode = hdd_convert_dot11mode_from_phymode(
1254 event->chan_info.info);
1255 if (event->HTCaps.present) {
1256 sta_info[i].ht_present = TRUE;
1257 hdd_copy_ht_caps(&sta_info[i].ht_caps, &event->HTCaps);
1258 }
1259 if (event->VHTCaps.present) {
1260 sta_info[i].vht_present = TRUE;
1261 hdd_copy_vht_caps(&sta_info[i].vht_caps,
1262 &event->VHTCaps);
1263 }
1264 }
1265 else
1266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "reached max staid, stainfo can't be cached");
1267}
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301268
Jeff Johnson295189b2012-06-20 16:38:30 -07001269VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
1270{
1271 hdd_adapter_t *pHostapdAdapter;
1272 hdd_ap_ctx_t *pHddApCtx;
1273 hdd_hostapd_state_t *pHostapdState;
1274 struct net_device *dev;
1275 eSapHddEvent sapEvent;
1276 union iwreq_data wrqu;
1277 v_BYTE_t *we_custom_event_generic = NULL;
1278 int we_event = 0;
1279 int i = 0;
1280 v_U8_t staId;
1281 VOS_STATUS vos_status;
1282 v_BOOL_t bWPSState;
1283 v_BOOL_t bApActive = FALSE;
1284 v_BOOL_t bAuthRequired = TRUE;
1285 tpSap_AssocMacAddr pAssocStasArray = NULL;
1286 char unknownSTAEvent[IW_CUSTOM_MAX+1];
1287 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
1288 v_BYTE_t we_custom_start_event[64];
1289 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001290 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001291 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -07001292 struct iw_michaelmicfailure msg;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301293 v_CONTEXT_t pVosContext = NULL;
1294 ptSapContext pSapCtx = NULL;
Deepthi Gowried085092015-10-20 19:30:52 +05301295 hdd_config_t *cfg_param;
Jeff Johnson295189b2012-06-20 16:38:30 -07001296
1297 dev = (struct net_device *)usrDataForCallback;
1298 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +05301299
1300 if ((NULL == pHostapdAdapter) ||
1301 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
1302 {
1303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1304 "invalid adapter or adapter has invalid magic");
1305 return eHAL_STATUS_FAILURE;
1306 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301307 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1308 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1309 if(pSapCtx == NULL){
1310 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1311 FL("psapCtx is NULL"));
1312 return eHAL_STATUS_FAILURE;
1313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1315 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1316 sapEvent = pSapEvent->sapHddEventCode;
1317 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001318 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Deepthi Gowried085092015-10-20 19:30:52 +05301319 cfg_param = pHddCtx->cfg_ini;
1320
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 switch(sapEvent)
1322 {
1323 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -08001324 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
1326 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
1327 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
1328
1329 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
1330 vos_status = vos_event_set(&pHostapdState->vosEvent);
Deepthi Gowried085092015-10-20 19:30:52 +05301331
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
Deepthi Gowried085092015-10-20 19:30:52 +05301333 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 goto stopbss;
1336 }
1337 else
Deepthi Gowried085092015-10-20 19:30:52 +05301338 {
1339 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
1340 {
1341 if ((cfg_param->dynSplitscan) &&
1342 (!pHddCtx->issplitscan_enabled))
1343 {
1344 pHddCtx->issplitscan_enabled = TRUE;
1345 sme_enable_disable_split_scan(
1346 WLAN_HDD_GET_HAL_CTX(pHostapdAdapter),
1347 cfg_param->nNumStaChanCombinedConc,
1348 cfg_param->nNumP2PChanCombinedConc);
1349 }
1350 }
1351
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
1353 //@@@ need wep logic here to set privacy bit
c_hpothuffdb5272013-10-02 16:42:35 +05301354 vos_status = hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
1355 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Agarwal Ashish8e538932014-12-24 18:12:52 +05301356 {
c_hpothuffdb5272013-10-02 16:42:35 +05301357 hddLog(LOGW, FL("Failed to register BC STA %d"), vos_status);
Agarwal Ashish8e538932014-12-24 18:12:52 +05301358 hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
1359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 }
Deepthi Gowried085092015-10-20 19:30:52 +05301361
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1363 {
1364 // AP Inactivity timer init and start
1365 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
1366 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
1367 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001368 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001369
1370 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1371 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001372 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001373
1374 }
1375 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
1376 pHostapdState->bssState = BSS_START;
1377
1378 // Send current operating channel of SoftAP to BTC-ES
1379 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
1380
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 //Check if there is any group key pending to set.
1382 if( pHddApCtx->groupKey.keyLength )
1383 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001384 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1386 &pHddApCtx->groupKey ) )
1387 {
1388 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1389 "%s: WLANSAP_SetKeySta failed", __func__);
1390 }
1391 pHddApCtx->groupKey.keyLength = 0;
1392 }
1393 else if ( pHddApCtx->wepKey[0].keyLength )
1394 {
1395 int i=0;
1396 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
1397 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001398 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1400 &pHddApCtx->wepKey[i] ) )
1401 {
1402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1403 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
1404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 }
1406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
1408 startBssEvent = "SOFTAP.enabled";
1409 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
1410 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
1411 memset(&wrqu, 0, sizeof(wrqu));
1412 wrqu.data.length = strlen(startBssEvent);
1413 we_event = IWEVCUSTOM;
1414 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001415 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 break; //Event will be sent after Switch-Case stmt
1417
1418 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001419 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1421
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001422 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07001423 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07001424
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301426
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 goto stopbss;
1428 case eSAP_STA_SET_KEY_EVENT:
1429 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001430 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1432 return VOS_STATUS_SUCCESS;
1433 case eSAP_STA_DEL_KEY_EVENT:
1434 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -08001435 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 return VOS_STATUS_SUCCESS;
1437 case eSAP_STA_MIC_FAILURE_EVENT:
1438 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 memset(&msg, '\0', sizeof(msg));
1440 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001441 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001442 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -07001443 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 msg.flags = IW_MICFAILURE_GROUP;
1445 else
1446 msg.flags = IW_MICFAILURE_PAIRWISE;
1447 memset(&wrqu, 0, sizeof(wrqu));
1448 wrqu.data.length = sizeof(msg);
1449 we_event = IWEVMICHAELMICFAILURE;
1450 we_custom_event_generic = (v_BYTE_t *)&msg;
1451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 /* inform mic failure to nl80211 */
1453 cfg80211_michael_mic_failure(dev,
1454 pSapEvent->sapevt.
1455 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -07001456 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 NL80211_KEYTYPE_GROUP :
1458 NL80211_KEYTYPE_PAIRWISE),
1459 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
1460 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
1461 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 break;
1463
1464 case eSAP_STA_ASSOC_EVENT:
1465 case eSAP_STA_REASSOC_EVENT:
1466 wrqu.addr.sa_family = ARPHRD_ETHER;
1467 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001468 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001469 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 we_event = IWEVREGISTERED;
1471
1472 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
1473
1474 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
1475 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
1476 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
1477 {
1478 bAuthRequired = FALSE;
1479 }
Abhishek Singh2c679282017-01-12 17:33:40 +05301480 /* fAuthRequiredshould should be false for sap offload */
1481 if ((bAuthRequired || bWPSState)
1482#ifdef SAP_AUTH_OFFLOAD
1483 && !cfg_param->enable_sap_auth_offload
1484#endif
1485 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 {
c_hpothuffdb5272013-10-02 16:42:35 +05301487 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 TRUE,
1489 pHddApCtx->uPrivacy,
1490 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1491 0,
1492 0,
1493 (v_MACADDR_t *)wrqu.addr.sa_data,
1494 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301495
1496 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1497 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1498 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 }
1500 else
1501 {
c_hpothuffdb5272013-10-02 16:42:35 +05301502 vos_status = hdd_softap_RegisterSTA( pHostapdAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 FALSE,
1504 pHddApCtx->uPrivacy,
1505 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
1506 0,
1507 0,
1508 (v_MACADDR_t *)wrqu.addr.sa_data,
1509 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
c_hpothuffdb5272013-10-02 16:42:35 +05301510 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1511 hddLog(LOGW, FL("Failed to register STA %d "MAC_ADDRESS_STR""),
1512 vos_status, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Amar Singhal6144c002013-05-03 16:11:42 -07001513 }
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301514 if (VOS_IS_STATUS_SUCCESS(vos_status))
1515 hdd_fill_station_info(pSapCtx,
1516 &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent);
Amar Singhal6144c002013-05-03 16:11:42 -07001517
Deepthi Gowriae6a1662015-10-12 12:59:37 +05301518 staId =
1519 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId;
1520 if (VOS_IS_STATUS_SUCCESS(vos_status))
1521 {
1522
1523 pSapCtx->aStaInfo[staId].rate_flags =
1524 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.rate_flags;
1525 }
1526
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 // Stop AP inactivity timer
1528 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
1529 {
1530 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1531 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001532 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001534#ifdef WLAN_OPEN_SOURCE
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301535 if (vos_wake_lock_active(&pHddCtx->sap_wake_lock))
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001536 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301537 vos_wake_lock_release(&pHddCtx->sap_wake_lock,
1538 WIFI_POWER_EVENT_WAKELOCK_SAP);
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08001539 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +05301540 vos_wake_lock_timeout_release(&pHddCtx->sap_wake_lock,
1541 HDD_SAP_WAKE_LOCK_DURATION,
1542 WIFI_POWER_EVENT_WAKELOCK_SAP);
1543
Sameer Thalappil50dc0092013-02-19 17:23:33 -08001544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001545#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1546 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301547 struct station_info *staInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
1549
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301550 staInfo = vos_mem_malloc(sizeof(*staInfo));
1551 if (staInfo == NULL) {
1552 hddLog(LOGE, FL("alloc station_info failed"));
1553 return VOS_STATUS_E_NOMEM;
1554 }
1555
1556 memset(staInfo, 0, sizeof(*staInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
1558 {
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301559 staInfo->assoc_req_ies =
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301561 staInfo->assoc_req_ies_len = iesLen;
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05301562#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31)) && \
1563 ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && \
1564 !defined(WITH_BACKPORTS))
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301565 staInfo->filled |= STATION_INFO_ASSOC_REQ_IES;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001566#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 cfg80211_new_sta(dev,
1568 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05301569 staInfo, GFP_KERNEL);
1570 vos_mem_free(staInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 }
1572 else
1573 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001574 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 }
1576 }
1577#endif
Bhargav Shahd0715912015-10-01 18:17:37 +05301578 hdd_manage_delack_timer(pHddCtx);
1579
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001580 pScanInfo = &pHddCtx->scan_info;
1581 // Lets do abort scan to ensure smooth authentication for client
1582 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1583 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05301584 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05301585 eCSR_SCAN_ABORT_DEFAULT);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001587
1588 break;
1589 case eSAP_STA_DISASSOC_EVENT:
1590 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -08001591 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001592 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05301593
1594 vos_status = vos_event_set(&pHostapdState->sta_discon_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
1596 hddLog(LOG1," User initiated disassociation");
1597 else
1598 hddLog(LOG1," MAC initiated disassociation");
1599 we_event = IWEVEXPIRED;
1600 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
1601 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1602 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001603 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 -07001604 return VOS_STATUS_E_FAILURE;
1605 }
1606 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
1607
1608 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1609 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301610 spin_lock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 // Start AP inactivity timer if no stations associated with it
1612 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
1613 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301614 if (pSapCtx->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 {
1616 bApActive = TRUE;
1617 break;
1618 }
1619 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05301620 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
1622 if (bApActive == FALSE)
1623 {
1624 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
1625 {
1626 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
1627 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -08001628 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 }
1630 else
1631 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
1632 }
1633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001634#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1635 cfg80211_del_sta(dev,
1636 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
1637 GFP_KERNEL);
1638#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001639 //Update the beacon Interval if it is P2P GO
c_hpothuffdb5272013-10-02 16:42:35 +05301640 vos_status = hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
1641 if (VOS_STATUS_SUCCESS != vos_status)
1642 {
1643 hddLog(LOGE, "%s: failed to update Beacon interval %d",
1644 __func__, vos_status);
1645 }
Bhargav Shahd0715912015-10-01 18:17:37 +05301646 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 break;
1648 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
1649 {
1650 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
1651 union iwreq_data wreq;
1652
1653 down(&pHddApCtx->semWpsPBCOverlapInd);
1654 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
1655
1656 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
1657 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
1658
1659 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -08001660 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 memset(&wreq, 0, sizeof(wreq));
1662 wreq.data.length = strlen(message); // This is length of message
1663 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
1664
1665 return VOS_STATUS_SUCCESS;
1666 }
1667 case eSAP_ASSOC_STA_CALLBACK_EVENT:
1668 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
1669 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
1670 { // List of associated stations
1671 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
1672 {
1673 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
1674 i+1,
1675 pAssocStasArray->assocId,
1676 pAssocStasArray->staId,
1677 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
1678 pAssocStasArray++;
1679 }
1680 }
1681 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001682 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 case eSAP_REMAIN_CHAN_READY:
1685 hdd_remainChanReadyHandler( pHostapdAdapter );
1686 return VOS_STATUS_SUCCESS;
1687 case eSAP_SEND_ACTION_CNF:
1688 hdd_sendActionCnf( pHostapdAdapter,
1689 ( eSAP_STATUS_SUCCESS ==
1690 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
1691 TRUE : FALSE );
1692 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 case eSAP_UNKNOWN_STA_JOIN:
1694 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
1695 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
1696 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
1697 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
1698 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
1699 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
1700 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
1701 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1702 wrqu.data.pointer = unknownSTAEvent;
1703 wrqu.data.length = strlen(unknownSTAEvent);
1704 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Agarwal Ashish971c2882013-10-30 20:11:12 +05301705 hddLog(LOGE,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 break;
1707
1708 case eSAP_MAX_ASSOC_EXCEEDED:
1709 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
1710 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
1711 " one or more devices to enable the new device connection",
1712 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
1713 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
1714 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
1715 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
1716 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
1717 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
1718 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
1719 wrqu.data.pointer = maxAssocExceededEvent;
1720 wrqu.data.length = strlen(maxAssocExceededEvent);
1721 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001722 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 break;
1724 case eSAP_STA_ASSOC_IND:
1725 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001726
1727 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001728 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001729 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
1730 return VOS_STATUS_SUCCESS;
1731
1732 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
Agarwal Ashish8e538932014-12-24 18:12:52 +05301733 vos_status = hdd_stop_bss_link(pHostapdAdapter, usrDataForCallback);
c_hpothuffdb5272013-10-02 16:42:35 +05301734 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1735 {
Agarwal Ashish8e538932014-12-24 18:12:52 +05301736 hddLog(LOGW, FL("hdd_stop_bss_link failed %d"), vos_status);
c_hpothuffdb5272013-10-02 16:42:35 +05301737 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001738 return VOS_STATUS_SUCCESS;
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301739 case eSAP_CHANNEL_CHANGED_EVENT:
1740 hddLog(LOG1, FL("Received eSAP_CHANNEL_CHANGED_EVENT event"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08001741
Abhishek Singhe8ebb922017-11-01 13:30:26 +05301742 return hdd_chan_change_notify(pHostapdAdapter, dev,
1743 pSapEvent->sapevt.sap_chan_selected.new_chan);
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05301744 case eSAP_STA_LOSTLINK_DETECTED:
1745 {
1746 tSap_StationDisassocCompleteEvent *disassoc_comp =
1747 &pSapEvent->sapevt.sapStationDisassocCompleteEvent;
1748
1749 struct hdd_cache_sta_info *sta_info = hdd_get_cache_stainfo(
1750 pSapCtx->cache_sta_info,
1751 disassoc_comp->staMac.bytes);
1752 if (!sta_info) {
1753 hddLog(LOGE, FL("invalid cache sta info"));
1754 return VOS_STATUS_E_FAILURE;
1755 }
1756
1757 WLANTL_GetSAPStaRSSi(pVosContext, disassoc_comp->staId,
1758 &sta_info->rssi);
1759 sta_info->rx_rate =
1760 wlan_tl_get_sta_rx_rate(pVosContext, disassoc_comp->staId);
1761 if (disassoc_comp->reason != eSAP_USR_INITATED_DISASSOC)
1762 sta_info->reason_code = disassoc_comp->reason;
1763 return VOS_STATUS_SUCCESS;
1764 }
1765
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001767 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 goto stopbss;
1769 return VOS_STATUS_SUCCESS;
1770 }
1771 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
1772 return VOS_STATUS_SUCCESS;
1773
1774stopbss :
1775 {
1776 v_BYTE_t we_custom_event[64];
1777 char *stopBssEvent = "STOP-BSS.response";//17
1778 int event_len = strlen(stopBssEvent);
1779
1780 hddLog(LOG1, FL("BSS stop status = %s"),
1781 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
1782 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
1783
1784 /* Change the BSS state now since, as we are shutting things down,
1785 * we don't want interfaces to become re-enabled */
1786 pHostapdState->bssState = BSS_STOP;
1787
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +05301788 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
1789 {
1790 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
1791 {
1792 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
1793 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1794 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
1795 }
1796
1797 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
1798 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1799 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
1800 }
1801
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 /* Stop the pkts from n/w stack as we are going to free all of
1803 * the TX WMM queues for all STAID's */
Kapil Gupta0afd1912016-12-28 12:52:13 +05301804
1805 /*
1806 * If channel avoidance is in progress means driver is performing SAP
1807 * restart. So don't do carrier off, which may lead framework to do
1808 * driver reload.
1809 */
1810 hddLog(LOG1, FL("ch avoid in progress: %d"),
1811 pHddCtx->is_ch_avoid_in_progress);
1812 if (pHddCtx->is_ch_avoid_in_progress &&
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05301813 pHddCtx->cfg_ini->sap_internal_restart)
Kapil Gupta0afd1912016-12-28 12:52:13 +05301814 netif_tx_disable(dev);
1815 else
1816 hdd_hostapd_stop(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001817
1818 /* reclaim all resources allocated to the BSS */
c_hpothuffdb5272013-10-02 16:42:35 +05301819 vos_status = hdd_softap_stop_bss(pHostapdAdapter);
1820 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1821 hddLog(LOGW, FL("hdd_softap_stop_bss failed %d"), vos_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001822
Amar Singhal37e6f052013-03-05 16:16:54 -08001823 /* once the event is set, structure dev/pHostapdAdapter should
1824 * not be touched since they are now subject to being deleted
1825 * by another thread */
1826 if (eSAP_STOP_BSS_EVENT == sapEvent)
1827 vos_event_set(&pHostapdState->vosEvent);
1828
Yeshwanth Sriram Guntukab973f1c2018-03-29 19:35:49 +05301829 if (hdd_is_any_session_connected(pHddCtx) == VOS_STATUS_E_FAILURE) {
1830 hdd_enable_bmps_imps(pHddCtx);
1831 sme_request_imps(pHddCtx->hHal);
1832 }
1833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 /* notify userspace that the BSS has stopped */
1835 memset(&we_custom_event, '\0', sizeof(we_custom_event));
1836 memcpy(&we_custom_event, stopBssEvent, event_len);
1837 memset(&wrqu, 0, sizeof(wrqu));
1838 wrqu.data.length = event_len;
1839 we_event = IWEVCUSTOM;
1840 we_custom_event_generic = we_custom_event;
1841 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001842 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 }
Bala Venkatesh5c06a252018-07-12 16:08:04 +05301844 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO ||
1845 pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
1846 {
1847 hddLog(LOG1,
1848 FL("SAP or Go is getting removed and we are trying to re-enable TDLS"));
1849 wlan_hdd_tdls_reenable(pHddCtx);
1850 }
1851
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 return VOS_STATUS_SUCCESS;
1853}
Chet Lanctot8cecea22014-02-11 19:09:36 -08001854
1855int hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 tHalHandle halHandle,
Chet Lanctot8cecea22014-02-11 19:09:36 -08001857 eCsrEncryptionType *pEncryptType,
1858 eCsrEncryptionType *mcEncryptType,
1859 eCsrAuthType *pAuthType,
1860 v_BOOL_t *pMFPCapable,
1861 v_BOOL_t *pMFPRequired,
1862 u_int16_t gen_ie_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 u_int8_t *gen_ie )
1864{
1865 tDot11fIERSN dot11RSNIE;
1866 tDot11fIEWPA dot11WPAIE;
1867
1868 tANI_U8 *pRsnIe;
1869 tANI_U16 RSNIeLen;
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301870 tANI_U32 status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001871
1872 if (NULL == halHandle)
1873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001874 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 return -EINVAL;
1876 }
1877
1878 // Validity checks
1879 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
1880 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
1881 return -EINVAL;
1882 // Type check
1883 if ( gen_ie[0] == DOT11F_EID_RSN)
1884 {
1885 // Validity checks
1886 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
1887 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
1888 {
1889 return VOS_STATUS_E_FAILURE;
1890 }
1891 // Skip past the EID byte and length byte
1892 pRsnIe = gen_ie + 2;
1893 RSNIeLen = gen_ie_len - 2;
1894 // Unpack the RSN IE
1895 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301896
1897 status = sme_unpack_rsn_ie(halHandle,
1898 pRsnIe,
1899 RSNIeLen,
1900 &dot11RSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05301901 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301902 {
1903 hddLog(LOGE,
1904 FL("unpack failed for RSN IE status:(0x%08x)"),
1905 status);
1906 return -EINVAL;
1907 }
1908
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001910 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001911 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001912 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301913 __func__, dot11RSNIE.akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 /*Here we have followed the apple base code,
1915 but probably I suspect we can do something different*/
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301916 //dot11RSNIE.akm_suite_cnt
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05301918 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 //dot11RSNIE.pwise_cipher_suite_count
1920 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
1921 //dot11RSNIE.gp_cipher_suite_count
1922 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
1923 // Set the PMKSA ID Cache for this interface
Chet Lanctot8cecea22014-02-11 19:09:36 -08001924 *pMFPCapable = 0 != (dot11RSNIE.RSN_Cap[0] & 0x80);
1925 *pMFPRequired = 0 != (dot11RSNIE.RSN_Cap[0] & 0x40);
Jeff Johnson295189b2012-06-20 16:38:30 -07001926
1927 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
1928 } else
1929 if (gen_ie[0] == DOT11F_EID_WPA)
1930 {
1931 // Validity checks
1932 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
1933 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
1934 {
1935 return VOS_STATUS_E_FAILURE;
1936 }
1937 // Skip past the EID byte and length byte - and four byte WiFi OUI
1938 pRsnIe = gen_ie + 2 + 4;
1939 RSNIeLen = gen_ie_len - (2 + 4);
1940 // Unpack the WPA IE
1941 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301942 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
1943 pRsnIe,
1944 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 &dot11WPAIE);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05301946 if (DOT11F_FAILED(status))
1947 {
1948 hddLog(LOGE,
1949 FL("unpack failed for WPA IE status:(0x%08x)"),
1950 status);
1951 return -EINVAL;
1952 }
1953
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -08001955 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001956 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -08001957 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001958 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 //dot11WPAIE.auth_suite_count
1960 // Just translate the FIRST one
1961 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
1962 //dot11WPAIE.unicast_cipher_count
1963 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
1964 //dot11WPAIE.unicast_cipher_count
1965 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
Chet Lanctot8cecea22014-02-11 19:09:36 -08001966 *pMFPCapable = VOS_FALSE;
1967 *pMFPRequired = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 }
1969 else
1970 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001971 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 return VOS_STATUS_E_FAILURE;
1973 }
1974 return VOS_STATUS_SUCCESS;
1975}
Leo Chang614d2072013-08-22 14:59:44 -07001976
Leo Chang0b0e45a2013-12-15 15:18:55 -08001977#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08001978
1979/*==========================================================================
1980 FUNCTION sapUpdateUnsafeChannelList
1981
1982 DESCRIPTION
1983 Function Undate unsafe channel list table
1984
1985 DEPENDENCIES
1986 NA.
1987
1988 PARAMETERS
1989
1990 IN
1991 pSapCtx : SAP context pointer, include unsafe channel list
1992
1993 RETURN VALUE
1994 NONE
1995============================================================================*/
1996void hdd_hostapd_update_unsafe_channel_list(hdd_context_t *pHddCtx,
1997 v_U16_t *unsafeChannelList, v_U16_t unsafeChannelCount)
1998{
1999 v_U16_t i, j;
2000
2001 vos_mem_zero((void *)pHddCtx->unsafeChannelList,
2002 sizeof(pHddCtx->unsafeChannelList));
2003 if (0 == unsafeChannelCount)
2004 {
2005 pHddCtx->unsafeChannelCount = 0;
2006 }
2007 else
2008 {
c_hpothu8de53e42014-08-22 15:00:37 +05302009 if (unsafeChannelCount > NUM_20MHZ_RF_CHANNELS)
2010 {
2011 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2012 FL("unsafeChannelCount%hd greater than %d"),
2013 unsafeChannelCount, NUM_20MHZ_RF_CHANNELS);
2014 unsafeChannelCount = NUM_20MHZ_RF_CHANNELS;
2015 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08002016 vos_mem_copy((void *)pHddCtx->unsafeChannelList,
2017 unsafeChannelList,
2018 unsafeChannelCount * sizeof(tANI_U16));
2019 pHddCtx->unsafeChannelCount = unsafeChannelCount;
2020 }
2021
2022 /* Flush, default set all channel safe */
2023 for (i = 0; i < NUM_20MHZ_RF_CHANNELS; i++)
2024 {
2025 safeChannels[i].isSafe = VOS_TRUE;
2026 }
2027
2028 /* Try to find unsafe channel */
2029 for (i = 0; i < pHddCtx->unsafeChannelCount; i++)
2030 {
2031 for (j = 0; j < NUM_20MHZ_RF_CHANNELS; j++)
2032 {
2033 if(safeChannels[j].channelNumber == pHddCtx->unsafeChannelList[i])
2034 {
2035 /* Found unsafe channel, update it */
2036 safeChannels[j].isSafe = VOS_FALSE;
2037 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2038 "%s : CH %d is not safe",
2039 __func__, pHddCtx->unsafeChannelList[i]);
2040 break;
2041 }
2042 }
2043 }
2044
2045 return;
2046}
2047
Kapil Gupta137ef892016-12-13 19:38:00 +05302048/**
2049 * hdd_unsafe_channel_restart_sap - restart sap if sap is on unsafe channel
2050 * @adapter: hdd ap adapter
2051 *
2052 * hdd_unsafe_channel_restart_sap check all unsafe channel list
2053 * and if ACS is enabled, driver will ask userspace to restart the
2054 * sap. User space on LTE coex indication restart driver.
2055 *
2056 * Return - none
2057 */
2058static void hdd_unsafe_channel_restart_sap(hdd_adapter_t *adapter,
2059 hdd_context_t *hdd_ctx)
2060{
2061
2062 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
2063 return;
2064 }
2065
2066 hddLog(LOG1, FL("Current operation channel %d"),
2067 adapter->sessionCtx.ap.operatingChannel);
2068 if (false == hdd_ctx->is_ch_avoid_in_progress) {
2069 hdd_change_ch_avoidance_status(hdd_ctx, true);
2070
2071 vos_flush_work(
2072 &hdd_ctx->sap_start_work);
2073
2074 /*
2075 * current operating channel
2076 * is un-safe channel, restart SAP
2077 */
2078 hddLog(LOG1,
2079 FL("Restarting SAP due to unsafe channel"));
2080
2081 adapter->sessionCtx.ap.sapConfig.channel =
2082 AUTO_CHANNEL_SELECT;
2083
Kapil Gupta137ef892016-12-13 19:38:00 +05302084
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05302085 if (hdd_ctx->cfg_ini->sap_internal_restart) {
Kapil Gupta0afd1912016-12-28 12:52:13 +05302086 netif_tx_disable(adapter->dev);
2087 schedule_work(&hdd_ctx->sap_start_work);
2088 } else {
2089 hdd_hostapd_stop(adapter->dev);
2090 }
Kapil Gupta137ef892016-12-13 19:38:00 +05302091
2092 return;
2093 }
2094 return;
2095}
2096
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302097static v_U16_t hdd_get_safe_channel_from_acs_range(hdd_context_t *hdd_ctx,
2098 hdd_adapter_t *sap_adapter, v_U16_t *unsafeChannelList,
2099 v_U16_t unsafeChannelCount)
2100{
2101 v_U8_t valid_channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2102 v_U32_t startChannelNum;
2103 v_U32_t endChannelNum;
2104 v_U32_t valid_channel_count = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2105 v_U16_t i, j;
2106 eHalStatus status;
2107 bool found;
2108
2109 status = sme_GetCfgValidChannels(hdd_ctx->hHal, valid_channels,
2110 &valid_channel_count);
2111 if (!HAL_STATUS_SUCCESS(status))
2112 return 0;
2113
2114 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL,
2115 &startChannelNum);
2116 ccmCfgGetInt(hdd_ctx->hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL,
2117 &endChannelNum);
2118
2119 for (i = 0; i < valid_channel_count; i++) {
2120 found = false;
2121 for (j = 0; j < unsafeChannelCount; j++) {
2122 if (valid_channels[i] == unsafeChannelList[j]) {
2123 found = true;
2124 break;
2125 }
2126 }
2127
2128 if (found)
2129 continue;
2130
2131 if ((valid_channels[i] >= startChannelNum) &&
2132 (valid_channels[i] <= endChannelNum)) {
2133 return valid_channels[i];
2134 }
2135 }
2136
2137 return 0;
2138}
2139
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302140void hdd_check_for_unsafe_ch(hdd_adapter_t *phostapd_adapter,
2141 hdd_context_t *hdd_ctxt)
2142{
2143 v_U16_t channelLoop;
2144 v_U16_t unsafeChannelCount = 0;
2145 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302146 v_U16_t sta_chan;
2147 v_U16_t restart_chan;
2148 v_CONTEXT_t vos_ctx;
2149 ptSapContext sap_ctx;
2150
2151 vos_ctx = hdd_ctxt->pvosContext;
2152 if (!vos_ctx) {
2153 hddLog(LOGE, FL("vos_ctx is NULL"));
2154 return;
2155 }
2156
2157 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
2158 if (!sap_ctx) {
2159 hddLog(LOGE, FL("sap_ctx is NULL"));
2160 return;
2161 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302162
2163 /* Get unsafe channel list */
2164 vos_get_wlan_unsafe_channel(unsafeChannelList, sizeof(unsafeChannelList),
2165 &unsafeChannelCount);
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302166 sta_chan = hdd_get_operating_channel(hdd_ctxt, WLAN_HDD_INFRA_STATION);
2167
2168 if (sta_chan) {
2169 hddLog(LOG1, FL("Only SCC supported for STA+SAP"));
2170 return;
2171 }
2172
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302173 for (channelLoop = 0; channelLoop < unsafeChannelCount; channelLoop++)
2174 {
2175 if ((unsafeChannelList[channelLoop] ==
2176 phostapd_adapter->sessionCtx.ap.operatingChannel)) {
2177 if ((AUTO_CHANNEL_SELECT ==
2178 phostapd_adapter->sessionCtx.ap.sapConfig.channel)
2179 && (WLAN_HDD_SOFTAP == phostapd_adapter->device_mode)) {
2180 /*
2181 * current operating channel is un-safe channel
2182 * restart driver
2183 */
Yeshwanth Sriram Guntuka06848b12018-07-20 14:58:22 +05302184 if (hdd_ctxt->cfg_ini->force_scc_with_ecsa) {
2185 restart_chan = hdd_get_safe_channel_from_acs_range(hdd_ctxt,
2186 phostapd_adapter, unsafeChannelList,
2187 unsafeChannelCount);
2188
2189 if (!restart_chan) {
2190 hddLog(LOGE, FL("Failed to restart SAP as no safe channel found"));
2191 return;
2192 } else {
2193 if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx))
2194 return;
2195 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
2196 if (wlansap_set_channel_change(vos_ctx, restart_chan,
2197 false)) {
2198 wlansap_reset_chan_change_in_progress(sap_ctx);
2199 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2200 return;
2201 }
2202 }
2203 } else {
2204 hdd_unsafe_channel_restart_sap(phostapd_adapter, hdd_ctxt);
2205 }
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302206 /*
2207 * On LE, this event is handled by wlan-services to
2208 * restart SAP. On android, this event would be
2209 * ignored.
2210 */
2211 wlan_hdd_send_svc_nlink_msg(WLAN_SVC_SAP_RESTART_IND,
2212 NULL, 0);
2213 }
2214 break;
2215 }
2216 }
2217 return;
2218}
2219
2220
Kapil Gupta137ef892016-12-13 19:38:00 +05302221
Leo Chang0b0e45a2013-12-15 15:18:55 -08002222/**---------------------------------------------------------------------------
2223
2224 \brief hdd_hostapd_ch_avoid_cb() -
2225
2226 Avoid channel notification from FW handler.
2227 FW will send un-safe channle list to avoid overwrapping.
2228 hostapd should not use notified channel
2229
2230 \param - pAdapter HDD adapter pointer
2231 indParam channel avoid notification parameter
2232
2233 \return - None
2234
2235 --------------------------------------------------------------------------*/
2236void hdd_hostapd_ch_avoid_cb
2237(
Kapil Gupta137ef892016-12-13 19:38:00 +05302238 void *context,
Leo Chang0b0e45a2013-12-15 15:18:55 -08002239 void *indParam
2240)
2241{
2242 hdd_adapter_t *pHostapdAdapter = NULL;
2243 hdd_context_t *hddCtxt;
2244 tSirChAvoidIndType *chAvoidInd;
2245 v_U8_t rangeLoop;
2246 v_U16_t channelLoop;
2247 v_U16_t dupCheck;
2248 v_U16_t startChannel;
2249 v_U16_t endChannel;
2250 v_U16_t unsafeChannelCount = 0;
2251 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
2252 v_CONTEXT_t pVosContext;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002253 tHddAvoidFreqList hddAvoidFreqList;
2254 tANI_U32 i;
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302255#ifdef WLAN_FEATURE_AP_HT40_24G
2256 ptSapContext pSapCtx = NULL;
2257 tHalHandle hHal;
2258 v_U8_t cbMode;
2259 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2260 v_U32_t delay;
2261#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002262
2263 /* Basic sanity */
Kapil Gupta137ef892016-12-13 19:38:00 +05302264 if ((NULL == context) || (NULL == indParam))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002265 {
2266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2267 "%s : Invalid arguments", __func__);
2268 return;
2269 }
2270
Kapil Gupta137ef892016-12-13 19:38:00 +05302271 hddCtxt = (hdd_context_t *)context;
Leo Chang0b0e45a2013-12-15 15:18:55 -08002272 chAvoidInd = (tSirChAvoidIndType *)indParam;
2273 pVosContext = hddCtxt->pvosContext;
2274
2275 /* Make unsafe channel list */
2276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2277 "%s : band count %d",
2278 __func__, chAvoidInd->avoidRangeCount);
2279 vos_mem_zero((void *)unsafeChannelList,
2280 NUM_20MHZ_RF_CHANNELS * sizeof(v_U16_t));
2281 for (rangeLoop = 0; rangeLoop < chAvoidInd->avoidRangeCount; rangeLoop++)
2282 {
Abhishek Singh57a31542016-01-04 21:01:43 +05302283 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2284 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2285 break;
2286 }
2287 startChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002288 chAvoidInd->avoidFreqRange[rangeLoop].startFreq);
Abhishek Singh57a31542016-01-04 21:01:43 +05302289 endChannel = ieee80211_frequency_to_channel(
Leo Chang0b0e45a2013-12-15 15:18:55 -08002290 chAvoidInd->avoidFreqRange[rangeLoop].endFreq);
2291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2292 "%s : start %d : %d, end %d : %d",
2293 __func__,
2294 chAvoidInd->avoidFreqRange[rangeLoop].startFreq,
2295 startChannel,
2296 chAvoidInd->avoidFreqRange[rangeLoop].endFreq,
2297 endChannel);
2298 for (channelLoop = startChannel;
2299 channelLoop < (endChannel + 1);
2300 channelLoop++)
2301 {
2302 /* Channel duplicate check routine */
2303 for (dupCheck = 0; dupCheck < unsafeChannelCount; dupCheck++)
2304 {
2305 if (unsafeChannelList[dupCheck] == channelLoop)
2306 {
2307 /* This channel is duplicated */
2308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2309 "%s : found duplicated channel %d",
2310 __func__, channelLoop);
2311 break;
2312 }
2313 }
2314 if (dupCheck == unsafeChannelCount)
2315 {
c_hpothu8de53e42014-08-22 15:00:37 +05302316 int ii;
2317 for(ii=0; ii<NUM_20MHZ_RF_CHANNELS; ii++)
2318 {
2319 if (channelLoop == safeChannels[ii].channelNumber)
2320 {
2321 unsafeChannelList[unsafeChannelCount] = channelLoop;
2322 unsafeChannelCount++;
2323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2324 "%s : unsafe channel %d, count %d",
2325 __func__,
2326 channelLoop, unsafeChannelCount);
Abhishek Singh57a31542016-01-04 21:01:43 +05302327 if (unsafeChannelCount >= NUM_20MHZ_RF_CHANNELS) {
2328 hddLog(LOGW, FL("LTE Coex unsafe channel list full"));
2329 break;
2330 }
c_hpothu8de53e42014-08-22 15:00:37 +05302331 }
2332 }
Leo Chang0b0e45a2013-12-15 15:18:55 -08002333 }
2334 else
2335 {
2336 /* DUP, do nothing */
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2338 "%s : duplicated channel %d",
2339 __func__, channelLoop);
2340 }
2341 }
2342 }
2343 /* Update unsafe channel cache
2344 * WCN Platform Driver cache */
2345 wcnss_set_wlan_unsafe_channel(unsafeChannelList,
2346 unsafeChannelCount);
2347
2348 /* Store into local cache
2349 * Start with STA and later start SAP
2350 * in this scenario, local cache will be used */
2351 hdd_hostapd_update_unsafe_channel_list(hddCtxt,
2352 unsafeChannelList,
2353 unsafeChannelCount);
2354
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002355 /* generate vendor specific event */
2356 vos_mem_zero((void *)&hddAvoidFreqList, sizeof(tHddAvoidFreqList));
2357 for (i = 0; i < chAvoidInd->avoidRangeCount; i++)
2358 {
2359 hddAvoidFreqList.avoidFreqRange[i].startFreq =
2360 chAvoidInd->avoidFreqRange[i].startFreq;
2361 hddAvoidFreqList.avoidFreqRange[i].endFreq =
2362 chAvoidInd->avoidFreqRange[i].endFreq;
2363 }
2364 hddAvoidFreqList.avoidFreqRangeCount = chAvoidInd->avoidRangeCount;
2365
2366 wlan_hdd_send_avoid_freq_event(hddCtxt, &hddAvoidFreqList);
2367
Leo Chang0b0e45a2013-12-15 15:18:55 -08002368 /* Get SAP context first
2369 * SAP and P2PGO would not concurrent */
2370 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_SOFTAP);
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302371#ifdef WLAN_FEATURE_AP_HT40_24G
2372 if (NULL == pHostapdAdapter)
2373 {
2374 pHostapdAdapter = hdd_get_adapter(hddCtxt, WLAN_HDD_P2P_GO);
2375 }
2376#endif
Kanchanapally, Vidyullatha99bd6c42014-12-10 13:54:38 +05302377 if ((pHostapdAdapter) &&
2378 (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) &&
2379 (unsafeChannelCount))
Leo Chang0b0e45a2013-12-15 15:18:55 -08002380 {
2381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2382 "%s : Current operation channel %d",
2383 __func__,
2384 pHostapdAdapter->sessionCtx.ap.operatingChannel);
Ashish Kumar Dhanotiya42aa5152017-01-03 20:25:57 +05302385 /* Check and Restart the SAP if it is on unsafe channel */
2386 hdd_check_for_unsafe_ch(pHostapdAdapter, hddCtxt);
2387
Leo Chang0b0e45a2013-12-15 15:18:55 -08002388 }
2389
Hardik Kantilal Patel8c2d5232015-01-08 00:31:38 +05302390#ifdef WLAN_FEATURE_AP_HT40_24G
2391 if (hddCtxt->cfg_ini->apHT40_24GEnabled)
2392 {
2393 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2394
2395 if(pSapCtx == NULL)
2396 {
2397 VOS_TRACE(VOS_MODULE_ID_HDD_SAP_DATA, VOS_TRACE_LEVEL_ERROR,
2398 FL("psapCtx is NULL"));
2399 return;
2400 }
2401
2402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2403 FL("SAP Secondary channel: %d "),
2404 pSapCtx->sap_sec_chan);
2405
2406 /* tHalHandle */
2407 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2408
2409 if (NULL == hHal)
2410 {
2411 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2412 FL("In invalid hHal"));
2413 return;
2414 }
2415
2416 cbMode = sme_GetChannelBondingMode24G(hHal);
2417
2418 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2419 FL("Selected Channel bonding : %d"), cbMode);
2420
2421 if (cbMode && (pSapCtx->sap_sec_chan > 0))
2422 {
2423 int i;
2424 eHalStatus halStatus;
2425
2426 for (i = 0; i < unsafeChannelCount; i++)
2427 {
2428 if ((pSapCtx->sap_sec_chan == unsafeChannelList[i]))
2429 {
2430 /* Current SAP Secondary channel is un-safe channel */
2431 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2432 FL("Move SAP from HT40 to HT20"));
2433
2434 halStatus = sme_SetHT2040Mode(hHal, pSapCtx->sessionId,
2435 PHY_SINGLE_CHANNEL_CENTERED);
2436
2437 if (halStatus == eHAL_STATUS_FAILURE)
2438 {
2439 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2440 FL("Failed to change HT20/40 mode"));
2441 return;
2442 }
2443
2444 /* Disable Channel Bonding for 2.4GHz */
2445 sme_UpdateChannelBondingMode24G(hHal,
2446 PHY_SINGLE_CHANNEL_CENTERED);
2447 return;
2448 }
2449 }
2450 }
2451
2452 if ((!pSapCtx->numHT40IntoSta)
2453 && (pHostapdAdapter)
2454 && (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)))
2455 {
2456 /* if Unsafe channel is Zero or SAP Primary/Secondary channel
2457 * are Safe then start HT20/40 timer to Move SAP from HT20
2458 * to HT40.
2459 */
2460 if (((!unsafeChannelCount)
2461 || (!sapCheckHT40SecondaryIsNotAllowed(pSapCtx))) && (!cbMode))
2462 {
2463 /* Stop Previous Running HT20/40 Timer & Start timer
2464 with (OBSS TransitionDelayFactor * obss interval)
2465 delay after time out move AP from HT20 -> HT40
2466 mode
2467 */
2468 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2469 {
2470 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2471 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2472 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2473 FL("Failed to Stop HT20/40 timer"));
2474 }
2475
2476 delay =
2477 (pSapCtx->ObssScanInterval * pSapCtx->ObssTransitionDelayFactor);
2478
2479 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2480 FL("Start HT20/40 transition timer (%d sec)"), delay);
2481
2482 vosStatus = vos_timer_start( &pSapCtx->sap_HT2040_timer,
2483 (delay * 1000));
2484
2485 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2486 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2487 FL("Failed to Start HT20/40 timer"));
2488 }
2489 else
2490 {
2491 /* Stop HT20/40 Timer */
2492 if (VOS_TIMER_STATE_RUNNING == pSapCtx->sap_HT2040_timer.state)
2493 {
2494 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2495 FL("Stop HT20/40 transition timer"));
2496 vosStatus = vos_timer_stop(&pSapCtx->sap_HT2040_timer);
2497 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
2498 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2499 FL("Failed to Stop HT20/40 timer"));
2500 }
2501 }
2502 }
2503 }
2504#endif
Leo Chang0b0e45a2013-12-15 15:18:55 -08002505 return;
2506}
Leo Chang0b0e45a2013-12-15 15:18:55 -08002507#endif /* FEATURE_WLAN_CH_AVOID */
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302510static __iw_softap_setparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 struct iw_request_info *info,
2512 union iwreq_data *wrqu, char *extra)
2513{
2514 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002515 tHalHandle hHal;
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302516 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 int *value = (int *)extra;
2518 int sub_cmd = value[0];
2519 int set_value = value[1];
2520 eHalStatus status;
2521 int ret = 0; /* success */
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302522 int enable_pattrn_byte_match, enable_magic_pkt;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002523 v_CONTEXT_t pVosContext;
2524
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302525 ENTER();
2526
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302527 if (NULL == pHostapdAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002528 {
2529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302530 "%s: hostapd Adapter is null",
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002531 __func__);
2532 return -1;
2533 }
2534
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302535 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2536 ret = wlan_hdd_validate_context(pHddCtx);
2537 if (0 != ret)
2538 {
Mahesh A Saptasagarc449f102015-01-09 21:15:18 +05302539 return -1;
2540 }
2541
Rajesh Chauhana0516c62014-01-30 16:11:18 -08002542 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2543 if (!hHal)
2544 {
2545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2546 "%s: Hal ctx is null", __func__);
2547 return -1;
2548 }
2549
2550 pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2551 if (!pVosContext)
2552 {
2553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2554 "%s: Vos ctx is null", __func__);
2555 return -1;
2556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002557
2558 switch(sub_cmd)
2559 {
2560
2561 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002562 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302564 ret = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 }
2566 break;
2567
2568 case QCSAP_PARAM_ACL_MODE:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302569 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
2571 {
2572 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
2573 ret = -EINVAL;
2574 }
2575 else
2576 {
2577 WLANSAP_SetMode(pVosContext, set_value);
2578 }
2579 break;
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05302580
2581 case QCSAP_PARAM_SET_AUTO_CHANNEL:
2582 if ((0 != set_value) && (1 != set_value))
2583 {
2584 hddLog(LOGE, FL("Invalid setAutoChannel value %d"), set_value);
2585 ret = -EINVAL;
2586 }
2587 else
2588 {
2589 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection = set_value;
2590 }
2591 break;
2592
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 case QCSAP_PARAM_MAX_ASSOC:
2594 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
2595 {
2596 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
2597 ret = -EINVAL;
2598 }
2599 else
2600 {
2601 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
2602 {
2603 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
2604 "Setting it to max allowed and continuing"),
2605 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
2606 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
2607 }
2608 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
2609 set_value, NULL, eANI_BOOLEAN_FALSE);
2610 if ( status != eHAL_STATUS_SUCCESS )
2611 {
2612 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
2613 status);
2614 ret = -EIO;
2615 }
2616 }
2617 break;
2618
2619 case QCSAP_PARAM_HIDE_SSID:
2620 {
2621 eHalStatus status = eHAL_STATUS_SUCCESS;
2622 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
2623 if(eHAL_STATUS_SUCCESS != status)
2624 {
2625 hddLog(VOS_TRACE_LEVEL_ERROR,
2626 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002627 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 return status;
2629 }
2630 break;
2631 }
2632
Leo Chang614d2072013-08-22 14:59:44 -07002633 case QCSAP_PARAM_SET_MC_RATE:
2634 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07002635 tSirRateUpdateInd *rateUpdate;
2636
2637 rateUpdate = (tSirRateUpdateInd *)
2638 vos_mem_malloc(sizeof(tSirRateUpdateInd));
2639 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07002640 {
2641 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07002642 "%s: SET_MC_RATE indication alloc fail", __func__);
2643 ret = -1;
2644 break;
2645 }
2646 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
2647
2648 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
2649 /* Ignore unicast */
2650 rateUpdate->ucastDataRate = -1;
2651 rateUpdate->mcastDataRate24GHz = set_value;
2652 rateUpdate->mcastDataRate5GHz = set_value;
2653 rateUpdate->mcastDataRate24GHzTxFlag = 0;
2654 rateUpdate->mcastDataRate5GHzTxFlag = 0;
2655 status = sme_SendRateUpdateInd(hHal, rateUpdate);
2656 if (eHAL_STATUS_SUCCESS != status)
2657 {
2658 hddLog(VOS_TRACE_LEVEL_ERROR,
2659 "%s: SET_MC_RATE failed", __func__);
2660 vos_mem_free(rateUpdate);
2661 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07002662 }
2663 break;
2664 }
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05302665 case QCSAP_PARAM_GET_FRAME_LOGS:
2666 {
2667 if (wlan_hdd_get_frame_logs(pHostapdAdapter, set_value)
2668 != VOS_STATUS_SUCCESS)
2669 {
2670 ret = -EINVAL;
2671 }
2672 break;
2673 }
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302674 case QCSAP_PARAM_SET_PROXIMITY:
2675 {
Padma, Santhosh Kumar98b5d252016-10-17 17:30:41 +05302676 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05302677 break;
2678 }
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302679 case QCSAP_PARAM_SET_WOWL:
2680 {
2681 if (!pHddCtx->is_ap_mode_wow_supported)
2682 {
2683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2684 "%s: Not supported",__func__);
2685 return -ENOTSUPP;
2686 }
2687 switch (set_value)
2688 {
2689 case 0x00:
2690 hdd_exit_wowl(pHostapdAdapter, eWOWL_EXIT_USER);
2691 break;
2692 case 0x01:
2693 case 0x02:
2694 case 0x03:
2695 enable_magic_pkt = (set_value & 0x01) ? 1 : 0;
2696 enable_pattrn_byte_match = (set_value & 0x02) ? 1 : 0;
2697 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
2698 (enable_magic_pkt ? "YES":"NO"),
2699 (enable_pattrn_byte_match ? "YES":"NO"));
2700 hdd_enter_wowl(pHostapdAdapter, enable_magic_pkt,
2701 enable_pattrn_byte_match);
2702 break;
2703 default:
2704 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
2705 ret = -EINVAL;
2706 break;
2707 }
2708 break;
2709 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05302710 case QCSAP_PARAM_CAP_TSF:
2711 {
2712 ret = hdd_capture_tsf(pHostapdAdapter,
2713 (uint32_t *)&set_value, 1);
2714 break;
2715 }
Abhishek Singh02605092017-10-25 14:06:12 +05302716 case QCSAP_PARAM_SET_CHANNEL_CHANGE:
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302717 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) {
2718 ptSapContext sap_ctx;
2719
2720 sap_ctx = VOS_GET_SAP_CB(pVosContext);
2721 if (!sap_ctx) {
2722 hddLog(LOGE, FL("sap_ctx is NULL"));
2723 return -EINVAL;
2724 }
2725 ret = wlansap_chk_n_set_chan_change_in_progress(sap_ctx);
2726 if (ret)
2727 return ret;
2728 INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp);
Abhishek Singh02605092017-10-25 14:06:12 +05302729 hddLog(LOG1, FL("ET Channel Change to new channel= %d"),
2730 set_value);
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302731 ret = wlansap_set_channel_change(pVosContext, set_value, false);
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302732 if (ret) {
2733 wlansap_reset_chan_change_in_progress(sap_ctx);
2734 complete(&sap_ctx->ecsa_info.chan_switch_comp);
2735 }
Abhishek Singh02605092017-10-25 14:06:12 +05302736 } else {
2737 hddLog(LOGE, FL("Channel %d Change Failed, Device in not in SAP/GO mode"),
2738 set_value);
2739 ret = -EINVAL;
2740 }
2741 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 default:
2743 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
2744 sub_cmd, set_value);
2745 ret = -EINVAL;
2746 break;
2747 }
2748
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302749 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 return ret;
2751}
2752
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302753int
2754static iw_softap_setparam(struct net_device *dev,
2755 struct iw_request_info *info,
2756 union iwreq_data *wrqu, char *extra)
2757{
2758 int ret;
2759
2760 vos_ssr_protect(__func__);
2761 ret = __iw_softap_setparam(dev, info, wrqu, extra);
2762 vos_ssr_unprotect(__func__);
2763
2764 return ret;
2765}
Jeff Johnson295189b2012-06-20 16:38:30 -07002766
2767int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302768static __iw_softap_getparam(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 struct iw_request_info *info,
2770 union iwreq_data *wrqu, char *extra)
2771{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302772 hdd_adapter_t *pHostapdAdapter;
2773 tHalHandle hHal;
2774 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 int *value = (int *)extra;
2776 int sub_cmd = value[0];
2777 eHalStatus status;
2778 int ret = 0; /* success */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302779 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302781 ENTER();
2782
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302783 pHostapdAdapter = (netdev_priv(dev));
2784 if (NULL == pHostapdAdapter)
2785 {
2786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2787 "%s: Adapter is NULL",__func__);
2788 return -EINVAL;
2789 }
2790 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2791 ret = wlan_hdd_validate_context(pHddCtx);
2792 if (0 != ret)
2793 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302794 return ret;
2795 }
2796 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2797 if (NULL == hHal)
2798 {
2799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2800 "%s: Hal Context is NULL",__func__);
2801 return -EINVAL;
2802 }
2803 pVosContext = pHddCtx->pvosContext;
2804 if (NULL == pVosContext)
2805 {
2806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2807 "%s: pVosContext Context is NULL",__func__);
2808 return -EINVAL;
2809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 switch (sub_cmd)
2811 {
2812 case QCSAP_PARAM_MAX_ASSOC:
2813 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
2814 if (eHAL_STATUS_SUCCESS != status)
2815 {
c_hpothuffdb5272013-10-02 16:42:35 +05302816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2817 FL("failed to get WNI_CFG_ASSOC_STA_LIMIT from cfg %d"),status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 ret = -EIO;
2819 }
Girish Gowli385be612014-09-18 11:17:20 +05302820
2821#ifdef WLAN_SOFTAP_VSTA_FEATURE
2822 if (pHddCtx->cfg_ini->fEnableVSTASupport)
2823 {
2824 if (*value > VSTA_NUM_ASSOC_STA)
2825 {
2826 *value = VSTA_NUM_ASSOC_STA;
2827 }
2828 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
2829 (*value > (VSTA_NUM_ASSOC_STA -
2830 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
2831 {
2832 *value = (VSTA_NUM_ASSOC_STA -
2833 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
2834 }
2835 }
2836 else
2837#endif
2838 {
2839 if (*value > NUM_ASSOC_STA)
2840 {
2841 *value = NUM_ASSOC_STA;
2842 }
2843 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
2844 (*value > (NUM_ASSOC_STA -
2845 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
2846 {
2847 *value = (NUM_ASSOC_STA -
2848 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
2849 }
2850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302852
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07002854 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 {
c_hpothuffdb5272013-10-02 16:42:35 +05302856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2857 FL("WLANSAP_ClearACL failed"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302858 ret = -EIO;
2859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 *value = 0;
2861 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302862
Jeff Johnson43971f52012-07-17 12:26:56 -07002863 case QCSAP_PARAM_GET_WLAN_DBG:
2864 {
2865 vos_trace_display();
2866 *value = 0;
2867 break;
2868 }
2869
2870 case QCSAP_PARAM_AUTO_CHANNEL:
2871 {
2872 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
2873 break;
2874 }
2875
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 default:
2877 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
2878 ret = -EINVAL;
2879 break;
2880
2881 }
2882
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302883 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 return ret;
2885}
2886
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05302887int
2888static iw_softap_getparam(struct net_device *dev,
2889 struct iw_request_info *info,
2890 union iwreq_data *wrqu, char *extra)
2891{
2892 int ret;
2893
2894 vos_ssr_protect(__func__);
2895 ret = __iw_softap_getparam(dev, info, wrqu, extra);
2896 vos_ssr_unprotect(__func__);
2897
2898 return ret;
2899}
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05302900
2901int
2902static __iw_softap_setchar_getnone(struct net_device *dev,
2903 struct iw_request_info *info,
2904 union iwreq_data *wrqu, char *extra)
2905{
2906 int sub_cmd;
2907 int ret = 0; /* success */
2908 char *pBuffer = NULL;
2909 hdd_adapter_t *pAdapter;
2910 hdd_context_t *pHddCtx;
2911 struct iw_point s_priv_data;
2912
2913 ENTER();
2914
2915 if (!capable(CAP_NET_ADMIN))
2916 {
2917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2918 FL("permission check failed"));
2919 return -EPERM;
2920 }
2921
2922 pAdapter = (netdev_priv(dev));
2923 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2924 ret = wlan_hdd_validate_context(pHddCtx);
2925 if (0 != ret)
2926 {
2927 return ret;
2928 }
2929
2930 if (!pHddCtx->is_ap_mode_wow_supported)
2931 {
2932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2933 "%s: Not supported",__func__);
2934 return -ENOTSUPP;
2935 }
2936
2937 /* helper function to get iwreq_data with compat handling. */
2938 if (hdd_priv_get_data(&s_priv_data, wrqu))
2939 {
2940 return -EINVAL;
2941 }
2942
2943 /* make sure all params are correctly passed to function */
2944 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
2945 {
2946 return -EINVAL;
2947 }
2948
2949 sub_cmd = s_priv_data.flags;
2950
2951 /* ODD number is used for set, copy data using copy_from_user */
2952 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
2953 s_priv_data.length);
2954 if (NULL == pBuffer)
2955 {
2956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2957 "mem_alloc_copy_from_user_helper fail");
2958 return -ENOMEM;
2959 }
2960
2961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2962 "%s: Received length %d", __func__, s_priv_data.length);
2963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2964 "%s: Received data %s", __func__, pBuffer);
2965
2966 switch(sub_cmd)
2967 {
2968 case WE_WOWL_ADD_PTRN:
2969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
2970 ret = hdd_add_wowl_ptrn(pAdapter, pBuffer);
2971 if (!ret)
2972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2973 "Failed to add pattern :%d", ret);
2974 break;
2975 case WE_WOWL_DEL_PTRN:
2976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
2977 ret = hdd_del_wowl_ptrn(pAdapter, pBuffer);
2978 if (!ret)
2979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2980 "Failed to del pattern :%d", ret);
2981 break;
2982 default:
2983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ioctl not supported in SOFTAP");
2984 ret = -EINVAL;
2985 break;
2986 }
2987
2988 kfree(pBuffer);
2989 return ret;
2990}
2991
2992int
2993static iw_softap_setchar_getnone(struct net_device *dev,
2994 struct iw_request_info *info,
2995 union iwreq_data *wrqu, char *extra)
2996{
2997 int ret;
2998
2999 vos_ssr_protect(__func__);
3000 ret = __iw_softap_setchar_getnone(dev, info, wrqu, extra);
3001 vos_ssr_unprotect(__func__);
3002
3003 return ret;
3004}
3005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006/* Usage:
3007 BLACK_LIST = 0
3008 WHITE_LIST = 1
3009 ADD MAC = 0
3010 REMOVE MAC = 1
3011
3012 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3013 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3014 while using this ioctl
3015
3016 Syntax:
3017 iwpriv softap.0 modify_acl
3018 <6 octet mac addr> <list type> <cmd type>
3019
3020 Examples:
3021 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
3022 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
3023 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
3024 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
3025*/
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303026int __iw_softap_modify_acl(struct net_device *dev,
3027 struct iw_request_info *info,
3028 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003029{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303030 hdd_adapter_t *pHostapdAdapter;
3031 v_CONTEXT_t pVosContext;
3032 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 v_BYTE_t *value = (v_BYTE_t*)extra;
3034 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
3035 int listType, cmd, i;
3036 int ret = 0; /* success */
3037
3038 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303039 pHostapdAdapter = (netdev_priv(dev));
3040 if (NULL == pHostapdAdapter)
3041 {
3042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3043 "%s: Adapter is NULL",__func__);
3044 return -EINVAL;
3045 }
3046 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3047 ret = wlan_hdd_validate_context(pHddCtx);
3048 if (0 != ret)
3049 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303050 return ret;
3051 }
3052 pVosContext = pHddCtx->pvosContext;
3053 if (NULL == pVosContext)
3054 {
3055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3056 "%s: Vos Context is NULL",__func__);
3057 return -EINVAL;
3058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
3060 {
3061 pPeerStaMac[i] = *(value+i);
3062 }
3063 listType = (int)(*(value+i));
3064 i++;
3065 cmd = (int)(*(value+i));
3066
Arif Hussain24bafea2013-11-15 15:10:03 -08003067 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
3068 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003069
3070 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
3071 != VOS_STATUS_SUCCESS)
3072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003073 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 ret = -EIO;
3075 }
3076 EXIT();
3077 return ret;
3078}
3079
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303080int iw_softap_modify_acl(struct net_device *dev,
3081 struct iw_request_info *info,
3082 union iwreq_data *wrqu, char *extra)
3083{
3084 int ret;
3085
3086 vos_ssr_protect(__func__);
3087 ret = __iw_softap_modify_acl(dev, info, wrqu, extra);
3088 vos_ssr_unprotect(__func__);
3089
3090 return ret;
3091}
3092
Jeff Johnson295189b2012-06-20 16:38:30 -07003093int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303094static __iw_softap_getchannel(struct net_device *dev,
3095 struct iw_request_info *info,
3096 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003097{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303098 hdd_adapter_t *pHostapdAdapter;
3099 hdd_context_t *pHddCtx;
3100 int ret = 0;
3101 int *value;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303102
3103 ENTER();
3104
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303105 pHostapdAdapter = (netdev_priv(dev));
3106 if (NULL == pHostapdAdapter)
3107 {
3108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3109 "%s: Adapter is NULL",__func__);
3110 return -EINVAL;
3111 }
3112 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3113 ret = wlan_hdd_validate_context(pHddCtx);
3114 if (0 != ret)
3115 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303116 return ret;
3117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003118
Mukul Sharma6d0762c2015-03-05 17:13:47 +05303119 value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003120
Jeff Johnson43971f52012-07-17 12:26:56 -07003121 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303122
3123 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 return 0;
3125}
3126
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303127
Jeff Johnsone7245742012-09-05 17:12:55 -07003128int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303129static iw_softap_getchannel(struct net_device *dev,
3130 struct iw_request_info *info,
3131 union iwreq_data *wrqu, char *extra)
3132{
3133 int ret;
3134
3135 vos_ssr_protect(__func__);
3136 ret = __iw_softap_getchannel(dev, info, wrqu, extra);
3137 vos_ssr_unprotect(__func__);
3138
3139 return ret;
3140}
3141
3142int
3143static __iw_softap_set_max_tx_power(struct net_device *dev,
3144 struct iw_request_info *info,
3145 union iwreq_data *wrqu, char *extra)
Jeff Johnsone7245742012-09-05 17:12:55 -07003146{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303147 hdd_adapter_t *pHostapdAdapter;
3148 tHalHandle hHal;
3149 hdd_context_t *pHddCtx;
schang86c22c42013-03-13 18:41:24 -07003150 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303151 int set_value, ret = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003152 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3153 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3154
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303155 ENTER();
3156
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303157 pHostapdAdapter = (netdev_priv(dev));
3158 if (NULL == pHostapdAdapter)
3159 {
3160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3161 "%s: Adapter is NULL",__func__);
3162 return -EINVAL;
3163 }
3164 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3165 ret = wlan_hdd_validate_context(pHddCtx);
3166 if (0 != ret)
3167 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303168 return ret;
3169 }
3170 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3171 if (NULL == hHal)
3172 {
3173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3174 "%s: Hal Context is NULL",__func__);
3175 return -EINVAL;
3176 }
schang86c22c42013-03-13 18:41:24 -07003177 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07003178 return -ENOMEM;
3179
Leo Changd37675a2013-08-01 13:19:45 -07003180 /* Assign correct slef MAC address */
3181 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
3182 VOS_MAC_ADDR_SIZE);
3183 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
3184 VOS_MAC_ADDR_SIZE);
3185
schang86c22c42013-03-13 18:41:24 -07003186 set_value = value[0];
3187 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
3188 {
3189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003190 __func__);
schang86c22c42013-03-13 18:41:24 -07003191 return -EIO;
3192 }
3193
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303194 EXIT();
schang86c22c42013-03-13 18:41:24 -07003195 return 0;
3196}
3197
3198int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303199static iw_softap_set_max_tx_power(struct net_device *dev,
3200 struct iw_request_info *info,
3201 union iwreq_data *wrqu, char *extra)
3202{
3203 int ret;
3204
3205 vos_ssr_protect(__func__);
3206 ret = __iw_softap_set_max_tx_power(dev, info, wrqu, extra);
3207 vos_ssr_unprotect(__func__);
3208
3209 return ret;
3210}
3211
3212
3213int
3214static __iw_display_data_path_snapshot(struct net_device *dev,
3215 struct iw_request_info *info,
3216 union iwreq_data *wrqu, char *extra)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303217{
3218
3219 /* Function intitiating dumping states of
3220 * HDD(WMM Tx Queues)
3221 * TL State (with Per Client infor)
3222 * DXE Snapshot (Called at the end of TL Snapshot)
3223 */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303224 hdd_adapter_t *pHostapdAdapter;
3225 hdd_context_t *pHddCtx;
3226 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303227
3228 ENTER();
3229
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303230 pHostapdAdapter = (netdev_priv(dev));
3231 if (NULL == pHostapdAdapter)
3232 {
3233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3234 "%s: Adapter is NULL",__func__);
3235 return -EINVAL;
3236 }
3237 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3238 ret = wlan_hdd_validate_context(pHddCtx);
3239 if (0 != ret)
3240 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303241 return ret;
3242 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303243 hdd_wmm_tx_snapshot(pHostapdAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05303244 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303245
3246 EXIT();
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303247 return 0;
3248}
3249
3250int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303251static iw_display_data_path_snapshot(struct net_device *dev,
3252 struct iw_request_info *info,
3253 union iwreq_data *wrqu, char *extra)
3254{
3255 int ret;
3256
3257 vos_ssr_protect(__func__);
3258 ret = __iw_display_data_path_snapshot(dev, info, wrqu, extra);
3259 vos_ssr_unprotect(__func__);
3260
3261 return ret;
3262}
3263
3264int
3265static __iw_softap_set_tx_power(struct net_device *dev,
3266 struct iw_request_info *info,
3267 union iwreq_data *wrqu, char *extra)
schang86c22c42013-03-13 18:41:24 -07003268{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303269 hdd_adapter_t *pHostapdAdapter;
3270 hdd_context_t *pHddCtx;
3271 v_CONTEXT_t pVosContext;
3272 tHalHandle hHal;
schang86c22c42013-03-13 18:41:24 -07003273 int *value = (int *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303274 int set_value, ret = 0;
schang86c22c42013-03-13 18:41:24 -07003275 ptSapContext pSapCtx = NULL;
3276
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303277 ENTER();
3278
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303279 pHostapdAdapter = (netdev_priv(dev));
3280 if (NULL == pHostapdAdapter)
3281 {
3282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3283 "%s: Adapter is NULL",__func__);
3284 return -EINVAL;
3285 }
3286 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3287 ret = wlan_hdd_validate_context(pHddCtx);
3288 if (0 != ret)
3289 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303290 return ret;
3291 }
3292 pVosContext = pHddCtx->pvosContext;
3293 if (NULL == pVosContext)
3294 {
3295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3296 "%s: Vos Context is NULL",__func__);
3297 return -EINVAL;
3298 }
3299 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3300 if (NULL == hHal)
3301 {
3302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3303 "%s: Hal Context is NULL",__func__);
3304 return -EINVAL;
3305 }
schang86c22c42013-03-13 18:41:24 -07003306 if (NULL == value)
3307 return -ENOMEM;
3308
3309 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3310 if (NULL == pSapCtx)
3311 {
3312 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3313 "%s: Invalid SAP pointer from pvosGCtx", __func__);
3314 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003315 }
3316
3317 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07003318 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07003319 {
schang86c22c42013-03-13 18:41:24 -07003320 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07003321 __func__);
3322 return -EIO;
3323 }
3324
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303325 EXIT();
Jeff Johnsone7245742012-09-05 17:12:55 -07003326 return 0;
3327}
3328
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303329int
3330static iw_softap_set_tx_power(struct net_device *dev,
3331 struct iw_request_info *info,
3332 union iwreq_data *wrqu, char *extra)
3333{
3334 int ret;
3335
3336 vos_ssr_protect(__func__);
3337 ret = __iw_softap_set_tx_power(dev, info, wrqu, extra);
3338 vos_ssr_unprotect(__func__);
3339
3340 return ret;
3341}
3342
Kiet Lambcf38522013-10-26 18:28:27 +05303343/**---------------------------------------------------------------------------
3344
3345 \brief iw_softap_set_trafficmonitor() -
3346 This function dynamically enable/disable traffic monitor functonality
3347 the command iwpriv wlanX setTrafficMon <value>.
3348
3349 \param - dev - Pointer to the net device.
3350 - addr - Pointer to the sockaddr.
3351 \return - 0 for success, non zero for failure
3352
3353 --------------------------------------------------------------------------*/
3354
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303355static int __iw_softap_set_trafficmonitor(struct net_device *dev,
3356 struct iw_request_info *info,
3357 union iwreq_data *wrqu, char *extra)
Kiet Lambcf38522013-10-26 18:28:27 +05303358{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303359 hdd_adapter_t *pAdapter;
Sushant Kaushik128a0bb2014-08-07 20:24:54 +05303360 int *isSetTrafficMon = (int *)extra;
Kiet Lambcf38522013-10-26 18:28:27 +05303361 hdd_context_t *pHddCtx;
3362 int status;
3363
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303364 ENTER();
3365
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303366 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kiet Lambcf38522013-10-26 18:28:27 +05303367 if (NULL == pAdapter)
3368 {
3369 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3370 "%s: HDD adapter is Null", __func__);
3371 return -ENODEV;
3372 }
3373
3374 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3375
3376 status = wlan_hdd_validate_context(pHddCtx);
Kiet Lambcf38522013-10-26 18:28:27 +05303377 if (0 != status)
3378 {
Kiet Lambcf38522013-10-26 18:28:27 +05303379 return status;
3380 }
3381
3382 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
3383
3384 if (NULL == isSetTrafficMon)
3385 {
3386 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3387 "%s: Invalid SAP pointer from extra", __func__);
3388 return -ENOMEM;
3389 }
3390
3391 if (TRUE == *isSetTrafficMon)
3392 {
3393 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303394 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303395 {
3396 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3397 "%s: failed to Start Traffic Monitor timer ", __func__ );
3398 return -EIO;
3399 }
3400 }
3401 else if (FALSE == *isSetTrafficMon)
3402 {
3403 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05303404 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter, false))
Kiet Lambcf38522013-10-26 18:28:27 +05303405 {
3406 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
3407 "%s: failed to Stop Traffic Monitor timer ", __func__ );
3408 return -EIO;
3409 }
3410
3411 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303412
3413 EXIT();
Kiet Lambcf38522013-10-26 18:28:27 +05303414 return 0;
3415}
3416
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303417static int iw_softap_set_trafficmonitor(struct net_device *dev,
3418 struct iw_request_info *info,
3419 union iwreq_data *wrqu, char *extra)
3420{
3421 int ret;
3422
3423 vos_ssr_protect(__func__);
3424 ret = __iw_softap_set_trafficmonitor(dev, info, wrqu, extra);
3425 vos_ssr_unprotect(__func__);
3426
3427 return ret;
3428}
3429
Jeff Johnson295189b2012-06-20 16:38:30 -07003430#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
3431
3432int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303433static __iw_softap_getassoc_stamacaddr(struct net_device *dev,
3434 struct iw_request_info *info,
3435 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003436{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303437 hdd_adapter_t *pHostapdAdapter;
3438 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303439 hdd_station_info_t *pStaInfo = NULL;
Jeff Johnson224f3702014-03-26 11:09:47 -07003440 char *buf;
3441 int cnt = 0;
3442 int left;
3443 int ret = 0;
3444 /* maclist_index must be u32 to match userspace */
3445 u32 maclist_index;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303446 v_CONTEXT_t pVosContext = NULL;
3447 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303448
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303449 ENTER();
3450
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303451 pHostapdAdapter = (netdev_priv(dev));
3452 if (NULL == pHostapdAdapter)
3453 {
3454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3455 "%s: Adapter is NULL",__func__);
3456 return -EINVAL;
3457 }
3458 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3459 ret = wlan_hdd_validate_context(pHddCtx);
3460 if (0 != ret)
3461 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303462 return ret;
3463 }
3464
Jeff Johnson224f3702014-03-26 11:09:47 -07003465 /*
3466 * NOTE WELL: this is a "get" ioctl but it uses an even ioctl
3467 * number, and even numbered iocts are supposed to have "set"
3468 * semantics. Hence the wireless extensions support in the kernel
3469 * won't correctly copy the result to userspace, so the ioctl
3470 * handler itself must copy the data. Output format is 32-bit
3471 * record length, followed by 0 or more 6-byte STA MAC addresses.
3472 *
3473 * Further note that due to the incorrect semantics, the "iwpriv"
3474 * userspace application is unable to correctly invoke this API,
3475 * hence it is not registered in the hostapd_private_args. This
3476 * API can only be invoked by directly invoking the ioctl() system
3477 * call.
3478 */
Jeff Johnson295189b2012-06-20 16:38:30 -07003479
Jeff Johnson224f3702014-03-26 11:09:47 -07003480 /* make sure userspace allocated a reasonable buffer size */
3481 if (wrqu->data.length < sizeof(maclist_index)) {
3482 hddLog(LOG1, "%s: invalid userspace buffer", __func__);
3483 return -EINVAL;
Arif Hussained667642013-10-27 23:01:14 -07003484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003485
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303486 pVosContext = ( WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
3487 pSapCtx = VOS_GET_SAP_CB(pVosContext);
3488 if(pSapCtx == NULL){
3489 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
3490 FL("psapCtx is NULL"));
3491 return -EFAULT;
3492 }
Hema Aparna Medicharla749399f2015-03-10 13:02:04 +05303493
3494 /* allocate local buffer to build the response */
3495 buf = kmalloc(wrqu->data.length, GFP_KERNEL);
3496 if (!buf) {
3497 hddLog(LOG1, "%s: failed to allocate response buffer", __func__);
3498 return -ENOMEM;
3499 }
3500
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303501 pStaInfo = pSapCtx->aStaInfo;
Jeff Johnson224f3702014-03-26 11:09:47 -07003502 /* start indexing beyond where the record count will be written */
3503 maclist_index = sizeof(maclist_index);
3504 left = wrqu->data.length - maclist_index;
3505
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303506 spin_lock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003507 while ((cnt < WLAN_MAX_STA_COUNT) && (left >= VOS_MAC_ADDR_SIZE)) {
3508 if ((pStaInfo[cnt].isUsed) &&
3509 (!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes))) {
3510 memcpy(&buf[maclist_index], &(pStaInfo[cnt].macAddrSTA),
3511 VOS_MAC_ADDR_SIZE);
3512 maclist_index += VOS_MAC_ADDR_SIZE;
3513 left -= VOS_MAC_ADDR_SIZE;
3514 }
3515 cnt++;
3516 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05303517 spin_unlock_bh(&pSapCtx->staInfo_lock);
Jeff Johnson224f3702014-03-26 11:09:47 -07003518
3519 *((u32 *)buf) = maclist_index;
3520 wrqu->data.length = maclist_index;
3521 if (copy_to_user(wrqu->data.pointer, buf, maclist_index)) {
3522 hddLog(LOG1, "%s: failed to copy response to user buffer", __func__);
3523 ret = -EFAULT;
3524 }
3525 kfree(buf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303526
3527 EXIT();
Jeff Johnson224f3702014-03-26 11:09:47 -07003528 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003529}
3530
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303531int
3532static iw_softap_getassoc_stamacaddr(struct net_device *dev,
3533 struct iw_request_info *info,
3534 union iwreq_data *wrqu, char *extra)
3535{
3536 int ret;
3537
3538 vos_ssr_protect(__func__);
3539 ret = __iw_softap_getassoc_stamacaddr(dev, info, wrqu, extra);
3540 vos_ssr_unprotect(__func__);
3541
3542 return ret;
3543}
3544
Jeff Johnson295189b2012-06-20 16:38:30 -07003545/* Usage:
3546 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
3547 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
3548 while using this ioctl
3549
3550 Syntax:
3551 iwpriv softap.0 disassoc_sta <6 octet mac address>
3552
3553 e.g.
3554 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
3555 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
3556*/
3557
3558int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303559static __iw_softap_disassoc_sta(struct net_device *dev,
3560 struct iw_request_info *info,
3561 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003562{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303563 hdd_adapter_t *pHostapdAdapter;
3564 hdd_context_t *pHddCtx;
3565 v_U8_t *peerMacAddr;
3566 int ret = 0;
3567
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 ENTER();
Hanumantha Reddy Pothula6633f3f2015-10-27 23:01:21 +05303569
3570 if (!capable(CAP_NET_ADMIN)) {
3571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3572 FL("permission check failed"));
3573 return -EPERM;
3574 }
3575
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303576 pHostapdAdapter = (netdev_priv(dev));
3577 if (NULL == pHostapdAdapter)
3578 {
3579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3580 "%s: Adapter is NULL",__func__);
3581 return -EINVAL;
3582 }
3583 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3584 ret = wlan_hdd_validate_context(pHddCtx);
3585 if (0 != ret)
3586 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303587 return ret;
3588 }
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303589 /* iwpriv tool or framework calls this ioctl with
3590 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05303592 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07003593
Arif Hussain24bafea2013-11-15 15:10:03 -08003594 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
3595 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
3597 EXIT();
3598 return 0;
3599}
3600
3601int
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303602static iw_softap_disassoc_sta(struct net_device *dev,
3603 struct iw_request_info *info,
3604 union iwreq_data *wrqu, char *extra)
3605{
3606 int ret;
3607
3608 vos_ssr_protect(__func__);
3609 ret = __iw_softap_disassoc_sta(dev, info, wrqu, extra);
3610 vos_ssr_unprotect(__func__);
3611
3612 return ret;
3613}
3614
3615int
3616static __iw_softap_ap_stats(struct net_device *dev,
3617 struct iw_request_info *info,
3618 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003619{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303620 hdd_adapter_t *pHostapdAdapter;
3621 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 WLANTL_TRANSFER_STA_TYPE statBuffer;
3623 char *pstatbuf;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303624 int len, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003625
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303626 ENTER();
3627
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303628 pHostapdAdapter = (netdev_priv(dev));
3629 if (NULL == pHostapdAdapter)
3630 {
3631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3632 "%s: Adapter is NULL",__func__);
3633 return -EINVAL;
3634 }
3635 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3636 ret = wlan_hdd_validate_context(pHddCtx);
3637 if (0 != ret)
3638 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303639 return ret;
3640 }
Rajesh Chauhana0516c62014-01-30 16:11:18 -08003641 memset(&statBuffer, 0, sizeof(statBuffer));
Arif Hussained667642013-10-27 23:01:14 -07003642 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
3643 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07003644
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303645 pstatbuf = kzalloc(QCSAP_MAX_WSC_IE, GFP_KERNEL);
Arif Hussained667642013-10-27 23:01:14 -07003646 if(NULL == pstatbuf) {
3647 hddLog(LOG1, "unable to allocate memory");
3648 return -ENOMEM;
3649 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303650
3651 len = scnprintf(pstatbuf, QCSAP_MAX_WSC_IE,
Arif Hussained667642013-10-27 23:01:14 -07003652 "RUF=%d RMF=%d RBF=%d "
3653 "RUB=%d RMB=%d RBB=%d "
3654 "TUF=%d TMF=%d TBF=%d "
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303655 "TUB=%d TMB=%d TBB=%d ",
Arif Hussained667642013-10-27 23:01:14 -07003656 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
3657 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
3658 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
3659 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
3660 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
3661 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003662
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303663 if (len >= QCSAP_MAX_WSC_IE) {
Arif Hussained667642013-10-27 23:01:14 -07003664 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
3665 kfree(pstatbuf);
3666 return -EFAULT;
3667 }
Sandeep Puligilla38e31bf2014-05-12 15:37:02 +05303668
3669 strlcpy(extra, pstatbuf, len);
3670 wrqu->data.length = len;
Arif Hussained667642013-10-27 23:01:14 -07003671 kfree(pstatbuf);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303672
3673 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 return 0;
3675}
Bhargav Shah7f03b812015-08-21 11:17:32 +05303676int
3677static __iw_softap_ap_get_stats(struct net_device *dev,
3678 struct iw_request_info *info,
3679 union iwreq_data *wrqu, char *extra)
3680{
3681 hdd_adapter_t *pAdapter;
3682 hdd_tx_rx_stats_t *pStats;
3683
3684 ENTER();
3685 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3686 if (NULL == pAdapter)
3687 {
3688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3689 "%s: Adapter is NULL",__func__);
3690 return -EINVAL;
3691 }
3692
3693 pStats = &pAdapter->hdd_stats.hddTxRxStats;
3694 snprintf(extra, QCSAP_MAX_STR_LEN,
3695 "\nTransmit"
3696 "\ncalled %u, dropped %u, backpressured %u, queued %u"
3697 "\n dropped BK %u, BE %u, VI %u, VO %u"
3698 "\n classified BK %u, BE %u, VI %u, VO %u"
3699 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
3700 "\n queued BK %u, BE %u, VI %u, VO %u"
3701 "\nfetched %u, empty %u, lowres %u, deqerr %u"
3702 "\ndequeued %u, depressured %u, deque-depressured %u,\
3703 completed %u, flushed %u"
3704 "\n fetched BK %u, BE %u, VI %u, VO %u"
3705 "\n dequeued BK %u, BE %u, VI %u, VO %u"
3706 "\n depressured BK %u, BE %u, VI %u, VO %u"
3707 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
3708 "\n flushed BK %u, BE %u, VI %u, VO %u"
3709 "\n\nReceive"
3710 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
3711 "\n\nResetsStats"
3712 "\n",
3713 pStats->txXmitCalled,
3714 pStats->txXmitDropped,
3715 pStats->txXmitBackPressured,
3716 pStats->txXmitQueued,
3717
3718 pStats->txXmitDroppedAC[WLANTL_AC_BK],
3719 pStats->txXmitDroppedAC[WLANTL_AC_BE],
3720 pStats->txXmitDroppedAC[WLANTL_AC_VI],
3721 pStats->txXmitDroppedAC[WLANTL_AC_VO],
3722
3723 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
3724 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
3725 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
3726 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
3727
3728 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
3729 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
3730 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
3731 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
3732
3733 pStats->txXmitQueuedAC[WLANTL_AC_BK],
3734 pStats->txXmitQueuedAC[WLANTL_AC_BE],
3735 pStats->txXmitQueuedAC[WLANTL_AC_VI],
3736 pStats->txXmitQueuedAC[WLANTL_AC_VO],
3737
3738 pStats->txFetched,
3739 pStats->txFetchEmpty,
3740 pStats->txFetchLowResources,
3741 pStats->txFetchDequeueError,
3742
3743 pStats->txFetchDequeued,
3744 pStats->txFetchDePressured,
3745 pStats->txDequeDePressured,
3746 pStats->txCompleted,
3747 pStats->txFlushed,
3748
3749 pStats->txFetchedAC[WLANTL_AC_BK],
3750 pStats->txFetchedAC[WLANTL_AC_BE],
3751 pStats->txFetchedAC[WLANTL_AC_VI],
3752 pStats->txFetchedAC[WLANTL_AC_VO],
3753
3754 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
3755 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
3756 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
3757 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
3758
3759 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
3760 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
3761 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
3762 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
3763
3764 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
3765 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
3766 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
3767 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
3768
3769 pStats->txFlushedAC[WLANTL_AC_BK],
3770 pStats->txFlushedAC[WLANTL_AC_BE],
3771 pStats->txFlushedAC[WLANTL_AC_VI],
3772 pStats->txFlushedAC[WLANTL_AC_VO],
3773
3774 pStats->rxChains,
3775 pStats->rxPackets,
3776 pStats->rxDropped,
3777 pStats->rxDelivered,
3778 pStats->rxRefused
3779 );
3780
3781 wrqu->data.length = strlen(extra) + 1;
3782
3783 return 0;
3784}
3785
3786int
3787static __iw_softap_ap_clear_stats(struct net_device *dev,
3788 struct iw_request_info *info,
3789 union iwreq_data *wrqu, char *extra)
3790{
3791 hdd_adapter_t *pAdapter;
3792
3793 ENTER();
3794
3795 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3796 if (NULL == pAdapter)
3797 {
3798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3799 "%s: Adapter is NULL",__func__);
3800 return -EINVAL;
3801 }
3802
3803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
3804 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
3805 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
3806 return 0;
3807}
3808
3809
3810int
3811static iw_softap_get_stats(struct net_device *dev,
3812 struct iw_request_info *info,
3813 union iwreq_data *wrqu, char *extra)
3814{
3815 int ret;
3816 vos_ssr_protect(__func__);
3817 ret = __iw_softap_ap_get_stats(dev, info, wrqu, extra);
3818 vos_ssr_unprotect(__func__);
3819 return ret;
3820}
3821
3822int
3823static iw_softap_clear_stats(struct net_device *dev,
3824 struct iw_request_info *info,
3825 union iwreq_data *wrqu, char *extra)
3826{
3827 int ret;
3828 vos_ssr_protect(__func__);
3829 ret = __iw_softap_ap_clear_stats(dev, info, wrqu, extra);
3830 vos_ssr_unprotect(__func__);
3831 return ret;
3832}
Jeff Johnson295189b2012-06-20 16:38:30 -07003833
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303834int
3835static iw_softap_ap_stats(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 struct iw_request_info *info,
3837 union iwreq_data *wrqu, char *extra)
3838{
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303839 int ret;
3840
3841 vos_ssr_protect(__func__);
3842 ret = __iw_softap_ap_stats(dev, info, wrqu, extra);
3843 vos_ssr_unprotect(__func__);
3844
3845 return ret;
3846}
3847
Manjeet Singh3ed79242017-01-11 19:04:32 +05303848/**
3849 * __iw_softap_get_three() - return three value to upper layer.
3850 *
3851 * @dev: pointer of net_device of this wireless card
3852 * @info: meta data about Request sent
3853 * @wrqu: include request info
3854 * @extra: buf used for in/out
3855 *
3856 * Return: execute result
3857 */
3858static int __iw_softap_get_three(struct net_device *dev,
3859 struct iw_request_info *info,
3860 union iwreq_data *wrqu, char *extra)
3861{
3862 uint32_t *value = (uint32_t *)extra;
3863 uint32_t sub_cmd = value[0];
3864 int ret = 0; /* success */
3865
3866 hdd_adapter_t *padapter = WLAN_HDD_GET_PRIV_PTR(dev);
3867
3868 switch (sub_cmd) {
3869 case QCSAP_IOCTL_GET_TSF:
3870 ret = hdd_indicate_tsf(padapter, value, 3);
3871 break;
3872 default:
3873 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
3874 break;
3875 }
3876 return ret;
3877}
3878
3879
3880/**
3881 * iw_softap_get_three() - return three value to upper layer.
3882 *
3883 * @dev: pointer of net_device of this wireless card
3884 * @info: meta data about Request sent
3885 * @wrqu: include request info
3886 * @extra: buf used for in/Output
3887 *
3888 * Return: execute result
3889 */
3890static int iw_softap_get_three(struct net_device *dev,
3891 struct iw_request_info *info,
3892 union iwreq_data *wrqu, char *extra)
3893{
3894 int ret;
3895
3896 vos_ssr_protect(__func__);
3897 ret = __iw_softap_get_three(dev, info, wrqu, extra);
3898 vos_ssr_unprotect(__func__);
3899
3900 return ret;
3901}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303902static int __iw_softap_set_channel_range(struct net_device *dev,
3903 struct iw_request_info *info,
3904 union iwreq_data *wrqu, char *extra)
3905{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303906 hdd_adapter_t *pHostapdAdapter;
3907 tHalHandle hHal;
3908 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 int *value = (int *)extra;
3910 int startChannel = value[0];
3911 int endChannel = value[1];
3912 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07003913 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 int ret = 0; /* success */
3915
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303916 ENTER();
3917
Hanumantha Reddy Pothulabcb1abf2015-10-28 00:21:00 +05303918 if (!capable(CAP_NET_ADMIN))
3919 {
3920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3921 FL("permission check failed"));
3922 return -EPERM;
3923 }
3924
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303925 pHostapdAdapter = (netdev_priv(dev));
3926 if (NULL == pHostapdAdapter)
3927 {
3928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3929 "%s: Adapter is NULL",__func__);
3930 return -EINVAL;
3931 }
3932 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3933 ret = wlan_hdd_validate_context(pHddCtx);
3934 if (0 != ret)
3935 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303936 return ret;
3937 }
3938 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
3939 if (NULL == hHal)
3940 {
3941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3942 "%s: Hal Context is NULL",__func__);
3943 return -EINVAL;
3944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
3946 if(status != VOS_STATUS_SUCCESS)
3947 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003948 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 startChannel,endChannel, band);
3950 ret = -EINVAL;
3951 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08003952
3953 pHddCtx->is_dynamic_channel_range_set = 1;
3954
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303955 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 return ret;
3957}
3958
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05303959static int iw_softap_set_channel_range(struct net_device *dev,
3960 struct iw_request_info *info,
3961 union iwreq_data *wrqu, char *extra)
3962{
3963 int ret;
3964
3965 vos_ssr_protect(__func__);
3966 ret = __iw_softap_set_channel_range(dev, info, wrqu, extra);
3967 vos_ssr_unprotect(__func__);
3968
3969 return ret;
3970}
3971
3972
3973int __iw_softap_get_channel_list(struct net_device *dev,
3974 struct iw_request_info *info,
3975 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003976{
3977 v_U32_t num_channels = 0;
3978 v_U8_t i = 0;
3979 v_U8_t bandStartChannel = RF_CHAN_1;
3980 v_U8_t bandEndChannel = RF_CHAN_165;
3981 v_U32_t temp_num_channels = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303982 hdd_adapter_t *pHostapdAdapter;
3983 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07003986 eCsrBand curBand = eCSR_BAND_ALL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303987 hdd_context_t *pHddCtx;
3988 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303989
3990 ENTER();
3991
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303992 pHostapdAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3993 if (NULL == pHostapdAdapter)
3994 {
3995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3996 "%s: Adapter is NULL",__func__);
3997 return -EINVAL;
3998 }
3999 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4000 ret = wlan_hdd_validate_context(pHddCtx);
4001 if (0 != ret)
4002 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304003 return ret;
4004 }
4005 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
4006 if (NULL == hHal)
4007 {
4008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4009 "%s: Hal Context is NULL",__func__);
4010 return -EINVAL;
4011 }
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07004012 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
4013 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004014 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07004015 return -EIO;
4016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 wrqu->data.length = sizeof(tChannelListInfo);
4018 ENTER();
4019
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07004020 if (eCSR_BAND_24 == curBand)
4021 {
4022 bandStartChannel = RF_CHAN_1;
4023 bandEndChannel = RF_CHAN_14;
4024 }
4025 else if (eCSR_BAND_5G == curBand)
4026 {
4027 bandStartChannel = RF_CHAN_36;
4028 bandEndChannel = RF_CHAN_165;
4029 }
4030
Arif Hussain6d2a3322013-11-17 19:50:10 -08004031 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05304032 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07004033 bandStartChannel, bandEndChannel );
4034
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 for( i = bandStartChannel; i <= bandEndChannel; i++ )
4036 {
4037 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
4038 {
4039 channel_list->channels[num_channels] = rfChannels[i].channelNum;
4040 num_channels++;
4041 }
4042 }
4043
4044 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
4045
4046 temp_num_channels = num_channels;
4047
4048 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
4049 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304050 hddLog(LOGE,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08004051 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 }
4053
Agarwal Ashish7b557c02014-07-02 12:32:39 +05304054 if(REGDOMAIN_FCC == domainIdCurrentSoftap &&
4055 pHddCtx->cfg_ini->gEnableStrictRegulatoryForFCC )
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 {
4057 for(i = 0; i < temp_num_channels; i++)
4058 {
4059
4060 if((channel_list->channels[i] > 35) &&
4061 (channel_list->channels[i] < 49))
4062 {
4063 vos_mem_move(&channel_list->channels[i],
4064 &channel_list->channels[i+1],
4065 temp_num_channels - (i-1));
4066 num_channels--;
4067 temp_num_channels--;
4068 i--;
4069 }
4070 }
4071 }
4072
Arif Hussain6d2a3322013-11-17 19:50:10 -08004073 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 channel_list->num_channels = num_channels;
4076 EXIT();
4077
4078 return 0;
4079}
4080
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304081int iw_softap_get_channel_list(struct net_device *dev,
4082 struct iw_request_info *info,
4083 union iwreq_data *wrqu, char *extra)
4084{
4085 int ret;
4086
4087 vos_ssr_protect(__func__);
4088 ret = __iw_softap_get_channel_list(dev, info, wrqu, extra);
4089 vos_ssr_unprotect(__func__);
4090
4091 return ret;
4092}
4093
4094static
4095int __iw_get_genie(struct net_device *dev,
4096 struct iw_request_info *info,
4097 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004098{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304099 hdd_adapter_t *pHostapdAdapter;
4100 hdd_context_t *pHddCtx;
4101 v_CONTEXT_t pVosContext;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304102 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
4104 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304105 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304106
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304108
4109 pHostapdAdapter = (netdev_priv(dev));
4110 if (NULL == pHostapdAdapter)
4111 {
4112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4113 "%s: Adapter is NULL",__func__);
4114 return -EINVAL;
4115 }
4116 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4117 ret = wlan_hdd_validate_context(pHddCtx);
4118 if (0 != ret)
4119 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304120 return ret;
4121 }
4122 pVosContext = pHddCtx->pvosContext;
4123 if (NULL == pVosContext)
4124 {
4125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4126 "%s: vos context is not valid ",__func__);
4127 return -EINVAL;
4128 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004129 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
4131 status = WLANSap_getstationIE_information(pVosContext,
4132 &length,
4133 genIeBytes);
Manjeet Singh0fc12712016-08-02 19:08:02 +05304134
4135 if (VOS_STATUS_SUCCESS != status) {
4136 hddLog(LOGE, FL("failed to get sta ies"));
Arif Hussained667642013-10-27 23:01:14 -07004137 return -EFAULT;
4138 }
Manjeet Singh0fc12712016-08-02 19:08:02 +05304139
Arif Hussained667642013-10-27 23:01:14 -07004140 wrqu->data.length = length;
Manjeet Singh0fc12712016-08-02 19:08:02 +05304141 if (length > DOT11F_IE_RSN_MAX_LEN) {
4142 hddLog(LOGE,
4143 FL("invalid buffer length length:%d"), length);
4144 return -E2BIG;
4145 }
4146
4147 vos_mem_copy(extra, genIeBytes, length);
4148
4149 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length);
4150
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 EXIT();
4152 return 0;
4153}
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304154
4155static
4156int iw_get_genie(struct net_device *dev,
4157 struct iw_request_info *info,
4158 union iwreq_data *wrqu, char *extra)
4159{
4160 int ret;
4161
4162 vos_ssr_protect(__func__);
4163 ret = __iw_get_genie(dev, info, wrqu, extra);
4164 vos_ssr_unprotect(__func__);
4165
4166 return ret;
4167}
4168
4169static
4170int __iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4171 struct iw_request_info *info,
4172 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004173{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304174 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07004175 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304176 hdd_ap_ctx_t *pHddApCtx;
4177 hdd_context_t *pHddCtx;
4178 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304179
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07004181
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304182 pHostapdAdapter = (netdev_priv(dev));
4183 if (NULL == pHostapdAdapter)
4184 {
4185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4186 "%s: Adapter is NULL",__func__);
4187 return -EINVAL;
4188 }
4189 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4190 ret = wlan_hdd_validate_context(pHddCtx);
4191 if (0 != ret)
4192 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304193 return ret;
4194 }
4195 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4196 if (NULL == pHddApCtx)
4197 {
4198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4199 "%s: AP context is NULL",__func__);
4200 return -EINVAL;
4201 }
4202
Arif Hussain6d2a3322013-11-17 19:50:10 -08004203 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07004204 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
4205
4206 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
4207 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
4208 pHddApCtx->WPSPBCProbeReq.probeReqIE,
4209 WPSPBCProbeReqIEs.probeReqIELen);
4210 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
4211 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
4212 sizeof(v_MACADDR_t));
4213 if (copy_to_user(wrqu->data.pointer,
4214 (void *)&WPSPBCProbeReqIEs,
4215 sizeof(WPSPBCProbeReqIEs)))
4216 {
4217 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
4218 return -EFAULT;
4219 }
4220 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004221 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07004222 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 up(&pHddApCtx->semWpsPBCOverlapInd);
4224 EXIT();
4225 return 0;
4226}
4227
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304228static
4229int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
4230 struct iw_request_info *info,
4231 union iwreq_data *wrqu, char *extra)
4232{
4233 int ret;
4234
4235 vos_ssr_protect(__func__);
4236 ret = __iw_get_WPSPBCProbeReqIEs(dev, info, wrqu, extra);
4237 vos_ssr_unprotect(__func__);
4238
4239 return ret;
4240}
4241
Jeff Johnson295189b2012-06-20 16:38:30 -07004242/**---------------------------------------------------------------------------
4243
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304244 \brief __iw_set_auth_hostap() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 This function sets the auth type received from the wpa_supplicant.
4246
4247 \param - dev - Pointer to the net device.
4248 - info - Pointer to the iw_request_info.
4249 - wrqu - Pointer to the iwreq_data.
4250 - extra - Pointer to the data.
4251 \return - 0 for success, non zero for failure
4252
4253 --------------------------------------------------------------------------*/
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304254int __iw_set_auth_hostap(struct net_device *dev,
4255 struct iw_request_info *info,
4256 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004257{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304258 hdd_adapter_t *pAdapter;
4259 hdd_context_t *pHddCtx;
4260 hdd_wext_state_t *pWextState;
4261 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304262
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304264
4265 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4266 if (NULL == pAdapter)
4267 {
4268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4269 "%s: Adapter is NULL",__func__);
4270 return -EINVAL;
4271 }
4272
4273 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4274 ret = wlan_hdd_validate_context(pHddCtx);
4275 if (0 != ret)
4276 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304277 return ret;
4278 }
4279 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4280 if (NULL == pWextState)
4281 {
4282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4283 "%s: pWextState is NULL",__func__);
4284 return -EINVAL;
4285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 switch(wrqu->param.flags & IW_AUTH_INDEX)
4287 {
4288 case IW_AUTH_TKIP_COUNTERMEASURES:
4289 {
4290 if(wrqu->param.value) {
4291 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4292 "Counter Measure started %d", wrqu->param.value);
4293 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304294 }
4295 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4297 "Counter Measure stopped=%d", wrqu->param.value);
4298 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4299 }
4300
4301 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
4302 wrqu->param.value);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304305
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 default:
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304307
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004308 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 wrqu->param.flags & IW_AUTH_INDEX);
4310 break;
4311 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304312
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 EXIT();
4314 return 0;
4315}
4316
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304317int iw_set_auth_hostap(struct net_device *dev,
4318 struct iw_request_info *info,
4319 union iwreq_data *wrqu,char *extra)
4320{
4321 int ret;
4322
4323 vos_ssr_protect(__func__);
4324 ret = __iw_set_auth_hostap(dev, info, wrqu, extra);
4325 vos_ssr_unprotect(__func__);
4326
4327 return ret;
4328}
4329
4330static int __iw_set_ap_encodeext(struct net_device *dev,
4331 struct iw_request_info *info,
4332 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004333{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304334 hdd_adapter_t *pHostapdAdapter;
4335 v_CONTEXT_t pVosContext;
4336 hdd_context_t *pHddCtx;
4337 hdd_ap_ctx_t *pHddApCtx;
Jeff Johnson43971f52012-07-17 12:26:56 -07004338 int retval = 0;
4339 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4341 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4342 int key_index;
4343 struct iw_point *encoding = &wrqu->encoding;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304344 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07004345// tCsrRoamRemoveKey RemoveKey;
4346 int i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304347
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304348 ENTER();
4349 pHostapdAdapter = (netdev_priv(dev));
4350 if (NULL == pHostapdAdapter)
4351 {
4352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4353 "%s: Adapter is NULL",__func__);
4354 return -EINVAL;
4355 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004356
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304357 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4358 retval = wlan_hdd_validate_context(pHddCtx);
4359 if (0 != retval)
4360 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304361 return retval;
4362 }
4363 pVosContext = pHddCtx->pvosContext;
4364 if (NULL == pVosContext)
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4367 "%s: pVosContext is NULL",__func__);
4368 return -EINVAL;
4369 }
4370 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4371 if (NULL == pHddApCtx)
4372 {
4373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4374 "%s: AP Context is NULL",__func__);
4375 return -EINVAL;
4376 }
4377
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 key_index = encoding->flags & IW_ENCODE_INDEX;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304379
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 if(key_index > 0) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304381
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 /*Convert from 1-based to 0-based keying*/
4383 key_index--;
4384 }
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304385 if(!ext->key_len || ext->key_len > CSR_MAX_KEY_LEN) {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304386#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 /*Set the encrytion type to NONE*/
4388#if 0
4389 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4390#endif
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304391
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 RemoveKey.keyId = key_index;
4393 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4394 /*Key direction for group is RX only*/
4395 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4396 }
4397 else {
4398 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4399 }
4400 switch(ext->alg)
4401 {
4402 case IW_ENCODE_ALG_NONE:
4403 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4404 break;
4405 case IW_ENCODE_ALG_WEP:
4406 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4407 break;
4408 case IW_ENCODE_ALG_TKIP:
4409 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07004410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 case IW_ENCODE_ALG_CCMP:
4412 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
4413 break;
4414 default:
4415 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4416 break;
4417 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08004418 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 -07004419 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004421 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 );
Jeff Johnson43971f52012-07-17 12:26:56 -07004423 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
4424 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 {
4426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07004427 __LINE__, vstatus );
4428 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 }
Jeff Johnson43971f52012-07-17 12:26:56 -07004430#endif
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304431 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004432
Jeff Johnson43971f52012-07-17 12:26:56 -07004433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004434
4435 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4436
4437 setKey.keyId = key_index;
4438 setKey.keyLength = ext->key_len;
4439
Ashish Kumar Dhanotiya2855c952018-01-02 19:52:26 +05304440 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004441
4442 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4443 /*Key direction for group is RX only*/
4444 setKey.keyDirection = eSIR_RX_ONLY;
4445 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4446 }
4447 else {
4448
4449 setKey.keyDirection = eSIR_TX_RX;
4450 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4451 }
4452 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4453 {
4454 setKey.keyDirection = eSIR_TX_DEFAULT;
4455 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4456 }
4457
4458 /*For supplicant pae role is zero*/
4459 setKey.paeRole = 0;
4460
4461 switch(ext->alg)
4462 {
4463 case IW_ENCODE_ALG_NONE:
4464 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4465 break;
4466
4467 case IW_ENCODE_ALG_WEP:
4468 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4469 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004470 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 break;
4472
4473 case IW_ENCODE_ALG_TKIP:
4474 {
4475 v_U8_t *pKey = &setKey.Key[0];
4476
4477 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4478
4479 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4480
4481 /*Supplicant sends the 32bytes key in this order
4482
4483 |--------------|----------|----------|
4484 | Tk1 |TX-MIC | RX Mic |
4485 |--------------|----------|----------|
4486 <---16bytes---><--8bytes--><--8bytes-->
4487
4488 */
4489 /*Sme expects the 32 bytes key to be in the below order
4490
4491 |--------------|----------|----------|
4492 | Tk1 |RX-MIC | TX Mic |
4493 |--------------|----------|----------|
4494 <---16bytes---><--8bytes--><--8bytes-->
4495 */
4496 /* Copy the Temporal Key 1 (TK1) */
4497 vos_mem_copy(pKey,ext->key,16);
4498
4499 /*Copy the rx mic first*/
4500 vos_mem_copy(&pKey[16],&ext->key[24],8);
4501
4502 /*Copy the tx mic */
4503 vos_mem_copy(&pKey[24],&ext->key[16],8);
4504
4505 }
4506 break;
4507
4508 case IW_ENCODE_ALG_CCMP:
4509 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4510 break;
4511
4512 default:
4513 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4514 break;
4515 }
4516
4517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304518 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 setKey.keyId);
4520 for(i=0; i< ext->key_len; i++)
4521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4522 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07004523
4524 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
4525 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 {
4527 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07004528 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
4529 retval = -EINVAL;
4530 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304531
4532 EXIT();
4533 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07004534}
Jeff Johnson43971f52012-07-17 12:26:56 -07004535
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304536static int iw_set_ap_encodeext(struct net_device *dev,
4537 struct iw_request_info *info,
4538 union iwreq_data *wrqu, char *extra)
4539{
4540 int ret;
4541
4542 vos_ssr_protect(__func__);
4543 ret = __iw_set_ap_encodeext(dev, info, wrqu, extra);
4544 vos_ssr_unprotect(__func__);
4545
4546 return ret;
4547}
Jeff Johnson43971f52012-07-17 12:26:56 -07004548
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304549static int __iw_set_ap_mlme(struct net_device *dev,
4550 struct iw_request_info *info,
4551 union iwreq_data *wrqu,
4552 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004553{
4554#if 0
4555 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4556 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4557
4558 ENTER();
4559
4560 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4561 switch (mlme->cmd) {
4562 case IW_MLME_DISASSOC:
4563 case IW_MLME_DEAUTH:
4564 hddLog(LOG1, "Station disassociate");
4565 if( pAdapter->conn_info.connState == eConnectionState_Associated )
4566 {
4567 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4568
4569 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4570 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4571
4572 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
4573
4574 //clear all the reason codes
4575 if (status != 0)
4576 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004577 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 }
4579
4580 netif_stop_queue(dev);
4581 netif_carrier_off(dev);
4582 }
4583 else
4584 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004585 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 -07004586 }
4587 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004588 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 return -EINVAL;
4590 }//end of switch
4591 EXIT();
4592#endif
4593 return 0;
4594// return status;
4595}
4596
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304597static int iw_set_ap_mlme(struct net_device *dev,
4598 struct iw_request_info *info,
4599 union iwreq_data *wrqu,
4600 char *extra)
4601{
4602 int ret;
4603
4604 vos_ssr_protect(__func__);
4605 ret = __iw_set_ap_mlme(dev, info, wrqu, extra);
4606 vos_ssr_unprotect(__func__);
4607
4608 return ret;
4609}
4610
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304611static int __iw_get_ap_rts_threshold(struct net_device *dev,
4612 struct iw_request_info *info,
4613 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004614{
4615 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4616 v_U32_t status = 0;
4617
4618 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
4619
4620 return status;
4621}
4622
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304623static int iw_get_ap_rts_threshold(struct net_device *dev,
4624 struct iw_request_info *info,
4625 union iwreq_data *wrqu, char *extra)
4626{
4627 int ret;
4628
4629 vos_ssr_protect(__func__);
4630 ret = __iw_get_ap_rts_threshold(dev, info, wrqu, extra);
4631 vos_ssr_unprotect(__func__);
4632
4633 return ret;
4634}
4635
4636static int __iw_get_ap_frag_threshold(struct net_device *dev,
4637 struct iw_request_info *info,
4638 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004639{
4640 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
4641 v_U32_t status = 0;
4642
4643 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
4644
4645 return status;
4646}
4647
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304648static int iw_get_ap_frag_threshold(struct net_device *dev,
4649 struct iw_request_info *info,
4650 union iwreq_data *wrqu, char *extra)
4651{
4652 int ret;
4653
4654 vos_ssr_protect(__func__);
4655 ret = __iw_get_ap_frag_threshold(dev, info, wrqu, extra);
4656 vos_ssr_unprotect(__func__);
4657
4658 return ret;
4659}
4660
4661static int __iw_get_ap_freq(struct net_device *dev,
4662 struct iw_request_info *info,
4663 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004664{
Jeff Johnsone7245742012-09-05 17:12:55 -07004665 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304666 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 tHalHandle hHal;
4668 hdd_hostapd_state_t *pHostapdState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304669 hdd_ap_ctx_t *pHddApCtx;
4670 hdd_context_t *pHddCtx;
4671 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004672
4673 ENTER();
4674
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304675 pHostapdAdapter = (netdev_priv(dev));
4676 if (NULL == pHostapdAdapter)
4677 {
4678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4679 "%s: Adapter is NULL",__func__);
4680 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304682 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4683 ret = wlan_hdd_validate_context(pHddCtx);
4684 if (0 != ret)
4685 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304686 return ret;
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304689 if (NULL == pHostapdState)
4690 {
4691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4692 "%s: pHostapdState is NULL",__func__);
4693 return -EINVAL;
4694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304696 if (NULL == hHal)
4697 {
4698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4699 "%s: Hal Context is NULL",__func__);
4700 return -EINVAL;
4701 }
4702 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
4703 if (NULL == pHddApCtx)
4704 {
4705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4706 "%s: AP context is NULL",__func__);
4707 return -EINVAL;
4708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 if(pHostapdState->bssState == BSS_STOP )
4710 {
4711 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
4712 != eHAL_STATUS_SUCCESS)
4713 {
c_hpothuffdb5272013-10-02 16:42:35 +05304714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4715 FL("failed to get WNI_CFG_CURRENT_CHANNEL from cfg"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 return -EIO;
4717 }
4718 else
4719 {
4720 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304721 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004722 {
4723 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4724 * iwlist & iwconfig command shows frequency into proper
4725 * format (2.412 GHz instead of 246.2 MHz)*/
4726 fwrq->m = freq;
4727 fwrq->e = MHZ;
4728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 }
4730 }
4731 else
4732 {
4733 channel = pHddApCtx->operatingChannel;
4734 status = hdd_wlan_get_freq(channel, &freq);
Ashish Kumar Dhanotiya95e5bc22018-04-19 17:06:33 +05304735 if( 0 == status)
Jeff Johnsone7245742012-09-05 17:12:55 -07004736 {
4737 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4738 * iwlist & iwconfig command shows frequency into proper
4739 * format (2.412 GHz instead of 246.2 MHz)*/
4740 fwrq->m = freq;
4741 fwrq->e = MHZ;
4742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304744
4745 EXIT();
4746 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004747}
4748
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304749static int iw_get_ap_freq(struct net_device *dev,
4750 struct iw_request_info *info,
4751 struct iw_freq *fwrq, char *extra)
4752{
4753 int ret;
4754
4755 vos_ssr_protect(__func__);
4756 ret = __iw_get_ap_freq(dev, info, fwrq, extra);
4757 vos_ssr_unprotect(__func__);
4758
4759 return ret;
4760}
4761
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304762static int __iw_softap_stopbss(struct net_device *dev,
4763 struct iw_request_info *info,
4764 union iwreq_data *wrqu,
4765 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004766{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304767 hdd_adapter_t *pHostapdAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 VOS_STATUS status = VOS_STATUS_SUCCESS;
Agarwal Ashish51325b52014-06-16 16:50:49 +05304769 hdd_context_t *pHddCtx = NULL;
4770
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304772 pHostapdAdapter = (netdev_priv(dev));
4773 if (NULL == pHostapdAdapter)
4774 {
4775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4776 "%s: Adapter is NULL",__func__);
4777 return -EINVAL;
4778 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05304779 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4780 status = wlan_hdd_validate_context(pHddCtx);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304781 if (0 != status) {
Agarwal Ashish51325b52014-06-16 16:50:49 +05304782 return status;
4783 }
4784
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304785 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07004786 {
Hanumanth Reddy Pothula74ba68c2018-06-22 17:52:09 +05304787 hdd_hostapd_state_t *pHostapdState =
4788 WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
4789
4790 vos_event_reset(&pHostapdState->vosEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
4792 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304794
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 if (!VOS_IS_STATUS_SUCCESS(status))
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304796 {
4797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004798 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 VOS_ASSERT(0);
4800 }
4801 }
4802 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05304803 wlan_hdd_decr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 }
4805 EXIT();
4806 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
4807}
4808
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304809static int iw_softap_stopbss(struct net_device *dev,
4810 struct iw_request_info *info,
4811 union iwreq_data *wrqu,
4812 char *extra)
4813{
4814 int ret;
4815
4816 vos_ssr_protect(__func__);
4817 ret = __iw_softap_stopbss(dev, info, wrqu, extra);
4818 vos_ssr_unprotect(__func__);
4819
4820 return ret;
4821}
4822
4823static int __iw_softap_version(struct net_device *dev,
4824 struct iw_request_info *info,
4825 union iwreq_data *wrqu,
4826 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004827{
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304829 hdd_context_t *pHddCtx;
4830 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304831
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304833 pHostapdAdapter = (netdev_priv(dev));
4834 if (NULL == pHostapdAdapter)
4835 {
4836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4837 "%s: Adapter is NULL",__func__);
4838 return -EINVAL;
4839 }
4840 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4841 ret = wlan_hdd_validate_context(pHddCtx);
4842 if (0 != ret)
4843 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304844 return ret;
4845 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004846 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 return 0;
4849}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004850
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05304851static int iw_softap_version(struct net_device *dev,
4852 struct iw_request_info *info,
4853 union iwreq_data *wrqu,
4854 char *extra)
4855{
4856 int ret;
4857
4858 vos_ssr_protect(__func__);
4859 ret = __iw_softap_version(dev, info, wrqu, extra);
4860 vos_ssr_unprotect(__func__);
4861
4862 return ret;
4863}
4864
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304865int hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004866{
4867 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004868 int len = 0;
4869 const char sta_info_header[] = "staId staAddress\n";
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304870 v_CONTEXT_t pVosContext;
4871 hdd_context_t *pHddCtx;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304872 ptSapContext pSapCtx = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304874 ENTER();
4875
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304876 if (NULL == pAdapter)
4877 {
4878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4879 "%s: Adapter is NULL",__func__);
4880 return -EINVAL;
4881 }
4882 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4883 if (0 != wlan_hdd_validate_context(pHddCtx))
4884 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304885 return VOS_STATUS_E_FAULT;
4886 }
4887 pVosContext = pHddCtx->pvosContext;
4888 if (NULL == pVosContext)
4889 {
4890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4891 "%s: VOS context is not valid",__func__);
4892 return VOS_STATUS_E_FAULT;
4893 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304894 pSapCtx = VOS_GET_SAP_CB(pVosContext);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304895 if(pSapCtx == NULL)
4896 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304897 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
4898 FL("psapCtx is NULL"));
4899 return VOS_STATUS_E_FAULT;
4900 }
4901
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304902 len = snprintf(pBuf, buf_len, sta_info_header);
4903 if (len >= buf_len) {
4904 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4905 return -E2BIG;
4906 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004907 pBuf += len;
4908 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004909
4910 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
4911 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304912 if(pSapCtx->aStaInfo[i].isUsed)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004913 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08004914 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05304915 pSapCtx->aStaInfo[i].ucSTAId,
4916 pSapCtx->aStaInfo[i].macAddrSTA.bytes[0],
4917 pSapCtx->aStaInfo[i].macAddrSTA.bytes[1],
4918 pSapCtx->aStaInfo[i].macAddrSTA.bytes[2],
4919 pSapCtx->aStaInfo[i].macAddrSTA.bytes[3],
4920 pSapCtx->aStaInfo[i].macAddrSTA.bytes[4],
4921 pSapCtx->aStaInfo[i].macAddrSTA.bytes[5]);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304922 if (len >= buf_len) {
4923 hddLog(LOGE, FL("Insufficient buffer:%d, %d"), buf_len, len);
4924 return -E2BIG;
4925 }
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07004926 pBuf += len;
4927 buf_len -= len;
4928 }
4929 if(WE_GET_STA_INFO_SIZE > buf_len)
4930 {
4931 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004932 }
4933 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304934 EXIT();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304935 return 0;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004936}
4937
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304938static int __iw_softap_get_sta_info(struct net_device *dev,
4939 struct iw_request_info *info,
4940 union iwreq_data *wrqu,
4941 char *extra)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004942{
4943 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304944 int ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004945 ENTER();
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304946 ret = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
4947 if (ret) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004948 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Chandrasekaran, Manishekarac8122b2016-04-22 16:42:41 +05304949 return ret;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08004950 }
4951 wrqu->data.length = strlen(extra);
4952 EXIT();
4953 return 0;
4954}
4955
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304956static int iw_softap_get_sta_info(struct net_device *dev,
4957 struct iw_request_info *info,
4958 union iwreq_data *wrqu,
4959 char *extra)
4960{
4961 int ret;
4962
4963 vos_ssr_protect(__func__);
4964 ret = __iw_softap_get_sta_info(dev, info, wrqu, extra);
4965 vos_ssr_unprotect(__func__);
4966
4967 return ret;
4968}
4969
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05304970static int __iw_set_ap_genie(struct net_device *dev,
4971 struct iw_request_info *info,
4972 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004973{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304974
4975 hdd_adapter_t *pHostapdAdapter;
4976 hdd_context_t *pHddCtx;
4977 v_CONTEXT_t pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07004979 u_int8_t *genie = (u_int8_t *)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304980 int ret = 0;
4981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304983 pHostapdAdapter = (netdev_priv(dev));
4984 if (NULL == pHostapdAdapter)
4985 {
4986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4987 "%s: Adapter is NULL",__func__);
4988 return -EINVAL;
4989 }
4990 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
4991 ret = wlan_hdd_validate_context(pHddCtx);
4992 if (0 != ret)
4993 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304994 return ret;
4995 }
4996 pVosContext = pHddCtx->pvosContext;
4997 if (NULL == pVosContext)
4998 {
4999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5000 "%s: VOS Context is NULL",__func__);
5001 return -EINVAL;
5002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 if(!wrqu->data.length)
5004 {
5005 EXIT();
5006 return 0;
5007 }
Arif Hussained667642013-10-27 23:01:14 -07005008
Nishank Aggarwalbd8e0f62017-02-10 15:48:13 +05305009 if (wrqu->data.length > DOT11F_IE_RSN_MAX_LEN)
5010 {
5011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5012 "%s: WPARSN Ie input length is more than max[%d]", __func__,
5013 wrqu->data.length);
5014 return -EINVAL;
5015 }
5016
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305017 switch (genie[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305019 case DOT11F_EID_WPA:
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 case DOT11F_EID_RSN:
5021 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
5022 {
5023 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
5024 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07005027 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 break;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305029
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005031 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 halStatus = 0;
5033 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305034
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305036 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005037}
5038
Mahesh A Saptasagarf176a862014-08-20 21:25:21 +05305039static int iw_set_ap_genie(struct net_device *dev,
5040 struct iw_request_info *info,
5041 union iwreq_data *wrqu, char *extra)
5042{
5043 int ret;
5044
5045 vos_ssr_protect(__func__);
5046 ret = __iw_set_ap_genie(dev, info, wrqu, extra);
5047 vos_ssr_unprotect(__func__);
5048
5049 return ret;
5050}
5051
Jeff Johnson295189b2012-06-20 16:38:30 -07005052static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
5053{
5054 eHalStatus hstatus;
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305055 int ret;
5056 void *cookie;
5057 struct hdd_request *request;
5058 struct stats_class_a_ctx *priv;
5059 static const struct hdd_request_params params = {
5060 .priv_size = sizeof(*priv),
5061 .timeout_ms = WLAN_WAIT_TIME_STATS,
5062 };
5063
Jeff Johnson295189b2012-06-20 16:38:30 -07005064
5065 if (NULL == pAdapter)
5066 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305067 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: pAdapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 return VOS_STATUS_E_FAULT;
5069 }
5070
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305071 request = hdd_request_alloc(&params);
5072 if (!request) {
5073 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
5074 return VOS_STATUS_E_NOMEM;
5075 }
5076 cookie = hdd_request_cookie(request);
5077
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
5079 eCSR_HDD,
5080 SME_GLOBAL_CLASSA_STATS,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305081 hdd_get_class_a_statistics_cb,
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 0, // not periodic
5083 FALSE, //non-cached results
5084 staid,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305085 cookie);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 if (eHAL_STATUS_SUCCESS != hstatus)
5087 {
5088 hddLog(VOS_TRACE_LEVEL_ERROR,
5089 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005090 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 }
5092 else
5093 {
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305094 ret = hdd_request_wait_for_response(request);
5095 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 {
5097 hddLog(VOS_TRACE_LEVEL_ERROR,
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305098 FL("SME timeout while retrieving link speed"));
5099 }
5100 else
5101 {
5102 priv = hdd_request_priv(request);
5103 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 }
5105 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005106
Hanumanth Reddy Pothulac76f0652018-04-06 17:31:52 +05305107 /*
5108 * either we never sent a request, we sent a request and received a
5109 * response or we sent a request and timed out. Regardless we are
5110 * done with the request.
5111 */
5112 hdd_request_put(request);
Jeff Johnson72a40512013-12-19 10:14:15 -08005113
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 return VOS_STATUS_SUCCESS;
5115}
5116
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305117int __iw_get_softap_linkspeed(struct net_device *dev,
5118 struct iw_request_info *info,
5119 union iwreq_data *wrqu,
5120 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005121
5122{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305123 hdd_adapter_t *pHostapdAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305124 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07005126 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305127 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305129 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
Arif Hussaina9571842014-01-15 16:43:41 -08005131 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305132 int rc, valid;
5133
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305134 ENTER();
5135
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305136 pHostapdAdapter = (netdev_priv(dev));
5137 if (NULL == pHostapdAdapter)
5138 {
5139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5140 "%s: Adapter is NULL",__func__);
5141 return -EINVAL;
5142 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305143 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305144 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305145 if (0 != valid)
5146 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305147 return valid;
5148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005149
Arif Hussain6d2a3322013-11-17 19:50:10 -08005150 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussaina9571842014-01-15 16:43:41 -08005151
5152 if (wrqu->data.length >= MAC_ADDRESS_STR_LEN - 1)
Arif Hussained667642013-10-27 23:01:14 -07005153 {
Arif Hussaina9571842014-01-15 16:43:41 -08005154 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
5155 if (NULL == pmacAddress) {
5156 hddLog(LOG1, "unable to allocate memory");
5157 return -ENOMEM;
5158 }
5159 if (copy_from_user((void *)pmacAddress,
5160 wrqu->data.pointer, MAC_ADDRESS_STR_LEN))
5161 {
5162 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
5163 kfree(pmacAddress);
5164 return -EFAULT;
5165 }
Manjeet Singha3739742016-05-03 16:21:46 +05305166 pmacAddress[MAC_ADDRESS_STR_LEN-1] = '\0';
Arif Hussaina9571842014-01-15 16:43:41 -08005167
5168 status = hdd_string_to_hex (pmacAddress, MAC_ADDRESS_STR_LEN, macAddress );
Arif Hussained667642013-10-27 23:01:14 -07005169 kfree(pmacAddress);
Arif Hussaina9571842014-01-15 16:43:41 -08005170
5171 if (!VOS_IS_STATUS_SUCCESS(status ))
5172 {
5173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
5174 }
Arif Hussained667642013-10-27 23:01:14 -07005175 }
Kiet Lam61589852013-09-19 17:10:58 +05305176 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305177 * link speed for first connected client will be returned.
5178 */
Arif Hussaina9571842014-01-15 16:43:41 -08005179 if (wrqu->data.length < 17 || !VOS_IS_STATUS_SUCCESS(status ))
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05305180 {
5181 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
5182 }
5183 else
5184 {
5185 status = hdd_softap_GetStaId(pHostapdAdapter,
5186 (v_MACADDR_t *)macAddress, (void *)(&staId));
5187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005188
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305189 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305191 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 link_speed = 0;
5193 }
5194 else
5195 {
5196 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305197
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 if (!VOS_IS_STATUS_SUCCESS(status ))
5199 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305200 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 return -EINVAL;
5202 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305203
5204 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
5205 staId, &link_speed);
5206
5207 link_speed = link_speed / 10;
5208
5209 if (0 == link_speed)
5210 {
5211 /* The linkspeed returned by HAL is in units of 500kbps.
5212 * converting it to mbps.
5213 * This is required to support legacy firmware which does
5214 * not return link capacity.
5215 */
5216 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
5217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 }
5219
5220 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07005221 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305222
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 if ((rc < 0) || (rc >= len))
5224 {
5225 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305226 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 return -EIO;
5228 }
5229
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305230 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 return 0;
5232}
5233
Mahesh A Saptasagar69e944e2014-08-13 20:01:27 +05305234int iw_get_softap_linkspeed(struct net_device *dev,
5235 struct iw_request_info *info,
5236 union iwreq_data *wrqu,
5237 char *extra)
5238{
5239 int ret;
5240
5241 vos_ssr_protect(__func__);
5242 ret = __iw_get_softap_linkspeed(dev, info, wrqu, extra);
5243 vos_ssr_unprotect(__func__);
5244
5245 return ret;
5246}
5247
5248
Jeff Johnson295189b2012-06-20 16:38:30 -07005249static const iw_handler hostapd_handler[] =
5250{
5251 (iw_handler) NULL, /* SIOCSIWCOMMIT */
5252 (iw_handler) NULL, /* SIOCGIWNAME */
5253 (iw_handler) NULL, /* SIOCSIWNWID */
5254 (iw_handler) NULL, /* SIOCGIWNWID */
5255 (iw_handler) NULL, /* SIOCSIWFREQ */
5256 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
5257 (iw_handler) NULL, /* SIOCSIWMODE */
Ashish Kumar Dhanotiya6b484a82018-04-24 15:11:55 +05305258 (iw_handler) NULL, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 (iw_handler) NULL, /* SIOCSIWSENS */
5260 (iw_handler) NULL, /* SIOCGIWSENS */
5261 (iw_handler) NULL, /* SIOCSIWRANGE */
5262 (iw_handler) NULL, /* SIOCGIWRANGE */
5263 (iw_handler) NULL, /* SIOCSIWPRIV */
5264 (iw_handler) NULL, /* SIOCGIWPRIV */
5265 (iw_handler) NULL, /* SIOCSIWSTATS */
5266 (iw_handler) NULL, /* SIOCGIWSTATS */
5267 (iw_handler) NULL, /* SIOCSIWSPY */
5268 (iw_handler) NULL, /* SIOCGIWSPY */
5269 (iw_handler) NULL, /* SIOCSIWTHRSPY */
5270 (iw_handler) NULL, /* SIOCGIWTHRSPY */
5271 (iw_handler) NULL, /* SIOCSIWAP */
5272 (iw_handler) NULL, /* SIOCGIWAP */
5273 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
5274 (iw_handler) NULL, /* SIOCGIWAPLIST */
5275 (iw_handler) NULL, /* SIOCSIWSCAN */
5276 (iw_handler) NULL, /* SIOCGIWSCAN */
5277 (iw_handler) NULL, /* SIOCSIWESSID */
5278 (iw_handler) NULL, /* SIOCGIWESSID */
5279 (iw_handler) NULL, /* SIOCSIWNICKN */
5280 (iw_handler) NULL, /* SIOCGIWNICKN */
5281 (iw_handler) NULL, /* -- hole -- */
5282 (iw_handler) NULL, /* -- hole -- */
5283 (iw_handler) NULL, /* SIOCSIWRATE */
5284 (iw_handler) NULL, /* SIOCGIWRATE */
5285 (iw_handler) NULL, /* SIOCSIWRTS */
5286 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
5287 (iw_handler) NULL, /* SIOCSIWFRAG */
5288 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
5289 (iw_handler) NULL, /* SIOCSIWTXPOW */
5290 (iw_handler) NULL, /* SIOCGIWTXPOW */
5291 (iw_handler) NULL, /* SIOCSIWRETRY */
5292 (iw_handler) NULL, /* SIOCGIWRETRY */
5293 (iw_handler) NULL, /* SIOCSIWENCODE */
5294 (iw_handler) NULL, /* SIOCGIWENCODE */
5295 (iw_handler) NULL, /* SIOCSIWPOWER */
5296 (iw_handler) NULL, /* SIOCGIWPOWER */
5297 (iw_handler) NULL, /* -- hole -- */
5298 (iw_handler) NULL, /* -- hole -- */
5299 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
5300 (iw_handler) NULL, /* SIOCGIWGENIE */
5301 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
5302 (iw_handler) NULL, /* SIOCGIWAUTH */
5303 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
5304 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
5305 (iw_handler) NULL, /* SIOCSIWPMKSA */
5306};
5307
Jeff Johnson224f3702014-03-26 11:09:47 -07005308/*
5309 * Note that the following ioctls were defined with semantics which
5310 * cannot be handled by the "iwpriv" userspace application and hence
5311 * they are not included in the hostapd_private_args array
5312 * QCSAP_IOCTL_ASSOC_STA_MACADDR
5313 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005314
5315static const struct iw_priv_args hostapd_private_args[] = {
5316 { QCSAP_IOCTL_SETPARAM,
5317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
5318 { QCSAP_IOCTL_SETPARAM,
5319 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
Mahesh A Saptasagar786266f2015-10-08 19:09:21 +05305320 { QCSAP_PARAM_GET_FRAME_LOGS,
5321 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "getFrameLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 { QCSAP_PARAM_MAX_ASSOC,
5323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
5324 { QCSAP_PARAM_HIDE_SSID,
5325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07005326 { QCSAP_PARAM_SET_MC_RATE,
5327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Hanumantha Reddy Pothula04900272016-01-08 15:39:47 +05305328 { QCSAP_PARAM_SET_PROXIMITY,
5329 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305330 { QCSAP_PARAM_CAP_TSF,
5331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "cap_tsf" },
Abhishek Singh02605092017-10-25 14:06:12 +05305332 {QCSAP_PARAM_SET_CHANNEL_CHANGE,
5333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setChanChange"},
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305334 { QCSAP_PARAM_SET_WOWL,
5335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wowl" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 { QCSAP_IOCTL_GETPARAM,
5337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
5338 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
5339 { QCSAP_IOCTL_GETPARAM, 0,
5340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
5341 { QCSAP_PARAM_MAX_ASSOC, 0,
5342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07005343 { QCSAP_PARAM_GET_WLAN_DBG, 0,
5344 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
5345 { QCSAP_PARAM_AUTO_CHANNEL, 0,
5346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Ravi Shankar Upadrastabb216bb2014-06-13 14:40:24 +05305347 { QCSAP_PARAM_SET_AUTO_CHANNEL,
5348 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 { QCSAP_PARAM_CLR_ACL, 0,
5350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
5351 { QCSAP_PARAM_ACL_MODE,
5352 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 { QCSAP_IOCTL_GET_STAWPAIE,
Manjeet Singh0fc12712016-08-02 19:08:02 +05305354 0, IW_PRIV_TYPE_BYTE | DOT11F_IE_RSN_MAX_LEN, "get_staWPAIE" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 { QCSAP_IOCTL_STOPBSS,
5356 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
5357 { QCSAP_IOCTL_VERSION, 0,
5358 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005359 { QCSAP_IOCTL_GET_STA_INFO, 0,
5360 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08005362 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07005364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson224f3702014-03-26 11:09:47 -07005365 { QCSAP_IOCTL_DISASSOC_STA,
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
Girish Gowlif3769802014-06-16 21:17:16 +05305367 { QCSAP_IOCTL_AP_STATS, 0,
5368 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "ap_stats" },
Manjeet Singh3ed79242017-01-11 19:04:32 +05305369 /* handlers for main ioctl */
5370 { QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT, 0,
5371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, "" },
5372#ifdef WLAN_FEATURE_TSF
5373 { QCSAP_IOCTL_GET_TSF, 0,
5374 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5375 "get_tsf" },
5376#endif
Bhargav Shah7f03b812015-08-21 11:17:32 +05305377 { QCSAP_IOCTL_GET_STATS, 0,
5378 IW_PRIV_TYPE_CHAR | QCSAP_MAX_STR_LEN, "getStats"},
5379 { QCSAP_IOCTL_CLR_STATS, 0, 0, "clearStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
5381 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05305382 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005383
5384 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
5385 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
5386 /* handlers for sub-ioctl */
5387 { WE_SET_WLAN_DBG,
5388 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
5389 0,
5390 "setwlandbg" },
5391
5392 /* handlers for main ioctl */
5393 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
5394 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5395 0,
5396 "" },
5397
5398 /* handlers for sub-ioctl */
5399 { WE_LOG_DUMP_CMD,
5400 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5401 0,
5402 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 { WE_P2P_NOA_CMD,
5404 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5405 0,
5406 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005407 /* handlers for sub ioctl */
5408 {
5409 WE_MCC_CONFIG_CREDENTIAL,
5410 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5411 0,
5412 "setMccCrdnl" },
5413
5414 /* handlers for sub ioctl */
5415 {
5416 WE_MCC_CONFIG_PARAMS,
5417 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
5418 0,
5419 "setMccConfig" },
5420
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 /* handlers for main ioctl */
5422 { QCSAP_IOCTL_MODIFY_ACL,
5423 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
5424 0,
5425 "modify_acl" },
5426
5427 /* handlers for main ioctl */
5428 { QCSAP_IOCTL_GET_CHANNEL_LIST,
5429 0,
5430 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
5431 "getChannelList" },
5432
Jeff Johnsone7245742012-09-05 17:12:55 -07005433 /* handlers for main ioctl */
5434 { QCSAP_IOCTL_SET_TX_POWER,
5435 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5436 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05305437 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07005438
5439 /* handlers for main ioctl */
5440 { QCSAP_IOCTL_SET_MAX_TX_POWER,
5441 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5442 0,
5443 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05305444
5445 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
5446 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
5447 0,
5448 "dataSnapshot" },
5449
5450 /* handlers for main ioctl */
5451 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
5452 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
5453 0,
5454 "setTrafficMon" },
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305455 /* handlers for main ioctl */
5456 { QCSAP_IOCTL_SET_CHAR_GET_NONE,
5457 IW_PRIV_TYPE_CHAR| 512,
5458 0,
5459 "" },
5460
5461 /* handlers for sub-ioctl */
5462 { WE_WOWL_ADD_PTRN,
5463 IW_PRIV_TYPE_CHAR| 512,
5464 0,
5465 "wowlAddPtrn" },
5466
5467 { WE_WOWL_DEL_PTRN,
5468 IW_PRIV_TYPE_CHAR| 512,
5469 0,
5470 "wowlDelPtrn" },
Jeff Johnson295189b2012-06-20 16:38:30 -07005471};
Jeff Johnsone7245742012-09-05 17:12:55 -07005472
Jeff Johnson295189b2012-06-20 16:38:30 -07005473static const iw_handler hostapd_private[] = {
5474 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
Arun Khandavalli08bcafd2016-11-08 14:45:48 +05305475 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
5476 [QCSAP_IOCTL_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] =
5477 iw_softap_setchar_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
5480 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
5481 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
5482 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
5483 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
5484 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
5485 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
Manjeet Singh3ed79242017-01-11 19:04:32 +05305486 [QCSAP_IOCTL_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] = iw_softap_get_three,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305487 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
5489 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
5490 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
5491 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08005492 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07005493 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
5494 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07005495 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305496 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05305497 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Bhargav Shah7f03b812015-08-21 11:17:32 +05305498 [QCSAP_IOCTL_GET_STATS - SIOCIWFIRSTPRIV] = iw_softap_get_stats,
5499 [QCSAP_IOCTL_CLR_STATS - SIOCIWFIRSTPRIV] = iw_softap_clear_stats,
Jeff Johnson295189b2012-06-20 16:38:30 -07005500};
5501const struct iw_handler_def hostapd_handler_def = {
5502 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
5503 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
5504 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
5505 .standard = (iw_handler *)hostapd_handler,
5506 .private = (iw_handler *)hostapd_private,
5507 .private_args = hostapd_private_args,
5508 .get_wireless_stats = NULL,
5509};
5510#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5511struct net_device_ops net_ops_struct = {
5512 .ndo_open = hdd_hostapd_open,
5513 .ndo_stop = hdd_hostapd_stop,
5514 .ndo_uninit = hdd_hostapd_uninit,
5515 .ndo_start_xmit = hdd_softap_hard_start_xmit,
5516 .ndo_tx_timeout = hdd_softap_tx_timeout,
5517 .ndo_get_stats = hdd_softap_stats,
5518 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
5519 .ndo_do_ioctl = hdd_hostapd_ioctl,
5520 .ndo_change_mtu = hdd_hostapd_change_mtu,
5521 .ndo_select_queue = hdd_hostapd_select_queue,
5522 };
5523#endif
5524
5525int hdd_set_hostapd(hdd_adapter_t *pAdapter)
5526{
5527 return VOS_STATUS_SUCCESS;
5528}
5529
5530void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
5531{
5532#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5533 pWlanHostapdDev->netdev_ops = &net_ops_struct;
5534#else
5535 pWlanHostapdDev->open = hdd_hostapd_open;
5536 pWlanHostapdDev->stop = hdd_hostapd_stop;
5537 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
5538 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
5539 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
5540 pWlanHostapdDev->get_stats = hdd_softap_stats;
5541 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
5542 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
5543#endif
5544}
5545
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305546VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter, bool re_init)
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305547{
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 hdd_hostapd_state_t * phostapdBuf;
Anurag Chouhan83026002016-12-13 22:46:21 +05305549#ifdef DHCP_SERVER_OFFLOAD
5550 hdd_dhcp_state_t *dhcp_status;
5551#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305552#ifdef MDNS_OFFLOAD
5553 hdd_mdns_state_t *mdns_status;
5554#endif /* MDNS_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005556 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 VOS_STATUS status;
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305558 hdd_config_t *ini_cfg;
Leo Chang0b0e45a2013-12-15 15:18:55 -08005559#ifdef FEATURE_WLAN_CH_AVOID
Leo Chang0b0e45a2013-12-15 15:18:55 -08005560 v_U16_t unsafeChannelList[NUM_20MHZ_RF_CHANNELS];
5561 v_U16_t unsafeChannelCount;
5562#endif /* FEATURE_WLAN_CH_AVOID */
5563
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305564 if (pHddCtx->isLogpInProgress && !re_init) {
Anand N Sunkad26d71b92014-12-24 18:08:22 +05305565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5566 "%s:LOGP in Progress. Ignore!!!",__func__);
5567 status = VOS_STATUS_E_FAILURE;
5568 }
5569
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 ENTER();
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305571
5572#ifdef SAP_AUTH_OFFLOAD
5573 if (pHddCtx->cfg_ini->enable_sap_auth_offload)
Agrawal Ashish6773c902017-01-06 19:45:03 +05305574 {
5575 if (!hdd_set_sap_auth_offload(pAdapter, TRUE))
5576 {
5577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5578 FL("SAP AUTH OFFLOAD is not enabled successfully, Don't start SAP"));
5579 return VOS_STATUS_E_FAILURE;
5580 }
5581 }
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305582#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05305583
Agrawal Ashish17ef5082016-10-17 18:33:21 +05305584 // Allocate the Wireless Extensions state structure
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
Anurag Chouhan83026002016-12-13 22:46:21 +05305586#ifdef DHCP_SERVER_OFFLOAD
5587 dhcp_status = &pAdapter->dhcp_status;
5588#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305589#ifdef MDNS_OFFLOAD
5590 mdns_status = &pAdapter->mdns_status;
5591#endif /* MDNS_OFFLOAD */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305592
Nirav Shah7e3c8132015-06-22 23:51:42 +05305593 spin_lock_init(&pAdapter->sta_hash_lock);
5594 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
5595
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005596 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
5597
Leo Chang0b0e45a2013-12-15 15:18:55 -08005598#ifdef FEATURE_WLAN_CH_AVOID
5599 /* Get unsafe cahnnel list from cached location */
5600 wcnss_get_wlan_unsafe_channel(unsafeChannelList,
5601 sizeof(unsafeChannelList),
5602 &unsafeChannelCount);
5603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5604 "%s : Unsafe Channel count %d",
5605 __func__, unsafeChannelCount);
Sushant Kaushik389e7f02014-06-11 19:56:10 +05305606 hdd_hostapd_update_unsafe_channel_list(pHddCtx,
Leo Chang0b0e45a2013-12-15 15:18:55 -08005607 unsafeChannelList,
5608 unsafeChannelCount);
5609#endif /* FEATURE_WLAN_CH_AVOID */
5610
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 // Zero the memory. This zeros the profile structure.
5612 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
Anurag Chouhan83026002016-12-13 22:46:21 +05305613#ifdef DHCP_SERVER_OFFLOAD
5614 memset(dhcp_status, 0,sizeof(*dhcp_status));
5615#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305616#ifdef MDNS_OFFLOAD
5617 memset(mdns_status, 0,sizeof(*mdns_status));
5618#endif /* MDNS_OFFLOAD */
Anurag Chouhan83026002016-12-13 22:46:21 +05305619
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 // Set up the pointer to the Wireless Extensions state structure
5621 // NOP
5622 status = hdd_set_hostapd(pAdapter);
5623 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 return status;
5626 }
5627
5628 status = vos_event_init(&phostapdBuf->vosEvent);
5629 if (!VOS_IS_STATUS_SUCCESS(status))
5630 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 return status;
5633 }
Abhishek Singh1a9dbcf2019-09-06 12:50:03 +05305634 status = vos_event_init(&phostapdBuf->sta_discon_event);
5635 if (!VOS_IS_STATUS_SUCCESS(status))
5636 {
5637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "ERROR: Hostapd HDD sta disassoc event init failed!!");
5638 return status;
5639 }
Anurag Chouhan83026002016-12-13 22:46:21 +05305640#ifdef DHCP_SERVER_OFFLOAD
5641 status = vos_event_init(&dhcp_status->vos_event);
5642 if (!VOS_IS_STATUS_SUCCESS(status)) {
5643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
5644 return status;
5645 }
5646#endif /* DHCP_SERVER_OFFLOAD */
Anurag Chouhan0b29de02016-12-16 13:18:40 +05305647#ifdef MDNS_OFFLOAD
5648 status = vos_event_init(&mdns_status->vos_event);
5649 if (!VOS_IS_STATUS_SUCCESS(status)) {
5650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5651 ("Hostapd HDD vos event init failed!!"));
5652 return status;
5653 }
5654#endif /* MDNS_OFFLOAD */
5655
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
5657
5658 // Register as a wireless device
5659 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
5660
5661 //Initialize the data path module
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305662 status = hdd_softap_init_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 if ( !VOS_IS_STATUS_SUCCESS( status ))
5664 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005665 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305667
5668 status = hdd_wmm_adapter_init( pAdapter );
5669 if (!VOS_IS_STATUS_SUCCESS(status))
5670 {
5671 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005672 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305673 status, status );
5674 goto error_wmm_init;
5675 }
5676
5677 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5678
Hanumanth Reddy Pothulab37ce862017-02-03 21:42:08 +05305679 ini_cfg = pHddCtx->cfg_ini;
5680 if (re_init && ini_cfg) {
5681 hddLog(VOS_TRACE_LEVEL_INFO, FL("start_ch: %d end_ch:%d op_band:%d"),
5682 ini_cfg->apStartChannelNum, ini_cfg->apEndChannelNum,
5683 ini_cfg->apOperatingBand);
5684 WLANSAP_SetChannelRange(WLAN_HDD_GET_HAL_CTX(pAdapter),
5685 ini_cfg->apStartChannelNum,
5686 ini_cfg->apEndChannelNum,
5687 ini_cfg->apOperatingBand);
5688 }
5689
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305690 return status;
5691
5692error_wmm_init:
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305693 hdd_softap_deinit_tx_rx(pAdapter, re_init);
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 EXIT();
5695 return status;
5696}
5697
5698hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
5699{
5700 struct net_device *pWlanHostapdDev = NULL;
5701 hdd_adapter_t *pHostapdAdapter = NULL;
5702 v_CONTEXT_t pVosContext= NULL;
5703
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05305704 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name,
5705#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
5706 NET_NAME_UNKNOWN,
5707#endif
5708 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 if (pWlanHostapdDev != NULL)
5710 {
5711 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
5712
5713 //Init the net_device structure
5714 ether_setup(pWlanHostapdDev);
5715
5716 //Initialize the adapter context to zeros.
5717 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
5718 pHostapdAdapter->dev = pWlanHostapdDev;
5719 pHostapdAdapter->pHddCtx = pHddCtx;
5720 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5721
5722 //Get the Global VOSS context.
5723 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
5724 //Save the adapter context in global context for future.
5725 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
5726
5727 //Init the net_device structure
5728 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
5729
5730 hdd_set_ap_ops( pHostapdAdapter->dev );
5731
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
5733 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
5734
5735 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
5736 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
5737
5738 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
5740 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
5741 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005742
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
5744 }
5745 return pHostapdAdapter;
5746}
5747
5748VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5749{
5750 struct net_device *dev = pAdapter->dev;
5751 VOS_STATUS status = VOS_STATUS_SUCCESS;
5752
5753 ENTER();
5754
5755 if( rtnl_lock_held )
5756 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005757 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 if( dev_alloc_name(dev, dev->name) < 0 )
5759 {
5760 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
5761 return VOS_STATUS_E_FAILURE;
5762 }
5763 }
5764 if (register_netdevice(dev))
5765 {
5766 hddLog(VOS_TRACE_LEVEL_FATAL,
5767 "%s:Failed:register_netdevice", __func__);
5768 return VOS_STATUS_E_FAILURE;
5769 }
5770 }
5771 else
5772 {
5773 if (register_netdev(dev))
5774 {
5775 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
5776 return VOS_STATUS_E_FAILURE;
5777 }
5778 }
5779 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5780
5781 EXIT();
5782 return status;
5783}
5784
c_hpothu002231a2015-02-05 14:58:51 +05305785VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter, tANI_U8 rtnl_held)
Jeff Johnson295189b2012-06-20 16:38:30 -07005786{
5787 ENTER();
5788
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305789 hdd_softap_deinit_tx_rx(pAdapter, false);
Jeff Johnson295189b2012-06-20 16:38:30 -07005790
5791 /* if we are being called during driver unload, then the dev has already
5792 been invalidated. if we are being called at other times, then we can
5793 detatch the wireless device handlers */
5794 if (pAdapter->dev)
5795 {
c_hpothu002231a2015-02-05 14:58:51 +05305796 if (TRUE == rtnl_held)
5797 {
5798 pAdapter->dev->wireless_handlers = NULL;
5799 }
5800 else
5801 {
5802 rtnl_lock();
5803 pAdapter->dev->wireless_handlers = NULL;
5804 rtnl_unlock();
5805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 }
5807 EXIT();
5808 return 0;
5809}
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305810
5811/**
5812 * hdd_sap_indicate_disconnect_for_sta() - Indicate disconnect indication
5813 * to supplicant, if there any clients connected to SAP interface.
5814 * @adapter: sap adapter context
5815 *
5816 * Return: nothing
5817 */
5818void hdd_sap_indicate_disconnect_for_sta(hdd_adapter_t *adapter)
5819{
5820 tSap_Event sap_event;
5821 int staId;
5822 hdd_context_t *hdd_ctx;
5823 v_CONTEXT_t vos_ctx;
5824 ptSapContext sap_ctx;
5825
5826 ENTER();
5827
5828 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305829 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5831 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305832 return;
5833 }
5834
5835 vos_ctx = hdd_ctx->pvosContext;
5836 if (NULL == vos_ctx) {
5837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5838 "%s: VOS context is not valid",__func__);
5839 return;
5840 }
5841
5842 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5843 if (!sap_ctx) {
5844 hddLog(LOGE, FL("invalid sap context"));
5845 return;
5846 }
5847
5848 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
5849 if (sap_ctx->aStaInfo[staId].isUsed) {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07005850 hddLog(LOG1, FL("staId: %d isUsed: %d %pK"),
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305851 staId, sap_ctx->aStaInfo[staId].isUsed,
5852 sap_ctx);
5853
5854 if (vos_is_macaddr_broadcast(
5855 &sap_ctx->aStaInfo[staId].macAddrSTA))
5856 continue;
5857
5858 sap_event.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
5859 vos_mem_copy(
5860 &sap_event.sapevt.
5861 sapStationDisassocCompleteEvent.staMac,
5862 &sap_ctx->aStaInfo[staId].macAddrSTA,
5863 sizeof(v_MACADDR_t));
5864 sap_event.sapevt.sapStationDisassocCompleteEvent.
5865 reason =
5866 eSAP_MAC_INITATED_DISASSOC;
5867 sap_event.sapevt.sapStationDisassocCompleteEvent.
5868 statusCode =
5869 eSIR_SME_RESOURCES_UNAVAILABLE;
5870 hdd_hostapd_SAPEventCB(&sap_event,
5871 sap_ctx->pUsrContext);
5872 }
5873 }
5874
5875 clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags);
5876
5877 EXIT();
5878}
5879
5880/**
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305881 * hdd_sap_destroy_timers() - Destroy sap timers
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305882 * @adapter: sap adapter context
5883 *
5884 * Return: nothing
5885 */
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305886void hdd_sap_destroy_timers(hdd_adapter_t *adapter)
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305887{
5888 hdd_context_t *hdd_ctx;
5889 v_CONTEXT_t vos_ctx;
5890 ptSapContext sap_ctx;
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305891 VOS_STATUS status = VOS_STATUS_E_FAILURE;
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305892
5893 ENTER();
5894
5895 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305896 if (NULL == hdd_ctx || NULL == hdd_ctx->cfg_ini) {
5897 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5898 "%s: HDD context is Null", __func__);
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305899 return;
5900 }
5901
5902 vos_ctx = hdd_ctx->pvosContext;
5903 if (NULL == vos_ctx) {
5904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5905 "%s: VOS context is not valid",__func__);
5906 return;
5907 }
5908
5909 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
5910 if (!sap_ctx) {
5911 hddLog(LOGE, FL("invalid sap context"));
5912 return;
5913 }
5914
Hanumanth Reddy Pothula15bc0fa2017-02-03 17:24:17 +05305915 if (VOS_TIMER_STATE_RUNNING == sap_ctx->sap_HT2040_timer.state) {
5916 status = vos_timer_stop(&sap_ctx->sap_HT2040_timer);
5917 if (!VOS_IS_STATUS_SUCCESS(status))
5918 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5919 FL("Failed to Stop HT20/40 timer"));
5920 }
5921
5922 status = vos_timer_destroy(&sap_ctx->sap_HT2040_timer);
5923 if (!VOS_IS_STATUS_SUCCESS(status))
5924 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
5925 FL("Failed to Destroy HT20/40 timer"));
5926
Hanumanth Reddy Pothulad864f312017-01-18 16:16:08 +05305927}
Agrawal Ashish574b3e62017-02-09 18:58:34 +05305928
5929/**
5930 * hdd_force_scc_restart_sap - restart sap to forcer SCC
5931 * @adapter: hdd ap adapter
5932 *
5933 * hdd_force_scc_restart_sap will choose station channel and will
5934 * schedule work to restart the sap.
5935 *
5936 * Return - none
5937 */
5938void hdd_force_scc_restart_sap(hdd_adapter_t *adapter,
5939 hdd_context_t *hdd_ctx, tANI_U8 channelId)
5940{
5941 if (!(adapter && (WLAN_HDD_SOFTAP == adapter->device_mode))) {
5942 return;
5943 }
5944
5945 hddLog(LOG1, FL("Current operation channel %d"),
5946 adapter->sessionCtx.ap.operatingChannel);
5947 hddLog(LOG1, FL("STA channel is %d"),
5948 channelId);
5949
5950 vos_flush_work(
5951 &hdd_ctx->sap_start_work);
5952
5953 hddLog(LOGE,
5954 FL("Restarting SAP for force SCC "));
5955
5956 adapter->sessionCtx.ap.sapConfig.channel = channelId;
5957
5958 if (hdd_ctx->cfg_ini->sap_internal_restart) {
5959 netif_tx_disable(adapter->dev);
5960 schedule_work(&hdd_ctx->sap_start_work);
5961 } else {
5962 hdd_hostapd_stop(adapter->dev);
5963 }
5964 return;
5965}
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +05305966
5967/**
5968 * hdd_get_cache_stainfo() - get stainfo for the specified peer
5969 * @stainfo: array of station info
5970 * @mac_addr: mac address of requested peer
5971 *
5972 * This function find the stainfo for the peer with mac_addr
5973 *
5974 * Return: stainfo if found, NULL if not found
5975 */
5976struct hdd_cache_sta_info *hdd_get_cache_stainfo(
5977 struct hdd_cache_sta_info *astainfo,
5978 u8 *mac_addr)
5979{
5980 struct hdd_cache_sta_info *stainfo = NULL;
5981 int i;
5982
5983 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
5984 if (vos_mem_compare(&astainfo[i].macAddrSTA,
5985 mac_addr,
5986 HDD_MAC_ADDR_LEN)) {
5987 stainfo = &astainfo[i];
5988 break;
5989 }
5990 }
5991
5992 return stainfo;
5993}
5994