blob: af8640256a2d896380a05eaaa3c6942eb4a0a02a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**========================================================================
43
44 \file wlan_hdd_hostapd.c
45 \brief WLAN Host Device Driver implementation
46
47 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
48
49 Qualcomm Confidential and Proprietary.
50
51 ========================================================================*/
52/**=========================================================================
53 EDIT HISTORY FOR FILE
54
55
56 This section contains comments describing changes made to the module.
57 Notice that changes are listed in reverse chronological order.
58
59 $Header:$ $DateTime: $ $Author: $
60
61
62 when who what, where, why
63 -------- --- --------------------------------------------------------
64 04/5/09 Shailender Created module.
65 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
66 ==========================================================================*/
67/*--------------------------------------------------------------------------
68 Include Files
69 ------------------------------------------------------------------------*/
70
71#include <linux/version.h>
72#include <linux/module.h>
73#include <linux/kernel.h>
74#include <linux/init.h>
75#include <linux/wireless.h>
76#include <linux/semaphore.h>
77#include <vos_api.h>
78#include <vos_sched.h>
79#include <linux/etherdevice.h>
80#include <wlan_hdd_includes.h>
81#include <qc_sap_ioctl.h>
82#include <wlan_hdd_hostapd.h>
83#include <sapApi.h>
84#include <sapInternal.h>
85#include <wlan_qct_tl.h>
86#include <wlan_hdd_softap_tx_rx.h>
87#include <wlan_hdd_main.h>
88#include <linux/netdevice.h>
89#include <linux/mmc/sdio_func.h>
90#include "wlan_nlink_common.h"
91#include "wlan_btc_svc.h"
92#include <bap_hdd_main.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_hdd_p2p.h"
Leo Chang614d2072013-08-22 14:59:44 -070094#include "cfgApi.h"
95#include "wniCfgAp.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#define IS_UP(_dev) \
98 (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
99#define IS_UP_AUTO(_ic) \
100 (IS_UP((_ic)->ic_dev) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
101#define WE_WLAN_VERSION 1
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -0700102#define WE_GET_STA_INFO_SIZE 30
103/* WEXT limition: MAX allowed buf len for any *
104 * IW_PRIV_TYPE_CHAR is 2Kbytes *
105 */
106#define WE_SAP_MAX_STA_INFO 0x7FF
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#define SAP_24GHZ_CH_COUNT (14)
Leo Chang614d2072013-08-22 14:59:44 -0700109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110/*---------------------------------------------------------------------------
111 * Function definitions
112 *-------------------------------------------------------------------------*/
113/**---------------------------------------------------------------------------
114
115 \brief hdd_hostapd_open() - HDD Open function for hostapd interface
116
117 This is called in response to ifconfig up
118
119 \param - dev Pointer to net_device structure
120
121 \return - 0 for success non-zero for failure
122
123 --------------------------------------------------------------------------*/
124int hdd_hostapd_open (struct net_device *dev)
125{
126 ENTER();
127
128 //Turn ON carrier state
129 netif_carrier_on(dev);
130 //Enable all Tx queues
131 netif_tx_start_all_queues(dev);
132
133 EXIT();
134 return 0;
135}
136/**---------------------------------------------------------------------------
137
138 \brief hdd_hostapd_stop() - HDD stop function for hostapd interface
139
140 This is called in response to ifconfig down
141
142 \param - dev Pointer to net_device structure
143
144 \return - 0 for success non-zero for failure
145
146 --------------------------------------------------------------------------*/
147int hdd_hostapd_stop (struct net_device *dev)
148{
149 ENTER();
150
151 //Stop all tx queues
152 netif_tx_disable(dev);
153
154 //Turn OFF carrier state
155 netif_carrier_off(dev);
156
157 EXIT();
158 return 0;
159}
160/**---------------------------------------------------------------------------
161
162 \brief hdd_hostapd_uninit() - HDD uninit function
163
164 This is called during the netdev unregister to uninitialize all data
165associated with the device
166
167 \param - dev Pointer to net_device structure
168
169 \return - void
170
171 --------------------------------------------------------------------------*/
172static void hdd_hostapd_uninit (struct net_device *dev)
173{
174 hdd_adapter_t *pHostapdAdapter = netdev_priv(dev);
175
176 ENTER();
177
178 if (pHostapdAdapter && pHostapdAdapter->pHddCtx)
179 {
180 hdd_deinit_adapter(pHostapdAdapter->pHddCtx, pHostapdAdapter);
181
182 /* after uninit our adapter structure will no longer be valid */
183 pHostapdAdapter->dev = NULL;
184 }
185
186 EXIT();
187}
188
189
190/**============================================================================
191 @brief hdd_hostapd_hard_start_xmit() - Function registered with the Linux OS for
192 transmitting packets. There are 2 versions of this function. One that uses
193 locked queue and other that uses lockless queues. Both have been retained to
194 do some performance testing
195 @param skb : [in] pointer to OS packet (sk_buff)
196 @param dev : [in] pointer to Libra network device
197
198 @return : NET_XMIT_DROP if packets are dropped
199 : NET_XMIT_SUCCESS if packet is enqueued succesfully
200 ===========================================================================*/
201int hdd_hostapd_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
202{
203 return 0;
204}
205int hdd_hostapd_change_mtu(struct net_device *dev, int new_mtu)
206{
207 return 0;
208}
209
210int hdd_hostapd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
211{
212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
213 hdd_priv_data_t priv_data;
214 tANI_U8 *command = NULL;
215 int ret = 0;
216
217 if (NULL == pAdapter)
218 {
219 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700220 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700221 ret = -ENODEV;
222 goto exit;
223 }
224
Jeff Johnsone7245742012-09-05 17:12:55 -0700225 if ((!ifr) || (!ifr->ifr_data))
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 {
227 ret = -EINVAL;
228 goto exit;
229 }
230
231 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(hdd_priv_data_t)))
232 {
233 ret = -EFAULT;
234 goto exit;
235 }
236
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800237 if (priv_data.total_len <= 0 ||
238 priv_data.total_len == INT_MAX)
239 {
240 /* below we allocate one more byte for command buffer.
241 * To avoid addition overflow total_len should be
242 * smaller than INT_MAX. */
243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800244 "%s: integer out of range", __func__);
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800245 ret = -EFAULT;
246 goto exit;
247 }
248
249 command = kmalloc((priv_data.total_len + 1), GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 if (!command)
251 {
252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800253 "%s: failed to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 ret = -ENOMEM;
255 goto exit;
256 }
257
258 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
259 {
260 ret = -EFAULT;
261 goto exit;
262 }
263
Mingcheng Zhuc7608ae2013-11-04 15:11:01 -0800264 command[priv_data.total_len] = '\0';
265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 if ((SIOCDEVPRIVATE + 1) == cmd)
267 {
Agarwal Ashish8518d5d2013-12-05 20:16:44 +0530268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 "***HOSTAPD*** : Received %s cmd from Wi-Fi GUI***", command);
270
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 if(strncmp(command, "P2P_SET_NOA", 11) == 0 )
272 {
273 hdd_setP2pNoa(dev, command);
274 }
275 else if( strncmp(command, "P2P_SET_PS", 10) == 0 )
276 {
277 hdd_setP2pOpps(dev, command);
278 }
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700279
280 /*
281 command should be a string having format
282 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
283 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700284 if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700285 {
286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700287 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700288
Mahesh Kumar Kalikot Veetil2aad8d82013-02-07 12:31:28 -0800289 ret = sapSetPreferredChannel(command);
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700290 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 }
292exit:
293 if (command)
294 {
295 kfree(command);
296 }
297 return ret;
298}
299
300/**---------------------------------------------------------------------------
301
302 \brief hdd_hostapd_set_mac_address() -
303 This function sets the user specified mac address using
304 the command ifconfig wlanX hw ether <mac adress>.
305
306 \param - dev - Pointer to the net device.
307 - addr - Pointer to the sockaddr.
308 \return - 0 for success, non zero for failure
309
310 --------------------------------------------------------------------------*/
311
312static int hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
313{
314 struct sockaddr *psta_mac_addr = addr;
315 ENTER();
316 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
317 EXIT();
318 return 0;
319}
320void hdd_hostapd_inactivity_timer_cb(v_PVOID_t usrDataForCallback)
321{
322 struct net_device *dev = (struct net_device *)usrDataForCallback;
323 v_BYTE_t we_custom_event[64];
324 union iwreq_data wrqu;
325#ifdef DISABLE_CONCURRENCY_AUTOSAVE
326 VOS_STATUS vos_status;
327 hdd_adapter_t *pHostapdAdapter;
328 hdd_ap_ctx_t *pHddApCtx;
329#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
330
331 /* event_name space-delimiter driver_module_name */
332 /* Format of the event is "AUTO-SHUT.indication" " " "module_name" */
333 char * autoShutEvent = "AUTO-SHUT.indication" " " KBUILD_MODNAME;
334 int event_len = strlen(autoShutEvent) + 1; /* For the NULL at the end */
335
336 ENTER();
337
338#ifdef DISABLE_CONCURRENCY_AUTOSAVE
339 if (vos_concurrent_sessions_running())
340 {
341 /*
342 This timer routine is going to be called only when AP
343 persona is up.
344 If there are concurrent sessions running we do not want
345 to shut down the Bss.Instead we run the timer again so
346 that if Autosave is enabled next time and other session
347 was down only then we bring down AP
348 */
349 pHostapdAdapter = netdev_priv(dev);
350 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
351 vos_status = vos_timer_start(
352 &pHddApCtx->hdd_ap_inactivity_timer,
353 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff
354 * 1000);
355 if (!VOS_IS_STATUS_SUCCESS(vos_status))
356 {
357 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
358 }
359 EXIT();
360 return;
361 }
362#endif /*DISABLE_CONCURRENCY_AUTOSAVE */
363 memset(&we_custom_event, '\0', sizeof(we_custom_event));
364 memcpy(&we_custom_event, autoShutEvent, event_len);
365
366 memset(&wrqu, 0, sizeof(wrqu));
367 wrqu.data.length = event_len;
368
369 hddLog(LOG1, FL("Shutting down AP interface due to inactivity"));
370 wireless_send_event(dev, IWEVCUSTOM, &wrqu, (char *)we_custom_event);
371
372 EXIT();
373}
374
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800375VOS_STATUS hdd_change_mcc_go_beacon_interval(hdd_adapter_t *pHostapdAdapter)
376{
377 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
378 ptSapContext pSapCtx = NULL;
379 eHalStatus halStatus = eHAL_STATUS_FAILURE;
380 v_PVOID_t hHal = NULL;
381
382 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
383 "%s: UPDATE Beacon Params", __func__);
384
385 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
386 pSapCtx = VOS_GET_SAP_CB(pVosContext);
387 if ( NULL == pSapCtx )
388 {
389 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
390 "%s: Invalid SAP pointer from pvosGCtx", __func__);
391 return VOS_STATUS_E_FAULT;
392 }
393
394 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
395 if ( NULL == hHal ){
396 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
397 "%s: Invalid HAL pointer from pvosGCtx", __func__);
398 return VOS_STATUS_E_FAULT;
399 }
400 halStatus = sme_ChangeMCCBeaconInterval(hHal, pSapCtx->sessionId);
401 if(halStatus == eHAL_STATUS_FAILURE ){
402 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
403 "%s: Failed to update Beacon Params", __func__);
404 return VOS_STATUS_E_FAILURE;
405 }
406 }
407 return VOS_STATUS_SUCCESS;
408}
409
410void hdd_clear_all_sta(hdd_adapter_t *pHostapdAdapter, v_PVOID_t usrDataForCallback)
411{
412 v_U8_t staId = 0;
413 struct net_device *dev;
414 dev = (struct net_device *)usrDataForCallback;
415
Arif Hussain6d2a3322013-11-17 19:50:10 -0800416 hddLog(LOGE, FL("Clearing all the STA entry...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800417 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
418 {
419 if ( pHostapdAdapter->aStaInfo[staId].isUsed &&
420 ( staId != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId))
421 {
422 //Disconnect all the stations
423 hdd_softap_sta_disassoc(pHostapdAdapter, &pHostapdAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
424 }
425 }
426}
427
428static int hdd_stop_p2p_link(hdd_adapter_t *pHostapdAdapter,v_PVOID_t usrDataForCallback)
429{
430 struct net_device *dev;
431 VOS_STATUS status = VOS_STATUS_SUCCESS;
432 dev = (struct net_device *)usrDataForCallback;
433 ENTER();
434 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
435 {
436 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
437 {
438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, FL("Deleting P2P link!!!!!!"));
439 }
440 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
441 }
442 EXIT();
443 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
444}
Jeff Johnson295189b2012-06-20 16:38:30 -0700445
446VOS_STATUS hdd_hostapd_SAPEventCB( tpSap_Event pSapEvent, v_PVOID_t usrDataForCallback)
447{
448 hdd_adapter_t *pHostapdAdapter;
449 hdd_ap_ctx_t *pHddApCtx;
450 hdd_hostapd_state_t *pHostapdState;
451 struct net_device *dev;
452 eSapHddEvent sapEvent;
453 union iwreq_data wrqu;
454 v_BYTE_t *we_custom_event_generic = NULL;
455 int we_event = 0;
456 int i = 0;
457 v_U8_t staId;
458 VOS_STATUS vos_status;
459 v_BOOL_t bWPSState;
460 v_BOOL_t bApActive = FALSE;
461 v_BOOL_t bAuthRequired = TRUE;
462 tpSap_AssocMacAddr pAssocStasArray = NULL;
463 char unknownSTAEvent[IW_CUSTOM_MAX+1];
464 char maxAssocExceededEvent[IW_CUSTOM_MAX+1];
465 v_BYTE_t we_custom_start_event[64];
466 char *startBssEvent;
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800467 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800468 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson5f12e902013-04-03 10:21:46 -0700469 struct iw_michaelmicfailure msg;
Jeff Johnson295189b2012-06-20 16:38:30 -0700470
471 dev = (struct net_device *)usrDataForCallback;
472 pHostapdAdapter = netdev_priv(dev);
Madan Mohan Koyyalamudie1b791f2013-07-24 12:53:33 +0530473
474 if ((NULL == pHostapdAdapter) ||
475 (WLAN_HDD_ADAPTER_MAGIC != pHostapdAdapter->magic))
476 {
477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
478 "invalid adapter or adapter has invalid magic");
479 return eHAL_STATUS_FAILURE;
480 }
481
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
483 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
484 sapEvent = pSapEvent->sapHddEventCode;
485 memset(&wrqu, '\0', sizeof(wrqu));
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800486 pHddCtx = (hdd_context_t*)(pHostapdAdapter->pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487
488 switch(sapEvent)
489 {
490 case eSAP_START_BSS_EVENT :
Arif Hussain6d2a3322013-11-17 19:50:10 -0800491 hddLog(LOG1, FL("BSS configured status = %s, channel = %u, bc sta Id = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 pSapEvent->sapevt.sapStartBssCompleteEvent.status ? "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS",
493 pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel,
494 pSapEvent->sapevt.sapStartBssCompleteEvent.staId);
495
496 pHostapdState->vosStatus = pSapEvent->sapevt.sapStartBssCompleteEvent.status;
497 vos_status = vos_event_set(&pHostapdState->vosEvent);
498
499 if (!VOS_IS_STATUS_SUCCESS(vos_status) || pHostapdState->vosStatus)
500 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: startbss event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 goto stopbss;
503 }
504 else
505 {
506 pHddApCtx->uBCStaId = pSapEvent->sapevt.sapStartBssCompleteEvent.staId;
507 //@@@ need wep logic here to set privacy bit
508 hdd_softap_Register_BC_STA(pHostapdAdapter, pHddApCtx->uPrivacy);
509 }
510
511 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
512 {
513 // AP Inactivity timer init and start
514 vos_status = vos_timer_init( &pHddApCtx->hdd_ap_inactivity_timer, VOS_TIMER_TYPE_SW,
515 hdd_hostapd_inactivity_timer_cb, (v_PVOID_t)dev );
516 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800517 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700518
519 vos_status = vos_timer_start( &pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
520 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800521 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523 }
524 pHddApCtx->operatingChannel = pSapEvent->sapevt.sapStartBssCompleteEvent.operatingChannel;
525 pHostapdState->bssState = BSS_START;
526
527 // Send current operating channel of SoftAP to BTC-ES
528 send_btc_nlink_msg(WLAN_BTC_SOFTAP_BSS_START, 0);
529
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 //Check if there is any group key pending to set.
531 if( pHddApCtx->groupKey.keyLength )
532 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700533 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
535 &pHddApCtx->groupKey ) )
536 {
537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
538 "%s: WLANSAP_SetKeySta failed", __func__);
539 }
540 pHddApCtx->groupKey.keyLength = 0;
541 }
542 else if ( pHddApCtx->wepKey[0].keyLength )
543 {
544 int i=0;
545 for ( i = 0; i < CSR_MAX_NUM_KEY; i++ )
546 {
Jeff Johnson43971f52012-07-17 12:26:56 -0700547 if( VOS_STATUS_SUCCESS != WLANSAP_SetKeySta(
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
549 &pHddApCtx->wepKey[i] ) )
550 {
551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
552 "%s: WLANSAP_SetKeySta failed idx %d", __func__, i);
553 }
554 pHddApCtx->wepKey[i].keyLength = 0;
555 }
556 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 //Fill the params for sending IWEVCUSTOM Event with SOFTAP.enabled
558 startBssEvent = "SOFTAP.enabled";
559 memset(&we_custom_start_event, '\0', sizeof(we_custom_start_event));
560 memcpy(&we_custom_start_event, startBssEvent, strlen(startBssEvent));
561 memset(&wrqu, 0, sizeof(wrqu));
562 wrqu.data.length = strlen(startBssEvent);
563 we_event = IWEVCUSTOM;
564 we_custom_event_generic = we_custom_start_event;
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700565 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 break; //Event will be sent after Switch-Case stmt
567
568 case eSAP_STOP_BSS_EVENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800569 hddLog(LOG1, FL("BSS stop status = %s"),pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
571
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700572 //Free up Channel List incase if it is set
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700573 sapCleanupChannelList();
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -0700574
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 pHddApCtx->operatingChannel = 0; //Invalidate the channel info.
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 goto stopbss;
577 case eSAP_STA_SET_KEY_EVENT:
578 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800579 hddLog(LOG1, FL("SET Key: configured status = %s"),pSapEvent->sapevt.sapStationSetKeyCompleteEvent.status ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
581 return VOS_STATUS_SUCCESS;
582 case eSAP_STA_DEL_KEY_EVENT:
583 //TODO: forward the message to hostapd once implementtation is done for now just print
Arif Hussain6d2a3322013-11-17 19:50:10 -0800584 hddLog(LOG1, FL("Event received %s"),"eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 return VOS_STATUS_SUCCESS;
586 case eSAP_STA_MIC_FAILURE_EVENT:
587 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 memset(&msg, '\0', sizeof(msg));
589 msg.src_addr.sa_family = ARPHRD_ETHER;
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800590 memcpy(msg.src_addr.sa_data, &pSapEvent->sapevt.sapStationMICFailureEvent.staMac, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800591 hddLog(LOG1, "MIC MAC "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Jeff Johnson43971f52012-07-17 12:26:56 -0700592 if(pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 msg.flags = IW_MICFAILURE_GROUP;
594 else
595 msg.flags = IW_MICFAILURE_PAIRWISE;
596 memset(&wrqu, 0, sizeof(wrqu));
597 wrqu.data.length = sizeof(msg);
598 we_event = IWEVMICHAELMICFAILURE;
599 we_custom_event_generic = (v_BYTE_t *)&msg;
600 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 /* inform mic failure to nl80211 */
602 cfg80211_michael_mic_failure(dev,
603 pSapEvent->sapevt.
604 sapStationMICFailureEvent.staMac.bytes,
Jeff Johnson43971f52012-07-17 12:26:56 -0700605 ((pSapEvent->sapevt.sapStationMICFailureEvent.multicast == eSAP_TRUE) ?
Jeff Johnson295189b2012-06-20 16:38:30 -0700606 NL80211_KEYTYPE_GROUP :
607 NL80211_KEYTYPE_PAIRWISE),
608 pSapEvent->sapevt.sapStationMICFailureEvent.keyId,
609 pSapEvent->sapevt.sapStationMICFailureEvent.TSC,
610 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 break;
612
613 case eSAP_STA_ASSOC_EVENT:
614 case eSAP_STA_REASSOC_EVENT:
615 wrqu.addr.sa_family = ARPHRD_ETHER;
616 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800617 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800618 hddLog(LOG1, " associated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 we_event = IWEVREGISTERED;
620
621 WLANSAP_Get_WPS_State((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext, &bWPSState);
622
623 if ( (eCSR_ENCRYPT_TYPE_NONE == pHddApCtx->ucEncryptType) ||
624 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddApCtx->ucEncryptType ) ||
625 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddApCtx->ucEncryptType ) )
626 {
627 bAuthRequired = FALSE;
628 }
629
630 if (bAuthRequired || bWPSState == eANI_BOOLEAN_TRUE )
631 {
632 hdd_softap_RegisterSTA( pHostapdAdapter,
633 TRUE,
634 pHddApCtx->uPrivacy,
635 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
636 0,
637 0,
638 (v_MACADDR_t *)wrqu.addr.sa_data,
639 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
640 }
641 else
642 {
643 hdd_softap_RegisterSTA( pHostapdAdapter,
644 FALSE,
645 pHddApCtx->uPrivacy,
646 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staId,
647 0,
648 0,
649 (v_MACADDR_t *)wrqu.addr.sa_data,
650 pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled);
Amar Singhal6144c002013-05-03 16:11:42 -0700651 }
652
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 // Stop AP inactivity timer
654 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_RUNNING)
655 {
656 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
657 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800658 hddLog(LOGE, FL("Failed to start AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800660#ifdef WLAN_OPEN_SOURCE
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -0800661 if (wake_lock_active(&pHddCtx->sap_wake_lock))
662 {
663 wake_unlock(&pHddCtx->sap_wake_lock);
664 }
Amar Singhal6144c002013-05-03 16:11:42 -0700665 wake_lock_timeout(&pHddCtx->sap_wake_lock, msecs_to_jiffies(HDD_SAP_WAKE_LOCK_DURATION));
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800666#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700667#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
668 {
669 struct station_info staInfo;
670 v_U16_t iesLen = pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.iesLen;
671
672 memset(&staInfo, 0, sizeof(staInfo));
673 if (iesLen <= MAX_ASSOC_IND_IE_LEN )
674 {
675 staInfo.assoc_req_ies =
676 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.ies[0];
677 staInfo.assoc_req_ies_len = iesLen;
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700678#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,31))
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700679 staInfo.filled |= STATION_INFO_ASSOC_REQ_IES;
680#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 cfg80211_new_sta(dev,
682 (const u8 *)&pSapEvent->sapevt.sapStationAssocReassocCompleteEvent.staMac.bytes[0],
683 &staInfo, GFP_KERNEL);
684 }
685 else
686 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800687 hddLog(LOGE, FL(" Assoc Ie length is too long"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 }
689 }
690#endif
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800691 pScanInfo = &pHddCtx->scan_info;
692 // Lets do abort scan to ensure smooth authentication for client
693 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
694 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +0530695 hdd_abort_mac_scan(pHddCtx, pHostapdAdapter->sessionId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -0800696 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700697
698 break;
699 case eSAP_STA_DISASSOC_EVENT:
700 memcpy(wrqu.addr.sa_data, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac,
Kumar Pavan0cf0cf22012-12-13 15:13:41 -0800701 sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800702 hddLog(LOG1, " disassociated "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(wrqu.addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 if (pSapEvent->sapevt.sapStationDisassocCompleteEvent.reason == eSAP_USR_INITATED_DISASSOC)
704 hddLog(LOG1," User initiated disassociation");
705 else
706 hddLog(LOG1," MAC initiated disassociation");
707 we_event = IWEVEXPIRED;
708 vos_status = hdd_softap_GetStaId(pHostapdAdapter, &pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac, &staId);
709 if (!VOS_IS_STATUS_SUCCESS(vos_status))
710 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700711 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 -0700712 return VOS_STATUS_E_FAILURE;
713 }
714 hdd_softap_DeregisterSTA(pHostapdAdapter, staId);
715
716 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
717 {
718 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
719 // Start AP inactivity timer if no stations associated with it
720 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
721 {
722 if (pHostapdAdapter->aStaInfo[i].isUsed && i != (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uBCStaId)
723 {
724 bApActive = TRUE;
725 break;
726 }
727 }
728 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
729
730 if (bApActive == FALSE)
731 {
732 if (pHddApCtx->hdd_ap_inactivity_timer.state == VOS_TIMER_STATE_STOPPED)
733 {
734 vos_status = vos_timer_start(&pHddApCtx->hdd_ap_inactivity_timer, (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff * 1000);
735 if (!VOS_IS_STATUS_SUCCESS(vos_status))
Arif Hussain6d2a3322013-11-17 19:50:10 -0800736 hddLog(LOGE, FL("Failed to init AP inactivity timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 }
738 else
739 VOS_ASSERT(vos_timer_getCurrentState(&pHddApCtx->hdd_ap_inactivity_timer) == VOS_TIMER_STATE_STOPPED);
740 }
741 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700742#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
743 cfg80211_del_sta(dev,
744 (const u8 *)&pSapEvent->sapevt.sapStationDisassocCompleteEvent.staMac.bytes[0],
745 GFP_KERNEL);
746#endif
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800747 //Update the beacon Interval if it is P2P GO
748 hdd_change_mcc_go_beacon_interval(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 break;
750 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
751 {
752 static const char * message ="MLMEWPSPBCPROBEREQ.indication";
753 union iwreq_data wreq;
754
755 down(&pHddApCtx->semWpsPBCOverlapInd);
756 pHddApCtx->WPSPBCProbeReq.probeReqIELen = pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIELen;
757
758 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.probeReqIE, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.probeReqIE,
759 pHddApCtx->WPSPBCProbeReq.probeReqIELen);
760
761 vos_mem_copy(pHddApCtx->WPSPBCProbeReq.peerMacAddr, pSapEvent->sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq.peerMacAddr, sizeof(v_MACADDR_t));
Arif Hussain6d2a3322013-11-17 19:50:10 -0800762 hddLog(LOG1, "WPS PBC probe req "MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHddApCtx->WPSPBCProbeReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 memset(&wreq, 0, sizeof(wreq));
764 wreq.data.length = strlen(message); // This is length of message
765 wireless_send_event(dev, IWEVCUSTOM, &wreq, (char *)message);
766
767 return VOS_STATUS_SUCCESS;
768 }
769 case eSAP_ASSOC_STA_CALLBACK_EVENT:
770 pAssocStasArray = pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas;
771 if (pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta != 0)
772 { // List of associated stations
773 for (i = 0; i < pSapEvent->sapevt.sapAssocStaListEvent.noOfAssocSta; i++)
774 {
775 hddLog(LOG1,"Associated Sta Num %d:assocId=%d, staId=%d, staMac="MAC_ADDRESS_STR,
776 i+1,
777 pAssocStasArray->assocId,
778 pAssocStasArray->staId,
779 MAC_ADDR_ARRAY(pAssocStasArray->staMac.bytes));
780 pAssocStasArray++;
781 }
782 }
783 vos_mem_free(pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas);// Release caller allocated memory here
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -0800784 pSapEvent->sapevt.sapAssocStaListEvent.pAssocStas = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 case eSAP_INDICATE_MGMT_FRAME:
787 hdd_indicateMgmtFrame( pHostapdAdapter,
788 pSapEvent->sapevt.sapManagementFrameInfo.nFrameLength,
789 pSapEvent->sapevt.sapManagementFrameInfo.pbFrames,
790 pSapEvent->sapevt.sapManagementFrameInfo.frameType,
Chilam NG571c65a2013-01-19 12:27:36 +0530791 pSapEvent->sapevt.sapManagementFrameInfo.rxChan, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 return VOS_STATUS_SUCCESS;
793 case eSAP_REMAIN_CHAN_READY:
794 hdd_remainChanReadyHandler( pHostapdAdapter );
795 return VOS_STATUS_SUCCESS;
796 case eSAP_SEND_ACTION_CNF:
797 hdd_sendActionCnf( pHostapdAdapter,
798 ( eSAP_STATUS_SUCCESS ==
799 pSapEvent->sapevt.sapActionCnf.actionSendSuccess ) ?
800 TRUE : FALSE );
801 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 case eSAP_UNKNOWN_STA_JOIN:
803 snprintf(unknownSTAEvent, IW_CUSTOM_MAX, "JOIN_UNKNOWN_STA-%02x:%02x:%02x:%02x:%02x:%02x",
804 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[0],
805 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[1],
806 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[2],
807 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[3],
808 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[4],
809 pSapEvent->sapevt.sapUnknownSTAJoin.macaddr.bytes[5]);
810 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
811 wrqu.data.pointer = unknownSTAEvent;
812 wrqu.data.length = strlen(unknownSTAEvent);
813 we_custom_event_generic = (v_BYTE_t *)unknownSTAEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -0800814 hddLog(LOG1,"%s", unknownSTAEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 break;
816
817 case eSAP_MAX_ASSOC_EXCEEDED:
818 snprintf(maxAssocExceededEvent, IW_CUSTOM_MAX, "Peer %02x:%02x:%02x:%02x:%02x:%02x denied"
819 " assoc due to Maximum Mobile Hotspot connections reached. Please disconnect"
820 " one or more devices to enable the new device connection",
821 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[0],
822 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[1],
823 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[2],
824 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[3],
825 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[4],
826 pSapEvent->sapevt.sapMaxAssocExceeded.macaddr.bytes[5]);
827 we_event = IWEVCUSTOM; /* Discovered a new node (AP mode). */
828 wrqu.data.pointer = maxAssocExceededEvent;
829 wrqu.data.length = strlen(maxAssocExceededEvent);
830 we_custom_event_generic = (v_BYTE_t *)maxAssocExceededEvent;
Arif Hussain6d2a3322013-11-17 19:50:10 -0800831 hddLog(LOG1,"%s", maxAssocExceededEvent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 break;
833 case eSAP_STA_ASSOC_IND:
834 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800835
836 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800837 hddLog(LOG1, FL(" Disconnecting all the P2P Clients...."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800838 hdd_clear_all_sta(pHostapdAdapter, usrDataForCallback);
839 return VOS_STATUS_SUCCESS;
840
841 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
842 hdd_stop_p2p_link(pHostapdAdapter, usrDataForCallback);
843 return VOS_STATUS_SUCCESS;
844
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800846 hddLog(LOG1,"SAP message is not handled");
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 goto stopbss;
848 return VOS_STATUS_SUCCESS;
849 }
850 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
851 return VOS_STATUS_SUCCESS;
852
853stopbss :
854 {
855 v_BYTE_t we_custom_event[64];
856 char *stopBssEvent = "STOP-BSS.response";//17
857 int event_len = strlen(stopBssEvent);
858
859 hddLog(LOG1, FL("BSS stop status = %s"),
860 pSapEvent->sapevt.sapStopBssCompleteEvent.status ?
861 "eSAP_STATUS_FAILURE" : "eSAP_STATUS_SUCCESS");
862
863 /* Change the BSS state now since, as we are shutting things down,
864 * we don't want interfaces to become re-enabled */
865 pHostapdState->bssState = BSS_STOP;
866
Gopichand Nakkalaf8fe15d2013-05-27 13:55:40 +0530867 if (0 != (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->nAPAutoShutOff)
868 {
869 if (VOS_TIMER_STATE_RUNNING == pHddApCtx->hdd_ap_inactivity_timer.state)
870 {
871 vos_status = vos_timer_stop(&pHddApCtx->hdd_ap_inactivity_timer);
872 if (!VOS_IS_STATUS_SUCCESS(vos_status))
873 hddLog(LOGE, FL("Failed to stop AP inactivity timer"));
874 }
875
876 vos_status = vos_timer_destroy(&pHddApCtx->hdd_ap_inactivity_timer);
877 if (!VOS_IS_STATUS_SUCCESS(vos_status))
878 hddLog(LOGE, FL("Failed to Destroy AP inactivity timer"));
879 }
880
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 /* Stop the pkts from n/w stack as we are going to free all of
882 * the TX WMM queues for all STAID's */
883 hdd_hostapd_stop(dev);
884
885 /* reclaim all resources allocated to the BSS */
886 hdd_softap_stop_bss(pHostapdAdapter);
887
Amar Singhal37e6f052013-03-05 16:16:54 -0800888 /* once the event is set, structure dev/pHostapdAdapter should
889 * not be touched since they are now subject to being deleted
890 * by another thread */
891 if (eSAP_STOP_BSS_EVENT == sapEvent)
892 vos_event_set(&pHostapdState->vosEvent);
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 /* notify userspace that the BSS has stopped */
895 memset(&we_custom_event, '\0', sizeof(we_custom_event));
896 memcpy(&we_custom_event, stopBssEvent, event_len);
897 memset(&wrqu, 0, sizeof(wrqu));
898 wrqu.data.length = event_len;
899 we_event = IWEVCUSTOM;
900 we_custom_event_generic = we_custom_event;
901 wireless_send_event(dev, we_event, &wrqu, (char *)we_custom_event_generic);
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700902 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 }
904 return VOS_STATUS_SUCCESS;
905}
906int hdd_softap_unpackIE(
907 tHalHandle halHandle,
908 eCsrEncryptionType *pEncryptType,
909 eCsrEncryptionType *mcEncryptType,
910 eCsrAuthType *pAuthType,
911 u_int16_t gen_ie_len,
912 u_int8_t *gen_ie )
913{
914 tDot11fIERSN dot11RSNIE;
915 tDot11fIEWPA dot11WPAIE;
916
917 tANI_U8 *pRsnIe;
918 tANI_U16 RSNIeLen;
919
920 if (NULL == halHandle)
921 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800922 hddLog(LOGE, FL("Error haHandle returned NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 return -EINVAL;
924 }
925
926 // Validity checks
927 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
928 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
929 return -EINVAL;
930 // Type check
931 if ( gen_ie[0] == DOT11F_EID_RSN)
932 {
933 // Validity checks
934 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
935 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
936 {
937 return VOS_STATUS_E_FAILURE;
938 }
939 // Skip past the EID byte and length byte
940 pRsnIe = gen_ie + 2;
941 RSNIeLen = gen_ie_len - 2;
942 // Unpack the RSN IE
943 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
944 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
945 pRsnIe,
946 RSNIeLen,
947 &dot11RSNIE);
948 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -0800949 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700950 __func__, dot11RSNIE.pwise_cipher_suite_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -0800951 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700952 __func__, dot11RSNIE.akm_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 /*Here we have followed the apple base code,
954 but probably I suspect we can do something different*/
955 //dot11RSNIE.akm_suite_count
956 // Just translate the FIRST one
957 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
958 //dot11RSNIE.pwise_cipher_suite_count
959 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
960 //dot11RSNIE.gp_cipher_suite_count
961 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
962 // Set the PMKSA ID Cache for this interface
963
964 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
965 } else
966 if (gen_ie[0] == DOT11F_EID_WPA)
967 {
968 // Validity checks
969 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
970 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
971 {
972 return VOS_STATUS_E_FAILURE;
973 }
974 // Skip past the EID byte and length byte - and four byte WiFi OUI
975 pRsnIe = gen_ie + 2 + 4;
976 RSNIeLen = gen_ie_len - (2 + 4);
977 // Unpack the WPA IE
978 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
979 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
980 pRsnIe,
981 RSNIeLen,
982 &dot11WPAIE);
983 // Copy out the encryption and authentication types
Arif Hussain6d2a3322013-11-17 19:50:10 -0800984 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700985 __func__, dot11WPAIE.unicast_cipher_count );
Arif Hussain6d2a3322013-11-17 19:50:10 -0800986 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700987 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 //dot11WPAIE.auth_suite_count
989 // Just translate the FIRST one
990 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
991 //dot11WPAIE.unicast_cipher_count
992 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
993 //dot11WPAIE.unicast_cipher_count
994 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
995 }
996 else
997 {
Arif Hussain6d2a3322013-11-17 19:50:10 -0800998 hddLog(LOGW, FL("%s: gen_ie[0]: %d"), __func__, gen_ie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 return VOS_STATUS_E_FAILURE;
1000 }
1001 return VOS_STATUS_SUCCESS;
1002}
Leo Chang614d2072013-08-22 14:59:44 -07001003
Jeff Johnson295189b2012-06-20 16:38:30 -07001004int
1005static iw_softap_setparam(struct net_device *dev,
1006 struct iw_request_info *info,
1007 union iwreq_data *wrqu, char *extra)
1008{
1009 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1010 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1011 int *value = (int *)extra;
1012 int sub_cmd = value[0];
1013 int set_value = value[1];
1014 eHalStatus status;
1015 int ret = 0; /* success */
1016 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1017
1018 switch(sub_cmd)
1019 {
1020
1021 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001022 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 {
1024 ret = -EIO;
1025 }
1026 break;
1027
1028 case QCSAP_PARAM_ACL_MODE:
1029 if ((eSAP_ALLOW_ALL < (eSapMacAddrACL)set_value) ||
1030 (eSAP_ACCEPT_UNLESS_DENIED > (eSapMacAddrACL)set_value))
1031 {
1032 hddLog(LOGE, FL("Invalid ACL Mode value %d"), set_value);
1033 ret = -EINVAL;
1034 }
1035 else
1036 {
1037 WLANSAP_SetMode(pVosContext, set_value);
1038 }
1039 break;
1040 case QCSAP_PARAM_MAX_ASSOC:
1041 if (WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value)
1042 {
1043 hddLog(LOGE, FL("Invalid setMaxAssoc value %d"), set_value);
1044 ret = -EINVAL;
1045 }
1046 else
1047 {
1048 if (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)
1049 {
1050 hddLog(LOGW, FL("setMaxAssoc value %d higher than max allowed %d."
1051 "Setting it to max allowed and continuing"),
1052 set_value, WNI_CFG_ASSOC_STA_LIMIT_STAMAX);
1053 set_value = WNI_CFG_ASSOC_STA_LIMIT_STAMAX;
1054 }
1055 status = ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
1056 set_value, NULL, eANI_BOOLEAN_FALSE);
1057 if ( status != eHAL_STATUS_SUCCESS )
1058 {
1059 hddLog(LOGE, FL("setMaxAssoc failure, status %d"),
1060 status);
1061 ret = -EIO;
1062 }
1063 }
1064 break;
1065
1066 case QCSAP_PARAM_HIDE_SSID:
1067 {
1068 eHalStatus status = eHAL_STATUS_SUCCESS;
1069 status = sme_HideSSID(hHal, pHostapdAdapter->sessionId, set_value);
1070 if(eHAL_STATUS_SUCCESS != status)
1071 {
1072 hddLog(VOS_TRACE_LEVEL_ERROR,
1073 "%s: QCSAP_PARAM_HIDE_SSID failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001074 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 return status;
1076 }
1077 break;
1078 }
1079
Leo Chang614d2072013-08-22 14:59:44 -07001080 case QCSAP_PARAM_SET_MC_RATE:
1081 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07001082 tSirRateUpdateInd *rateUpdate;
1083
1084 rateUpdate = (tSirRateUpdateInd *)
1085 vos_mem_malloc(sizeof(tSirRateUpdateInd));
1086 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07001087 {
1088 hddLog(VOS_TRACE_LEVEL_ERROR,
Leo Chang1f98cbd2013-10-17 15:03:52 -07001089 "%s: SET_MC_RATE indication alloc fail", __func__);
1090 ret = -1;
1091 break;
1092 }
1093 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
1094
1095 hddLog(VOS_TRACE_LEVEL_INFO, "MC Target rate %d", set_value);
1096 /* Ignore unicast */
1097 rateUpdate->ucastDataRate = -1;
1098 rateUpdate->mcastDataRate24GHz = set_value;
1099 rateUpdate->mcastDataRate5GHz = set_value;
1100 rateUpdate->mcastDataRate24GHzTxFlag = 0;
1101 rateUpdate->mcastDataRate5GHzTxFlag = 0;
1102 status = sme_SendRateUpdateInd(hHal, rateUpdate);
1103 if (eHAL_STATUS_SUCCESS != status)
1104 {
1105 hddLog(VOS_TRACE_LEVEL_ERROR,
1106 "%s: SET_MC_RATE failed", __func__);
1107 vos_mem_free(rateUpdate);
1108 ret = -1;
Leo Chang614d2072013-08-22 14:59:44 -07001109 }
1110 break;
1111 }
1112
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 default:
1114 hddLog(LOGE, FL("Invalid setparam command %d value %d"),
1115 sub_cmd, set_value);
1116 ret = -EINVAL;
1117 break;
1118 }
1119
1120 return ret;
1121}
1122
1123
1124int
1125static iw_softap_getparam(struct net_device *dev,
1126 struct iw_request_info *info,
1127 union iwreq_data *wrqu, char *extra)
1128{
1129 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1130 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1131 int *value = (int *)extra;
1132 int sub_cmd = value[0];
1133 eHalStatus status;
1134 int ret = 0; /* success */
1135 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1136
1137 switch (sub_cmd)
1138 {
1139 case QCSAP_PARAM_MAX_ASSOC:
1140 status = ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value);
1141 if (eHAL_STATUS_SUCCESS != status)
1142 {
1143 ret = -EIO;
1144 }
1145 break;
1146
1147 case QCSAP_PARAM_CLR_ACL:
Jeff Johnson43971f52012-07-17 12:26:56 -07001148 if ( VOS_STATUS_SUCCESS != WLANSAP_ClearACL( pVosContext ))
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 {
1150 ret = -EIO;
1151 }
1152 *value = 0;
1153 break;
1154
1155 case QCSAP_PARAM_MODULE_DOWN_IND:
1156 {
1157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001158 "%s: sending WLAN_MODULE_DOWN_IND", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
1160#ifdef WLAN_BTAMP_FEATURE
1161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001162 "%s: Take down AMP PAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 BSL_Deinit(vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
1164#endif
1165 *value = 0;
1166 break;
Jeff Johnson43971f52012-07-17 12:26:56 -07001167 }
1168
1169 case QCSAP_PARAM_GET_WLAN_DBG:
1170 {
1171 vos_trace_display();
1172 *value = 0;
1173 break;
1174 }
1175
1176 case QCSAP_PARAM_AUTO_CHANNEL:
1177 {
1178 *value = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apAutoChannelSelection;
1179 break;
1180 }
1181
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 default:
1183 hddLog(LOGE, FL("Invalid getparam command %d"), sub_cmd);
1184 ret = -EINVAL;
1185 break;
1186
1187 }
1188
1189 return ret;
1190}
1191
1192/* Usage:
1193 BLACK_LIST = 0
1194 WHITE_LIST = 1
1195 ADD MAC = 0
1196 REMOVE MAC = 1
1197
1198 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
1199 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
1200 while using this ioctl
1201
1202 Syntax:
1203 iwpriv softap.0 modify_acl
1204 <6 octet mac addr> <list type> <cmd type>
1205
1206 Examples:
1207 eg 1. to add a mac addr 00:0a:f5:89:89:90 to the black list
1208 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 0 0
1209 eg 2. to delete a mac addr 00:0a:f5:89:89:90 from white list
1210 iwpriv softap.0 modify_acl 0x00 0x0a 0xf5 0x89 0x89 0x90 1 1
1211*/
1212int iw_softap_modify_acl(struct net_device *dev, struct iw_request_info *info,
1213 union iwreq_data *wrqu, char *extra)
1214{
1215 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1216 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1217 v_BYTE_t *value = (v_BYTE_t*)extra;
1218 v_U8_t pPeerStaMac[VOS_MAC_ADDR_SIZE];
1219 int listType, cmd, i;
1220 int ret = 0; /* success */
1221
1222 ENTER();
1223 for (i=0; i<VOS_MAC_ADDR_SIZE; i++)
1224 {
1225 pPeerStaMac[i] = *(value+i);
1226 }
1227 listType = (int)(*(value+i));
1228 i++;
1229 cmd = (int)(*(value+i));
1230
Arif Hussain24bafea2013-11-15 15:10:03 -08001231 hddLog(LOG1, "%s: SAP Modify ACL arg0 " MAC_ADDRESS_STR " arg1 %d arg2 %d",
1232 __func__, MAC_ADDR_ARRAY(pPeerStaMac), listType, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07001233
1234 if (WLANSAP_ModifyACL(pVosContext, pPeerStaMac,(eSapACLType)listType,(eSapACLCmdType)cmd)
1235 != VOS_STATUS_SUCCESS)
1236 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001237 hddLog(LOGE, FL("Modify ACL failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 ret = -EIO;
1239 }
1240 EXIT();
1241 return ret;
1242}
1243
1244int
1245static iw_softap_getchannel(struct net_device *dev,
1246 struct iw_request_info *info,
1247 union iwreq_data *wrqu, char *extra)
1248{
1249 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1250
Jeff Johnson43971f52012-07-17 12:26:56 -07001251 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07001252
Jeff Johnson43971f52012-07-17 12:26:56 -07001253 *value = (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->operatingChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 return 0;
1255}
1256
Jeff Johnsone7245742012-09-05 17:12:55 -07001257int
schang86c22c42013-03-13 18:41:24 -07001258static iw_softap_set_max_tx_power(struct net_device *dev,
Jeff Johnsone7245742012-09-05 17:12:55 -07001259 struct iw_request_info *info,
1260 union iwreq_data *wrqu, char *extra)
1261{
1262 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1263 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
schang86c22c42013-03-13 18:41:24 -07001264 int *value = (int *)extra;
Jeff Johnsone7245742012-09-05 17:12:55 -07001265 int set_value;
1266 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
1267 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
1268
schang86c22c42013-03-13 18:41:24 -07001269 if (NULL == value)
Jeff Johnsone7245742012-09-05 17:12:55 -07001270 return -ENOMEM;
1271
Leo Changd37675a2013-08-01 13:19:45 -07001272 /* Assign correct slef MAC address */
1273 vos_mem_copy(bssid, pHostapdAdapter->macAddressCurrent.bytes,
1274 VOS_MAC_ADDR_SIZE);
1275 vos_mem_copy(selfMac, pHostapdAdapter->macAddressCurrent.bytes,
1276 VOS_MAC_ADDR_SIZE);
1277
schang86c22c42013-03-13 18:41:24 -07001278 set_value = value[0];
1279 if (eHAL_STATUS_SUCCESS != sme_SetMaxTxPower(hHal, bssid, selfMac, set_value))
1280 {
1281 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001282 __func__);
schang86c22c42013-03-13 18:41:24 -07001283 return -EIO;
1284 }
1285
1286 return 0;
1287}
1288
1289int
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05301290static iw_display_data_path_snapshot(struct net_device *dev,
1291 struct iw_request_info *info,
1292 union iwreq_data *wrqu, char *extra)
1293{
1294
1295 /* Function intitiating dumping states of
1296 * HDD(WMM Tx Queues)
1297 * TL State (with Per Client infor)
1298 * DXE Snapshot (Called at the end of TL Snapshot)
1299 */
1300 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1301 hddLog(LOGE, "%s: called for SAP",__func__);
1302 hdd_wmm_tx_snapshot(pHostapdAdapter);
1303 WLANTL_TLDebugMessage(VOS_TRUE);
1304 return 0;
1305}
1306
1307int
schang86c22c42013-03-13 18:41:24 -07001308static iw_softap_set_tx_power(struct net_device *dev,
1309 struct iw_request_info *info,
1310 union iwreq_data *wrqu, char *extra)
1311{
1312 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1313 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1314 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1315 int *value = (int *)extra;
1316 int set_value;
1317 ptSapContext pSapCtx = NULL;
1318
1319 if (NULL == value)
1320 return -ENOMEM;
1321
1322 pSapCtx = VOS_GET_SAP_CB(pVosContext);
1323 if (NULL == pSapCtx)
1324 {
1325 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1326 "%s: Invalid SAP pointer from pvosGCtx", __func__);
1327 return VOS_STATUS_E_FAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07001328 }
1329
1330 set_value = value[0];
schang86c22c42013-03-13 18:41:24 -07001331 if (eHAL_STATUS_SUCCESS != sme_SetTxPower(hHal, pSapCtx->sessionId, set_value))
Jeff Johnsone7245742012-09-05 17:12:55 -07001332 {
schang86c22c42013-03-13 18:41:24 -07001333 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting tx power failed",
Jeff Johnsone7245742012-09-05 17:12:55 -07001334 __func__);
1335 return -EIO;
1336 }
1337
1338 return 0;
1339}
1340
Kiet Lambcf38522013-10-26 18:28:27 +05301341/**---------------------------------------------------------------------------
1342
1343 \brief iw_softap_set_trafficmonitor() -
1344 This function dynamically enable/disable traffic monitor functonality
1345 the command iwpriv wlanX setTrafficMon <value>.
1346
1347 \param - dev - Pointer to the net device.
1348 - addr - Pointer to the sockaddr.
1349 \return - 0 for success, non zero for failure
1350
1351 --------------------------------------------------------------------------*/
1352
1353static int iw_softap_set_trafficmonitor(struct net_device *dev,
1354 struct iw_request_info *info,
1355 union iwreq_data *wrqu, char *extra)
1356{
1357 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1358 int *isSetTrafficMon = (int *)wrqu->data.pointer;
1359 hdd_context_t *pHddCtx;
1360 int status;
1361
1362 if (NULL == pAdapter)
1363 {
1364 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1365 "%s: HDD adapter is Null", __func__);
1366 return -ENODEV;
1367 }
1368
1369 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1370
1371 status = wlan_hdd_validate_context(pHddCtx);
1372
1373 if (0 != status)
1374 {
1375 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1376 "%s: HDD context is not valid", __func__);
1377 return status;
1378 }
1379
1380 hddLog(VOS_TRACE_LEVEL_INFO, "%s : ", __func__);
1381
1382 if (NULL == isSetTrafficMon)
1383 {
1384 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1385 "%s: Invalid SAP pointer from extra", __func__);
1386 return -ENOMEM;
1387 }
1388
1389 if (TRUE == *isSetTrafficMon)
1390 {
1391 pHddCtx->cfg_ini->enableTrafficMonitor= TRUE;
1392 if (VOS_STATUS_SUCCESS != hdd_start_trafficMonitor(pAdapter))
1393 {
1394 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
1395 "%s: failed to Start Traffic Monitor timer ", __func__ );
1396 return -EIO;
1397 }
1398 }
1399 else if (FALSE == *isSetTrafficMon)
1400 {
1401 pHddCtx->cfg_ini->enableTrafficMonitor= FALSE;
1402 if (VOS_STATUS_SUCCESS != hdd_stop_trafficMonitor(pAdapter))
1403 {
1404 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
1405 "%s: failed to Stop Traffic Monitor timer ", __func__ );
1406 return -EIO;
1407 }
1408
1409 }
1410 return 0;
1411}
1412
Jeff Johnson295189b2012-06-20 16:38:30 -07001413#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
1414
1415int
1416static iw_softap_getassoc_stamacaddr(struct net_device *dev,
1417 struct iw_request_info *info,
1418 union iwreq_data *wrqu, char *extra)
1419{
1420 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07001421 unsigned int maclist_index;
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 hdd_station_info_t *pStaInfo = pHostapdAdapter->aStaInfo;
Arif Hussained667642013-10-27 23:01:14 -07001423 char maclist_null = '\0';
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 int cnt = 0, len;
1425
1426
Arif Hussained667642013-10-27 23:01:14 -07001427 maclist_index = sizeof(unsigned long int);
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 len = wrqu->data.length;
1429
1430 spin_lock_bh( &pHostapdAdapter->staInfo_lock );
1431 while((cnt < WLAN_MAX_STA_COUNT) && (len > (sizeof(v_MACADDR_t)+1))) {
1432 if (TRUE == pStaInfo[cnt].isUsed) {
1433
1434 if(!IS_BROADCAST_MAC(pStaInfo[cnt].macAddrSTA.bytes)) {
Arif Hussained667642013-10-27 23:01:14 -07001435 if (copy_to_user((void *)wrqu->data.pointer + maclist_index,
1436 (void *)&(pStaInfo[cnt].macAddrSTA), sizeof(v_MACADDR_t)))
1437 {
1438 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1439 return -EFAULT;
1440 }
1441 maclist_index += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 len -= sizeof(v_MACADDR_t);
1443 }
1444 }
1445 cnt++;
1446 }
1447 spin_unlock_bh( &pHostapdAdapter->staInfo_lock );
1448
Arif Hussained667642013-10-27 23:01:14 -07001449 if (copy_to_user((void *)wrqu->data.pointer + maclist_index,
1450 (void *)&maclist_null, sizeof(maclist_null)) ||
1451 copy_to_user((void *)wrqu->data.pointer,
1452 (void *)&wrqu->data.length, sizeof(wrqu->data.length)))
1453 {
1454 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1455 return -EFAULT;
1456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 wrqu->data.length -= len;
1458
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 return 0;
1460}
1461
1462/* Usage:
1463 mac addr will be accepted as a 6 octet mac address with each octet inputted in hex
1464 for e.g. 00:0a:f5:11:22:33 will be represented as 0x00 0x0a 0xf5 0x11 0x22 0x33
1465 while using this ioctl
1466
1467 Syntax:
1468 iwpriv softap.0 disassoc_sta <6 octet mac address>
1469
1470 e.g.
1471 disassociate sta with mac addr 00:0a:f5:11:22:33 from softap
1472 iwpriv softap.0 disassoc_sta 0x00 0x0a 0xf5 0x11 0x22 0x33
1473*/
1474
1475int
1476static iw_softap_disassoc_sta(struct net_device *dev,
1477 struct iw_request_info *info,
1478 union iwreq_data *wrqu, char *extra)
1479{
1480 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1481 v_U8_t *peerMacAddr;
1482
1483 ENTER();
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05301484 /* iwpriv tool or framework calls this ioctl with
1485 * data passed in extra (less than 16 octets);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 */
Gopichand Nakkala252c9ef2013-02-27 17:01:23 +05301487 peerMacAddr = (v_U8_t *)(extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
Arif Hussain24bafea2013-11-15 15:10:03 -08001489 hddLog(LOG1, "%s data " MAC_ADDRESS_STR,
1490 __func__, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 hdd_softap_sta_disassoc(pHostapdAdapter, peerMacAddr);
1492 EXIT();
1493 return 0;
1494}
1495
1496int
1497static iw_softap_ap_stats(struct net_device *dev,
1498 struct iw_request_info *info,
1499 union iwreq_data *wrqu, char *extra)
1500{
1501 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1502 WLANTL_TRANSFER_STA_TYPE statBuffer;
1503 char *pstatbuf;
1504 int len = wrqu->data.length;
1505 pstatbuf = wrqu->data.pointer;
1506
Arif Hussained667642013-10-27 23:01:14 -07001507 WLANSAP_GetStatistics((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext,
1508 &statBuffer, (v_BOOL_t)wrqu->data.flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07001509
Arif Hussained667642013-10-27 23:01:14 -07001510 pstatbuf = kmalloc(wrqu->data.length, GFP_KERNEL);
1511 if(NULL == pstatbuf) {
1512 hddLog(LOG1, "unable to allocate memory");
1513 return -ENOMEM;
1514 }
1515 len = scnprintf(pstatbuf, wrqu->data.length,
1516 "RUF=%d RMF=%d RBF=%d "
1517 "RUB=%d RMB=%d RBB=%d "
1518 "TUF=%d TMF=%d TBF=%d "
1519 "TUB=%d TMB=%d TBB=%d",
1520 (int)statBuffer.rxUCFcnt, (int)statBuffer.rxMCFcnt,
1521 (int)statBuffer.rxBCFcnt, (int)statBuffer.rxUCBcnt,
1522 (int)statBuffer.rxMCBcnt, (int)statBuffer.rxBCBcnt,
1523 (int)statBuffer.txUCFcnt, (int)statBuffer.txMCFcnt,
1524 (int)statBuffer.txBCFcnt, (int)statBuffer.txUCBcnt,
1525 (int)statBuffer.txMCBcnt, (int)statBuffer.txBCBcnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07001526
Arif Hussained667642013-10-27 23:01:14 -07001527 if (len > wrqu->data.length ||
1528 copy_to_user((void *)wrqu->data.pointer, (void *)pstatbuf, len))
1529 {
1530 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1531 kfree(pstatbuf);
1532 return -EFAULT;
1533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 wrqu->data.length -= len;
Arif Hussained667642013-10-27 23:01:14 -07001535 kfree(pstatbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 return 0;
1537}
1538
1539int
1540static iw_softap_commit(struct net_device *dev,
1541 struct iw_request_info *info,
1542 union iwreq_data *wrqu, char *extra)
1543{
1544 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1545 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1546 hdd_hostapd_state_t *pHostapdState;
1547 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1548 tpWLAN_SAPEventCB pSapEventCallback;
1549 tsap_Config_t *pConfig;
1550 s_CommitConfig_t *pCommitConfig;
1551 struct qc_mac_acl_entry *acl_entry = NULL;
1552 v_SINT_t i = 0, num_mac = 0;
1553 v_U32_t status = 0;
1554 eCsrAuthType RSNAuthType;
1555 eCsrEncryptionType RSNEncryptType;
1556 eCsrEncryptionType mcRSNEncryptType;
1557
1558 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1559 pCommitConfig = (s_CommitConfig_t *)extra;
1560
1561 pConfig = kmalloc(sizeof(tsap_Config_t), GFP_KERNEL);
1562 if(NULL == pConfig) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001563 hddLog(LOG1, "VOS unable to allocate memory");
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 return -ENOMEM;
1565 }
1566 pConfig->beacon_int = pCommitConfig->beacon_int;
1567 pConfig->channel = pCommitConfig->channel;
1568
1569 /*Protection parameter to enable or disable*/
1570 pConfig->protEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1571 pConfig->dtim_period = pCommitConfig->dtim_period;
1572 switch(pCommitConfig->hw_mode )
1573 {
1574 case eQC_DOT11_MODE_11A:
1575 pConfig->SapHw_mode = eSAP_DOT11_MODE_11a;
1576 break;
1577 case eQC_DOT11_MODE_11B:
1578 pConfig->SapHw_mode = eSAP_DOT11_MODE_11b;
1579 break;
1580 case eQC_DOT11_MODE_11G:
1581 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g;
1582 break;
1583
1584 case eQC_DOT11_MODE_11N:
1585 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
1586 break;
1587 case eQC_DOT11_MODE_11G_ONLY:
1588 pConfig->SapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1589 break;
1590 case eQC_DOT11_MODE_11N_ONLY:
1591 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n_ONLY;
1592 break;
1593 default:
1594 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
1595 break;
1596
1597 }
1598
1599 pConfig->ieee80211d = pCommitConfig->qcsap80211d;
1600 vos_mem_copy(pConfig->countryCode, pCommitConfig->countryCode, 3);
1601 if(pCommitConfig->authType == eQC_AUTH_TYPE_SHARED_KEY)
1602 pConfig->authType = eSAP_SHARED_KEY;
1603 else if(pCommitConfig->authType == eQC_AUTH_TYPE_OPEN_SYSTEM)
1604 pConfig->authType = eSAP_OPEN_SYSTEM;
1605 else
1606 pConfig->authType = eSAP_AUTO_SWITCH;
1607
1608 pConfig->privacy = pCommitConfig->privacy;
1609 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pCommitConfig->privacy;
1610 pConfig->wps_state = pCommitConfig->wps_state;
1611 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
1612 pConfig->RSNWPAReqIELength = pCommitConfig->RSNWPAReqIELength;
1613 if(pConfig->RSNWPAReqIELength){
1614 pConfig->pRSNWPAReqIE = &pCommitConfig->RSNWPAReqIE[0];
1615 if ((pConfig->pRSNWPAReqIE[0] == DOT11F_EID_RSN) || (pConfig->pRSNWPAReqIE[0] == DOT11F_EID_WPA)){
1616 // The actual processing may eventually be more extensive than this.
1617 // Right now, just consume any PMKIDs that are sent in by the app.
1618 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 vos_get_context( VOS_MODULE_ID_PE, pVosContext),
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 &RSNEncryptType,
1621 &mcRSNEncryptType,
1622 &RSNAuthType,
1623 pConfig->pRSNWPAReqIE[1]+2,
1624 pConfig->pRSNWPAReqIE );
1625
1626 if( VOS_STATUS_SUCCESS == status )
1627 {
1628 // Now copy over all the security attributes you have parsed out
1629 //TODO: Need to handle mixed mode
1630 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1631 pConfig->mcRSNEncryptType = mcRSNEncryptType;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001632 hddLog( LOG1, FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1634 }
1635 }
1636 }
1637 else
1638 {
1639 /* If no RSNIE, set encrypt type to NONE*/
1640 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
1641 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001642 hddLog( LOG1, FL("EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 pConfig->RSNEncryptType, pConfig->mcRSNEncryptType);
1644 }
1645
Chilam Ngc4244af2013-04-01 15:37:32 -07001646 if (pConfig->RSNWPAReqIELength > QCSAP_MAX_OPT_IE) {
1647 hddLog(LOGE, FL("RSNWPAReqIELength: %d too large"), pConfig->RSNWPAReqIELength);
1648 kfree(pConfig);
1649 return -EIO;
1650 }
1651
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 pConfig->SSIDinfo.ssidHidden = pCommitConfig->SSIDinfo.ssidHidden;
1653 pConfig->SSIDinfo.ssid.length = pCommitConfig->SSIDinfo.ssid.length;
1654 vos_mem_copy(pConfig->SSIDinfo.ssid.ssId, pCommitConfig->SSIDinfo.ssid.ssId, pConfig->SSIDinfo.ssid.length);
1655 vos_mem_copy(pConfig->self_macaddr.bytes, pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1656
1657 pConfig->SapMacaddr_acl = pCommitConfig->qc_macaddr_acl;
1658
1659 // ht_capab is not what the name conveys,this is used for protection bitmap
1660 pConfig->ht_capab = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
1661
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301662 if (pCommitConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
1663 num_mac = pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 else
1665 num_mac = pConfig->num_accept_mac = pCommitConfig->num_accept_mac;
1666 acl_entry = pCommitConfig->accept_mac;
1667 for (i = 0; i < num_mac; i++)
1668 {
1669 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
1670 acl_entry++;
1671 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301672 if (pCommitConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
1673 num_mac = pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 else
1675 num_mac = pConfig->num_deny_mac = pCommitConfig->num_deny_mac;
1676 acl_entry = pCommitConfig->deny_mac;
1677 for (i = 0; i < num_mac; i++)
1678 {
1679 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(v_MACADDR_t));
1680 acl_entry++;
1681 }
1682 //Uapsd Enabled Bit
1683 pConfig->UapsdEnable = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
1684 //Enable OBSS protection
1685 pConfig->obssProtEnabled = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
1686 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd = (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apDisableIntraBssFwd;
1687
Arif Hussain6d2a3322013-11-17 19:50:10 -08001688 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
1689 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
1690 pConfig->SSIDinfo.ssid.ssId,
1691 (int)pConfig->beacon_int, (int)pConfig->channel);
1692 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
1693 pConfig->SapHw_mode, pConfig->privacy, pConfig->authType);
1694 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
1695 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
1696 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d, DisableIntraBssFwd = %d"),
1697 pConfig->protEnabled, pConfig->obssProtEnabled,
1698 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->apDisableIntraBssFwd);
Jeff Johnson295189b2012-06-20 16:38:30 -07001699
1700 pSapEventCallback = hdd_hostapd_SAPEventCB;
1701 pConfig->persona = pHostapdAdapter->device_mode;
1702 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,(v_PVOID_t)dev) != VOS_STATUS_SUCCESS)
1703 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001704 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 }
1706
1707 kfree(pConfig);
1708
1709 hddLog(LOG1, FL("Waiting for Scan to complete(auto mode) and BSS to start"));
1710 vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
1711
1712 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 VOS_ASSERT(0);
1716 }
1717
1718 pHostapdState->bCommit = TRUE;
1719 if(pHostapdState->vosStatus)
1720 {
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08001721 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 }
1723 else
1724 {
1725 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
1726 WLANSAP_Update_WpsIe ( pVosContext );
1727 return 0;
1728 }
1729}
1730static
1731int iw_softap_setmlme(struct net_device *dev,
1732 struct iw_request_info *info,
1733 union iwreq_data *wrqu, char *extra)
1734{
1735 struct sQcSapreq_mlme *pmlme;
1736 hdd_adapter_t *pHostapdAdapter = (hdd_adapter_t*)(netdev_priv(dev));
1737 v_MACADDR_t destAddress;
1738 pmlme = (struct sQcSapreq_mlme *)(wrqu->name);
1739 /* NOTE: this address is not valid incase of TKIP failure, since not filled */
1740 vos_mem_copy(&destAddress.bytes, pmlme->im_macaddr, sizeof(v_MACADDR_t));
1741 switch(pmlme->im_op)
1742 {
1743 case QCSAP_MLME_AUTHORIZE:
1744 hdd_softap_change_STA_state( pHostapdAdapter, &destAddress, WLANTL_STA_AUTHENTICATED);
1745 break;
1746 case QCSAP_MLME_ASSOC:
1747 //TODO:inform to TL after associating (not needed as we do in sapCallback)
1748 break;
1749 case QCSAP_MLME_UNAUTHORIZE:
1750 //TODO: send the disassoc to station
1751 //hdd_softap_change_STA_state( pHostapdAdapter, pmlme->im_macaddr, WLANTL_STA_AUTHENTICATED);
1752 break;
1753 case QCSAP_MLME_DISASSOC:
1754 hdd_softap_sta_disassoc(pHostapdAdapter,pmlme->im_macaddr);
1755 break;
1756 case QCSAP_MLME_DEAUTH:
1757 hdd_softap_sta_deauth(pHostapdAdapter,pmlme->im_macaddr);
1758 break;
1759 case QCSAP_MLME_MICFAILURE:
1760 hdd_softap_tkip_mic_fail_counter_measure(pHostapdAdapter,pmlme->im_reason);
1761 break;
1762 default:
1763 break;
1764 }
1765 return 0;
1766}
1767
1768static int iw_softap_set_channel_range(struct net_device *dev,
1769 struct iw_request_info *info,
1770 union iwreq_data *wrqu, char *extra)
1771{
1772 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1773 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001774 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001775
1776 int *value = (int *)extra;
1777 int startChannel = value[0];
1778 int endChannel = value[1];
1779 int band = value[2];
Jeff Johnson43971f52012-07-17 12:26:56 -07001780 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 int ret = 0; /* success */
1782
1783 status = WLANSAP_SetChannelRange(hHal,startChannel,endChannel,band);
1784 if(status != VOS_STATUS_SUCCESS)
1785 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001786 hddLog( LOGE, FL("iw_softap_set_channel_range: startChannel = %d, endChannel = %d band = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 startChannel,endChannel, band);
1788 ret = -EINVAL;
1789 }
Gopichand Nakkalaf7e53c52013-01-07 14:52:52 -08001790
1791 pHddCtx->is_dynamic_channel_range_set = 1;
1792
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 return ret;
1794}
1795
1796int iw_softap_get_channel_list(struct net_device *dev,
1797 struct iw_request_info *info,
1798 union iwreq_data *wrqu, char *extra)
1799{
1800 v_U32_t num_channels = 0;
1801 v_U8_t i = 0;
1802 v_U8_t bandStartChannel = RF_CHAN_1;
1803 v_U8_t bandEndChannel = RF_CHAN_165;
1804 v_U32_t temp_num_channels = 0;
1805 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1806 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1807 v_REGDOMAIN_t domainIdCurrentSoftap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 tpChannelListInfo channel_list = (tpChannelListInfo) extra;
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07001809 eCsrBand curBand = eCSR_BAND_ALL;
1810
1811 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &curBand))
1812 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001813 hddLog(LOGE,FL("not able get the current frequency band"));
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07001814 return -EIO;
1815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 wrqu->data.length = sizeof(tChannelListInfo);
1817 ENTER();
1818
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07001819 if (eCSR_BAND_24 == curBand)
1820 {
1821 bandStartChannel = RF_CHAN_1;
1822 bandEndChannel = RF_CHAN_14;
1823 }
1824 else if (eCSR_BAND_5G == curBand)
1825 {
1826 bandStartChannel = RF_CHAN_36;
1827 bandEndChannel = RF_CHAN_165;
1828 }
1829
Arif Hussain6d2a3322013-11-17 19:50:10 -08001830 hddLog(LOG1, FL("curBand = %d, bandStartChannel = %hu, "
Gopichand Nakkala29d00192013-06-20 19:03:52 +05301831 "bandEndChannel = %hu "), curBand,
Madan Mohan Koyyalamudibb7b43a2012-10-11 14:55:09 -07001832 bandStartChannel, bandEndChannel );
1833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 for( i = bandStartChannel; i <= bandEndChannel; i++ )
1835 {
1836 if( NV_CHANNEL_ENABLE == regChannels[i].enabled )
1837 {
1838 channel_list->channels[num_channels] = rfChannels[i].channelNum;
1839 num_channels++;
1840 }
1841 }
1842
1843 /* remove indoor channels if the domain is FCC, channels 36 - 48 */
1844
1845 temp_num_channels = num_channels;
1846
1847 if(eHAL_STATUS_SUCCESS != sme_getSoftApDomain(hHal,(v_REGDOMAIN_t *) &domainIdCurrentSoftap))
1848 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001849 hddLog(LOG1,FL("Failed to get Domain ID, %d"),domainIdCurrentSoftap);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08001850 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 }
1852
1853 if(REGDOMAIN_FCC == domainIdCurrentSoftap)
1854 {
1855 for(i = 0; i < temp_num_channels; i++)
1856 {
1857
1858 if((channel_list->channels[i] > 35) &&
1859 (channel_list->channels[i] < 49))
1860 {
1861 vos_mem_move(&channel_list->channels[i],
1862 &channel_list->channels[i+1],
1863 temp_num_channels - (i-1));
1864 num_channels--;
1865 temp_num_channels--;
1866 i--;
1867 }
1868 }
1869 }
1870
Arif Hussain6d2a3322013-11-17 19:50:10 -08001871 hddLog(LOG1,FL(" number of channels %d"), num_channels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001872
1873 if (num_channels > IW_MAX_FREQUENCIES)
1874 {
1875 num_channels = IW_MAX_FREQUENCIES;
1876 }
1877
1878 channel_list->num_channels = num_channels;
1879 EXIT();
1880
1881 return 0;
1882}
1883
1884static
1885int iw_get_genie(struct net_device *dev,
1886 struct iw_request_info *info,
1887 union iwreq_data *wrqu, char *extra)
1888{
1889 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
1890 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1891 eHalStatus status;
1892 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1893 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1894 ENTER();
Arif Hussain6d2a3322013-11-17 19:50:10 -08001895 hddLog(LOG1,FL("getGEN_IE ioctl"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
1897 status = WLANSap_getstationIE_information(pVosContext,
1898 &length,
1899 genIeBytes);
Arif Hussained667642013-10-27 23:01:14 -07001900 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
1901 if (wrqu->data.length < length ||
1902 copy_to_user(wrqu->data.pointer,
1903 (v_VOID_t*)genIeBytes, length))
1904 {
1905 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1906 return -EFAULT;
1907 }
1908 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07001909
Arif Hussain6d2a3322013-11-17 19:50:10 -08001910 hddLog(LOG1,FL(" RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07001911
1912
1913 EXIT();
1914 return 0;
1915}
1916static
1917int iw_get_WPSPBCProbeReqIEs(struct net_device *dev,
1918 struct iw_request_info *info,
1919 union iwreq_data *wrqu, char *extra)
1920{
1921 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Arif Hussained667642013-10-27 23:01:14 -07001922 sQcSapreq_WPSPBCProbeReqIES_t WPSPBCProbeReqIEs;
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
1924 ENTER();
Arif Hussained667642013-10-27 23:01:14 -07001925
Arif Hussain6d2a3322013-11-17 19:50:10 -08001926 hddLog(LOG1,FL("get_WPSPBCProbeReqIEs ioctl"));
Arif Hussained667642013-10-27 23:01:14 -07001927 memset((void*)&WPSPBCProbeReqIEs, 0, sizeof(WPSPBCProbeReqIEs));
1928
1929 WPSPBCProbeReqIEs.probeReqIELen = pHddApCtx->WPSPBCProbeReq.probeReqIELen;
1930 vos_mem_copy(&WPSPBCProbeReqIEs.probeReqIE,
1931 pHddApCtx->WPSPBCProbeReq.probeReqIE,
1932 WPSPBCProbeReqIEs.probeReqIELen);
1933 vos_mem_copy(&WPSPBCProbeReqIEs.macaddr,
1934 pHddApCtx->WPSPBCProbeReq.peerMacAddr,
1935 sizeof(v_MACADDR_t));
1936 if (copy_to_user(wrqu->data.pointer,
1937 (void *)&WPSPBCProbeReqIEs,
1938 sizeof(WPSPBCProbeReqIEs)))
1939 {
1940 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
1941 return -EFAULT;
1942 }
1943 wrqu->data.length = 12 + WPSPBCProbeReqIEs.probeReqIELen;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001944 hddLog(LOG1, FL("Macaddress : "MAC_ADDRESS_STR),
Arif Hussained667642013-10-27 23:01:14 -07001945 MAC_ADDR_ARRAY(WPSPBCProbeReqIEs.macaddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 up(&pHddApCtx->semWpsPBCOverlapInd);
1947 EXIT();
1948 return 0;
1949}
1950
1951/**---------------------------------------------------------------------------
1952
1953 \brief iw_set_auth_hostap() -
1954 This function sets the auth type received from the wpa_supplicant.
1955
1956 \param - dev - Pointer to the net device.
1957 - info - Pointer to the iw_request_info.
1958 - wrqu - Pointer to the iwreq_data.
1959 - extra - Pointer to the data.
1960 \return - 0 for success, non zero for failure
1961
1962 --------------------------------------------------------------------------*/
1963int iw_set_auth_hostap(struct net_device *dev,struct iw_request_info *info,
1964 union iwreq_data *wrqu,char *extra)
1965{
1966 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1967 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1968
1969 ENTER();
1970 switch(wrqu->param.flags & IW_AUTH_INDEX)
1971 {
1972 case IW_AUTH_TKIP_COUNTERMEASURES:
1973 {
1974 if(wrqu->param.value) {
1975 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1976 "Counter Measure started %d", wrqu->param.value);
1977 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
1978 }
1979 else {
1980 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1981 "Counter Measure stopped=%d", wrqu->param.value);
1982 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
1983 }
1984
1985 hdd_softap_tkip_mic_fail_counter_measure(pAdapter,
1986 wrqu->param.value);
1987 }
1988 break;
1989
1990 default:
1991
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001992 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 wrqu->param.flags & IW_AUTH_INDEX);
1994 break;
1995 }
1996
1997 EXIT();
1998 return 0;
1999}
2000
2001static int iw_set_ap_encodeext(struct net_device *dev,
2002 struct iw_request_info *info,
2003 union iwreq_data *wrqu, char *extra)
2004{
2005 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2006 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2007 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson43971f52012-07-17 12:26:56 -07002008 int retval = 0;
2009 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
2011 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2012 int key_index;
2013 struct iw_point *encoding = &wrqu->encoding;
2014 tCsrRoamSetKey setKey;
2015// tCsrRoamRemoveKey RemoveKey;
2016 int i;
Jeff Johnson43971f52012-07-17 12:26:56 -07002017
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 ENTER();
2019
2020 key_index = encoding->flags & IW_ENCODE_INDEX;
2021
2022 if(key_index > 0) {
2023
2024 /*Convert from 1-based to 0-based keying*/
2025 key_index--;
2026 }
2027 if(!ext->key_len) {
2028#if 0
2029 /*Set the encrytion type to NONE*/
2030#if 0
2031 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
2032#endif
2033
2034 RemoveKey.keyId = key_index;
2035 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2036 /*Key direction for group is RX only*/
2037 vos_mem_copy(RemoveKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2038 }
2039 else {
2040 vos_mem_copy(RemoveKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2041 }
2042 switch(ext->alg)
2043 {
2044 case IW_ENCODE_ALG_NONE:
2045 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2046 break;
2047 case IW_ENCODE_ALG_WEP:
2048 RemoveKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2049 break;
2050 case IW_ENCODE_ALG_TKIP:
2051 RemoveKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
Jeff Johnson43971f52012-07-17 12:26:56 -07002052 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 case IW_ENCODE_ALG_CCMP:
2054 RemoveKey.encType = eCSR_ENCRYPT_TYPE_AES;
2055 break;
2056 default:
2057 RemoveKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2058 break;
2059 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08002060 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 -07002061 __func__,(int)ext->alg,(int)ext->key_len,RemoveKey.encType);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Peer Mac = "MAC_ADDRESS_STR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002063 __func__, MAC_ADDR_ARRAY(RemoveKey.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 );
Jeff Johnson43971f52012-07-17 12:26:56 -07002065 vstatus = WLANSAP_DelKeySta( pVosContext, &RemoveKey);
2066 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 {
2068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "[%4d] WLANSAP_DeleteKeysSta returned ERROR status= %d",
Jeff Johnson43971f52012-07-17 12:26:56 -07002069 __LINE__, vstatus );
2070 retval = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002072#endif
2073 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002074
Jeff Johnson43971f52012-07-17 12:26:56 -07002075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002076
2077 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2078
2079 setKey.keyId = key_index;
2080 setKey.keyLength = ext->key_len;
2081
2082 if(ext->key_len <= CSR_MAX_KEY_LEN) {
2083 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
2084 }
2085
2086 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2087 /*Key direction for group is RX only*/
2088 setKey.keyDirection = eSIR_RX_ONLY;
2089 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2090 }
2091 else {
2092
2093 setKey.keyDirection = eSIR_TX_RX;
2094 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2095 }
2096 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2097 {
2098 setKey.keyDirection = eSIR_TX_DEFAULT;
2099 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
2100 }
2101
2102 /*For supplicant pae role is zero*/
2103 setKey.paeRole = 0;
2104
2105 switch(ext->alg)
2106 {
2107 case IW_ENCODE_ALG_NONE:
2108 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2109 break;
2110
2111 case IW_ENCODE_ALG_WEP:
2112 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
2113 pHddApCtx->uPrivacy = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002114 hddLog(LOG1, "(%s) uPrivacy=%d", __func__, pHddApCtx->uPrivacy);
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 break;
2116
2117 case IW_ENCODE_ALG_TKIP:
2118 {
2119 v_U8_t *pKey = &setKey.Key[0];
2120
2121 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
2122
2123 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
2124
2125 /*Supplicant sends the 32bytes key in this order
2126
2127 |--------------|----------|----------|
2128 | Tk1 |TX-MIC | RX Mic |
2129 |--------------|----------|----------|
2130 <---16bytes---><--8bytes--><--8bytes-->
2131
2132 */
2133 /*Sme expects the 32 bytes key to be in the below order
2134
2135 |--------------|----------|----------|
2136 | Tk1 |RX-MIC | TX Mic |
2137 |--------------|----------|----------|
2138 <---16bytes---><--8bytes--><--8bytes-->
2139 */
2140 /* Copy the Temporal Key 1 (TK1) */
2141 vos_mem_copy(pKey,ext->key,16);
2142
2143 /*Copy the rx mic first*/
2144 vos_mem_copy(&pKey[16],&ext->key[24],8);
2145
2146 /*Copy the tx mic */
2147 vos_mem_copy(&pKey[24],&ext->key[16],8);
2148
2149 }
2150 break;
2151
2152 case IW_ENCODE_ALG_CCMP:
2153 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
2154 break;
2155
2156 default:
2157 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2158 break;
2159 }
2160
2161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302162 ("%s:EncryptionType:%d key_len:%d, KeyId:%d"), __func__, setKey.encType, setKey.keyLength,
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 setKey.keyId);
2164 for(i=0; i< ext->key_len; i++)
2165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2166 ("%02x"), setKey.Key[i]);
Jeff Johnson43971f52012-07-17 12:26:56 -07002167
2168 vstatus = WLANSAP_SetKeySta( pVosContext, &setKey);
2169 if ( vstatus != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 {
2171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson43971f52012-07-17 12:26:56 -07002172 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", __LINE__, vstatus );
2173 retval = -EINVAL;
2174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002175
Jeff Johnson43971f52012-07-17 12:26:56 -07002176 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002177}
Jeff Johnson43971f52012-07-17 12:26:56 -07002178
2179
Jeff Johnson295189b2012-06-20 16:38:30 -07002180static int iw_set_ap_mlme(struct net_device *dev,
2181 struct iw_request_info *info,
2182 union iwreq_data *wrqu,
2183 char *extra)
2184{
2185#if 0
2186 hdd_adapter_t *pAdapter = (netdev_priv(dev));
2187 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2188
2189 ENTER();
2190
2191 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
2192 switch (mlme->cmd) {
2193 case IW_MLME_DISASSOC:
2194 case IW_MLME_DEAUTH:
2195 hddLog(LOG1, "Station disassociate");
2196 if( pAdapter->conn_info.connState == eConnectionState_Associated )
2197 {
2198 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
2199
2200 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
2201 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
2202
2203 status = sme_RoamDisconnect( pAdapter->hHal,pAdapter->sessionId, reason);
2204
2205 //clear all the reason codes
2206 if (status != 0)
2207 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002208 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d", __func__, (int)mlme->cmd, (int)status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 }
2210
2211 netif_stop_queue(dev);
2212 netif_carrier_off(dev);
2213 }
2214 else
2215 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002216 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 -07002217 }
2218 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08002219 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 return -EINVAL;
2221 }//end of switch
2222 EXIT();
2223#endif
2224 return 0;
2225// return status;
2226}
2227
2228static int iw_get_ap_rts_threshold(struct net_device *dev,
2229 struct iw_request_info *info,
2230 union iwreq_data *wrqu, char *extra)
2231{
2232 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2233 v_U32_t status = 0;
2234
2235 status = hdd_wlan_get_rts_threshold(pHostapdAdapter, wrqu);
2236
2237 return status;
2238}
2239
2240static int iw_get_ap_frag_threshold(struct net_device *dev,
2241 struct iw_request_info *info,
2242 union iwreq_data *wrqu, char *extra)
2243{
2244 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2245 v_U32_t status = 0;
2246
2247 status = hdd_wlan_get_frag_threshold(pHostapdAdapter, wrqu);
2248
2249 return status;
2250}
2251
2252static int iw_get_ap_freq(struct net_device *dev, struct iw_request_info *info,
2253 struct iw_freq *fwrq, char *extra)
2254{
Jeff Johnsone7245742012-09-05 17:12:55 -07002255 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2257 tHalHandle hHal;
2258 hdd_hostapd_state_t *pHostapdState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002259 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
2261 ENTER();
2262
2263 if ((WLAN_HDD_GET_CTX(pHostapdAdapter))->isLogpInProgress) {
2264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2265 "%s:LOGP in Progress. Ignore!!!",__func__);
2266 return status;
2267 }
2268
2269 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
2270 hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
2271
2272 if(pHostapdState->bssState == BSS_STOP )
2273 {
2274 if (ccmCfgGetInt(hHal, WNI_CFG_CURRENT_CHANNEL, &channel)
2275 != eHAL_STATUS_SUCCESS)
2276 {
2277 return -EIO;
2278 }
2279 else
2280 {
2281 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07002282 if( TRUE == status)
2283 {
2284 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2285 * iwlist & iwconfig command shows frequency into proper
2286 * format (2.412 GHz instead of 246.2 MHz)*/
2287 fwrq->m = freq;
2288 fwrq->e = MHZ;
2289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 }
2291 }
2292 else
2293 {
2294 channel = pHddApCtx->operatingChannel;
2295 status = hdd_wlan_get_freq(channel, &freq);
Jeff Johnsone7245742012-09-05 17:12:55 -07002296 if( TRUE == status)
2297 {
2298 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2299 * iwlist & iwconfig command shows frequency into proper
2300 * format (2.412 GHz instead of 246.2 MHz)*/
2301 fwrq->m = freq;
2302 fwrq->e = MHZ;
2303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002305 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002306}
2307
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05302308static int iw_get_mode(struct net_device *dev,
2309 struct iw_request_info *info,
2310 union iwreq_data *wrqu,
2311 char *extra)
2312{
2313 int status = 0;
2314
2315 wrqu->mode = IW_MODE_MASTER;
2316
2317 return status;
2318}
2319
Jeff Johnson295189b2012-06-20 16:38:30 -07002320static int iw_softap_setwpsie(struct net_device *dev,
2321 struct iw_request_info *info,
2322 union iwreq_data *wrqu,
2323 char *extra)
2324{
2325 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2326 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2327 hdd_hostapd_state_t *pHostapdState;
2328 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07002329 u_int8_t *wps_genie;
2330 u_int8_t *fwps_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 u_int8_t *pos;
2332 tpSap_WPSIE pSap_WPSIe;
2333 u_int8_t WPSIeType;
2334 u_int16_t length;
2335 ENTER();
2336
Arif Hussained667642013-10-27 23:01:14 -07002337 if(!wrqu->data.length || wrqu->data.length <= QCSAP_MAX_WSC_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 return 0;
2339
Arif Hussained667642013-10-27 23:01:14 -07002340 wps_genie = kmalloc(wrqu->data.length, GFP_KERNEL);
2341
2342 if(NULL == wps_genie) {
2343 hddLog(LOG1, "unable to allocate memory");
2344 return -ENOMEM;
2345 }
2346 fwps_genie = wps_genie;
2347 if (copy_from_user((void *)wps_genie,
2348 wrqu->data.pointer, wrqu->data.length))
2349 {
2350 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2351 kfree(fwps_genie);
2352 return -EFAULT;
2353 }
2354
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 pSap_WPSIe = vos_mem_malloc(sizeof(tSap_WPSIE));
2356 if (NULL == pSap_WPSIe)
2357 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002358 hddLog(LOGE, "VOS unable to allocate memory");
Arif Hussained667642013-10-27 23:01:14 -07002359 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 return -ENOMEM;
2361 }
2362 vos_mem_zero(pSap_WPSIe, sizeof(tSap_WPSIE));
2363
Arif Hussain6d2a3322013-11-17 19:50:10 -08002364 hddLog(LOG1,"%s WPS IE type[0x%X] IE[0x%X], LEN[%d]", __func__, wps_genie[0], wps_genie[1], wps_genie[2]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 WPSIeType = wps_genie[0];
2366 if ( wps_genie[0] == eQC_WPS_BEACON_IE)
2367 {
2368 pSap_WPSIe->sapWPSIECode = eSAP_WPS_BEACON_IE;
2369 wps_genie = wps_genie + 1;
2370 switch ( wps_genie[0] )
2371 {
2372 case DOT11F_EID_WPA:
2373 if (wps_genie[1] < 2 + 4)
2374 {
2375 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002376 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 return -EINVAL;
2378 }
2379 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
2380 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002381 hddLog (LOG1, "%s Set WPS BEACON IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 pos = &wps_genie[6];
2383 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
2384 {
2385 switch((u_int16_t)(*pos<<8) | *(pos+1))
2386 {
2387 case HDD_WPS_ELEM_VERSION:
2388 pos += 4;
2389 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002390 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_VER_PRESENT;
2392 pos += 1;
2393 break;
2394
2395 case HDD_WPS_ELEM_WPS_STATE:
2396 pos +=4;
2397 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002398 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_STATE_PRESENT;
2400 pos += 1;
2401 break;
2402 case HDD_WPS_ELEM_APSETUPLOCK:
2403 pos += 4;
2404 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002405 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_APSETUPLOCK_PRESENT;
2407 pos += 1;
2408 break;
2409 case HDD_WPS_ELEM_SELECTEDREGISTRA:
2410 pos += 4;
2411 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002412 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRA_PRESENT;
2414 pos += 1;
2415 break;
2416 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
2417 pos += 4;
2418 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002419 hddLog(LOG1, "Password ID: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_DEVICEPASSWORDID_PRESENT;
2421 pos += 2;
2422 break;
2423 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
2424 pos += 4;
2425 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002426 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT;
2428 pos += 2;
2429 break;
2430
2431 case HDD_WPS_ELEM_UUID_E:
2432 pos += 2;
2433 length = *pos<<8 | *(pos+1);
2434 pos += 2;
2435 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSBeaconIE.UUID_E, pos, length);
2436 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_UUIDE_PRESENT;
2437 pos += length;
2438 break;
2439 case HDD_WPS_ELEM_RF_BANDS:
2440 pos += 4;
2441 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002442 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSBeaconIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 pSap_WPSIe->sapwpsie.sapWPSBeaconIE.FieldPresent |= WPS_BEACON_RF_BANDS_PRESENT;
2444 pos += 1;
2445 break;
2446
2447 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08002448 hddLog (LOGW, "UNKNOWN TLV in WPS IE(%x)", (*pos<<8 | *(pos+1)));
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002450 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 return -EINVAL;
2452 }
2453 }
2454 }
2455 else {
2456 hddLog (LOGE, "%s WPS IE Mismatch %X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002457 __func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459 break;
2460
2461 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002462 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002464 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return 0;
2466 }
2467 }
2468 else if( wps_genie[0] == eQC_WPS_PROBE_RSP_IE)
2469 {
2470 pSap_WPSIe->sapWPSIECode = eSAP_WPS_PROBE_RSP_IE;
2471 wps_genie = wps_genie + 1;
2472 switch ( wps_genie[0] )
2473 {
2474 case DOT11F_EID_WPA:
2475 if (wps_genie[1] < 2 + 4)
2476 {
2477 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002478 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 return -EINVAL;
2480 }
2481 else if (memcmp(&wps_genie[2], "\x00\x50\xf2\x04", 4) == 0)
2482 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002483 hddLog (LOG1, "%s Set WPS PROBE RSP IE(len %d)",__func__, wps_genie[1]+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002484 pos = &wps_genie[6];
2485 while (((size_t)pos - (size_t)&wps_genie[6]) < (wps_genie[1] - 4) )
2486 {
2487 switch((u_int16_t)(*pos<<8) | *(pos+1))
2488 {
2489 case HDD_WPS_ELEM_VERSION:
2490 pos += 4;
2491 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002492 hddLog(LOG1, "WPS version %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Version);
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_VER_PRESENT;
2494 pos += 1;
2495 break;
2496
2497 case HDD_WPS_ELEM_WPS_STATE:
2498 pos +=4;
2499 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002500 hddLog(LOG1, "WPS State %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.wpsState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_STATE_PRESENT;
2502 pos += 1;
2503 break;
2504 case HDD_WPS_ELEM_APSETUPLOCK:
2505 pos += 4;
2506 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002507 hddLog(LOG1, "AP setup lock %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.APSetupLocked);
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_APSETUPLOCK_PRESENT;
2509 pos += 1;
2510 break;
2511 case HDD_WPS_ELEM_SELECTEDREGISTRA:
2512 pos += 4;
2513 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002514 hddLog(LOG1, "Selected Registra %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRA_PRESENT;
2516 pos += 1;
2517 break;
2518 case HDD_WPS_ELEM_DEVICE_PASSWORD_ID:
2519 pos += 4;
2520 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002521 hddLog(LOG1, "Password ID: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DevicePasswordID);
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICEPASSWORDID_PRESENT;
2523 pos += 2;
2524 break;
2525 case HDD_WPS_ELEM_REGISTRA_CONF_METHODS:
2526 pos += 4;
2527 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002528 hddLog(LOG1, "Select Registra Config Methods: %x", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT;
2530 pos += 2;
2531 break;
2532 case HDD_WPS_ELEM_RSP_TYPE:
2533 pos += 4;
2534 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002535 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ResponseType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RESPONSETYPE_PRESENT;
2537 pos += 1;
2538 break;
2539 case HDD_WPS_ELEM_UUID_E:
2540 pos += 2;
2541 length = *pos<<8 | *(pos+1);
2542 pos += 2;
2543 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.UUID_E, pos, length);
2544 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_UUIDE_PRESENT;
2545 pos += length;
2546 break;
2547
2548 case HDD_WPS_ELEM_MANUFACTURER:
2549 pos += 2;
2550 length = *pos<<8 | *(pos+1);
2551 pos += 2;
2552 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.num_name = length;
2553 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.Manufacture.name, pos, length);
2554 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MANUFACTURE_PRESENT;
2555 pos += length;
2556 break;
2557
2558 case HDD_WPS_ELEM_MODEL_NAME:
2559 pos += 2;
2560 length = *pos<<8 | *(pos+1);
2561 pos += 2;
2562 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.num_text = length;
2563 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelName.text, pos, length);
2564 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNAME_PRESENT;
2565 pos += length;
2566 break;
2567 case HDD_WPS_ELEM_MODEL_NUM:
2568 pos += 2;
2569 length = *pos<<8 | *(pos+1);
2570 pos += 2;
2571 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.num_text = length;
2572 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ModelNumber.text, pos, length);
2573 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_MODELNUMBER_PRESENT;
2574 pos += length;
2575 break;
2576 case HDD_WPS_ELEM_SERIAL_NUM:
2577 pos += 2;
2578 length = *pos<<8 | *(pos+1);
2579 pos += 2;
2580 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.num_text = length;
2581 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SerialNumber.text, pos, length);
2582 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_SERIALNUMBER_PRESENT;
2583 pos += length;
2584 break;
2585 case HDD_WPS_ELEM_PRIMARY_DEVICE_TYPE:
2586 pos += 4;
2587 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002588 hddLog(LOG1, "primary dev category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 pos += 2;
2590
2591 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.PrimaryDeviceOUI, pos, HDD_WPS_DEVICE_OUI_LEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002592 hddLog(LOG1, "primary dev oui: %02x, %02x, %02x, %02x", pos[0], pos[1], pos[2], pos[3]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 pos += 4;
2594 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory = (*pos<<8 | *(pos+1));
Arif Hussain6d2a3322013-11-17 19:50:10 -08002595 hddLog(LOG1, "primary dev sub category: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceSubCategory);
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 pos += 2;
2597 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT;
2598 break;
2599 case HDD_WPS_ELEM_DEVICE_NAME:
2600 pos += 2;
2601 length = *pos<<8 | *(pos+1);
2602 pos += 2;
2603 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.num_text = length;
2604 vos_mem_copy(pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.DeviceName.text, pos, length);
2605 pos += length;
2606 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_DEVICENAME_PRESENT;
2607 break;
2608 case HDD_WPS_ELEM_CONFIG_METHODS:
2609 pos += 4;
2610 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.ConfigMethod = (*pos<<8) | *(pos+1);
Arif Hussain6d2a3322013-11-17 19:50:10 -08002611 hddLog(LOG1, "Config Methods: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.SelectedRegistraCfgMethod);
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 pos += 2;
2613 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_CONFIGMETHODS_PRESENT;
2614 break;
2615
2616 case HDD_WPS_ELEM_RF_BANDS:
2617 pos += 4;
2618 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand = *pos;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002619 hddLog(LOG1, "RF band: %d", pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.RFBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 pos += 1;
2621 pSap_WPSIe->sapwpsie.sapWPSProbeRspIE.FieldPresent |= WPS_PROBRSP_RF_BANDS_PRESENT;
2622 break;
2623 } // switch
2624 }
2625 }
2626 else
2627 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002628 hddLog (LOGE, "%s WPS IE Mismatch %X",__func__, wps_genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 }
2630
2631 } // switch
2632 }
2633 halStatus = WLANSAP_Set_WpsIe(pVosContext, pSap_WPSIe);
2634 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
2635 if( pHostapdState->bCommit && WPSIeType == eQC_WPS_PROBE_RSP_IE)
2636 {
2637 //hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2638 //v_CONTEXT_t pVosContext = pHostapdAdapter->pvosContext;
2639 WLANSAP_Update_WpsIe ( pVosContext );
2640 }
2641
2642 vos_mem_free(pSap_WPSIe);
Arif Hussained667642013-10-27 23:01:14 -07002643 kfree(fwps_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 EXIT();
2645 return halStatus;
2646}
2647
2648static int iw_softap_stopbss(struct net_device *dev,
2649 struct iw_request_info *info,
2650 union iwreq_data *wrqu,
2651 char *extra)
2652{
2653 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2654 VOS_STATUS status = VOS_STATUS_SUCCESS;
2655 ENTER();
2656 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
2657 {
2658 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext) ) )
2659 {
2660 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
2661
2662 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2663
2664 if (!VOS_IS_STATUS_SUCCESS(status))
2665 {
2666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002667 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 VOS_ASSERT(0);
2669 }
2670 }
2671 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2672 }
2673 EXIT();
2674 return (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
2675}
2676
2677static int iw_softap_version(struct net_device *dev,
2678 struct iw_request_info *info,
Jeff Johnson4824d4c2013-02-12 14:23:57 -08002679 union iwreq_data *wrqu,
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 char *extra)
2681{
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Jeff Johnson4824d4c2013-02-12 14:23:57 -08002683
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 ENTER();
Jeff Johnson4824d4c2013-02-12 14:23:57 -08002685 hdd_wlan_get_version(pHostapdAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 return 0;
2688}
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002689
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07002690VOS_STATUS hdd_softap_get_sta_info(hdd_adapter_t *pAdapter, v_U8_t *pBuf, int buf_len)
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002691{
2692 v_U8_t i;
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07002693 int len = 0;
2694 const char sta_info_header[] = "staId staAddress\n";
2695
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002696 len = scnprintf(pBuf, buf_len, sta_info_header);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07002697 pBuf += len;
2698 buf_len -= len;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002699
2700 for (i = 0; i < WLAN_MAX_STA_COUNT; i++)
2701 {
2702 if(pAdapter->aStaInfo[i].isUsed)
2703 {
Jeff Johnson59a121e2013-11-30 09:46:08 -08002704 len = scnprintf(pBuf, buf_len, "%5d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002705 pAdapter->aStaInfo[i].ucSTAId,
2706 pAdapter->aStaInfo[i].macAddrSTA.bytes[0],
2707 pAdapter->aStaInfo[i].macAddrSTA.bytes[1],
2708 pAdapter->aStaInfo[i].macAddrSTA.bytes[2],
2709 pAdapter->aStaInfo[i].macAddrSTA.bytes[3],
2710 pAdapter->aStaInfo[i].macAddrSTA.bytes[4],
2711 pAdapter->aStaInfo[i].macAddrSTA.bytes[5]);
Yathish Hanumapuradoddi Shivanna7b659402013-03-25 14:12:32 -07002712 pBuf += len;
2713 buf_len -= len;
2714 }
2715 if(WE_GET_STA_INFO_SIZE > buf_len)
2716 {
2717 break;
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002718 }
2719 }
2720 return VOS_STATUS_SUCCESS;
2721}
2722
2723static int iw_softap_get_sta_info(struct net_device *dev,
2724 struct iw_request_info *info,
2725 union iwreq_data *wrqu,
2726 char *extra)
2727{
2728 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2729 VOS_STATUS status;
2730 ENTER();
Yathish Hanumapuradoddi Shivanna4171f7d2013-04-08 20:05:56 -07002731 status = hdd_softap_get_sta_info(pHostapdAdapter, extra, WE_SAP_MAX_STA_INFO);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002732 if ( !VOS_IS_STATUS_SUCCESS( status ) ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002733 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Failed!!!",__func__);
Gopichand Nakkala976e3252013-01-03 15:45:56 -08002734 return -EINVAL;
2735 }
2736 wrqu->data.length = strlen(extra);
2737 EXIT();
2738 return 0;
2739}
2740
Jeff Johnson295189b2012-06-20 16:38:30 -07002741static int iw_set_ap_genie(struct net_device *dev,
2742 struct iw_request_info *info,
2743 union iwreq_data *wrqu,
2744 char *extra)
2745{
2746
2747 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2748 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
2749 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
Arif Hussained667642013-10-27 23:01:14 -07002750 u_int8_t *genie = (u_int8_t *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002751
2752 ENTER();
2753
2754 if(!wrqu->data.length)
2755 {
2756 EXIT();
2757 return 0;
2758 }
Arif Hussained667642013-10-27 23:01:14 -07002759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 switch (genie[0])
2761 {
2762 case DOT11F_EID_WPA:
2763 case DOT11F_EID_RSN:
2764 if((WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy == 0)
2765 {
2766 hdd_softap_Deregister_BC_STA(pHostapdAdapter);
2767 hdd_softap_Register_BC_STA(pHostapdAdapter, 1);
2768 }
2769 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = 1;
Arif Hussained667642013-10-27 23:01:14 -07002770 halStatus = WLANSAP_Set_WPARSNIes(pVosContext, genie, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 break;
2772
2773 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002774 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, genie[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 halStatus = 0;
2776 }
2777
2778 EXIT();
2779 return halStatus;
2780}
2781
2782static VOS_STATUS wlan_hdd_get_classAstats_for_station(hdd_adapter_t *pAdapter, u8 staid)
2783{
2784 eHalStatus hstatus;
2785 long lrc;
2786 struct statsContext context;
2787
2788 if (NULL == pAdapter)
2789 {
2790 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Padapter is NULL", __func__);
2791 return VOS_STATUS_E_FAULT;
2792 }
2793
2794 init_completion(&context.completion);
2795 context.pAdapter = pAdapter;
2796 context.magic = STATS_CONTEXT_MAGIC;
2797 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2798 eCSR_HDD,
2799 SME_GLOBAL_CLASSA_STATS,
2800 hdd_GetClassA_statisticsCB,
2801 0, // not periodic
2802 FALSE, //non-cached results
2803 staid,
2804 &context);
2805 if (eHAL_STATUS_SUCCESS != hstatus)
2806 {
2807 hddLog(VOS_TRACE_LEVEL_ERROR,
2808 "%s: Unable to retrieve statistics for link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002809 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 }
2811 else
2812 {
2813 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2814 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 if (lrc <= 0)
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR,
2818 "%s: SME %s while retrieving link speed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002819 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 }
2821 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002822
2823 /* either we never sent a request, we sent a request and received a
2824 response or we sent a request and timed out. if we never sent a
2825 request or if we sent a request and got a response, we want to
2826 clear the magic out of paranoia. if we timed out there is a
2827 race condition such that the callback function could be
2828 executing at the same time we are. of primary concern is if the
2829 callback function had already verified the "magic" but had not
2830 yet set the completion variable when a timeout occurred. we
2831 serialize these activities by invalidating the magic while
2832 holding a shared spinlock which will cause us to block if the
2833 callback is currently executing */
2834 spin_lock(&hdd_context_lock);
2835 context.magic = 0;
2836 spin_unlock(&hdd_context_lock);
2837
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 return VOS_STATUS_SUCCESS;
2839}
2840
2841int iw_get_softap_linkspeed(struct net_device *dev,
2842 struct iw_request_info *info,
2843 union iwreq_data *wrqu,
2844 char *extra)
2845
2846{
2847 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302848 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 char *pLinkSpeed = (char*)extra;
Arif Hussained667642013-10-27 23:01:14 -07002850 char *pmacAddress;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302851 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 unsigned short staId;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302853 int len = sizeof(v_U32_t)+1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 v_BYTE_t macAddress[VOS_MAC_ADDR_SIZE];
2855 VOS_STATUS status;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302856 int rc, valid;
2857
2858 pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2859
2860 valid = wlan_hdd_validate_context(pHddCtx);
2861
2862 if (0 != valid)
2863 {
2864 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context not valid"));
2865 return valid;
2866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
Arif Hussain6d2a3322013-11-17 19:50:10 -08002868 hddLog(VOS_TRACE_LEVEL_INFO, "%s wrqu->data.length= %d", __func__, wrqu->data.length);
Arif Hussained667642013-10-27 23:01:14 -07002869 if (wrqu->data.length != MAC_ADDRESS_STR_LEN)
2870 {
2871 hddLog(LOG1, "Invalid length");
2872 return -EINVAL;
2873 }
2874 pmacAddress = kmalloc(MAC_ADDRESS_STR_LEN, GFP_KERNEL);
2875 if(NULL == pmacAddress) {
2876 hddLog(LOG1, "unable to allocate memory");
2877 return -ENOMEM;
2878 }
2879 if (copy_from_user((void *)pmacAddress,
2880 wrqu->data.pointer, wrqu->data.length))
2881 {
2882 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2883 kfree(pmacAddress);
2884 return -EFAULT;
2885 }
2886
2887 status = hdd_string_to_hex (pmacAddress, wrqu->data.length, macAddress );
2888 kfree(pmacAddress);
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05302889
2890 if (!VOS_IS_STATUS_SUCCESS(status ))
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 {
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05302892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("String to Hex conversion Failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
2894
Kiet Lam61589852013-09-19 17:10:58 +05302895 /* If no mac address is passed and/or its length is less than 17,
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05302896 * link speed for first connected client will be returned.
2897 */
Kiet Lam61589852013-09-19 17:10:58 +05302898 if (!VOS_IS_STATUS_SUCCESS(status ) || wrqu->data.length < 17)
Madan Mohan Koyyalamudie68989b2013-09-10 01:15:19 +05302899 {
2900 status = hdd_softap_GetConnectedStaId(pHostapdAdapter, (void *)(&staId));
2901 }
2902 else
2903 {
2904 status = hdd_softap_GetStaId(pHostapdAdapter,
2905 (v_MACADDR_t *)macAddress, (void *)(&staId));
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302908 if (!VOS_IS_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302910 hddLog(VOS_TRACE_LEVEL_ERROR, FL("ERROR: HDD Failed to find sta id!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 link_speed = 0;
2912 }
2913 else
2914 {
2915 status = wlan_hdd_get_classAstats_for_station(pHostapdAdapter , staId);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302916
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 if (!VOS_IS_STATUS_SUCCESS(status ))
2918 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302919 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 return -EINVAL;
2921 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302922
2923 WLANTL_GetSTALinkCapacity(pHddCtx->pvosContext,
2924 staId, &link_speed);
2925
2926 link_speed = link_speed / 10;
2927
2928 if (0 == link_speed)
2929 {
2930 /* The linkspeed returned by HAL is in units of 500kbps.
2931 * converting it to mbps.
2932 * This is required to support legacy firmware which does
2933 * not return link capacity.
2934 */
2935 link_speed =(int)pHostapdAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 }
2938
2939 wrqu->data.length = len;
Jeff Johnson02797792013-10-26 19:17:13 -07002940 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302941
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 if ((rc < 0) || (rc >= len))
2943 {
2944 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302945 hddLog(VOS_TRACE_LEVEL_ERROR,FL( "Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 return -EIO;
2947 }
2948
2949 return 0;
2950}
2951
2952static const iw_handler hostapd_handler[] =
2953{
2954 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2955 (iw_handler) NULL, /* SIOCGIWNAME */
2956 (iw_handler) NULL, /* SIOCSIWNWID */
2957 (iw_handler) NULL, /* SIOCGIWNWID */
2958 (iw_handler) NULL, /* SIOCSIWFREQ */
2959 (iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
2960 (iw_handler) NULL, /* SIOCSIWMODE */
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05302961 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 (iw_handler) NULL, /* SIOCSIWSENS */
2963 (iw_handler) NULL, /* SIOCGIWSENS */
2964 (iw_handler) NULL, /* SIOCSIWRANGE */
2965 (iw_handler) NULL, /* SIOCGIWRANGE */
2966 (iw_handler) NULL, /* SIOCSIWPRIV */
2967 (iw_handler) NULL, /* SIOCGIWPRIV */
2968 (iw_handler) NULL, /* SIOCSIWSTATS */
2969 (iw_handler) NULL, /* SIOCGIWSTATS */
2970 (iw_handler) NULL, /* SIOCSIWSPY */
2971 (iw_handler) NULL, /* SIOCGIWSPY */
2972 (iw_handler) NULL, /* SIOCSIWTHRSPY */
2973 (iw_handler) NULL, /* SIOCGIWTHRSPY */
2974 (iw_handler) NULL, /* SIOCSIWAP */
2975 (iw_handler) NULL, /* SIOCGIWAP */
2976 (iw_handler) iw_set_ap_mlme, /* SIOCSIWMLME */
2977 (iw_handler) NULL, /* SIOCGIWAPLIST */
2978 (iw_handler) NULL, /* SIOCSIWSCAN */
2979 (iw_handler) NULL, /* SIOCGIWSCAN */
2980 (iw_handler) NULL, /* SIOCSIWESSID */
2981 (iw_handler) NULL, /* SIOCGIWESSID */
2982 (iw_handler) NULL, /* SIOCSIWNICKN */
2983 (iw_handler) NULL, /* SIOCGIWNICKN */
2984 (iw_handler) NULL, /* -- hole -- */
2985 (iw_handler) NULL, /* -- hole -- */
2986 (iw_handler) NULL, /* SIOCSIWRATE */
2987 (iw_handler) NULL, /* SIOCGIWRATE */
2988 (iw_handler) NULL, /* SIOCSIWRTS */
2989 (iw_handler) iw_get_ap_rts_threshold, /* SIOCGIWRTS */
2990 (iw_handler) NULL, /* SIOCSIWFRAG */
2991 (iw_handler) iw_get_ap_frag_threshold, /* SIOCGIWFRAG */
2992 (iw_handler) NULL, /* SIOCSIWTXPOW */
2993 (iw_handler) NULL, /* SIOCGIWTXPOW */
2994 (iw_handler) NULL, /* SIOCSIWRETRY */
2995 (iw_handler) NULL, /* SIOCGIWRETRY */
2996 (iw_handler) NULL, /* SIOCSIWENCODE */
2997 (iw_handler) NULL, /* SIOCGIWENCODE */
2998 (iw_handler) NULL, /* SIOCSIWPOWER */
2999 (iw_handler) NULL, /* SIOCGIWPOWER */
3000 (iw_handler) NULL, /* -- hole -- */
3001 (iw_handler) NULL, /* -- hole -- */
3002 (iw_handler) iw_set_ap_genie, /* SIOCSIWGENIE */
3003 (iw_handler) NULL, /* SIOCGIWGENIE */
3004 (iw_handler) iw_set_auth_hostap, /* SIOCSIWAUTH */
3005 (iw_handler) NULL, /* SIOCGIWAUTH */
3006 (iw_handler) iw_set_ap_encodeext, /* SIOCSIWENCODEEXT */
3007 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
3008 (iw_handler) NULL, /* SIOCSIWPMKSA */
3009};
3010
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003011#define IW_PRIV_TYPE_OPTIE (IW_PRIV_TYPE_BYTE | QCSAP_MAX_OPT_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003012#define IW_PRIV_TYPE_MLME \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -08003013 (IW_PRIV_TYPE_BYTE | sizeof(struct ieee80211req_mlme))
Jeff Johnson295189b2012-06-20 16:38:30 -07003014
3015static const struct iw_priv_args hostapd_private_args[] = {
3016 { QCSAP_IOCTL_SETPARAM,
3017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setparam" },
3018 { QCSAP_IOCTL_SETPARAM,
3019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
3020 { QCSAP_PARAM_MAX_ASSOC,
3021 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMaxAssoc" },
3022 { QCSAP_PARAM_HIDE_SSID,
3023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hideSSID" },
Leo Chang614d2072013-08-22 14:59:44 -07003024 { QCSAP_PARAM_SET_MC_RATE,
3025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setMcRate" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 { QCSAP_IOCTL_GETPARAM,
3027 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getparam" },
3029 { QCSAP_IOCTL_GETPARAM, 0,
3030 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
3031 { QCSAP_PARAM_MAX_ASSOC, 0,
3032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getMaxAssoc" },
Jeff Johnson43971f52012-07-17 12:26:56 -07003033 { QCSAP_PARAM_GET_WLAN_DBG, 0,
3034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwlandbg" },
3035 { QCSAP_PARAM_AUTO_CHANNEL, 0,
3036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getAutoChannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 { QCSAP_PARAM_MODULE_DOWN_IND, 0,
3038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "moduleDownInd" },
3039 { QCSAP_PARAM_CLR_ACL, 0,
3040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "setClearAcl" },
3041 { QCSAP_PARAM_ACL_MODE,
3042 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setAclMode" },
3043 { QCSAP_IOCTL_COMMIT,
3044 IW_PRIV_TYPE_BYTE | sizeof(struct s_CommitConfig) | IW_PRIV_SIZE_FIXED, 0, "commit" },
3045 { QCSAP_IOCTL_SETMLME,
3046 IW_PRIV_TYPE_BYTE | sizeof(struct sQcSapreq_mlme)| IW_PRIV_SIZE_FIXED, 0, "setmlme" },
3047 { QCSAP_IOCTL_GET_STAWPAIE,
3048 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "get_staWPAIE" },
3049 { QCSAP_IOCTL_SETWPAIE,
3050 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE | IW_PRIV_SIZE_FIXED, 0, "setwpaie" },
3051 { QCSAP_IOCTL_STOPBSS,
3052 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED, 0, "stopbss" },
3053 { QCSAP_IOCTL_VERSION, 0,
3054 IW_PRIV_TYPE_CHAR | QCSAP_MAX_WSC_IE, "version" },
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003055 { QCSAP_IOCTL_GET_STA_INFO, 0,
3056 IW_PRIV_TYPE_CHAR | WE_SAP_MAX_STA_INFO, "get_sta_info" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 { QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES,
Arif Hussaind443e332013-11-18 23:59:44 -08003058 IW_PRIV_TYPE_BYTE | sizeof(sQcSapreq_WPSPBCProbeReqIES_t) | IW_PRIV_SIZE_FIXED, 0, "getProbeReqIEs" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 { QCSAP_IOCTL_GET_CHANNEL, 0,
Jeff Johnson43971f52012-07-17 12:26:56 -07003060 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getchannel" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 { QCSAP_IOCTL_ASSOC_STA_MACADDR, 0,
3062 IW_PRIV_TYPE_BYTE | /*((WLAN_MAX_STA_COUNT*6)+100)*/1 , "get_assoc_stamac" },
3063 { QCSAP_IOCTL_DISASSOC_STA,
3064 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 6 , 0, "disassoc_sta" },
3065 { QCSAP_IOCTL_AP_STATS,
3066 IW_PRIV_TYPE_BYTE | QCSAP_MAX_WSC_IE, 0, "ap_stats" },
3067 { QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED,
3068 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303069 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003070
3071 { QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE,
3072 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "" },
3073 /* handlers for sub-ioctl */
3074 { WE_SET_WLAN_DBG,
3075 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
3076 0,
3077 "setwlandbg" },
3078
3079 /* handlers for main ioctl */
3080 { QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE,
3081 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3082 0,
3083 "" },
3084
3085 /* handlers for sub-ioctl */
3086 { WE_LOG_DUMP_CMD,
3087 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3088 0,
3089 "dump" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 { WE_P2P_NOA_CMD,
3091 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3092 0,
3093 "SetP2pPs" },
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08003094 /* handlers for sub ioctl */
3095 {
3096 WE_MCC_CONFIG_CREDENTIAL,
3097 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3098 0,
3099 "setMccCrdnl" },
3100
3101 /* handlers for sub ioctl */
3102 {
3103 WE_MCC_CONFIG_PARAMS,
3104 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
3105 0,
3106 "setMccConfig" },
3107
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 /* handlers for main ioctl */
3109 { QCSAP_IOCTL_MODIFY_ACL,
3110 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 8,
3111 0,
3112 "modify_acl" },
3113
3114 /* handlers for main ioctl */
3115 { QCSAP_IOCTL_GET_CHANNEL_LIST,
3116 0,
3117 IW_PRIV_TYPE_BYTE | sizeof(tChannelListInfo),
3118 "getChannelList" },
3119
Jeff Johnsone7245742012-09-05 17:12:55 -07003120 /* handlers for main ioctl */
3121 { QCSAP_IOCTL_SET_TX_POWER,
3122 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3123 0,
Madan Mohan Koyyalamudid12bf052012-11-27 19:07:55 +05303124 "setTxPower" },
schang86c22c42013-03-13 18:41:24 -07003125
3126 /* handlers for main ioctl */
3127 { QCSAP_IOCTL_SET_MAX_TX_POWER,
3128 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3129 0,
3130 "setTxMaxPower" },
Kiet Lambcf38522013-10-26 18:28:27 +05303131
3132 { QCSAP_IOCTL_DATAPATH_SNAP_SHOT,
3133 IW_PRIV_TYPE_NONE | IW_PRIV_TYPE_NONE,
3134 0,
3135 "dataSnapshot" },
3136
3137 /* handlers for main ioctl */
3138 { QCSAP_IOCTL_SET_TRAFFIC_MONITOR,
3139 IW_PRIV_TYPE_INT| IW_PRIV_SIZE_FIXED | 1,
3140 0,
3141 "setTrafficMon" },
Jeff Johnson295189b2012-06-20 16:38:30 -07003142};
Jeff Johnsone7245742012-09-05 17:12:55 -07003143
Jeff Johnson295189b2012-06-20 16:38:30 -07003144static const iw_handler hostapd_private[] = {
3145 [QCSAP_IOCTL_SETPARAM - SIOCIWFIRSTPRIV] = iw_softap_setparam, //set priv ioctl
3146 [QCSAP_IOCTL_GETPARAM - SIOCIWFIRSTPRIV] = iw_softap_getparam, //get priv ioctl
3147 [QCSAP_IOCTL_COMMIT - SIOCIWFIRSTPRIV] = iw_softap_commit, //get priv ioctl
3148 [QCSAP_IOCTL_SETMLME - SIOCIWFIRSTPRIV] = iw_softap_setmlme,
3149 [QCSAP_IOCTL_GET_STAWPAIE - SIOCIWFIRSTPRIV] = iw_get_genie, //get station genIE
3150 [QCSAP_IOCTL_SETWPAIE - SIOCIWFIRSTPRIV] = iw_softap_setwpsie,
3151 [QCSAP_IOCTL_STOPBSS - SIOCIWFIRSTPRIV] = iw_softap_stopbss, // stop bss
3152 [QCSAP_IOCTL_VERSION - SIOCIWFIRSTPRIV] = iw_softap_version, // get driver version
3153 [QCSAP_IOCTL_GET_WPS_PBC_PROBE_REQ_IES - SIOCIWFIRSTPRIV] = iw_get_WPSPBCProbeReqIEs,
3154 [QCSAP_IOCTL_GET_CHANNEL - SIOCIWFIRSTPRIV] = iw_softap_getchannel,
3155 [QCSAP_IOCTL_ASSOC_STA_MACADDR - SIOCIWFIRSTPRIV] = iw_softap_getassoc_stamacaddr,
3156 [QCSAP_IOCTL_DISASSOC_STA - SIOCIWFIRSTPRIV] = iw_softap_disassoc_sta,
3157 [QCSAP_IOCTL_AP_STATS - SIOCIWFIRSTPRIV] = iw_softap_ap_stats,
3158 [QCSAP_IOCTL_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
3159 [QCSAP_IOCTL_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
3160 [QCSAP_IOCTL_SET_CHANNEL_RANGE - SIOCIWFIRSTPRIV] = iw_softap_set_channel_range,
3161 [QCSAP_IOCTL_MODIFY_ACL - SIOCIWFIRSTPRIV] = iw_softap_modify_acl,
3162 [QCSAP_IOCTL_GET_CHANNEL_LIST - SIOCIWFIRSTPRIV] = iw_softap_get_channel_list,
Gopichand Nakkala976e3252013-01-03 15:45:56 -08003163 [QCSAP_IOCTL_GET_STA_INFO - SIOCIWFIRSTPRIV] = iw_softap_get_sta_info,
Jeff Johnsone7245742012-09-05 17:12:55 -07003164 [QCSAP_IOCTL_PRIV_GET_SOFTAP_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_softap_linkspeed,
3165 [QCSAP_IOCTL_SET_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_tx_power,
schang86c22c42013-03-13 18:41:24 -07003166 [QCSAP_IOCTL_SET_MAX_TX_POWER - SIOCIWFIRSTPRIV] = iw_softap_set_max_tx_power,
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05303167 [QCSAP_IOCTL_DATAPATH_SNAP_SHOT - SIOCIWFIRSTPRIV] = iw_display_data_path_snapshot,
Kiet Lambcf38522013-10-26 18:28:27 +05303168 [QCSAP_IOCTL_SET_TRAFFIC_MONITOR - SIOCIWFIRSTPRIV] = iw_softap_set_trafficmonitor,
Jeff Johnson295189b2012-06-20 16:38:30 -07003169};
3170const struct iw_handler_def hostapd_handler_def = {
3171 .num_standard = sizeof(hostapd_handler) / sizeof(hostapd_handler[0]),
3172 .num_private = sizeof(hostapd_private) / sizeof(hostapd_private[0]),
3173 .num_private_args = sizeof(hostapd_private_args) / sizeof(hostapd_private_args[0]),
3174 .standard = (iw_handler *)hostapd_handler,
3175 .private = (iw_handler *)hostapd_private,
3176 .private_args = hostapd_private_args,
3177 .get_wireless_stats = NULL,
3178};
3179#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3180struct net_device_ops net_ops_struct = {
3181 .ndo_open = hdd_hostapd_open,
3182 .ndo_stop = hdd_hostapd_stop,
3183 .ndo_uninit = hdd_hostapd_uninit,
3184 .ndo_start_xmit = hdd_softap_hard_start_xmit,
3185 .ndo_tx_timeout = hdd_softap_tx_timeout,
3186 .ndo_get_stats = hdd_softap_stats,
3187 .ndo_set_mac_address = hdd_hostapd_set_mac_address,
3188 .ndo_do_ioctl = hdd_hostapd_ioctl,
3189 .ndo_change_mtu = hdd_hostapd_change_mtu,
3190 .ndo_select_queue = hdd_hostapd_select_queue,
3191 };
3192#endif
3193
3194int hdd_set_hostapd(hdd_adapter_t *pAdapter)
3195{
3196 return VOS_STATUS_SUCCESS;
3197}
3198
3199void hdd_set_ap_ops( struct net_device *pWlanHostapdDev )
3200{
3201#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
3202 pWlanHostapdDev->netdev_ops = &net_ops_struct;
3203#else
3204 pWlanHostapdDev->open = hdd_hostapd_open;
3205 pWlanHostapdDev->stop = hdd_hostapd_stop;
3206 pWlanHostapdDev->uninit = hdd_hostapd_uninit;
3207 pWlanHostapdDev->hard_start_xmit = hdd_softap_hard_start_xmit;
3208 pWlanHostapdDev->tx_timeout = hdd_softap_tx_timeout;
3209 pWlanHostapdDev->get_stats = hdd_softap_stats;
3210 pWlanHostapdDev->set_mac_address = hdd_hostapd_set_mac_address;
3211 pWlanHostapdDev->do_ioctl = hdd_hostapd_ioctl;
3212#endif
3213}
3214
3215VOS_STATUS hdd_init_ap_mode( hdd_adapter_t *pAdapter )
3216{
3217 hdd_hostapd_state_t * phostapdBuf;
3218 struct net_device *dev = pAdapter->dev;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07003219 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 VOS_STATUS status;
3221 ENTER();
3222 // Allocate the Wireless Extensions state structure
3223 phostapdBuf = WLAN_HDD_GET_HOSTAP_STATE_PTR( pAdapter );
3224
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07003225 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
3226
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 // Zero the memory. This zeros the profile structure.
3228 memset(phostapdBuf, 0,sizeof(hdd_hostapd_state_t));
3229
3230 // Set up the pointer to the Wireless Extensions state structure
3231 // NOP
3232 status = hdd_set_hostapd(pAdapter);
3233 if(!VOS_IS_STATUS_SUCCESS(status)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_hostapd failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 return status;
3236 }
3237
3238 status = vos_event_init(&phostapdBuf->vosEvent);
3239 if (!VOS_IS_STATUS_SUCCESS(status))
3240 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: Hostapd HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 return status;
3243 }
3244
3245 init_completion(&pAdapter->session_close_comp_var);
3246 init_completion(&pAdapter->session_open_comp_var);
3247
3248 sema_init(&(WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->semWpsPBCOverlapInd, 1);
3249
3250 // Register as a wireless device
3251 dev->wireless_handlers = (struct iw_handler_def *)& hostapd_handler_def;
3252
3253 //Initialize the data path module
3254 status = hdd_softap_init_tx_rx(pAdapter);
3255 if ( !VOS_IS_STATUS_SUCCESS( status ))
3256 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003257 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_softap_init_tx_rx failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 }
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05303259
3260 status = hdd_wmm_adapter_init( pAdapter );
3261 if (!VOS_IS_STATUS_SUCCESS(status))
3262 {
3263 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003264 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05303265 status, status );
3266 goto error_wmm_init;
3267 }
3268
3269 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
3270
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), pAdapter );
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05303272
3273 return status;
3274
3275error_wmm_init:
3276 hdd_softap_deinit_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 EXIT();
3278 return status;
3279}
3280
3281hdd_adapter_t* hdd_wlan_create_ap_dev( hdd_context_t *pHddCtx, tSirMacAddr macAddr, tANI_U8 *iface_name )
3282{
3283 struct net_device *pWlanHostapdDev = NULL;
3284 hdd_adapter_t *pHostapdAdapter = NULL;
3285 v_CONTEXT_t pVosContext= NULL;
3286
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 pWlanHostapdDev = alloc_netdev_mq(sizeof(hdd_adapter_t), iface_name, ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289 if (pWlanHostapdDev != NULL)
3290 {
3291 pHostapdAdapter = netdev_priv(pWlanHostapdDev);
3292
3293 //Init the net_device structure
3294 ether_setup(pWlanHostapdDev);
3295
3296 //Initialize the adapter context to zeros.
3297 vos_mem_zero(pHostapdAdapter, sizeof( hdd_adapter_t ));
3298 pHostapdAdapter->dev = pWlanHostapdDev;
3299 pHostapdAdapter->pHddCtx = pHddCtx;
3300 pHostapdAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
3301
3302 //Get the Global VOSS context.
3303 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
3304 //Save the adapter context in global context for future.
3305 ((VosContextType*)(pVosContext))->pHDDSoftAPContext = (v_VOID_t*)pHostapdAdapter;
3306
3307 //Init the net_device structure
3308 strlcpy(pWlanHostapdDev->name, (const char *)iface_name, IFNAMSIZ);
3309
3310 hdd_set_ap_ops( pHostapdAdapter->dev );
3311
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 pWlanHostapdDev->watchdog_timeo = HDD_TX_TIMEOUT;
3313 pWlanHostapdDev->mtu = HDD_DEFAULT_MTU;
3314
3315 vos_mem_copy(pWlanHostapdDev->dev_addr, (void *)macAddr,sizeof(tSirMacAddr));
3316 vos_mem_copy(pHostapdAdapter->macAddressCurrent.bytes, (void *)macAddr, sizeof(tSirMacAddr));
3317
3318 pWlanHostapdDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 pWlanHostapdDev->ieee80211_ptr = &pHostapdAdapter->wdev ;
3320 pHostapdAdapter->wdev.wiphy = pHddCtx->wiphy;
3321 pHostapdAdapter->wdev.netdev = pWlanHostapdDev;
3322 init_completion(&pHostapdAdapter->tx_action_cnf_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 init_completion(&pHostapdAdapter->cancel_rem_on_chan_var);
3324 init_completion(&pHostapdAdapter->rem_on_chan_ready_event);
3325#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3326 init_completion(&pHostapdAdapter->offchannel_tx_event);
3327#endif
3328
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 SET_NETDEV_DEV(pWlanHostapdDev, pHddCtx->parent_dev);
3330 }
3331 return pHostapdAdapter;
3332}
3333
3334VOS_STATUS hdd_register_hostapd( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
3335{
3336 struct net_device *dev = pAdapter->dev;
3337 VOS_STATUS status = VOS_STATUS_SUCCESS;
3338
3339 ENTER();
3340
3341 if( rtnl_lock_held )
3342 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08003343 if (strnchr(dev->name, strlen(dev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 if( dev_alloc_name(dev, dev->name) < 0 )
3345 {
3346 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:Failed:dev_alloc_name", __func__);
3347 return VOS_STATUS_E_FAILURE;
3348 }
3349 }
3350 if (register_netdevice(dev))
3351 {
3352 hddLog(VOS_TRACE_LEVEL_FATAL,
3353 "%s:Failed:register_netdevice", __func__);
3354 return VOS_STATUS_E_FAILURE;
3355 }
3356 }
3357 else
3358 {
3359 if (register_netdev(dev))
3360 {
3361 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed:register_netdev", __func__);
3362 return VOS_STATUS_E_FAILURE;
3363 }
3364 }
3365 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
3366
3367 EXIT();
3368 return status;
3369}
3370
3371VOS_STATUS hdd_unregister_hostapd(hdd_adapter_t *pAdapter)
3372{
3373 ENTER();
3374
3375 hdd_softap_deinit_tx_rx(pAdapter);
3376
3377 /* if we are being called during driver unload, then the dev has already
3378 been invalidated. if we are being called at other times, then we can
3379 detatch the wireless device handlers */
3380 if (pAdapter->dev)
3381 {
3382 pAdapter->dev->wireless_handlers = NULL;
3383 }
3384 EXIT();
3385 return 0;
3386}