blob: ea550f58a1cc372beee081e2cb37cbe6bd479b18 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 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
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/*========================================================================
31
32 \file wlan_hdd_main.c
33
34 \brief WLAN Host Device Driver implementation
35
36 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
37
38 Qualcomm Confidential and Proprietary.
39
40 ========================================================================*/
41
42/**=========================================================================
43
44 EDIT HISTORY FOR FILE
45
46
47 This section contains comments describing changes made to the module.
48 Notice that changes are listed in reverse chronological order.
49
50
51 $Header:$ $DateTime: $ $Author: $
52
53
54 when who what, where, why
55 -------- --- --------------------------------------------------------
56 04/5/09 Shailender Created module.
57 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module
58 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
59 ==========================================================================*/
60
61/*--------------------------------------------------------------------------
62 Include Files
63 ------------------------------------------------------------------------*/
64//#include <wlan_qct_driver.h>
65#include <wlan_hdd_includes.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include <vos_api.h>
67#include <vos_sched.h>
68#include <vos_power.h>
69#include <linux/etherdevice.h>
70#include <linux/firmware.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070071#ifdef ANI_BUS_TYPE_PLATFORM
72#include <linux/wcnss_wlan.h>
73#endif //ANI_BUS_TYPE_PLATFORM
74#ifdef ANI_BUS_TYPE_PCI
75#include "wcnss_wlan.h"
76#endif /* ANI_BUS_TYPE_PCI */
77#include <wlan_hdd_tx_rx.h>
78#include <palTimer.h>
79#include <wniApi.h>
80#include <wlan_nlink_srv.h>
81#include <wlan_btc_svc.h>
82#include <wlan_hdd_cfg.h>
83#include <wlan_ptt_sock_svc.h>
84#include <wlan_hdd_wowl.h>
85#include <wlan_hdd_misc.h>
86#include <wlan_hdd_wext.h>
87#ifdef WLAN_BTAMP_FEATURE
88#include <bap_hdd_main.h>
89#include <bapInternal.h>
90#endif // WLAN_BTAMP_FEATURE
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +053094#include <linux/inetdevice.h>
95#include <net/addrconf.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070096#include "wlan_hdd_cfg80211.h"
97#include "wlan_hdd_p2p.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070099int wlan_hdd_ftm_start(hdd_context_t *pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700100#include "sapApi.h"
101#include <linux/semaphore.h>
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -0700102#include <linux/ctype.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700103#include <mach/subsystem_restart.h>
104#include <wlan_hdd_hostapd.h>
105#include <wlan_hdd_softap_tx_rx.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#include "cfgApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#include "wlan_hdd_dev_pwr.h"
108#ifdef WLAN_BTAMP_FEATURE
109#include "bap_hdd_misc.h"
110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700111#include "wlan_qct_pal_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700112#include "qwlan_version.h"
Yathish9f22e662012-12-10 14:21:35 -0800113#include "wlan_qct_wda.h"
Chilam NG571c65a2013-01-19 12:27:36 +0530114#ifdef FEATURE_WLAN_TDLS
115#include "wlan_hdd_tdls.h"
116#endif
Yue Ma0d4891e2013-08-06 17:01:45 -0700117#include "wlan_hdd_debugfs.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#ifdef MODULE
120#define WLAN_MODULE_NAME module_name(THIS_MODULE)
121#else
122#define WLAN_MODULE_NAME "wlan"
123#endif
124
125#ifdef TIMER_MANAGER
126#define TIMER_MANAGER_STR " +TIMER_MANAGER"
127#else
128#define TIMER_MANAGER_STR ""
129#endif
130
131#ifdef MEMORY_DEBUG
132#define MEMORY_DEBUG_STR " +MEMORY_DEBUG"
133#else
134#define MEMORY_DEBUG_STR ""
135#endif
136
137/* the Android framework expects this param even though we don't use it */
138#define BUF_LEN 20
Jeff Johnson76052702013-04-16 13:55:05 -0700139static char fwpath_buffer[BUF_LEN];
140static struct kparam_string fwpath = {
141 .string = fwpath_buffer,
142 .maxlen = BUF_LEN,
143};
Arif Hussain66559122013-11-21 10:11:40 -0800144
145static char *country_code;
146static int enable_11d = -1;
147static int enable_dfs_chan_scan = -1;
148
Madan Mohan Koyyalamudi05f313c2012-09-18 19:19:15 -0700149#ifndef MODULE
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700150static int wlan_hdd_inited;
Madan Mohan Koyyalamudi05f313c2012-09-18 19:19:15 -0700151#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700152
Jeff Johnsone7245742012-09-05 17:12:55 -0700153/*
Jeff Johnson72a40512013-12-19 10:14:15 -0800154 * spinlock for synchronizing asynchronous request/response
155 * (full description of use in wlan_hdd_main.h)
156 */
157DEFINE_SPINLOCK(hdd_context_lock);
158
159/*
Jeff Johnsone7245742012-09-05 17:12:55 -0700160 * The rate at which the driver sends RESTART event to supplicant
161 * once the function 'vos_wlanRestart()' is called
162 *
163 */
164#define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */
165#define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700166
167/*
168 * Size of Driver command strings from upper layer
169 */
170#define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */
171#define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */
172
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700173#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
174#define TID_MIN_VALUE 0
175#define TID_MAX_VALUE 15
176static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
177 tAniTrafStrmMetrics* pTsmMetrics);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800178static VOS_STATUS hdd_parse_ccx_beacon_req(tANI_U8 *pValue,
179 tCsrCcxBeaconReq *pCcxBcnReq);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700180#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
181
Srinivas Girigowda4081bb12014-01-06 17:12:58 -0800182#define WLAN_PRIV_DATA_MAX_LEN 4096
183
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700184/*
185 * Driver miracast parameters 0-Disabled
186 * 1-Source, 2-Sink
187 */
188#define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0
189#define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2
190
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800191#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -0700192static struct wake_lock wlan_wake_lock;
Jeff Johnsone7245742012-09-05 17:12:55 -0700193#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700194/* set when SSR is needed after unload */
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700195static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700196
197//internal function declaration
Jeff Johnsone7245742012-09-05 17:12:55 -0700198static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx);
199static void wlan_hdd_restart_init(hdd_context_t *pHddCtx);
200static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx);
201void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback);
Sameer Thalappil45931fb2013-02-01 11:18:05 -0800202void hdd_set_wlan_suspend_mode(bool suspend);
Jeff Johnsone7245742012-09-05 17:12:55 -0700203
Jeff Johnson295189b2012-06-20 16:38:30 -0700204v_U16_t hdd_select_queue(struct net_device *dev,
205 struct sk_buff *skb);
206
207#ifdef WLAN_FEATURE_PACKET_FILTERING
208static void hdd_set_multicast_list(struct net_device *dev);
209#endif
210
211void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter);
212
213extern int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
Amar Singhal0a402232013-10-11 20:57:16 -0700214
Srinivas Girigowdade697412013-02-14 16:31:48 -0800215#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
216void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand);
217static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels);
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700218static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid,
219 tANI_U8 *pChannel, tANI_U8 *pDwellTime,
220 tANI_U8 **pBuf, tANI_U8 *pBufLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -0700221static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
222 tANI_U8 *pTargetApBssid,
223 tANI_U8 *pChannel);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800224#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700225#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
226VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen);
227#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
228
Mihir Shetee1093ba2014-01-21 20:13:32 +0530229static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx);
230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231static int hdd_netdev_notifier_call(struct notifier_block * nb,
232 unsigned long state,
233 void *ndev)
234{
235 struct net_device *dev = ndev;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700236 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson27cee452013-03-27 11:10:24 -0700237 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700238#ifdef WLAN_BTAMP_FEATURE
239 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700240#endif
241
242 //Make sure that this callback corresponds to our device.
Jeff Johnson27cee452013-03-27 11:10:24 -0700243 if ((strncmp(dev->name, "wlan", 4)) &&
Amar Singhal4c723bd2013-03-25 18:14:15 -0700244 (strncmp(dev->name, "p2p", 3)))
245 return NOTIFY_DONE;
246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 if (!dev->ieee80211_ptr)
Jeff Johnson27cee452013-03-27 11:10:24 -0700248 return NOTIFY_DONE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700249
Jeff Johnson27cee452013-03-27 11:10:24 -0700250 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -0800252 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253 VOS_ASSERT(0);
254 return NOTIFY_DONE;
255 }
256
Jeff Johnson27cee452013-03-27 11:10:24 -0700257 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
258 if (NULL == pHddCtx)
259 {
260 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__);
261 VOS_ASSERT(0);
262 return NOTIFY_DONE;
263 }
Sameer Thalappil14067972014-01-23 14:54:54 -0800264 if (pHddCtx->isLogpInProgress)
265 return NOTIFY_DONE;
266
Jeff Johnson27cee452013-03-27 11:10:24 -0700267
268 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu",
269 __func__, dev->name, state);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270
271 switch (state) {
272 case NETDEV_REGISTER:
273 break;
274
275 case NETDEV_UNREGISTER:
276 break;
277
278 case NETDEV_UP:
279 break;
280
281 case NETDEV_DOWN:
282 break;
283
284 case NETDEV_CHANGE:
Jeff Johnsone7245742012-09-05 17:12:55 -0700285 if(TRUE == pAdapter->isLinkUpSvcNeeded)
286 complete(&pAdapter->linkup_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 break;
288
289 case NETDEV_GOING_DOWN:
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700290 if( pHddCtx->scan_info.mScanPending != FALSE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530292 long result;
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -0800293 INIT_COMPLETION(pHddCtx->scan_info.abortscan_event_var);
Srinivas, Dasari138af4f2014-02-07 11:13:45 +0530294 hdd_abort_mac_scan(pAdapter->pHddCtx, pAdapter->sessionId,
295 eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 result = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -0800297 &pHddCtx->scan_info.abortscan_event_var,
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530299 if (result <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 {
301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530302 "%s: Timeout occurred while waiting for abortscan %ld",
303 __func__, result);
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 }
305 }
306 else
307 {
308 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700309 "%s: Scan is not Pending from user" , __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 }
311#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 status = WLANBAP_StopAmp();
314 if(VOS_STATUS_SUCCESS != status )
315 {
316 pHddCtx->isAmpAllowed = VOS_TRUE;
317 hddLog(VOS_TRACE_LEVEL_FATAL,
318 "%s: Failed to stop AMP", __func__);
319 }
320 else
321 {
322 //a state m/c implementation in PAL is TBD to avoid this delay
323 msleep(500);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700324 if ( pHddCtx->isAmpAllowed )
325 {
326 WLANBAP_DeregisterFromHCI();
327 pHddCtx->isAmpAllowed = VOS_FALSE;
328 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330#endif //WLAN_BTAMP_FEATURE
331 break;
332
333 default:
334 break;
335 }
336
337 return NOTIFY_DONE;
338}
339
340struct notifier_block hdd_netdev_notifier = {
341 .notifier_call = hdd_netdev_notifier_call,
342};
343
344/*---------------------------------------------------------------------------
345 * Function definitions
346 *-------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700347void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx);
348void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700349//variable to hold the insmod parameters
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700350static int con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -0700351#ifndef MODULE
352/* current con_mode - used only for statically linked driver
353 * con_mode is changed by userspace to indicate a mode change which will
354 * result in calling the module exit and init functions. The module
355 * exit function will clean up based on the value of con_mode prior to it
356 * being changed by userspace. So curr_con_mode records the current con_mode
357 * for exit when con_mode becomes the next mode for init
358 */
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700359static int curr_con_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700360#endif
361
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -0800362/**---------------------------------------------------------------------------
363
364 \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable
365
366 Called immediately after the cfg.ini is read in order to configure
367 the desired trace levels.
368
369 \param - moduleId - module whose trace level is being configured
370 \param - bitmask - bitmask of log levels to be enabled
371
372 \return - void
373
374 --------------------------------------------------------------------------*/
375static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask)
376{
377 wpt_tracelevel level;
378
379 /* if the bitmask is the default value, then a bitmask was not
380 specified in cfg.ini, so leave the logging level alone (it
381 will remain at the "compiled in" default value) */
382 if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask)
383 {
384 return;
385 }
386
387 /* a mask was specified. start by disabling all logging */
388 vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0);
389
390 /* now cycle through the bitmask until all "set" bits are serviced */
391 level = VOS_TRACE_LEVEL_FATAL;
392 while (0 != bitmask)
393 {
394 if (bitmask & 1)
395 {
396 vos_trace_setValue(moduleId, level, 1);
397 }
398 level++;
399 bitmask >>= 1;
400 }
401}
402
403
Jeff Johnson295189b2012-06-20 16:38:30 -0700404/**---------------------------------------------------------------------------
405
406 \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable
407
408 Called immediately after the cfg.ini is read in order to configure
409 the desired trace levels in the WDI.
410
411 \param - moduleId - module whose trace level is being configured
412 \param - bitmask - bitmask of log levels to be enabled
413
414 \return - void
415
416 --------------------------------------------------------------------------*/
417static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask)
418{
419 wpt_tracelevel level;
420
421 /* if the bitmask is the default value, then a bitmask was not
422 specified in cfg.ini, so leave the logging level alone (it
423 will remain at the "compiled in" default value) */
424 if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask)
425 {
426 return;
427 }
428
429 /* a mask was specified. start by disabling all logging */
430 wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0);
431
432 /* now cycle through the bitmask until all "set" bits are serviced */
433 level = eWLAN_PAL_TRACE_LEVEL_FATAL;
434 while (0 != bitmask)
435 {
436 if (bitmask & 1)
437 {
438 wpalTraceSetLevel(moduleId, level, 1);
439 }
440 level++;
441 bitmask >>= 1;
442 }
443}
Jeff Johnson295189b2012-06-20 16:38:30 -0700444
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530445/*
446 * FUNCTION: wlan_hdd_validate_context
447 * This function is used to check the HDD context
448 */
449int wlan_hdd_validate_context(hdd_context_t *pHddCtx)
450{
451 ENTER();
452
453 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
454 {
455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
456 "%s: HDD context is Null", __func__);
457 return -ENODEV;
458 }
459
460 if (pHddCtx->isLogpInProgress)
461 {
462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
463 "%s: LOGP in Progress. Ignore!!!", __func__);
464 return -EAGAIN;
465 }
466
467 if (pHddCtx->isLoadUnloadInProgress)
468 {
469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
470 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
471 return -EAGAIN;
472 }
473 return 0;
474}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700475#ifdef CONFIG_ENABLE_LINUX_REG
476void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx)
477{
478 hdd_adapter_t *pAdapter = NULL;
479 hdd_station_ctx_t *pHddStaCtx = NULL;
480 eCsrPhyMode phyMode;
481 hdd_config_t *cfg_param = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530482
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700483 if (NULL == pHddCtx)
484 {
485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
486 "HDD Context is null !!");
487 return ;
488 }
489
490 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
491 if (NULL == pAdapter)
492 {
493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
494 "pAdapter is null !!");
495 return ;
496 }
497
498 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
499 if (NULL == pHddStaCtx)
500 {
501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
502 "pHddStaCtx is null !!");
503 return ;
504 }
505
506 cfg_param = pHddCtx->cfg_ini;
507 if (NULL == cfg_param)
508 {
509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
510 "cfg_params not available !!");
511 return ;
512 }
513
514 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
515
516 if (!pHddCtx->isVHT80Allowed)
517 {
518 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
519 (eCSR_DOT11_MODE_11ac == phyMode) ||
520 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
521 {
522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
523 "Setting phymode to 11n!!");
524 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
525 }
526 }
527 else
528 {
529 /*New country Supports 11ac as well resetting value back from .ini*/
530 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
531 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
532 return ;
533 }
534
535 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
536 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
537 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
538 {
539 VOS_STATUS vosStatus;
540
541 // need to issue a disconnect to CSR.
542 INIT_COMPLETION(pAdapter->disconnect_comp_var);
543 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
544 pAdapter->sessionId,
545 eCSR_DISCONNECT_REASON_UNSPECIFIED );
546
547 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530548 {
549 long ret;
550
551 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700552 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530553 if (0 >= ret)
554 hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"),
555 ret);
556 }
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700557
558 }
559}
560#else
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530561void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code)
562{
563 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
564 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
565 hdd_config_t *cfg_param;
566 eCsrPhyMode phyMode;
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530567 long ret;
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530568
569 if (NULL == pHddCtx)
570 {
571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
572 "HDD Context is null !!");
573 return ;
574 }
575
576 cfg_param = pHddCtx->cfg_ini;
577
578 if (NULL == cfg_param)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
581 "cfg_params not available !!");
582 return ;
583 }
584
585 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
586
587 if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code))
588 {
589 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
590 (eCSR_DOT11_MODE_11ac == phyMode) ||
591 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
592 {
593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
594 "Setting phymode to 11n!!");
595 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
596 }
597 }
598 else
599 {
600 /*New country Supports 11ac as well resetting value back from .ini*/
601 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
602 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
603 return ;
604 }
605
606 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
607 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
608 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
609 {
610 VOS_STATUS vosStatus;
611
612 // need to issue a disconnect to CSR.
613 INIT_COMPLETION(pAdapter->disconnect_comp_var);
614 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
615 pAdapter->sessionId,
616 eCSR_DISCONNECT_REASON_UNSPECIFIED );
617
618 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530619 {
620 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530621 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530622 if (ret <= 0)
623 {
624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
625 "wait on disconnect_comp_var is failed %ld", ret);
626 }
627 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530628
629 }
630}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700631#endif //CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530632
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700633void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code)
634{
635 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
636 hdd_config_t *cfg_param;
637
638 if (NULL == pHddCtx)
639 {
640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
641 "HDD Context is null !!");
642 return ;
643 }
644
645 cfg_param = pHddCtx->cfg_ini;
646
647 if (NULL == cfg_param)
648 {
649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
650 "cfg_params not available !!");
651 return ;
652 }
653
654 if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code))
655 {
656 /*New country doesn't support DFS */
657 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0);
658 }
659 else
660 {
661 /*New country Supports DFS as well resetting value back from .ini*/
662 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan);
663 }
664
665}
666
Rajeev79dbe4c2013-10-05 11:03:42 +0530667#ifdef FEATURE_WLAN_BATCH_SCAN
668
669/**---------------------------------------------------------------------------
670
671 \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from
672 input string
673
674 This function extracts assigned integer from string in below format:
675 "STRING=10" : extracts integer 10 from this string
676
677 \param - pInPtr Pointer to input string
678 \param - base Base for string to int conversion(10 for decimal 16 for hex)
679 \param - pOutPtr Pointer to variable in which extracted integer needs to be
680 assigned
681 \param - pLastArg to tell whether it is last arguement in input string or
682 not
683
684 \return - NULL for failure cases
685 pointer to next arguement in input string for success cases
686 --------------------------------------------------------------------------*/
687static tANI_U8 *
688hdd_extract_assigned_int_from_str
689(
690 tANI_U8 *pInPtr,
691 tANI_U8 base,
692 tANI_U32 *pOutPtr,
693 tANI_U8 *pLastArg
694)
695{
696 int tempInt;
697 int v = 0;
698 char buf[32];
699 int val = 0;
700 *pLastArg = FALSE;
701
702 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
703 if (NULL == pInPtr)
704 {
705 return NULL;
706 }
707
708 pInPtr++;
709
710 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
711
712 val = sscanf(pInPtr, "%32s ", buf);
713 if (val < 0 && val > strlen(pInPtr))
714 {
715 return NULL;
716 }
717 pInPtr += val;
718 v = kstrtos32(buf, base, &tempInt);
719 if (v < 0)
720 {
721 return NULL;
722 }
Rajeev Kumar4d93d842014-01-02 18:31:21 -0800723 if (tempInt < 0)
724 {
725 tempInt = 0;
726 }
Rajeev79dbe4c2013-10-05 11:03:42 +0530727 *pOutPtr = tempInt;
728
729 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
730 if (NULL == pInPtr)
731 {
732 *pLastArg = TRUE;
733 return NULL;
734 }
735 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
736
737 return pInPtr;
738}
739
740/**---------------------------------------------------------------------------
741
742 \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from
743 input string
744
745 This function extracts assigned character from string in below format:
746 "STRING=A" : extracts char 'A' from this string
747
748 \param - pInPtr Pointer to input string
749 \param - pOutPtr Pointer to variable in which extracted char needs to be
750 assigned
751 \param - pLastArg to tell whether it is last arguement in input string or
752 not
753
754 \return - NULL for failure cases
755 pointer to next arguement in input string for success cases
756 --------------------------------------------------------------------------*/
757static tANI_U8 *
758hdd_extract_assigned_char_from_str
759(
760 tANI_U8 *pInPtr,
761 tANI_U8 *pOutPtr,
762 tANI_U8 *pLastArg
763)
764{
765 *pLastArg = FALSE;
766
767 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
768 if (NULL == pInPtr)
769 {
770 return NULL;
771 }
772
773 pInPtr++;
774
775 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
776
777 *pOutPtr = *pInPtr;
778
779 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
780 if (NULL == pInPtr)
781 {
782 *pLastArg = TRUE;
783 return NULL;
784 }
785 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
786
787 return pInPtr;
788}
789
790
791/**---------------------------------------------------------------------------
792
793 \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command
794
795 This function parses set batch scan command in below format:
796 WLS_BATCHING_SET <space> followed by below arguements
797 "SCANFREQ=XX" : Optional defaults to 30 sec
798 "MSCAN=XX" : Required number of scans to attempt to batch
799 "BESTN=XX" : Best Network (RSSI) defaults to 16
800 "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B.
801 A. implies only 5 GHz , B. implies only 2.4GHz
802 "RTT=X" : optional defaults to 0
803 returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on
804 error
805
806 For example input commands:
807 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is
808 translated into set batch scan with following parameters:
809 a) Frequence 60 seconds
810 b) Batch 10 scans together
811 c) Best RSSI to be 20
812 d) 5GHz band only
813 e) RTT is equal to 0
814
815 \param - pValue Pointer to input channel list
816 \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure
817
818 \return - 0 for success non-zero for failure
819
820 --------------------------------------------------------------------------*/
821static int
822hdd_parse_set_batchscan_command
823(
824 tANI_U8 *pValue,
825 tSirSetBatchScanReq *pHddSetBatchScanReq
826)
827{
828 tANI_U8 *inPtr = pValue;
829 tANI_U8 val = 0;
830 tANI_U8 lastArg = 0;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800831 tANI_U32 nScanFreq;
832 tANI_U32 nMscan;
833 tANI_U32 nBestN;
834 tANI_U8 ucRfBand;
835 tANI_U32 nRtt;
Rajeev Kumarc933d982013-11-18 20:04:20 -0800836 tANI_U32 temp;
Rajeev79dbe4c2013-10-05 11:03:42 +0530837
838 /*initialize default values*/
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800839 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ;
840 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
841 nRtt = 0;
842 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK;
Rajeev79dbe4c2013-10-05 11:03:42 +0530843
844 /*go to space after WLS_BATCHING_SET command*/
845 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
846 /*no argument after the command*/
847 if (NULL == inPtr)
848 {
849 return -EINVAL;
850 }
851
852 /*no space after the command*/
853 else if (SPACE_ASCII_VALUE != *inPtr)
854 {
855 return -EINVAL;
856 }
857
858 /*removing empty spaces*/
859 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
860
861 /*no argument followed by spaces*/
862 if ('\0' == *inPtr)
863 {
864 return -EINVAL;
865 }
866
867 /*check and parse SCANFREQ*/
868 if ((strncmp(inPtr, "SCANFREQ", 8) == 0))
869 {
870 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800871 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800872
Rajeev Kumarc933d982013-11-18 20:04:20 -0800873 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800874 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800875 nScanFreq = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800876 }
877
Rajeev79dbe4c2013-10-05 11:03:42 +0530878 if ( (NULL == inPtr) || (TRUE == lastArg))
879 {
880 return -EINVAL;
881 }
882 }
883
884 /*check and parse MSCAN*/
885 if ((strncmp(inPtr, "MSCAN", 5) == 0))
886 {
887 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800888 &nMscan, &lastArg);
889
890 if (0 == nMscan)
891 {
892 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
893 "invalid MSCAN=%d", nMscan);
894 return -EINVAL;
895 }
896
Rajeev79dbe4c2013-10-05 11:03:42 +0530897 if (TRUE == lastArg)
898 {
899 goto done;
900 }
901 else if (NULL == inPtr)
902 {
903 return -EINVAL;
904 }
905 }
906 else
907 {
908 return -EINVAL;
909 }
910
911 /*check and parse BESTN*/
912 if ((strncmp(inPtr, "BESTN", 5) == 0))
913 {
914 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800915 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800916
Rajeev Kumarc933d982013-11-18 20:04:20 -0800917 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800918 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800919 nBestN = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800920 }
921
Rajeev79dbe4c2013-10-05 11:03:42 +0530922 if (TRUE == lastArg)
923 {
924 goto done;
925 }
926 else if (NULL == inPtr)
927 {
928 return -EINVAL;
929 }
930 }
931
932 /*check and parse CHANNEL*/
933 if ((strncmp(inPtr, "CHANNEL", 7) == 0))
934 {
935 inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg);
Rajeev Kumarc933d982013-11-18 20:04:20 -0800936
Rajeev79dbe4c2013-10-05 11:03:42 +0530937 if (('A' == val) || ('a' == val))
938 {
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800939 ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530940 }
941 else if (('B' == val) || ('b' == val))
942 {
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800943 ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530944 }
945 else
946 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800947 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
948 }
949
950 if (TRUE == lastArg)
951 {
952 goto done;
953 }
954 else if (NULL == inPtr)
955 {
Rajeev79dbe4c2013-10-05 11:03:42 +0530956 return -EINVAL;
957 }
958 }
959
960 /*check and parse RTT*/
961 if ((strncmp(inPtr, "RTT", 3) == 0))
962 {
963 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800964 &nRtt, &lastArg);
Rajeev79dbe4c2013-10-05 11:03:42 +0530965 if (TRUE == lastArg)
966 {
967 goto done;
968 }
969 if (NULL == inPtr)
970 {
971 return -EINVAL;
972 }
973 }
974
975
976done:
977
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800978 pHddSetBatchScanReq->scanFrequency = nScanFreq;
979 pHddSetBatchScanReq->numberOfScansToBatch = nMscan;
980 pHddSetBatchScanReq->bestNetwork = nBestN;
981 pHddSetBatchScanReq->rfBand = ucRfBand;
982 pHddSetBatchScanReq->rtt = nRtt;
983
Rajeev79dbe4c2013-10-05 11:03:42 +0530984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
985 "Received WLS_BATCHING_SET with SCANFREQ=%d "
986 "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d",
987 pHddSetBatchScanReq->scanFrequency,
988 pHddSetBatchScanReq->numberOfScansToBatch,
989 pHddSetBatchScanReq->bestNetwork,
990 pHddSetBatchScanReq->rfBand,
991 pHddSetBatchScanReq->rtt);
992
993 return 0;
994}/*End of hdd_parse_set_batchscan_command*/
995
996/**---------------------------------------------------------------------------
997
998 \brief hdd_set_batch_scan_req_callback () - This function is called after
999 receiving set batch scan response from FW and it saves set batch scan
1000 response data FW to HDD context and sets the completion event on
1001 which hdd_ioctl is waiting
1002
1003 \param - callbackContext Pointer to HDD adapter
1004 \param - pRsp Pointer to set batch scan response data received from FW
1005
1006 \return - nothing
1007
1008 --------------------------------------------------------------------------*/
1009static void hdd_set_batch_scan_req_callback
1010(
1011 void *callbackContext,
1012 tSirSetBatchScanRsp *pRsp
1013)
1014{
1015 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
1016 tSirSetBatchScanRsp *pHddSetBatchScanRsp;
1017
1018 /*sanity check*/
1019 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1020 {
1021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1022 "%s: Invalid pAdapter magic", __func__);
1023 VOS_ASSERT(0);
1024 return;
1025 }
1026 pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp;
1027
1028 /*save set batch scan response*/
1029 pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch;
1030
1031 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1032 "Received set batch scan rsp from FW with nScansToBatch=%d",
1033 pHddSetBatchScanRsp->nScansToBatch);
1034
1035 pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE;
1036 complete(&pAdapter->hdd_set_batch_scan_req_var);
1037
1038 return;
1039}/*End of hdd_set_batch_scan_req_callback*/
1040
1041
1042/**---------------------------------------------------------------------------
1043
1044 \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta
1045 info in hdd batch scan response queue
1046
1047 \param - pAdapter Pointer to hdd adapter
1048 \param - pAPMetaInfo Pointer to access point meta info
1049 \param - scanId scan ID of batch scan response
1050 \param - isLastAp tells whether AP is last AP in batch scan response or not
1051
1052 \return - nothing
1053
1054 --------------------------------------------------------------------------*/
1055static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter,
1056 tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp)
1057{
1058 tHddBatchScanRsp *pHead;
1059 tHddBatchScanRsp *pNode;
1060 tHddBatchScanRsp *pPrev;
1061 tHddBatchScanRsp *pTemp;
1062 tANI_U8 ssidLen;
1063
1064 /*head of hdd batch scan response queue*/
1065 pHead = pAdapter->pBatchScanRsp;
1066
1067 pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp));
1068 if (NULL == pNode)
1069 {
1070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1071 "%s: Could not allocate memory", __func__);
1072 VOS_ASSERT(0);
1073 return;
1074 }
1075
1076 vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid,
1077 sizeof(pNode->ApInfo.bssid));
1078 ssidLen = strlen(pApMetaInfo->ssid);
1079 if (SIR_MAX_SSID_SIZE < ssidLen)
1080 {
1081 /*invalid scan result*/
1082 vos_mem_free(pNode);
1083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1084 "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen);
1085 return;
1086 }
1087 vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen);
1088 /*null terminate ssid*/
1089 pNode->ApInfo.ssid[ssidLen] = '\0';
1090 pNode->ApInfo.ch = pApMetaInfo->ch;
1091 pNode->ApInfo.rssi = pApMetaInfo->rssi;
1092 pNode->ApInfo.age = pApMetaInfo->timestamp;
1093 pNode->ApInfo.batchId = scanId;
1094 pNode->ApInfo.isLastAp = isLastAp;
1095
1096 pNode->pNext = NULL;
1097 if (NULL == pHead)
1098 {
1099 pAdapter->pBatchScanRsp = pNode;
1100 }
1101 else
1102 {
1103 pTemp = pHead;
1104 while (NULL != pTemp)
1105 {
1106 pPrev = pTemp;
1107 pTemp = pTemp->pNext;
1108 }
1109 pPrev->pNext = pNode;
1110 }
1111
1112 return;
1113}/*End of hdd_populate_batch_scan_rsp_queue*/
1114
1115/**---------------------------------------------------------------------------
1116
1117 \brief hdd_batch_scan_result_ind_callback () - This function is called after
1118 receiving batch scan response indication from FW. It saves get batch scan
1119 response data in HDD batch scan response queue. This callback sets the
1120 completion event on which hdd_ioctl is waiting only after getting complete
1121 batch scan response data from FW
1122
1123 \param - callbackContext Pointer to HDD adapter
1124 \param - pRsp Pointer to get batch scan response data received from FW
1125
1126 \return - nothing
1127
1128 --------------------------------------------------------------------------*/
1129static void hdd_batch_scan_result_ind_callback
1130(
1131 void *callbackContext,
1132 void *pRsp
1133)
1134{
1135 v_BOOL_t isLastAp;
1136 tANI_U32 numApMetaInfo;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001137 tANI_U32 numNetworkInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301138 tANI_U32 numberScanList;
1139 tANI_U32 nextScanListOffset;
1140 tANI_U32 nextApMetaInfoOffset;
1141 hdd_adapter_t* pAdapter;
1142 tpSirBatchScanList pScanList;
1143 tpSirBatchScanNetworkInfo pApMetaInfo;
1144 tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/
1145 tSirSetBatchScanReq *pReq;
1146
1147 pAdapter = (hdd_adapter_t *)callbackContext;
1148 /*sanity check*/
Rajeev Kumar5286bb92013-12-05 11:52:10 -08001149 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Rajeev79dbe4c2013-10-05 11:03:42 +05301150 {
1151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1152 "%s: Invalid pAdapter magic", __func__);
1153 VOS_ASSERT(0);
1154 return;
1155 }
1156
1157 /*initialize locals*/
1158 pReq = &pAdapter->hddSetBatchScanReq;
1159 pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp;
1160 isLastAp = FALSE;
1161 numApMetaInfo = 0;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001162 numNetworkInScanList = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05301163 numberScanList = 0;
1164 nextScanListOffset = 0;
1165 nextApMetaInfoOffset = 0;
1166 pScanList = NULL;
1167 pApMetaInfo = NULL;
1168
1169 if ((NULL == pBatchScanRsp) || (NULL == pReq))
1170 {
1171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1172 "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq);
1173 isLastAp = TRUE;
1174 goto done;
1175 }
1176
1177 pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists;
1178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1179 "Batch scan rsp: numberScalList %d", numberScanList);
1180
1181 if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch))
1182 {
1183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1184 "%s: numberScanList %d", __func__, numberScanList);
1185 isLastAp = TRUE;
1186 goto done;
1187 }
1188
1189 while (numberScanList)
1190 {
Rajeev Kumarce651e42013-10-21 18:57:15 -07001191 pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults +
Rajeev79dbe4c2013-10-05 11:03:42 +05301192 nextScanListOffset);
1193 if (NULL == pScanList)
1194 {
1195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1196 "%s: pScanList is %p", __func__, pScanList);
1197 isLastAp = TRUE;
1198 goto done;
1199 }
Rajeev Kumarce651e42013-10-21 18:57:15 -07001200 numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumarce651e42013-10-21 18:57:15 -07001202 "Batch scan rsp: numApMetaInfo %d scanId %d",
1203 numApMetaInfo, pScanList->scanId);
Rajeev79dbe4c2013-10-05 11:03:42 +05301204
1205 if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork))
1206 {
1207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1208 "%s: numApMetaInfo %d", __func__, numApMetaInfo);
1209 isLastAp = TRUE;
1210 goto done;
1211 }
1212
Rajeev Kumarce651e42013-10-21 18:57:15 -07001213 /*Initialize next AP meta info offset for next scan list*/
1214 nextApMetaInfoOffset = 0;
1215
Rajeev79dbe4c2013-10-05 11:03:42 +05301216 while (numApMetaInfo)
1217 {
1218 pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList +
1219 nextApMetaInfoOffset);
1220 if (NULL == pApMetaInfo)
1221 {
1222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1223 "%s: pApMetaInfo is %p", __func__, pApMetaInfo);
1224 isLastAp = TRUE;
1225 goto done;
1226 }
1227 /*calculate AP age*/
1228 pApMetaInfo->timestamp =
1229 pBatchScanRsp->timestamp - pApMetaInfo->timestamp;
1230
1231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussaina7c8e412013-11-20 11:06:42 -08001232 "%s: bssId "MAC_ADDRESS_STR
1233 " ch %d rssi %d timestamp %d", __func__,
1234 MAC_ADDR_ARRAY(pApMetaInfo->bssid),
1235 pApMetaInfo->ch, pApMetaInfo->rssi,
1236 pApMetaInfo->timestamp);
Rajeev79dbe4c2013-10-05 11:03:42 +05301237
1238 /*mark last AP in batch scan response*/
1239 if ((TRUE == pBatchScanRsp->isLastResult) &&
1240 (1 == numberScanList) && (1 == numApMetaInfo))
1241 {
1242 isLastAp = TRUE;
1243 }
1244
1245 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1246 /*store batch scan repsonse in hdd queue*/
1247 hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo,
1248 pScanList->scanId, isLastAp);
1249 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1250
1251 nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo);
1252 numApMetaInfo--;
1253 }
1254
Rajeev Kumarce651e42013-10-21 18:57:15 -07001255 nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8))
1256 + (sizeof(tSirBatchScanNetworkInfo)
1257 * numNetworkInScanList));
Rajeev79dbe4c2013-10-05 11:03:42 +05301258 numberScanList--;
1259 }
1260
1261done:
1262
1263 /*notify hdd_ioctl only if complete batch scan rsp is received and it was
1264 requested from hdd_ioctl*/
1265 if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) &&
1266 (TRUE == isLastAp))
1267 {
1268 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1269 complete(&pAdapter->hdd_get_batch_scan_req_var);
1270 }
1271
1272 return;
1273}/*End of hdd_batch_scan_result_ind_callback*/
1274
1275/**---------------------------------------------------------------------------
1276
1277 \brief hdd_format_batch_scan_rsp () - This function formats batch scan
1278 response as per batch scan FR request format by putting proper markers
1279
1280 \param - pDest pointer to destination buffer
1281 \param - cur_len current length
1282 \param - tot_len total remaining size which can be written to user space
1283 \param - pApMetaInfo Pointer to get batch scan response AP meta info
1284 \param - pAdapter Pointer to HDD adapter
1285
1286 \return - ret no of characters written
1287
1288 --------------------------------------------------------------------------*/
1289static tANI_U32
1290hdd_format_batch_scan_rsp
1291(
1292 tANI_U8 *pDest,
1293 tANI_U32 cur_len,
1294 tANI_U32 tot_len,
1295 tHddBatchScanRsp *pApMetaInfo,
1296 hdd_adapter_t* pAdapter
1297)
1298{
1299 tANI_U32 ret = 0;
1300 tANI_U32 rem_len = 0;
1301 tANI_U8 temp_len = 0;
1302 tANI_U8 temp_total_len = 0;
1303 tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE];
1304 tANI_U8 *pTemp = temp;
1305
1306 /*Batch scan reponse needs to be returned to user space in
1307 following format:
1308 "scancount=X\n" where X is the number of scans in current batch
1309 batch
1310 "trunc\n" optional present if current scan truncated
1311 "bssid=XX:XX:XX:XX:XX:XX\n"
1312 "ssid=XXXX\n"
1313 "freq=X\n" frequency in Mhz
1314 "level=XX\n"
1315 "age=X\n" ms
1316 "dist=X\n" cm (-1 if not available)
1317 "errror=X\n" (-1if not available)
1318 "====\n" (end of ap marker)
1319 "####\n" (end of scan marker)
1320 "----\n" (end of results)*/
1321 /*send scan result in above format to user space based on
1322 available length*/
1323 /*The GET response may have more data than the driver can return in its
1324 buffer. In that case the buffer should be filled to the nearest complete
1325 scan, ending with "%%%%".Subsequent callsshould return the remaining data
1326 starting with the next scan (optional .trunc\n., .apcount=X\n., etc).
1327 The final buffer should end with "----\n"*/
1328
1329 /*sanity*/
1330 if (cur_len > tot_len)
1331 {
1332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1333 "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len);
1334 return 0;
1335 }
1336 else
1337 {
1338 rem_len = (tot_len - cur_len);
1339 }
1340
1341 /*end scan marker*/
1342 if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id)
1343 {
1344 temp_len = snprintf(pTemp, sizeof(temp), "####\n");
1345 pTemp += temp_len;
1346 temp_total_len += temp_len;
1347 }
1348
1349 /*bssid*/
1350 temp_len = snprintf(pTemp, sizeof(temp),
1351 "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n",
1352 pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1],
1353 pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3],
1354 pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]);
1355 pTemp += temp_len;
1356 temp_total_len += temp_len;
1357
1358 /*ssid*/
1359 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n",
1360 pApMetaInfo->ApInfo.ssid);
1361 pTemp += temp_len;
1362 temp_total_len += temp_len;
1363
1364 /*freq*/
1365 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n",
Rajeev Kumarc40f7512013-11-04 14:13:23 -08001366 sme_ChnToFreq(pApMetaInfo->ApInfo.ch));
Rajeev79dbe4c2013-10-05 11:03:42 +05301367 pTemp += temp_len;
1368 temp_total_len += temp_len;
1369
1370 /*level*/
1371 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n",
1372 pApMetaInfo->ApInfo.rssi);
1373 pTemp += temp_len;
1374 temp_total_len += temp_len;
1375
1376 /*age*/
Jeff Johnson02797792013-10-26 19:17:13 -07001377 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n",
Rajeev79dbe4c2013-10-05 11:03:42 +05301378 pApMetaInfo->ApInfo.age);
1379 pTemp += temp_len;
1380 temp_total_len += temp_len;
1381
1382 /*dist*/
1383 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n");
1384 pTemp += temp_len;
1385 temp_total_len += temp_len;
1386
1387 /*error*/
1388 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n");
1389 pTemp += temp_len;
1390 temp_total_len += temp_len;
1391
1392 /*end AP marker*/
1393 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n");
1394 pTemp += temp_len;
1395 temp_total_len += temp_len;
1396
1397 /*last AP in batch scan response*/
1398 if(TRUE == pApMetaInfo->ApInfo.isLastAp)
1399 {
1400 /*end scan marker*/
1401 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n");
1402 pTemp += temp_len;
1403 temp_total_len += temp_len;
1404
1405 /*end batch scan result marker*/
1406 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n");
1407 pTemp += temp_len;
1408 temp_total_len += temp_len;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001409
Rajeev79dbe4c2013-10-05 11:03:42 +05301410 }
1411
1412 if (temp_total_len < rem_len)
1413 {
1414 ret = temp_total_len + 1;
1415 strlcpy(pDest, temp, ret);
1416 pAdapter->isTruncated = FALSE;
1417 }
1418 else
1419 {
1420 pAdapter->isTruncated = TRUE;
1421 if (rem_len >= strlen("%%%%"))
1422 {
Rajeev Kumarc933d982013-11-18 20:04:20 -08001423 ret = snprintf(pDest, sizeof(temp), "%%%%");
Rajeev79dbe4c2013-10-05 11:03:42 +05301424 }
Rajeev Kumarc933d982013-11-18 20:04:20 -08001425 else
Rajeev79dbe4c2013-10-05 11:03:42 +05301426 {
1427 ret = 0;
1428 }
1429 }
1430
1431 return ret;
1432
1433}/*End of hdd_format_batch_scan_rsp*/
1434
1435/**---------------------------------------------------------------------------
1436
1437 \brief hdd_populate_user_batch_scan_rsp() - This function populates user data
1438 buffer starting with head of hdd batch scan response queue
1439
1440 \param - pAdapter Pointer to HDD adapter
1441 \param - pDest Pointer to user data buffer
1442 \param - cur_len current offset in user buffer
1443 \param - rem_len remaining no of bytes in user buffer
1444
1445 \return - number of bytes written in user buffer
1446
1447 --------------------------------------------------------------------------*/
1448
1449tANI_U32 hdd_populate_user_batch_scan_rsp
1450(
1451 hdd_adapter_t* pAdapter,
1452 tANI_U8 *pDest,
1453 tANI_U32 cur_len,
1454 tANI_U32 rem_len
1455)
1456{
1457 tHddBatchScanRsp *pHead;
1458 tHddBatchScanRsp *pPrev;
1459 tANI_U32 len;
1460
Rajeev79dbe4c2013-10-05 11:03:42 +05301461 pAdapter->isTruncated = FALSE;
1462
1463 /*head of hdd batch scan response queue*/
1464 pHead = pAdapter->pBatchScanRsp;
1465 while (pHead)
1466 {
1467 len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead,
1468 pAdapter);
1469 pDest += len;
Rajeev Kumar292d2bb2013-10-23 15:01:44 -07001470 pDest--;
Rajeev79dbe4c2013-10-05 11:03:42 +05301471 cur_len += len;
1472 if(TRUE == pAdapter->isTruncated)
1473 {
1474 /*result is truncated return rest of scan rsp in next req*/
1475 cur_len = rem_len;
1476 break;
1477 }
1478 pPrev = pHead;
1479 pHead = pHead->pNext;
1480 pAdapter->pBatchScanRsp = pHead;
Rajeev Kumarbe17d8b2014-01-10 15:39:45 -08001481 if (TRUE == pPrev->ApInfo.isLastAp)
1482 {
1483 pAdapter->prev_batch_id = 0;
1484 }
1485 else
1486 {
1487 pAdapter->prev_batch_id = pPrev->ApInfo.batchId;
1488 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301489 vos_mem_free(pPrev);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001490 pPrev = NULL;
Rajeev79dbe4c2013-10-05 11:03:42 +05301491 }
1492
1493 return cur_len;
1494}/*End of hdd_populate_user_batch_scan_rsp*/
1495
1496/**---------------------------------------------------------------------------
1497
1498 \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch
1499 scan response data from HDD queue to user space
1500 It does following in detail:
1501 a) if HDD has enough data in its queue then it 1st copies data to user
1502 space and then send get batch scan indication message to FW. In this
1503 case it does not wait on any event and batch scan response data will
1504 be populated in HDD response queue in MC thread context after receiving
1505 indication from FW
1506 b) else send get batch scan indication message to FW and wait on an event
1507 which will be set once HDD receives complete batch scan response from
1508 FW and then this function returns batch scan response to user space
1509
1510 \param - pAdapter Pointer to HDD adapter
1511 \param - pPrivData Pointer to priv_data
1512
1513 \return - 0 for success -EFAULT for failure
1514
1515 --------------------------------------------------------------------------*/
1516
1517int hdd_return_batch_scan_rsp_to_user
1518(
1519 hdd_adapter_t* pAdapter,
1520 hdd_priv_data_t *pPrivData,
1521 tANI_U8 *command
1522)
1523{
1524 tANI_U8 *pDest;
1525 tANI_U32 count = 0;
1526 tANI_U32 len = 0;
1527 tANI_U32 cur_len = 0;
1528 tANI_U32 rem_len = 0;
1529 eHalStatus halStatus;
1530 unsigned long rc;
1531 tSirTriggerBatchScanResultInd *pReq;
1532
1533 pReq = &pAdapter->hddTriggerBatchScanResultInd;
1534 pReq->param = 0;/*batch scan client*/
1535 pDest = (tANI_U8 *)(command + pPrivData->used_len);
1536 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1537
1538 cur_len = pPrivData->used_len;
1539 if (pPrivData->total_len > pPrivData->used_len)
1540 {
1541 rem_len = pPrivData->total_len - pPrivData->used_len;
1542 }
1543 else
1544 {
1545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1546 "%s: Invalid user data buffer total_len %d used_len %d",
1547 __func__, pPrivData->total_len, pPrivData->used_len);
1548 return -EFAULT;
1549 }
1550
1551 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1552 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1553 cur_len, rem_len);
1554 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1555
1556 /*enough scan result available in cache to return to user space or
1557 scan result needs to be fetched 1st from fw and then return*/
Rajeev Kumar99db6262013-11-11 15:23:36 -08001558 if (len == cur_len)
Rajeev79dbe4c2013-10-05 11:03:42 +05301559 {
1560 pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE;
1561 halStatus = sme_TriggerBatchScanResultInd(
1562 WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1563 pAdapter->sessionId, hdd_batch_scan_result_ind_callback,
1564 pAdapter);
1565 if ( eHAL_STATUS_SUCCESS == halStatus )
1566 {
1567 if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp)
1568 {
1569 INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var);
1570 rc = wait_for_completion_timeout(
1571 &pAdapter->hdd_get_batch_scan_req_var,
1572 msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT));
1573 if (0 == rc)
1574 {
1575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1576 "%s: Timeout waiting to fetch batch scan rsp from fw",
1577 __func__);
1578 return -EFAULT;
1579 }
1580 }
1581
1582 len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE,
Jeff Johnson02797792013-10-26 19:17:13 -07001583 "scancount=%u\n", pAdapter->numScanList);
Rajeev79dbe4c2013-10-05 11:03:42 +05301584 pDest += len;
1585 cur_len += len;
1586
1587 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1588 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1589 cur_len, rem_len);
1590 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1591
1592 count = 0;
1593 len = (len - pPrivData->used_len);
1594 pDest = (command + pPrivData->used_len);
1595 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001596 "NEW BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301597 while(count < len)
1598 {
1599 printk("%c", *(pDest + count));
1600 count++;
1601 }
1602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1603 "%s: copy %d data to user buffer", __func__, len);
1604 if (copy_to_user(pPrivData->buf, pDest, len))
1605 {
1606 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1607 "%s: failed to copy data to user buffer", __func__);
1608 return -EFAULT;
1609 }
1610 }
1611 else
1612 {
1613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1614 "sme_GetBatchScanScan returned failure halStatus %d",
1615 halStatus);
1616 return -EINVAL;
1617 }
1618 }
1619 else
1620 {
Rajeev79dbe4c2013-10-05 11:03:42 +05301621 count = 0;
1622 len = (len - pPrivData->used_len);
1623 pDest = (command + pPrivData->used_len);
1624 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001625 "REMAINING TRUNCATED BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301626 while(count < len)
1627 {
1628 printk("%c", *(pDest + count));
1629 count++;
1630 }
Rajeev Kumar99db6262013-11-11 15:23:36 -08001631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1632 "%s: copy %d data to user buffer", __func__, len);
Rajeev79dbe4c2013-10-05 11:03:42 +05301633 if (copy_to_user(pPrivData->buf, pDest, len))
1634 {
1635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1636 "%s: failed to copy data to user buffer", __func__);
1637 return -EFAULT;
1638 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301639 }
1640
1641 return 0;
1642} /*End of hdd_return_batch_scan_rsp_to_user*/
1643
Rajeev Kumar8b373292014-01-08 20:36:55 -08001644
1645/**---------------------------------------------------------------------------
1646
1647 \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING
1648 IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled:
1649 WLS_BATCHING VERSION
1650 WLS_BATCHING SET
1651 WLS_BATCHING GET
1652 WLS_BATCHING STOP
1653
1654 \param - pAdapter Pointer to HDD adapter
1655 \param - pPrivdata Pointer to priv_data
1656 \param - command Pointer to command
1657
1658 \return - 0 for success -EFAULT for failure
1659
1660 --------------------------------------------------------------------------*/
1661
1662int hdd_handle_batch_scan_ioctl
1663(
1664 hdd_adapter_t *pAdapter,
1665 hdd_priv_data_t *pPrivdata,
1666 tANI_U8 *command
1667)
1668{
1669 int ret = 0;
1670
1671 if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0)
1672 {
1673 char extra[32];
1674 tANI_U8 len = 0;
1675 tANI_U8 version = HDD_BATCH_SCAN_VERSION;
1676
1677 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1678 {
1679 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1680 "%s: Batch scan feature is not supported by FW", __func__);
1681 ret = -EINVAL;
1682 goto exit;
1683 }
1684
1685 len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d",
1686 version);
1687 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1688 {
1689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1690 "%s: failed to copy data to user buffer", __func__);
1691 ret = -EFAULT;
1692 goto exit;
1693 }
1694 ret = HDD_BATCH_SCAN_VERSION;
1695 }
1696 else if (strncmp(command, "WLS_BATCHING SET", 16) == 0)
1697 {
1698 int status;
1699 tANI_U8 *value = (command + 16);
1700 eHalStatus halStatus;
1701 unsigned long rc;
1702 tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq;
1703 tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp;
1704
1705 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1706 {
1707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1708 "%s: Batch scan feature is not supported by FW", __func__);
1709 ret = -EINVAL;
1710 goto exit;
1711 }
1712
1713 if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) &&
1714 (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) &&
1715 (WLAN_HDD_P2P_GO != pAdapter->device_mode) &&
1716 (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode))
1717 {
1718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1719 "Received WLS_BATCHING SET command in invalid mode %d "
1720 "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode",
1721 pAdapter->device_mode);
1722 ret = -EINVAL;
1723 goto exit;
1724 }
1725
1726 status = hdd_parse_set_batchscan_command(value, pReq);
1727 if (status)
1728 {
1729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1730 "Invalid WLS_BATCHING SET command");
1731 ret = -EINVAL;
1732 goto exit;
1733 }
1734
1735
1736 pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE;
1737 halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1738 pAdapter->sessionId, hdd_set_batch_scan_req_callback,
1739 pAdapter);
1740
1741 if ( eHAL_STATUS_SUCCESS == halStatus )
1742 {
1743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1744 "sme_SetBatchScanReq returned success halStatus %d",
1745 halStatus);
1746 if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp)
1747 {
1748 INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var);
1749 rc = wait_for_completion_timeout(
1750 &pAdapter->hdd_set_batch_scan_req_var,
1751 msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT));
1752 if (0 == rc)
1753 {
1754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1755 "%s: Timeout waiting for set batch scan to complete",
1756 __func__);
1757 ret = -EINVAL;
1758 goto exit;
1759 }
1760 }
1761 if ( !pRsp->nScansToBatch )
1762 {
1763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1764 "%s: Received set batch scan failure response from FW",
1765 __func__);
1766 ret = -EINVAL;
1767 goto exit;
1768 }
1769 /*As per the Batch Scan Framework API we should return the MIN of
1770 either MSCAN or the max # of scans firmware can cache*/
1771 ret = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch);
1772
1773 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED;
1774
1775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1776 "%s: request MSCAN %d response MSCAN %d ret %d",
1777 __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, ret);
1778 }
1779 else
1780 {
1781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1782 "sme_SetBatchScanReq returned failure halStatus %d",
1783 halStatus);
1784 ret = -EINVAL;
1785 goto exit;
1786 }
1787 }
1788 else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0)
1789 {
1790 eHalStatus halStatus;
1791 tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd;
1792 pInd->param = 0;
1793
1794 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1795 {
1796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1797 "%s: Batch scan feature is not supported by FW", __func__);
1798 ret = -EINVAL;
1799 goto exit;
1800 }
1801
1802 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1803 {
1804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1805 "Batch scan is not yet enabled batch scan state %d",
1806 pAdapter->batchScanState);
1807 ret = -EINVAL;
1808 goto exit;
1809 }
1810
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001811 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1812 hdd_deinit_batch_scan(pAdapter);
1813 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1814
Rajeev Kumar8b373292014-01-08 20:36:55 -08001815 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
1816
1817 halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd,
1818 pAdapter->sessionId);
1819 if ( eHAL_STATUS_SUCCESS == halStatus )
1820 {
1821 ret = 0;
1822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1823 "sme_StopBatchScanInd returned success halStatus %d",
1824 halStatus);
1825 }
1826 else
1827 {
1828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1829 "sme_StopBatchScanInd returned failure halStatus %d",
1830 halStatus);
1831 ret = -EINVAL;
1832 goto exit;
1833 }
1834 }
1835 else if (strncmp(command, "WLS_BATCHING GET", 16) == 0)
1836 {
1837 tANI_U32 remain_len;
1838
1839 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1840 {
1841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1842 "%s: Batch scan feature is not supported by FW", __func__);
1843 ret = -EINVAL;
1844 goto exit;
1845 }
1846
1847 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1848 {
1849 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1850 "Batch scan is not yet enabled could not return results"
1851 "Batch Scan state %d",
1852 pAdapter->batchScanState);
1853 ret = -EINVAL;
1854 goto exit;
1855 }
1856
1857 pPrivdata->used_len = 16;
1858 remain_len = pPrivdata->total_len - pPrivdata->used_len;
1859 if (remain_len < pPrivdata->total_len)
1860 {
1861 /*Clear previous batch scan response data if any*/
1862 vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len);
1863 }
1864 else
1865 {
1866 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1867 "Invalid total length from user space can't fetch batch"
1868 " scan response total_len %d used_len %d remain len %d",
1869 pPrivdata->total_len, pPrivdata->used_len, remain_len);
1870 ret = -EINVAL;
1871 goto exit;
1872 }
1873 ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command);
1874 }
1875
1876exit:
1877
1878 return ret;
1879}
1880
1881
Rajeev79dbe4c2013-10-05 11:03:42 +05301882#endif/*End of FEATURE_WLAN_BATCH_SCAN*/
1883
Jeff Johnson295189b2012-06-20 16:38:30 -07001884int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1885{
1886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1887 hdd_priv_data_t priv_data;
1888 tANI_U8 *command = NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301889 long ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890
1891 if (NULL == pAdapter)
1892 {
1893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05301894 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 ret = -ENODEV;
1896 goto exit;
1897 }
1898
Jeff Johnsone7245742012-09-05 17:12:55 -07001899 if ((!ifr) || (!ifr->ifr_data))
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301901 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1902 "%s: invalid data", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 ret = -EINVAL;
1904 goto exit;
1905 }
1906
Sameer Thalappil8ef3a0e2013-04-05 14:36:04 -07001907 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1908 {
1909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1910 "%s:LOGP in Progress. Ignore!!!", __func__);
1911 ret = -EBUSY;
1912 goto exit;
1913 }
1914
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(hdd_priv_data_t)))
1916 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1918 FL("failed to get data from user buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 ret = -EFAULT;
1920 goto exit;
1921 }
1922
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08001923 if (priv_data.total_len <= 0 ||
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301924 priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN)
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07001925 {
1926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1927 "%s:invalid priv_data.total_len(%d)!!!", __func__,
1928 priv_data.total_len);
1929 ret = -EINVAL;
1930 goto exit;
1931 }
1932
1933 /* Allocate +1 for '\0' */
1934 command = kmalloc(priv_data.total_len + 1, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 if (!command)
1936 {
1937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301938 "%s: failed to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 ret = -ENOMEM;
1940 goto exit;
1941 }
1942
1943 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
1944 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1946 FL("failed to get data from user buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 ret = -EFAULT;
1948 goto exit;
1949 }
1950
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07001951 /* Making sure the command is NUL-terminated */
1952 command[priv_data.total_len] = '\0';
1953
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 if ((SIOCDEVPRIVATE + 1) == cmd)
1955 {
1956 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1957
1958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07001959 "%s: Received %s cmd from Wi-Fi GUI***", __func__, command);
Jeff Johnson295189b2012-06-20 16:38:30 -07001960
1961 if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 )
1962 {
1963 if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes,
1964 sizeof(tSirMacAddr)))
1965 {
1966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001967 "%s: failed to copy data to user buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 ret = -EFAULT;
1969 }
1970 }
Amar Singhal0974e402013-02-12 14:27:46 -08001971 else if(strncmp(command, "SETBAND", 7) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 {
Amar Singhal0974e402013-02-12 14:27:46 -08001973 tANI_U8 *ptr = command ;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001974
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 /* Change band request received */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001976
1977 /* First 8 bytes will have "SETBAND " and
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 * 9 byte will have band setting value */
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal0974e402013-02-12 14:27:46 -08001980 "%s: SetBandCommand Info comm %s UL %d, TL %d", __func__, command, priv_data.used_len, priv_data.total_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 /* Change band request received */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001982 ret = hdd_setBand_helper(dev, ptr);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05301983 if(ret != 0)
1984 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
1985 "%s: failed to set band ret=%ld",__func__, ret);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001986 }
Kiet Lamf040f472013-11-20 21:15:23 +05301987 else if(strncmp(command, "SETWMMPS", 8) == 0)
1988 {
1989 tANI_U8 *ptr = command;
1990 ret = hdd_wmmps_helper(pAdapter, ptr);
1991 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001992 else if ( strncasecmp(command, "COUNTRY", 7) == 0 )
1993 {
1994 char *country_code;
1995
1996 country_code = command + 8;
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07001997
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07001998 INIT_COMPLETION(pAdapter->change_country_code);
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07001999 hdd_checkandupdate_dfssetting(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002000#ifndef CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302001 hdd_checkandupdate_phymode(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002002#endif
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002003 ret = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2004 (void *)(tSmeChangeCountryCallback)
2005 wlan_hdd_change_country_code_callback,
Abhishek Singha306a442013-11-07 18:39:01 +05302006 country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002007 if (eHAL_STATUS_SUCCESS == ret)
2008 {
2009 ret = wait_for_completion_interruptible_timeout(
2010 &pAdapter->change_country_code,
2011 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2012 if (0 >= ret)
2013 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302014 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out %ld",
2015 __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002016 }
2017 }
2018 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07002019 {
2020 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302021 "%s: SME Change Country code fail ret=%ld", __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002022 ret = -EINVAL;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002023 }
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002024
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002025 }
2026 /*
2027 command should be a string having format
2028 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
2029 */
Amar Singhal0974e402013-02-12 14:27:46 -08002030 else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002031 {
Amar Singhal0974e402013-02-12 14:27:46 -08002032 tANI_U8 *ptr = command;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002033
2034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002035 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002036
Mahesh Kumar Kalikot Veetil2aad8d82013-02-07 12:31:28 -08002037 ret = sapSetPreferredChannel(ptr);
Jeff Johnson32d95a32012-09-10 13:15:23 -07002038 }
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002039 else if(strncmp(command, "SETSUSPENDMODE", 14) == 0)
2040 {
2041 int suspend = 0;
2042 tANI_U8 *ptr = (tANI_U8*)command + 15;
2043
2044 suspend = *ptr - '0';
2045 hdd_set_wlan_suspend_mode(suspend);
2046 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002047#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2048 else if (strncmp(command, "SETROAMTRIGGER", 14) == 0)
2049 {
2050 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002051 tANI_S8 rssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002052 tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT;
2053 eHalStatus status = eHAL_STATUS_SUCCESS;
2054
2055 /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */
2056 value = value + 15;
2057
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002058 /* Convert the value from ascii to integer */
2059 ret = kstrtos8(value, 10, &rssi);
2060 if (ret < 0)
2061 {
2062 /* If the input value is greater than max value of datatype, then also
2063 kstrtou8 fails */
2064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2065 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdafa7157d2013-10-31 10:14:22 -07002066 __func__,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002067 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2068 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2069 ret = -EINVAL;
2070 goto exit;
2071 }
2072
Srinivas Girigowdade697412013-02-14 16:31:48 -08002073 lookUpThreshold = abs(rssi);
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002074
Srinivas Girigowdade697412013-02-14 16:31:48 -08002075 if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) ||
2076 (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX))
2077 {
2078 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2079 "Neighbor lookup threshold value %d is out of range"
2080 " (Min: %d Max: %d)", lookUpThreshold,
2081 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2082 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2083 ret = -EINVAL;
2084 goto exit;
2085 }
2086
2087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2088 "%s: Received Command to Set Roam trigger"
2089 " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold);
2090
2091 pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold;
2092 status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold);
2093 if (eHAL_STATUS_SUCCESS != status)
2094 {
2095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2096 "%s: Failed to set roam trigger, try again", __func__);
2097 ret = -EPERM;
2098 goto exit;
2099 }
2100
2101 /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */
2102 sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5);
2103 }
2104 else if (strncmp(command, "GETROAMTRIGGER", 14) == 0)
2105 {
2106 tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal));
2107 int rssi = (-1) * lookUpThreshold;
2108 char extra[32];
2109 tANI_U8 len = 0;
2110
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002111 len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002112 if (copy_to_user(priv_data.buf, &extra, len + 1))
2113 {
2114 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2115 "%s: failed to copy data to user buffer", __func__);
2116 ret = -EFAULT;
2117 goto exit;
2118 }
2119 }
2120 else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0)
2121 {
2122 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002123 tANI_U8 roamScanPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002124 tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002125
Srinivas Girigowdade697412013-02-14 16:31:48 -08002126 /* input refresh period is in terms of seconds */
2127 /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */
2128 value = value + 18;
2129 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002130 ret = kstrtou8(value, 10, &roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002131 if (ret < 0)
2132 {
2133 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002134 kstrtou8 fails */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002135 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002136 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdade697412013-02-14 16:31:48 -08002137 __func__,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002138 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2139 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002140 ret = -EINVAL;
2141 goto exit;
2142 }
2143
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002144 if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) ||
2145 (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002146 {
2147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002148 "Roam scan period value %d is out of range"
2149 " (Min: %d Max: %d)", roamScanPeriod,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002150 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2151 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002152 ret = -EINVAL;
2153 goto exit;
2154 }
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002155 neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002156
2157 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2158 "%s: Received Command to Set roam scan period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002159 " (Empty Scan refresh period) = %d", __func__, roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002160
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002161 pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod;
2162 sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002163 }
2164 else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0)
2165 {
2166 tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2167 char extra[32];
2168 tANI_U8 len = 0;
2169
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002170 len = scnprintf(extra, sizeof(extra), "%s %d",
2171 "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002172 /* Returned value is in units of seconds */
2173 if (copy_to_user(priv_data.buf, &extra, len + 1))
2174 {
2175 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2176 "%s: failed to copy data to user buffer", __func__);
2177 ret = -EFAULT;
2178 goto exit;
2179 }
2180 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002181 else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0)
2182 {
2183 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002184 tANI_U8 roamScanRefreshPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002185 tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002186
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002187 /* input refresh period is in terms of seconds */
2188 /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */
2189 value = value + 25;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002190
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002191 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002192 ret = kstrtou8(value, 10, &roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002193 if (ret < 0)
2194 {
2195 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002196 kstrtou8 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002197 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002198 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002199 __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002200 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2201 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2202 ret = -EINVAL;
2203 goto exit;
2204 }
2205
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002206 if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) ||
2207 (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)))
2208 {
2209 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2210 "Neighbor scan results refresh period value %d is out of range"
2211 " (Min: %d Max: %d)", roamScanRefreshPeriod,
2212 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2213 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2214 ret = -EINVAL;
2215 goto exit;
2216 }
2217 neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000;
2218
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002219 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2220 "%s: Received Command to Set roam scan refresh period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002221 " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002222
2223 pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod;
2224 sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod);
2225 }
2226 else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0)
2227 {
2228 tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2229 char extra[32];
2230 tANI_U8 len = 0;
2231
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002232 len = scnprintf(extra, sizeof(extra), "%s %d",
2233 "GETROAMSCANREFRESHPERIOD", (value/1000));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002234 /* Returned value is in units of seconds */
2235 if (copy_to_user(priv_data.buf, &extra, len + 1))
2236 {
2237 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2238 "%s: failed to copy data to user buffer", __func__);
2239 ret = -EFAULT;
2240 goto exit;
2241 }
2242 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002243#ifdef FEATURE_WLAN_LFR
2244 /* SETROAMMODE */
2245 else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0)
2246 {
2247 tANI_U8 *value = command;
2248 tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
2249
2250 /* Move pointer to ahead of SETROAMMODE<delimiter> */
2251 value = value + SIZE_OF_SETROAMMODE + 1;
2252
2253 /* Convert the value from ascii to integer */
2254 ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode);
2255 if (ret < 0)
2256 {
2257 /* If the input value is greater than max value of datatype, then also
2258 kstrtou8 fails */
2259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2260 "%s: kstrtou8 failed range [%d - %d]", __func__,
2261 CFG_LFR_FEATURE_ENABLED_MIN,
2262 CFG_LFR_FEATURE_ENABLED_MAX);
2263 ret = -EINVAL;
2264 goto exit;
2265 }
2266 if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
2267 (roamMode > CFG_LFR_FEATURE_ENABLED_MAX))
2268 {
2269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2270 "Roam Mode value %d is out of range"
2271 " (Min: %d Max: %d)", roamMode,
2272 CFG_LFR_FEATURE_ENABLED_MIN,
2273 CFG_LFR_FEATURE_ENABLED_MAX);
2274 ret = -EINVAL;
2275 goto exit;
2276 }
2277
2278 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2279 "%s: Received Command to Set Roam Mode = %d", __func__, roamMode);
2280 /*
2281 * Note that
2282 * SETROAMMODE 0 is to enable LFR while
2283 * SETROAMMODE 1 is to disable LFR, but
2284 * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable.
2285 * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled.
2286 */
2287 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2288 roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */
2289 else
2290 roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */
2291
2292 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode;
2293 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode);
2294 }
2295 /* GETROAMMODE */
2296 else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0)
2297 {
2298 tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2299 char extra[32];
2300 tANI_U8 len = 0;
2301
2302 /*
2303 * roamMode value shall be inverted because the sementics is different.
2304 */
2305 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2306 roamMode = CFG_LFR_FEATURE_ENABLED_MAX;
2307 else
2308 roamMode = CFG_LFR_FEATURE_ENABLED_MIN;
2309
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002310 len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002311 if (copy_to_user(priv_data.buf, &extra, len + 1))
2312 {
2313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2314 "%s: failed to copy data to user buffer", __func__);
2315 ret = -EFAULT;
2316 goto exit;
2317 }
2318 }
2319#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08002320#endif
2321#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
2322 else if (strncmp(command, "SETROAMDELTA", 12) == 0)
2323 {
2324 tANI_U8 *value = command;
2325 tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT;
2326
2327 /* Move pointer to ahead of SETROAMDELTA<delimiter> */
2328 value = value + 13;
2329 /* Convert the value from ascii to integer */
2330 ret = kstrtou8(value, 10, &roamRssiDiff);
2331 if (ret < 0)
2332 {
2333 /* If the input value is greater than max value of datatype, then also
2334 kstrtou8 fails */
2335 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2336 "%s: kstrtou8 failed range [%d - %d]", __func__,
2337 CFG_ROAM_RSSI_DIFF_MIN,
2338 CFG_ROAM_RSSI_DIFF_MAX);
2339 ret = -EINVAL;
2340 goto exit;
2341 }
2342
2343 if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) ||
2344 (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX))
2345 {
2346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2347 "Roam rssi diff value %d is out of range"
2348 " (Min: %d Max: %d)", roamRssiDiff,
2349 CFG_ROAM_RSSI_DIFF_MIN,
2350 CFG_ROAM_RSSI_DIFF_MAX);
2351 ret = -EINVAL;
2352 goto exit;
2353 }
2354
2355 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2356 "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff);
2357
2358 pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff;
2359 sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff);
2360 }
2361 else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0)
2362 {
2363 tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal));
2364 char extra[32];
2365 tANI_U8 len = 0;
2366
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002367 len = scnprintf(extra, sizeof(extra), "%s %d",
2368 command, roamRssiDiff);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002369 if (copy_to_user(priv_data.buf, &extra, len + 1))
2370 {
2371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2372 "%s: failed to copy data to user buffer", __func__);
2373 ret = -EFAULT;
2374 goto exit;
2375 }
2376 }
2377#endif
2378#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
2379 else if (strncmp(command, "GETBAND", 7) == 0)
2380 {
2381 int band = -1;
2382 char extra[32];
2383 tANI_U8 len = 0;
2384 hdd_getBand_helper(pHddCtx, &band);
2385
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002386 len = scnprintf(extra, sizeof(extra), "%s %d", command, band);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002387 if (copy_to_user(priv_data.buf, &extra, len + 1))
2388 {
2389 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2390 "%s: failed to copy data to user buffer", __func__);
2391 ret = -EFAULT;
2392 goto exit;
2393 }
2394 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002395 else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0)
2396 {
2397 tANI_U8 *value = command;
2398 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2399 tANI_U8 numChannels = 0;
2400 eHalStatus status = eHAL_STATUS_SUCCESS;
2401
2402 status = hdd_parse_channellist(value, ChannelList, &numChannels);
2403 if (eHAL_STATUS_SUCCESS != status)
2404 {
2405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2406 "%s: Failed to parse channel list information", __func__);
2407 ret = -EINVAL;
2408 goto exit;
2409 }
2410
2411 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2412 {
2413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2414 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
2415 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
2416 ret = -EINVAL;
2417 goto exit;
2418 }
2419 status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList,
2420 numChannels);
2421 if (eHAL_STATUS_SUCCESS != status)
2422 {
2423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2424 "%s: Failed to update channel list information", __func__);
2425 ret = -EINVAL;
2426 goto exit;
2427 }
2428 }
2429 else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0)
2430 {
2431 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2432 tANI_U8 numChannels = 0;
Jeff Johnson51b67782013-04-05 12:35:41 -07002433 tANI_U8 j = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002434 char extra[128] = {0};
Jeff Johnson51b67782013-04-05 12:35:41 -07002435 int len;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002436
2437 if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal),
2438 ChannelList, &numChannels ))
2439 {
2440 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2441 "%s: failed to get roam scan channel list", __func__);
2442 ret = -EFAULT;
2443 goto exit;
2444 }
2445 /* output channel list is of the format
2446 [Number of roam scan channels][Channel1][Channel2]... */
2447 /* copy the number of channels in the 0th index */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002448 len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002449 for (j = 0; (j < numChannels); j++)
2450 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002451 len += scnprintf(extra + len, sizeof(extra) - len, " %d",
2452 ChannelList[j]);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002453 }
2454
2455 if (copy_to_user(priv_data.buf, &extra, len + 1))
2456 {
2457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2458 "%s: failed to copy data to user buffer", __func__);
2459 ret = -EFAULT;
2460 goto exit;
2461 }
2462 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002463 else if (strncmp(command, "GETCCXMODE", 10) == 0)
2464 {
2465 tANI_BOOLEAN ccxMode = sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2466 char extra[32];
2467 tANI_U8 len = 0;
2468
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002469 /* Check if the features OKC/CCX/11R are supported simultaneously,
2470 then this operation is not permitted (return FAILURE) */
2471 if (ccxMode &&
2472 hdd_is_okc_mode_enabled(pHddCtx) &&
2473 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2474 {
2475 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2476 "%s: OKC/CCX/11R are supported simultaneously"
2477 " hence this operation is not permitted!", __func__);
2478 ret = -EPERM;
2479 goto exit;
2480 }
2481
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002482 len = scnprintf(extra, sizeof(extra), "%s %d",
2483 "GETCCXMODE", ccxMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002484 if (copy_to_user(priv_data.buf, &extra, len + 1))
2485 {
2486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2487 "%s: failed to copy data to user buffer", __func__);
2488 ret = -EFAULT;
2489 goto exit;
2490 }
2491 }
2492 else if (strncmp(command, "GETOKCMODE", 10) == 0)
2493 {
2494 tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx);
2495 char extra[32];
2496 tANI_U8 len = 0;
2497
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002498 /* Check if the features OKC/CCX/11R are supported simultaneously,
2499 then this operation is not permitted (return FAILURE) */
2500 if (okcMode &&
2501 sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
2502 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2503 {
2504 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2505 "%s: OKC/CCX/11R are supported simultaneously"
2506 " hence this operation is not permitted!", __func__);
2507 ret = -EPERM;
2508 goto exit;
2509 }
2510
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002511 len = scnprintf(extra, sizeof(extra), "%s %d",
2512 "GETOKCMODE", okcMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002513 if (copy_to_user(priv_data.buf, &extra, len + 1))
2514 {
2515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2516 "%s: failed to copy data to user buffer", __func__);
2517 ret = -EFAULT;
2518 goto exit;
2519 }
2520 }
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002521 else if (strncmp(command, "GETFASTROAM", 11) == 0)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002522 {
2523 tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2524 char extra[32];
2525 tANI_U8 len = 0;
2526
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002527 len = scnprintf(extra, sizeof(extra), "%s %d",
2528 "GETFASTROAM", lfrMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002529 if (copy_to_user(priv_data.buf, &extra, len + 1))
2530 {
2531 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2532 "%s: failed to copy data to user buffer", __func__);
2533 ret = -EFAULT;
2534 goto exit;
2535 }
2536 }
2537 else if (strncmp(command, "GETFASTTRANSITION", 17) == 0)
2538 {
2539 tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2540 char extra[32];
2541 tANI_U8 len = 0;
2542
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002543 len = scnprintf(extra, sizeof(extra), "%s %d",
2544 "GETFASTTRANSITION", ft);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002545 if (copy_to_user(priv_data.buf, &extra, len + 1))
2546 {
2547 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2548 "%s: failed to copy data to user buffer", __func__);
2549 ret = -EFAULT;
2550 goto exit;
2551 }
2552 }
2553 else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0)
2554 {
2555 tANI_U8 *value = command;
2556 tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT;
2557
2558 /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */
2559 value = value + 26;
2560 /* Convert the value from ascii to integer */
2561 ret = kstrtou8(value, 10, &minTime);
2562 if (ret < 0)
2563 {
2564 /* If the input value is greater than max value of datatype, then also
2565 kstrtou8 fails */
2566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2567 "%s: kstrtou8 failed range [%d - %d]", __func__,
2568 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2569 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2570 ret = -EINVAL;
2571 goto exit;
2572 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002573 if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) ||
2574 (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX))
2575 {
2576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2577 "scan min channel time value %d is out of range"
2578 " (Min: %d Max: %d)", minTime,
2579 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2580 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2581 ret = -EINVAL;
2582 goto exit;
2583 }
2584
2585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2586 "%s: Received Command to change channel min time = %d", __func__, minTime);
2587
2588 pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime;
2589 sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime);
2590 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002591 else if (strncmp(command, "SENDACTIONFRAME", 15) == 0)
2592 {
2593 tANI_U8 *value = command;
2594 tANI_U8 channel = 0;
2595 tANI_U8 dwellTime = 0;
2596 tANI_U8 bufLen = 0;
2597 tANI_U8 *buf = NULL;
2598 tSirMacAddr targetApBssid;
2599 eHalStatus status = eHAL_STATUS_SUCCESS;
2600 struct ieee80211_channel chan;
2601 tANI_U8 finalLen = 0;
2602 tANI_U8 *finalBuf = NULL;
2603 tANI_U8 temp = 0;
2604 u64 cookie;
2605 hdd_station_ctx_t *pHddStaCtx = NULL;
2606 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2607
2608 /* if not associated, no need to send action frame */
2609 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2610 {
2611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
2612 ret = -EINVAL;
2613 goto exit;
2614 }
2615
2616 status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel,
2617 &dwellTime, &buf, &bufLen);
2618 if (eHAL_STATUS_SUCCESS != status)
2619 {
2620 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2621 "%s: Failed to parse send action frame data", __func__);
2622 ret = -EINVAL;
2623 goto exit;
2624 }
2625
2626 /* if the target bssid is different from currently associated AP,
2627 then no need to send action frame */
2628 if (VOS_TRUE != vos_mem_compare(targetApBssid,
2629 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
2630 {
2631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__);
2632 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07002633 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002634 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002635 goto exit;
2636 }
2637
2638 /* if the channel number is different from operating channel then
2639 no need to send action frame */
2640 if (channel != pHddStaCtx->conn_info.operationChannel)
2641 {
2642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2643 "%s: channel(%d) is different from operating channel(%d)",
2644 __func__, channel, pHddStaCtx->conn_info.operationChannel);
2645 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07002646 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002647 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002648 goto exit;
2649 }
2650 chan.center_freq = sme_ChnToFreq(channel);
2651
2652 finalLen = bufLen + 24;
2653 finalBuf = vos_mem_malloc(finalLen);
2654 if (NULL == finalBuf)
2655 {
2656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__);
2657 ret = -ENOMEM;
Jeff Johnson11c33152013-04-16 17:52:40 -07002658 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002659 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002660 goto exit;
2661 }
2662 vos_mem_zero(finalBuf, finalLen);
2663
2664 /* Fill subtype */
2665 temp = SIR_MAC_MGMT_ACTION << 4;
2666 vos_mem_copy(finalBuf + 0, &temp, sizeof(temp));
2667
2668 /* Fill type */
2669 temp = SIR_MAC_MGMT_FRAME;
2670 vos_mem_copy(finalBuf + 2, &temp, sizeof(temp));
2671
2672 /* Fill destination address (bssid of the AP) */
2673 vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid));
2674
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07002675 /* Fill source address (STA mac address) */
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002676 vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes));
2677
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07002678 /* Fill BSSID (AP mac address) */
2679 vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid));
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002680
2681 /* Fill received buffer from 24th address */
2682 vos_mem_copy(finalBuf + 24, buf, bufLen);
2683
Jeff Johnson11c33152013-04-16 17:52:40 -07002684 /* done with the parsed buffer */
2685 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002686 buf = NULL;
Jeff Johnson11c33152013-04-16 17:52:40 -07002687
Yue Maf49ba872013-08-19 12:04:25 -07002688 wlan_hdd_action( NULL,
2689#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
2690 &(pAdapter->wdev),
2691#else
2692 dev,
2693#endif
2694 &chan, 0,
2695#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2696 NL80211_CHAN_HT20, 1,
2697#endif
2698 dwellTime, finalBuf, finalLen, 1,
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002699 1, &cookie );
2700 vos_mem_free(finalBuf);
2701 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002702 else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0)
2703 {
2704 tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal));
2705 char extra[32];
2706 tANI_U8 len = 0;
2707
2708 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002709 len = scnprintf(extra, sizeof(extra), "%s %d",
2710 "GETROAMSCANCHANNELMINTIME", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002711 if (copy_to_user(priv_data.buf, &extra, len + 1))
2712 {
2713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2714 "%s: failed to copy data to user buffer", __func__);
2715 ret = -EFAULT;
2716 goto exit;
2717 }
2718 }
2719 else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0)
2720 {
2721 tANI_U8 *value = command;
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002722 tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002723
2724 /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */
2725 value = value + 19;
2726 /* Convert the value from ascii to integer */
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002727 ret = kstrtou16(value, 10, &maxTime);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002728 if (ret < 0)
2729 {
2730 /* If the input value is greater than max value of datatype, then also
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002731 kstrtou16 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002733 "%s: kstrtou16 failed range [%d - %d]", __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002734 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
2735 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
2736 ret = -EINVAL;
2737 goto exit;
2738 }
2739
2740 if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) ||
2741 (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX))
2742 {
2743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2744 "lfr mode value %d is out of range"
2745 " (Min: %d Max: %d)", maxTime,
2746 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
2747 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
2748 ret = -EINVAL;
2749 goto exit;
2750 }
2751
2752 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2753 "%s: Received Command to change channel max time = %d", __func__, maxTime);
2754
2755 pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime;
2756 sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime);
2757 }
2758 else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0)
2759 {
2760 tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal));
2761 char extra[32];
2762 tANI_U8 len = 0;
2763
2764 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002765 len = scnprintf(extra, sizeof(extra), "%s %d",
2766 "GETSCANCHANNELTIME", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002767 if (copy_to_user(priv_data.buf, &extra, len + 1))
2768 {
2769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2770 "%s: failed to copy data to user buffer", __func__);
2771 ret = -EFAULT;
2772 goto exit;
2773 }
2774 }
2775 else if (strncmp(command, "SETSCANHOMETIME", 15) == 0)
2776 {
2777 tANI_U8 *value = command;
2778 tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT;
2779
2780 /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */
2781 value = value + 16;
2782 /* Convert the value from ascii to integer */
2783 ret = kstrtou16(value, 10, &val);
2784 if (ret < 0)
2785 {
2786 /* If the input value is greater than max value of datatype, then also
2787 kstrtou16 fails */
2788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2789 "%s: kstrtou16 failed range [%d - %d]", __func__,
2790 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
2791 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
2792 ret = -EINVAL;
2793 goto exit;
2794 }
2795
2796 if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) ||
2797 (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX))
2798 {
2799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2800 "scan home time value %d is out of range"
2801 " (Min: %d Max: %d)", val,
2802 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
2803 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
2804 ret = -EINVAL;
2805 goto exit;
2806 }
2807
2808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2809 "%s: Received Command to change scan home time = %d", __func__, val);
2810
2811 pHddCtx->cfg_ini->nNeighborScanPeriod = val;
2812 sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val);
2813 }
2814 else if (strncmp(command, "GETSCANHOMETIME", 15) == 0)
2815 {
2816 tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal));
2817 char extra[32];
2818 tANI_U8 len = 0;
2819
2820 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002821 len = scnprintf(extra, sizeof(extra), "%s %d",
2822 "GETSCANHOMETIME", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002823 if (copy_to_user(priv_data.buf, &extra, len + 1))
2824 {
2825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2826 "%s: failed to copy data to user buffer", __func__);
2827 ret = -EFAULT;
2828 goto exit;
2829 }
2830 }
2831 else if (strncmp(command, "SETROAMINTRABAND", 16) == 0)
2832 {
2833 tANI_U8 *value = command;
2834 tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT;
2835
2836 /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */
2837 value = value + 17;
2838 /* Convert the value from ascii to integer */
2839 ret = kstrtou8(value, 10, &val);
2840 if (ret < 0)
2841 {
2842 /* If the input value is greater than max value of datatype, then also
2843 kstrtou8 fails */
2844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2845 "%s: kstrtou8 failed range [%d - %d]", __func__,
2846 CFG_ROAM_INTRA_BAND_MIN,
2847 CFG_ROAM_INTRA_BAND_MAX);
2848 ret = -EINVAL;
2849 goto exit;
2850 }
2851
2852 if ((val < CFG_ROAM_INTRA_BAND_MIN) ||
2853 (val > CFG_ROAM_INTRA_BAND_MAX))
2854 {
2855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2856 "intra band mode value %d is out of range"
2857 " (Min: %d Max: %d)", val,
2858 CFG_ROAM_INTRA_BAND_MIN,
2859 CFG_ROAM_INTRA_BAND_MAX);
2860 ret = -EINVAL;
2861 goto exit;
2862 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2864 "%s: Received Command to change intra band = %d", __func__, val);
2865
2866 pHddCtx->cfg_ini->nRoamIntraBand = val;
2867 sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val);
2868 }
2869 else if (strncmp(command, "GETROAMINTRABAND", 16) == 0)
2870 {
2871 tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal));
2872 char extra[32];
2873 tANI_U8 len = 0;
2874
2875 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002876 len = scnprintf(extra, sizeof(extra), "%s %d",
2877 "GETROAMINTRABAND", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002878 if (copy_to_user(priv_data.buf, &extra, len + 1))
2879 {
2880 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2881 "%s: failed to copy data to user buffer", __func__);
2882 ret = -EFAULT;
2883 goto exit;
2884 }
2885 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002886 else if (strncmp(command, "SETSCANNPROBES", 14) == 0)
2887 {
2888 tANI_U8 *value = command;
2889 tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT;
2890
2891 /* Move pointer to ahead of SETSCANNPROBES<delimiter> */
2892 value = value + 15;
2893 /* Convert the value from ascii to integer */
2894 ret = kstrtou8(value, 10, &nProbes);
2895 if (ret < 0)
2896 {
2897 /* If the input value is greater than max value of datatype, then also
2898 kstrtou8 fails */
2899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2900 "%s: kstrtou8 failed range [%d - %d]", __func__,
2901 CFG_ROAM_SCAN_N_PROBES_MIN,
2902 CFG_ROAM_SCAN_N_PROBES_MAX);
2903 ret = -EINVAL;
2904 goto exit;
2905 }
2906
2907 if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) ||
2908 (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX))
2909 {
2910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2911 "NProbes value %d is out of range"
2912 " (Min: %d Max: %d)", nProbes,
2913 CFG_ROAM_SCAN_N_PROBES_MIN,
2914 CFG_ROAM_SCAN_N_PROBES_MAX);
2915 ret = -EINVAL;
2916 goto exit;
2917 }
2918
2919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2920 "%s: Received Command to Set nProbes = %d", __func__, nProbes);
2921
2922 pHddCtx->cfg_ini->nProbes = nProbes;
2923 sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes);
2924 }
2925 else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0)
2926 {
2927 tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal));
2928 char extra[32];
2929 tANI_U8 len = 0;
2930
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002931 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002932 if (copy_to_user(priv_data.buf, &extra, len + 1))
2933 {
2934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2935 "%s: failed to copy data to user buffer", __func__);
2936 ret = -EFAULT;
2937 goto exit;
2938 }
2939 }
2940 else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0)
2941 {
2942 tANI_U8 *value = command;
2943 tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT;
2944
2945 /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */
2946 /* input value is in units of msec */
2947 value = value + 20;
2948 /* Convert the value from ascii to integer */
2949 ret = kstrtou16(value, 10, &homeAwayTime);
2950 if (ret < 0)
2951 {
2952 /* If the input value is greater than max value of datatype, then also
2953 kstrtou8 fails */
2954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2955 "%s: kstrtou8 failed range [%d - %d]", __func__,
2956 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
2957 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
2958 ret = -EINVAL;
2959 goto exit;
2960 }
2961
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002962 if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) ||
2963 (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX))
2964 {
2965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2966 "homeAwayTime value %d is out of range"
2967 " (Min: %d Max: %d)", homeAwayTime,
2968 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
2969 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
2970 ret = -EINVAL;
2971 goto exit;
2972 }
2973
2974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2975 "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002976 if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime)
2977 {
2978 pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime;
2979 sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE);
2980 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002981 }
2982 else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0)
2983 {
2984 tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal));
2985 char extra[32];
2986 tANI_U8 len = 0;
2987
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002988 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002989 if (copy_to_user(priv_data.buf, &extra, len + 1))
2990 {
2991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2992 "%s: failed to copy data to user buffer", __func__);
2993 ret = -EFAULT;
2994 goto exit;
2995 }
2996 }
2997 else if (strncmp(command, "REASSOC", 7) == 0)
2998 {
2999 tANI_U8 *value = command;
3000 tANI_U8 channel = 0;
3001 tSirMacAddr targetApBssid;
3002 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003003#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3004 tCsrHandoffRequest handoffInfo;
3005#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003006 hdd_station_ctx_t *pHddStaCtx = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003007 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3008
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003009 /* if not associated, no need to proceed with reassoc */
3010 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3011 {
3012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3013 ret = -EINVAL;
3014 goto exit;
3015 }
3016
3017 status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel);
3018 if (eHAL_STATUS_SUCCESS != status)
3019 {
3020 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3021 "%s: Failed to parse reassoc command data", __func__);
3022 ret = -EINVAL;
3023 goto exit;
3024 }
3025
3026 /* if the target bssid is same as currently associated AP,
3027 then no need to proceed with reassoc */
3028 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3029 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3030 {
3031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__);
3032 ret = -EINVAL;
3033 goto exit;
3034 }
3035
3036 /* Check channel number is a valid channel number */
3037 if(VOS_STATUS_SUCCESS !=
3038 wlan_hdd_validate_operation_channel(pAdapter, channel))
3039 {
3040 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003041 "%s: Invalid Channel [%d]", __func__, channel);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003042 return -EINVAL;
3043 }
3044
3045 /* Proceed with reassoc */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003046#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3047 handoffInfo.channel = channel;
3048 vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr));
3049 sme_HandoffRequest(pHddCtx->hHal, &handoffInfo);
3050#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003051 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003052 else if (strncmp(command, "SETWESMODE", 10) == 0)
3053 {
3054 tANI_U8 *value = command;
3055 tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT;
3056
3057 /* Move pointer to ahead of SETWESMODE<delimiter> */
3058 value = value + 11;
3059 /* Convert the value from ascii to integer */
3060 ret = kstrtou8(value, 10, &wesMode);
3061 if (ret < 0)
3062 {
3063 /* If the input value is greater than max value of datatype, then also
3064 kstrtou8 fails */
3065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: kstrtou8 failed range [%d - %d]", __func__,
3067 CFG_ENABLE_WES_MODE_NAME_MIN,
3068 CFG_ENABLE_WES_MODE_NAME_MAX);
3069 ret = -EINVAL;
3070 goto exit;
3071 }
3072
3073 if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) ||
3074 (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX))
3075 {
3076 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3077 "WES Mode value %d is out of range"
3078 " (Min: %d Max: %d)", wesMode,
3079 CFG_ENABLE_WES_MODE_NAME_MIN,
3080 CFG_ENABLE_WES_MODE_NAME_MAX);
3081 ret = -EINVAL;
3082 goto exit;
3083 }
3084 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3085 "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode);
3086
3087 pHddCtx->cfg_ini->isWESModeEnabled = wesMode;
3088 sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode);
3089 }
3090 else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0)
3091 {
3092 tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal));
3093 char extra[32];
3094 tANI_U8 len = 0;
3095
Arif Hussain826d9412013-11-12 16:44:54 -08003096 len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode);
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003097 if (copy_to_user(priv_data.buf, &extra, len + 1))
3098 {
3099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3100 "%s: failed to copy data to user buffer", __func__);
3101 ret = -EFAULT;
3102 goto exit;
3103 }
3104 }
3105#endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_CCX || FEATURE_WLAN_LFR */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003106#ifdef FEATURE_WLAN_LFR
3107 else if (strncmp(command, "SETFASTROAM", 11) == 0)
3108 {
3109 tANI_U8 *value = command;
3110 tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
3111
3112 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3113 value = value + 12;
3114 /* Convert the value from ascii to integer */
3115 ret = kstrtou8(value, 10, &lfrMode);
3116 if (ret < 0)
3117 {
3118 /* If the input value is greater than max value of datatype, then also
3119 kstrtou8 fails */
3120 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3121 "%s: kstrtou8 failed range [%d - %d]", __func__,
3122 CFG_LFR_FEATURE_ENABLED_MIN,
3123 CFG_LFR_FEATURE_ENABLED_MAX);
3124 ret = -EINVAL;
3125 goto exit;
3126 }
3127
3128 if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
3129 (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX))
3130 {
3131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3132 "lfr mode value %d is out of range"
3133 " (Min: %d Max: %d)", lfrMode,
3134 CFG_LFR_FEATURE_ENABLED_MIN,
3135 CFG_LFR_FEATURE_ENABLED_MAX);
3136 ret = -EINVAL;
3137 goto exit;
3138 }
3139
3140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3141 "%s: Received Command to change lfr mode = %d", __func__, lfrMode);
3142
3143 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode;
3144 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode);
3145 }
3146#endif
3147#ifdef WLAN_FEATURE_VOWIFI_11R
3148 else if (strncmp(command, "SETFASTTRANSITION", 17) == 0)
3149 {
3150 tANI_U8 *value = command;
3151 tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT;
3152
3153 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3154 value = value + 18;
3155 /* Convert the value from ascii to integer */
3156 ret = kstrtou8(value, 10, &ft);
3157 if (ret < 0)
3158 {
3159 /* If the input value is greater than max value of datatype, then also
3160 kstrtou8 fails */
3161 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3162 "%s: kstrtou8 failed range [%d - %d]", __func__,
3163 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3164 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3165 ret = -EINVAL;
3166 goto exit;
3167 }
3168
3169 if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) ||
3170 (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX))
3171 {
3172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3173 "ft mode value %d is out of range"
3174 " (Min: %d Max: %d)", ft,
3175 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3176 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3177 ret = -EINVAL;
3178 goto exit;
3179 }
3180
3181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3182 "%s: Received Command to change ft mode = %d", __func__, ft);
3183
3184 pHddCtx->cfg_ini->isFastTransitionEnabled = ft;
3185 sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft);
3186 }
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303187
3188 else if (strncmp(command, "FASTREASSOC", 11) == 0)
3189 {
3190 tANI_U8 *value = command;
3191 tSirMacAddr targetApBssid;
3192 tANI_U8 trigger = 0;
3193 eHalStatus status = eHAL_STATUS_SUCCESS;
3194 hdd_station_ctx_t *pHddStaCtx = NULL;
3195 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3196
3197 /* if not associated, no need to proceed with reassoc */
3198 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3199 {
3200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3201 ret = -EINVAL;
3202 goto exit;
3203 }
3204
3205 status = hdd_parse_reassoc_command_data(value, targetApBssid, &trigger);
3206 if (eHAL_STATUS_SUCCESS != status)
3207 {
3208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3209 "%s: Failed to parse reassoc command data", __func__);
3210 ret = -EINVAL;
3211 goto exit;
3212 }
3213
3214 /* if the target bssid is same as currently associated AP,
3215 then no need to proceed with reassoc */
3216 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3217 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3218 {
3219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3220 "%s:11r Reassoc BSSID is same as currently associated AP bssid",
3221 __func__);
3222 ret = -EINVAL;
3223 goto exit;
3224 }
3225
3226 /* Proceed with scan/roam */
3227 smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter),
3228 &targetApBssid[0],
3229 (tSmeFastRoamTrigger)(trigger));
3230 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003231#endif
3232#ifdef FEATURE_WLAN_CCX
3233 else if (strncmp(command, "SETCCXMODE", 10) == 0)
3234 {
3235 tANI_U8 *value = command;
3236 tANI_U8 ccxMode = CFG_CCX_FEATURE_ENABLED_DEFAULT;
3237
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003238 /* Check if the features OKC/CCX/11R are supported simultaneously,
3239 then this operation is not permitted (return FAILURE) */
3240 if (sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
3241 hdd_is_okc_mode_enabled(pHddCtx) &&
3242 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3243 {
3244 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3245 "%s: OKC/CCX/11R are supported simultaneously"
3246 " hence this operation is not permitted!", __func__);
3247 ret = -EPERM;
3248 goto exit;
3249 }
3250
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003251 /* Move pointer to ahead of SETCCXMODE<delimiter> */
3252 value = value + 11;
3253 /* Convert the value from ascii to integer */
3254 ret = kstrtou8(value, 10, &ccxMode);
3255 if (ret < 0)
3256 {
3257 /* If the input value is greater than max value of datatype, then also
3258 kstrtou8 fails */
3259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3260 "%s: kstrtou8 failed range [%d - %d]", __func__,
3261 CFG_CCX_FEATURE_ENABLED_MIN,
3262 CFG_CCX_FEATURE_ENABLED_MAX);
3263 ret = -EINVAL;
3264 goto exit;
3265 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003266 if ((ccxMode < CFG_CCX_FEATURE_ENABLED_MIN) ||
3267 (ccxMode > CFG_CCX_FEATURE_ENABLED_MAX))
3268 {
3269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3270 "Ccx mode value %d is out of range"
3271 " (Min: %d Max: %d)", ccxMode,
3272 CFG_CCX_FEATURE_ENABLED_MIN,
3273 CFG_CCX_FEATURE_ENABLED_MAX);
3274 ret = -EINVAL;
3275 goto exit;
3276 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003277 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3278 "%s: Received Command to change ccx mode = %d", __func__, ccxMode);
3279
3280 pHddCtx->cfg_ini->isCcxIniFeatureEnabled = ccxMode;
3281 sme_UpdateIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal), ccxMode);
3282 }
3283#endif
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003284 else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0)
3285 {
3286 tANI_U8 *value = command;
3287 tANI_BOOLEAN roamScanControl = 0;
3288
3289 /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */
3290 value = value + 19;
3291 /* Convert the value from ascii to integer */
3292 ret = kstrtou8(value, 10, &roamScanControl);
3293 if (ret < 0)
3294 {
3295 /* If the input value is greater than max value of datatype, then also
3296 kstrtou8 fails */
3297 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3298 "%s: kstrtou8 failed ", __func__);
3299 ret = -EINVAL;
3300 goto exit;
3301 }
3302
3303 if (0 != roamScanControl)
3304 {
3305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3306 "roam scan control invalid value = %d",
3307 roamScanControl);
3308 ret = -EINVAL;
3309 goto exit;
3310 }
3311 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3312 "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl);
3313
3314 sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl);
3315 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003316#ifdef FEATURE_WLAN_OKC
3317 else if (strncmp(command, "SETOKCMODE", 10) == 0)
3318 {
3319 tANI_U8 *value = command;
3320 tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT;
3321
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003322 /* Check if the features OKC/CCX/11R are supported simultaneously,
3323 then this operation is not permitted (return FAILURE) */
3324 if (sme_getIsCcxFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
3325 hdd_is_okc_mode_enabled(pHddCtx) &&
3326 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3327 {
3328 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3329 "%s: OKC/CCX/11R are supported simultaneously"
3330 " hence this operation is not permitted!", __func__);
3331 ret = -EPERM;
3332 goto exit;
3333 }
3334
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003335 /* Move pointer to ahead of SETOKCMODE<delimiter> */
3336 value = value + 11;
3337 /* Convert the value from ascii to integer */
3338 ret = kstrtou8(value, 10, &okcMode);
3339 if (ret < 0)
3340 {
3341 /* If the input value is greater than max value of datatype, then also
3342 kstrtou8 fails */
3343 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3344 "%s: kstrtou8 failed range [%d - %d]", __func__,
3345 CFG_OKC_FEATURE_ENABLED_MIN,
3346 CFG_OKC_FEATURE_ENABLED_MAX);
3347 ret = -EINVAL;
3348 goto exit;
3349 }
3350
3351 if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) ||
3352 (okcMode > CFG_OKC_FEATURE_ENABLED_MAX))
3353 {
3354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3355 "Okc mode value %d is out of range"
3356 " (Min: %d Max: %d)", okcMode,
3357 CFG_OKC_FEATURE_ENABLED_MIN,
3358 CFG_OKC_FEATURE_ENABLED_MAX);
3359 ret = -EINVAL;
3360 goto exit;
3361 }
3362
3363 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3364 "%s: Received Command to change okc mode = %d", __func__, okcMode);
3365
3366 pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode;
3367 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003368#endif /* FEATURE_WLAN_OKC */
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003369 else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0)
3370 {
3371 tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal));
3372 char extra[32];
3373 tANI_U8 len = 0;
3374
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003375 len = scnprintf(extra, sizeof(extra), "%s %d",
3376 command, roamScanControl);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003377 if (copy_to_user(priv_data.buf, &extra, len + 1))
3378 {
3379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3380 "%s: failed to copy data to user buffer", __func__);
3381 ret = -EFAULT;
3382 goto exit;
3383 }
3384 }
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05303385#ifdef WLAN_FEATURE_PACKET_FILTERING
3386 else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0)
3387 {
3388 tANI_U8 filterType = 0;
3389 tANI_U8 *value = command;
3390
3391 /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */
3392 value = value + 22;
3393
3394 /* Convert the value from ascii to integer */
3395 ret = kstrtou8(value, 10, &filterType);
3396 if (ret < 0)
3397 {
3398 /* If the input value is greater than max value of datatype,
3399 * then also kstrtou8 fails
3400 */
3401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3402 "%s: kstrtou8 failed range ", __func__);
3403 ret = -EINVAL;
3404 goto exit;
3405 }
3406
3407 if (filterType != 0 && filterType != 1)
3408 {
3409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3410 "%s: Accepted Values are 0 and 1 ", __func__);
3411 ret = -EINVAL;
3412 goto exit;
3413 }
3414 wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType,
3415 pAdapter->sessionId);
3416 }
3417#endif
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303418 else if (strncmp(command, "BTCOEXMODE", 10) == 0 )
3419 {
3420 char *dhcpPhase;
c_hpothu9b781ba2013-12-30 20:57:45 +05303421 dhcpPhase = command + 11;
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303422 if ('1' == *dhcpPhase)
3423 {
c_hpothu9b781ba2013-12-30 20:57:45 +05303424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu0b0cab72014-02-13 21:52:40 +05303425 FL("send DHCP START indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303426
3427 pHddCtx->btCoexModeSet = TRUE;
3428
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303429 sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode,
c_hpothu0b0cab72014-02-13 21:52:40 +05303430 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303431 }
3432 else if ('2' == *dhcpPhase)
3433 {
c_hpothu9b781ba2013-12-30 20:57:45 +05303434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu0b0cab72014-02-13 21:52:40 +05303435 FL("send DHCP STOP indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303436
3437 pHddCtx->btCoexModeSet = FALSE;
3438
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303439 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
c_hpothu0b0cab72014-02-13 21:52:40 +05303440 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303441 }
3442 }
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003443 else if (strncmp(command, "SCAN-ACTIVE", 11) == 0)
3444 {
3445 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
3446 }
3447 else if (strncmp(command, "SCAN-PASSIVE", 12) == 0)
3448 {
3449 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
3450 }
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303451 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
3452 {
3453 hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3454 char extra[32];
3455 tANI_U8 len = 0;
3456
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003457 len = scnprintf(extra, sizeof(extra), "GETDWELLTIME %u\n",
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303458 (int)pCfg->nActiveMaxChnTime);
3459 if (copy_to_user(priv_data.buf, &extra, len + 1))
3460 {
3461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3462 "%s: failed to copy data to user buffer", __func__);
3463 ret = -EFAULT;
3464 goto exit;
3465 }
3466 ret = len;
3467 }
3468 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
3469 {
3470 tANI_U8 *value = command;
3471 hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3472 int val = 0, temp;
3473
3474 value = value + 13;
3475 temp = kstrtou32(value, 10, &val);
3476 if ( temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
3477 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
3478 {
3479 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3480 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
3481 ret = -EFAULT;
3482 goto exit;
3483 }
3484 pCfg->nActiveMaxChnTime = val;
3485 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003486 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
3487 {
3488 tANI_U8 filterType = 0;
3489 tANI_U8 *value;
3490 value = command + 9;
3491
3492 /* Convert the value from ascii to integer */
3493 ret = kstrtou8(value, 10, &filterType);
3494 if (ret < 0)
3495 {
3496 /* If the input value is greater than max value of datatype,
3497 * then also kstrtou8 fails
3498 */
3499 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3500 "%s: kstrtou8 failed range ", __func__);
3501 ret = -EINVAL;
3502 goto exit;
3503 }
3504 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
3505 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
3506 {
3507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3508 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
3509 " 2-Sink ", __func__);
3510 ret = -EINVAL;
3511 goto exit;
3512 }
3513 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
3514 pHddCtx->drvr_miracast = filterType;
3515 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
3516 }
Leo Chang614d2072013-08-22 14:59:44 -07003517 else if (strncmp(command, "SETMCRATE", 9) == 0)
3518 {
Leo Chang614d2072013-08-22 14:59:44 -07003519 tANI_U8 *value = command;
3520 int targetRate;
Leo Chang1f98cbd2013-10-17 15:03:52 -07003521 tSirRateUpdateInd *rateUpdate;
3522 eHalStatus status;
Leo Chang614d2072013-08-22 14:59:44 -07003523
3524 /* Only valid for SAP mode */
3525 if (WLAN_HDD_SOFTAP != pAdapter->device_mode)
3526 {
3527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3528 "%s: SAP mode is not running", __func__);
3529 ret = -EFAULT;
3530 goto exit;
3531 }
3532
3533 /* Move pointer to ahead of SETMCRATE<delimiter> */
3534 /* input value is in units of hundred kbps */
3535 value = value + 10;
3536 /* Convert the value from ascii to integer, decimal base */
3537 ret = kstrtouint(value, 10, &targetRate);
3538
Leo Chang1f98cbd2013-10-17 15:03:52 -07003539 rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd));
3540 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07003541 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07003542 hddLog(VOS_TRACE_LEVEL_ERROR,
3543 "%s: SETMCRATE indication alloc fail", __func__);
3544 ret = -EFAULT;
3545 goto exit;
3546 }
3547 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
3548
3549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3550 "MC Target rate %d", targetRate);
3551 /* Ignore unicast */
3552 rateUpdate->ucastDataRate = -1;
3553 rateUpdate->mcastDataRate24GHz = targetRate;
3554 rateUpdate->mcastDataRate5GHz = targetRate;
3555 rateUpdate->mcastDataRate24GHzTxFlag = 0;
3556 rateUpdate->mcastDataRate5GHzTxFlag = 0;
3557 status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate);
3558 if (eHAL_STATUS_SUCCESS != status)
3559 {
3560 hddLog(VOS_TRACE_LEVEL_ERROR,
3561 "%s: SET_MC_RATE failed", __func__);
3562 vos_mem_free(rateUpdate);
3563 ret = -EFAULT;
3564 goto exit;
Leo Chang614d2072013-08-22 14:59:44 -07003565 }
3566 }
Rajeev79dbe4c2013-10-05 11:03:42 +05303567#ifdef FEATURE_WLAN_BATCH_SCAN
Rajeev Kumar8b373292014-01-08 20:36:55 -08003568 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
Rajeev79dbe4c2013-10-05 11:03:42 +05303569 {
Rajeev Kumar8b373292014-01-08 20:36:55 -08003570 ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command);
Rajeev79dbe4c2013-10-05 11:03:42 +05303571 }
3572#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003573#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
3574 else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0)
3575 {
3576 tANI_U8 *value = command;
3577 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3578 tANI_U8 numChannels = 0;
3579 eHalStatus status = eHAL_STATUS_SUCCESS;
3580
3581 status = hdd_parse_channellist(value, ChannelList, &numChannels);
3582 if (eHAL_STATUS_SUCCESS != status)
3583 {
3584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3585 "%s: Failed to parse channel list information", __func__);
3586 ret = -EINVAL;
3587 goto exit;
3588 }
3589
3590 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3591 {
3592 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3593 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
3594 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
3595 ret = -EINVAL;
3596 goto exit;
3597 }
3598 status = sme_SetCcxRoamScanChannelList((tHalHandle)(pHddCtx->hHal),
3599 ChannelList,
3600 numChannels);
3601 if (eHAL_STATUS_SUCCESS != status)
3602 {
3603 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3604 "%s: Failed to update channel list information", __func__);
3605 ret = -EINVAL;
3606 goto exit;
3607 }
3608 }
3609 else if (strncmp(command, "GETTSMSTATS", 11) == 0)
3610 {
3611 tANI_U8 *value = command;
3612 char extra[128] = {0};
3613 int len = 0;
3614 tANI_U8 tid = 0;
3615 hdd_station_ctx_t *pHddStaCtx = NULL;
3616 tAniTrafStrmMetrics tsmMetrics;
3617 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3618
3619 /* if not associated, return error */
3620 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3621 {
3622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__);
3623 ret = -EINVAL;
3624 goto exit;
3625 }
3626
3627 /* Move pointer to ahead of GETTSMSTATS<delimiter> */
3628 value = value + 12;
3629 /* Convert the value from ascii to integer */
3630 ret = kstrtou8(value, 10, &tid);
3631 if (ret < 0)
3632 {
3633 /* If the input value is greater than max value of datatype, then also
3634 kstrtou8 fails */
3635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3636 "%s: kstrtou8 failed range [%d - %d]", __func__,
3637 TID_MIN_VALUE,
3638 TID_MAX_VALUE);
3639 ret = -EINVAL;
3640 goto exit;
3641 }
3642
3643 if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE))
3644 {
3645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3646 "tid value %d is out of range"
3647 " (Min: %d Max: %d)", tid,
3648 TID_MIN_VALUE,
3649 TID_MAX_VALUE);
3650 ret = -EINVAL;
3651 goto exit;
3652 }
3653
3654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3655 "%s: Received Command to get tsm stats tid = %d", __func__, tid);
3656
3657 if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics))
3658 {
3659 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3660 "%s: failed to get tsm stats", __func__);
3661 ret = -EFAULT;
3662 goto exit;
3663 }
3664
3665 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3666 "UplinkPktQueueDly(%d)\n"
3667 "UplinkPktQueueDlyHist[0](%d)\n"
3668 "UplinkPktQueueDlyHist[1](%d)\n"
3669 "UplinkPktQueueDlyHist[2](%d)\n"
3670 "UplinkPktQueueDlyHist[3](%d)\n"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05303671 "UplinkPktTxDly(%u)\n"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003672 "UplinkPktLoss(%d)\n"
3673 "UplinkPktCount(%d)\n"
3674 "RoamingCount(%d)\n"
3675 "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly,
3676 tsmMetrics.UplinkPktQueueDlyHist[0],
3677 tsmMetrics.UplinkPktQueueDlyHist[1],
3678 tsmMetrics.UplinkPktQueueDlyHist[2],
3679 tsmMetrics.UplinkPktQueueDlyHist[3],
3680 tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss,
3681 tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly);
3682
3683 /* Output TSM stats is of the format
3684 GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly]
3685 eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003686 len = scnprintf(extra, sizeof(extra), "%s %d %d:%d:%d:%d %u %d %d %d %d", command,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003687 tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0],
3688 tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2],
3689 tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly,
3690 tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount,
3691 tsmMetrics.RoamingDly);
3692
3693 if (copy_to_user(priv_data.buf, &extra, len + 1))
3694 {
3695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3696 "%s: failed to copy data to user buffer", __func__);
3697 ret = -EFAULT;
3698 goto exit;
3699 }
3700 }
3701 else if (strncmp(command, "SETCCKMIE", 9) == 0)
3702 {
3703 tANI_U8 *value = command;
3704 tANI_U8 *cckmIe = NULL;
3705 tANI_U8 cckmIeLen = 0;
3706 eHalStatus status = eHAL_STATUS_SUCCESS;
3707
3708 status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen);
3709 if (eHAL_STATUS_SUCCESS != status)
3710 {
3711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3712 "%s: Failed to parse cckm ie data", __func__);
3713 ret = -EINVAL;
3714 goto exit;
3715 }
3716
3717 if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN)
3718 {
3719 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3720 "%s: CCKM Ie input length is more than max[%d]", __func__,
3721 DOT11F_IE_RSN_MAX_LEN);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003722 vos_mem_free(cckmIe);
3723 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003724 ret = -EINVAL;
3725 goto exit;
3726 }
3727 sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003728 vos_mem_free(cckmIe);
3729 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003730 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003731 else if (strncmp(command, "CCXBEACONREQ", 12) == 0)
3732 {
3733 tANI_U8 *value = command;
3734 tCsrCcxBeaconReq ccxBcnReq;
3735 eHalStatus status = eHAL_STATUS_SUCCESS;
3736 status = hdd_parse_ccx_beacon_req(value, &ccxBcnReq);
3737 if (eHAL_STATUS_SUCCESS != status)
3738 {
3739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3740 "%s: Failed to parse ccx beacon req", __func__);
3741 ret = -EINVAL;
3742 goto exit;
3743 }
3744
3745 sme_SetCcxBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &ccxBcnReq);
3746 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003747#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003748 else {
3749 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3750 __func__, command);
3751 }
3752
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 }
3754exit:
3755 if (command)
3756 {
3757 kfree(command);
3758 }
3759 return ret;
3760}
3761
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003762
3763
3764#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003765/**---------------------------------------------------------------------------
3766
3767 \brief hdd_parse_ccx_beacon_req() - Parse ccx beacon request
3768
3769 This function parses the ccx beacon request passed in the format
3770 CCXBEACONREQ<space><Number of fields><space><Measurement token>
3771 <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N
3772 <space>Scan Mode N<space>Meas Duration N
3773 if the Number of bcn req fields (N) does not match with the actual number of fields passed
3774 then take N.
3775 <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair
3776 For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40.
3777 This function does not take care of removing duplicate channels from the list
3778
3779 \param - pValue Pointer to data
3780 \param - pCcxBcnReq output pointer to store parsed ie information
3781
3782 \return - 0 for success non-zero for failure
3783
3784 --------------------------------------------------------------------------*/
3785static VOS_STATUS hdd_parse_ccx_beacon_req(tANI_U8 *pValue,
3786 tCsrCcxBeaconReq *pCcxBcnReq)
3787{
3788 tANI_U8 *inPtr = pValue;
3789 int tempInt = 0;
3790 int j = 0, i = 0, v = 0;
3791 char buf[32];
3792
3793 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
3794 /*no argument after the command*/
3795 if (NULL == inPtr)
3796 {
3797 return -EINVAL;
3798 }
3799 /*no space after the command*/
3800 else if (SPACE_ASCII_VALUE != *inPtr)
3801 {
3802 return -EINVAL;
3803 }
3804
3805 /*removing empty spaces*/
3806 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
3807
3808 /*no argument followed by spaces*/
3809 if ('\0' == *inPtr) return -EINVAL;
3810
3811 /*getting the first argument ie measurement token*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08003812 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003813 if (1 != v) return -EINVAL;
3814
3815 v = kstrtos32(buf, 10, &tempInt);
3816 if ( v < 0) return -EINVAL;
3817
3818 pCcxBcnReq->numBcnReqIe = tempInt;
3819
3820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3821 "Number of Bcn Req Ie fields(%d)", pCcxBcnReq->numBcnReqIe);
3822
3823 for (j = 0; j < (pCcxBcnReq->numBcnReqIe); j++)
3824 {
3825 for (i = 0; i < 4; i++)
3826 {
3827 /*inPtr pointing to the beginning of first space after number of ie fields*/
3828 inPtr = strpbrk( inPtr, " " );
3829 /*no ie data after the number of ie fields argument*/
3830 if (NULL == inPtr) return -EINVAL;
3831
3832 /*removing empty space*/
3833 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
3834
3835 /*no ie data after the number of ie fields argument and spaces*/
3836 if ( '\0' == *inPtr ) return -EINVAL;
3837
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08003838 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003839 if (1 != v) return -EINVAL;
3840
3841 v = kstrtos32(buf, 10, &tempInt);
3842 if (v < 0) return -EINVAL;
3843
3844 switch (i)
3845 {
3846 case 0: /* Measurement token */
3847 if (tempInt <= 0)
3848 {
3849 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3850 "Invalid Measurement Token(%d)", tempInt);
3851 return -EINVAL;
3852 }
3853 pCcxBcnReq->bcnReq[j].measurementToken = tempInt;
3854 break;
3855
3856 case 1: /* Channel number */
3857 if ((tempInt <= 0) ||
3858 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
3859 {
3860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3861 "Invalid Channel Number(%d)", tempInt);
3862 return -EINVAL;
3863 }
3864 pCcxBcnReq->bcnReq[j].channel = tempInt;
3865 break;
3866
3867 case 2: /* Scan mode */
Varun Reddy Yeturu0b18d5a2013-12-04 11:42:23 -08003868 if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003869 {
3870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3871 "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt);
3872 return -EINVAL;
3873 }
3874 pCcxBcnReq->bcnReq[j].scanMode= tempInt;
3875 break;
3876
3877 case 3: /* Measurement duration */
Varun Reddy Yeturu0b18d5a2013-12-04 11:42:23 -08003878 if (((tempInt <= 0) && (pCcxBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) ||
3879 ((tempInt < 0) && (pCcxBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE)))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003880 {
3881 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3882 "Invalid Measurement Duration(%d)", tempInt);
3883 return -EINVAL;
3884 }
3885 pCcxBcnReq->bcnReq[j].measurementDuration = tempInt;
3886 break;
3887 }
3888 }
3889 }
3890
3891 for (j = 0; j < pCcxBcnReq->numBcnReqIe; j++)
3892 {
3893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05303894 "Index(%d) Measurement Token(%u)Channel(%u) Scan Mode(%u) Measurement Duration(%u)\n",
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003895 j,
3896 pCcxBcnReq->bcnReq[j].measurementToken,
3897 pCcxBcnReq->bcnReq[j].channel,
3898 pCcxBcnReq->bcnReq[j].scanMode,
3899 pCcxBcnReq->bcnReq[j].measurementDuration);
3900 }
3901
3902 return VOS_STATUS_SUCCESS;
3903}
3904
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003905static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext )
3906{
3907 struct statsContext *pStatsContext = NULL;
3908 hdd_adapter_t *pAdapter = NULL;
3909
3910 if (NULL == pContext)
3911 {
3912 hddLog(VOS_TRACE_LEVEL_ERROR,
3913 "%s: Bad param, pContext [%p]",
3914 __func__, pContext);
3915 return;
3916 }
3917
Jeff Johnson72a40512013-12-19 10:14:15 -08003918 /* there is a race condition that exists between this callback
3919 function and the caller since the caller could time out either
3920 before or while this code is executing. we use a spinlock to
3921 serialize these actions */
3922 spin_lock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003923
3924 pStatsContext = pContext;
3925 pAdapter = pStatsContext->pAdapter;
3926 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3927 {
3928 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003929 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003930 hddLog(VOS_TRACE_LEVEL_WARN,
3931 "%s: Invalid context, pAdapter [%p] magic [%08x]",
3932 __func__, pAdapter, pStatsContext->magic);
3933 return;
3934 }
3935
Jeff Johnson72a40512013-12-19 10:14:15 -08003936 /* context is valid so caller is still waiting */
3937
3938 /* paranoia: invalidate the magic */
3939 pStatsContext->magic = 0;
3940
3941 /* copy over the tsm stats */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003942 pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly;
3943 vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist,
3944 tsmMetrics.UplinkPktQueueDlyHist,
3945 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
3946 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
3947 pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly;
3948 pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss;
3949 pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount;
3950 pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount;
3951 pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly;
3952
Jeff Johnson72a40512013-12-19 10:14:15 -08003953 /* notify the caller */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003954 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003955
3956 /* serialization is complete */
3957 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003958}
3959
3960
3961
3962static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
3963 tAniTrafStrmMetrics* pTsmMetrics)
3964{
3965 hdd_station_ctx_t *pHddStaCtx = NULL;
3966 eHalStatus hstatus;
Jeff Johnson72a40512013-12-19 10:14:15 -08003967 VOS_STATUS vstatus = VOS_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003968 long lrc;
3969 struct statsContext context;
3970 hdd_context_t *pHddCtx = NULL;
3971
3972 if (NULL == pAdapter)
3973 {
3974 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__);
3975 return VOS_STATUS_E_FAULT;
3976 }
3977
3978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3979 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3980
3981 /* we are connected prepare our callback context */
3982 init_completion(&context.completion);
3983 context.pAdapter = pAdapter;
3984 context.magic = STATS_CONTEXT_MAGIC;
3985
3986 /* query tsm stats */
3987 hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB,
3988 pHddStaCtx->conn_info.staId[ 0 ],
3989 pHddStaCtx->conn_info.bssId,
3990 &context, pHddCtx->pvosContext, tid);
3991
3992 if (eHAL_STATUS_SUCCESS != hstatus)
3993 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003994 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics",
3995 __func__);
3996 vstatus = VOS_STATUS_E_FAULT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003997 }
3998 else
3999 {
4000 /* request was sent -- wait for the response */
4001 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4002 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004003 if (lrc <= 0)
4004 {
4005 hddLog(VOS_TRACE_LEVEL_ERROR,
4006 "%s: SME %s while retrieving statistics",
4007 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson72a40512013-12-19 10:14:15 -08004008 vstatus = VOS_STATUS_E_TIMEOUT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004009 }
4010 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004011
Jeff Johnson72a40512013-12-19 10:14:15 -08004012 /* either we never sent a request, we sent a request and received a
4013 response or we sent a request and timed out. if we never sent a
4014 request or if we sent a request and got a response, we want to
4015 clear the magic out of paranoia. if we timed out there is a
4016 race condition such that the callback function could be
4017 executing at the same time we are. of primary concern is if the
4018 callback function had already verified the "magic" but had not
4019 yet set the completion variable when a timeout occurred. we
4020 serialize these activities by invalidating the magic while
4021 holding a shared spinlock which will cause us to block if the
4022 callback is currently executing */
4023 spin_lock(&hdd_context_lock);
4024 context.magic = 0;
4025 spin_unlock(&hdd_context_lock);
4026
4027 if (VOS_STATUS_SUCCESS == vstatus)
4028 {
4029 pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly;
4030 vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist,
4031 pAdapter->tsmStats.UplinkPktQueueDlyHist,
4032 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4033 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4034 pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly;
4035 pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss;
4036 pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount;
4037 pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount;
4038 pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly;
4039 }
4040 return vstatus;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004041}
4042#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4043
Srinivas Girigowdade697412013-02-14 16:31:48 -08004044#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
4045void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand)
4046{
4047 eCsrBand band = -1;
4048 sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band);
4049 switch (band)
4050 {
4051 case eCSR_BAND_ALL:
4052 *pBand = WLAN_HDD_UI_BAND_AUTO;
4053 break;
4054
4055 case eCSR_BAND_24:
4056 *pBand = WLAN_HDD_UI_BAND_2_4_GHZ;
4057 break;
4058
4059 case eCSR_BAND_5G:
4060 *pBand = WLAN_HDD_UI_BAND_5_GHZ;
4061 break;
4062
4063 default:
4064 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band);
4065 *pBand = -1;
4066 break;
4067 }
4068}
4069
4070/**---------------------------------------------------------------------------
4071
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004072 \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data
4073
4074 This function parses the send action frame data passed in the format
4075 SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data>
4076
Srinivas Girigowda56076852013-08-20 14:00:50 -07004077 \param - pValue Pointer to input data
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004078 \param - pTargetApBssid Pointer to target Ap bssid
4079 \param - pChannel Pointer to the Target AP channel
4080 \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame
4081 \param - pBuf Pointer to data
4082 \param - pBufLen Pointer to data length
4083
4084 \return - 0 for success non-zero for failure
4085
4086 --------------------------------------------------------------------------*/
4087VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel,
4088 tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen)
4089{
4090 tANI_U8 *inPtr = pValue;
4091 tANI_U8 *dataEnd;
4092 int tempInt;
4093 int j = 0;
4094 int i = 0;
4095 int v = 0;
4096 tANI_U8 tempBuf[32];
4097 tANI_U8 tempByte = 0;
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004098 /* 12 hexa decimal digits, 5 ':' and '\0' */
4099 tANI_U8 macAddress[18];
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004100
4101 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4102 /*no argument after the command*/
4103 if (NULL == inPtr)
4104 {
4105 return -EINVAL;
4106 }
4107
4108 /*no space after the command*/
4109 else if (SPACE_ASCII_VALUE != *inPtr)
4110 {
4111 return -EINVAL;
4112 }
4113
4114 /*removing empty spaces*/
4115 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4116
4117 /*no argument followed by spaces*/
4118 if ('\0' == *inPtr)
4119 {
4120 return -EINVAL;
4121 }
4122
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004123 v = sscanf(inPtr, "%17s", macAddress);
4124 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004125 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4127 "Invalid MAC address or All hex inputs are not read (%d)", v);
4128 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004129 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004130
4131 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
4132 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
4133 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
4134 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
4135 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
4136 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004137
4138 /* point to the next argument */
4139 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4140 /*no argument after the command*/
4141 if (NULL == inPtr) return -EINVAL;
4142
4143 /*removing empty spaces*/
4144 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4145
4146 /*no argument followed by spaces*/
4147 if ('\0' == *inPtr)
4148 {
4149 return -EINVAL;
4150 }
4151
4152 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004153 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004154 if (1 != v) return -EINVAL;
4155
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004156 v = kstrtos32(tempBuf, 10, &tempInt);
Agarwal Ashishc0126762014-02-17 19:30:26 +05304157 if ( v < 0 || tempInt < 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX )
Kiet Lambe150c22013-11-21 16:30:32 +05304158 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004159
4160 *pChannel = tempInt;
4161
4162 /* point to the next argument */
4163 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4164 /*no argument after the command*/
4165 if (NULL == inPtr) return -EINVAL;
4166 /*removing empty spaces*/
4167 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4168
4169 /*no argument followed by spaces*/
4170 if ('\0' == *inPtr)
4171 {
4172 return -EINVAL;
4173 }
4174
4175 /*getting the next argument ie the dwell time */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004176 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004177 if (1 != v) return -EINVAL;
4178
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004179 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda5a6e0672014-01-09 14:42:57 -08004180 if ( v < 0 || tempInt < 0) return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004181
4182 *pDwellTime = tempInt;
4183
4184 /* point to the next argument */
4185 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4186 /*no argument after the command*/
4187 if (NULL == inPtr) return -EINVAL;
4188 /*removing empty spaces*/
4189 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4190
4191 /*no argument followed by spaces*/
4192 if ('\0' == *inPtr)
4193 {
4194 return -EINVAL;
4195 }
4196
4197 /* find the length of data */
4198 dataEnd = inPtr;
4199 while(('\0' != *dataEnd) )
4200 {
4201 dataEnd++;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004202 }
Kiet Lambe150c22013-11-21 16:30:32 +05304203 *pBufLen = dataEnd - inPtr ;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004204 if ( *pBufLen <= 0) return -EINVAL;
4205
Srinivas Girigowdab5ae85d2013-06-03 10:51:45 -07004206 /* Allocate the number of bytes based on the number of input characters
4207 whether it is even or odd.
4208 if the number of input characters are even, then we need N/2 byte.
4209 if the number of input characters are odd, then we need do (N+1)/2 to
4210 compensate rounding off.
4211 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
4212 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
4213 *pBuf = vos_mem_malloc((*pBufLen + 1)/2);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004214 if (NULL == *pBuf)
4215 {
4216 hddLog(VOS_TRACE_LEVEL_FATAL,
4217 "%s: vos_mem_alloc failed ", __func__);
4218 return -EINVAL;
4219 }
4220
4221 /* the buffer received from the upper layer is character buffer,
4222 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
4223 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
4224 and f0 in 3rd location */
4225 for (i = 0, j = 0; j < *pBufLen; j += 2)
4226 {
Kiet Lambe150c22013-11-21 16:30:32 +05304227 if( j+1 == *pBufLen)
4228 {
4229 tempByte = hdd_parse_hex(inPtr[j]);
4230 }
4231 else
4232 {
4233 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
4234 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004235 (*pBuf)[i++] = tempByte;
4236 }
4237 *pBufLen = i;
4238 return VOS_STATUS_SUCCESS;
4239}
4240
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004241/**---------------------------------------------------------------------------
4242
Srinivas Girigowdade697412013-02-14 16:31:48 -08004243 \brief hdd_parse_channellist() - HDD Parse channel list
4244
4245 This function parses the channel list passed in the format
4246 SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07004247 if the Number of channels (N) does not match with the actual number of channels passed
4248 then take the minimum of N and count of (Ch1, Ch2, ...Ch M)
4249 For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken.
4250 If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48.
4251 This function does not take care of removing duplicate channels from the list
Srinivas Girigowdade697412013-02-14 16:31:48 -08004252
4253 \param - pValue Pointer to input channel list
4254 \param - ChannelList Pointer to local output array to record channel list
4255 \param - pNumChannels Pointer to number of roam scan channels
4256
4257 \return - 0 for success non-zero for failure
4258
4259 --------------------------------------------------------------------------*/
4260VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels)
4261{
4262 tANI_U8 *inPtr = pValue;
4263 int tempInt;
4264 int j = 0;
4265 int v = 0;
4266 char buf[32];
4267
4268 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4269 /*no argument after the command*/
4270 if (NULL == inPtr)
4271 {
4272 return -EINVAL;
4273 }
4274
4275 /*no space after the command*/
4276 else if (SPACE_ASCII_VALUE != *inPtr)
4277 {
4278 return -EINVAL;
4279 }
4280
4281 /*removing empty spaces*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004282 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004283
4284 /*no argument followed by spaces*/
4285 if ('\0' == *inPtr)
4286 {
4287 return -EINVAL;
4288 }
4289
4290 /*getting the first argument ie the number of channels*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004291 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004292 if (1 != v) return -EINVAL;
4293
Srinivas Girigowdade697412013-02-14 16:31:48 -08004294 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004295 if ((v < 0) ||
4296 (tempInt <= 0) ||
4297 (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN))
4298 {
4299 return -EINVAL;
4300 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004301
4302 *pNumChannels = tempInt;
4303
4304 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
4305 "Number of channels are: %d", *pNumChannels);
4306
4307 for (j = 0; j < (*pNumChannels); j++)
4308 {
4309 /*inPtr pointing to the beginning of first space after number of channels*/
4310 inPtr = strpbrk( inPtr, " " );
4311 /*no channel list after the number of channels argument*/
4312 if (NULL == inPtr)
4313 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07004314 if (0 != j)
4315 {
4316 *pNumChannels = j;
4317 return VOS_STATUS_SUCCESS;
4318 }
4319 else
4320 {
4321 return -EINVAL;
4322 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004323 }
4324
4325 /*removing empty space*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004326 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004327
4328 /*no channel list after the number of channels argument and spaces*/
4329 if ( '\0' == *inPtr )
4330 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07004331 if (0 != j)
4332 {
4333 *pNumChannels = j;
4334 return VOS_STATUS_SUCCESS;
4335 }
4336 else
4337 {
4338 return -EINVAL;
4339 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004340 }
4341
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004342 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004343 if (1 != v) return -EINVAL;
4344
Srinivas Girigowdade697412013-02-14 16:31:48 -08004345 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004346 if ((v < 0) ||
4347 (tempInt <= 0) ||
4348 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4349 {
4350 return -EINVAL;
4351 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004352 pChannelList[j] = tempInt;
4353
4354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
4355 "Channel %d added to preferred channel list",
4356 pChannelList[j] );
4357 }
4358
Srinivas Girigowdade697412013-02-14 16:31:48 -08004359 return VOS_STATUS_SUCCESS;
4360}
4361
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004362
4363/**---------------------------------------------------------------------------
4364
4365 \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data
4366
4367 This function parses the reasoc command data passed in the format
4368 REASSOC<space><bssid><space><channel>
4369
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004370 \param - pValue Pointer to input data (its a NUL terminated string)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004371 \param - pTargetApBssid Pointer to target Ap bssid
4372 \param - pChannel Pointer to the Target AP channel
4373
4374 \return - 0 for success non-zero for failure
4375
4376 --------------------------------------------------------------------------*/
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004377VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
4378 tANI_U8 *pTargetApBssid, tANI_U8 *pChannel)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004379{
4380 tANI_U8 *inPtr = pValue;
4381 int tempInt;
4382 int v = 0;
4383 tANI_U8 tempBuf[32];
Kiet Lamaa8e15a2014-02-11 23:30:06 -08004384 /* 12 hexa decimal digits, 5 ':' and '\0' */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004385 tANI_U8 macAddress[18];
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004386
4387 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4388 /*no argument after the command*/
4389 if (NULL == inPtr)
4390 {
4391 return -EINVAL;
4392 }
4393
4394 /*no space after the command*/
4395 else if (SPACE_ASCII_VALUE != *inPtr)
4396 {
4397 return -EINVAL;
4398 }
4399
4400 /*removing empty spaces*/
4401 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4402
4403 /*no argument followed by spaces*/
4404 if ('\0' == *inPtr)
4405 {
4406 return -EINVAL;
4407 }
4408
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004409 v = sscanf(inPtr, "%17s", macAddress);
4410 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004411 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4413 "Invalid MAC address or All hex inputs are not read (%d)", v);
4414 return -EINVAL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004415 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004416
4417 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
4418 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
4419 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
4420 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
4421 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
4422 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004423
4424 /* point to the next argument */
4425 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4426 /*no argument after the command*/
4427 if (NULL == inPtr) return -EINVAL;
4428
4429 /*removing empty spaces*/
4430 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4431
4432 /*no argument followed by spaces*/
4433 if ('\0' == *inPtr)
4434 {
4435 return -EINVAL;
4436 }
4437
4438 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004439 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004440 if (1 != v) return -EINVAL;
4441
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004442 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004443 if ((v < 0) ||
4444 (tempInt <= 0) ||
4445 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4446 {
4447 return -EINVAL;
4448 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004449
4450 *pChannel = tempInt;
4451 return VOS_STATUS_SUCCESS;
4452}
4453
4454#endif
4455
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004456#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
4457/**---------------------------------------------------------------------------
4458
4459 \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE
4460
4461 This function parses the SETCCKM IE command
4462 SETCCKMIE<space><ie data>
4463
4464 \param - pValue Pointer to input data
4465 \param - pCckmIe Pointer to output cckm Ie
4466 \param - pCckmIeLen Pointer to output cckm ie length
4467
4468 \return - 0 for success non-zero for failure
4469
4470 --------------------------------------------------------------------------*/
4471VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe,
4472 tANI_U8 *pCckmIeLen)
4473{
4474 tANI_U8 *inPtr = pValue;
4475 tANI_U8 *dataEnd;
4476 int j = 0;
4477 int i = 0;
4478 tANI_U8 tempByte = 0;
4479
4480 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4481 /*no argument after the command*/
4482 if (NULL == inPtr)
4483 {
4484 return -EINVAL;
4485 }
4486
4487 /*no space after the command*/
4488 else if (SPACE_ASCII_VALUE != *inPtr)
4489 {
4490 return -EINVAL;
4491 }
4492
4493 /*removing empty spaces*/
4494 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4495
4496 /*no argument followed by spaces*/
4497 if ('\0' == *inPtr)
4498 {
4499 return -EINVAL;
4500 }
4501
4502 /* find the length of data */
4503 dataEnd = inPtr;
4504 while(('\0' != *dataEnd) )
4505 {
4506 dataEnd++;
4507 ++(*pCckmIeLen);
4508 }
4509 if ( *pCckmIeLen <= 0) return -EINVAL;
4510
4511 /* Allocate the number of bytes based on the number of input characters
4512 whether it is even or odd.
4513 if the number of input characters are even, then we need N/2 byte.
4514 if the number of input characters are odd, then we need do (N+1)/2 to
4515 compensate rounding off.
4516 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
4517 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
4518 *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2);
4519 if (NULL == *pCckmIe)
4520 {
4521 hddLog(VOS_TRACE_LEVEL_FATAL,
4522 "%s: vos_mem_alloc failed ", __func__);
4523 return -EINVAL;
4524 }
4525 vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2);
4526 /* the buffer received from the upper layer is character buffer,
4527 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
4528 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
4529 and f0 in 3rd location */
4530 for (i = 0, j = 0; j < *pCckmIeLen; j += 2)
4531 {
4532 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
4533 (*pCckmIe)[i++] = tempByte;
4534 }
4535 *pCckmIeLen = i;
4536
4537 return VOS_STATUS_SUCCESS;
4538}
4539#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4540
Jeff Johnson295189b2012-06-20 16:38:30 -07004541/**---------------------------------------------------------------------------
4542
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004543 \brief hdd_is_valid_mac_address() - Validate MAC address
4544
4545 This function validates whether the given MAC address is valid or not
4546 Expected MAC address is of the format XX:XX:XX:XX:XX:XX
4547 where X is the hexa decimal digit character and separated by ':'
4548 This algorithm works even if MAC address is not separated by ':'
4549
4550 This code checks given input string mac contains exactly 12 hexadecimal digits.
4551 and a separator colon : appears in the input string only after
4552 an even number of hex digits.
4553
4554 \param - pMacAddr pointer to the input MAC address
4555 \return - 1 for valid and 0 for invalid
4556
4557 --------------------------------------------------------------------------*/
4558
4559v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr)
4560{
4561 int xdigit = 0;
4562 int separator = 0;
4563 while (*pMacAddr)
4564 {
4565 if (isxdigit(*pMacAddr))
4566 {
4567 xdigit++;
4568 }
4569 else if (':' == *pMacAddr)
4570 {
4571 if (0 == xdigit || ((xdigit / 2) - 1) != separator)
4572 break;
4573
4574 ++separator;
4575 }
4576 else
4577 {
4578 separator = -1;
4579 /* Invalid MAC found */
4580 return 0;
4581 }
4582 ++pMacAddr;
4583 }
4584 return (xdigit == 12 && (separator == 5 || separator == 0));
4585}
4586
4587/**---------------------------------------------------------------------------
4588
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 \brief hdd_open() - HDD Open function
4590
4591 This is called in response to ifconfig up
4592
4593 \param - dev Pointer to net_device structure
4594
4595 \return - 0 for success non-zero for failure
4596
4597 --------------------------------------------------------------------------*/
4598int hdd_open (struct net_device *dev)
4599{
4600 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4601 hdd_context_t *pHddCtx;
4602 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4603 VOS_STATUS status;
4604 v_BOOL_t in_standby = TRUE;
4605
4606 if (NULL == pAdapter)
4607 {
4608 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05304609 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 return -ENODEV;
4611 }
4612
4613 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4614 if (NULL == pHddCtx)
4615 {
4616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004617 "%s: HDD context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 return -ENODEV;
4619 }
4620
4621 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4622 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
4623 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07004624 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
4625 {
4626 hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby",
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304627 __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07004628 in_standby = FALSE;
4629 break;
4630 }
4631 else
4632 {
4633 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4634 pAdapterNode = pNext;
4635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 }
4637
4638 if (TRUE == in_standby)
4639 {
4640 if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter))
4641 {
4642 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring "
4643 "wlan out of power save", __func__);
4644 return -EINVAL;
4645 }
4646 }
4647
Jeff Johnson6a81ca42013-04-05 10:37:08 -07004648 set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
4650 {
4651 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004652 "%s: Enabling Tx Queues", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 /* Enable TX queues only when we are connected */
4654 netif_tx_start_all_queues(dev);
4655 }
4656
4657 return 0;
4658}
4659
4660int hdd_mon_open (struct net_device *dev)
4661{
4662 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4663
4664 if(pAdapter == NULL) {
4665 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004666 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08004667 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 }
4669
4670 netif_start_queue(dev);
4671
4672 return 0;
4673}
4674/**---------------------------------------------------------------------------
4675
4676 \brief hdd_stop() - HDD stop function
4677
4678 This is called in response to ifconfig down
4679
4680 \param - dev Pointer to net_device structure
4681
4682 \return - 0 for success non-zero for failure
4683
4684 --------------------------------------------------------------------------*/
4685
4686int hdd_stop (struct net_device *dev)
4687{
4688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4689 hdd_context_t *pHddCtx;
4690 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4691 VOS_STATUS status;
4692 v_BOOL_t enter_standby = TRUE;
4693
4694 ENTER();
4695
4696 if (NULL == pAdapter)
4697 {
4698 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05304699 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 return -ENODEV;
4701 }
4702
4703 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4704 if (NULL == pHddCtx)
4705 {
4706 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004707 "%s: HDD context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 return -ENODEV;
4709 }
4710
Jeff Johnson6a81ca42013-04-05 10:37:08 -07004711 clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__);
4713 netif_tx_disable(pAdapter->dev);
4714 netif_carrier_off(pAdapter->dev);
4715
4716
4717 /* SoftAP ifaces should never go in power save mode
4718 making sure same here. */
4719 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode )
4720 || (WLAN_HDD_MONITOR == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 || (WLAN_HDD_P2P_GO == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 )
4723 {
4724 /* SoftAP mode, so return from here */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304725 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4726 "%s: In SAP MODE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 EXIT();
4728 return 0;
4729 }
4730
4731 /* Find if any iface is up then
4732 if any iface is up then can't put device to sleep/ power save mode. */
4733 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4734 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
4735 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07004736 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
4737 {
4738 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05304739 "put device to sleep", __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07004740 enter_standby = FALSE;
4741 break;
4742 }
4743 else
4744 {
4745 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4746 pAdapterNode = pNext;
4747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 }
4749
4750 if (TRUE == enter_standby)
4751 {
4752 hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down "
4753 "entering standby", __func__);
4754 if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx))
4755 {
4756 /*log and return success*/
4757 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put "
4758 "wlan in power save", __func__);
4759 }
4760 }
4761
4762 EXIT();
4763 return 0;
4764}
4765
4766/**---------------------------------------------------------------------------
4767
4768 \brief hdd_uninit() - HDD uninit function
4769
4770 This is called during the netdev unregister to uninitialize all data
4771associated with the device
4772
4773 \param - dev Pointer to net_device structure
4774
4775 \return - void
4776
4777 --------------------------------------------------------------------------*/
4778static void hdd_uninit (struct net_device *dev)
4779{
4780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4781
4782 ENTER();
4783
4784 do
4785 {
4786 if (NULL == pAdapter)
4787 {
4788 hddLog(VOS_TRACE_LEVEL_FATAL,
4789 "%s: NULL pAdapter", __func__);
4790 break;
4791 }
4792
4793 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4794 {
4795 hddLog(VOS_TRACE_LEVEL_FATAL,
4796 "%s: Invalid magic", __func__);
4797 break;
4798 }
4799
4800 if (NULL == pAdapter->pHddCtx)
4801 {
4802 hddLog(VOS_TRACE_LEVEL_FATAL,
4803 "%s: NULL pHddCtx", __func__);
4804 break;
4805 }
4806
4807 if (dev != pAdapter->dev)
4808 {
4809 hddLog(VOS_TRACE_LEVEL_FATAL,
4810 "%s: Invalid device reference", __func__);
4811 /* we haven't validated all cases so let this go for now */
4812 }
4813
4814 hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter);
4815
4816 /* after uninit our adapter structure will no longer be valid */
4817 pAdapter->dev = NULL;
4818 pAdapter->magic = 0;
4819 } while (0);
4820
4821 EXIT();
4822}
4823
4824/**---------------------------------------------------------------------------
4825
4826 \brief hdd_release_firmware() -
4827
4828 This function calls the release firmware API to free the firmware buffer.
4829
4830 \param - pFileName Pointer to the File Name.
4831 pCtx - Pointer to the adapter .
4832
4833
4834 \return - 0 for success, non zero for failure
4835
4836 --------------------------------------------------------------------------*/
4837
4838VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx)
4839{
4840 VOS_STATUS status = VOS_STATUS_SUCCESS;
4841 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
4842 ENTER();
4843
4844
4845 if (!strcmp(WLAN_FW_FILE, pFileName)) {
4846
4847 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName);
4848
4849 if(pHddCtx->fw) {
4850 release_firmware(pHddCtx->fw);
4851 pHddCtx->fw = NULL;
4852 }
4853 else
4854 status = VOS_STATUS_E_FAILURE;
4855 }
4856 else if (!strcmp(WLAN_NV_FILE,pFileName)) {
4857 if(pHddCtx->nv) {
4858 release_firmware(pHddCtx->nv);
4859 pHddCtx->nv = NULL;
4860 }
4861 else
4862 status = VOS_STATUS_E_FAILURE;
4863
4864 }
4865
4866 EXIT();
4867 return status;
4868}
4869
4870/**---------------------------------------------------------------------------
4871
4872 \brief hdd_request_firmware() -
4873
4874 This function reads the firmware file using the request firmware
4875 API and returns the the firmware data and the firmware file size.
4876
4877 \param - pfileName - Pointer to the file name.
4878 - pCtx - Pointer to the adapter .
4879 - ppfw_data - Pointer to the pointer of the firmware data.
4880 - pSize - Pointer to the file size.
4881
4882 \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure
4883
4884 --------------------------------------------------------------------------*/
4885
4886
4887VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize)
4888{
4889 int status;
4890 VOS_STATUS retval = VOS_STATUS_SUCCESS;
4891 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
4892 ENTER();
4893
4894 if( (!strcmp(WLAN_FW_FILE, pfileName)) ) {
4895
4896 status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev);
4897
4898 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
4899 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed",
4900 __func__, pfileName);
4901 retval = VOS_STATUS_E_FAILURE;
4902 }
4903
4904 else {
4905 *ppfw_data = (v_VOID_t *)pHddCtx->fw->data;
4906 *pSize = pHddCtx->fw->size;
4907 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d",
4908 __func__, *pSize);
4909 }
4910 }
4911 else if(!strcmp(WLAN_NV_FILE, pfileName)) {
4912
4913 status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev);
4914
4915 if(status || !pHddCtx->nv || !pHddCtx->nv->data) {
4916 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed",
4917 __func__, pfileName);
4918 retval = VOS_STATUS_E_FAILURE;
4919 }
4920
4921 else {
4922 *ppfw_data = (v_VOID_t *)pHddCtx->nv->data;
4923 *pSize = pHddCtx->nv->size;
4924 hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d",
4925 __func__, *pSize);
4926 }
4927 }
4928
4929 EXIT();
4930 return retval;
4931}
4932/**---------------------------------------------------------------------------
4933 \brief hdd_full_pwr_cbk() - HDD full power callbackfunction
4934
4935 This is the function invoked by SME to inform the result of a full power
4936 request issued by HDD
4937
4938 \param - callbackcontext - Pointer to cookie
4939 status - result of request
4940
4941 \return - None
4942
4943--------------------------------------------------------------------------*/
4944void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status)
4945{
4946 hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext;
4947
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"HDD full Power callback status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 if(&pHddCtx->full_pwr_comp_var)
4950 {
4951 complete(&pHddCtx->full_pwr_comp_var);
4952 }
4953}
4954
4955/**---------------------------------------------------------------------------
4956
4957 \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function
4958
4959 This is the function invoked by SME to inform the result of BMPS
4960 request issued by HDD
4961
4962 \param - callbackcontext - Pointer to cookie
4963 status - result of request
4964
4965 \return - None
4966
4967--------------------------------------------------------------------------*/
4968void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status)
4969{
4970
4971 struct completion *completion_var = (struct completion*) callbackContext;
4972
Arif Hussain6d2a3322013-11-17 19:50:10 -08004973 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 if(completion_var != NULL)
4975 {
4976 complete(completion_var);
4977 }
4978}
4979
4980/**---------------------------------------------------------------------------
4981
4982 \brief hdd_get_cfg_file_size() -
4983
4984 This function reads the configuration file using the request firmware
4985 API and returns the configuration file size.
4986
4987 \param - pCtx - Pointer to the adapter .
4988 - pFileName - Pointer to the file name.
4989 - pBufSize - Pointer to the buffer size.
4990
4991 \return - 0 for success, non zero for failure
4992
4993 --------------------------------------------------------------------------*/
4994
4995VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize)
4996{
4997 int status;
4998 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
4999
5000 ENTER();
5001
5002 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5003
5004 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5005 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5006 status = VOS_STATUS_E_FAILURE;
5007 }
5008 else {
5009 *pBufSize = pHddCtx->fw->size;
5010 hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize);
5011 release_firmware(pHddCtx->fw);
5012 pHddCtx->fw = NULL;
5013 }
5014
5015 EXIT();
5016 return VOS_STATUS_SUCCESS;
5017}
5018
5019/**---------------------------------------------------------------------------
5020
5021 \brief hdd_read_cfg_file() -
5022
5023 This function reads the configuration file using the request firmware
5024 API and returns the cfg data and the buffer size of the configuration file.
5025
5026 \param - pCtx - Pointer to the adapter .
5027 - pFileName - Pointer to the file name.
5028 - pBuffer - Pointer to the data buffer.
5029 - pBufSize - Pointer to the buffer size.
5030
5031 \return - 0 for success, non zero for failure
5032
5033 --------------------------------------------------------------------------*/
5034
5035VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName,
5036 v_VOID_t *pBuffer, v_SIZE_t *pBufSize)
5037{
5038 int status;
5039 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5040
5041 ENTER();
5042
5043 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5044
5045 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5046 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5047 return VOS_STATUS_E_FAILURE;
5048 }
5049 else {
5050 if(*pBufSize != pHddCtx->fw->size) {
5051 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG "
5052 "file size", __func__);
5053 release_firmware(pHddCtx->fw);
5054 pHddCtx->fw = NULL;
5055 return VOS_STATUS_E_FAILURE;
5056 }
5057 else {
5058 if(pBuffer) {
5059 vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize);
5060 }
5061 release_firmware(pHddCtx->fw);
5062 pHddCtx->fw = NULL;
5063 }
5064 }
5065
5066 EXIT();
5067
5068 return VOS_STATUS_SUCCESS;
5069}
5070
5071/**---------------------------------------------------------------------------
5072
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 \brief hdd_set_mac_address() -
5074
5075 This function sets the user specified mac address using
5076 the command ifconfig wlanX hw ether <mac adress>.
5077
5078 \param - dev - Pointer to the net device.
5079 - addr - Pointer to the sockaddr.
5080 \return - 0 for success, non zero for failure
5081
5082 --------------------------------------------------------------------------*/
5083
5084static int hdd_set_mac_address(struct net_device *dev, void *addr)
5085{
5086 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5087 struct sockaddr *psta_mac_addr = addr;
5088 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5089
5090 ENTER();
5091
5092 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
5093
5094#ifdef HDD_SESSIONIZE
5095 // set the MAC address though the STA ID CFG.
5096 halStatus = ccmCfgSetStr( pAdapter->hHal, WNI_CFG_STA_ID,
5097 (v_U8_t *)&pAdapter->macAddressCurrent,
5098 sizeof( pAdapter->macAddressCurrent ),
5099 hdd_set_mac_addr_cb, VOS_FALSE );
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305100
5101 if(eHAL_STATUS_SUCCESS != halStatus)
5102 {
5103 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5104 "%s: failed to set MAC address in CFG", __func__);
5105 }
5106
Jeff Johnson295189b2012-06-20 16:38:30 -07005107#endif
5108
5109 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
5110
5111 EXIT();
5112 return halStatus;
5113}
5114
5115tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx)
5116{
5117 int i;
5118 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
5119 {
Abhishek Singheb183782014-02-06 13:37:21 +05305120 if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 break;
5122 }
5123
5124 if( VOS_MAX_CONCURRENCY_PERSONA == i)
5125 return NULL;
5126
5127 pHddCtx->cfg_ini->intfAddrMask |= (1 << i);
5128 return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0];
5129}
5130
5131void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr)
5132{
5133 int i;
5134 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
5135 {
5136 if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) )
5137 {
5138 pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i);
5139 break;
5140 }
5141 }
5142 return;
5143}
5144
5145#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
5146 static struct net_device_ops wlan_drv_ops = {
5147 .ndo_open = hdd_open,
5148 .ndo_stop = hdd_stop,
5149 .ndo_uninit = hdd_uninit,
5150 .ndo_start_xmit = hdd_hard_start_xmit,
5151 .ndo_tx_timeout = hdd_tx_timeout,
5152 .ndo_get_stats = hdd_stats,
5153 .ndo_do_ioctl = hdd_ioctl,
5154 .ndo_set_mac_address = hdd_set_mac_address,
5155 .ndo_select_queue = hdd_select_queue,
5156#ifdef WLAN_FEATURE_PACKET_FILTERING
5157#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0))
5158 .ndo_set_rx_mode = hdd_set_multicast_list,
5159#else
5160 .ndo_set_multicast_list = hdd_set_multicast_list,
5161#endif //LINUX_VERSION_CODE
5162#endif
5163 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 static struct net_device_ops wlan_mon_drv_ops = {
5165 .ndo_open = hdd_mon_open,
5166 .ndo_stop = hdd_stop,
5167 .ndo_uninit = hdd_uninit,
5168 .ndo_start_xmit = hdd_mon_hard_start_xmit,
5169 .ndo_tx_timeout = hdd_tx_timeout,
5170 .ndo_get_stats = hdd_stats,
5171 .ndo_do_ioctl = hdd_ioctl,
5172 .ndo_set_mac_address = hdd_set_mac_address,
5173 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005174
5175#endif
5176
5177void hdd_set_station_ops( struct net_device *pWlanDev )
5178{
5179#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 pWlanDev->netdev_ops = &wlan_drv_ops;
5181#else
5182 pWlanDev->open = hdd_open;
5183 pWlanDev->stop = hdd_stop;
5184 pWlanDev->uninit = hdd_uninit;
5185 pWlanDev->hard_start_xmit = NULL;
5186 pWlanDev->tx_timeout = hdd_tx_timeout;
5187 pWlanDev->get_stats = hdd_stats;
5188 pWlanDev->do_ioctl = hdd_ioctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 pWlanDev->set_mac_address = hdd_set_mac_address;
5190#endif
5191}
5192
Jeff Johnsoneed415b2013-01-18 16:11:20 -08005193static hdd_adapter_t* hdd_alloc_station_adapter( hdd_context_t *pHddCtx, tSirMacAddr macAddr, const char* name )
Jeff Johnson295189b2012-06-20 16:38:30 -07005194{
5195 struct net_device *pWlanDev = NULL;
5196 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 /*
5198 * cfg80211 initialization and registration....
5199 */
5200 pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES);
5201
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 if(pWlanDev != NULL)
5203 {
5204
5205 //Save the pointer to the net_device in the HDD adapter
5206 pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev );
5207
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) );
5209
5210 pAdapter->dev = pWlanDev;
5211 pAdapter->pHddCtx = pHddCtx;
5212 pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
5213
5214 init_completion(&pAdapter->session_open_comp_var);
5215 init_completion(&pAdapter->session_close_comp_var);
5216 init_completion(&pAdapter->disconnect_comp_var);
5217 init_completion(&pAdapter->linkup_event_var);
5218 init_completion(&pAdapter->cancel_rem_on_chan_var);
5219 init_completion(&pAdapter->rem_on_chan_ready_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07005220#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5221 init_completion(&pAdapter->offchannel_tx_event);
5222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 init_completion(&pAdapter->tx_action_cnf_event);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005224#ifdef FEATURE_WLAN_TDLS
5225 init_completion(&pAdapter->tdls_add_station_comp);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07005226 init_completion(&pAdapter->tdls_del_station_comp);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08005227 init_completion(&pAdapter->tdls_mgmt_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305228 init_completion(&pAdapter->tdls_link_establish_req_comp);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005229#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 init_completion(&pHddCtx->mc_sus_event_var);
5231 init_completion(&pHddCtx->tx_sus_event_var);
Gopichand Nakkala05621412013-06-19 19:37:38 +05305232 init_completion(&pHddCtx->rx_sus_event_var);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07005233 init_completion(&pAdapter->ula_complete);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07005234 init_completion(&pAdapter->change_country_code);
Jeff Johnson295189b2012-06-20 16:38:30 -07005235
Rajeev79dbe4c2013-10-05 11:03:42 +05305236#ifdef FEATURE_WLAN_BATCH_SCAN
5237 init_completion(&pAdapter->hdd_set_batch_scan_req_var);
5238 init_completion(&pAdapter->hdd_get_batch_scan_req_var);
5239 pAdapter->pBatchScanRsp = NULL;
5240 pAdapter->numScanList = 0;
Rajeev Kumar20140c12013-10-21 19:39:02 -07005241 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08005242 pAdapter->prev_batch_id = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05305243 mutex_init(&pAdapter->hdd_batch_scan_lock);
5244#endif
5245
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 pAdapter->isLinkUpSvcNeeded = FALSE;
5247 pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE;
5248 //Init the net_device structure
5249 strlcpy(pWlanDev->name, name, IFNAMSIZ);
5250
5251 vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr));
5252 vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr));
5253 pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT;
5254 pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM;
5255
5256 hdd_set_station_ops( pAdapter->dev );
5257
5258 pWlanDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 pWlanDev->ieee80211_ptr = &pAdapter->wdev ;
5260 pAdapter->wdev.wiphy = pHddCtx->wiphy;
5261 pAdapter->wdev.netdev = pWlanDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 /* set pWlanDev's parent to underlying device */
5263 SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev);
5264 }
5265
5266 return pAdapter;
5267}
5268
5269VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5270{
5271 struct net_device *pWlanDev = pAdapter->dev;
5272 //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
5273 //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5274 //eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5275
5276 if( rtnl_lock_held )
5277 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005278 if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 )
5280 {
5281 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__);
5282 return VOS_STATUS_E_FAILURE;
5283 }
5284 }
5285 if (register_netdevice(pWlanDev))
5286 {
5287 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__);
5288 return VOS_STATUS_E_FAILURE;
5289 }
5290 }
5291 else
5292 {
5293 if(register_netdev(pWlanDev))
5294 {
5295 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__);
5296 return VOS_STATUS_E_FAILURE;
5297 }
5298 }
5299 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5300
5301 return VOS_STATUS_SUCCESS;
5302}
5303
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005304static eHalStatus hdd_smeCloseSessionCallback(void *pContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07005305{
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005306 hdd_adapter_t *pAdapter = pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005308 if (NULL == pAdapter)
5309 {
5310 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__);
5311 return eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 }
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005313
5314 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5315 {
5316 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__);
5317 return eHAL_STATUS_NOT_INITIALIZED;
5318 }
5319
5320 clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
5321
Sameer Thalappilbee426e2013-10-30 10:30:30 -07005322#ifndef WLAN_OPEN_SOURCE
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005323 /* need to make sure all of our scheduled work has completed.
5324 * This callback is called from MC thread context, so it is safe to
5325 * to call below flush workqueue API from here.
Sameer Thalappilbee426e2013-10-30 10:30:30 -07005326 *
5327 * Even though this is called from MC thread context, if there is a faulty
5328 * work item in the system, that can hang this call forever. So flushing
5329 * this global work queue is not safe; and now we make sure that
5330 * individual work queues are stopped correctly. But the cancel work queue
5331 * is a GPL only API, so the proprietary version of the driver would still
5332 * rely on the global work queue flush.
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005333 */
5334 flush_scheduled_work();
Sameer Thalappilbee426e2013-10-30 10:30:30 -07005335#endif
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005336
5337 /* We can be blocked while waiting for scheduled work to be
5338 * flushed, and the adapter structure can potentially be freed, in
5339 * which case the magic will have been reset. So make sure the
5340 * magic is still good, and hence the adapter structure is still
5341 * valid, before signaling completion */
5342 if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic)
5343 {
5344 complete(&pAdapter->session_close_comp_var);
5345 }
5346
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 return eHAL_STATUS_SUCCESS;
5348}
5349
5350VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter )
5351{
5352 struct net_device *pWlanDev = pAdapter->dev;
5353 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
5354 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5355 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5356 VOS_STATUS status = VOS_STATUS_E_FAILURE;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305357 long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005358
5359 INIT_COMPLETION(pAdapter->session_open_comp_var);
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005360 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 //Open a SME session for future operation
5362 halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005363 (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 if ( !HAL_STATUS_SUCCESS( halStatus ) )
5365 {
5366 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005367 "sme_OpenSession() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 halStatus, halStatus );
5369 status = VOS_STATUS_E_FAILURE;
5370 goto error_sme_open;
5371 }
5372
5373 //Block on a completion variable. Can't wait forever though.
5374 rc = wait_for_completion_interruptible_timeout(
5375 &pAdapter->session_open_comp_var,
5376 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305377 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 {
5379 hddLog(VOS_TRACE_LEVEL_FATAL,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305380 "Session is not opened within timeout period code %ld", rc );
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 status = VOS_STATUS_E_FAILURE;
5382 goto error_sme_open;
5383 }
5384
5385 // Register wireless extensions
5386 if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev)))
5387 {
5388 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005389 "hdd_register_wext() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 halStatus, halStatus );
5391 status = VOS_STATUS_E_FAILURE;
5392 goto error_register_wext;
5393 }
5394 //Safe to register the hard_start_xmit function again
5395#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
5396 wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit;
5397#else
5398 pWlanDev->hard_start_xmit = hdd_hard_start_xmit;
5399#endif
5400
5401 //Set the Connection State to Not Connected
5402 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5403
5404 //Set the default operation channel
5405 pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel;
5406
5407 /* Make the default Auth Type as OPEN*/
5408 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5409
5410 if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) )
5411 {
5412 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005413 "hdd_init_tx_rx() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 status, status );
5415 goto error_init_txrx;
5416 }
5417
5418 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
5419
5420 if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) )
5421 {
5422 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005423 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 status, status );
5425 goto error_wmm_init;
5426 }
5427
5428 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5429
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005430#ifdef FEATURE_WLAN_TDLS
5431 if(0 != wlan_hdd_tdls_init(pAdapter))
5432 {
5433 status = VOS_STATUS_E_FAILURE;
5434 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_tdls_init failed",__func__);
5435 goto error_tdls_init;
5436 }
5437 set_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
5438#endif
5439
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 return VOS_STATUS_SUCCESS;
5441
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005442#ifdef FEATURE_WLAN_TDLS
5443error_tdls_init:
5444 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5445 hdd_wmm_adapter_close(pAdapter);
5446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005447error_wmm_init:
5448 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
5449 hdd_deinit_tx_rx(pAdapter);
5450error_init_txrx:
5451 hdd_UnregisterWext(pWlanDev);
5452error_register_wext:
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005453 if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 {
5455 INIT_COMPLETION(pAdapter->session_close_comp_var);
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005456 if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 pAdapter->sessionId,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005458 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305460 unsigned long rc;
5461
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305463 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 &pAdapter->session_close_comp_var,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005465 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305466 if (rc <= 0)
5467 hddLog(VOS_TRACE_LEVEL_ERROR,
5468 FL("Session is not opened within timeout period code %ld"), rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 }
5470}
5471error_sme_open:
5472 return status;
5473}
5474
Jeff Johnson295189b2012-06-20 16:38:30 -07005475void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
5476{
5477 hdd_cfg80211_state_t *cfgState;
5478
5479 cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
5480
5481 if( NULL != cfgState->buf )
5482 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305483 long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 INIT_COMPLETION(pAdapter->tx_action_cnf_event);
5485 rc = wait_for_completion_interruptible_timeout(
5486 &pAdapter->tx_action_cnf_event,
5487 msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305488 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 {
Sudhir Sattayappa Kohalli8ee532d2013-02-15 13:16:26 -08005490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305491 "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld"
5492 , __func__, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 }
5494 }
5495 return;
5496}
Jeff Johnson295189b2012-06-20 16:38:30 -07005497
5498void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
5499{
5500 ENTER();
5501 switch ( pAdapter->device_mode )
5502 {
5503 case WLAN_HDD_INFRA_STATION:
5504 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07005505 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 {
5507 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
5508 {
5509 hdd_deinit_tx_rx( pAdapter );
5510 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
5511 }
5512
5513 if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
5514 {
5515 hdd_wmm_adapter_close( pAdapter );
5516 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5517 }
5518
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005520#ifdef FEATURE_WLAN_TDLS
5521 if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags))
5522 {
5523 wlan_hdd_tdls_exit(pAdapter);
5524 clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
5525 }
5526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005527
5528 break;
5529 }
5530
5531 case WLAN_HDD_SOFTAP:
5532 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 {
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05305534
5535 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
5536 {
5537 hdd_wmm_adapter_close( pAdapter );
5538 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
5539 }
5540
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005542
5543 hdd_unregister_hostapd(pAdapter);
5544 hdd_set_conparam( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 break;
5547 }
5548
5549 case WLAN_HDD_MONITOR:
5550 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
5553 {
5554 hdd_deinit_tx_rx( pAdapter );
5555 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
5556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 if(NULL != pAdapterforTx)
5558 {
5559 hdd_cleanup_actionframe(pHddCtx, pAdapterforTx);
5560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 break;
5562 }
5563
5564
5565 default:
5566 break;
5567 }
5568
5569 EXIT();
5570}
5571
5572void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held )
5573{
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005574 struct net_device *pWlanDev = NULL;
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05305575
5576 ENTER();
5577 if (NULL == pAdapter)
5578 {
5579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5580 "%s: HDD adapter is Null", __func__);
5581 return;
5582 }
5583
5584 pWlanDev = pAdapter->dev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005585
Rajeev79dbe4c2013-10-05 11:03:42 +05305586#ifdef FEATURE_WLAN_BATCH_SCAN
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05305587 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
5588 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Rajeev Kumarf999e582014-01-09 17:33:29 -08005589 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05305590 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
5591 )
5592 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08005593 if (pAdapter)
Rajeev79dbe4c2013-10-05 11:03:42 +05305594 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08005595 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
5596 {
5597 hdd_deinit_batch_scan(pAdapter);
5598 }
Rajeev79dbe4c2013-10-05 11:03:42 +05305599 }
Rajeev Kumarf999e582014-01-09 17:33:29 -08005600 }
Rajeev79dbe4c2013-10-05 11:03:42 +05305601#endif
5602
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) {
5604 if( rtnl_held )
5605 {
5606 unregister_netdevice(pWlanDev);
5607 }
5608 else
5609 {
5610 unregister_netdev(pWlanDev);
5611 }
5612 // note that the pAdapter is no longer valid at this point
5613 // since the memory has been reclaimed
5614 }
5615
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05305616 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005617}
5618
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005619void hdd_set_pwrparams(hdd_context_t *pHddCtx)
5620{
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305621 VOS_STATUS status;
5622 hdd_adapter_t *pAdapter = NULL;
5623 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005624
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305625 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005626
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305627 /*loop through all adapters.*/
5628 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005629 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305630 pAdapter = pAdapterNode->pAdapter;
5631 if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
5632 && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005633
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305634 { // we skip this registration for modes other than STA and P2P client modes.
5635 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5636 pAdapterNode = pNext;
5637 continue;
5638 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005639
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305640 //Apply Dynamic DTIM For P2P
5641 //Only if ignoreDynamicDtimInP2pMode is not set in ini
5642 if ((pHddCtx->cfg_ini->enableDynamicDTIM ||
5643 pHddCtx->cfg_ini->enableModulatedDTIM) &&
5644 ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5645 ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) &&
5646 !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) &&
5647 (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) &&
5648 (eConnectionState_Associated ==
5649 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) &&
5650 (pHddCtx->cfg_ini->fIsBmpsEnabled))
5651 {
5652 tSirSetPowerParamsReq powerRequest = { 0 };
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005653
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305654 powerRequest.uIgnoreDTIM = 1;
5655 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
5656
5657 if (pHddCtx->cfg_ini->enableModulatedDTIM)
5658 {
5659 powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM;
5660 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
5661 }
5662 else
5663 {
5664 powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM;
5665 }
5666
5667 /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM
5668 * specified during Enter/Exit BMPS when LCD off*/
5669 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
5670 NULL, eANI_BOOLEAN_FALSE);
5671 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
5672 NULL, eANI_BOOLEAN_FALSE);
5673
5674 /* switch to the DTIM specified in cfg.ini */
5675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5676 "Switch to DTIM %d", powerRequest.uListenInterval);
5677 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
5678 break;
5679
5680 }
5681
5682 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5683 pAdapterNode = pNext;
5684 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005685}
5686
5687void hdd_reset_pwrparams(hdd_context_t *pHddCtx)
5688{
5689 /*Switch back to DTIM 1*/
5690 tSirSetPowerParamsReq powerRequest = { 0 };
5691
5692 powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value;
5693 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
Yue Mac24062f2013-05-13 17:01:29 -07005694 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005695
5696 /* Update ignoreDTIM and ListedInterval in CFG with default values */
5697 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
5698 NULL, eANI_BOOLEAN_FALSE);
5699 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
5700 NULL, eANI_BOOLEAN_FALSE);
5701
5702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5703 "Switch to DTIM%d",powerRequest.uListenInterval);
5704 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
5705
5706}
5707
Jeff Johnson295189b2012-06-20 16:38:30 -07005708VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx)
5709{
5710 VOS_STATUS status = VOS_STATUS_SUCCESS;
5711
5712 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
5713 {
5714 sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
5715 }
5716
5717 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
5718 {
5719 sme_StartAutoBmpsTimer(pHddCtx->hHal);
5720 }
5721
5722 if (pHddCtx->cfg_ini->fIsImpsEnabled)
5723 {
5724 sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
5725 }
5726
5727 return status;
5728}
5729
5730VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type)
5731{
5732 hdd_adapter_t *pAdapter = NULL;
5733 eHalStatus halStatus;
5734 VOS_STATUS status = VOS_STATUS_E_INVAL;
5735 v_BOOL_t disableBmps = FALSE;
5736 v_BOOL_t disableImps = FALSE;
5737
5738 switch(session_type)
5739 {
5740 case WLAN_HDD_INFRA_STATION:
5741 case WLAN_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 case WLAN_HDD_P2P_CLIENT:
5743 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 //Exit BMPS -> Is Sta/P2P Client is already connected
5745 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
5746 if((NULL != pAdapter)&&
5747 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5748 {
5749 disableBmps = TRUE;
5750 }
5751
5752 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
5753 if((NULL != pAdapter)&&
5754 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5755 {
5756 disableBmps = TRUE;
5757 }
5758
5759 //Exit both Bmps and Imps incase of Go/SAP Mode
5760 if((WLAN_HDD_SOFTAP == session_type) ||
5761 (WLAN_HDD_P2P_GO == session_type))
5762 {
5763 disableBmps = TRUE;
5764 disableImps = TRUE;
5765 }
5766
5767 if(TRUE == disableImps)
5768 {
5769 if (pHddCtx->cfg_ini->fIsImpsEnabled)
5770 {
5771 sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
5772 }
5773 }
5774
5775 if(TRUE == disableBmps)
5776 {
5777 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
5778 {
5779 halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
5780
5781 if(eHAL_STATUS_SUCCESS != halStatus)
5782 {
5783 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005784 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 VOS_ASSERT(0);
5786 return status;
5787 }
5788 }
5789
5790 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
5791 {
5792 halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal);
5793
5794 if(eHAL_STATUS_SUCCESS != halStatus)
5795 {
5796 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005797 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Stop Auto Bmps Timer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 VOS_ASSERT(0);
5799 return status;
5800 }
5801 }
5802 }
5803
5804 if((TRUE == disableBmps) ||
5805 (TRUE == disableImps))
5806 {
5807 /* Now, get the chip into Full Power now */
5808 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
5809 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk,
5810 pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD);
5811
5812 if(halStatus != eHAL_STATUS_SUCCESS)
5813 {
5814 if(halStatus == eHAL_STATUS_PMC_PENDING)
5815 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305816 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 //Block on a completion variable. Can't wait forever though
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305818 ret = wait_for_completion_interruptible_timeout(
5819 &pHddCtx->full_pwr_comp_var,
5820 msecs_to_jiffies(1000));
5821 if (ret <= 0)
5822 {
5823 hddLog(VOS_TRACE_LEVEL_ERROR,
5824 "%s: wait on full_pwr_comp_var failed %ld",
5825 __func__, ret);
5826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 }
5828 else
5829 {
5830 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005831 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 VOS_ASSERT(0);
5833 return status;
5834 }
5835 }
5836
5837 status = VOS_STATUS_SUCCESS;
5838 }
5839
5840 break;
5841 }
5842 return status;
5843}
5844
5845hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type,
Jeff Johnsoneed415b2013-01-18 16:11:20 -08005846 const char *iface_name, tSirMacAddr macAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 tANI_U8 rtnl_held )
5848{
5849 hdd_adapter_t *pAdapter = NULL;
5850 hdd_adapter_list_node_t *pHddAdapterNode = NULL;
5851 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5852 VOS_STATUS exitbmpsStatus;
5853
Arif Hussain6d2a3322013-11-17 19:50:10 -08005854 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s iface =%s type = %d",__func__,iface_name,session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07005855
5856 //Disable BMPS incase of Concurrency
5857 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type);
5858
5859 if(VOS_STATUS_E_FAILURE == exitbmpsStatus)
5860 {
5861 //Fail to Exit BMPS
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305862 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 VOS_ASSERT(0);
5864 return NULL;
5865 }
5866
5867 switch(session_type)
5868 {
5869 case WLAN_HDD_INFRA_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07005871 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 {
5873 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
5874
5875 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305876 {
5877 hddLog(VOS_TRACE_LEVEL_FATAL,
5878 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005881
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05305882#ifdef FEATURE_WLAN_TDLS
5883 /* A Mutex Lock is introduced while changing/initializing the mode to
5884 * protect the concurrent access for the Adapters by TDLS module.
5885 */
5886 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
5887 {
5888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5889 "%s: unable to lock list", __func__);
5890 return NULL;
5891 }
5892#endif
5893
Jeff Johnsone7245742012-09-05 17:12:55 -07005894 pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ?
5895 NL80211_IFTYPE_P2P_CLIENT:
5896 NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07005897
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 pAdapter->device_mode = session_type;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05305899#ifdef FEATURE_WLAN_TDLS
5900 mutex_unlock(&pHddCtx->tdls_lock);
5901#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05305902
5903 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 if( VOS_STATUS_SUCCESS != status )
5905 goto err_free_netdev;
5906
5907 status = hdd_register_interface( pAdapter, rtnl_held );
5908 if( VOS_STATUS_SUCCESS != status )
5909 {
5910 hdd_deinit_adapter(pHddCtx, pAdapter);
5911 goto err_free_netdev;
5912 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05305913
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05305914 // Workqueue which gets scheduled in IPv4 notification callback.
5915 INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue);
5916
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05305917#ifdef WLAN_NS_OFFLOAD
5918 // Workqueue which gets scheduled in IPv6 notification callback.
5919 INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue);
5920#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 //Stop the Interface TX queue.
5922 netif_tx_disable(pAdapter->dev);
5923 //netif_tx_disable(pWlanDev);
5924 netif_carrier_off(pAdapter->dev);
5925
5926 break;
5927 }
5928
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 case WLAN_HDD_SOFTAP:
5931 {
5932 pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name );
5933 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305934 {
5935 hddLog(VOS_TRACE_LEVEL_FATAL,
5936 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005939
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ?
5941 NL80211_IFTYPE_AP:
5942 NL80211_IFTYPE_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 pAdapter->device_mode = session_type;
5944
5945 status = hdd_init_ap_mode(pAdapter);
5946 if( VOS_STATUS_SUCCESS != status )
5947 goto err_free_netdev;
5948
5949 status = hdd_register_hostapd( pAdapter, rtnl_held );
5950 if( VOS_STATUS_SUCCESS != status )
5951 {
5952 hdd_deinit_adapter(pHddCtx, pAdapter);
5953 goto err_free_netdev;
5954 }
5955
5956 netif_tx_disable(pAdapter->dev);
5957 netif_carrier_off(pAdapter->dev);
5958
5959 hdd_set_conparam( 1 );
5960 break;
5961 }
5962 case WLAN_HDD_MONITOR:
5963 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
5965 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305966 {
5967 hddLog(VOS_TRACE_LEVEL_FATAL,
5968 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005971
5972 pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR;
5973 pAdapter->device_mode = session_type;
5974 status = hdd_register_interface( pAdapter, rtnl_held );
5975#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
5976 pAdapter->dev->netdev_ops = &wlan_mon_drv_ops;
5977#else
5978 pAdapter->dev->open = hdd_mon_open;
5979 pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit;
5980#endif
5981 hdd_init_tx_rx( pAdapter );
5982 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
5983 //Set adapter to be used for data tx. It will use either GO or softap.
5984 pAdapter->sessionCtx.monitor.pAdapterForTx =
5985 hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx)
5987 {
5988 pAdapter->sessionCtx.monitor.pAdapterForTx =
5989 hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO);
5990 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 /* This workqueue will be used to transmit management packet over
5992 * monitor interface. */
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07005993 if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) {
5994 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__);
5995 return NULL;
5996 }
Madan Mohan Koyyalamudi9f40ceb2012-10-18 19:22:56 -07005997
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue,
5999 hdd_mon_tx_work_queue);
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 }
6001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 case WLAN_HDD_FTM:
6003 {
6004 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6005
6006 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306007 {
6008 hddLog(VOS_TRACE_LEVEL_FATAL,
6009 FL("failed to allocate adapter for session %d"), session_type);
6010 return NULL;
6011 }
6012
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning
6014 * message while loading driver in FTM mode. */
6015 pAdapter->wdev.iftype = NL80211_IFTYPE_STATION;
6016 pAdapter->device_mode = session_type;
6017 status = hdd_register_interface( pAdapter, rtnl_held );
Madan Mohan Koyyalamudif89ac9f2013-09-19 16:58:12 +05306018
6019 hdd_init_tx_rx( pAdapter );
6020
6021 //Stop the Interface TX queue.
6022 netif_tx_disable(pAdapter->dev);
6023 netif_carrier_off(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 }
6025 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 default:
6027 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306028 hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d",
6029 __func__, session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 VOS_ASSERT(0);
6031 return NULL;
6032 }
6033 }
6034
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 if( VOS_STATUS_SUCCESS == status )
6036 {
6037 //Add it to the hdd's session list.
6038 pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) );
6039 if( NULL == pHddAdapterNode )
6040 {
6041 status = VOS_STATUS_E_NOMEM;
6042 }
6043 else
6044 {
6045 pHddAdapterNode->pAdapter = pAdapter;
6046 status = hdd_add_adapter_back ( pHddCtx,
6047 pHddAdapterNode );
6048 }
6049 }
6050
6051 if( VOS_STATUS_SUCCESS != status )
6052 {
6053 if( NULL != pAdapter )
6054 {
6055 hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held );
6056 pAdapter = NULL;
6057 }
6058 if( NULL != pHddAdapterNode )
6059 {
6060 vos_mem_free( pHddAdapterNode );
6061 }
6062
6063 goto resume_bmps;
6064 }
6065
6066 if(VOS_STATUS_SUCCESS == status)
6067 {
6068 wlan_hdd_set_concurrency_mode(pHddCtx, session_type);
6069
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006070 //Initialize the WoWL service
6071 if(!hdd_init_wowl(pAdapter))
6072 {
6073 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__);
6074 goto err_free_netdev;
6075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 return pAdapter;
6078
6079err_free_netdev:
6080 free_netdev(pAdapter->dev);
6081 wlan_hdd_release_intf_addr( pHddCtx,
6082 pAdapter->macAddressCurrent.bytes );
6083
6084resume_bmps:
6085 //If bmps disabled enable it
6086 if(VOS_STATUS_SUCCESS == exitbmpsStatus)
6087 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306088 if (pHddCtx->hdd_wlan_suspended)
6089 {
6090 hdd_set_pwrparams(pHddCtx);
6091 }
6092 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 }
6094 return NULL;
6095}
6096
6097VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
6098 tANI_U8 rtnl_held )
6099{
6100 hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext;
6101 VOS_STATUS status;
6102
6103 status = hdd_get_front_adapter ( pHddCtx, &pCurrent );
6104 if( VOS_STATUS_SUCCESS != status )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306105 {
6106 hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d",
6107 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006110
6111 while ( pCurrent->pAdapter != pAdapter )
6112 {
6113 status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext );
6114 if( VOS_STATUS_SUCCESS != status )
6115 break;
6116
6117 pCurrent = pNext;
6118 }
6119 pAdapterNode = pCurrent;
6120 if( VOS_STATUS_SUCCESS == status )
6121 {
6122 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
6123 hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306124
6125#ifdef FEATURE_WLAN_TDLS
6126
6127 /* A Mutex Lock is introduced while changing/initializing the mode to
6128 * protect the concurrent access for the Adapters by TDLS module.
6129 */
6130 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
6131 {
6132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6133 "%s: unable to lock list", __func__);
6134 return VOS_STATUS_E_FAILURE;
6135 }
6136#endif
6137
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 hdd_remove_adapter( pHddCtx, pAdapterNode );
6139 vos_mem_free( pAdapterNode );
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08006140 pAdapterNode = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006141
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306142#ifdef FEATURE_WLAN_TDLS
6143 mutex_unlock(&pHddCtx->tdls_lock);
6144#endif
6145
Jeff Johnson295189b2012-06-20 16:38:30 -07006146
6147 /* If there is a single session of STA/P2P client, re-enable BMPS */
6148 if ((!vos_concurrent_sessions_running()) &&
6149 ((pHddCtx->no_of_sessions[VOS_STA_MODE] >= 1) ||
6150 (pHddCtx->no_of_sessions[VOS_P2P_CLIENT_MODE] >= 1)))
6151 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306152 if (pHddCtx->hdd_wlan_suspended)
6153 {
6154 hdd_set_pwrparams(pHddCtx);
6155 }
6156 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 }
6158
6159 return VOS_STATUS_SUCCESS;
6160 }
6161
6162 return VOS_STATUS_E_FAILURE;
6163}
6164
6165VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx )
6166{
6167 hdd_adapter_list_node_t *pHddAdapterNode;
6168 VOS_STATUS status;
6169
6170 ENTER();
6171
6172 do
6173 {
6174 status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode );
6175 if( pHddAdapterNode && VOS_STATUS_SUCCESS == status )
6176 {
6177 hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE );
6178 vos_mem_free( pHddAdapterNode );
6179 }
6180 }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status );
6181
6182 EXIT();
6183
6184 return VOS_STATUS_SUCCESS;
6185}
6186
6187void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter)
6188{
6189 v_U8_t addIE[1] = {0};
6190
6191 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6192 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL,
6193 eANI_BOOLEAN_FALSE) )
6194 {
6195 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006196 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 }
6198
6199 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6200 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6201 eANI_BOOLEAN_FALSE) )
6202 {
6203 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006204 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 }
6206
6207 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6208 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6209 eANI_BOOLEAN_FALSE) )
6210 {
6211 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006212 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 }
6214}
6215
6216VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
6217{
6218 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
6219 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6220 union iwreq_data wrqu;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306221 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006222
6223 ENTER();
6224
6225 switch(pAdapter->device_mode)
6226 {
6227 case WLAN_HDD_INFRA_STATION:
6228 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006229 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) )
6231 {
6232 if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS)
6233 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
6234 pAdapter->sessionId,
6235 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6236 else
6237 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
6238 pAdapter->sessionId,
6239 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6240 //success implies disconnect command got queued up successfully
6241 if(halStatus == eHAL_STATUS_SUCCESS)
6242 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306243 ret = wait_for_completion_interruptible_timeout(
6244 &pAdapter->disconnect_comp_var,
6245 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6246 if (ret <= 0)
6247 {
6248 hddLog(VOS_TRACE_LEVEL_ERROR,
6249 "%s: wait on disconnect_comp_var failed %ld",
6250 __func__, ret);
6251 }
6252 }
6253 else
6254 {
6255 hddLog(LOGE, "%s: failed to post disconnect event to SME",
6256 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 }
6258 memset(&wrqu, '\0', sizeof(wrqu));
6259 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
6260 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
6261 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
6262 }
6263 else
6264 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306265 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
6266 eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306268#ifdef WLAN_NS_OFFLOAD
Vinay Krishna Eranna941360f2014-01-16 15:38:22 +05306269#ifdef WLAN_OPEN_SOURCE
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306270 cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue);
6271#endif
Vinay Krishna Eranna941360f2014-01-16 15:38:22 +05306272 if (pAdapter->ipv6_notifier_registered)
6273 {
6274 hddLog(LOG1, FL("Unregistered IPv6 notifier"));
6275 unregister_inet6addr_notifier(&pAdapter->ipv6_notifier);
6276 pAdapter->ipv6_notifier_registered = false;
6277 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306278#endif
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +05306279 if (pAdapter->ipv4_notifier_registered)
6280 {
6281 hddLog(LOG1, FL("Unregistered IPv4 notifier"));
6282 unregister_inetaddr_notifier(&pAdapter->ipv4_notifier);
6283 pAdapter->ipv4_notifier_registered = false;
6284 }
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306285#ifdef WLAN_OPEN_SOURCE
6286 cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue);
6287#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
6289 {
6290 INIT_COMPLETION(pAdapter->session_close_comp_var);
6291 if (eHAL_STATUS_SUCCESS ==
6292 sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId,
6293 hdd_smeCloseSessionCallback, pAdapter))
6294 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306295 unsigned long ret;
6296
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306298 ret = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 &pAdapter->session_close_comp_var,
6300 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306301 if ( 0 >= ret)
6302 {
6303 hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld",
6304 __func__, ret);
6305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 }
6307 }
6308
6309 break;
6310
6311 case WLAN_HDD_SOFTAP:
6312 case WLAN_HDD_P2P_GO:
6313 //Any softap specific cleanup here...
6314 mutex_lock(&pHddCtx->sap_lock);
6315 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6316 {
6317 VOS_STATUS status;
6318 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6319
6320 //Stop Bss.
6321 status = WLANSAP_StopBss(pHddCtx->pvosContext);
6322 if (VOS_IS_STATUS_SUCCESS(status))
6323 {
6324 hdd_hostapd_state_t *pHostapdState =
6325 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6326
6327 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6328
6329 if (!VOS_IS_STATUS_SUCCESS(status))
6330 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306331 hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d",
6332 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 }
6334 }
6335 else
6336 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006337 hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
6339 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
6340
6341 if (eHAL_STATUS_FAILURE ==
6342 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG,
6343 0, NULL, eANI_BOOLEAN_FALSE))
6344 {
6345 hddLog(LOGE,
6346 "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006347 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 }
6349
6350 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6351 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6352 eANI_BOOLEAN_FALSE) )
6353 {
6354 hddLog(LOGE,
6355 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
6356 }
6357
6358 // Reset WNI_CFG_PROBE_RSP Flags
6359 wlan_hdd_reset_prob_rspies(pAdapter);
6360 kfree(pAdapter->sessionCtx.ap.beacon);
6361 pAdapter->sessionCtx.ap.beacon = NULL;
6362 }
6363 mutex_unlock(&pHddCtx->sap_lock);
6364 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006365
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 case WLAN_HDD_MONITOR:
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006367#ifdef WLAN_OPEN_SOURCE
6368 cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue);
6369#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006371
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 default:
6373 break;
6374 }
6375
6376 EXIT();
6377 return VOS_STATUS_SUCCESS;
6378}
6379
6380VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx )
6381{
6382 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6383 VOS_STATUS status;
6384 hdd_adapter_t *pAdapter;
6385
6386 ENTER();
6387
6388 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6389
6390 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6391 {
6392 pAdapter = pAdapterNode->pAdapter;
6393 netif_tx_disable(pAdapter->dev);
6394 netif_carrier_off(pAdapter->dev);
6395
6396 hdd_stop_adapter( pHddCtx, pAdapter );
6397
6398 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6399 pAdapterNode = pNext;
6400 }
6401
6402 EXIT();
6403
6404 return VOS_STATUS_SUCCESS;
6405}
6406
Rajeev Kumarf999e582014-01-09 17:33:29 -08006407
6408#ifdef FEATURE_WLAN_BATCH_SCAN
6409/**---------------------------------------------------------------------------
6410
6411 \brief hdd_deinit_batch_scan () - This function cleans up batch scan data
6412 structures
6413
6414 \param - pAdapter Pointer to HDD adapter
6415
6416 \return - None
6417
6418 --------------------------------------------------------------------------*/
6419void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter)
6420{
6421 tHddBatchScanRsp *pNode;
6422 tHddBatchScanRsp *pPrev;
6423
6424 if (pAdapter)
6425 {
6426 pNode = pAdapter->pBatchScanRsp;
6427 while (pNode)
6428 {
6429 pPrev = pNode;
6430 pNode = pNode->pNext;
6431 vos_mem_free((v_VOID_t * )pPrev);
6432 }
6433 pAdapter->pBatchScanRsp = NULL;
6434 }
6435
6436 pAdapter->pBatchScanRsp = NULL;
6437 pAdapter->numScanList = 0;
6438 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
6439 pAdapter->prev_batch_id = 0;
6440
6441 return;
6442}
6443#endif
6444
6445
Jeff Johnson295189b2012-06-20 16:38:30 -07006446VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx )
6447{
6448 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6449 VOS_STATUS status;
6450 hdd_adapter_t *pAdapter;
6451
6452 ENTER();
6453
6454 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6455
6456 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6457 {
6458 pAdapter = pAdapterNode->pAdapter;
6459 netif_tx_disable(pAdapter->dev);
6460 netif_carrier_off(pAdapter->dev);
6461
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07006462 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
6463
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 hdd_deinit_tx_rx(pAdapter);
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05306465 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6466 {
6467 hdd_wmm_adapter_close( pAdapter );
6468 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006470
Rajeev Kumarf999e582014-01-09 17:33:29 -08006471#ifdef FEATURE_WLAN_BATCH_SCAN
6472 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
6473 {
6474 hdd_deinit_batch_scan(pAdapter);
6475 }
6476#endif
6477
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6479 pAdapterNode = pNext;
6480 }
6481
6482 EXIT();
6483
6484 return VOS_STATUS_SUCCESS;
6485}
6486
6487VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx )
6488{
6489 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6490 VOS_STATUS status;
6491 hdd_adapter_t *pAdapter;
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05306492 eConnectionState connState;
Jeff Johnson295189b2012-06-20 16:38:30 -07006493
6494 ENTER();
6495
6496 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6497
6498 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6499 {
6500 pAdapter = pAdapterNode->pAdapter;
6501
6502 switch(pAdapter->device_mode)
6503 {
6504 case WLAN_HDD_INFRA_STATION:
6505 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006506 case WLAN_HDD_P2P_DEVICE:
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05306507
6508 connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState;
6509
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 hdd_init_station_mode(pAdapter);
6511 /* Open the gates for HDD to receive Wext commands */
6512 pAdapter->isLinkUpSvcNeeded = FALSE;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006513 pHddCtx->scan_info.mScanPending = FALSE;
6514 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006515
6516 //Trigger the initial scan
6517 hdd_wlan_initial_scan(pAdapter);
6518
6519 //Indicate disconnect event to supplicant if associated previously
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05306520 if (eConnectionState_Associated == connState ||
6521 eConnectionState_IbssConnected == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 {
6523 union iwreq_data wrqu;
6524 memset(&wrqu, '\0', sizeof(wrqu));
6525 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
6526 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
6527 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07006528 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006529
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 /* indicate disconnected event to nl80211 */
6531 cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED,
6532 NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 }
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05306534 else if (eConnectionState_Connecting == connState)
6535 {
6536 /*
6537 * Indicate connect failure to supplicant if we were in the
6538 * process of connecting
6539 */
6540 cfg80211_connect_result(pAdapter->dev, NULL,
6541 NULL, 0, NULL, 0,
6542 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
6543 GFP_KERNEL);
6544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 break;
6546
6547 case WLAN_HDD_SOFTAP:
6548 /* softAP can handle SSR */
6549 break;
6550
6551 case WLAN_HDD_P2P_GO:
Sameer Thalappiledf0d792013-08-09 14:31:03 -07006552 hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant",
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 __func__);
Sameer Thalappiledf0d792013-08-09 14:31:03 -07006554 cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 break;
6556
6557 case WLAN_HDD_MONITOR:
6558 /* monitor interface start */
6559 break;
6560 default:
6561 break;
6562 }
6563
6564 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6565 pAdapterNode = pNext;
6566 }
6567
6568 EXIT();
6569
6570 return VOS_STATUS_SUCCESS;
6571}
6572
6573VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx )
6574{
6575 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6576 hdd_adapter_t *pAdapter;
6577 VOS_STATUS status;
6578 v_U32_t roamId;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306579 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006580
6581 ENTER();
6582
6583 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6584
6585 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6586 {
6587 pAdapter = pAdapterNode->pAdapter;
6588
6589 if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6590 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
6591 {
6592 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6593 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6594
6595 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6596 init_completion(&pAdapter->disconnect_comp_var);
6597 sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId,
6598 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6599
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306600 ret = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 &pAdapter->disconnect_comp_var,
6602 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306603 if (0 >= ret)
6604 hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld",
6605 __func__, ret);
Jeff Johnson295189b2012-06-20 16:38:30 -07006606
6607 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
6608 pHddCtx->isAmpAllowed = VOS_FALSE;
6609 sme_RoamConnect(pHddCtx->hHal,
6610 pAdapter->sessionId, &(pWextState->roamProfile),
6611 &roamId);
6612 }
6613
6614 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6615 pAdapterNode = pNext;
6616 }
6617
6618 EXIT();
6619
6620 return VOS_STATUS_SUCCESS;
6621}
6622
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07006623void hdd_dump_concurrency_info(hdd_context_t *pHddCtx)
6624{
6625 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6626 VOS_STATUS status;
6627 hdd_adapter_t *pAdapter;
6628 hdd_station_ctx_t *pHddStaCtx;
6629 hdd_ap_ctx_t *pHddApCtx;
6630 hdd_hostapd_state_t * pHostapdState;
6631 tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 };
6632 v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0;
6633 const char *p2pMode = "DEV";
6634 const char *ccMode = "Standalone";
6635 int n;
6636
6637 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6638 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6639 {
6640 pAdapter = pAdapterNode->pAdapter;
6641 switch (pAdapter->device_mode) {
6642 case WLAN_HDD_INFRA_STATION:
6643 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6644 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
6645 staChannel = pHddStaCtx->conn_info.operationChannel;
6646 memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid));
6647 }
6648 break;
6649 case WLAN_HDD_P2P_CLIENT:
6650 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6651 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
6652 p2pChannel = pHddStaCtx->conn_info.operationChannel;
6653 memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid));
6654 p2pMode = "CLI";
6655 }
6656 break;
6657 case WLAN_HDD_P2P_GO:
6658 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
6659 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6660 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
6661 p2pChannel = pHddApCtx->operatingChannel;
6662 memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid));
6663 }
6664 p2pMode = "GO";
6665 break;
6666 case WLAN_HDD_SOFTAP:
6667 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
6668 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6669 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
6670 apChannel = pHddApCtx->operatingChannel;
6671 memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid));
6672 }
6673 break;
6674 default:
6675 break;
6676 }
6677 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6678 pAdapterNode = pNext;
6679 }
6680 if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) {
6681 ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC";
6682 }
6683 n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s",
6684 staChannel, MAC_ADDR_ARRAY(staBssid), ccMode);
6685 if (p2pChannel > 0) {
6686 n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR,
6687 p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid));
6688 }
6689 if (apChannel > 0) {
6690 n += pr_info("AP(%d) " MAC_ADDRESS_STR,
6691 apChannel, MAC_ADDR_ARRAY(apBssid));
6692 }
6693
6694 if (p2pChannel > 0 && apChannel > 0) {
6695 hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel);
6696 }
6697}
6698
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07006699bool hdd_is_ssr_required( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07006700{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07006701 return (isSsrRequired == HDD_SSR_REQUIRED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006702}
6703
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07006704/* Once SSR is disabled then it cannot be set. */
6705void hdd_set_ssr_required( e_hdd_ssr_required value)
Jeff Johnson295189b2012-06-20 16:38:30 -07006706{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07006707 if (HDD_SSR_DISABLED == isSsrRequired)
6708 return;
6709
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 isSsrRequired = value;
6711}
6712
6713VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx,
6714 hdd_adapter_list_node_t** ppAdapterNode)
6715{
6716 VOS_STATUS status;
6717 spin_lock(&pHddCtx->hddAdapters.lock);
6718 status = hdd_list_peek_front ( &pHddCtx->hddAdapters,
6719 (hdd_list_node_t**) ppAdapterNode );
6720 spin_unlock(&pHddCtx->hddAdapters.lock);
6721 return status;
6722}
6723
6724VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx,
6725 hdd_adapter_list_node_t* pAdapterNode,
6726 hdd_adapter_list_node_t** pNextAdapterNode)
6727{
6728 VOS_STATUS status;
6729 spin_lock(&pHddCtx->hddAdapters.lock);
6730 status = hdd_list_peek_next ( &pHddCtx->hddAdapters,
6731 (hdd_list_node_t*) pAdapterNode,
6732 (hdd_list_node_t**)pNextAdapterNode );
6733
6734 spin_unlock(&pHddCtx->hddAdapters.lock);
6735 return status;
6736}
6737
6738VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx,
6739 hdd_adapter_list_node_t* pAdapterNode)
6740{
6741 VOS_STATUS status;
6742 spin_lock(&pHddCtx->hddAdapters.lock);
6743 status = hdd_list_remove_node ( &pHddCtx->hddAdapters,
6744 &pAdapterNode->node );
6745 spin_unlock(&pHddCtx->hddAdapters.lock);
6746 return status;
6747}
6748
6749VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx,
6750 hdd_adapter_list_node_t** ppAdapterNode)
6751{
6752 VOS_STATUS status;
6753 spin_lock(&pHddCtx->hddAdapters.lock);
6754 status = hdd_list_remove_front( &pHddCtx->hddAdapters,
6755 (hdd_list_node_t**) ppAdapterNode );
6756 spin_unlock(&pHddCtx->hddAdapters.lock);
6757 return status;
6758}
6759
6760VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx,
6761 hdd_adapter_list_node_t* pAdapterNode)
6762{
6763 VOS_STATUS status;
6764 spin_lock(&pHddCtx->hddAdapters.lock);
6765 status = hdd_list_insert_back ( &pHddCtx->hddAdapters,
6766 (hdd_list_node_t*) pAdapterNode );
6767 spin_unlock(&pHddCtx->hddAdapters.lock);
6768 return status;
6769}
6770
6771VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx,
6772 hdd_adapter_list_node_t* pAdapterNode)
6773{
6774 VOS_STATUS status;
6775 spin_lock(&pHddCtx->hddAdapters.lock);
6776 status = hdd_list_insert_front ( &pHddCtx->hddAdapters,
6777 (hdd_list_node_t*) pAdapterNode );
6778 spin_unlock(&pHddCtx->hddAdapters.lock);
6779 return status;
6780}
6781
6782hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx,
6783 tSirMacAddr macAddr )
6784{
6785 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6786 hdd_adapter_t *pAdapter;
6787 VOS_STATUS status;
6788
6789 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6790
6791 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6792 {
6793 pAdapter = pAdapterNode->pAdapter;
6794
6795 if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes,
6796 macAddr, sizeof(tSirMacAddr) ) )
6797 {
6798 return pAdapter;
6799 }
6800 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6801 pAdapterNode = pNext;
6802 }
6803
6804 return NULL;
6805
6806}
6807
6808hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name )
6809{
6810 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6811 hdd_adapter_t *pAdapter;
6812 VOS_STATUS status;
6813
6814 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6815
6816 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6817 {
6818 pAdapter = pAdapterNode->pAdapter;
6819
6820 if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name,
6821 IFNAMSIZ ) )
6822 {
6823 return pAdapter;
6824 }
6825 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6826 pAdapterNode = pNext;
6827 }
6828
6829 return NULL;
6830
6831}
6832
6833hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode )
6834{
6835 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6836 hdd_adapter_t *pAdapter;
6837 VOS_STATUS status;
6838
6839 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6840
6841 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6842 {
6843 pAdapter = pAdapterNode->pAdapter;
6844
6845 if( pAdapter && (mode == pAdapter->device_mode) )
6846 {
6847 return pAdapter;
6848 }
6849 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6850 pAdapterNode = pNext;
6851 }
6852
6853 return NULL;
6854
6855}
6856
6857//Remove this function later
6858hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx )
6859{
6860 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6861 hdd_adapter_t *pAdapter;
6862 VOS_STATUS status;
6863
6864 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6865
6866 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6867 {
6868 pAdapter = pAdapterNode->pAdapter;
6869
6870 if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode )
6871 {
6872 return pAdapter;
6873 }
6874
6875 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6876 pAdapterNode = pNext;
6877 }
6878
6879 return NULL;
6880
6881}
6882
Jeff Johnson295189b2012-06-20 16:38:30 -07006883/**---------------------------------------------------------------------------
6884
6885 \brief hdd_set_monitor_tx_adapter() -
6886
6887 This API initializes the adapter to be used while transmitting on monitor
6888 adapter.
6889
6890 \param - pHddCtx - Pointer to the HDD context.
6891 pAdapter - Adapter that will used for TX. This can be NULL.
6892 \return - None.
6893 --------------------------------------------------------------------------*/
6894void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
6895{
6896 hdd_adapter_t *pMonAdapter;
6897
6898 pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR );
6899
6900 if( NULL != pMonAdapter )
6901 {
6902 pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter;
6903 }
6904}
Jeff Johnson295189b2012-06-20 16:38:30 -07006905/**---------------------------------------------------------------------------
6906
6907 \brief hdd_select_queue() -
6908
6909 This API returns the operating channel of the requested device mode
6910
6911 \param - pHddCtx - Pointer to the HDD context.
6912 - mode - Device mode for which operating channel is required
6913 suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT
6914 WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO.
6915 \return - channel number. "0" id the requested device is not found OR it is not connected.
6916 --------------------------------------------------------------------------*/
6917v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode )
6918{
6919 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6920 VOS_STATUS status;
6921 hdd_adapter_t *pAdapter;
6922 v_U8_t operatingChannel = 0;
6923
6924 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6925
6926 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6927 {
6928 pAdapter = pAdapterNode->pAdapter;
6929
6930 if( mode == pAdapter->device_mode )
6931 {
6932 switch(pAdapter->device_mode)
6933 {
6934 case WLAN_HDD_INFRA_STATION:
6935 case WLAN_HDD_P2P_CLIENT:
6936 if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) )
6937 operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel;
6938 break;
6939 case WLAN_HDD_SOFTAP:
6940 case WLAN_HDD_P2P_GO:
6941 /*softap connection info */
6942 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6943 operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel;
6944 break;
6945 default:
6946 break;
6947 }
6948
6949 break; //Found the device of interest. break the loop
6950 }
6951
6952 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6953 pAdapterNode = pNext;
6954 }
6955 return operatingChannel;
6956}
6957
6958#ifdef WLAN_FEATURE_PACKET_FILTERING
6959/**---------------------------------------------------------------------------
6960
6961 \brief hdd_set_multicast_list() -
6962
6963 This used to set the multicast address list.
6964
6965 \param - dev - Pointer to the WLAN device.
6966 - skb - Pointer to OS packet (sk_buff).
6967 \return - success/fail
6968
6969 --------------------------------------------------------------------------*/
6970static void hdd_set_multicast_list(struct net_device *dev)
6971{
6972 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 int mc_count;
6974 int i = 0;
6975 struct netdev_hw_addr *ha;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306976
6977 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 {
6979 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306980 "%s: Adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 return;
6982 }
6983
6984 if (dev->flags & IFF_ALLMULTI)
6985 {
6986 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006987 "%s: allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306988 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 }
6990 else
6991 {
6992 mc_count = netdev_mc_count(dev);
6993 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006994 "%s: mc_count = %u", __func__, mc_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST)
6996 {
6997 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006998 "%s: No free filter available; allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306999 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 return;
7001 }
7002
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307003 pAdapter->mc_addr_list.mc_cnt = mc_count;
Jeff Johnson295189b2012-06-20 16:38:30 -07007004
7005 netdev_for_each_mc_addr(ha, dev) {
7006 if (i == mc_count)
7007 break;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307008 memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN);
7009 memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007010 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 __func__, i,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307012 MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i]));
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 i++;
7014 }
7015 }
7016 return;
7017}
7018#endif
7019
7020/**---------------------------------------------------------------------------
7021
7022 \brief hdd_select_queue() -
7023
7024 This function is registered with the Linux OS for network
7025 core to decide which queue to use first.
7026
7027 \param - dev - Pointer to the WLAN device.
7028 - skb - Pointer to OS packet (sk_buff).
7029 \return - ac, Queue Index/access category corresponding to UP in IP header
7030
7031 --------------------------------------------------------------------------*/
7032v_U16_t hdd_select_queue(struct net_device *dev,
7033 struct sk_buff *skb)
7034{
7035 return hdd_wmm_select_queue(dev, skb);
7036}
7037
7038
7039/**---------------------------------------------------------------------------
7040
7041 \brief hdd_wlan_initial_scan() -
7042
7043 This function triggers the initial scan
7044
7045 \param - pAdapter - Pointer to the HDD adapter.
7046
7047 --------------------------------------------------------------------------*/
7048void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter)
7049{
7050 tCsrScanRequest scanReq;
7051 tCsrChannelInfo channelInfo;
7052 eHalStatus halStatus;
Jeff Johnson02797792013-10-26 19:17:13 -07007053 tANI_U32 scanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7055
7056 vos_mem_zero(&scanReq, sizeof(tCsrScanRequest));
7057 vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff);
7058 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
7059
7060 if(sme_Is11dSupported(pHddCtx->hHal))
7061 {
7062 halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo );
7063 if ( HAL_STATUS_SUCCESS( halStatus ) )
7064 {
7065 scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels);
7066 if( !scanReq.ChannelInfo.ChannelList )
7067 {
7068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__);
7069 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08007070 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 return;
7072 }
7073 vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList,
7074 channelInfo.numOfChannels);
7075 scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels;
7076 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08007077 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 }
7079
7080 scanReq.scanType = eSIR_PASSIVE_SCAN;
7081 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
7082 scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime;
7083 scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime;
7084 }
7085 else
7086 {
7087 scanReq.scanType = eSIR_ACTIVE_SCAN;
7088 scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
7089 scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime;
7090 scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime;
7091 }
7092
7093 halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL);
7094 if ( !HAL_STATUS_SUCCESS( halStatus ) )
7095 {
7096 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d",
7097 __func__, halStatus );
7098 }
7099
7100 if(sme_Is11dSupported(pHddCtx->hHal))
7101 vos_mem_free(scanReq.ChannelInfo.ChannelList);
7102}
7103
Jeff Johnson295189b2012-06-20 16:38:30 -07007104/**---------------------------------------------------------------------------
7105
7106 \brief hdd_full_power_callback() - HDD full power callback function
7107
7108 This is the function invoked by SME to inform the result of a full power
7109 request issued by HDD
7110
7111 \param - callbackcontext - Pointer to cookie
7112 \param - status - result of request
7113
7114 \return - None
7115
7116 --------------------------------------------------------------------------*/
7117static void hdd_full_power_callback(void *callbackContext, eHalStatus status)
7118{
Jeff Johnson72a40512013-12-19 10:14:15 -08007119 struct statsContext *pContext = callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120
7121 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307122 "%s: context = %p, status = %d", __func__, pContext, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007123
7124 if (NULL == callbackContext)
7125 {
7126 hddLog(VOS_TRACE_LEVEL_ERROR,
7127 "%s: Bad param, context [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007128 __func__, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 return;
7130 }
7131
Jeff Johnson72a40512013-12-19 10:14:15 -08007132 /* there is a race condition that exists between this callback
7133 function and the caller since the caller could time out either
7134 before or while this code is executing. we use a spinlock to
7135 serialize these actions */
7136 spin_lock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007137
7138 if (POWER_CONTEXT_MAGIC != pContext->magic)
7139 {
7140 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08007141 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 hddLog(VOS_TRACE_LEVEL_WARN,
7143 "%s: Invalid context, magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007144 __func__, pContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07007145 return;
7146 }
7147
Jeff Johnson72a40512013-12-19 10:14:15 -08007148 /* context is valid so caller is still waiting */
7149
7150 /* paranoia: invalidate the magic */
7151 pContext->magic = 0;
7152
7153 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 complete(&pContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08007155
7156 /* serialization is complete */
7157 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007158}
7159
7160/**---------------------------------------------------------------------------
7161
7162 \brief hdd_wlan_exit() - HDD WLAN exit function
7163
7164 This is the driver exit point (invoked during rmmod)
7165
7166 \param - pHddCtx - Pointer to the HDD Context
7167
7168 \return - None
7169
7170 --------------------------------------------------------------------------*/
7171void hdd_wlan_exit(hdd_context_t *pHddCtx)
7172{
7173 eHalStatus halStatus;
7174 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
7175 VOS_STATUS vosStatus;
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05307176 struct wiphy *wiphy = pHddCtx->wiphy;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007177 hdd_adapter_t* pAdapter = NULL;
Jeff Johnson72a40512013-12-19 10:14:15 -08007178 struct statsContext powerContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 long lrc;
7180
7181 ENTER();
7182
Jeff Johnson88ba7742013-02-27 14:36:02 -08007183 if (VOS_FTM_MODE != hdd_get_conparam())
7184 {
7185 // Unloading, restart logic is no more required.
7186 wlan_hdd_restart_deinit(pHddCtx);
7187 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007188
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 if (VOS_STA_SAP_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 {
7193 hdd_adapter_t* pAdapter = hdd_get_adapter(pHddCtx,
7194 WLAN_HDD_INFRA_STATION);
7195 if (pAdapter == NULL)
7196 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7197
7198 if (pAdapter != NULL)
7199 {
7200 wlan_hdd_cfg80211_pre_voss_stop(pAdapter);
7201 hdd_UnregisterWext(pAdapter->dev);
7202 }
7203 }
7204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007205
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 if (VOS_FTM_MODE == hdd_get_conparam())
Jeff Johnson88ba7742013-02-27 14:36:02 -08007207 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307208 hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__);
Jeff Johnson88ba7742013-02-27 14:36:02 -08007209 wlan_hdd_ftm_close(pHddCtx);
7210 goto free_hdd_ctx;
7211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 //Stop the Interface TX queue.
7213 //netif_tx_disable(pWlanDev);
7214 //netif_carrier_off(pWlanDev);
7215
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 if (VOS_STA_SAP_MODE == hdd_get_conparam())
7217 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307218 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SAP MODE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 pAdapter = hdd_get_adapter(pHddCtx,
7220 WLAN_HDD_SOFTAP);
7221 }
7222 else
7223 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307226 hddLog(VOS_TRACE_LEVEL_INFO,"%s: STA MODE",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 pAdapter = hdd_get_adapter(pHddCtx,
7228 WLAN_HDD_INFRA_STATION);
Praveen Kumar Sirisilla47ce6ea2013-09-24 15:08:08 -07007229 if (pAdapter == NULL)
7230 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_IBSS);
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307233
7234 if(NULL == pAdapter)
7235 {
7236 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: pAdapter is NULL",__func__);
7237 goto free_hdd_ctx;
7238 }
7239
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 /* DeRegister with platform driver as client for Suspend/Resume */
7241 vosStatus = hddDeregisterPmOps(pHddCtx);
7242 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
7243 {
7244 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__);
7245 VOS_ASSERT(0);
7246 }
7247
7248 vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx);
7249 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
7250 {
7251 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
7252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007253
7254 // Cancel any outstanding scan requests. We are about to close all
7255 // of our adapters, but an adapter structure is what SME passes back
7256 // to our callback function. Hence if there are any outstanding scan
7257 // requests then there is a race condition between when the adapter
7258 // is closed and when the callback is invoked. We try to resolve that
7259 // race condition here by canceling any outstanding scans before we
7260 // close the adapters.
7261 // Note that the scans may be cancelled in an asynchronous manner, so
7262 // ideally there needs to be some kind of synchronization. Rather than
7263 // introduce a new synchronization here, we will utilize the fact that
7264 // we are about to Request Full Power, and since that is synchronized,
7265 // the expectation is that by the time Request Full Power has completed,
7266 // all scans will be cancelled.
Praveen Kumar Sirisilla47ce6ea2013-09-24 15:08:08 -07007267 if (NULL != pAdapter)
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307268 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, eCSR_SCAN_ABORT_DEFAULT);
Praveen Kumar Sirisilla47ce6ea2013-09-24 15:08:08 -07007269 else
7270 hddLog(VOS_TRACE_LEVEL_ERROR,
7271 "%s: pAdapter is NULL, cannot Abort scan", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007272
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07007273 //Stop the traffic monitor timer
7274 if ( VOS_TIMER_STATE_RUNNING ==
7275 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))
7276 {
7277 vos_timer_stop(&pHddCtx->tx_rx_trafficTmr);
7278 }
7279
7280 // Destroy the traffic monitor timer
7281 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(
7282 &pHddCtx->tx_rx_trafficTmr)))
7283 {
7284 hddLog(VOS_TRACE_LEVEL_ERROR,
7285 "%s: Cannot deallocate Traffic monitor timer", __func__);
7286 }
7287
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 //Disable IMPS/BMPS as we do not want the device to enter any power
7289 //save mode during shutdown
7290 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
7291 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
7292 sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE);
7293
7294 //Ensure that device is in full power as we will touch H/W during vos_Stop
7295 init_completion(&powerContext.completion);
7296 powerContext.magic = POWER_CONTEXT_MAGIC;
7297
7298 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback,
7299 &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD);
7300
7301 if (eHAL_STATUS_SUCCESS != halStatus)
7302 {
7303 if (eHAL_STATUS_PMC_PENDING == halStatus)
7304 {
7305 /* request was sent -- wait for the response */
7306 lrc = wait_for_completion_interruptible_timeout(
7307 &powerContext.completion,
7308 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 if (lrc <= 0)
7310 {
7311 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007312 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 }
7314 }
7315 else
7316 {
7317 hddLog(VOS_TRACE_LEVEL_ERROR,
7318 "%s: Request for Full Power failed, status %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007319 __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 /* continue -- need to clean up as much as possible */
7321 }
7322 }
7323
Jeff Johnson72a40512013-12-19 10:14:15 -08007324 /* either we never sent a request, we sent a request and received a
7325 response or we sent a request and timed out. if we never sent a
7326 request or if we sent a request and got a response, we want to
7327 clear the magic out of paranoia. if we timed out there is a
7328 race condition such that the callback function could be
7329 executing at the same time we are. of primary concern is if the
7330 callback function had already verified the "magic" but had not
7331 yet set the completion variable when a timeout occurred. we
7332 serialize these activities by invalidating the magic while
7333 holding a shared spinlock which will cause us to block if the
7334 callback is currently executing */
7335 spin_lock(&hdd_context_lock);
7336 powerContext.magic = 0;
7337 spin_unlock(&hdd_context_lock);
7338
Yue Ma0d4891e2013-08-06 17:01:45 -07007339 hdd_debugfs_exit(pHddCtx);
7340
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 // Unregister the Net Device Notifier
7342 unregister_netdevice_notifier(&hdd_netdev_notifier);
7343
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 hdd_stop_all_adapters( pHddCtx );
7345
Jeff Johnson295189b2012-06-20 16:38:30 -07007346#ifdef WLAN_BTAMP_FEATURE
7347 vosStatus = WLANBAP_Stop(pVosContext);
7348 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
7349 {
7350 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
7351 "%s: Failed to stop BAP",__func__);
7352 }
7353#endif //WLAN_BTAMP_FEATURE
7354
7355 //Stop all the modules
7356 vosStatus = vos_stop( pVosContext );
7357 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
7358 {
7359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7360 "%s: Failed to stop VOSS",__func__);
7361 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
7362 }
7363
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 //Assert Deep sleep signal now to put Libra HW in lowest power state
7365 vosStatus = vos_chipAssertDeepSleep( NULL, NULL, NULL );
7366 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
7367
7368 //Vote off any PMIC voltage supplies
7369 vos_chipPowerDown(NULL, NULL, NULL);
7370
7371 vos_chipVoteOffXOBuffer(NULL, NULL, NULL);
7372
Leo Chang59cdc7e2013-07-10 10:08:21 -07007373
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 //This requires pMac access, Call this before vos_close().
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 hdd_unregister_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007376
7377 //Close the scheduler before calling vos_close to make sure no thread is
7378 // scheduled after the each module close is called i.e after all the data
7379 // structures are freed.
7380 vosStatus = vos_sched_close( pVosContext );
7381 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
7382 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
7383 "%s: Failed to close VOSS Scheduler",__func__);
7384 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
7385 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08007386#ifdef WLAN_OPEN_SOURCE
Jeff Johnsone7245742012-09-05 17:12:55 -07007387#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
7388 /* Destroy the wake lock */
7389 wake_lock_destroy(&pHddCtx->rx_wake_lock);
7390#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08007391 /* Destroy the wake lock */
7392 wake_lock_destroy(&pHddCtx->sap_wake_lock);
Sameer Thalappil50dc0092013-02-19 17:23:33 -08007393#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007394
Mihir Shete7a24b5f2013-12-21 12:18:31 +05307395#ifdef CONFIG_ENABLE_LINUX_REG
7396 vosStatus = vos_nv_close();
7397 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
7398 {
7399 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
7400 "%s: Failed to close NV", __func__);
7401 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
7402 }
7403#endif
7404
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 //Close VOSS
7406 //This frees pMac(HAL) context. There should not be any call that requires pMac access after this.
7407 vos_close(pVosContext);
7408
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 //Close Watchdog
7410 if(pHddCtx->cfg_ini->fIsLogpEnabled)
7411 vos_watchdog_close(pVosContext);
7412
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05307413 //Clean up HDD Nlink Service
7414 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Leo Chang59cdc7e2013-07-10 10:08:21 -07007415#ifdef WLAN_KD_READY_NOTIFIER
7416 nl_srv_exit(pHddCtx->ptt_pid);
7417#else
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05307418 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -07007419#endif /* WLAN_KD_READY_NOTIFIER */
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05307420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 /* Cancel the vote for XO Core ON.
7422 * This is done here to ensure there is no race condition since MC, TX and WD threads have
7423 * exited at this point
7424 */
7425 hddLog(VOS_TRACE_LEVEL_WARN, "In module exit: Cancel the vote for XO Core ON"
Arif Hussain6d2a3322013-11-17 19:50:10 -08007426 " when WLAN is turned OFF");
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS)
7428 {
7429 hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel the vote for XO Core ON."
7430 " Not returning failure."
Arif Hussain6d2a3322013-11-17 19:50:10 -08007431 " Power consumed will be high");
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 }
7433
7434 hdd_close_all_adapters( pHddCtx );
7435
7436
7437 //Free up dynamically allocated members inside HDD Adapter
7438 kfree(pHddCtx->cfg_ini);
7439 pHddCtx->cfg_ini= NULL;
7440
7441 /* free the power on lock from platform driver */
7442 if (free_riva_power_on_lock("wlan"))
7443 {
7444 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock",
7445 __func__);
7446 }
7447
Jeff Johnson88ba7742013-02-27 14:36:02 -08007448free_hdd_ctx:
Leo Changf04ddad2013-09-18 13:46:38 -07007449 /* FTM mode, WIPHY did not registered
7450 If un-register here, system crash will happen */
7451 if (VOS_FTM_MODE != hdd_get_conparam())
7452 {
7453 wiphy_unregister(wiphy) ;
7454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 wiphy_free(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 if (hdd_is_ssr_required())
7457 {
7458 /* WDI timeout had happened during unload, so SSR is needed here */
Madan Mohan Koyyalamudi3246f5b2012-10-15 15:40:02 -07007459 subsystem_restart("wcnss");
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 msleep(5000);
7461 }
7462 hdd_set_ssr_required (VOS_FALSE);
7463}
7464
7465
7466/**---------------------------------------------------------------------------
7467
7468 \brief hdd_update_config_from_nv() - Function to update the contents of
7469 the running configuration with parameters taken from NV storage
7470
7471 \param - pHddCtx - Pointer to the HDD global context
7472
7473 \return - VOS_STATUS_SUCCESS if successful
7474
7475 --------------------------------------------------------------------------*/
7476static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx)
7477{
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 v_BOOL_t itemIsValid = VOS_FALSE;
7479 VOS_STATUS status;
7480 v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA];
7481 v_U8_t macLoop;
7482
7483 /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/
7484 status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid);
7485 if(status != VOS_STATUS_SUCCESS)
7486 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007487 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 return VOS_STATUS_E_FAILURE;
7489 }
7490
7491 if (itemIsValid == VOS_TRUE)
7492 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007493 hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV");
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0],
7495 VOS_MAX_CONCURRENCY_PERSONA);
7496 if(status != VOS_STATUS_SUCCESS)
7497 {
7498 /* Get MAC from NV fail, not update CFG info
7499 * INI MAC value will be used for MAC setting */
Arif Hussain6d2a3322013-11-17 19:50:10 -08007500 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 return VOS_STATUS_E_FAILURE;
7502 }
7503
7504 /* If first MAC is not valid, treat all others are not valid
7505 * Then all MACs will be got from ini file */
7506 if(vos_is_macaddr_zero(&macFromNV[0]))
7507 {
7508 /* MAC address in NV file is not configured yet */
7509 hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file");
7510 return VOS_STATUS_E_INVAL;
7511 }
7512
7513 /* Get MAC address from NV, update CFG info */
7514 for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++)
7515 {
7516 if(vos_is_macaddr_zero(&macFromNV[macLoop]))
7517 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307518 hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop);
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 /* This MAC is not valid, skip it
7520 * This MAC will be got from ini file */
7521 }
7522 else
7523 {
7524 vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0],
7525 (v_U8_t *)&macFromNV[macLoop].bytes[0],
7526 VOS_MAC_ADDR_SIZE);
7527 }
7528 }
7529 }
7530 else
7531 {
7532 hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid");
7533 return VOS_STATUS_E_FAILURE;
7534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536
7537 return VOS_STATUS_SUCCESS;
7538}
7539
7540/**---------------------------------------------------------------------------
7541
7542 \brief hdd_post_voss_start_config() - HDD post voss start config helper
7543
7544 \param - pAdapter - Pointer to the HDD
7545
7546 \return - None
7547
7548 --------------------------------------------------------------------------*/
7549VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx)
7550{
7551 eHalStatus halStatus;
7552 v_U32_t listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307553 tANI_U32 ignoreDtim;
Jeff Johnson295189b2012-06-20 16:38:30 -07007554
Jeff Johnson295189b2012-06-20 16:38:30 -07007555
7556 // Send ready indication to the HDD. This will kick off the MAC
7557 // into a 'running' state and should kick off an initial scan.
7558 halStatus = sme_HDDReadyInd( pHddCtx->hHal );
7559 if ( !HAL_STATUS_SUCCESS( halStatus ) )
7560 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307561 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status "
Jeff Johnson295189b2012-06-20 16:38:30 -07007562 "code %08d [x%08x]",__func__, halStatus, halStatus );
7563 return VOS_STATUS_E_FAILURE;
7564 }
7565
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307566 // Set default LI and ignoreDtim into HDD context,
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 // otherwise under some race condition, HDD will set 0 LI value into RIVA,
7568 // And RIVA will crash
7569 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval);
7570 pHddCtx->hdd_actual_LI_value = listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307571 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim);
7572 pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim;
7573
7574
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 return VOS_STATUS_SUCCESS;
7576}
7577
Jeff Johnson295189b2012-06-20 16:38:30 -07007578/* wake lock APIs for HDD */
7579void hdd_prevent_suspend(void)
7580{
Sameer Thalappil50dc0092013-02-19 17:23:33 -08007581#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 wake_lock(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07007583#else
7584 wcnss_prevent_suspend();
7585#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007586}
7587
7588void hdd_allow_suspend(void)
7589{
Sameer Thalappil50dc0092013-02-19 17:23:33 -08007590#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 wake_unlock(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07007592#else
7593 wcnss_allow_suspend();
7594#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007595}
7596
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05307597void hdd_prevent_suspend_timeout(v_U32_t timeout)
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07007598{
Sameer Thalappil50dc0092013-02-19 17:23:33 -08007599#ifdef WLAN_OPEN_SOURCE
Amar Singhal6144c002013-05-03 16:11:42 -07007600 wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout));
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07007601#else
7602 /* Do nothing as there is no API in wcnss for timeout*/
7603#endif
7604}
7605
Jeff Johnson295189b2012-06-20 16:38:30 -07007606/**---------------------------------------------------------------------------
7607
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007608 \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability
7609 information between Host and Riva
7610
7611 This function gets reported version of FW
7612 It also finds the version of Riva headers used to compile the host
7613 It compares the above two and prints a warning if they are different
7614 It gets the SW and HW version string
7615 Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg
7616 indicating the features they support through a bitmap
7617
7618 \param - pHddCtx - Pointer to HDD context
7619
7620 \return - void
7621
7622 --------------------------------------------------------------------------*/
7623
7624void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx)
7625{
7626
7627 tSirVersionType versionCompiled;
7628 tSirVersionType versionReported;
7629 tSirVersionString versionString;
7630 tANI_U8 fwFeatCapsMsgSupported = 0;
7631 VOS_STATUS vstatus;
7632
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007633 memset(&versionCompiled, 0, sizeof(versionCompiled));
7634 memset(&versionReported, 0, sizeof(versionReported));
7635
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007636 /* retrieve and display WCNSS version information */
7637 do {
7638
7639 vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal,
7640 &versionCompiled);
7641 if (!VOS_IS_STATUS_SUCCESS(vstatus))
7642 {
7643 hddLog(VOS_TRACE_LEVEL_FATAL,
7644 "%s: unable to retrieve WCNSS WLAN compiled version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007645 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007646 break;
7647 }
7648
7649 vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal,
7650 &versionReported);
7651 if (!VOS_IS_STATUS_SUCCESS(vstatus))
7652 {
7653 hddLog(VOS_TRACE_LEVEL_FATAL,
7654 "%s: unable to retrieve WCNSS WLAN reported version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007655 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007656 break;
7657 }
7658
7659 if ((versionCompiled.major != versionReported.major) ||
7660 (versionCompiled.minor != versionReported.minor) ||
7661 (versionCompiled.version != versionReported.version) ||
7662 (versionCompiled.revision != versionReported.revision))
7663 {
7664 pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, "
7665 "Host expected %u.%u.%u.%u\n",
7666 WLAN_MODULE_NAME,
7667 (int)versionReported.major,
7668 (int)versionReported.minor,
7669 (int)versionReported.version,
7670 (int)versionReported.revision,
7671 (int)versionCompiled.major,
7672 (int)versionCompiled.minor,
7673 (int)versionCompiled.version,
7674 (int)versionCompiled.revision);
7675 }
7676 else
7677 {
7678 pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n",
7679 WLAN_MODULE_NAME,
7680 (int)versionReported.major,
7681 (int)versionReported.minor,
7682 (int)versionReported.version,
7683 (int)versionReported.revision);
7684 }
7685
7686 vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal,
7687 versionString,
7688 sizeof(versionString));
7689 if (!VOS_IS_STATUS_SUCCESS(vstatus))
7690 {
7691 hddLog(VOS_TRACE_LEVEL_FATAL,
7692 "%s: unable to retrieve WCNSS software version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007693 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007694 break;
7695 }
7696
7697 pr_info("%s: WCNSS software version %s\n",
7698 WLAN_MODULE_NAME, versionString);
7699
7700 vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal,
7701 versionString,
7702 sizeof(versionString));
7703 if (!VOS_IS_STATUS_SUCCESS(vstatus))
7704 {
7705 hddLog(VOS_TRACE_LEVEL_FATAL,
7706 "%s: unable to retrieve WCNSS hardware version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007707 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007708 break;
7709 }
7710
7711 pr_info("%s: WCNSS hardware version %s\n",
7712 WLAN_MODULE_NAME, versionString);
7713
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07007714 /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message
7715 2.Host-FW capability exchange message is only present on riva 1.1 so
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007716 send the message only if it the riva is 1.1
7717 minor numbers for different riva branches:
7718 0 -> (1.0)Mainline Build
7719 1 -> (1.1)Mainline Build
7720 2->(1.04) Stability Build
7721 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07007722 if (((versionReported.major>0) || (versionReported.minor>1) ||
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007723 ((versionReported.minor>=1) && (versionReported.version>=1)))
7724 && ((versionReported.major == 1) && (versionReported.minor >= 1)))
7725 fwFeatCapsMsgSupported = 1;
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07007726
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007727 if (fwFeatCapsMsgSupported)
Yathish9f22e662012-12-10 14:21:35 -08007728 {
7729#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
7730 if(!pHddCtx->cfg_ini->fEnableActiveModeOffload)
7731 sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD);
7732#endif
Ravi Joshid2ca7c42013-07-23 08:37:49 -07007733 /* Indicate if IBSS heartbeat monitoring needs to be offloaded */
7734 if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload)
7735 {
7736 sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD);
7737 }
7738
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007739 sme_featureCapsExchange(pHddCtx->hHal);
Yathish9f22e662012-12-10 14:21:35 -08007740 }
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07007741
7742 } while (0);
7743
7744}
7745
7746/**---------------------------------------------------------------------------
7747
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05307748 \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz
7749
7750 \param - pHddCtx - Pointer to the hdd context
7751
7752 \return - true if hardware supports 5GHz
7753
7754 --------------------------------------------------------------------------*/
7755static boolean hdd_is_5g_supported(hdd_context_t * pHddCtx)
7756{
7757 /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1);
7758 * then hardware support 5Ghz.
7759 */
7760 if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode())
7761 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307762 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05307763 return true;
7764 }
7765 else
7766 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307767 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz",
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05307768 __func__);
7769 return false;
7770 }
7771}
7772
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05307773/**---------------------------------------------------------------------------
7774
7775 \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto
7776 generate function
7777
7778 This is generate the random mac address for WLAN interface
7779
7780 \param - pHddCtx - Pointer to HDD context
7781 idx - Start interface index to get auto
7782 generated mac addr.
7783 mac_addr - Mac address
7784
7785 \return - 0 for success, < 0 for failure
7786
7787 --------------------------------------------------------------------------*/
7788
7789static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx,
7790 int idx, v_MACADDR_t mac_addr)
7791{
7792 int i;
7793 unsigned int serialno;
7794 serialno = wcnss_get_serial_number();
7795
7796 if (0 != serialno)
7797 {
7798 /* MAC address has 3 bytes of OUI so we have a maximum of 3
7799 bytes of the serial number that can be used to generate
7800 the other 3 bytes of the MAC address. Mask off all but
7801 the lower 3 bytes (this will also make sure we don't
7802 overflow in the next step) */
7803 serialno &= 0x00FFFFFF;
7804
7805 /* we need a unique address for each session */
7806 serialno *= VOS_MAX_CONCURRENCY_PERSONA;
7807
7808 /* autogen other Mac addresses */
7809 for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
7810 {
7811 /* start with the entire default address */
7812 pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr;
7813 /* then replace the lower 3 bytes */
7814 pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF;
7815 pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF;
7816 pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF;
7817
7818 serialno++;
7819 hddLog(VOS_TRACE_LEVEL_ERROR,
7820 "%s: Derived Mac Addr: "
7821 MAC_ADDRESS_STR, __func__,
7822 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes));
7823 }
7824
7825 }
7826 else
7827 {
7828 hddLog(LOGE, FL("Failed to Get Serial NO"));
7829 return -1;
7830 }
7831 return 0;
7832}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05307833
7834/**---------------------------------------------------------------------------
7835
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05307836 \brief hdd_11d_scan_done - callback to be executed when 11d scan is
7837 completed to flush out the scan results
7838
7839 11d scan is done during driver load and is a passive scan on all
7840 channels supported by the device, 11d scans may find some APs on
7841 frequencies which are forbidden to be used in the regulatory domain
7842 the device is operating in. If these APs are notified to the supplicant
7843 it may try to connect to these APs, thus flush out all the scan results
7844 which are present in SME after 11d scan is done.
7845
7846 \return - eHalStatus
7847
7848 --------------------------------------------------------------------------*/
7849static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext,
7850 tANI_U32 scanId, eCsrScanStatus status)
7851{
7852 ENTER();
7853
7854 sme_ScanFlushResult(halHandle, 0);
7855
7856 EXIT();
7857
7858 return eHAL_STATUS_SUCCESS;
7859}
7860
7861/**---------------------------------------------------------------------------
7862
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 \brief hdd_wlan_startup() - HDD init function
7864
7865 This is the driver startup code executed once a WLAN device has been detected
7866
7867 \param - dev - Pointer to the underlying device
7868
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08007869 \return - 0 for success, < 0 for failure
Jeff Johnson295189b2012-06-20 16:38:30 -07007870
7871 --------------------------------------------------------------------------*/
7872
7873int hdd_wlan_startup(struct device *dev )
7874{
7875 VOS_STATUS status;
7876 hdd_adapter_t *pAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07007877 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 hdd_context_t *pHddCtx = NULL;
7879 v_CONTEXT_t pVosContext= NULL;
7880#ifdef WLAN_BTAMP_FEATURE
7881 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
7882 WLANBAP_ConfigType btAmpConfig;
7883 hdd_config_t *pConfig;
7884#endif
7885 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 struct wiphy *wiphy;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05307887 v_MACADDR_t mac_addr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007888
7889 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 /*
7891 * cfg80211: wiphy allocation
7892 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307893 wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07007894
7895 if(wiphy == NULL)
7896 {
7897 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08007898 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 }
7900
7901 pHddCtx = wiphy_priv(wiphy);
7902
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 //Initialize the adapter context to zeros.
7904 vos_mem_zero(pHddCtx, sizeof( hdd_context_t ));
7905
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 pHddCtx->wiphy = wiphy;
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 hdd_prevent_suspend();
7908 pHddCtx->isLoadUnloadInProgress = TRUE;
7909
7910 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
7911
7912 /*Get vos context here bcoz vos_open requires it*/
7913 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
7914
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08007915 if(pVosContext == NULL)
7916 {
7917 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__);
7918 goto err_free_hdd_context;
7919 }
7920
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 //Save the Global VOSS context in adapter context for future.
7922 pHddCtx->pvosContext = pVosContext;
7923
7924 //Save the adapter context in global context for future.
7925 ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx;
7926
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 pHddCtx->parent_dev = dev;
7928
7929 init_completion(&pHddCtx->full_pwr_comp_var);
7930 init_completion(&pHddCtx->standby_comp_var);
7931 init_completion(&pHddCtx->req_bmps_comp_var);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007932 init_completion(&pHddCtx->scan_info.scan_req_completion_event);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08007933 init_completion(&pHddCtx->scan_info.abortscan_event_var);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307934 init_completion(&pHddCtx->wiphy_channel_update_event);
Amar Singhala49cbc52013-10-08 18:37:44 -07007935
7936#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhalfddc28c2013-09-05 13:03:40 -07007937 init_completion(&pHddCtx->linux_reg_req);
Amar Singhala49cbc52013-10-08 18:37:44 -07007938#else
7939 init_completion(&pHddCtx->driver_crda_req);
7940#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007941
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307942 spin_lock_init(&pHddCtx->schedScan_lock);
7943
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS );
7945
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307946#ifdef FEATURE_WLAN_TDLS
7947 /* tdls_lock is initialized before an hdd_open_adapter ( which is
7948 * invoked by other instances also) to protect the concurrent
7949 * access for the Adapters by TDLS module.
7950 */
7951 mutex_init(&pHddCtx->tdls_lock);
7952#endif
7953
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307954 pHddCtx->nEnableStrictRegulatoryForFCC = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 // Load all config first as TL config is needed during vos_open
7956 pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL);
7957 if(pHddCtx->cfg_ini == NULL)
7958 {
7959 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__);
7960 goto err_free_hdd_context;
7961 }
7962
7963 vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t ));
7964
7965 // Read and parse the qcom_cfg.ini file
7966 status = hdd_parse_config_ini( pHddCtx );
7967 if ( VOS_STATUS_SUCCESS != status )
7968 {
7969 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s",
7970 __func__, WLAN_INI_FILE);
7971 goto err_config;
7972 }
Arif Hussaind5218912013-12-05 01:10:55 -08007973#ifdef MEMORY_DEBUG
7974 if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled)
7975 vos_mem_init();
7976
7977 hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d",
7978 __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled);
7979#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007980
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307981 /* INI has been read, initialise the configuredMcastBcastFilter with
7982 * INI value as this will serve as the default value
7983 */
7984 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
7985 hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d",
7986 pHddCtx->cfg_ini->mcastBcastFilterSetting);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05307987
7988 if (false == hdd_is_5g_supported(pHddCtx))
7989 {
7990 //5Ghz is not supported.
7991 if (1 != pHddCtx->cfg_ini->nBandCapability)
7992 {
7993 hddLog(VOS_TRACE_LEVEL_INFO,
7994 "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__);
7995 pHddCtx->cfg_ini->nBandCapability = 1;
7996 }
7997 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05307998
7999 /* If SNR Monitoring is enabled, FW has to parse all beacons
8000 * for calcaluting and storing the average SNR, so set Nth beacon
8001 * filter to 1 to enable FW to parse all the beaocons
8002 */
8003 if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring)
8004 {
8005 /* The log level is deliberately set to WARN as overriding
8006 * nthBeaconFilter to 1 will increase power cosumption and this
8007 * might just prove helpful to detect the power issue.
8008 */
8009 hddLog(VOS_TRACE_LEVEL_WARN,
8010 "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__);
8011 pHddCtx->cfg_ini->nthBeaconFilter = 1;
8012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 /*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308014 * cfg80211: Initialization ...
Jeff Johnson295189b2012-06-20 16:38:30 -07008015 */
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08008016 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 {
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08008018 if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini))
8019 {
8020 hddLog(VOS_TRACE_LEVEL_FATAL,
8021 "%s: wlan_hdd_cfg80211_init return failure", __func__);
8022 goto err_config;
8023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008025
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008026 // Update VOS trace levels based upon the cfg.ini
8027 hdd_vos_trace_enable(VOS_MODULE_ID_BAP,
8028 pHddCtx->cfg_ini->vosTraceEnableBAP);
8029 hdd_vos_trace_enable(VOS_MODULE_ID_TL,
8030 pHddCtx->cfg_ini->vosTraceEnableTL);
8031 hdd_vos_trace_enable(VOS_MODULE_ID_WDI,
8032 pHddCtx->cfg_ini->vosTraceEnableWDI);
8033 hdd_vos_trace_enable(VOS_MODULE_ID_HDD,
8034 pHddCtx->cfg_ini->vosTraceEnableHDD);
8035 hdd_vos_trace_enable(VOS_MODULE_ID_SME,
8036 pHddCtx->cfg_ini->vosTraceEnableSME);
8037 hdd_vos_trace_enable(VOS_MODULE_ID_PE,
8038 pHddCtx->cfg_ini->vosTraceEnablePE);
Katya Nigam70d68332013-09-16 16:49:45 +05308039 hdd_vos_trace_enable(VOS_MODULE_ID_PMC,
8040 pHddCtx->cfg_ini->vosTraceEnablePMC);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008041 hdd_vos_trace_enable(VOS_MODULE_ID_WDA,
8042 pHddCtx->cfg_ini->vosTraceEnableWDA);
8043 hdd_vos_trace_enable(VOS_MODULE_ID_SYS,
8044 pHddCtx->cfg_ini->vosTraceEnableSYS);
8045 hdd_vos_trace_enable(VOS_MODULE_ID_VOSS,
8046 pHddCtx->cfg_ini->vosTraceEnableVOSS);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008047 hdd_vos_trace_enable(VOS_MODULE_ID_SAP,
8048 pHddCtx->cfg_ini->vosTraceEnableSAP);
8049 hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP,
8050 pHddCtx->cfg_ini->vosTraceEnableHDDSAP);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008051
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 // Update WDI trace levels based upon the cfg.ini
8053 hdd_wdi_trace_enable(eWLAN_MODULE_DAL,
8054 pHddCtx->cfg_ini->wdiTraceEnableDAL);
8055 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL,
8056 pHddCtx->cfg_ini->wdiTraceEnableCTL);
8057 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA,
8058 pHddCtx->cfg_ini->wdiTraceEnableDAT);
8059 hdd_wdi_trace_enable(eWLAN_MODULE_PAL,
8060 pHddCtx->cfg_ini->wdiTraceEnablePAL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008061
Jeff Johnson88ba7742013-02-27 14:36:02 -08008062 if (VOS_FTM_MODE == hdd_get_conparam())
8063 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) )
8065 {
8066 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__);
8067 goto err_free_hdd_context;
8068 }
8069 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__);
8070 return VOS_STATUS_SUCCESS;
Jeff Johnson88ba7742013-02-27 14:36:02 -08008071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008072
Jeff Johnson88ba7742013-02-27 14:36:02 -08008073 //Open watchdog module
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8075 {
8076 status = vos_watchdog_open(pVosContext,
8077 &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext));
8078
8079 if(!VOS_IS_STATUS_SUCCESS( status ))
8080 {
8081 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308082 goto err_wdclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 }
8084 }
8085
8086 pHddCtx->isLogpInProgress = FALSE;
8087 vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE);
8088
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 status = vos_chipVoteOnXOBuffer(NULL, NULL, NULL);
8090 if(!VOS_IS_STATUS_SUCCESS(status))
8091 {
8092 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed to configure 19.2 MHz Clock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 goto err_wdclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07008094 }
8095
Amar Singhala49cbc52013-10-08 18:37:44 -07008096#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07008097 /* initialize the NV module. This is required so that
8098 we can initialize the channel information in wiphy
8099 from the NV.bin data. The channel information in
8100 wiphy needs to be initialized before wiphy registration */
8101
8102 status = vos_nv_open();
8103 if (!VOS_IS_STATUS_SUCCESS(status))
8104 {
8105 /* NV module cannot be initialized */
8106 hddLog( VOS_TRACE_LEVEL_FATAL,
8107 "%s: vos_nv_open failed", __func__);
8108 goto err_clkvote;
8109 }
8110
8111 status = vos_init_wiphy_from_nv_bin();
8112 if (!VOS_IS_STATUS_SUCCESS(status))
8113 {
8114 /* NV module cannot be initialized */
8115 hddLog( VOS_TRACE_LEVEL_FATAL,
8116 "%s: vos_init_wiphy failed", __func__);
8117 goto err_vos_nv_close;
8118 }
8119
Amar Singhala49cbc52013-10-08 18:37:44 -07008120#endif
8121
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 status = vos_open( &pVosContext, 0);
8123 if ( !VOS_IS_STATUS_SUCCESS( status ))
8124 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008125 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05308126 goto err_vos_nv_close;
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 }
8128
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext );
8130
8131 if ( NULL == pHddCtx->hHal )
8132 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008133 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 goto err_vosclose;
8135 }
8136
Mihir Shetee1093ba2014-01-21 20:13:32 +05308137#ifdef CONFIG_ENABLE_LINUX_REG
8138 /* registration of wiphy dev with cfg80211 */
8139 if (0 > wlan_hdd_cfg80211_register(wiphy))
8140 {
8141 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8142 goto err_vosclose;
8143 }
8144
8145 status = wlan_hdd_init_channels(pHddCtx);
8146 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8147 {
8148 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed",
8149 __func__);
8150 goto err_wiphy_unregister;
8151 }
8152#endif
8153
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008154 status = vos_preStart( pHddCtx->pvosContext );
8155 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8156 {
8157 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05308158 goto err_wiphy_unregister;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008159 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008160
Arif Hussaineaf68602013-12-30 23:10:44 -08008161 if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan)
8162 {
8163 pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan;
8164 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d",
8165 __func__, enable_dfs_chan_scan);
8166 }
8167 if (0 == enable_11d || 1 == enable_11d)
8168 {
8169 pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d;
8170 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d",
8171 __func__, enable_11d);
8172 }
8173
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008174 /* Note that the vos_preStart() sequence triggers the cfg download.
8175 The cfg download must occur before we update the SME config
8176 since the SME config operation must access the cfg database */
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 status = hdd_set_sme_config( pHddCtx );
8178
8179 if ( VOS_STATUS_SUCCESS != status )
8180 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008181 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05308182 goto err_wiphy_unregister;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008184
8185 //Initialize the WMM module
8186 status = hdd_wmm_init(pHddCtx);
8187 if (!VOS_IS_STATUS_SUCCESS(status))
8188 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008189 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_wmm_init failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05308190 goto err_wiphy_unregister;
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 }
8192
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 /* In the integrated architecture we update the configuration from
8194 the INI file and from NV before vOSS has been started so that
8195 the final contents are available to send down to the cCPU */
8196
8197 // Apply the cfg.ini to cfg.dat
8198 if (FALSE == hdd_update_config_dat(pHddCtx))
8199 {
8200 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ );
Mihir Shetee1093ba2014-01-21 20:13:32 +05308201 goto err_wiphy_unregister;
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 }
8203
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308204 // Get mac addr from platform driver
8205 ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes);
8206
8207 if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308209 /* Store the mac addr for first interface */
8210 pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr;
8211
8212 hddLog(VOS_TRACE_LEVEL_ERROR,
8213 "%s: WLAN Mac Addr: "
8214 MAC_ADDRESS_STR, __func__,
8215 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
8216
8217 /* Here, passing Arg2 as 1 because we do not want to change the
8218 last 3 bytes (means non OUI bytes) of first interface mac
8219 addr.
8220 */
8221 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr))
8222 {
8223 hddLog(VOS_TRACE_LEVEL_ERROR,
8224 "%s: Failed to generate wlan interface mac addr "
8225 "using MAC from ini file ", __func__);
8226 }
8227 }
8228 else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx))
8229 {
8230 // Apply the NV to cfg.dat
8231 /* Prima Update MAC address only at here */
Jeff Johnson295189b2012-06-20 16:38:30 -07008232#ifdef WLAN_AUTOGEN_MACADDR_FEATURE
8233 /* There was not a valid set of MAC Addresses in NV. See if the
8234 default addresses were modified by the cfg.ini settings. If so,
8235 we'll use them, but if not, we'll autogenerate a set of MAC
8236 addresses based upon the device serial number */
8237
8238 static const v_MACADDR_t default_address =
8239 {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}};
Jeff Johnson295189b2012-06-20 16:38:30 -07008240
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308241 if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0],
8242 sizeof(default_address)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 {
8244 /* cfg.ini has the default address, invoke autogen logic */
8245
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308246 /* Here, passing Arg2 as 0 because we want to change the
8247 last 3 bytes (means non OUI bytes) of all the interfaces
8248 mac addr.
8249 */
8250 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0,
8251 default_address))
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308253 hddLog(VOS_TRACE_LEVEL_ERROR,
8254 "%s: Failed to generate wlan interface mac addr "
8255 "using MAC from ini file " MAC_ADDRESS_STR, __func__,
8256 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 }
8259 else
8260#endif //WLAN_AUTOGEN_MACADDR_FEATURE
8261 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008262 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 "%s: Invalid MAC address in NV, using MAC from ini file "
8264 MAC_ADDRESS_STR, __func__,
8265 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
8266 }
8267 }
8268 {
8269 eHalStatus halStatus;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308270
8271 /* Set the MAC Address Currently this is used by HAL to
8272 * add self sta. Remove this once self sta is added as
8273 * part of session open.
8274 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID,
8276 (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0],
8277 sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) );
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308278
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 if (!HAL_STATUS_SUCCESS( halStatus ))
8280 {
8281 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. "
8282 "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus );
Mihir Shetee1093ba2014-01-21 20:13:32 +05308283 goto err_wiphy_unregister;
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 }
8285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008286
8287 /*Start VOSS which starts up the SME/MAC/HAL modules and everything else
8288 Note: Firmware image will be read and downloaded inside vos_start API */
8289 status = vos_start( pHddCtx->pvosContext );
8290 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8291 {
8292 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05308293 goto err_wiphy_unregister;
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 }
8295
Leo Chang6cec3e22014-01-21 15:33:49 -08008296#ifdef FEATURE_WLAN_CH_AVOID
8297 /* Plug in avoid channel notification callback
8298 * This should happen before ADD_SELF_STA
8299 * FW will send first IND with ADD_SELF_STA REQ from host */
8300 sme_AddChAvoidCallback(pHddCtx->hHal,
8301 hdd_hostapd_ch_avoid_cb);
8302#endif /* FEATURE_WLAN_CH_AVOID */
8303
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008304 /* Exchange capability info between Host and FW and also get versioning info from FW */
8305 hdd_exchange_version_and_caps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008306
8307 status = hdd_post_voss_start_config( pHddCtx );
8308 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8309 {
8310 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed",
8311 __func__);
8312 goto err_vosstop;
8313 }
Amar Singhala49cbc52013-10-08 18:37:44 -07008314
8315#ifndef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308316 wlan_hdd_cfg80211_update_reg_info( wiphy );
8317
8318 /* registration of wiphy dev with cfg80211 */
8319 if (0 > wlan_hdd_cfg80211_register(wiphy))
8320 {
8321 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
8322 goto err_vosstop;
8323 }
Amar Singhala49cbc52013-10-08 18:37:44 -07008324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008325
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 if (VOS_STA_SAP_MODE == hdd_get_conparam())
8327 {
8328 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d",
8329 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
8330 }
8331 else
8332 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d",
8334 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
8335 if (pAdapter != NULL)
8336 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05308337 if ( pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated )
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05308339 vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes,
8340 pHddCtx->cfg_ini->intfMacAddr[0].bytes,
8341 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudiedfc1b72012-10-18 20:25:55 -07008342
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05308343 /* Generate the P2P Device Address. This consists of the device's
8344 * primary MAC address with the locally administered bit set.
8345 */
8346 pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02;
Jeff Johnsone7245742012-09-05 17:12:55 -07008347 }
8348 else
8349 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05308350 tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx);
8351 if (p2p_dev_addr != NULL)
8352 {
8353 vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0],
8354 p2p_dev_addr, VOS_MAC_ADDR_SIZE);
8355 }
8356 else
8357 {
8358 hddLog(VOS_TRACE_LEVEL_FATAL,
8359 "%s: Failed to allocate mac_address for p2p_device",
8360 __func__);
8361 goto err_close_adapter;
8362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008364
8365 pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d",
8366 &pHddCtx->p2pDeviceAddress.bytes[0], FALSE );
8367 if ( NULL == pP2pAdapter )
8368 {
8369 hddLog(VOS_TRACE_LEVEL_FATAL,
8370 "%s: Failed to do hdd_open_adapter for P2P Device Interface",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008371 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07008372 goto err_close_adapter;
8373 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008376
8377 if( pAdapter == NULL )
8378 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008379 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
8380 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008382
Arif Hussain66559122013-11-21 10:11:40 -08008383 if (country_code)
8384 {
8385 eHalStatus ret;
Arif Hussaincb607082013-12-20 11:57:42 -08008386 INIT_COMPLETION(pAdapter->change_country_code);
Arif Hussain66559122013-11-21 10:11:40 -08008387 hdd_checkandupdate_dfssetting(pAdapter, country_code);
8388#ifndef CONFIG_ENABLE_LINUX_REG
8389 hdd_checkandupdate_phymode(pAdapter, country_code);
8390#endif
Arif Hussaineaf68602013-12-30 23:10:44 -08008391 ret = sme_ChangeCountryCode(pHddCtx->hHal,
8392 (void *)(tSmeChangeCountryCallback)
8393 wlan_hdd_change_country_code_callback,
Arif Hussain66559122013-11-21 10:11:40 -08008394 country_code,
8395 pAdapter, pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308396 eSIR_TRUE, eSIR_TRUE);
Arif Hussain66559122013-11-21 10:11:40 -08008397 if (eHAL_STATUS_SUCCESS == ret)
8398 {
Arif Hussaincb607082013-12-20 11:57:42 -08008399 ret = wait_for_completion_interruptible_timeout(
8400 &pAdapter->change_country_code,
8401 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
8402
8403 if (0 >= ret)
8404 {
8405 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8406 "%s: SME while setting country code timed out", __func__);
8407 }
Arif Hussain66559122013-11-21 10:11:40 -08008408 }
8409 else
8410 {
Arif Hussaincb607082013-12-20 11:57:42 -08008411 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8412 "%s: SME Change Country code from module param fail ret=%d",
8413 __func__, ret);
Arif Hussain66559122013-11-21 10:11:40 -08008414 }
8415 }
8416
Jeff Johnson295189b2012-06-20 16:38:30 -07008417#ifdef WLAN_BTAMP_FEATURE
8418 vStatus = WLANBAP_Open(pVosContext);
8419 if(!VOS_IS_STATUS_SUCCESS(vStatus))
8420 {
8421 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8422 "%s: Failed to open BAP",__func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07008423 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 }
8425
8426 vStatus = BSL_Init(pVosContext);
8427 if(!VOS_IS_STATUS_SUCCESS(vStatus))
8428 {
8429 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8430 "%s: Failed to Init BSL",__func__);
8431 goto err_bap_close;
8432 }
8433 vStatus = WLANBAP_Start(pVosContext);
8434 if (!VOS_IS_STATUS_SUCCESS(vStatus))
8435 {
8436 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8437 "%s: Failed to start TL",__func__);
8438 goto err_bap_close;
8439 }
8440
8441 pConfig = pHddCtx->cfg_ini;
8442 btAmpConfig.ucPreferredChannel = pConfig->preferredChannel;
8443 status = WLANBAP_SetConfig(&btAmpConfig);
8444
8445#endif //WLAN_BTAMP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -07008446
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008447#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8448 if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE))
8449 {
8450 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__);
8451 pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0;
8452 sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal),
8453 pHddCtx->cfg_ini->isRoamOffloadScanEnabled);
8454 }
8455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008456#ifdef FEATURE_WLAN_SCAN_PNO
8457 /*SME must send channel update configuration to RIVA*/
8458 sme_UpdateChannelConfig(pHddCtx->hHal);
8459#endif
8460
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05308461 sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done);
8462
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 /* Register with platform driver as client for Suspend/Resume */
8464 status = hddRegisterPmOps(pHddCtx);
8465 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8466 {
8467 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__);
8468#ifdef WLAN_BTAMP_FEATURE
8469 goto err_bap_stop;
8470#else
Jeff Johnsone7245742012-09-05 17:12:55 -07008471 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07008472#endif //WLAN_BTAMP_FEATURE
8473 }
8474
Yue Ma0d4891e2013-08-06 17:01:45 -07008475 /* Open debugfs interface */
8476 if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter))
8477 {
8478 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8479 "%s: hdd_debugfs_init failed!", __func__);
Yue Ma0d4891e2013-08-06 17:01:45 -07008480 }
8481
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 /* Register TM level change handler function to the platform */
8483 status = hddDevTmRegisterNotifyCallback(pHddCtx);
8484 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8485 {
8486 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__);
8487 goto err_unregister_pmops;
8488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008489
8490 /* register for riva power on lock to platform driver */
8491 if (req_riva_power_on_lock("wlan"))
8492 {
8493 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed",
8494 __func__);
8495 goto err_unregister_pmops;
8496 }
8497
Jeff Johnson295189b2012-06-20 16:38:30 -07008498 // register net device notifier for device change notification
8499 ret = register_netdevice_notifier(&hdd_netdev_notifier);
8500
8501 if(ret < 0)
8502 {
8503 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__);
8504 goto err_free_power_on_lock;
8505 }
8506
8507 //Initialize the nlink service
8508 if(nl_srv_init() != 0)
8509 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308510 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 goto err_reg_netdev;
8512 }
8513
Leo Chang4ce1cc52013-10-21 18:27:15 -07008514#ifdef WLAN_KD_READY_NOTIFIER
8515 pHddCtx->kd_nl_init = 1;
8516#endif /* WLAN_KD_READY_NOTIFIER */
8517
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 //Initialize the BTC service
8519 if(btc_activate_service(pHddCtx) != 0)
8520 {
8521 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__);
8522 goto err_nl_srv;
8523 }
8524
8525#ifdef PTT_SOCK_SVC_ENABLE
8526 //Initialize the PTT service
8527 if(ptt_sock_activate_svc(pHddCtx) != 0)
8528 {
8529 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__);
8530 goto err_nl_srv;
8531 }
8532#endif
8533
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 hdd_register_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 if (VOS_STA_SAP_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07008537 /* Action frame registered in one adapter which will
8538 * applicable to all interfaces
8539 */
Madan Mohan Koyyalamudie233e292012-09-18 17:38:02 -07008540 wlan_hdd_cfg80211_post_voss_start(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008542
8543 mutex_init(&pHddCtx->sap_lock);
8544
8545 pHddCtx->isLoadUnloadInProgress = FALSE;
8546
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008547#ifdef WLAN_OPEN_SOURCE
Jeff Johnsone7245742012-09-05 17:12:55 -07008548#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
8549 /* Initialize the wake lcok */
8550 wake_lock_init(&pHddCtx->rx_wake_lock,
8551 WAKE_LOCK_SUSPEND,
8552 "qcom_rx_wakelock");
8553#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08008554 /* Initialize the wake lcok */
8555 wake_lock_init(&pHddCtx->sap_wake_lock,
8556 WAKE_LOCK_SUSPEND,
8557 "qcom_sap_wakelock");
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008558#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008559
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008560 vos_event_init(&pHddCtx->scan_info.scan_finished_event);
8561 pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07008562
8563 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
8564 hdd_allow_suspend();
Abhishek Singha306a442013-11-07 18:39:01 +05308565#ifndef CONFIG_ENABLE_LINUX_REG
8566 /*updating wiphy so that regulatory user hints can be processed*/
8567 if (wiphy)
8568 {
8569 regulatory_hint(wiphy, "00");
8570 }
8571#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008572 // Initialize the restart logic
8573 wlan_hdd_restart_init(pHddCtx);
Chilam NG571c65a2013-01-19 12:27:36 +05308574
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07008575 //Register the traffic monitor timer now
8576 if ( pHddCtx->cfg_ini->dynSplitscan)
8577 {
8578 vos_timer_init(&pHddCtx->tx_rx_trafficTmr,
8579 VOS_TIMER_TYPE_SW,
8580 hdd_tx_rx_pkt_cnt_stat_timer_handler,
8581 (void *)pHddCtx);
8582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 goto success;
8584
8585err_nl_srv:
Leo Chang59cdc7e2013-07-10 10:08:21 -07008586#ifdef WLAN_KD_READY_NOTIFIER
8587 nl_srv_exit(pHddCtx->ptt_pid);
8588#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -07008590#endif /* WLAN_KD_READY_NOTIFIER */
Jeff Johnson295189b2012-06-20 16:38:30 -07008591err_reg_netdev:
8592 unregister_netdevice_notifier(&hdd_netdev_notifier);
8593
8594err_free_power_on_lock:
8595 free_riva_power_on_lock("wlan");
8596
8597err_unregister_pmops:
8598 hddDevTmUnregisterNotifyCallback(pHddCtx);
8599 hddDeregisterPmOps(pHddCtx);
8600
Yue Ma0d4891e2013-08-06 17:01:45 -07008601 hdd_debugfs_exit(pHddCtx);
8602
Jeff Johnson295189b2012-06-20 16:38:30 -07008603#ifdef WLAN_BTAMP_FEATURE
8604err_bap_stop:
8605 WLANBAP_Stop(pVosContext);
8606#endif
8607
8608#ifdef WLAN_BTAMP_FEATURE
8609err_bap_close:
8610 WLANBAP_Close(pVosContext);
8611#endif
8612
Jeff Johnson295189b2012-06-20 16:38:30 -07008613err_close_adapter:
8614 hdd_close_all_adapters( pHddCtx );
Amar Singhala49cbc52013-10-08 18:37:44 -07008615
8616#ifndef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308617 wiphy_unregister(wiphy) ;
Amar Singhala49cbc52013-10-08 18:37:44 -07008618#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008619
8620err_vosstop:
8621 vos_stop(pVosContext);
8622
Mihir Shetee1093ba2014-01-21 20:13:32 +05308623err_wiphy_unregister:
8624#ifdef CONFIG_ENABLE_LINUX_REG
8625 wiphy_unregister(wiphy);
8626#endif
8627
Amar Singhala49cbc52013-10-08 18:37:44 -07008628err_vosclose:
Jeff Johnson295189b2012-06-20 16:38:30 -07008629 status = vos_sched_close( pVosContext );
8630 if (!VOS_IS_STATUS_SUCCESS(status)) {
8631 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8632 "%s: Failed to close VOSS Scheduler", __func__);
8633 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
8634 }
Amar Singhala49cbc52013-10-08 18:37:44 -07008635 vos_close(pVosContext );
8636
Amar Singhala49cbc52013-10-08 18:37:44 -07008637#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07008638err_vos_nv_close:
8639
8640 vos_nv_close();
8641
Jeff Johnson295189b2012-06-20 16:38:30 -07008642err_clkvote:
Amar Singhala49cbc52013-10-08 18:37:44 -07008643#endif
8644
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008645 vos_chipVoteOffXOBuffer(NULL, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008646
8647err_wdclose:
8648 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8649 vos_watchdog_close(pVosContext);
8650
Jeff Johnson295189b2012-06-20 16:38:30 -07008651err_config:
8652 kfree(pHddCtx->cfg_ini);
8653 pHddCtx->cfg_ini= NULL;
8654
8655err_free_hdd_context:
8656 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 wiphy_free(wiphy) ;
8658 //kfree(wdev) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07008659 VOS_BUG(1);
8660
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08008661 if (hdd_is_ssr_required())
8662 {
8663 /* WDI timeout had happened during load, so SSR is needed here */
8664 subsystem_restart("wcnss");
8665 msleep(5000);
8666 }
8667 hdd_set_ssr_required (VOS_FALSE);
8668
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08008669 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008670
8671success:
8672 EXIT();
8673 return 0;
8674}
8675
8676/**---------------------------------------------------------------------------
8677
Jeff Johnson32d95a32012-09-10 13:15:23 -07008678 \brief hdd_driver_init() - Core Driver Init Function
Jeff Johnson295189b2012-06-20 16:38:30 -07008679
Jeff Johnson32d95a32012-09-10 13:15:23 -07008680 This is the driver entry point - called in different timeline depending
8681 on whether the driver is statically or dynamically linked
Jeff Johnson295189b2012-06-20 16:38:30 -07008682
8683 \param - None
8684
8685 \return - 0 for success, non zero for failure
8686
8687 --------------------------------------------------------------------------*/
Jeff Johnson32d95a32012-09-10 13:15:23 -07008688static int hdd_driver_init( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07008689{
8690 VOS_STATUS status;
8691 v_CONTEXT_t pVosContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008692 struct device *dev = NULL;
8693 int ret_status = 0;
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07008694#ifdef HAVE_WCNSS_CAL_DOWNLOAD
8695 int max_retries = 0;
8696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008697
Gopichand Nakkalad0774962013-05-24 11:32:21 +05308698#ifdef WCONN_TRACE_KMSG_LOG_BUFF
8699 vos_wconn_trace_init();
8700#endif
8701
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 ENTER();
8703
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008704#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan");
Jeff Johnsone7245742012-09-05 17:12:55 -07008706#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008707
8708 pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME,
8709 QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR);
8710
8711 //Power Up Libra WLAN card first if not already powered up
8712 status = vos_chipPowerUp(NULL,NULL,NULL);
8713 if (!VOS_IS_STATUS_SUCCESS(status))
8714 {
8715 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Libra WLAN not Powered Up. "
8716 "exiting", __func__);
madan mohan koyyalamudi8c96ce12013-07-10 19:14:39 +05308717#ifdef WLAN_OPEN_SOURCE
8718 wake_lock_destroy(&wlan_wake_lock);
8719#endif
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08008720 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 }
8722
Jeff Johnson295189b2012-06-20 16:38:30 -07008723#ifdef ANI_BUS_TYPE_PCI
8724
8725 dev = wcnss_wlan_get_device();
8726
8727#endif // ANI_BUS_TYPE_PCI
8728
8729#ifdef ANI_BUS_TYPE_PLATFORM
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07008730
8731#ifdef HAVE_WCNSS_CAL_DOWNLOAD
8732 /* wait until WCNSS driver downloads NV */
8733 while (!wcnss_device_ready() && 5 >= ++max_retries) {
8734 msleep(1000);
8735 }
8736 if (max_retries >= 5) {
8737 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__);
madan mohan koyyalamudi8c96ce12013-07-10 19:14:39 +05308738#ifdef WLAN_OPEN_SOURCE
8739 wake_lock_destroy(&wlan_wake_lock);
8740#endif
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07008741 return -ENODEV;
8742 }
8743#endif
8744
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 dev = wcnss_wlan_get_device();
8746#endif // ANI_BUS_TYPE_PLATFORM
8747
8748
8749 do {
8750 if (NULL == dev) {
8751 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__);
8752 ret_status = -1;
8753 break;
8754 }
8755
Jeff Johnson295189b2012-06-20 16:38:30 -07008756#ifdef TIMER_MANAGER
8757 vos_timer_manager_init();
8758#endif
8759
8760 /* Preopen VOSS so that it is ready to start at least SAL */
8761 status = vos_preOpen(&pVosContext);
8762
8763 if (!VOS_IS_STATUS_SUCCESS(status))
8764 {
8765 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__);
8766 ret_status = -1;
8767 break;
8768 }
8769
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07008770#ifndef MODULE
8771 /* For statically linked driver, call hdd_set_conparam to update curr_con_mode
8772 */
8773 hdd_set_conparam((v_UINT_t)con_mode);
8774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008775
8776 // Call our main init function
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008777 if (hdd_wlan_startup(dev))
8778 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed",
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008780 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 vos_preClose( &pVosContext );
8782 ret_status = -1;
8783 break;
8784 }
8785
8786 /* Cancel the vote for XO Core ON
8787 * This is done here for safety purposes in case we re-initialize without turning
8788 * it OFF in any error scenario.
8789 */
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07008790 hddLog(VOS_TRACE_LEVEL_INFO, "In module init: Ensure Force XO Core is OFF"
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 " when WLAN is turned ON so Core toggles"
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07008792 " unless we enter PSD");
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS)
8794 {
8795 hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel XO Core ON vote. Not returning failure."
Arif Hussain6d2a3322013-11-17 19:50:10 -08008796 " Power consumed will be high");
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 }
8798 } while (0);
8799
8800 if (0 != ret_status)
8801 {
8802 //Assert Deep sleep signal now to put Libra HW in lowest power state
8803 status = vos_chipAssertDeepSleep( NULL, NULL, NULL );
8804 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status) );
8805
8806 //Vote off any PMIC voltage supplies
8807 vos_chipPowerDown(NULL, NULL, NULL);
8808#ifdef TIMER_MANAGER
8809 vos_timer_exit();
8810#endif
8811#ifdef MEMORY_DEBUG
8812 vos_mem_exit();
8813#endif
8814
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008815#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 wake_lock_destroy(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008817#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 pr_err("%s: driver load failure\n", WLAN_MODULE_NAME);
8819 }
8820 else
8821 {
8822 //Send WLAN UP indication to Nlink Service
8823 send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0);
8824
8825 pr_info("%s: driver loaded\n", WLAN_MODULE_NAME);
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 }
8827
8828 EXIT();
8829
8830 return ret_status;
8831}
8832
Jeff Johnson32d95a32012-09-10 13:15:23 -07008833/**---------------------------------------------------------------------------
8834
8835 \brief hdd_module_init() - Init Function
8836
8837 This is the driver entry point (invoked when module is loaded using insmod)
8838
8839 \param - None
8840
8841 \return - 0 for success, non zero for failure
8842
8843 --------------------------------------------------------------------------*/
8844#ifdef MODULE
8845static int __init hdd_module_init ( void)
8846{
8847 return hdd_driver_init();
8848}
Jeff Johnson32d95a32012-09-10 13:15:23 -07008849#else /* #ifdef MODULE */
8850static int __init hdd_module_init ( void)
8851{
8852 /* Driver initialization is delayed to fwpath_changed_handler */
8853 return 0;
8854}
Jeff Johnson32d95a32012-09-10 13:15:23 -07008855#endif /* #ifdef MODULE */
8856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857
8858/**---------------------------------------------------------------------------
8859
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07008860 \brief hdd_driver_exit() - Exit function
Jeff Johnson295189b2012-06-20 16:38:30 -07008861
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07008862 This is the driver exit point (invoked when module is unloaded using rmmod
8863 or con_mode was changed by userspace)
Jeff Johnson295189b2012-06-20 16:38:30 -07008864
8865 \param - None
8866
8867 \return - None
8868
8869 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07008870static void hdd_driver_exit(void)
Jeff Johnson295189b2012-06-20 16:38:30 -07008871{
8872 hdd_context_t *pHddCtx = NULL;
8873 v_CONTEXT_t pVosContext = NULL;
Sameer Thalappil451ebb92013-06-28 15:49:58 -07008874 int retry = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008875
8876 pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR);
8877
8878 //Get the global vos context
8879 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
8880
8881 if(!pVosContext)
8882 {
8883 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
8884 goto done;
8885 }
8886
8887 //Get the HDD context.
8888 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
8889
8890 if(!pHddCtx)
8891 {
8892 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__);
8893 }
8894 else
8895 {
Sameer Thalappil14067972014-01-23 14:54:54 -08008896 while (pHddCtx->isLogpInProgress) {
Sameer Thalappil451ebb92013-06-28 15:49:58 -07008897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8898 "%s:SSR in Progress; block rmmod for 1 second!!!", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07008899 msleep(1000);
Sameer Thalappil451ebb92013-06-28 15:49:58 -07008900
8901 if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) {
8902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8903 "%s:SSR never completed, fatal error", __func__);
8904 VOS_BUG(0);
8905 }
8906 }
8907
Jeff Johnson295189b2012-06-20 16:38:30 -07008908
8909 pHddCtx->isLoadUnloadInProgress = TRUE;
8910 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
8911
8912 //Do all the cleanup before deregistering the driver
8913 hdd_wlan_exit(pHddCtx);
8914 }
8915
Jeff Johnson295189b2012-06-20 16:38:30 -07008916 vos_preClose( &pVosContext );
8917
8918#ifdef TIMER_MANAGER
8919 vos_timer_exit();
8920#endif
8921#ifdef MEMORY_DEBUG
8922 vos_mem_exit();
8923#endif
8924
Gopichand Nakkalad0774962013-05-24 11:32:21 +05308925#ifdef WCONN_TRACE_KMSG_LOG_BUFF
8926 vos_wconn_trace_exit();
8927#endif
8928
Jeff Johnson295189b2012-06-20 16:38:30 -07008929done:
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008930#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 wake_lock_destroy(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008932#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME);
8934}
8935
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07008936/**---------------------------------------------------------------------------
8937
8938 \brief hdd_module_exit() - Exit function
8939
8940 This is the driver exit point (invoked when module is unloaded using rmmod)
8941
8942 \param - None
8943
8944 \return - None
8945
8946 --------------------------------------------------------------------------*/
8947static void __exit hdd_module_exit(void)
8948{
8949 hdd_driver_exit();
8950}
8951
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008952#ifdef MODULE
8953static int fwpath_changed_handler(const char *kmessage,
8954 struct kernel_param *kp)
8955{
Jeff Johnson76052702013-04-16 13:55:05 -07008956 return param_set_copystring(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008957}
8958
8959static int con_mode_handler(const char *kmessage,
8960 struct kernel_param *kp)
8961{
Madan Mohan Koyyalamudif2f8d8b2012-10-11 17:06:59 -07008962 return param_set_int(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008963}
8964#else /* #ifdef MODULE */
8965/**---------------------------------------------------------------------------
8966
Jeff Johnson76052702013-04-16 13:55:05 -07008967 \brief kickstart_driver
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008968
Jeff Johnson76052702013-04-16 13:55:05 -07008969 This is the driver entry point
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008970 - delayed driver initialization when driver is statically linked
Jeff Johnson76052702013-04-16 13:55:05 -07008971 - invoked when module parameter fwpath is modified from userspace to signal
8972 initializing the WLAN driver or when con_mode is modified from userspace
8973 to signal a switch in operating mode
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008974
8975 \return - 0 for success, non zero for failure
8976
8977 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -07008978static int kickstart_driver(void)
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008979{
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -07008980 int ret_status;
8981
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008982 if (!wlan_hdd_inited) {
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -07008983 ret_status = hdd_driver_init();
8984 wlan_hdd_inited = ret_status ? 0 : 1;
8985 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008986 }
8987
8988 hdd_driver_exit();
Jeff Johnson76052702013-04-16 13:55:05 -07008989
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008990 msleep(200);
Jeff Johnson76052702013-04-16 13:55:05 -07008991
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -07008992 ret_status = hdd_driver_init();
8993 wlan_hdd_inited = ret_status ? 0 : 1;
8994 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07008995}
8996
Jeff Johnson295189b2012-06-20 16:38:30 -07008997/**---------------------------------------------------------------------------
8998
Jeff Johnson76052702013-04-16 13:55:05 -07008999 \brief fwpath_changed_handler() - Handler Function
9000
9001 Handle changes to the fwpath parameter
9002
9003 \return - 0 for success, non zero for failure
9004
9005 --------------------------------------------------------------------------*/
9006static int fwpath_changed_handler(const char *kmessage,
9007 struct kernel_param *kp)
9008{
9009 int ret;
9010
9011 ret = param_set_copystring(kmessage, kp);
9012 if (0 == ret)
9013 ret = kickstart_driver();
9014 return ret;
9015}
9016
9017/**---------------------------------------------------------------------------
9018
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009019 \brief con_mode_handler() -
9020
9021 Handler function for module param con_mode when it is changed by userspace
9022 Dynamically linked - do nothing
9023 Statically linked - exit and init driver, as in rmmod and insmod
9024
Jeff Johnson76052702013-04-16 13:55:05 -07009025 \param -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009026
Jeff Johnson76052702013-04-16 13:55:05 -07009027 \return -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009028
9029 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -07009030static int con_mode_handler(const char *kmessage, struct kernel_param *kp)
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009031{
Jeff Johnson76052702013-04-16 13:55:05 -07009032 int ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009033
Jeff Johnson76052702013-04-16 13:55:05 -07009034 ret = param_set_int(kmessage, kp);
9035 if (0 == ret)
9036 ret = kickstart_driver();
9037 return ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009038}
9039#endif /* #ifdef MODULE */
9040
9041/**---------------------------------------------------------------------------
9042
Jeff Johnson295189b2012-06-20 16:38:30 -07009043 \brief hdd_get_conparam() -
9044
9045 This is the driver exit point (invoked when module is unloaded using rmmod)
9046
9047 \param - None
9048
9049 \return - tVOS_CON_MODE
9050
9051 --------------------------------------------------------------------------*/
9052tVOS_CON_MODE hdd_get_conparam ( void )
9053{
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009054#ifdef MODULE
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 return (tVOS_CON_MODE)con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009056#else
9057 return (tVOS_CON_MODE)curr_con_mode;
9058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009059}
9060void hdd_set_conparam ( v_UINT_t newParam )
9061{
9062 con_mode = newParam;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009063#ifndef MODULE
9064 curr_con_mode = con_mode;
9065#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009066}
9067/**---------------------------------------------------------------------------
9068
9069 \brief hdd_softap_sta_deauth() - function
9070
9071 This to take counter measure to handle deauth req from HDD
9072
9073 \param - pAdapter - Pointer to the HDD
9074
9075 \param - enable - boolean value
9076
9077 \return - None
9078
9079 --------------------------------------------------------------------------*/
9080
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009081VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, v_U8_t *pDestMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009082{
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009084 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -07009085
9086 ENTER();
9087
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07009088 hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)",
9089 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07009090
9091 //Ignore request to deauth bcmc station
9092 if( pDestMacAddress[0] & 0x1 )
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009093 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07009094
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009095 vosStatus = WLANSAP_DeauthSta(pVosContext,pDestMacAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009096
9097 EXIT();
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009098 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07009099}
9100
9101/**---------------------------------------------------------------------------
9102
9103 \brief hdd_softap_sta_disassoc() - function
9104
9105 This to take counter measure to handle deauth req from HDD
9106
9107 \param - pAdapter - Pointer to the HDD
9108
9109 \param - enable - boolean value
9110
9111 \return - None
9112
9113 --------------------------------------------------------------------------*/
9114
9115void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress)
9116{
9117 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
9118
9119 ENTER();
9120
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309121 hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07009122
9123 //Ignore request to disassoc bcmc station
9124 if( pDestMacAddress[0] & 0x1 )
9125 return;
9126
9127 WLANSAP_DisassocSta(pVosContext,pDestMacAddress);
9128}
9129
9130void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable)
9131{
9132 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
9133
9134 ENTER();
9135
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309136 hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07009137
9138 WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable);
9139}
9140
Jeff Johnson295189b2012-06-20 16:38:30 -07009141/**---------------------------------------------------------------------------
9142 *
9143 * \brief hdd_get__concurrency_mode() -
9144 *
9145 *
9146 * \param - None
9147 *
9148 * \return - CONCURRENCY MODE
9149 *
9150 * --------------------------------------------------------------------------*/
9151tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void )
9152{
9153 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
9154 hdd_context_t *pHddCtx;
9155
9156 if (NULL != pVosContext)
9157 {
9158 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
9159 if (NULL != pHddCtx)
9160 {
9161 return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode;
9162 }
9163 }
9164
9165 /* we are in an invalid state :( */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009166 hddLog(LOGE, "%s: Invalid context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 return VOS_STA;
9168}
9169
9170/* Decide whether to allow/not the apps power collapse.
9171 * Allow apps power collapse if we are in connected state.
9172 * if not, allow only if we are in IMPS */
9173v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx)
9174{
9175 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
Srikant Kuppafef66a72013-01-30 17:32:44 -08009176 tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal);
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08009177 tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 hdd_config_t *pConfig = pHddCtx->cfg_ini;
9179 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9180 hdd_adapter_t *pAdapter = NULL;
9181 VOS_STATUS status;
Yathish9f22e662012-12-10 14:21:35 -08009182 tVOS_CONCURRENCY_MODE concurrent_state = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009183
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 if (VOS_STA_SAP_MODE == hdd_get_conparam())
9185 return TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009186
Yathish9f22e662012-12-10 14:21:35 -08009187 concurrent_state = hdd_get_concurrency_mode();
9188
9189#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9190 if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) ||
9191 (concurrent_state == (VOS_STA | VOS_P2P_GO))) &&
9192 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
9193 return TRUE;
9194#endif
9195
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 /*loop through all adapters. TBD fix for Concurrency */
9197 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9198 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9199 {
9200 pAdapter = pAdapterNode->pAdapter;
9201 if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
9202 || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
9203 {
Srikant Kuppafef66a72013-01-30 17:32:44 -08009204 if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 && (pmcState != IMPS && pmcState != BMPS
Srikant Kuppafef66a72013-01-30 17:32:44 -08009206 && pmcState != STOPPED && pmcState != STANDBY)) ||
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08009207 (eANI_BOOLEAN_TRUE == scanRspPending) ||
9208 (eANI_BOOLEAN_TRUE == inMiddleOfRoaming))
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 {
Srikant Kuppafef66a72013-01-30 17:32:44 -08009210 hddLog( LOGE, "%s: do not allow APPS power collapse-"
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08009211 "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d",
9212 __func__, pmcState, scanRspPending, inMiddleOfRoaming );
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 return FALSE;
9214 }
9215 }
9216 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9217 pAdapterNode = pNext;
9218 }
9219 return TRUE;
9220}
9221
Madan Mohan Koyyalamudic72a4d62012-11-08 14:59:34 -08009222/* Decides whether to send suspend notification to Riva
9223 * if any adapter is in BMPS; then it is required */
9224v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx)
9225{
9226 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
9227 hdd_config_t *pConfig = pHddCtx->cfg_ini;
9228
9229 if (pConfig->fIsBmpsEnabled && (pmcState == BMPS))
9230 {
9231 return TRUE;
9232 }
9233 return FALSE;
9234}
9235
Jeff Johnson295189b2012-06-20 16:38:30 -07009236void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
9237{
9238 switch(mode)
9239 {
Chilam Ngc4244af2013-04-01 15:37:32 -07009240 case VOS_STA_MODE:
9241 case VOS_P2P_CLIENT_MODE:
9242 case VOS_P2P_GO_MODE:
9243 case VOS_STA_SAP_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -07009244 pHddCtx->concurrency_mode |= (1 << mode);
9245 pHddCtx->no_of_sessions[mode]++;
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 break;
9247 default:
9248 break;
9249
9250 }
9251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d",
9252 __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]);
9253}
9254
9255
9256void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
9257{
9258 switch(mode)
9259 {
Chilam Ngc4244af2013-04-01 15:37:32 -07009260 case VOS_STA_MODE:
9261 case VOS_P2P_CLIENT_MODE:
9262 case VOS_P2P_GO_MODE:
9263 case VOS_STA_SAP_MODE:
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 pHddCtx->no_of_sessions[mode]--;
9265 if (!(pHddCtx->no_of_sessions[mode]))
9266 pHddCtx->concurrency_mode &= (~(1 << mode));
9267 break;
9268 default:
9269 break;
9270 }
9271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d",
9272 __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]);
9273}
9274
Jeff Johnsone7245742012-09-05 17:12:55 -07009275/**---------------------------------------------------------------------------
9276 *
9277 * \brief wlan_hdd_restart_init
9278 *
9279 * This function initalizes restart timer/flag. An internal function.
9280 *
9281 * \param - pHddCtx
9282 *
9283 * \return - None
9284 *
9285 * --------------------------------------------------------------------------*/
9286
9287static void wlan_hdd_restart_init(hdd_context_t *pHddCtx)
9288{
9289 /* Initialize */
9290 pHddCtx->hdd_restart_retries = 0;
9291 atomic_set(&pHddCtx->isRestartInProgress, 0);
9292 vos_timer_init(&pHddCtx->hdd_restart_timer,
9293 VOS_TIMER_TYPE_SW,
9294 wlan_hdd_restart_timer_cb,
9295 pHddCtx);
9296}
9297/**---------------------------------------------------------------------------
9298 *
9299 * \brief wlan_hdd_restart_deinit
9300 *
9301 * This function cleans up the resources used. An internal function.
9302 *
9303 * \param - pHddCtx
9304 *
9305 * \return - None
9306 *
9307 * --------------------------------------------------------------------------*/
9308
9309static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx)
9310{
9311
9312 VOS_STATUS vos_status;
9313 /* Block any further calls */
9314 atomic_set(&pHddCtx->isRestartInProgress, 1);
9315 /* Cleanup */
9316 vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer );
9317 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309318 hddLog(LOGE, FL("Failed to stop HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009319 vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer);
9320 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309321 hddLog(LOGE, FL("Failed to destroy HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009322
9323}
9324
9325/**---------------------------------------------------------------------------
9326 *
9327 * \brief wlan_hdd_framework_restart
9328 *
9329 * This function uses a cfg80211 API to start a framework initiated WLAN
9330 * driver module unload/load.
9331 *
9332 * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT).
9333 *
9334 *
9335 * \param - pHddCtx
9336 *
9337 * \return - VOS_STATUS_SUCCESS: Success
9338 * VOS_STATUS_E_EMPTY: Adapter is Empty
9339 * VOS_STATUS_E_NOMEM: No memory
9340
9341 * --------------------------------------------------------------------------*/
9342
9343static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx)
9344{
9345 VOS_STATUS status = VOS_STATUS_SUCCESS;
9346 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -07009347 int len = (sizeof (struct ieee80211_mgmt));
9348 struct ieee80211_mgmt *mgmt = NULL;
9349
9350 /* Prepare the DEAUTH managment frame with reason code */
9351 mgmt = kzalloc(len, GFP_KERNEL);
9352 if(mgmt == NULL)
9353 {
9354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9355 "%s: memory allocation failed (%d bytes)", __func__, len);
9356 return VOS_STATUS_E_NOMEM;
9357 }
9358 mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK;
Jeff Johnsone7245742012-09-05 17:12:55 -07009359
9360 /* Iterate over all adapters/devices */
9361 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9362 do
9363 {
9364 if( (status == VOS_STATUS_SUCCESS) &&
9365 pAdapterNode &&
9366 pAdapterNode->pAdapter)
9367 {
9368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9369 "restarting the driver(intf:\'%s\' mode:%d :try %d)",
9370 pAdapterNode->pAdapter->dev->name,
9371 pAdapterNode->pAdapter->device_mode,
9372 pHddCtx->hdd_restart_retries + 1);
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -07009373 /*
9374 * CFG80211 event to restart the driver
9375 *
9376 * 'cfg80211_send_unprot_deauth' sends a
9377 * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state
9378 * of SME(Linux Kernel) state machine.
9379 *
9380 * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart
9381 * the driver.
9382 *
9383 */
9384
9385 cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len );
Jeff Johnsone7245742012-09-05 17:12:55 -07009386 }
9387 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9388 pAdapterNode = pNext;
9389 } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status));
9390
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -07009391
9392 /* Free the allocated management frame */
9393 kfree(mgmt);
9394
Jeff Johnsone7245742012-09-05 17:12:55 -07009395 /* Retry until we unload or reach max count */
9396 if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT)
9397 vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS);
9398
9399 return status;
9400
9401}
9402/**---------------------------------------------------------------------------
9403 *
9404 * \brief wlan_hdd_restart_timer_cb
9405 *
9406 * Restart timer callback. An internal function.
9407 *
9408 * \param - User data:
9409 *
9410 * \return - None
9411 *
9412 * --------------------------------------------------------------------------*/
9413
9414void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback)
9415{
9416 hdd_context_t *pHddCtx = usrDataForCallback;
9417 wlan_hdd_framework_restart(pHddCtx);
9418 return;
9419
9420}
9421
9422
9423/**---------------------------------------------------------------------------
9424 *
9425 * \brief wlan_hdd_restart_driver
9426 *
9427 * This function sends an event to supplicant to restart the WLAN driver.
9428 *
9429 * This function is called from vos_wlanRestart.
9430 *
9431 * \param - pHddCtx
9432 *
9433 * \return - VOS_STATUS_SUCCESS: Success
9434 * VOS_STATUS_E_EMPTY: Adapter is Empty
9435 * VOS_STATUS_E_ALREADY: Request already in progress
9436
9437 * --------------------------------------------------------------------------*/
9438VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx)
9439{
9440 VOS_STATUS status = VOS_STATUS_SUCCESS;
9441
9442 /* A tight check to make sure reentrancy */
9443 if(atomic_xchg(&pHddCtx->isRestartInProgress, 1))
9444 {
9445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9446 "%s: WLAN restart is already in progress", __func__);
9447
9448 return VOS_STATUS_E_ALREADY;
9449 }
Sameer Thalappil0c164f52013-03-28 15:27:56 -07009450 /* Send reset FIQ to WCNSS to invoke SSR. */
Madan Mohan Koyyalamudie388b342012-11-08 15:03:16 -08009451#ifdef HAVE_WCNSS_RESET_INTR
Madan Mohan Koyyalamudibb8f0172012-09-28 15:36:06 -07009452 wcnss_reset_intr();
9453#endif
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07009454
Jeff Johnsone7245742012-09-05 17:12:55 -07009455 return status;
9456}
9457
Mihir Shetee1093ba2014-01-21 20:13:32 +05309458/**---------------------------------------------------------------------------
9459 *
9460 * \brief wlan_hdd_init_channels
9461 *
9462 * This function is used to initialize the channel list in CSR
9463 *
9464 * This function is called from hdd_wlan_startup
9465 *
9466 * \param - pHddCtx: HDD context
9467 *
9468 * \return - VOS_STATUS_SUCCESS: Success
9469 * VOS_STATUS_E_FAULT: Failure reported by SME
9470
9471 * --------------------------------------------------------------------------*/
9472static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx)
9473{
9474 eHalStatus status;
9475
9476 status = sme_InitChannels(pHddCtx->hHal);
9477 if (HAL_STATUS_SUCCESS(status))
9478 {
9479 return VOS_STATUS_SUCCESS;
9480 }
9481 else
9482 {
9483 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)",
9484 __func__, status);
9485 return VOS_STATUS_E_FAULT;
9486 }
9487}
9488
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07009489/*
9490 * API to find if there is any STA or P2P-Client is connected
9491 */
9492VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx)
9493{
9494 return sme_isSta_p2p_clientConnected(pHddCtx->hHal);
9495}
Jeff Johnsone7245742012-09-05 17:12:55 -07009496
Jeff Johnson295189b2012-06-20 16:38:30 -07009497//Register the module init/exit functions
9498module_init(hdd_module_init);
9499module_exit(hdd_module_exit);
9500
9501MODULE_LICENSE("Dual BSD/GPL");
9502MODULE_AUTHOR("Qualcomm Atheros, Inc.");
9503MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER");
9504
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009505module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode,
9506 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009507
Jeff Johnson76052702013-04-16 13:55:05 -07009508module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath,
Jeff Johnson32d95a32012-09-10 13:15:23 -07009509 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Arif Hussain66559122013-11-21 10:11:40 -08009510
9511module_param(enable_dfs_chan_scan, int,
9512 S_IRUSR | S_IRGRP | S_IROTH);
9513
9514module_param(enable_11d, int,
9515 S_IRUSR | S_IRGRP | S_IROTH);
9516
9517module_param(country_code, charp,
9518 S_IRUSR | S_IRGRP | S_IROTH);