blob: 5541c8affa594dfb7aade06f70d4fa3a492f90d9 [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 Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/*========================================================================
32
33 \file wlan_hdd_main.c
34
35 \brief WLAN Host Device Driver implementation
36
37 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
38
39 Qualcomm Confidential and Proprietary.
40
41 ========================================================================*/
42
43/**=========================================================================
44
45 EDIT HISTORY FOR FILE
46
47
48 This section contains comments describing changes made to the module.
49 Notice that changes are listed in reverse chronological order.
50
51
52 $Header:$ $DateTime: $ $Author: $
53
54
55 when who what, where, why
56 -------- --- --------------------------------------------------------
57 04/5/09 Shailender Created module.
58 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module
59 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
60 ==========================================================================*/
61
62/*--------------------------------------------------------------------------
63 Include Files
64 ------------------------------------------------------------------------*/
65//#include <wlan_qct_driver.h>
66#include <wlan_hdd_includes.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include <vos_api.h>
68#include <vos_sched.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070069#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>
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053084#include <wlan_logging_sock_svc.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include <wlan_hdd_wowl.h>
86#include <wlan_hdd_misc.h>
87#include <wlan_hdd_wext.h>
88#ifdef WLAN_BTAMP_FEATURE
89#include <bap_hdd_main.h>
90#include <bapInternal.h>
91#endif // WLAN_BTAMP_FEATURE
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053092#include "wlan_hdd_trace.h"
93#include "vos_types.h"
94#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095#include <linux/wireless.h>
96#include <net/cfg80211.h>
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +053097#include <linux/inetdevice.h>
98#include <net/addrconf.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070099#include "wlan_hdd_cfg80211.h"
100#include "wlan_hdd_p2p.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700101#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700102int wlan_hdd_ftm_start(hdd_context_t *pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700103#include "sapApi.h"
104#include <linux/semaphore.h>
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -0700105#include <linux/ctype.h>
Arun Kumar Khandavalli74fe3032014-03-17 20:35:34 +0530106#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
107#include <soc/qcom/subsystem_restart.h>
108#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#include <mach/subsystem_restart.h>
Arun Kumar Khandavalli74fe3032014-03-17 20:35:34 +0530110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700111#include <wlan_hdd_hostapd.h>
112#include <wlan_hdd_softap_tx_rx.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#include "cfgApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700114#include "wlan_hdd_dev_pwr.h"
115#ifdef WLAN_BTAMP_FEATURE
116#include "bap_hdd_misc.h"
117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118#include "wlan_qct_pal_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700119#include "qwlan_version.h"
Yathish9f22e662012-12-10 14:21:35 -0800120#include "wlan_qct_wda.h"
Chilam NG571c65a2013-01-19 12:27:36 +0530121#ifdef FEATURE_WLAN_TDLS
122#include "wlan_hdd_tdls.h"
123#endif
Yue Ma0d4891e2013-08-06 17:01:45 -0700124#include "wlan_hdd_debugfs.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700125
126#ifdef MODULE
127#define WLAN_MODULE_NAME module_name(THIS_MODULE)
128#else
129#define WLAN_MODULE_NAME "wlan"
130#endif
131
132#ifdef TIMER_MANAGER
133#define TIMER_MANAGER_STR " +TIMER_MANAGER"
134#else
135#define TIMER_MANAGER_STR ""
136#endif
137
138#ifdef MEMORY_DEBUG
139#define MEMORY_DEBUG_STR " +MEMORY_DEBUG"
140#else
141#define MEMORY_DEBUG_STR ""
142#endif
Kaushik, Sushant7005e372014-04-08 11:36:54 +0530143#define MAX_WAIT_FOR_ROC_COMPLETION 3
Jeff Johnson295189b2012-06-20 16:38:30 -0700144/* the Android framework expects this param even though we don't use it */
145#define BUF_LEN 20
Jeff Johnson76052702013-04-16 13:55:05 -0700146static char fwpath_buffer[BUF_LEN];
147static struct kparam_string fwpath = {
148 .string = fwpath_buffer,
149 .maxlen = BUF_LEN,
150};
Arif Hussain66559122013-11-21 10:11:40 -0800151
152static char *country_code;
153static int enable_11d = -1;
154static int enable_dfs_chan_scan = -1;
c_hpothu92367912014-05-01 15:18:17 +0530155static int gbcnMissRate = -1;
Arif Hussain66559122013-11-21 10:11:40 -0800156
Madan Mohan Koyyalamudi05f313c2012-09-18 19:19:15 -0700157#ifndef MODULE
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700158static int wlan_hdd_inited;
Madan Mohan Koyyalamudi05f313c2012-09-18 19:19:15 -0700159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700160
Jeff Johnsone7245742012-09-05 17:12:55 -0700161/*
Jeff Johnson72a40512013-12-19 10:14:15 -0800162 * spinlock for synchronizing asynchronous request/response
163 * (full description of use in wlan_hdd_main.h)
164 */
165DEFINE_SPINLOCK(hdd_context_lock);
166
167/*
Jeff Johnsone7245742012-09-05 17:12:55 -0700168 * The rate at which the driver sends RESTART event to supplicant
169 * once the function 'vos_wlanRestart()' is called
170 *
171 */
172#define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */
173#define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700174
175/*
176 * Size of Driver command strings from upper layer
177 */
178#define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */
179#define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */
180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800181#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700182#define TID_MIN_VALUE 0
183#define TID_MAX_VALUE 15
184static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
185 tAniTrafStrmMetrics* pTsmMetrics);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800186static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue,
187 tCsrEseBeaconReq *pEseBcnReq);
188#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700189
Atul Mittal1d722422014-03-19 11:15:07 +0530190/*
191 * Maximum buffer size used for returning the data back to user space
192 */
193#define WLAN_MAX_BUF_SIZE 1024
194#define WLAN_PRIV_DATA_MAX_LEN 8192
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700195
c_hpothu92367912014-05-01 15:18:17 +0530196//wait time for beacon miss rate.
197#define BCN_MISS_RATE_TIME 500
198
Sameer Thalappil50dc0092013-02-19 17:23:33 -0800199#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -0700200static struct wake_lock wlan_wake_lock;
Jeff Johnsone7245742012-09-05 17:12:55 -0700201#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700202/* set when SSR is needed after unload */
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700203static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700204
205//internal function declaration
Jeff Johnsone7245742012-09-05 17:12:55 -0700206static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx);
207static void wlan_hdd_restart_init(hdd_context_t *pHddCtx);
208static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx);
209void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback);
Sameer Thalappil45931fb2013-02-01 11:18:05 -0800210void hdd_set_wlan_suspend_mode(bool suspend);
Jeff Johnsone7245742012-09-05 17:12:55 -0700211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212v_U16_t hdd_select_queue(struct net_device *dev,
213 struct sk_buff *skb);
214
215#ifdef WLAN_FEATURE_PACKET_FILTERING
216static void hdd_set_multicast_list(struct net_device *dev);
217#endif
218
219void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter);
220
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800221#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -0800222void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand);
223static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels);
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700224static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid,
225 tANI_U8 *pChannel, tANI_U8 *pDwellTime,
226 tANI_U8 **pBuf, tANI_U8 *pBufLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -0700227static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
228 tANI_U8 *pTargetApBssid,
229 tANI_U8 *pChannel);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800230#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800231#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700232VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800233#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700234
Mihir Shetee1093ba2014-01-21 20:13:32 +0530235static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx);
Sushant Kaushik8bc7df22014-04-09 17:55:29 +0530236const char * hdd_device_modetoString(v_U8_t device_mode)
237{
238 switch(device_mode)
239 {
240 CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION );
241 CASE_RETURN_STRING( WLAN_HDD_SOFTAP );
242 CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT );
243 CASE_RETURN_STRING( WLAN_HDD_P2P_GO );
244 CASE_RETURN_STRING( WLAN_HDD_MONITOR);
245 CASE_RETURN_STRING( WLAN_HDD_FTM );
246 CASE_RETURN_STRING( WLAN_HDD_IBSS );
247 CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE );
248 default:
249 return "device_mode Unknown";
250 }
251}
Mihir Shetee1093ba2014-01-21 20:13:32 +0530252
Jeff Johnson295189b2012-06-20 16:38:30 -0700253static int hdd_netdev_notifier_call(struct notifier_block * nb,
254 unsigned long state,
255 void *ndev)
256{
257 struct net_device *dev = ndev;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700258 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson27cee452013-03-27 11:10:24 -0700259 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700260#ifdef WLAN_BTAMP_FEATURE
261 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700262#endif
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530263 long result;
Jeff Johnson295189b2012-06-20 16:38:30 -0700264
265 //Make sure that this callback corresponds to our device.
Jeff Johnson27cee452013-03-27 11:10:24 -0700266 if ((strncmp(dev->name, "wlan", 4)) &&
Amar Singhal4c723bd2013-03-25 18:14:15 -0700267 (strncmp(dev->name, "p2p", 3)))
268 return NOTIFY_DONE;
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 if (!dev->ieee80211_ptr)
Jeff Johnson27cee452013-03-27 11:10:24 -0700271 return NOTIFY_DONE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
Jeff Johnson27cee452013-03-27 11:10:24 -0700273 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -0800275 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 VOS_ASSERT(0);
277 return NOTIFY_DONE;
278 }
279
Jeff Johnson27cee452013-03-27 11:10:24 -0700280 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
281 if (NULL == pHddCtx)
282 {
283 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__);
284 VOS_ASSERT(0);
285 return NOTIFY_DONE;
286 }
Sameer Thalappil14067972014-01-23 14:54:54 -0800287 if (pHddCtx->isLogpInProgress)
288 return NOTIFY_DONE;
289
Jeff Johnson27cee452013-03-27 11:10:24 -0700290
291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu",
292 __func__, dev->name, state);
Jeff Johnson295189b2012-06-20 16:38:30 -0700293
294 switch (state) {
295 case NETDEV_REGISTER:
296 break;
297
298 case NETDEV_UNREGISTER:
299 break;
300
301 case NETDEV_UP:
302 break;
303
304 case NETDEV_DOWN:
305 break;
306
307 case NETDEV_CHANGE:
Jeff Johnsone7245742012-09-05 17:12:55 -0700308 if(TRUE == pAdapter->isLinkUpSvcNeeded)
309 complete(&pAdapter->linkup_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 break;
311
312 case NETDEV_GOING_DOWN:
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530313 result = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +0530314 if (result < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530315 {
316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
317 "%s: Timeout occurred while waiting for abortscan %ld",
318 __func__, result);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 }
320 else
321 {
322 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530323 "%s: Scan Abort Successful" , __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 }
325#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 status = WLANBAP_StopAmp();
328 if(VOS_STATUS_SUCCESS != status )
329 {
330 pHddCtx->isAmpAllowed = VOS_TRUE;
331 hddLog(VOS_TRACE_LEVEL_FATAL,
332 "%s: Failed to stop AMP", __func__);
333 }
334 else
335 {
336 //a state m/c implementation in PAL is TBD to avoid this delay
337 msleep(500);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700338 if ( pHddCtx->isAmpAllowed )
339 {
340 WLANBAP_DeregisterFromHCI();
341 pHddCtx->isAmpAllowed = VOS_FALSE;
342 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 }
344#endif //WLAN_BTAMP_FEATURE
345 break;
346
347 default:
348 break;
349 }
350
351 return NOTIFY_DONE;
352}
353
354struct notifier_block hdd_netdev_notifier = {
355 .notifier_call = hdd_netdev_notifier_call,
356};
357
358/*---------------------------------------------------------------------------
359 * Function definitions
360 *-------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700361void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx);
362void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700363//variable to hold the insmod parameters
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700364static int con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -0700365#ifndef MODULE
366/* current con_mode - used only for statically linked driver
367 * con_mode is changed by userspace to indicate a mode change which will
368 * result in calling the module exit and init functions. The module
369 * exit function will clean up based on the value of con_mode prior to it
370 * being changed by userspace. So curr_con_mode records the current con_mode
371 * for exit when con_mode becomes the next mode for init
372 */
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700373static int curr_con_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700374#endif
375
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -0800376/**---------------------------------------------------------------------------
377
378 \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable
379
380 Called immediately after the cfg.ini is read in order to configure
381 the desired trace levels.
382
383 \param - moduleId - module whose trace level is being configured
384 \param - bitmask - bitmask of log levels to be enabled
385
386 \return - void
387
388 --------------------------------------------------------------------------*/
389static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask)
390{
391 wpt_tracelevel level;
392
393 /* if the bitmask is the default value, then a bitmask was not
394 specified in cfg.ini, so leave the logging level alone (it
395 will remain at the "compiled in" default value) */
396 if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask)
397 {
398 return;
399 }
400
401 /* a mask was specified. start by disabling all logging */
402 vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0);
403
404 /* now cycle through the bitmask until all "set" bits are serviced */
405 level = VOS_TRACE_LEVEL_FATAL;
406 while (0 != bitmask)
407 {
408 if (bitmask & 1)
409 {
410 vos_trace_setValue(moduleId, level, 1);
411 }
412 level++;
413 bitmask >>= 1;
414 }
415}
416
417
Jeff Johnson295189b2012-06-20 16:38:30 -0700418/**---------------------------------------------------------------------------
419
420 \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable
421
422 Called immediately after the cfg.ini is read in order to configure
423 the desired trace levels in the WDI.
424
425 \param - moduleId - module whose trace level is being configured
426 \param - bitmask - bitmask of log levels to be enabled
427
428 \return - void
429
430 --------------------------------------------------------------------------*/
431static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask)
432{
433 wpt_tracelevel level;
434
435 /* if the bitmask is the default value, then a bitmask was not
436 specified in cfg.ini, so leave the logging level alone (it
437 will remain at the "compiled in" default value) */
438 if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask)
439 {
440 return;
441 }
442
443 /* a mask was specified. start by disabling all logging */
444 wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0);
445
446 /* now cycle through the bitmask until all "set" bits are serviced */
447 level = eWLAN_PAL_TRACE_LEVEL_FATAL;
448 while (0 != bitmask)
449 {
450 if (bitmask & 1)
451 {
452 wpalTraceSetLevel(moduleId, level, 1);
453 }
454 level++;
455 bitmask >>= 1;
456 }
457}
Jeff Johnson295189b2012-06-20 16:38:30 -0700458
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530459/*
460 * FUNCTION: wlan_hdd_validate_context
461 * This function is used to check the HDD context
462 */
463int wlan_hdd_validate_context(hdd_context_t *pHddCtx)
464{
465 ENTER();
466
467 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
468 {
469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
470 "%s: HDD context is Null", __func__);
471 return -ENODEV;
472 }
473
474 if (pHddCtx->isLogpInProgress)
475 {
476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
477 "%s: LOGP in Progress. Ignore!!!", __func__);
478 return -EAGAIN;
479 }
480
Mihir Shete18156292014-03-11 15:38:30 +0530481 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530482 {
483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
484 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
485 return -EAGAIN;
486 }
487 return 0;
488}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700489#ifdef CONFIG_ENABLE_LINUX_REG
490void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx)
491{
492 hdd_adapter_t *pAdapter = NULL;
493 hdd_station_ctx_t *pHddStaCtx = NULL;
494 eCsrPhyMode phyMode;
495 hdd_config_t *cfg_param = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530496
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700497 if (NULL == pHddCtx)
498 {
499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
500 "HDD Context is null !!");
501 return ;
502 }
503
504 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
505 if (NULL == pAdapter)
506 {
507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
508 "pAdapter is null !!");
509 return ;
510 }
511
512 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
513 if (NULL == pHddStaCtx)
514 {
515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
516 "pHddStaCtx is null !!");
517 return ;
518 }
519
520 cfg_param = pHddCtx->cfg_ini;
521 if (NULL == cfg_param)
522 {
523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
524 "cfg_params not available !!");
525 return ;
526 }
527
528 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
529
530 if (!pHddCtx->isVHT80Allowed)
531 {
532 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
533 (eCSR_DOT11_MODE_11ac == phyMode) ||
534 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
535 {
536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
537 "Setting phymode to 11n!!");
538 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
539 }
540 }
541 else
542 {
543 /*New country Supports 11ac as well resetting value back from .ini*/
544 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
545 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
546 return ;
547 }
548
549 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
550 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
551 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
552 {
553 VOS_STATUS vosStatus;
554
555 // need to issue a disconnect to CSR.
556 INIT_COMPLETION(pAdapter->disconnect_comp_var);
557 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
558 pAdapter->sessionId,
559 eCSR_DISCONNECT_REASON_UNSPECIFIED );
560
561 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530562 {
563 long ret;
564
565 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700566 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530567 if (0 >= ret)
568 hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"),
569 ret);
570 }
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700571
572 }
573}
574#else
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530575void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code)
576{
577 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
578 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
579 hdd_config_t *cfg_param;
580 eCsrPhyMode phyMode;
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530581 long ret;
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530582
583 if (NULL == pHddCtx)
584 {
585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
586 "HDD Context is null !!");
587 return ;
588 }
589
590 cfg_param = pHddCtx->cfg_ini;
591
592 if (NULL == cfg_param)
593 {
594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
595 "cfg_params not available !!");
596 return ;
597 }
598
599 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
600
601 if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code))
602 {
603 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
604 (eCSR_DOT11_MODE_11ac == phyMode) ||
605 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
608 "Setting phymode to 11n!!");
609 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
610 }
611 }
612 else
613 {
614 /*New country Supports 11ac as well resetting value back from .ini*/
615 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
616 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
617 return ;
618 }
619
620 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
621 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
622 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
623 {
624 VOS_STATUS vosStatus;
625
626 // need to issue a disconnect to CSR.
627 INIT_COMPLETION(pAdapter->disconnect_comp_var);
628 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
629 pAdapter->sessionId,
630 eCSR_DISCONNECT_REASON_UNSPECIFIED );
631
632 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530633 {
634 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530635 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530636 if (ret <= 0)
637 {
638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
639 "wait on disconnect_comp_var is failed %ld", ret);
640 }
641 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530642
643 }
644}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700645#endif //CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530646
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700647void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code)
648{
649 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
650 hdd_config_t *cfg_param;
651
652 if (NULL == pHddCtx)
653 {
654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
655 "HDD Context is null !!");
656 return ;
657 }
658
659 cfg_param = pHddCtx->cfg_ini;
660
661 if (NULL == cfg_param)
662 {
663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
664 "cfg_params not available !!");
665 return ;
666 }
667
Agarwal Ashish738843c2014-09-25 12:27:56 +0530668 if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) ||
669 pHddCtx->disable_dfs_flag == TRUE)
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700670 {
671 /*New country doesn't support DFS */
672 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0);
673 }
674 else
675 {
676 /*New country Supports DFS as well resetting value back from .ini*/
677 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan);
678 }
679
680}
681
Rajeev79dbe4c2013-10-05 11:03:42 +0530682#ifdef FEATURE_WLAN_BATCH_SCAN
683
684/**---------------------------------------------------------------------------
685
686 \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from
687 input string
688
689 This function extracts assigned integer from string in below format:
690 "STRING=10" : extracts integer 10 from this string
691
692 \param - pInPtr Pointer to input string
693 \param - base Base for string to int conversion(10 for decimal 16 for hex)
694 \param - pOutPtr Pointer to variable in which extracted integer needs to be
695 assigned
696 \param - pLastArg to tell whether it is last arguement in input string or
697 not
698
699 \return - NULL for failure cases
700 pointer to next arguement in input string for success cases
701 --------------------------------------------------------------------------*/
702static tANI_U8 *
703hdd_extract_assigned_int_from_str
704(
705 tANI_U8 *pInPtr,
706 tANI_U8 base,
707 tANI_U32 *pOutPtr,
708 tANI_U8 *pLastArg
709)
710{
711 int tempInt;
712 int v = 0;
713 char buf[32];
714 int val = 0;
715 *pLastArg = FALSE;
716
717 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
718 if (NULL == pInPtr)
719 {
720 return NULL;
721 }
722
723 pInPtr++;
724
725 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
726
727 val = sscanf(pInPtr, "%32s ", buf);
728 if (val < 0 && val > strlen(pInPtr))
729 {
730 return NULL;
731 }
732 pInPtr += val;
733 v = kstrtos32(buf, base, &tempInt);
734 if (v < 0)
735 {
736 return NULL;
737 }
Rajeev Kumar4d93d842014-01-02 18:31:21 -0800738 if (tempInt < 0)
739 {
740 tempInt = 0;
741 }
Rajeev79dbe4c2013-10-05 11:03:42 +0530742 *pOutPtr = tempInt;
743
744 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
745 if (NULL == pInPtr)
746 {
747 *pLastArg = TRUE;
748 return NULL;
749 }
750 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
751
752 return pInPtr;
753}
754
755/**---------------------------------------------------------------------------
756
757 \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from
758 input string
759
760 This function extracts assigned character from string in below format:
761 "STRING=A" : extracts char 'A' from this string
762
763 \param - pInPtr Pointer to input string
764 \param - pOutPtr Pointer to variable in which extracted char needs to be
765 assigned
766 \param - pLastArg to tell whether it is last arguement in input string or
767 not
768
769 \return - NULL for failure cases
770 pointer to next arguement in input string for success cases
771 --------------------------------------------------------------------------*/
772static tANI_U8 *
773hdd_extract_assigned_char_from_str
774(
775 tANI_U8 *pInPtr,
776 tANI_U8 *pOutPtr,
777 tANI_U8 *pLastArg
778)
779{
780 *pLastArg = FALSE;
781
782 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
783 if (NULL == pInPtr)
784 {
785 return NULL;
786 }
787
788 pInPtr++;
789
790 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
791
792 *pOutPtr = *pInPtr;
793
794 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
795 if (NULL == pInPtr)
796 {
797 *pLastArg = TRUE;
798 return NULL;
799 }
800 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
801
802 return pInPtr;
803}
804
805
806/**---------------------------------------------------------------------------
807
808 \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command
809
810 This function parses set batch scan command in below format:
811 WLS_BATCHING_SET <space> followed by below arguements
812 "SCANFREQ=XX" : Optional defaults to 30 sec
813 "MSCAN=XX" : Required number of scans to attempt to batch
814 "BESTN=XX" : Best Network (RSSI) defaults to 16
815 "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B.
816 A. implies only 5 GHz , B. implies only 2.4GHz
817 "RTT=X" : optional defaults to 0
818 returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on
819 error
820
821 For example input commands:
822 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is
823 translated into set batch scan with following parameters:
824 a) Frequence 60 seconds
825 b) Batch 10 scans together
826 c) Best RSSI to be 20
827 d) 5GHz band only
828 e) RTT is equal to 0
829
830 \param - pValue Pointer to input channel list
831 \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure
832
833 \return - 0 for success non-zero for failure
834
835 --------------------------------------------------------------------------*/
836static int
837hdd_parse_set_batchscan_command
838(
839 tANI_U8 *pValue,
840 tSirSetBatchScanReq *pHddSetBatchScanReq
841)
842{
843 tANI_U8 *inPtr = pValue;
844 tANI_U8 val = 0;
845 tANI_U8 lastArg = 0;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800846 tANI_U32 nScanFreq;
847 tANI_U32 nMscan;
848 tANI_U32 nBestN;
849 tANI_U8 ucRfBand;
850 tANI_U32 nRtt;
Rajeev Kumarc933d982013-11-18 20:04:20 -0800851 tANI_U32 temp;
Rajeev79dbe4c2013-10-05 11:03:42 +0530852
853 /*initialize default values*/
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800854 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ;
855 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
856 nRtt = 0;
857 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK;
Rajeev79dbe4c2013-10-05 11:03:42 +0530858
859 /*go to space after WLS_BATCHING_SET command*/
860 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
861 /*no argument after the command*/
862 if (NULL == inPtr)
863 {
864 return -EINVAL;
865 }
866
867 /*no space after the command*/
868 else if (SPACE_ASCII_VALUE != *inPtr)
869 {
870 return -EINVAL;
871 }
872
873 /*removing empty spaces*/
874 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
875
876 /*no argument followed by spaces*/
877 if ('\0' == *inPtr)
878 {
879 return -EINVAL;
880 }
881
882 /*check and parse SCANFREQ*/
883 if ((strncmp(inPtr, "SCANFREQ", 8) == 0))
884 {
885 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800886 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800887
Rajeev Kumarc933d982013-11-18 20:04:20 -0800888 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800889 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800890 nScanFreq = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800891 }
892
Rajeev79dbe4c2013-10-05 11:03:42 +0530893 if ( (NULL == inPtr) || (TRUE == lastArg))
894 {
895 return -EINVAL;
896 }
897 }
898
899 /*check and parse MSCAN*/
900 if ((strncmp(inPtr, "MSCAN", 5) == 0))
901 {
902 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800903 &nMscan, &lastArg);
904
905 if (0 == nMscan)
906 {
907 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
908 "invalid MSCAN=%d", nMscan);
909 return -EINVAL;
910 }
911
Rajeev79dbe4c2013-10-05 11:03:42 +0530912 if (TRUE == lastArg)
913 {
914 goto done;
915 }
916 else if (NULL == inPtr)
917 {
918 return -EINVAL;
919 }
920 }
921 else
922 {
923 return -EINVAL;
924 }
925
926 /*check and parse BESTN*/
927 if ((strncmp(inPtr, "BESTN", 5) == 0))
928 {
929 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800930 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800931
Rajeev Kumarc933d982013-11-18 20:04:20 -0800932 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800933 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800934 nBestN = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800935 }
936
Rajeev79dbe4c2013-10-05 11:03:42 +0530937 if (TRUE == lastArg)
938 {
939 goto done;
940 }
941 else if (NULL == inPtr)
942 {
943 return -EINVAL;
944 }
945 }
946
947 /*check and parse CHANNEL*/
948 if ((strncmp(inPtr, "CHANNEL", 7) == 0))
949 {
950 inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg);
Rajeev Kumarc933d982013-11-18 20:04:20 -0800951
Rajeev79dbe4c2013-10-05 11:03:42 +0530952 if (('A' == val) || ('a' == val))
953 {
c_hpothuebf89732014-02-25 13:00:24 +0530954 ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530955 }
956 else if (('B' == val) || ('b' == val))
957 {
c_hpothuebf89732014-02-25 13:00:24 +0530958 ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530959 }
960 else
961 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800962 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
963 }
964
965 if (TRUE == lastArg)
966 {
967 goto done;
968 }
969 else if (NULL == inPtr)
970 {
Rajeev79dbe4c2013-10-05 11:03:42 +0530971 return -EINVAL;
972 }
973 }
974
975 /*check and parse RTT*/
976 if ((strncmp(inPtr, "RTT", 3) == 0))
977 {
978 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800979 &nRtt, &lastArg);
Rajeev79dbe4c2013-10-05 11:03:42 +0530980 if (TRUE == lastArg)
981 {
982 goto done;
983 }
984 if (NULL == inPtr)
985 {
986 return -EINVAL;
987 }
988 }
989
990
991done:
992
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800993 pHddSetBatchScanReq->scanFrequency = nScanFreq;
994 pHddSetBatchScanReq->numberOfScansToBatch = nMscan;
995 pHddSetBatchScanReq->bestNetwork = nBestN;
996 pHddSetBatchScanReq->rfBand = ucRfBand;
997 pHddSetBatchScanReq->rtt = nRtt;
998
Rajeev79dbe4c2013-10-05 11:03:42 +0530999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1000 "Received WLS_BATCHING_SET with SCANFREQ=%d "
1001 "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d",
1002 pHddSetBatchScanReq->scanFrequency,
1003 pHddSetBatchScanReq->numberOfScansToBatch,
1004 pHddSetBatchScanReq->bestNetwork,
1005 pHddSetBatchScanReq->rfBand,
1006 pHddSetBatchScanReq->rtt);
1007
1008 return 0;
1009}/*End of hdd_parse_set_batchscan_command*/
1010
1011/**---------------------------------------------------------------------------
1012
1013 \brief hdd_set_batch_scan_req_callback () - This function is called after
1014 receiving set batch scan response from FW and it saves set batch scan
1015 response data FW to HDD context and sets the completion event on
1016 which hdd_ioctl is waiting
1017
1018 \param - callbackContext Pointer to HDD adapter
1019 \param - pRsp Pointer to set batch scan response data received from FW
1020
1021 \return - nothing
1022
1023 --------------------------------------------------------------------------*/
1024static void hdd_set_batch_scan_req_callback
1025(
1026 void *callbackContext,
1027 tSirSetBatchScanRsp *pRsp
1028)
1029{
1030 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
1031 tSirSetBatchScanRsp *pHddSetBatchScanRsp;
1032
1033 /*sanity check*/
1034 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1035 {
1036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1037 "%s: Invalid pAdapter magic", __func__);
1038 VOS_ASSERT(0);
1039 return;
1040 }
1041 pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp;
1042
1043 /*save set batch scan response*/
1044 pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch;
1045
1046 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1047 "Received set batch scan rsp from FW with nScansToBatch=%d",
1048 pHddSetBatchScanRsp->nScansToBatch);
1049
1050 pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE;
1051 complete(&pAdapter->hdd_set_batch_scan_req_var);
1052
1053 return;
1054}/*End of hdd_set_batch_scan_req_callback*/
1055
1056
1057/**---------------------------------------------------------------------------
1058
1059 \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta
1060 info in hdd batch scan response queue
1061
1062 \param - pAdapter Pointer to hdd adapter
1063 \param - pAPMetaInfo Pointer to access point meta info
1064 \param - scanId scan ID of batch scan response
1065 \param - isLastAp tells whether AP is last AP in batch scan response or not
1066
1067 \return - nothing
1068
1069 --------------------------------------------------------------------------*/
1070static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter,
1071 tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp)
1072{
1073 tHddBatchScanRsp *pHead;
1074 tHddBatchScanRsp *pNode;
1075 tHddBatchScanRsp *pPrev;
1076 tHddBatchScanRsp *pTemp;
1077 tANI_U8 ssidLen;
1078
1079 /*head of hdd batch scan response queue*/
1080 pHead = pAdapter->pBatchScanRsp;
1081
1082 pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp));
1083 if (NULL == pNode)
1084 {
1085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1086 "%s: Could not allocate memory", __func__);
1087 VOS_ASSERT(0);
1088 return;
1089 }
1090
1091 vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid,
1092 sizeof(pNode->ApInfo.bssid));
1093 ssidLen = strlen(pApMetaInfo->ssid);
1094 if (SIR_MAX_SSID_SIZE < ssidLen)
1095 {
1096 /*invalid scan result*/
1097 vos_mem_free(pNode);
1098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1099 "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen);
1100 return;
1101 }
1102 vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen);
1103 /*null terminate ssid*/
1104 pNode->ApInfo.ssid[ssidLen] = '\0';
1105 pNode->ApInfo.ch = pApMetaInfo->ch;
1106 pNode->ApInfo.rssi = pApMetaInfo->rssi;
1107 pNode->ApInfo.age = pApMetaInfo->timestamp;
1108 pNode->ApInfo.batchId = scanId;
1109 pNode->ApInfo.isLastAp = isLastAp;
1110
1111 pNode->pNext = NULL;
1112 if (NULL == pHead)
1113 {
1114 pAdapter->pBatchScanRsp = pNode;
1115 }
1116 else
1117 {
1118 pTemp = pHead;
1119 while (NULL != pTemp)
1120 {
1121 pPrev = pTemp;
1122 pTemp = pTemp->pNext;
1123 }
1124 pPrev->pNext = pNode;
1125 }
1126
1127 return;
1128}/*End of hdd_populate_batch_scan_rsp_queue*/
1129
1130/**---------------------------------------------------------------------------
1131
1132 \brief hdd_batch_scan_result_ind_callback () - This function is called after
1133 receiving batch scan response indication from FW. It saves get batch scan
1134 response data in HDD batch scan response queue. This callback sets the
1135 completion event on which hdd_ioctl is waiting only after getting complete
1136 batch scan response data from FW
1137
1138 \param - callbackContext Pointer to HDD adapter
1139 \param - pRsp Pointer to get batch scan response data received from FW
1140
1141 \return - nothing
1142
1143 --------------------------------------------------------------------------*/
1144static void hdd_batch_scan_result_ind_callback
1145(
1146 void *callbackContext,
1147 void *pRsp
1148)
1149{
1150 v_BOOL_t isLastAp;
1151 tANI_U32 numApMetaInfo;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001152 tANI_U32 numNetworkInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301153 tANI_U32 numberScanList;
1154 tANI_U32 nextScanListOffset;
1155 tANI_U32 nextApMetaInfoOffset;
1156 hdd_adapter_t* pAdapter;
1157 tpSirBatchScanList pScanList;
1158 tpSirBatchScanNetworkInfo pApMetaInfo;
1159 tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/
1160 tSirSetBatchScanReq *pReq;
1161
1162 pAdapter = (hdd_adapter_t *)callbackContext;
1163 /*sanity check*/
Rajeev Kumar5286bb92013-12-05 11:52:10 -08001164 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Rajeev79dbe4c2013-10-05 11:03:42 +05301165 {
1166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1167 "%s: Invalid pAdapter magic", __func__);
1168 VOS_ASSERT(0);
1169 return;
1170 }
1171
1172 /*initialize locals*/
1173 pReq = &pAdapter->hddSetBatchScanReq;
1174 pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp;
1175 isLastAp = FALSE;
1176 numApMetaInfo = 0;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001177 numNetworkInScanList = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05301178 numberScanList = 0;
1179 nextScanListOffset = 0;
1180 nextApMetaInfoOffset = 0;
1181 pScanList = NULL;
1182 pApMetaInfo = NULL;
1183
1184 if ((NULL == pBatchScanRsp) || (NULL == pReq))
1185 {
1186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1187 "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq);
1188 isLastAp = TRUE;
1189 goto done;
1190 }
1191
1192 pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists;
1193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1194 "Batch scan rsp: numberScalList %d", numberScanList);
1195
1196 if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch))
1197 {
1198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1199 "%s: numberScanList %d", __func__, numberScanList);
1200 isLastAp = TRUE;
1201 goto done;
1202 }
1203
1204 while (numberScanList)
1205 {
Rajeev Kumarce651e42013-10-21 18:57:15 -07001206 pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults +
Rajeev79dbe4c2013-10-05 11:03:42 +05301207 nextScanListOffset);
1208 if (NULL == pScanList)
1209 {
1210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1211 "%s: pScanList is %p", __func__, pScanList);
1212 isLastAp = TRUE;
1213 goto done;
1214 }
Rajeev Kumarce651e42013-10-21 18:57:15 -07001215 numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumarce651e42013-10-21 18:57:15 -07001217 "Batch scan rsp: numApMetaInfo %d scanId %d",
1218 numApMetaInfo, pScanList->scanId);
Rajeev79dbe4c2013-10-05 11:03:42 +05301219
1220 if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork))
1221 {
1222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1223 "%s: numApMetaInfo %d", __func__, numApMetaInfo);
1224 isLastAp = TRUE;
1225 goto done;
1226 }
1227
Rajeev Kumarce651e42013-10-21 18:57:15 -07001228 /*Initialize next AP meta info offset for next scan list*/
1229 nextApMetaInfoOffset = 0;
1230
Rajeev79dbe4c2013-10-05 11:03:42 +05301231 while (numApMetaInfo)
1232 {
1233 pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList +
1234 nextApMetaInfoOffset);
1235 if (NULL == pApMetaInfo)
1236 {
1237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1238 "%s: pApMetaInfo is %p", __func__, pApMetaInfo);
1239 isLastAp = TRUE;
1240 goto done;
1241 }
1242 /*calculate AP age*/
1243 pApMetaInfo->timestamp =
1244 pBatchScanRsp->timestamp - pApMetaInfo->timestamp;
1245
1246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussaina7c8e412013-11-20 11:06:42 -08001247 "%s: bssId "MAC_ADDRESS_STR
1248 " ch %d rssi %d timestamp %d", __func__,
1249 MAC_ADDR_ARRAY(pApMetaInfo->bssid),
1250 pApMetaInfo->ch, pApMetaInfo->rssi,
1251 pApMetaInfo->timestamp);
Rajeev79dbe4c2013-10-05 11:03:42 +05301252
1253 /*mark last AP in batch scan response*/
1254 if ((TRUE == pBatchScanRsp->isLastResult) &&
1255 (1 == numberScanList) && (1 == numApMetaInfo))
1256 {
1257 isLastAp = TRUE;
1258 }
1259
1260 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1261 /*store batch scan repsonse in hdd queue*/
1262 hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo,
1263 pScanList->scanId, isLastAp);
1264 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1265
1266 nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo);
1267 numApMetaInfo--;
1268 }
1269
Rajeev Kumarce651e42013-10-21 18:57:15 -07001270 nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8))
1271 + (sizeof(tSirBatchScanNetworkInfo)
1272 * numNetworkInScanList));
Rajeev79dbe4c2013-10-05 11:03:42 +05301273 numberScanList--;
1274 }
1275
1276done:
1277
1278 /*notify hdd_ioctl only if complete batch scan rsp is received and it was
1279 requested from hdd_ioctl*/
1280 if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) &&
1281 (TRUE == isLastAp))
1282 {
1283 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1284 complete(&pAdapter->hdd_get_batch_scan_req_var);
1285 }
1286
1287 return;
1288}/*End of hdd_batch_scan_result_ind_callback*/
1289
1290/**---------------------------------------------------------------------------
1291
1292 \brief hdd_format_batch_scan_rsp () - This function formats batch scan
1293 response as per batch scan FR request format by putting proper markers
1294
1295 \param - pDest pointer to destination buffer
1296 \param - cur_len current length
1297 \param - tot_len total remaining size which can be written to user space
1298 \param - pApMetaInfo Pointer to get batch scan response AP meta info
1299 \param - pAdapter Pointer to HDD adapter
1300
1301 \return - ret no of characters written
1302
1303 --------------------------------------------------------------------------*/
1304static tANI_U32
1305hdd_format_batch_scan_rsp
1306(
1307 tANI_U8 *pDest,
1308 tANI_U32 cur_len,
1309 tANI_U32 tot_len,
1310 tHddBatchScanRsp *pApMetaInfo,
1311 hdd_adapter_t* pAdapter
1312)
1313{
1314 tANI_U32 ret = 0;
1315 tANI_U32 rem_len = 0;
1316 tANI_U8 temp_len = 0;
1317 tANI_U8 temp_total_len = 0;
1318 tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE];
1319 tANI_U8 *pTemp = temp;
1320
1321 /*Batch scan reponse needs to be returned to user space in
1322 following format:
1323 "scancount=X\n" where X is the number of scans in current batch
1324 batch
1325 "trunc\n" optional present if current scan truncated
1326 "bssid=XX:XX:XX:XX:XX:XX\n"
1327 "ssid=XXXX\n"
1328 "freq=X\n" frequency in Mhz
1329 "level=XX\n"
1330 "age=X\n" ms
1331 "dist=X\n" cm (-1 if not available)
1332 "errror=X\n" (-1if not available)
1333 "====\n" (end of ap marker)
1334 "####\n" (end of scan marker)
1335 "----\n" (end of results)*/
1336 /*send scan result in above format to user space based on
1337 available length*/
1338 /*The GET response may have more data than the driver can return in its
1339 buffer. In that case the buffer should be filled to the nearest complete
1340 scan, ending with "%%%%".Subsequent callsshould return the remaining data
1341 starting with the next scan (optional .trunc\n., .apcount=X\n., etc).
1342 The final buffer should end with "----\n"*/
1343
1344 /*sanity*/
1345 if (cur_len > tot_len)
1346 {
1347 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1348 "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len);
1349 return 0;
1350 }
1351 else
1352 {
1353 rem_len = (tot_len - cur_len);
1354 }
1355
1356 /*end scan marker*/
1357 if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id)
1358 {
1359 temp_len = snprintf(pTemp, sizeof(temp), "####\n");
1360 pTemp += temp_len;
1361 temp_total_len += temp_len;
1362 }
1363
1364 /*bssid*/
1365 temp_len = snprintf(pTemp, sizeof(temp),
1366 "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n",
1367 pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1],
1368 pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3],
1369 pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]);
1370 pTemp += temp_len;
1371 temp_total_len += temp_len;
1372
1373 /*ssid*/
1374 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n",
1375 pApMetaInfo->ApInfo.ssid);
1376 pTemp += temp_len;
1377 temp_total_len += temp_len;
1378
1379 /*freq*/
1380 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n",
Rajeev Kumarc40f7512013-11-04 14:13:23 -08001381 sme_ChnToFreq(pApMetaInfo->ApInfo.ch));
Rajeev79dbe4c2013-10-05 11:03:42 +05301382 pTemp += temp_len;
1383 temp_total_len += temp_len;
1384
1385 /*level*/
1386 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n",
1387 pApMetaInfo->ApInfo.rssi);
1388 pTemp += temp_len;
1389 temp_total_len += temp_len;
1390
1391 /*age*/
Jeff Johnson02797792013-10-26 19:17:13 -07001392 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n",
Rajeev79dbe4c2013-10-05 11:03:42 +05301393 pApMetaInfo->ApInfo.age);
1394 pTemp += temp_len;
1395 temp_total_len += temp_len;
1396
1397 /*dist*/
1398 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n");
1399 pTemp += temp_len;
1400 temp_total_len += temp_len;
1401
1402 /*error*/
1403 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n");
1404 pTemp += temp_len;
1405 temp_total_len += temp_len;
1406
1407 /*end AP marker*/
1408 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n");
1409 pTemp += temp_len;
1410 temp_total_len += temp_len;
1411
1412 /*last AP in batch scan response*/
1413 if(TRUE == pApMetaInfo->ApInfo.isLastAp)
1414 {
1415 /*end scan marker*/
1416 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n");
1417 pTemp += temp_len;
1418 temp_total_len += temp_len;
1419
1420 /*end batch scan result marker*/
1421 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n");
1422 pTemp += temp_len;
1423 temp_total_len += temp_len;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001424
Rajeev79dbe4c2013-10-05 11:03:42 +05301425 }
1426
1427 if (temp_total_len < rem_len)
1428 {
1429 ret = temp_total_len + 1;
1430 strlcpy(pDest, temp, ret);
1431 pAdapter->isTruncated = FALSE;
1432 }
1433 else
1434 {
1435 pAdapter->isTruncated = TRUE;
1436 if (rem_len >= strlen("%%%%"))
1437 {
Rajeev Kumarc933d982013-11-18 20:04:20 -08001438 ret = snprintf(pDest, sizeof(temp), "%%%%");
Rajeev79dbe4c2013-10-05 11:03:42 +05301439 }
Rajeev Kumarc933d982013-11-18 20:04:20 -08001440 else
Rajeev79dbe4c2013-10-05 11:03:42 +05301441 {
1442 ret = 0;
1443 }
1444 }
1445
1446 return ret;
1447
1448}/*End of hdd_format_batch_scan_rsp*/
1449
1450/**---------------------------------------------------------------------------
1451
1452 \brief hdd_populate_user_batch_scan_rsp() - This function populates user data
1453 buffer starting with head of hdd batch scan response queue
1454
1455 \param - pAdapter Pointer to HDD adapter
1456 \param - pDest Pointer to user data buffer
1457 \param - cur_len current offset in user buffer
1458 \param - rem_len remaining no of bytes in user buffer
1459
1460 \return - number of bytes written in user buffer
1461
1462 --------------------------------------------------------------------------*/
1463
1464tANI_U32 hdd_populate_user_batch_scan_rsp
1465(
1466 hdd_adapter_t* pAdapter,
1467 tANI_U8 *pDest,
1468 tANI_U32 cur_len,
1469 tANI_U32 rem_len
1470)
1471{
1472 tHddBatchScanRsp *pHead;
1473 tHddBatchScanRsp *pPrev;
1474 tANI_U32 len;
1475
Rajeev79dbe4c2013-10-05 11:03:42 +05301476 pAdapter->isTruncated = FALSE;
1477
1478 /*head of hdd batch scan response queue*/
1479 pHead = pAdapter->pBatchScanRsp;
1480 while (pHead)
1481 {
1482 len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead,
1483 pAdapter);
1484 pDest += len;
Rajeev Kumar292d2bb2013-10-23 15:01:44 -07001485 pDest--;
Rajeev79dbe4c2013-10-05 11:03:42 +05301486 cur_len += len;
1487 if(TRUE == pAdapter->isTruncated)
1488 {
1489 /*result is truncated return rest of scan rsp in next req*/
1490 cur_len = rem_len;
1491 break;
1492 }
1493 pPrev = pHead;
1494 pHead = pHead->pNext;
1495 pAdapter->pBatchScanRsp = pHead;
Rajeev Kumarbe17d8b2014-01-10 15:39:45 -08001496 if (TRUE == pPrev->ApInfo.isLastAp)
1497 {
1498 pAdapter->prev_batch_id = 0;
1499 }
1500 else
1501 {
1502 pAdapter->prev_batch_id = pPrev->ApInfo.batchId;
1503 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301504 vos_mem_free(pPrev);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001505 pPrev = NULL;
Rajeev79dbe4c2013-10-05 11:03:42 +05301506 }
1507
1508 return cur_len;
1509}/*End of hdd_populate_user_batch_scan_rsp*/
1510
1511/**---------------------------------------------------------------------------
1512
1513 \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch
1514 scan response data from HDD queue to user space
1515 It does following in detail:
1516 a) if HDD has enough data in its queue then it 1st copies data to user
1517 space and then send get batch scan indication message to FW. In this
1518 case it does not wait on any event and batch scan response data will
1519 be populated in HDD response queue in MC thread context after receiving
1520 indication from FW
1521 b) else send get batch scan indication message to FW and wait on an event
1522 which will be set once HDD receives complete batch scan response from
1523 FW and then this function returns batch scan response to user space
1524
1525 \param - pAdapter Pointer to HDD adapter
1526 \param - pPrivData Pointer to priv_data
1527
1528 \return - 0 for success -EFAULT for failure
1529
1530 --------------------------------------------------------------------------*/
1531
1532int hdd_return_batch_scan_rsp_to_user
1533(
1534 hdd_adapter_t* pAdapter,
1535 hdd_priv_data_t *pPrivData,
1536 tANI_U8 *command
1537)
1538{
1539 tANI_U8 *pDest;
1540 tANI_U32 count = 0;
1541 tANI_U32 len = 0;
1542 tANI_U32 cur_len = 0;
1543 tANI_U32 rem_len = 0;
1544 eHalStatus halStatus;
1545 unsigned long rc;
1546 tSirTriggerBatchScanResultInd *pReq;
1547
1548 pReq = &pAdapter->hddTriggerBatchScanResultInd;
1549 pReq->param = 0;/*batch scan client*/
1550 pDest = (tANI_U8 *)(command + pPrivData->used_len);
1551 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1552
1553 cur_len = pPrivData->used_len;
1554 if (pPrivData->total_len > pPrivData->used_len)
1555 {
1556 rem_len = pPrivData->total_len - pPrivData->used_len;
1557 }
1558 else
1559 {
1560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1561 "%s: Invalid user data buffer total_len %d used_len %d",
1562 __func__, pPrivData->total_len, pPrivData->used_len);
1563 return -EFAULT;
1564 }
1565
1566 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1567 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1568 cur_len, rem_len);
1569 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1570
1571 /*enough scan result available in cache to return to user space or
1572 scan result needs to be fetched 1st from fw and then return*/
Rajeev Kumar99db6262013-11-11 15:23:36 -08001573 if (len == cur_len)
Rajeev79dbe4c2013-10-05 11:03:42 +05301574 {
1575 pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE;
1576 halStatus = sme_TriggerBatchScanResultInd(
1577 WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1578 pAdapter->sessionId, hdd_batch_scan_result_ind_callback,
1579 pAdapter);
1580 if ( eHAL_STATUS_SUCCESS == halStatus )
1581 {
1582 if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp)
1583 {
1584 INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var);
1585 rc = wait_for_completion_timeout(
1586 &pAdapter->hdd_get_batch_scan_req_var,
1587 msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT));
1588 if (0 == rc)
1589 {
1590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1591 "%s: Timeout waiting to fetch batch scan rsp from fw",
1592 __func__);
1593 return -EFAULT;
1594 }
1595 }
1596
1597 len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE,
Jeff Johnson02797792013-10-26 19:17:13 -07001598 "scancount=%u\n", pAdapter->numScanList);
Rajeev79dbe4c2013-10-05 11:03:42 +05301599 pDest += len;
1600 cur_len += len;
1601
1602 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1603 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1604 cur_len, rem_len);
1605 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1606
1607 count = 0;
1608 len = (len - pPrivData->used_len);
1609 pDest = (command + pPrivData->used_len);
1610 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001611 "NEW BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301612 while(count < len)
1613 {
1614 printk("%c", *(pDest + count));
1615 count++;
1616 }
1617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1618 "%s: copy %d data to user buffer", __func__, len);
1619 if (copy_to_user(pPrivData->buf, pDest, len))
1620 {
1621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1622 "%s: failed to copy data to user buffer", __func__);
1623 return -EFAULT;
1624 }
1625 }
1626 else
1627 {
1628 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1629 "sme_GetBatchScanScan returned failure halStatus %d",
1630 halStatus);
1631 return -EINVAL;
1632 }
1633 }
1634 else
1635 {
Rajeev79dbe4c2013-10-05 11:03:42 +05301636 count = 0;
1637 len = (len - pPrivData->used_len);
1638 pDest = (command + pPrivData->used_len);
1639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001640 "REMAINING TRUNCATED BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301641 while(count < len)
1642 {
1643 printk("%c", *(pDest + count));
1644 count++;
1645 }
Rajeev Kumar99db6262013-11-11 15:23:36 -08001646 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1647 "%s: copy %d data to user buffer", __func__, len);
Rajeev79dbe4c2013-10-05 11:03:42 +05301648 if (copy_to_user(pPrivData->buf, pDest, len))
1649 {
1650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1651 "%s: failed to copy data to user buffer", __func__);
1652 return -EFAULT;
1653 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301654 }
1655
1656 return 0;
1657} /*End of hdd_return_batch_scan_rsp_to_user*/
1658
Rajeev Kumar8b373292014-01-08 20:36:55 -08001659
1660/**---------------------------------------------------------------------------
1661
1662 \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING
1663 IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled:
1664 WLS_BATCHING VERSION
1665 WLS_BATCHING SET
1666 WLS_BATCHING GET
1667 WLS_BATCHING STOP
1668
1669 \param - pAdapter Pointer to HDD adapter
1670 \param - pPrivdata Pointer to priv_data
1671 \param - command Pointer to command
1672
1673 \return - 0 for success -EFAULT for failure
1674
1675 --------------------------------------------------------------------------*/
1676
1677int hdd_handle_batch_scan_ioctl
1678(
1679 hdd_adapter_t *pAdapter,
1680 hdd_priv_data_t *pPrivdata,
1681 tANI_U8 *command
1682)
1683{
1684 int ret = 0;
Yue Mae36e3552014-03-05 17:06:20 -08001685 hdd_context_t *pHddCtx;
1686
1687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1688 ret = wlan_hdd_validate_context(pHddCtx);
1689 if (ret)
1690 {
1691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1692 "%s: HDD context is not valid!", __func__);
1693 goto exit;
1694 }
Rajeev Kumar8b373292014-01-08 20:36:55 -08001695
1696 if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0)
1697 {
1698 char extra[32];
1699 tANI_U8 len = 0;
1700 tANI_U8 version = HDD_BATCH_SCAN_VERSION;
1701
1702 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1703 {
1704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1705 "%s: Batch scan feature is not supported by FW", __func__);
1706 ret = -EINVAL;
1707 goto exit;
1708 }
1709
1710 len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d",
1711 version);
1712 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1713 {
1714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1715 "%s: failed to copy data to user buffer", __func__);
1716 ret = -EFAULT;
1717 goto exit;
1718 }
1719 ret = HDD_BATCH_SCAN_VERSION;
1720 }
1721 else if (strncmp(command, "WLS_BATCHING SET", 16) == 0)
1722 {
1723 int status;
1724 tANI_U8 *value = (command + 16);
1725 eHalStatus halStatus;
1726 unsigned long rc;
1727 tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq;
1728 tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp;
1729
1730 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1731 {
1732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1733 "%s: Batch scan feature is not supported by FW", __func__);
1734 ret = -EINVAL;
1735 goto exit;
1736 }
1737
1738 if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) &&
1739 (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) &&
1740 (WLAN_HDD_P2P_GO != pAdapter->device_mode) &&
1741 (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode))
1742 {
1743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301744 "Received WLS_BATCHING SET command in invalid mode %s (%d) "
Rajeev Kumar8b373292014-01-08 20:36:55 -08001745 "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode",
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301746 hdd_device_modetoString(pAdapter->device_mode),
1747 pAdapter->device_mode);
Rajeev Kumar8b373292014-01-08 20:36:55 -08001748 ret = -EINVAL;
1749 goto exit;
1750 }
1751
1752 status = hdd_parse_set_batchscan_command(value, pReq);
1753 if (status)
1754 {
1755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1756 "Invalid WLS_BATCHING SET command");
1757 ret = -EINVAL;
1758 goto exit;
1759 }
1760
1761
1762 pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE;
1763 halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1764 pAdapter->sessionId, hdd_set_batch_scan_req_callback,
1765 pAdapter);
1766
1767 if ( eHAL_STATUS_SUCCESS == halStatus )
1768 {
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301769 char extra[32];
1770 tANI_U8 len = 0;
1771 tANI_U8 mScan = 0;
1772
Rajeev Kumar8b373292014-01-08 20:36:55 -08001773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1774 "sme_SetBatchScanReq returned success halStatus %d",
1775 halStatus);
1776 if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp)
1777 {
1778 INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var);
1779 rc = wait_for_completion_timeout(
1780 &pAdapter->hdd_set_batch_scan_req_var,
1781 msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT));
1782 if (0 == rc)
1783 {
1784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1785 "%s: Timeout waiting for set batch scan to complete",
1786 __func__);
1787 ret = -EINVAL;
1788 goto exit;
1789 }
1790 }
1791 if ( !pRsp->nScansToBatch )
1792 {
1793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1794 "%s: Received set batch scan failure response from FW",
1795 __func__);
1796 ret = -EINVAL;
1797 goto exit;
1798 }
1799 /*As per the Batch Scan Framework API we should return the MIN of
1800 either MSCAN or the max # of scans firmware can cache*/
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301801 mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch);
Rajeev Kumar8b373292014-01-08 20:36:55 -08001802
1803 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED;
1804
1805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1806 "%s: request MSCAN %d response MSCAN %d ret %d",
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301807 __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan);
1808 len = scnprintf(extra, sizeof(extra), "%d", mScan);
1809 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1810 {
1811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1812 "%s: failed to copy MSCAN value to user buffer", __func__);
1813 ret = -EFAULT;
1814 goto exit;
1815 }
Rajeev Kumar8b373292014-01-08 20:36:55 -08001816 }
1817 else
1818 {
1819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1820 "sme_SetBatchScanReq returned failure halStatus %d",
1821 halStatus);
1822 ret = -EINVAL;
1823 goto exit;
1824 }
1825 }
1826 else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0)
1827 {
1828 eHalStatus halStatus;
1829 tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd;
1830 pInd->param = 0;
1831
1832 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1833 {
1834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1835 "%s: Batch scan feature is not supported by FW", __func__);
1836 ret = -EINVAL;
1837 goto exit;
1838 }
1839
1840 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1841 {
1842 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1843 "Batch scan is not yet enabled batch scan state %d",
1844 pAdapter->batchScanState);
1845 ret = -EINVAL;
1846 goto exit;
1847 }
1848
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001849 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1850 hdd_deinit_batch_scan(pAdapter);
1851 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1852
Rajeev Kumar8b373292014-01-08 20:36:55 -08001853 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
1854
1855 halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd,
1856 pAdapter->sessionId);
1857 if ( eHAL_STATUS_SUCCESS == halStatus )
1858 {
1859 ret = 0;
1860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1861 "sme_StopBatchScanInd returned success halStatus %d",
1862 halStatus);
1863 }
1864 else
1865 {
1866 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1867 "sme_StopBatchScanInd returned failure halStatus %d",
1868 halStatus);
1869 ret = -EINVAL;
1870 goto exit;
1871 }
1872 }
1873 else if (strncmp(command, "WLS_BATCHING GET", 16) == 0)
1874 {
1875 tANI_U32 remain_len;
1876
1877 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1878 {
1879 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1880 "%s: Batch scan feature is not supported by FW", __func__);
1881 ret = -EINVAL;
1882 goto exit;
1883 }
1884
1885 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1886 {
1887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1888 "Batch scan is not yet enabled could not return results"
1889 "Batch Scan state %d",
1890 pAdapter->batchScanState);
1891 ret = -EINVAL;
1892 goto exit;
1893 }
1894
1895 pPrivdata->used_len = 16;
1896 remain_len = pPrivdata->total_len - pPrivdata->used_len;
1897 if (remain_len < pPrivdata->total_len)
1898 {
1899 /*Clear previous batch scan response data if any*/
1900 vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len);
1901 }
1902 else
1903 {
1904 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1905 "Invalid total length from user space can't fetch batch"
1906 " scan response total_len %d used_len %d remain len %d",
1907 pPrivdata->total_len, pPrivdata->used_len, remain_len);
1908 ret = -EINVAL;
1909 goto exit;
1910 }
1911 ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command);
1912 }
1913
1914exit:
1915
1916 return ret;
1917}
1918
1919
Rajeev79dbe4c2013-10-05 11:03:42 +05301920#endif/*End of FEATURE_WLAN_BATCH_SCAN*/
1921
c_hpothu92367912014-05-01 15:18:17 +05301922static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data)
1923{
c_hpothu39eb1e32014-06-26 16:31:50 +05301924 bcnMissRateContext_t *pCBCtx;
1925
1926 if (NULL == data)
1927 {
1928 hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL"));
1929 return;
1930 }
c_hpothu92367912014-05-01 15:18:17 +05301931
1932 /* there is a race condition that exists between this callback
1933 function and the caller since the caller could time out either
1934 before or while this code is executing. we use a spinlock to
1935 serialize these actions */
1936 spin_lock(&hdd_context_lock);
1937
c_hpothu39eb1e32014-06-26 16:31:50 +05301938 pCBCtx = (bcnMissRateContext_t *)data;
c_hpothu92367912014-05-01 15:18:17 +05301939 gbcnMissRate = -1;
1940
c_hpothu39eb1e32014-06-26 16:31:50 +05301941 if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC)
c_hpothu92367912014-05-01 15:18:17 +05301942 {
1943 hddLog(VOS_TRACE_LEVEL_ERROR,
c_hpothu39eb1e32014-06-26 16:31:50 +05301944 FL("invalid context magic: %08x"), pCBCtx->magic);
c_hpothu92367912014-05-01 15:18:17 +05301945 spin_unlock(&hdd_context_lock);
1946 return ;
1947 }
1948
1949 if (VOS_STATUS_SUCCESS == status)
1950 {
c_hpothu39eb1e32014-06-26 16:31:50 +05301951 gbcnMissRate = bcnMissRate;
c_hpothu92367912014-05-01 15:18:17 +05301952 }
c_hpothu39eb1e32014-06-26 16:31:50 +05301953 else
1954 {
1955 hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate"));
1956 }
1957
c_hpothu92367912014-05-01 15:18:17 +05301958 complete(&(pCBCtx->completion));
1959 spin_unlock(&hdd_context_lock);
1960
1961 return;
1962}
1963
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05301964static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len)
1965{
1966 int ret = 0;
1967
1968 if (!pCfg || !command || !extra || !len)
1969 {
1970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1971 "%s: argument passsed for GETDWELLTIME is incorrect", __func__);
1972 ret = -EINVAL;
1973 return ret;
1974 }
1975
1976 if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0)
1977 {
1978 *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n",
1979 (int)pCfg->nActiveMaxChnTime);
1980 return ret;
1981 }
1982 else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0)
1983 {
1984 *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n",
1985 (int)pCfg->nActiveMinChnTime);
1986 return ret;
1987 }
1988 else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0)
1989 {
1990 *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n",
1991 (int)pCfg->nPassiveMaxChnTime);
1992 return ret;
1993 }
1994 else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0)
1995 {
1996 *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n",
1997 (int)pCfg->nPassiveMinChnTime);
1998 return ret;
1999 }
Rajesh Babu Prathipati0fd227e2014-07-05 12:50:00 +05302000 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
2001 {
2002 *len = scnprintf(extra, n, "GETDWELLTIME %u \n",
2003 (int)pCfg->nActiveMaxChnTime);
2004 return ret;
2005 }
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302006 else
2007 {
2008 ret = -EINVAL;
2009 }
2010
2011 return ret;
2012}
2013
2014static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command)
2015{
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302016 tHalHandle hHal;
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302017 hdd_config_t *pCfg;
2018 tANI_U8 *value = command;
2019 int val = 0, ret = 0, temp = 0;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302020 tSmeConfigParams smeConfig;
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302021
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302022 if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini)
2023 || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter))))
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302024 {
2025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2026 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
2027 ret = -EINVAL;
2028 return ret;
2029 }
2030
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302031 vos_mem_zero(&smeConfig, sizeof(smeConfig));
2032 sme_GetConfigParam(hHal, &smeConfig);
2033
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302034 if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 )
2035 {
2036 value = value + 24;
2037 temp = kstrtou32(value, 10, &val);
2038 if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
2039 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
2040 {
2041 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2042 "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__);
2043 ret = -EFAULT;
2044 return ret;
2045 }
2046 pCfg->nActiveMaxChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302047 smeConfig.csrConfig.nActiveMaxChnTime = val;
2048 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302049 }
2050 else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0)
2051 {
2052 value = value + 24;
2053 temp = kstrtou32(value, 10, &val);
2054 if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN ||
2055 val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX )
2056 {
2057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2058 "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__);
2059 ret = -EFAULT;
2060 return ret;
2061 }
2062 pCfg->nActiveMinChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302063 smeConfig.csrConfig.nActiveMinChnTime = val;
2064 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302065 }
2066 else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0)
2067 {
2068 value = value + 25;
2069 temp = kstrtou32(value, 10, &val);
2070 if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN ||
2071 val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX )
2072 {
2073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2074 "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__);
2075 ret = -EFAULT;
2076 return ret;
2077 }
2078 pCfg->nPassiveMaxChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302079 smeConfig.csrConfig.nPassiveMaxChnTime = val;
2080 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302081 }
2082 else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0)
2083 {
2084 value = value + 25;
2085 temp = kstrtou32(value, 10, &val);
2086 if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN ||
2087 val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX )
2088 {
2089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2090 "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__);
2091 ret = -EFAULT;
2092 return ret;
2093 }
2094 pCfg->nPassiveMinChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302095 smeConfig.csrConfig.nPassiveMinChnTime = val;
2096 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302097 }
Rajesh Babu Prathipati0fd227e2014-07-05 12:50:00 +05302098 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
2099 {
2100 value = value + 13;
2101 temp = kstrtou32(value, 10, &val);
2102 if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
2103 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
2104 {
2105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2106 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
2107 ret = -EFAULT;
2108 return ret;
2109 }
2110 pCfg->nActiveMaxChnTime = val;
2111 smeConfig.csrConfig.nActiveMaxChnTime = val;
2112 sme_UpdateConfig(hHal, &smeConfig);
2113 }
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302114 else
2115 {
2116 ret = -EINVAL;
2117 }
2118
2119 return ret;
2120}
2121
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002122static int hdd_driver_command(hdd_adapter_t *pAdapter,
2123 hdd_priv_data_t *ppriv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -07002124{
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 hdd_priv_data_t priv_data;
2126 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302127 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2128 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002129 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302130 int status;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002131 /*
2132 * Note that valid pointers are provided by caller
2133 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002134
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002135 /* copy to local struct to avoid numerous changes to legacy code */
2136 priv_data = *ppriv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07002137
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002138 if (priv_data.total_len <= 0 ||
2139 priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN)
Sameer Thalappil8ef3a0e2013-04-05 14:36:04 -07002140 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002141 hddLog(VOS_TRACE_LEVEL_WARN,
2142 "%s:invalid priv_data.total_len(%d)!!!", __func__,
2143 priv_data.total_len);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002144 ret = -EINVAL;
2145 goto exit;
2146 }
Kaushik, Sushant96122442014-10-21 16:40:18 +05302147 status = wlan_hdd_validate_context(pHddCtx);
2148 if (0 != status)
2149 {
2150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2151 "%s: HDD context is not valid", __func__);
2152 return status;
2153 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002154 /* Allocate +1 for '\0' */
2155 command = kmalloc(priv_data.total_len + 1, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 if (!command)
2157 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002158 hddLog(VOS_TRACE_LEVEL_ERROR,
2159 "%s: failed to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 ret = -ENOMEM;
2161 goto exit;
2162 }
2163
2164 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
2165 {
2166 ret = -EFAULT;
2167 goto exit;
2168 }
2169
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002170 /* Make sure the command is NUL-terminated */
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002171 command[priv_data.total_len] = '\0';
2172
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002173 /* at one time the following block of code was conditional. braces
2174 * have been retained to avoid re-indenting the legacy code
2175 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 {
2177 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2178
2179 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002180 "%s: Received %s cmd from Wi-Fi GUI***", __func__, command);
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 )
2183 {
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302184 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2185 TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL,
2186 pAdapter->sessionId, (unsigned)
2187 (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 |
2188 *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 |
2189 *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 |
2190 *(pHddCtx->p2pDeviceAddress.bytes+5))));
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes,
2192 sizeof(tSirMacAddr)))
2193 {
2194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002195 "%s: failed to copy data to user buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 ret = -EFAULT;
2197 }
2198 }
Amar Singhal0974e402013-02-12 14:27:46 -08002199 else if(strncmp(command, "SETBAND", 7) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 {
Amar Singhal0974e402013-02-12 14:27:46 -08002201 tANI_U8 *ptr = command ;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002202
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 /* Change band request received */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002204
2205 /* First 8 bytes will have "SETBAND " and
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 * 9 byte will have band setting value */
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal0974e402013-02-12 14:27:46 -08002208 "%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 -07002209 /* Change band request received */
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002210 ret = hdd_setBand_helper(pAdapter->dev, ptr);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05302211 if(ret < 0)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302212 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002213 "%s: failed to set band ret=%d", __func__, ret);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002214 }
Kiet Lamf040f472013-11-20 21:15:23 +05302215 else if(strncmp(command, "SETWMMPS", 8) == 0)
2216 {
2217 tANI_U8 *ptr = command;
2218 ret = hdd_wmmps_helper(pAdapter, ptr);
2219 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07002220 else if ( strncasecmp(command, "COUNTRY", 7) == 0 )
2221 {
2222 char *country_code;
2223
2224 country_code = command + 8;
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07002225
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002226 INIT_COMPLETION(pAdapter->change_country_code);
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07002227 hdd_checkandupdate_dfssetting(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002228#ifndef CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302229 hdd_checkandupdate_phymode(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002230#endif
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002231 ret = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2232 (void *)(tSmeChangeCountryCallback)
2233 wlan_hdd_change_country_code_callback,
Abhishek Singha306a442013-11-07 18:39:01 +05302234 country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002235 if (eHAL_STATUS_SUCCESS == ret)
2236 {
2237 ret = wait_for_completion_interruptible_timeout(
2238 &pAdapter->change_country_code,
2239 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2240 if (0 >= ret)
2241 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002242 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out %d",
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302243 __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002244 }
2245 }
2246 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07002247 {
2248 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002249 "%s: SME Change Country code fail ret=%d", __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002250 ret = -EINVAL;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002251 }
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002252
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002253 }
2254 /*
2255 command should be a string having format
2256 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
2257 */
Amar Singhal0974e402013-02-12 14:27:46 -08002258 else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002259 {
Amar Singhal0974e402013-02-12 14:27:46 -08002260 tANI_U8 *ptr = command;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002261
2262 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002263 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002264
Mahesh Kumar Kalikot Veetil2aad8d82013-02-07 12:31:28 -08002265 ret = sapSetPreferredChannel(ptr);
Jeff Johnson32d95a32012-09-10 13:15:23 -07002266 }
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002267 else if(strncmp(command, "SETSUSPENDMODE", 14) == 0)
2268 {
2269 int suspend = 0;
2270 tANI_U8 *ptr = (tANI_U8*)command + 15;
2271
2272 suspend = *ptr - '0';
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302273 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2274 TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL,
2275 pAdapter->sessionId, suspend));
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002276 hdd_set_wlan_suspend_mode(suspend);
2277 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002278#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2279 else if (strncmp(command, "SETROAMTRIGGER", 14) == 0)
2280 {
2281 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002282 tANI_S8 rssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002283 tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT;
2284 eHalStatus status = eHAL_STATUS_SUCCESS;
2285
2286 /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */
2287 value = value + 15;
2288
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002289 /* Convert the value from ascii to integer */
2290 ret = kstrtos8(value, 10, &rssi);
2291 if (ret < 0)
2292 {
2293 /* If the input value is greater than max value of datatype, then also
2294 kstrtou8 fails */
2295 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2296 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdafa7157d2013-10-31 10:14:22 -07002297 __func__,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002298 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2299 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2300 ret = -EINVAL;
2301 goto exit;
2302 }
2303
Srinivas Girigowdade697412013-02-14 16:31:48 -08002304 lookUpThreshold = abs(rssi);
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002305
Srinivas Girigowdade697412013-02-14 16:31:48 -08002306 if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) ||
2307 (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX))
2308 {
2309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2310 "Neighbor lookup threshold value %d is out of range"
2311 " (Min: %d Max: %d)", lookUpThreshold,
2312 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2313 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2314 ret = -EINVAL;
2315 goto exit;
2316 }
2317
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302318 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2319 TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL,
2320 pAdapter->sessionId, lookUpThreshold));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002321 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2322 "%s: Received Command to Set Roam trigger"
2323 " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold);
2324
2325 pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold;
2326 status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold);
2327 if (eHAL_STATUS_SUCCESS != status)
2328 {
2329 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2330 "%s: Failed to set roam trigger, try again", __func__);
2331 ret = -EPERM;
2332 goto exit;
2333 }
2334
2335 /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */
mukul sharmad6e1fdd2014-06-23 19:19:09 +05302336 pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002337 sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5);
2338 }
2339 else if (strncmp(command, "GETROAMTRIGGER", 14) == 0)
2340 {
2341 tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal));
2342 int rssi = (-1) * lookUpThreshold;
2343 char extra[32];
2344 tANI_U8 len = 0;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302345 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2346 TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL,
2347 pAdapter->sessionId, lookUpThreshold));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002348 len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002349 if (copy_to_user(priv_data.buf, &extra, len + 1))
2350 {
2351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2352 "%s: failed to copy data to user buffer", __func__);
2353 ret = -EFAULT;
2354 goto exit;
2355 }
2356 }
2357 else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0)
2358 {
2359 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002360 tANI_U8 roamScanPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002361 tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002362
Srinivas Girigowdade697412013-02-14 16:31:48 -08002363 /* input refresh period is in terms of seconds */
2364 /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */
2365 value = value + 18;
2366 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002367 ret = kstrtou8(value, 10, &roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002368 if (ret < 0)
2369 {
2370 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002371 kstrtou8 fails */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002373 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdade697412013-02-14 16:31:48 -08002374 __func__,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002375 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2376 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002377 ret = -EINVAL;
2378 goto exit;
2379 }
2380
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002381 if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) ||
2382 (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002383 {
2384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002385 "Roam scan period value %d is out of range"
2386 " (Min: %d Max: %d)", roamScanPeriod,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002387 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2388 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002389 ret = -EINVAL;
2390 goto exit;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302391 }
2392 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2393 TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL,
2394 pAdapter->sessionId, roamScanPeriod));
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002395 neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002396
2397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2398 "%s: Received Command to Set roam scan period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002399 " (Empty Scan refresh period) = %d", __func__, roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002400
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002401 pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod;
2402 sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002403 }
2404 else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0)
2405 {
2406 tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2407 char extra[32];
2408 tANI_U8 len = 0;
2409
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302410 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2411 TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL,
2412 pAdapter->sessionId, nEmptyScanRefreshPeriod));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002413 len = scnprintf(extra, sizeof(extra), "%s %d",
2414 "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002415 /* Returned value is in units of seconds */
2416 if (copy_to_user(priv_data.buf, &extra, len + 1))
2417 {
2418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2419 "%s: failed to copy data to user buffer", __func__);
2420 ret = -EFAULT;
2421 goto exit;
2422 }
2423 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002424 else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0)
2425 {
2426 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002427 tANI_U8 roamScanRefreshPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002428 tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002429
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002430 /* input refresh period is in terms of seconds */
2431 /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */
2432 value = value + 25;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002433
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002434 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002435 ret = kstrtou8(value, 10, &roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002436 if (ret < 0)
2437 {
2438 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002439 kstrtou8 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002440 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002441 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002442 __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002443 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2444 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2445 ret = -EINVAL;
2446 goto exit;
2447 }
2448
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002449 if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) ||
2450 (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)))
2451 {
2452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2453 "Neighbor scan results refresh period value %d is out of range"
2454 " (Min: %d Max: %d)", roamScanRefreshPeriod,
2455 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2456 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2457 ret = -EINVAL;
2458 goto exit;
2459 }
2460 neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000;
2461
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002462 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2463 "%s: Received Command to Set roam scan refresh period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002464 " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002465
2466 pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod;
2467 sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod);
2468 }
2469 else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0)
2470 {
2471 tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2472 char extra[32];
2473 tANI_U8 len = 0;
2474
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002475 len = scnprintf(extra, sizeof(extra), "%s %d",
2476 "GETROAMSCANREFRESHPERIOD", (value/1000));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002477 /* Returned value is in units of seconds */
2478 if (copy_to_user(priv_data.buf, &extra, len + 1))
2479 {
2480 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2481 "%s: failed to copy data to user buffer", __func__);
2482 ret = -EFAULT;
2483 goto exit;
2484 }
2485 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002486#ifdef FEATURE_WLAN_LFR
2487 /* SETROAMMODE */
2488 else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0)
2489 {
2490 tANI_U8 *value = command;
2491 tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
2492
2493 /* Move pointer to ahead of SETROAMMODE<delimiter> */
2494 value = value + SIZE_OF_SETROAMMODE + 1;
2495
2496 /* Convert the value from ascii to integer */
2497 ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode);
2498 if (ret < 0)
2499 {
2500 /* If the input value is greater than max value of datatype, then also
2501 kstrtou8 fails */
2502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2503 "%s: kstrtou8 failed range [%d - %d]", __func__,
2504 CFG_LFR_FEATURE_ENABLED_MIN,
2505 CFG_LFR_FEATURE_ENABLED_MAX);
2506 ret = -EINVAL;
2507 goto exit;
2508 }
2509 if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
2510 (roamMode > CFG_LFR_FEATURE_ENABLED_MAX))
2511 {
2512 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2513 "Roam Mode value %d is out of range"
2514 " (Min: %d Max: %d)", roamMode,
2515 CFG_LFR_FEATURE_ENABLED_MIN,
2516 CFG_LFR_FEATURE_ENABLED_MAX);
2517 ret = -EINVAL;
2518 goto exit;
2519 }
2520
2521 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2522 "%s: Received Command to Set Roam Mode = %d", __func__, roamMode);
2523 /*
2524 * Note that
2525 * SETROAMMODE 0 is to enable LFR while
2526 * SETROAMMODE 1 is to disable LFR, but
2527 * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable.
2528 * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled.
2529 */
2530 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2531 roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */
2532 else
2533 roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */
2534
2535 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode;
2536 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode);
2537 }
2538 /* GETROAMMODE */
2539 else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0)
2540 {
2541 tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2542 char extra[32];
2543 tANI_U8 len = 0;
2544
2545 /*
2546 * roamMode value shall be inverted because the sementics is different.
2547 */
2548 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2549 roamMode = CFG_LFR_FEATURE_ENABLED_MAX;
2550 else
2551 roamMode = CFG_LFR_FEATURE_ENABLED_MIN;
2552
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002553 len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002554 if (copy_to_user(priv_data.buf, &extra, len + 1))
2555 {
2556 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2557 "%s: failed to copy data to user buffer", __func__);
2558 ret = -EFAULT;
2559 goto exit;
2560 }
2561 }
2562#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08002563#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002564#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002565 else if (strncmp(command, "SETROAMDELTA", 12) == 0)
2566 {
2567 tANI_U8 *value = command;
2568 tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT;
2569
2570 /* Move pointer to ahead of SETROAMDELTA<delimiter> */
2571 value = value + 13;
2572 /* Convert the value from ascii to integer */
2573 ret = kstrtou8(value, 10, &roamRssiDiff);
2574 if (ret < 0)
2575 {
2576 /* If the input value is greater than max value of datatype, then also
2577 kstrtou8 fails */
2578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2579 "%s: kstrtou8 failed range [%d - %d]", __func__,
2580 CFG_ROAM_RSSI_DIFF_MIN,
2581 CFG_ROAM_RSSI_DIFF_MAX);
2582 ret = -EINVAL;
2583 goto exit;
2584 }
2585
2586 if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) ||
2587 (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX))
2588 {
2589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2590 "Roam rssi diff value %d is out of range"
2591 " (Min: %d Max: %d)", roamRssiDiff,
2592 CFG_ROAM_RSSI_DIFF_MIN,
2593 CFG_ROAM_RSSI_DIFF_MAX);
2594 ret = -EINVAL;
2595 goto exit;
2596 }
2597
2598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2599 "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff);
2600
2601 pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff;
2602 sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff);
2603 }
2604 else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0)
2605 {
2606 tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal));
2607 char extra[32];
2608 tANI_U8 len = 0;
2609
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302610 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2611 TRACE_CODE_HDD_GETROAMDELTA_IOCTL,
2612 pAdapter->sessionId, roamRssiDiff));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002613 len = scnprintf(extra, sizeof(extra), "%s %d",
2614 command, roamRssiDiff);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002615 if (copy_to_user(priv_data.buf, &extra, len + 1))
2616 {
2617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2618 "%s: failed to copy data to user buffer", __func__);
2619 ret = -EFAULT;
2620 goto exit;
2621 }
2622 }
2623#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002624#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002625 else if (strncmp(command, "GETBAND", 7) == 0)
2626 {
2627 int band = -1;
2628 char extra[32];
2629 tANI_U8 len = 0;
2630 hdd_getBand_helper(pHddCtx, &band);
2631
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302632 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2633 TRACE_CODE_HDD_GETBAND_IOCTL,
2634 pAdapter->sessionId, band));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002635 len = scnprintf(extra, sizeof(extra), "%s %d", command, band);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002636 if (copy_to_user(priv_data.buf, &extra, len + 1))
2637 {
2638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2639 "%s: failed to copy data to user buffer", __func__);
2640 ret = -EFAULT;
2641 goto exit;
2642 }
2643 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002644 else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0)
2645 {
2646 tANI_U8 *value = command;
2647 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2648 tANI_U8 numChannels = 0;
2649 eHalStatus status = eHAL_STATUS_SUCCESS;
2650
2651 status = hdd_parse_channellist(value, ChannelList, &numChannels);
2652 if (eHAL_STATUS_SUCCESS != status)
2653 {
2654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2655 "%s: Failed to parse channel list information", __func__);
2656 ret = -EINVAL;
2657 goto exit;
2658 }
2659
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302660 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2661 TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL,
2662 pAdapter->sessionId, numChannels));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002663 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2664 {
2665 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2666 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
2667 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
2668 ret = -EINVAL;
2669 goto exit;
2670 }
2671 status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList,
2672 numChannels);
2673 if (eHAL_STATUS_SUCCESS != status)
2674 {
2675 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2676 "%s: Failed to update channel list information", __func__);
2677 ret = -EINVAL;
2678 goto exit;
2679 }
2680 }
2681 else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0)
2682 {
2683 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2684 tANI_U8 numChannels = 0;
Jeff Johnson51b67782013-04-05 12:35:41 -07002685 tANI_U8 j = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002686 char extra[128] = {0};
Jeff Johnson51b67782013-04-05 12:35:41 -07002687 int len;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002688
2689 if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal),
2690 ChannelList, &numChannels ))
2691 {
2692 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2693 "%s: failed to get roam scan channel list", __func__);
2694 ret = -EFAULT;
2695 goto exit;
2696 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302697 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2698 TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL,
2699 pAdapter->sessionId, numChannels));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002700 /* output channel list is of the format
2701 [Number of roam scan channels][Channel1][Channel2]... */
2702 /* copy the number of channels in the 0th index */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002703 len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002704 for (j = 0; (j < numChannels); j++)
2705 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002706 len += scnprintf(extra + len, sizeof(extra) - len, " %d",
2707 ChannelList[j]);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002708 }
2709
2710 if (copy_to_user(priv_data.buf, &extra, len + 1))
2711 {
2712 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2713 "%s: failed to copy data to user buffer", __func__);
2714 ret = -EFAULT;
2715 goto exit;
2716 }
2717 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002718 else if (strncmp(command, "GETCCXMODE", 10) == 0)
2719 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002720 tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002721 char extra[32];
2722 tANI_U8 len = 0;
2723
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002724 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002725 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002726 if (eseMode &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002727 hdd_is_okc_mode_enabled(pHddCtx) &&
2728 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2729 {
2730 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002731 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002732 " hence this operation is not permitted!", __func__);
2733 ret = -EPERM;
2734 goto exit;
2735 }
2736
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002737 len = scnprintf(extra, sizeof(extra), "%s %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002738 "GETCCXMODE", eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002739 if (copy_to_user(priv_data.buf, &extra, len + 1))
2740 {
2741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2742 "%s: failed to copy data to user buffer", __func__);
2743 ret = -EFAULT;
2744 goto exit;
2745 }
2746 }
2747 else if (strncmp(command, "GETOKCMODE", 10) == 0)
2748 {
2749 tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx);
2750 char extra[32];
2751 tANI_U8 len = 0;
2752
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002753 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002754 then this operation is not permitted (return FAILURE) */
2755 if (okcMode &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002756 sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002757 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2758 {
2759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002760 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002761 " hence this operation is not permitted!", __func__);
2762 ret = -EPERM;
2763 goto exit;
2764 }
2765
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002766 len = scnprintf(extra, sizeof(extra), "%s %d",
2767 "GETOKCMODE", okcMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002768 if (copy_to_user(priv_data.buf, &extra, len + 1))
2769 {
2770 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2771 "%s: failed to copy data to user buffer", __func__);
2772 ret = -EFAULT;
2773 goto exit;
2774 }
2775 }
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002776 else if (strncmp(command, "GETFASTROAM", 11) == 0)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002777 {
2778 tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2779 char extra[32];
2780 tANI_U8 len = 0;
2781
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002782 len = scnprintf(extra, sizeof(extra), "%s %d",
2783 "GETFASTROAM", lfrMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002784 if (copy_to_user(priv_data.buf, &extra, len + 1))
2785 {
2786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2787 "%s: failed to copy data to user buffer", __func__);
2788 ret = -EFAULT;
2789 goto exit;
2790 }
2791 }
2792 else if (strncmp(command, "GETFASTTRANSITION", 17) == 0)
2793 {
2794 tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2795 char extra[32];
2796 tANI_U8 len = 0;
2797
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002798 len = scnprintf(extra, sizeof(extra), "%s %d",
2799 "GETFASTTRANSITION", ft);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002800 if (copy_to_user(priv_data.buf, &extra, len + 1))
2801 {
2802 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2803 "%s: failed to copy data to user buffer", __func__);
2804 ret = -EFAULT;
2805 goto exit;
2806 }
2807 }
2808 else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0)
2809 {
2810 tANI_U8 *value = command;
2811 tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT;
2812
2813 /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */
2814 value = value + 26;
2815 /* Convert the value from ascii to integer */
2816 ret = kstrtou8(value, 10, &minTime);
2817 if (ret < 0)
2818 {
2819 /* If the input value is greater than max value of datatype, then also
2820 kstrtou8 fails */
2821 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2822 "%s: kstrtou8 failed range [%d - %d]", __func__,
2823 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2824 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2825 ret = -EINVAL;
2826 goto exit;
2827 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002828 if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) ||
2829 (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX))
2830 {
2831 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2832 "scan min channel time value %d is out of range"
2833 " (Min: %d Max: %d)", minTime,
2834 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2835 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2836 ret = -EINVAL;
2837 goto exit;
2838 }
2839
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302840 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2841 TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL,
2842 pAdapter->sessionId, minTime));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2844 "%s: Received Command to change channel min time = %d", __func__, minTime);
2845
2846 pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime;
2847 sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime);
2848 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002849 else if (strncmp(command, "SENDACTIONFRAME", 15) == 0)
2850 {
2851 tANI_U8 *value = command;
2852 tANI_U8 channel = 0;
2853 tANI_U8 dwellTime = 0;
2854 tANI_U8 bufLen = 0;
2855 tANI_U8 *buf = NULL;
2856 tSirMacAddr targetApBssid;
2857 eHalStatus status = eHAL_STATUS_SUCCESS;
2858 struct ieee80211_channel chan;
2859 tANI_U8 finalLen = 0;
2860 tANI_U8 *finalBuf = NULL;
2861 tANI_U8 temp = 0;
2862 u64 cookie;
2863 hdd_station_ctx_t *pHddStaCtx = NULL;
2864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2865
2866 /* if not associated, no need to send action frame */
2867 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2868 {
2869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
2870 ret = -EINVAL;
2871 goto exit;
2872 }
2873
2874 status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel,
2875 &dwellTime, &buf, &bufLen);
2876 if (eHAL_STATUS_SUCCESS != status)
2877 {
2878 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2879 "%s: Failed to parse send action frame data", __func__);
2880 ret = -EINVAL;
2881 goto exit;
2882 }
2883
2884 /* if the target bssid is different from currently associated AP,
2885 then no need to send action frame */
2886 if (VOS_TRUE != vos_mem_compare(targetApBssid,
2887 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
2888 {
2889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__);
2890 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07002891 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002892 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002893 goto exit;
2894 }
2895
2896 /* if the channel number is different from operating channel then
2897 no need to send action frame */
2898 if (channel != pHddStaCtx->conn_info.operationChannel)
2899 {
2900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2901 "%s: channel(%d) is different from operating channel(%d)",
2902 __func__, channel, pHddStaCtx->conn_info.operationChannel);
2903 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07002904 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002905 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002906 goto exit;
2907 }
2908 chan.center_freq = sme_ChnToFreq(channel);
2909
2910 finalLen = bufLen + 24;
2911 finalBuf = vos_mem_malloc(finalLen);
2912 if (NULL == finalBuf)
2913 {
2914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__);
2915 ret = -ENOMEM;
Jeff Johnson11c33152013-04-16 17:52:40 -07002916 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002917 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002918 goto exit;
2919 }
2920 vos_mem_zero(finalBuf, finalLen);
2921
2922 /* Fill subtype */
2923 temp = SIR_MAC_MGMT_ACTION << 4;
2924 vos_mem_copy(finalBuf + 0, &temp, sizeof(temp));
2925
2926 /* Fill type */
2927 temp = SIR_MAC_MGMT_FRAME;
2928 vos_mem_copy(finalBuf + 2, &temp, sizeof(temp));
2929
2930 /* Fill destination address (bssid of the AP) */
2931 vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid));
2932
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07002933 /* Fill source address (STA mac address) */
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002934 vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes));
2935
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07002936 /* Fill BSSID (AP mac address) */
2937 vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid));
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002938
2939 /* Fill received buffer from 24th address */
2940 vos_mem_copy(finalBuf + 24, buf, bufLen);
2941
Jeff Johnson11c33152013-04-16 17:52:40 -07002942 /* done with the parsed buffer */
2943 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08002944 buf = NULL;
Jeff Johnson11c33152013-04-16 17:52:40 -07002945
DARAM SUDHA39eede62014-02-12 11:16:40 +05302946 wlan_hdd_mgmt_tx( NULL,
Yue Maf49ba872013-08-19 12:04:25 -07002947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
2948 &(pAdapter->wdev),
2949#else
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002950 pAdapter->dev,
Yue Maf49ba872013-08-19 12:04:25 -07002951#endif
2952 &chan, 0,
2953#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2954 NL80211_CHAN_HT20, 1,
2955#endif
2956 dwellTime, finalBuf, finalLen, 1,
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002957 1, &cookie );
2958 vos_mem_free(finalBuf);
2959 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002960 else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0)
2961 {
2962 tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal));
2963 char extra[32];
2964 tANI_U8 len = 0;
2965
2966 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002967 len = scnprintf(extra, sizeof(extra), "%s %d",
2968 "GETROAMSCANCHANNELMINTIME", val);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302969 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2970 TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL,
2971 pAdapter->sessionId, val));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002972 if (copy_to_user(priv_data.buf, &extra, len + 1))
2973 {
2974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2975 "%s: failed to copy data to user buffer", __func__);
2976 ret = -EFAULT;
2977 goto exit;
2978 }
2979 }
2980 else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0)
2981 {
2982 tANI_U8 *value = command;
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002983 tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002984
2985 /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */
2986 value = value + 19;
2987 /* Convert the value from ascii to integer */
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002988 ret = kstrtou16(value, 10, &maxTime);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002989 if (ret < 0)
2990 {
2991 /* If the input value is greater than max value of datatype, then also
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002992 kstrtou16 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002993 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07002994 "%s: kstrtou16 failed range [%d - %d]", __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002995 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
2996 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
2997 ret = -EINVAL;
2998 goto exit;
2999 }
3000
3001 if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) ||
3002 (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX))
3003 {
3004 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3005 "lfr mode value %d is out of range"
3006 " (Min: %d Max: %d)", maxTime,
3007 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
3008 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
3009 ret = -EINVAL;
3010 goto exit;
3011 }
3012
3013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3014 "%s: Received Command to change channel max time = %d", __func__, maxTime);
3015
3016 pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime;
3017 sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime);
3018 }
3019 else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0)
3020 {
3021 tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal));
3022 char extra[32];
3023 tANI_U8 len = 0;
3024
3025 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003026 len = scnprintf(extra, sizeof(extra), "%s %d",
3027 "GETSCANCHANNELTIME", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003028 if (copy_to_user(priv_data.buf, &extra, len + 1))
3029 {
3030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3031 "%s: failed to copy data to user buffer", __func__);
3032 ret = -EFAULT;
3033 goto exit;
3034 }
3035 }
3036 else if (strncmp(command, "SETSCANHOMETIME", 15) == 0)
3037 {
3038 tANI_U8 *value = command;
3039 tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT;
3040
3041 /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */
3042 value = value + 16;
3043 /* Convert the value from ascii to integer */
3044 ret = kstrtou16(value, 10, &val);
3045 if (ret < 0)
3046 {
3047 /* If the input value is greater than max value of datatype, then also
3048 kstrtou16 fails */
3049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3050 "%s: kstrtou16 failed range [%d - %d]", __func__,
3051 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
3052 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
3053 ret = -EINVAL;
3054 goto exit;
3055 }
3056
3057 if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) ||
3058 (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX))
3059 {
3060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3061 "scan home time value %d is out of range"
3062 " (Min: %d Max: %d)", val,
3063 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
3064 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
3065 ret = -EINVAL;
3066 goto exit;
3067 }
3068
3069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3070 "%s: Received Command to change scan home time = %d", __func__, val);
3071
3072 pHddCtx->cfg_ini->nNeighborScanPeriod = val;
3073 sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val);
3074 }
3075 else if (strncmp(command, "GETSCANHOMETIME", 15) == 0)
3076 {
3077 tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal));
3078 char extra[32];
3079 tANI_U8 len = 0;
3080
3081 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003082 len = scnprintf(extra, sizeof(extra), "%s %d",
3083 "GETSCANHOMETIME", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003084 if (copy_to_user(priv_data.buf, &extra, len + 1))
3085 {
3086 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3087 "%s: failed to copy data to user buffer", __func__);
3088 ret = -EFAULT;
3089 goto exit;
3090 }
3091 }
3092 else if (strncmp(command, "SETROAMINTRABAND", 16) == 0)
3093 {
3094 tANI_U8 *value = command;
3095 tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT;
3096
3097 /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */
3098 value = value + 17;
3099 /* Convert the value from ascii to integer */
3100 ret = kstrtou8(value, 10, &val);
3101 if (ret < 0)
3102 {
3103 /* If the input value is greater than max value of datatype, then also
3104 kstrtou8 fails */
3105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3106 "%s: kstrtou8 failed range [%d - %d]", __func__,
3107 CFG_ROAM_INTRA_BAND_MIN,
3108 CFG_ROAM_INTRA_BAND_MAX);
3109 ret = -EINVAL;
3110 goto exit;
3111 }
3112
3113 if ((val < CFG_ROAM_INTRA_BAND_MIN) ||
3114 (val > CFG_ROAM_INTRA_BAND_MAX))
3115 {
3116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3117 "intra band mode value %d is out of range"
3118 " (Min: %d Max: %d)", val,
3119 CFG_ROAM_INTRA_BAND_MIN,
3120 CFG_ROAM_INTRA_BAND_MAX);
3121 ret = -EINVAL;
3122 goto exit;
3123 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3125 "%s: Received Command to change intra band = %d", __func__, val);
3126
3127 pHddCtx->cfg_ini->nRoamIntraBand = val;
3128 sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val);
3129 }
3130 else if (strncmp(command, "GETROAMINTRABAND", 16) == 0)
3131 {
3132 tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal));
3133 char extra[32];
3134 tANI_U8 len = 0;
3135
3136 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003137 len = scnprintf(extra, sizeof(extra), "%s %d",
3138 "GETROAMINTRABAND", val);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003139 if (copy_to_user(priv_data.buf, &extra, len + 1))
3140 {
3141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3142 "%s: failed to copy data to user buffer", __func__);
3143 ret = -EFAULT;
3144 goto exit;
3145 }
3146 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003147 else if (strncmp(command, "SETSCANNPROBES", 14) == 0)
3148 {
3149 tANI_U8 *value = command;
3150 tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT;
3151
3152 /* Move pointer to ahead of SETSCANNPROBES<delimiter> */
3153 value = value + 15;
3154 /* Convert the value from ascii to integer */
3155 ret = kstrtou8(value, 10, &nProbes);
3156 if (ret < 0)
3157 {
3158 /* If the input value is greater than max value of datatype, then also
3159 kstrtou8 fails */
3160 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3161 "%s: kstrtou8 failed range [%d - %d]", __func__,
3162 CFG_ROAM_SCAN_N_PROBES_MIN,
3163 CFG_ROAM_SCAN_N_PROBES_MAX);
3164 ret = -EINVAL;
3165 goto exit;
3166 }
3167
3168 if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) ||
3169 (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX))
3170 {
3171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3172 "NProbes value %d is out of range"
3173 " (Min: %d Max: %d)", nProbes,
3174 CFG_ROAM_SCAN_N_PROBES_MIN,
3175 CFG_ROAM_SCAN_N_PROBES_MAX);
3176 ret = -EINVAL;
3177 goto exit;
3178 }
3179
3180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3181 "%s: Received Command to Set nProbes = %d", __func__, nProbes);
3182
3183 pHddCtx->cfg_ini->nProbes = nProbes;
3184 sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes);
3185 }
3186 else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0)
3187 {
3188 tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal));
3189 char extra[32];
3190 tANI_U8 len = 0;
3191
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003192 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003193 if (copy_to_user(priv_data.buf, &extra, len + 1))
3194 {
3195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3196 "%s: failed to copy data to user buffer", __func__);
3197 ret = -EFAULT;
3198 goto exit;
3199 }
3200 }
3201 else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0)
3202 {
3203 tANI_U8 *value = command;
3204 tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT;
3205
3206 /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */
3207 /* input value is in units of msec */
3208 value = value + 20;
3209 /* Convert the value from ascii to integer */
3210 ret = kstrtou16(value, 10, &homeAwayTime);
3211 if (ret < 0)
3212 {
3213 /* If the input value is greater than max value of datatype, then also
3214 kstrtou8 fails */
3215 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3216 "%s: kstrtou8 failed range [%d - %d]", __func__,
3217 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
3218 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
3219 ret = -EINVAL;
3220 goto exit;
3221 }
3222
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003223 if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) ||
3224 (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX))
3225 {
3226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3227 "homeAwayTime value %d is out of range"
3228 " (Min: %d Max: %d)", homeAwayTime,
3229 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
3230 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
3231 ret = -EINVAL;
3232 goto exit;
3233 }
3234
3235 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3236 "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07003237 if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime)
3238 {
3239 pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime;
3240 sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE);
3241 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003242 }
3243 else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0)
3244 {
3245 tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal));
3246 char extra[32];
3247 tANI_U8 len = 0;
3248
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003249 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003250 if (copy_to_user(priv_data.buf, &extra, len + 1))
3251 {
3252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3253 "%s: failed to copy data to user buffer", __func__);
3254 ret = -EFAULT;
3255 goto exit;
3256 }
3257 }
3258 else if (strncmp(command, "REASSOC", 7) == 0)
3259 {
3260 tANI_U8 *value = command;
3261 tANI_U8 channel = 0;
3262 tSirMacAddr targetApBssid;
3263 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003264#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3265 tCsrHandoffRequest handoffInfo;
3266#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003267 hdd_station_ctx_t *pHddStaCtx = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003268 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3269
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003270 /* if not associated, no need to proceed with reassoc */
3271 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3272 {
3273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3274 ret = -EINVAL;
3275 goto exit;
3276 }
3277
3278 status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel);
3279 if (eHAL_STATUS_SUCCESS != status)
3280 {
3281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3282 "%s: Failed to parse reassoc command data", __func__);
3283 ret = -EINVAL;
3284 goto exit;
3285 }
3286
3287 /* if the target bssid is same as currently associated AP,
3288 then no need to proceed with reassoc */
3289 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3290 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3291 {
3292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__);
3293 ret = -EINVAL;
3294 goto exit;
3295 }
3296
3297 /* Check channel number is a valid channel number */
3298 if(VOS_STATUS_SUCCESS !=
3299 wlan_hdd_validate_operation_channel(pAdapter, channel))
3300 {
3301 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003302 "%s: Invalid Channel [%d]", __func__, channel);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003303 return -EINVAL;
3304 }
3305
3306 /* Proceed with reassoc */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003307#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3308 handoffInfo.channel = channel;
3309 vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr));
3310 sme_HandoffRequest(pHddCtx->hHal, &handoffInfo);
3311#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003312 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003313 else if (strncmp(command, "SETWESMODE", 10) == 0)
3314 {
3315 tANI_U8 *value = command;
3316 tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT;
3317
3318 /* Move pointer to ahead of SETWESMODE<delimiter> */
3319 value = value + 11;
3320 /* Convert the value from ascii to integer */
3321 ret = kstrtou8(value, 10, &wesMode);
3322 if (ret < 0)
3323 {
3324 /* If the input value is greater than max value of datatype, then also
3325 kstrtou8 fails */
3326 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3327 "%s: kstrtou8 failed range [%d - %d]", __func__,
3328 CFG_ENABLE_WES_MODE_NAME_MIN,
3329 CFG_ENABLE_WES_MODE_NAME_MAX);
3330 ret = -EINVAL;
3331 goto exit;
3332 }
3333
3334 if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) ||
3335 (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX))
3336 {
3337 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3338 "WES Mode value %d is out of range"
3339 " (Min: %d Max: %d)", wesMode,
3340 CFG_ENABLE_WES_MODE_NAME_MIN,
3341 CFG_ENABLE_WES_MODE_NAME_MAX);
3342 ret = -EINVAL;
3343 goto exit;
3344 }
3345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3346 "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode);
3347
3348 pHddCtx->cfg_ini->isWESModeEnabled = wesMode;
3349 sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode);
3350 }
3351 else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0)
3352 {
3353 tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal));
3354 char extra[32];
3355 tANI_U8 len = 0;
3356
Arif Hussain826d9412013-11-12 16:44:54 -08003357 len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode);
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003358 if (copy_to_user(priv_data.buf, &extra, len + 1))
3359 {
3360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3361 "%s: failed to copy data to user buffer", __func__);
3362 ret = -EFAULT;
3363 goto exit;
3364 }
3365 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003366#endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003367#ifdef FEATURE_WLAN_LFR
3368 else if (strncmp(command, "SETFASTROAM", 11) == 0)
3369 {
3370 tANI_U8 *value = command;
3371 tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
3372
3373 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3374 value = value + 12;
3375 /* Convert the value from ascii to integer */
3376 ret = kstrtou8(value, 10, &lfrMode);
3377 if (ret < 0)
3378 {
3379 /* If the input value is greater than max value of datatype, then also
3380 kstrtou8 fails */
3381 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3382 "%s: kstrtou8 failed range [%d - %d]", __func__,
3383 CFG_LFR_FEATURE_ENABLED_MIN,
3384 CFG_LFR_FEATURE_ENABLED_MAX);
3385 ret = -EINVAL;
3386 goto exit;
3387 }
3388
3389 if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
3390 (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX))
3391 {
3392 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3393 "lfr mode value %d is out of range"
3394 " (Min: %d Max: %d)", lfrMode,
3395 CFG_LFR_FEATURE_ENABLED_MIN,
3396 CFG_LFR_FEATURE_ENABLED_MAX);
3397 ret = -EINVAL;
3398 goto exit;
3399 }
3400
3401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3402 "%s: Received Command to change lfr mode = %d", __func__, lfrMode);
3403
3404 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode;
3405 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode);
3406 }
3407#endif
3408#ifdef WLAN_FEATURE_VOWIFI_11R
3409 else if (strncmp(command, "SETFASTTRANSITION", 17) == 0)
3410 {
3411 tANI_U8 *value = command;
3412 tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT;
3413
3414 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3415 value = value + 18;
3416 /* Convert the value from ascii to integer */
3417 ret = kstrtou8(value, 10, &ft);
3418 if (ret < 0)
3419 {
3420 /* If the input value is greater than max value of datatype, then also
3421 kstrtou8 fails */
3422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3423 "%s: kstrtou8 failed range [%d - %d]", __func__,
3424 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3425 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3426 ret = -EINVAL;
3427 goto exit;
3428 }
3429
3430 if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) ||
3431 (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX))
3432 {
3433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3434 "ft mode value %d is out of range"
3435 " (Min: %d Max: %d)", ft,
3436 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3437 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3438 ret = -EINVAL;
3439 goto exit;
3440 }
3441
3442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3443 "%s: Received Command to change ft mode = %d", __func__, ft);
3444
3445 pHddCtx->cfg_ini->isFastTransitionEnabled = ft;
3446 sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft);
3447 }
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303448
3449 else if (strncmp(command, "FASTREASSOC", 11) == 0)
3450 {
3451 tANI_U8 *value = command;
3452 tSirMacAddr targetApBssid;
3453 tANI_U8 trigger = 0;
3454 eHalStatus status = eHAL_STATUS_SUCCESS;
3455 hdd_station_ctx_t *pHddStaCtx = NULL;
3456 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3457
3458 /* if not associated, no need to proceed with reassoc */
3459 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3460 {
3461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3462 ret = -EINVAL;
3463 goto exit;
3464 }
3465
3466 status = hdd_parse_reassoc_command_data(value, targetApBssid, &trigger);
3467 if (eHAL_STATUS_SUCCESS != status)
3468 {
3469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3470 "%s: Failed to parse reassoc command data", __func__);
3471 ret = -EINVAL;
3472 goto exit;
3473 }
3474
3475 /* if the target bssid is same as currently associated AP,
3476 then no need to proceed with reassoc */
3477 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3478 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3479 {
3480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3481 "%s:11r Reassoc BSSID is same as currently associated AP bssid",
3482 __func__);
3483 ret = -EINVAL;
3484 goto exit;
3485 }
3486
3487 /* Proceed with scan/roam */
3488 smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter),
3489 &targetApBssid[0],
3490 (tSmeFastRoamTrigger)(trigger));
3491 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003492#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003493#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003494 else if (strncmp(command, "SETCCXMODE", 10) == 0)
3495 {
3496 tANI_U8 *value = command;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003497 tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003498
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003499 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003500 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003501 if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003502 hdd_is_okc_mode_enabled(pHddCtx) &&
3503 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3504 {
3505 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003506 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003507 " hence this operation is not permitted!", __func__);
3508 ret = -EPERM;
3509 goto exit;
3510 }
3511
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003512 /* Move pointer to ahead of SETCCXMODE<delimiter> */
3513 value = value + 11;
3514 /* Convert the value from ascii to integer */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003515 ret = kstrtou8(value, 10, &eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003516 if (ret < 0)
3517 {
3518 /* If the input value is greater than max value of datatype, then also
3519 kstrtou8 fails */
3520 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3521 "%s: kstrtou8 failed range [%d - %d]", __func__,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003522 CFG_ESE_FEATURE_ENABLED_MIN,
3523 CFG_ESE_FEATURE_ENABLED_MAX);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003524 ret = -EINVAL;
3525 goto exit;
3526 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003527 if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) ||
3528 (eseMode > CFG_ESE_FEATURE_ENABLED_MAX))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003529 {
3530 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003531 "Ese mode value %d is out of range"
3532 " (Min: %d Max: %d)", eseMode,
3533 CFG_ESE_FEATURE_ENABLED_MIN,
3534 CFG_ESE_FEATURE_ENABLED_MAX);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003535 ret = -EINVAL;
3536 goto exit;
3537 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003538 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003539 "%s: Received Command to change ese mode = %d", __func__, eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003540
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003541 pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode;
3542 sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003543 }
3544#endif
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003545 else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0)
3546 {
3547 tANI_U8 *value = command;
3548 tANI_BOOLEAN roamScanControl = 0;
3549
3550 /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */
3551 value = value + 19;
3552 /* Convert the value from ascii to integer */
3553 ret = kstrtou8(value, 10, &roamScanControl);
3554 if (ret < 0)
3555 {
3556 /* If the input value is greater than max value of datatype, then also
3557 kstrtou8 fails */
3558 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3559 "%s: kstrtou8 failed ", __func__);
3560 ret = -EINVAL;
3561 goto exit;
3562 }
3563
3564 if (0 != roamScanControl)
3565 {
3566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3567 "roam scan control invalid value = %d",
3568 roamScanControl);
3569 ret = -EINVAL;
3570 goto exit;
3571 }
3572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3573 "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl);
3574
3575 sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl);
3576 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003577#ifdef FEATURE_WLAN_OKC
3578 else if (strncmp(command, "SETOKCMODE", 10) == 0)
3579 {
3580 tANI_U8 *value = command;
3581 tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT;
3582
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003583 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003584 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003585 if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003586 hdd_is_okc_mode_enabled(pHddCtx) &&
3587 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3588 {
3589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003590 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003591 " hence this operation is not permitted!", __func__);
3592 ret = -EPERM;
3593 goto exit;
3594 }
3595
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003596 /* Move pointer to ahead of SETOKCMODE<delimiter> */
3597 value = value + 11;
3598 /* Convert the value from ascii to integer */
3599 ret = kstrtou8(value, 10, &okcMode);
3600 if (ret < 0)
3601 {
3602 /* If the input value is greater than max value of datatype, then also
3603 kstrtou8 fails */
3604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3605 "%s: kstrtou8 failed range [%d - %d]", __func__,
3606 CFG_OKC_FEATURE_ENABLED_MIN,
3607 CFG_OKC_FEATURE_ENABLED_MAX);
3608 ret = -EINVAL;
3609 goto exit;
3610 }
3611
3612 if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) ||
3613 (okcMode > CFG_OKC_FEATURE_ENABLED_MAX))
3614 {
3615 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3616 "Okc mode value %d is out of range"
3617 " (Min: %d Max: %d)", okcMode,
3618 CFG_OKC_FEATURE_ENABLED_MIN,
3619 CFG_OKC_FEATURE_ENABLED_MAX);
3620 ret = -EINVAL;
3621 goto exit;
3622 }
3623
3624 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3625 "%s: Received Command to change okc mode = %d", __func__, okcMode);
3626
3627 pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode;
3628 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003629#endif /* FEATURE_WLAN_OKC */
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003630 else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0)
3631 {
3632 tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal));
3633 char extra[32];
3634 tANI_U8 len = 0;
3635
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003636 len = scnprintf(extra, sizeof(extra), "%s %d",
3637 command, roamScanControl);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003638 if (copy_to_user(priv_data.buf, &extra, len + 1))
3639 {
3640 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3641 "%s: failed to copy data to user buffer", __func__);
3642 ret = -EFAULT;
3643 goto exit;
3644 }
3645 }
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05303646#ifdef WLAN_FEATURE_PACKET_FILTERING
3647 else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0)
3648 {
3649 tANI_U8 filterType = 0;
3650 tANI_U8 *value = command;
3651
3652 /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */
3653 value = value + 22;
3654
3655 /* Convert the value from ascii to integer */
3656 ret = kstrtou8(value, 10, &filterType);
3657 if (ret < 0)
3658 {
3659 /* If the input value is greater than max value of datatype,
3660 * then also kstrtou8 fails
3661 */
3662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3663 "%s: kstrtou8 failed range ", __func__);
3664 ret = -EINVAL;
3665 goto exit;
3666 }
3667
3668 if (filterType != 0 && filterType != 1)
3669 {
3670 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3671 "%s: Accepted Values are 0 and 1 ", __func__);
3672 ret = -EINVAL;
3673 goto exit;
3674 }
3675 wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType,
3676 pAdapter->sessionId);
3677 }
3678#endif
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303679 else if (strncmp(command, "BTCOEXMODE", 10) == 0 )
3680 {
Kiet Lamad161252014-07-22 11:23:32 -07003681 char *dhcpPhase;
Satyanarayana Dash1faea4f2014-09-22 16:21:04 +05303682 int ret;
3683
Kiet Lamad161252014-07-22 11:23:32 -07003684 dhcpPhase = command + 11;
3685 if ('1' == *dhcpPhase)
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303686 {
c_hpothu9b781ba2013-12-30 20:57:45 +05303687 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kiet Lamad161252014-07-22 11:23:32 -07003688 FL("send DHCP START indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303689
3690 pHddCtx->btCoexModeSet = TRUE;
Kiet Lamad161252014-07-22 11:23:32 -07003691
Satyanarayana Dash1faea4f2014-09-22 16:21:04 +05303692 ret = wlan_hdd_scan_abort(pAdapter);
3693 if (ret < 0)
3694 {
3695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3696 FL("failed to abort existing scan %d"), ret);
3697 }
3698
Kiet Lamad161252014-07-22 11:23:32 -07003699 sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode,
3700 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303701 }
Kiet Lamad161252014-07-22 11:23:32 -07003702 else if ('2' == *dhcpPhase)
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303703 {
c_hpothu9b781ba2013-12-30 20:57:45 +05303704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kiet Lamad161252014-07-22 11:23:32 -07003705 FL("send DHCP STOP indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303706
3707 pHddCtx->btCoexModeSet = FALSE;
Kiet Lamad161252014-07-22 11:23:32 -07003708
3709 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
3710 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303711 }
3712 }
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003713 else if (strncmp(command, "SCAN-ACTIVE", 11) == 0)
3714 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3716 FL("making default scan to ACTIVE"));
3717 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003718 }
3719 else if (strncmp(command, "SCAN-PASSIVE", 12) == 0)
3720 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3722 FL("making default scan to PASSIVE"));
3723 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003724 }
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303725 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
3726 {
3727 hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3728 char extra[32];
3729 tANI_U8 len = 0;
3730
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05303731 memset(extra, 0, sizeof(extra));
3732 ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len);
3733 if (ret != 0 || copy_to_user(priv_data.buf, &extra, len + 1))
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303734 {
3735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3736 "%s: failed to copy data to user buffer", __func__);
3737 ret = -EFAULT;
3738 goto exit;
3739 }
3740 ret = len;
3741 }
3742 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
3743 {
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05303744 ret = hdd_set_dwell_time(pAdapter, command);
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303745 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003746 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
3747 {
3748 tANI_U8 filterType = 0;
3749 tANI_U8 *value;
3750 value = command + 9;
3751
3752 /* Convert the value from ascii to integer */
3753 ret = kstrtou8(value, 10, &filterType);
3754 if (ret < 0)
3755 {
3756 /* If the input value is greater than max value of datatype,
3757 * then also kstrtou8 fails
3758 */
3759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3760 "%s: kstrtou8 failed range ", __func__);
3761 ret = -EINVAL;
3762 goto exit;
3763 }
3764 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
3765 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
3766 {
3767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3768 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
3769 " 2-Sink ", __func__);
3770 ret = -EINVAL;
3771 goto exit;
3772 }
3773 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
3774 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +05303775 pScanInfo = &pHddCtx->scan_info;
3776 if (filterType && pScanInfo != NULL &&
3777 pHddCtx->scan_info.mScanPending)
3778 {
3779 /*Miracast Session started. Abort Scan */
3780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3781 "%s, Aborting Scan For Miracast",__func__);
3782 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
3783 eCSR_SCAN_ABORT_DEFAULT);
3784 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003785 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05303786 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003787 }
Leo Chang614d2072013-08-22 14:59:44 -07003788 else if (strncmp(command, "SETMCRATE", 9) == 0)
3789 {
Leo Chang614d2072013-08-22 14:59:44 -07003790 tANI_U8 *value = command;
3791 int targetRate;
Leo Chang1f98cbd2013-10-17 15:03:52 -07003792 tSirRateUpdateInd *rateUpdate;
3793 eHalStatus status;
Leo Chang614d2072013-08-22 14:59:44 -07003794
3795 /* Only valid for SAP mode */
3796 if (WLAN_HDD_SOFTAP != pAdapter->device_mode)
3797 {
3798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3799 "%s: SAP mode is not running", __func__);
3800 ret = -EFAULT;
3801 goto exit;
3802 }
3803
3804 /* Move pointer to ahead of SETMCRATE<delimiter> */
3805 /* input value is in units of hundred kbps */
3806 value = value + 10;
3807 /* Convert the value from ascii to integer, decimal base */
3808 ret = kstrtouint(value, 10, &targetRate);
3809
Leo Chang1f98cbd2013-10-17 15:03:52 -07003810 rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd));
3811 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07003812 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07003813 hddLog(VOS_TRACE_LEVEL_ERROR,
3814 "%s: SETMCRATE indication alloc fail", __func__);
3815 ret = -EFAULT;
3816 goto exit;
3817 }
3818 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
3819
3820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3821 "MC Target rate %d", targetRate);
3822 /* Ignore unicast */
3823 rateUpdate->ucastDataRate = -1;
3824 rateUpdate->mcastDataRate24GHz = targetRate;
3825 rateUpdate->mcastDataRate5GHz = targetRate;
3826 rateUpdate->mcastDataRate24GHzTxFlag = 0;
3827 rateUpdate->mcastDataRate5GHzTxFlag = 0;
3828 status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate);
3829 if (eHAL_STATUS_SUCCESS != status)
3830 {
3831 hddLog(VOS_TRACE_LEVEL_ERROR,
3832 "%s: SET_MC_RATE failed", __func__);
3833 vos_mem_free(rateUpdate);
3834 ret = -EFAULT;
3835 goto exit;
Leo Chang614d2072013-08-22 14:59:44 -07003836 }
3837 }
Rajeev79dbe4c2013-10-05 11:03:42 +05303838#ifdef FEATURE_WLAN_BATCH_SCAN
Rajeev Kumar8b373292014-01-08 20:36:55 -08003839 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
Rajeev79dbe4c2013-10-05 11:03:42 +05303840 {
Rajeev Kumar8b373292014-01-08 20:36:55 -08003841 ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command);
Rajeev79dbe4c2013-10-05 11:03:42 +05303842 }
3843#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003844#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003845 else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0)
3846 {
3847 tANI_U8 *value = command;
3848 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3849 tANI_U8 numChannels = 0;
3850 eHalStatus status = eHAL_STATUS_SUCCESS;
3851
3852 status = hdd_parse_channellist(value, ChannelList, &numChannels);
3853 if (eHAL_STATUS_SUCCESS != status)
3854 {
3855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3856 "%s: Failed to parse channel list information", __func__);
3857 ret = -EINVAL;
3858 goto exit;
3859 }
3860
3861 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3862 {
3863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3864 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
3865 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
3866 ret = -EINVAL;
3867 goto exit;
3868 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003869 status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003870 ChannelList,
3871 numChannels);
3872 if (eHAL_STATUS_SUCCESS != status)
3873 {
3874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3875 "%s: Failed to update channel list information", __func__);
3876 ret = -EINVAL;
3877 goto exit;
3878 }
3879 }
3880 else if (strncmp(command, "GETTSMSTATS", 11) == 0)
3881 {
3882 tANI_U8 *value = command;
3883 char extra[128] = {0};
3884 int len = 0;
3885 tANI_U8 tid = 0;
3886 hdd_station_ctx_t *pHddStaCtx = NULL;
3887 tAniTrafStrmMetrics tsmMetrics;
3888 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3889
3890 /* if not associated, return error */
3891 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3892 {
3893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__);
3894 ret = -EINVAL;
3895 goto exit;
3896 }
3897
3898 /* Move pointer to ahead of GETTSMSTATS<delimiter> */
3899 value = value + 12;
3900 /* Convert the value from ascii to integer */
3901 ret = kstrtou8(value, 10, &tid);
3902 if (ret < 0)
3903 {
3904 /* If the input value is greater than max value of datatype, then also
3905 kstrtou8 fails */
3906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3907 "%s: kstrtou8 failed range [%d - %d]", __func__,
3908 TID_MIN_VALUE,
3909 TID_MAX_VALUE);
3910 ret = -EINVAL;
3911 goto exit;
3912 }
3913
3914 if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE))
3915 {
3916 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3917 "tid value %d is out of range"
3918 " (Min: %d Max: %d)", tid,
3919 TID_MIN_VALUE,
3920 TID_MAX_VALUE);
3921 ret = -EINVAL;
3922 goto exit;
3923 }
3924
3925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3926 "%s: Received Command to get tsm stats tid = %d", __func__, tid);
3927
3928 if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics))
3929 {
3930 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3931 "%s: failed to get tsm stats", __func__);
3932 ret = -EFAULT;
3933 goto exit;
3934 }
3935
3936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3937 "UplinkPktQueueDly(%d)\n"
3938 "UplinkPktQueueDlyHist[0](%d)\n"
3939 "UplinkPktQueueDlyHist[1](%d)\n"
3940 "UplinkPktQueueDlyHist[2](%d)\n"
3941 "UplinkPktQueueDlyHist[3](%d)\n"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05303942 "UplinkPktTxDly(%u)\n"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003943 "UplinkPktLoss(%d)\n"
3944 "UplinkPktCount(%d)\n"
3945 "RoamingCount(%d)\n"
3946 "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly,
3947 tsmMetrics.UplinkPktQueueDlyHist[0],
3948 tsmMetrics.UplinkPktQueueDlyHist[1],
3949 tsmMetrics.UplinkPktQueueDlyHist[2],
3950 tsmMetrics.UplinkPktQueueDlyHist[3],
3951 tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss,
3952 tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly);
3953
3954 /* Output TSM stats is of the format
3955 GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly]
3956 eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003957 len = scnprintf(extra, sizeof(extra), "%s %d %d:%d:%d:%d %u %d %d %d %d", command,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003958 tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0],
3959 tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2],
3960 tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly,
3961 tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount,
3962 tsmMetrics.RoamingDly);
3963
3964 if (copy_to_user(priv_data.buf, &extra, len + 1))
3965 {
3966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3967 "%s: failed to copy data to user buffer", __func__);
3968 ret = -EFAULT;
3969 goto exit;
3970 }
3971 }
3972 else if (strncmp(command, "SETCCKMIE", 9) == 0)
3973 {
3974 tANI_U8 *value = command;
3975 tANI_U8 *cckmIe = NULL;
3976 tANI_U8 cckmIeLen = 0;
3977 eHalStatus status = eHAL_STATUS_SUCCESS;
3978
3979 status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen);
3980 if (eHAL_STATUS_SUCCESS != status)
3981 {
3982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3983 "%s: Failed to parse cckm ie data", __func__);
3984 ret = -EINVAL;
3985 goto exit;
3986 }
3987
3988 if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN)
3989 {
3990 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3991 "%s: CCKM Ie input length is more than max[%d]", __func__,
3992 DOT11F_IE_RSN_MAX_LEN);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003993 vos_mem_free(cckmIe);
3994 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003995 ret = -EINVAL;
3996 goto exit;
3997 }
3998 sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003999 vos_mem_free(cckmIe);
4000 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004001 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004002 else if (strncmp(command, "CCXBEACONREQ", 12) == 0)
4003 {
4004 tANI_U8 *value = command;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004005 tCsrEseBeaconReq eseBcnReq;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004006 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004007
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004008 status = hdd_parse_ese_beacon_req(value, &eseBcnReq);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004009 if (eHAL_STATUS_SUCCESS != status)
4010 {
4011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004012 "%s: Failed to parse ese beacon req", __func__);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004013 ret = -EINVAL;
4014 goto exit;
4015 }
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004016 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
4017 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated"));
4018 hdd_indicateEseBcnReportNoResults (pAdapter,
4019 eseBcnReq.bcnReq[0].measurementToken,
4020 0x02, //BIT(1) set for measurement done
4021 0); // no BSS
4022 goto exit;
4023 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004024
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004025 status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq);
4026 if (eHAL_STATUS_SUCCESS != status)
4027 {
4028 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4029 "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status);
4030 ret = -EINVAL;
4031 goto exit;
4032 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004033 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004034#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
c_hpothu92367912014-05-01 15:18:17 +05304035 else if (strncmp(command, "GETBCNMISSRATE", 14) == 0)
4036 {
4037 eHalStatus status;
4038 char buf[32], len;
4039 long waitRet;
4040 bcnMissRateContext_t getBcnMissRateCtx;
4041
4042 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4043
4044 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4045 {
4046 hddLog(VOS_TRACE_LEVEL_WARN,
4047 FL("GETBCNMISSRATE: STA is not in connected state"));
4048 ret = -1;
4049 goto exit;
4050 }
4051
4052 init_completion(&(getBcnMissRateCtx.completion));
4053 getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC;
4054
4055 status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal),
4056 pAdapter->sessionId,
4057 (void *)getBcnMissRateCB,
4058 (void *)(&getBcnMissRateCtx));
4059 if( eHAL_STATUS_SUCCESS != status)
4060 {
4061 hddLog(VOS_TRACE_LEVEL_INFO,
4062 FL("GETBCNMISSRATE: fail to post WDA cmd"));
4063 ret = -EINVAL;
4064 goto exit;
4065 }
4066
4067 waitRet = wait_for_completion_interruptible_timeout
4068 (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME);
4069 if(waitRet <= 0)
4070 {
4071 hddLog(VOS_TRACE_LEVEL_ERROR,
4072 FL("failed to wait on bcnMissRateComp %d"), ret);
4073
4074 //Make magic number to zero so that callback is not called.
4075 spin_lock(&hdd_context_lock);
4076 getBcnMissRateCtx.magic = 0x0;
4077 spin_unlock(&hdd_context_lock);
4078 ret = -EINVAL;
4079 goto exit;
4080 }
4081
4082 hddLog(VOS_TRACE_LEVEL_INFO,
4083 FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate);
4084
4085 len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate);
4086 if (copy_to_user(priv_data.buf, &buf, len + 1))
4087 {
4088 hddLog(VOS_TRACE_LEVEL_ERROR,
4089 "%s: failed to copy data to user buffer", __func__);
4090 ret = -EFAULT;
4091 goto exit;
4092 }
4093 ret = len;
4094 }
Atul Mittal87ec2422014-09-24 13:12:50 +05304095#ifdef FEATURE_WLAN_TDLS
4096 else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) {
4097 tANI_U8 *value = command;
4098 int set_value;
4099 /* Move pointer to ahead of TDLSOFFCH*/
4100 value += 26;
4101 sscanf(value, "%d", &set_value);
4102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4103 "%s: Tdls offchannel offset:%d",
4104 __func__, set_value);
4105 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4106 if (ret < 0)
4107 {
4108 ret = -EINVAL;
4109 goto exit;
4110 }
4111
4112 } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) {
4113 tANI_U8 *value = command;
4114 int set_value;
4115 /* Move pointer to ahead of tdlsoffchnmode*/
4116 value += 18;
4117 sscanf(value, "%d", &set_value);
4118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4119 "%s: Tdls offchannel mode:%d",
4120 __func__, set_value);
4121 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4122 if (ret < 0)
4123 {
4124 ret = -EINVAL;
4125 goto exit;
4126 }
4127 } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) {
4128 tANI_U8 *value = command;
4129 int set_value;
4130 /* Move pointer to ahead of TDLSOFFCH*/
4131 value += 14;
4132 sscanf(value, "%d", &set_value);
4133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4134 "%s: Tdls offchannel num: %d",
4135 __func__, set_value);
4136 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4137 if (ret < 0)
4138 {
4139 ret = -EINVAL;
4140 goto exit;
4141 }
4142 }
4143#endif
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004144 else {
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304145 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4146 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
4147 pAdapter->sessionId, 0));
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004148 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4149 __func__, command);
4150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 }
4152exit:
4153 if (command)
4154 {
4155 kfree(command);
4156 }
4157 return ret;
4158}
4159
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004160#ifdef CONFIG_COMPAT
4161static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4162{
4163 struct {
4164 compat_uptr_t buf;
4165 int used_len;
4166 int total_len;
4167 } compat_priv_data;
4168 hdd_priv_data_t priv_data;
4169 int ret = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004170
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004171 /*
4172 * Note that pAdapter and ifr have already been verified by caller,
4173 * and HDD context has also been validated
4174 */
4175 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
4176 sizeof(compat_priv_data))) {
4177 ret = -EFAULT;
4178 goto exit;
4179 }
4180 priv_data.buf = compat_ptr(compat_priv_data.buf);
4181 priv_data.used_len = compat_priv_data.used_len;
4182 priv_data.total_len = compat_priv_data.total_len;
4183 ret = hdd_driver_command(pAdapter, &priv_data);
4184 exit:
4185 return ret;
4186}
4187#else /* CONFIG_COMPAT */
4188static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4189{
4190 /* will never be invoked */
4191 return 0;
4192}
4193#endif /* CONFIG_COMPAT */
4194
4195static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4196{
4197 hdd_priv_data_t priv_data;
4198 int ret = 0;
4199
4200 /*
4201 * Note that pAdapter and ifr have already been verified by caller,
4202 * and HDD context has also been validated
4203 */
4204 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
4205 ret = -EFAULT;
4206 } else {
4207 ret = hdd_driver_command(pAdapter, &priv_data);
4208 }
4209 return ret;
4210}
4211
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05304212int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004213{
4214 hdd_adapter_t *pAdapter;
4215 hdd_context_t *pHddCtx;
4216 int ret;
4217
4218 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4219 if (NULL == pAdapter) {
4220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4221 "%s: HDD adapter context is Null", __func__);
4222 ret = -ENODEV;
4223 goto exit;
4224 }
4225 if (dev != pAdapter->dev) {
4226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4227 "%s: HDD adapter/dev inconsistency", __func__);
4228 ret = -ENODEV;
4229 goto exit;
4230 }
4231
4232 if ((!ifr) || (!ifr->ifr_data)) {
4233 ret = -EINVAL;
4234 goto exit;
4235 }
4236
4237 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4238 ret = wlan_hdd_validate_context(pHddCtx);
4239 if (ret) {
4240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4241 "%s: invalid context", __func__);
4242 ret = -EBUSY;
4243 goto exit;
4244 }
4245
4246 switch (cmd) {
4247 case (SIOCDEVPRIVATE + 1):
4248 if (is_compat_task())
4249 ret = hdd_driver_compat_ioctl(pAdapter, ifr);
4250 else
4251 ret = hdd_driver_ioctl(pAdapter, ifr);
4252 break;
4253 default:
4254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
4255 __func__, cmd);
4256 ret = -EINVAL;
4257 break;
4258 }
4259 exit:
4260 return ret;
4261}
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004262
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05304263int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4264{
4265 int ret;
4266
4267 vos_ssr_protect(__func__);
4268 ret = __hdd_ioctl(dev, ifr, cmd);
4269 vos_ssr_unprotect(__func__);
4270
4271 return ret;
4272}
4273
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004274#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004275/**---------------------------------------------------------------------------
4276
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004277 \brief hdd_parse_ese_beacon_req() - Parse ese beacon request
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004278
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004279 This function parses the ese beacon request passed in the format
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004280 CCXBEACONREQ<space><Number of fields><space><Measurement token>
4281 <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N
4282 <space>Scan Mode N<space>Meas Duration N
4283 if the Number of bcn req fields (N) does not match with the actual number of fields passed
4284 then take N.
4285 <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair
4286 For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40.
4287 This function does not take care of removing duplicate channels from the list
4288
4289 \param - pValue Pointer to data
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004290 \param - pEseBcnReq output pointer to store parsed ie information
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004291
4292 \return - 0 for success non-zero for failure
4293
4294 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004295static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue,
4296 tCsrEseBeaconReq *pEseBcnReq)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004297{
4298 tANI_U8 *inPtr = pValue;
4299 int tempInt = 0;
4300 int j = 0, i = 0, v = 0;
4301 char buf[32];
4302
4303 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4304 /*no argument after the command*/
4305 if (NULL == inPtr)
4306 {
4307 return -EINVAL;
4308 }
4309 /*no space after the command*/
4310 else if (SPACE_ASCII_VALUE != *inPtr)
4311 {
4312 return -EINVAL;
4313 }
4314
4315 /*removing empty spaces*/
4316 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
4317
4318 /*no argument followed by spaces*/
4319 if ('\0' == *inPtr) return -EINVAL;
4320
4321 /*getting the first argument ie measurement token*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004322 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004323 if (1 != v) return -EINVAL;
4324
4325 v = kstrtos32(buf, 10, &tempInt);
4326 if ( v < 0) return -EINVAL;
4327
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004328 pEseBcnReq->numBcnReqIe = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004329
4330 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004331 "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004332
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004333 for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004334 {
4335 for (i = 0; i < 4; i++)
4336 {
4337 /*inPtr pointing to the beginning of first space after number of ie fields*/
4338 inPtr = strpbrk( inPtr, " " );
4339 /*no ie data after the number of ie fields argument*/
4340 if (NULL == inPtr) return -EINVAL;
4341
4342 /*removing empty space*/
4343 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
4344
4345 /*no ie data after the number of ie fields argument and spaces*/
4346 if ( '\0' == *inPtr ) return -EINVAL;
4347
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004348 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004349 if (1 != v) return -EINVAL;
4350
4351 v = kstrtos32(buf, 10, &tempInt);
4352 if (v < 0) return -EINVAL;
4353
4354 switch (i)
4355 {
4356 case 0: /* Measurement token */
4357 if (tempInt <= 0)
4358 {
4359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4360 "Invalid Measurement Token(%d)", tempInt);
4361 return -EINVAL;
4362 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004363 pEseBcnReq->bcnReq[j].measurementToken = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004364 break;
4365
4366 case 1: /* Channel number */
4367 if ((tempInt <= 0) ||
4368 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4369 {
4370 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4371 "Invalid Channel Number(%d)", tempInt);
4372 return -EINVAL;
4373 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004374 pEseBcnReq->bcnReq[j].channel = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004375 break;
4376
4377 case 2: /* Scan mode */
Varun Reddy Yeturu0b18d5a2013-12-04 11:42:23 -08004378 if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004379 {
4380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4381 "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt);
4382 return -EINVAL;
4383 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004384 pEseBcnReq->bcnReq[j].scanMode= tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004385 break;
4386
4387 case 3: /* Measurement duration */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004388 if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) ||
4389 ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE)))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004390 {
4391 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4392 "Invalid Measurement Duration(%d)", tempInt);
4393 return -EINVAL;
4394 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004395 pEseBcnReq->bcnReq[j].measurementDuration = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004396 break;
4397 }
4398 }
4399 }
4400
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004401 for (j = 0; j < pEseBcnReq->numBcnReqIe; j++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004402 {
4403 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304404 "Index(%d) Measurement Token(%u)Channel(%u) Scan Mode(%u) Measurement Duration(%u)\n",
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004405 j,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004406 pEseBcnReq->bcnReq[j].measurementToken,
4407 pEseBcnReq->bcnReq[j].channel,
4408 pEseBcnReq->bcnReq[j].scanMode,
4409 pEseBcnReq->bcnReq[j].measurementDuration);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004410 }
4411
4412 return VOS_STATUS_SUCCESS;
4413}
4414
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004415static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext )
4416{
4417 struct statsContext *pStatsContext = NULL;
4418 hdd_adapter_t *pAdapter = NULL;
4419
4420 if (NULL == pContext)
4421 {
4422 hddLog(VOS_TRACE_LEVEL_ERROR,
4423 "%s: Bad param, pContext [%p]",
4424 __func__, pContext);
4425 return;
4426 }
4427
Jeff Johnson72a40512013-12-19 10:14:15 -08004428 /* there is a race condition that exists between this callback
4429 function and the caller since the caller could time out either
4430 before or while this code is executing. we use a spinlock to
4431 serialize these actions */
4432 spin_lock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004433
4434 pStatsContext = pContext;
4435 pAdapter = pStatsContext->pAdapter;
4436 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
4437 {
4438 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08004439 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004440 hddLog(VOS_TRACE_LEVEL_WARN,
4441 "%s: Invalid context, pAdapter [%p] magic [%08x]",
4442 __func__, pAdapter, pStatsContext->magic);
4443 return;
4444 }
4445
Jeff Johnson72a40512013-12-19 10:14:15 -08004446 /* context is valid so caller is still waiting */
4447
4448 /* paranoia: invalidate the magic */
4449 pStatsContext->magic = 0;
4450
4451 /* copy over the tsm stats */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004452 pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly;
4453 vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist,
4454 tsmMetrics.UplinkPktQueueDlyHist,
4455 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4456 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4457 pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly;
4458 pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss;
4459 pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount;
4460 pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount;
4461 pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly;
4462
Jeff Johnson72a40512013-12-19 10:14:15 -08004463 /* notify the caller */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004464 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08004465
4466 /* serialization is complete */
4467 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004468}
4469
4470
4471
4472static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
4473 tAniTrafStrmMetrics* pTsmMetrics)
4474{
4475 hdd_station_ctx_t *pHddStaCtx = NULL;
4476 eHalStatus hstatus;
Jeff Johnson72a40512013-12-19 10:14:15 -08004477 VOS_STATUS vstatus = VOS_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004478 long lrc;
4479 struct statsContext context;
4480 hdd_context_t *pHddCtx = NULL;
4481
4482 if (NULL == pAdapter)
4483 {
4484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__);
4485 return VOS_STATUS_E_FAULT;
4486 }
4487
4488 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4489 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4490
4491 /* we are connected prepare our callback context */
4492 init_completion(&context.completion);
4493 context.pAdapter = pAdapter;
4494 context.magic = STATS_CONTEXT_MAGIC;
4495
4496 /* query tsm stats */
4497 hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB,
4498 pHddStaCtx->conn_info.staId[ 0 ],
4499 pHddStaCtx->conn_info.bssId,
4500 &context, pHddCtx->pvosContext, tid);
4501
4502 if (eHAL_STATUS_SUCCESS != hstatus)
4503 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004504 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics",
4505 __func__);
4506 vstatus = VOS_STATUS_E_FAULT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004507 }
4508 else
4509 {
4510 /* request was sent -- wait for the response */
4511 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4512 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004513 if (lrc <= 0)
4514 {
4515 hddLog(VOS_TRACE_LEVEL_ERROR,
4516 "%s: SME %s while retrieving statistics",
4517 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson72a40512013-12-19 10:14:15 -08004518 vstatus = VOS_STATUS_E_TIMEOUT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004519 }
4520 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004521
Jeff Johnson72a40512013-12-19 10:14:15 -08004522 /* either we never sent a request, we sent a request and received a
4523 response or we sent a request and timed out. if we never sent a
4524 request or if we sent a request and got a response, we want to
4525 clear the magic out of paranoia. if we timed out there is a
4526 race condition such that the callback function could be
4527 executing at the same time we are. of primary concern is if the
4528 callback function had already verified the "magic" but had not
4529 yet set the completion variable when a timeout occurred. we
4530 serialize these activities by invalidating the magic while
4531 holding a shared spinlock which will cause us to block if the
4532 callback is currently executing */
4533 spin_lock(&hdd_context_lock);
4534 context.magic = 0;
4535 spin_unlock(&hdd_context_lock);
4536
4537 if (VOS_STATUS_SUCCESS == vstatus)
4538 {
4539 pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly;
4540 vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist,
4541 pAdapter->tsmStats.UplinkPktQueueDlyHist,
4542 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4543 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4544 pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly;
4545 pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss;
4546 pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount;
4547 pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount;
4548 pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly;
4549 }
4550 return vstatus;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004551}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004552#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004553
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004554#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08004555void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand)
4556{
4557 eCsrBand band = -1;
4558 sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band);
4559 switch (band)
4560 {
4561 case eCSR_BAND_ALL:
4562 *pBand = WLAN_HDD_UI_BAND_AUTO;
4563 break;
4564
4565 case eCSR_BAND_24:
4566 *pBand = WLAN_HDD_UI_BAND_2_4_GHZ;
4567 break;
4568
4569 case eCSR_BAND_5G:
4570 *pBand = WLAN_HDD_UI_BAND_5_GHZ;
4571 break;
4572
4573 default:
4574 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band);
4575 *pBand = -1;
4576 break;
4577 }
4578}
4579
4580/**---------------------------------------------------------------------------
4581
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004582 \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data
4583
4584 This function parses the send action frame data passed in the format
4585 SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data>
4586
Srinivas Girigowda56076852013-08-20 14:00:50 -07004587 \param - pValue Pointer to input data
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004588 \param - pTargetApBssid Pointer to target Ap bssid
4589 \param - pChannel Pointer to the Target AP channel
4590 \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame
4591 \param - pBuf Pointer to data
4592 \param - pBufLen Pointer to data length
4593
4594 \return - 0 for success non-zero for failure
4595
4596 --------------------------------------------------------------------------*/
4597VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel,
4598 tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen)
4599{
4600 tANI_U8 *inPtr = pValue;
4601 tANI_U8 *dataEnd;
4602 int tempInt;
4603 int j = 0;
4604 int i = 0;
4605 int v = 0;
4606 tANI_U8 tempBuf[32];
4607 tANI_U8 tempByte = 0;
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004608 /* 12 hexa decimal digits, 5 ':' and '\0' */
4609 tANI_U8 macAddress[18];
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004610
4611 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4612 /*no argument after the command*/
4613 if (NULL == inPtr)
4614 {
4615 return -EINVAL;
4616 }
4617
4618 /*no space after the command*/
4619 else if (SPACE_ASCII_VALUE != *inPtr)
4620 {
4621 return -EINVAL;
4622 }
4623
4624 /*removing empty spaces*/
4625 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4626
4627 /*no argument followed by spaces*/
4628 if ('\0' == *inPtr)
4629 {
4630 return -EINVAL;
4631 }
4632
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004633 v = sscanf(inPtr, "%17s", macAddress);
4634 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004635 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4637 "Invalid MAC address or All hex inputs are not read (%d)", v);
4638 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004639 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004640
4641 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
4642 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
4643 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
4644 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
4645 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
4646 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004647
4648 /* point to the next argument */
4649 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4650 /*no argument after the command*/
4651 if (NULL == inPtr) return -EINVAL;
4652
4653 /*removing empty spaces*/
4654 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4655
4656 /*no argument followed by spaces*/
4657 if ('\0' == *inPtr)
4658 {
4659 return -EINVAL;
4660 }
4661
4662 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004663 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004664 if (1 != v) return -EINVAL;
4665
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004666 v = kstrtos32(tempBuf, 10, &tempInt);
Agarwal Ashish353b3a82014-04-08 14:55:11 +05304667 if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX )
Kiet Lambe150c22013-11-21 16:30:32 +05304668 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004669
4670 *pChannel = tempInt;
4671
4672 /* point to the next argument */
4673 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4674 /*no argument after the command*/
4675 if (NULL == inPtr) return -EINVAL;
4676 /*removing empty spaces*/
4677 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4678
4679 /*no argument followed by spaces*/
4680 if ('\0' == *inPtr)
4681 {
4682 return -EINVAL;
4683 }
4684
4685 /*getting the next argument ie the dwell time */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004686 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004687 if (1 != v) return -EINVAL;
4688
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004689 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda5a6e0672014-01-09 14:42:57 -08004690 if ( v < 0 || tempInt < 0) return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004691
4692 *pDwellTime = tempInt;
4693
4694 /* point to the next argument */
4695 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4696 /*no argument after the command*/
4697 if (NULL == inPtr) return -EINVAL;
4698 /*removing empty spaces*/
4699 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4700
4701 /*no argument followed by spaces*/
4702 if ('\0' == *inPtr)
4703 {
4704 return -EINVAL;
4705 }
4706
4707 /* find the length of data */
4708 dataEnd = inPtr;
4709 while(('\0' != *dataEnd) )
4710 {
4711 dataEnd++;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004712 }
Kiet Lambe150c22013-11-21 16:30:32 +05304713 *pBufLen = dataEnd - inPtr ;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004714 if ( *pBufLen <= 0) return -EINVAL;
4715
Srinivas Girigowdab5ae85d2013-06-03 10:51:45 -07004716 /* Allocate the number of bytes based on the number of input characters
4717 whether it is even or odd.
4718 if the number of input characters are even, then we need N/2 byte.
4719 if the number of input characters are odd, then we need do (N+1)/2 to
4720 compensate rounding off.
4721 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
4722 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
4723 *pBuf = vos_mem_malloc((*pBufLen + 1)/2);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004724 if (NULL == *pBuf)
4725 {
4726 hddLog(VOS_TRACE_LEVEL_FATAL,
4727 "%s: vos_mem_alloc failed ", __func__);
4728 return -EINVAL;
4729 }
4730
4731 /* the buffer received from the upper layer is character buffer,
4732 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
4733 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
4734 and f0 in 3rd location */
4735 for (i = 0, j = 0; j < *pBufLen; j += 2)
4736 {
Kiet Lambe150c22013-11-21 16:30:32 +05304737 if( j+1 == *pBufLen)
4738 {
4739 tempByte = hdd_parse_hex(inPtr[j]);
4740 }
4741 else
4742 {
4743 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
4744 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004745 (*pBuf)[i++] = tempByte;
4746 }
4747 *pBufLen = i;
4748 return VOS_STATUS_SUCCESS;
4749}
4750
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004751/**---------------------------------------------------------------------------
4752
Srinivas Girigowdade697412013-02-14 16:31:48 -08004753 \brief hdd_parse_channellist() - HDD Parse channel list
4754
4755 This function parses the channel list passed in the format
4756 SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07004757 if the Number of channels (N) does not match with the actual number of channels passed
4758 then take the minimum of N and count of (Ch1, Ch2, ...Ch M)
4759 For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken.
4760 If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48.
4761 This function does not take care of removing duplicate channels from the list
Srinivas Girigowdade697412013-02-14 16:31:48 -08004762
4763 \param - pValue Pointer to input channel list
4764 \param - ChannelList Pointer to local output array to record channel list
4765 \param - pNumChannels Pointer to number of roam scan channels
4766
4767 \return - 0 for success non-zero for failure
4768
4769 --------------------------------------------------------------------------*/
4770VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels)
4771{
4772 tANI_U8 *inPtr = pValue;
4773 int tempInt;
4774 int j = 0;
4775 int v = 0;
4776 char buf[32];
4777
4778 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4779 /*no argument after the command*/
4780 if (NULL == inPtr)
4781 {
4782 return -EINVAL;
4783 }
4784
4785 /*no space after the command*/
4786 else if (SPACE_ASCII_VALUE != *inPtr)
4787 {
4788 return -EINVAL;
4789 }
4790
4791 /*removing empty spaces*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004792 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004793
4794 /*no argument followed by spaces*/
4795 if ('\0' == *inPtr)
4796 {
4797 return -EINVAL;
4798 }
4799
4800 /*getting the first argument ie the number of channels*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004801 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004802 if (1 != v) return -EINVAL;
4803
Srinivas Girigowdade697412013-02-14 16:31:48 -08004804 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004805 if ((v < 0) ||
4806 (tempInt <= 0) ||
4807 (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN))
4808 {
4809 return -EINVAL;
4810 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004811
4812 *pNumChannels = tempInt;
4813
4814 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
4815 "Number of channels are: %d", *pNumChannels);
4816
4817 for (j = 0; j < (*pNumChannels); j++)
4818 {
4819 /*inPtr pointing to the beginning of first space after number of channels*/
4820 inPtr = strpbrk( inPtr, " " );
4821 /*no channel list after the number of channels argument*/
4822 if (NULL == inPtr)
4823 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07004824 if (0 != j)
4825 {
4826 *pNumChannels = j;
4827 return VOS_STATUS_SUCCESS;
4828 }
4829 else
4830 {
4831 return -EINVAL;
4832 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004833 }
4834
4835 /*removing empty space*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004836 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004837
4838 /*no channel list after the number of channels argument and spaces*/
4839 if ( '\0' == *inPtr )
4840 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07004841 if (0 != j)
4842 {
4843 *pNumChannels = j;
4844 return VOS_STATUS_SUCCESS;
4845 }
4846 else
4847 {
4848 return -EINVAL;
4849 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004850 }
4851
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004852 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004853 if (1 != v) return -EINVAL;
4854
Srinivas Girigowdade697412013-02-14 16:31:48 -08004855 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07004856 if ((v < 0) ||
4857 (tempInt <= 0) ||
4858 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4859 {
4860 return -EINVAL;
4861 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08004862 pChannelList[j] = tempInt;
4863
4864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
4865 "Channel %d added to preferred channel list",
4866 pChannelList[j] );
4867 }
4868
Srinivas Girigowdade697412013-02-14 16:31:48 -08004869 return VOS_STATUS_SUCCESS;
4870}
4871
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004872
4873/**---------------------------------------------------------------------------
4874
4875 \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data
4876
4877 This function parses the reasoc command data passed in the format
4878 REASSOC<space><bssid><space><channel>
4879
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004880 \param - pValue Pointer to input data (its a NUL terminated string)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004881 \param - pTargetApBssid Pointer to target Ap bssid
4882 \param - pChannel Pointer to the Target AP channel
4883
4884 \return - 0 for success non-zero for failure
4885
4886 --------------------------------------------------------------------------*/
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004887VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
4888 tANI_U8 *pTargetApBssid, tANI_U8 *pChannel)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004889{
4890 tANI_U8 *inPtr = pValue;
4891 int tempInt;
4892 int v = 0;
4893 tANI_U8 tempBuf[32];
Kiet Lamaa8e15a2014-02-11 23:30:06 -08004894 /* 12 hexa decimal digits, 5 ':' and '\0' */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004895 tANI_U8 macAddress[18];
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004896
4897 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4898 /*no argument after the command*/
4899 if (NULL == inPtr)
4900 {
4901 return -EINVAL;
4902 }
4903
4904 /*no space after the command*/
4905 else if (SPACE_ASCII_VALUE != *inPtr)
4906 {
4907 return -EINVAL;
4908 }
4909
4910 /*removing empty spaces*/
4911 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4912
4913 /*no argument followed by spaces*/
4914 if ('\0' == *inPtr)
4915 {
4916 return -EINVAL;
4917 }
4918
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004919 v = sscanf(inPtr, "%17s", macAddress);
4920 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004921 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4923 "Invalid MAC address or All hex inputs are not read (%d)", v);
4924 return -EINVAL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004925 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004926
4927 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
4928 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
4929 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
4930 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
4931 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
4932 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004933
4934 /* point to the next argument */
4935 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4936 /*no argument after the command*/
4937 if (NULL == inPtr) return -EINVAL;
4938
4939 /*removing empty spaces*/
4940 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4941
4942 /*no argument followed by spaces*/
4943 if ('\0' == *inPtr)
4944 {
4945 return -EINVAL;
4946 }
4947
4948 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004949 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004950 if (1 != v) return -EINVAL;
4951
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004952 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004953 if ((v < 0) ||
4954 (tempInt <= 0) ||
4955 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4956 {
4957 return -EINVAL;
4958 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07004959
4960 *pChannel = tempInt;
4961 return VOS_STATUS_SUCCESS;
4962}
4963
4964#endif
4965
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004966#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004967/**---------------------------------------------------------------------------
4968
4969 \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE
4970
4971 This function parses the SETCCKM IE command
4972 SETCCKMIE<space><ie data>
4973
4974 \param - pValue Pointer to input data
4975 \param - pCckmIe Pointer to output cckm Ie
4976 \param - pCckmIeLen Pointer to output cckm ie length
4977
4978 \return - 0 for success non-zero for failure
4979
4980 --------------------------------------------------------------------------*/
4981VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe,
4982 tANI_U8 *pCckmIeLen)
4983{
4984 tANI_U8 *inPtr = pValue;
4985 tANI_U8 *dataEnd;
4986 int j = 0;
4987 int i = 0;
4988 tANI_U8 tempByte = 0;
4989
4990 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4991 /*no argument after the command*/
4992 if (NULL == inPtr)
4993 {
4994 return -EINVAL;
4995 }
4996
4997 /*no space after the command*/
4998 else if (SPACE_ASCII_VALUE != *inPtr)
4999 {
5000 return -EINVAL;
5001 }
5002
5003 /*removing empty spaces*/
5004 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5005
5006 /*no argument followed by spaces*/
5007 if ('\0' == *inPtr)
5008 {
5009 return -EINVAL;
5010 }
5011
5012 /* find the length of data */
5013 dataEnd = inPtr;
5014 while(('\0' != *dataEnd) )
5015 {
5016 dataEnd++;
5017 ++(*pCckmIeLen);
5018 }
5019 if ( *pCckmIeLen <= 0) return -EINVAL;
5020
5021 /* Allocate the number of bytes based on the number of input characters
5022 whether it is even or odd.
5023 if the number of input characters are even, then we need N/2 byte.
5024 if the number of input characters are odd, then we need do (N+1)/2 to
5025 compensate rounding off.
5026 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
5027 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
5028 *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2);
5029 if (NULL == *pCckmIe)
5030 {
5031 hddLog(VOS_TRACE_LEVEL_FATAL,
5032 "%s: vos_mem_alloc failed ", __func__);
5033 return -EINVAL;
5034 }
5035 vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2);
5036 /* the buffer received from the upper layer is character buffer,
5037 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
5038 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
5039 and f0 in 3rd location */
5040 for (i = 0, j = 0; j < *pCckmIeLen; j += 2)
5041 {
5042 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
5043 (*pCckmIe)[i++] = tempByte;
5044 }
5045 *pCckmIeLen = i;
5046
5047 return VOS_STATUS_SUCCESS;
5048}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005049#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005050
Jeff Johnson295189b2012-06-20 16:38:30 -07005051/**---------------------------------------------------------------------------
5052
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005053 \brief hdd_is_valid_mac_address() - Validate MAC address
5054
5055 This function validates whether the given MAC address is valid or not
5056 Expected MAC address is of the format XX:XX:XX:XX:XX:XX
5057 where X is the hexa decimal digit character and separated by ':'
5058 This algorithm works even if MAC address is not separated by ':'
5059
5060 This code checks given input string mac contains exactly 12 hexadecimal digits.
5061 and a separator colon : appears in the input string only after
5062 an even number of hex digits.
5063
5064 \param - pMacAddr pointer to the input MAC address
5065 \return - 1 for valid and 0 for invalid
5066
5067 --------------------------------------------------------------------------*/
5068
5069v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr)
5070{
5071 int xdigit = 0;
5072 int separator = 0;
5073 while (*pMacAddr)
5074 {
5075 if (isxdigit(*pMacAddr))
5076 {
5077 xdigit++;
5078 }
5079 else if (':' == *pMacAddr)
5080 {
5081 if (0 == xdigit || ((xdigit / 2) - 1) != separator)
5082 break;
5083
5084 ++separator;
5085 }
5086 else
5087 {
5088 separator = -1;
5089 /* Invalid MAC found */
5090 return 0;
5091 }
5092 ++pMacAddr;
5093 }
5094 return (xdigit == 12 && (separator == 5 || separator == 0));
5095}
5096
5097/**---------------------------------------------------------------------------
5098
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305099 \brief __hdd_open() - HDD Open function
Jeff Johnson295189b2012-06-20 16:38:30 -07005100
5101 \param - dev Pointer to net_device structure
5102
5103 \return - 0 for success non-zero for failure
5104
5105 --------------------------------------------------------------------------*/
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305106int __hdd_open(struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005107{
5108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5109 hdd_context_t *pHddCtx;
5110 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5111 VOS_STATUS status;
5112 v_BOOL_t in_standby = TRUE;
5113
5114 if (NULL == pAdapter)
5115 {
5116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05305117 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 return -ENODEV;
5119 }
5120
5121 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305122 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST,
5123 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 if (NULL == pHddCtx)
5125 {
5126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005127 "%s: HDD context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 return -ENODEV;
5129 }
5130
5131 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5132 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
5133 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005134 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
5135 {
5136 hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby",
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305137 __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005138 in_standby = FALSE;
5139 break;
5140 }
5141 else
5142 {
5143 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5144 pAdapterNode = pNext;
5145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 }
5147
5148 if (TRUE == in_standby)
5149 {
5150 if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter))
5151 {
5152 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring "
5153 "wlan out of power save", __func__);
5154 return -EINVAL;
5155 }
5156 }
5157
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005158 set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5160 {
5161 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005162 "%s: Enabling Tx Queues", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 /* Enable TX queues only when we are connected */
5164 netif_tx_start_all_queues(dev);
5165 }
5166
5167 return 0;
5168}
5169
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305170/**---------------------------------------------------------------------------
5171
5172 \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR
5173
5174 This is called in response to ifconfig up
5175
5176 \param - dev Pointer to net_device structure
5177
5178 \return - 0 for success non-zero for failure
5179
5180 --------------------------------------------------------------------------*/
5181int hdd_open(struct net_device *dev)
5182{
5183 int ret;
5184
5185 vos_ssr_protect(__func__);
5186 ret = __hdd_open(dev);
5187 vos_ssr_unprotect(__func__);
5188
5189 return ret;
5190}
5191
Jeff Johnson295189b2012-06-20 16:38:30 -07005192int hdd_mon_open (struct net_device *dev)
5193{
5194 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5195
5196 if(pAdapter == NULL) {
5197 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005198 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005199 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 }
5201
5202 netif_start_queue(dev);
5203
5204 return 0;
5205}
5206/**---------------------------------------------------------------------------
5207
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305208 \brief __hdd_stop() - HDD stop function
Jeff Johnson295189b2012-06-20 16:38:30 -07005209
5210 \param - dev Pointer to net_device structure
5211
5212 \return - 0 for success non-zero for failure
5213
5214 --------------------------------------------------------------------------*/
5215
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305216int __hdd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005217{
5218 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5219 hdd_context_t *pHddCtx;
5220 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5221 VOS_STATUS status;
5222 v_BOOL_t enter_standby = TRUE;
5223
5224 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 if (NULL == pAdapter)
5226 {
5227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05305228 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 return -ENODEV;
5230 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305231 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST,
5232 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
5234 if (NULL == pHddCtx)
5235 {
5236 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005237 "%s: HDD context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 return -ENODEV;
5239 }
5240
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305241 /* Nothing to be done if the interface is not opened */
5242 if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags))
5243 {
5244 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5245 "%s: NETDEV Interface is not OPENED", __func__);
5246 return -ENODEV;
5247 }
5248
5249 /* Make sure the interface is marked as closed */
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005250 clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__);
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305252
5253 /* Disable TX on the interface, after this hard_start_xmit() will not
5254 * be called on that interface
5255 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 netif_tx_disable(pAdapter->dev);
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305257
5258 /* Mark the interface status as "down" for outside world */
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 netif_carrier_off(pAdapter->dev);
5260
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305261 /* The interface is marked as down for outside world (aka kernel)
5262 * But the driver is pretty much alive inside. The driver needs to
5263 * tear down the existing connection on the netdev (session)
5264 * cleanup the data pipes and wait until the control plane is stabilized
5265 * for this interface. The call also needs to wait until the above
5266 * mentioned actions are completed before returning to the caller.
5267 * Notice that the hdd_stop_adapter is requested not to close the session
5268 * That is intentional to be able to scan if it is a STA/P2P interface
5269 */
5270 hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005271
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305272 /* DeInit the adapter. This ensures datapath cleanup as well */
5273 hdd_deinit_adapter(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 /* SoftAP ifaces should never go in power save mode
5275 making sure same here. */
5276 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode )
5277 || (WLAN_HDD_MONITOR == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 || (WLAN_HDD_P2P_GO == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 )
5280 {
5281 /* SoftAP mode, so return from here */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5283 "%s: In SAP MODE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 EXIT();
5285 return 0;
5286 }
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305287 /* Find if any iface is up. If any iface is up then can't put device to
5288 * sleep/power save mode
5289 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5291 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
5292 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005293 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
5294 {
5295 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305296 "put device to sleep", __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005297 enter_standby = FALSE;
5298 break;
5299 }
5300 else
5301 {
5302 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5303 pAdapterNode = pNext;
5304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 }
5306
5307 if (TRUE == enter_standby)
5308 {
5309 hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down "
5310 "entering standby", __func__);
5311 if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx))
5312 {
5313 /*log and return success*/
5314 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put "
5315 "wlan in power save", __func__);
5316 }
5317 }
5318
5319 EXIT();
5320 return 0;
5321}
5322
5323/**---------------------------------------------------------------------------
5324
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305325 \brief hdd_stop() - wrapper_function for __hdd_stop to protect it from SSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005326
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305327 This is called in response to ifconfig down
5328
5329 \param - dev Pointer to net_device structure
5330
5331 \return - 0 for success non-zero for failure
5332-----------------------------------------------------------------------------*/
5333int hdd_stop (struct net_device *dev)
5334{
5335 int ret;
5336
5337 vos_ssr_protect(__func__);
5338 ret = __hdd_stop(dev);
5339 vos_ssr_unprotect(__func__);
5340
5341 return ret;
5342}
5343
5344/**---------------------------------------------------------------------------
5345
5346 \brief __hdd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -07005347
5348 \param - dev Pointer to net_device structure
5349
5350 \return - void
5351
5352 --------------------------------------------------------------------------*/
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305353static void __hdd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005354{
5355 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5356
5357 ENTER();
5358
5359 do
5360 {
5361 if (NULL == pAdapter)
5362 {
5363 hddLog(VOS_TRACE_LEVEL_FATAL,
5364 "%s: NULL pAdapter", __func__);
5365 break;
5366 }
5367
5368 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5369 {
5370 hddLog(VOS_TRACE_LEVEL_FATAL,
5371 "%s: Invalid magic", __func__);
5372 break;
5373 }
5374
5375 if (NULL == pAdapter->pHddCtx)
5376 {
5377 hddLog(VOS_TRACE_LEVEL_FATAL,
5378 "%s: NULL pHddCtx", __func__);
5379 break;
5380 }
5381
5382 if (dev != pAdapter->dev)
5383 {
5384 hddLog(VOS_TRACE_LEVEL_FATAL,
5385 "%s: Invalid device reference", __func__);
5386 /* we haven't validated all cases so let this go for now */
5387 }
5388
5389 hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter);
5390
5391 /* after uninit our adapter structure will no longer be valid */
5392 pAdapter->dev = NULL;
5393 pAdapter->magic = 0;
5394 } while (0);
5395
5396 EXIT();
5397}
5398
5399/**---------------------------------------------------------------------------
5400
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305401 \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR
5402
5403 This is called during the netdev unregister to uninitialize all data
5404associated with the device
5405
5406 \param - dev Pointer to net_device structure
5407
5408 \return - void
5409
5410 --------------------------------------------------------------------------*/
5411static void hdd_uninit (struct net_device *dev)
5412{
5413 vos_ssr_protect(__func__);
5414 __hdd_uninit(dev);
5415 vos_ssr_unprotect(__func__);
5416}
5417
5418/**---------------------------------------------------------------------------
5419
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 \brief hdd_release_firmware() -
5421
5422 This function calls the release firmware API to free the firmware buffer.
5423
5424 \param - pFileName Pointer to the File Name.
5425 pCtx - Pointer to the adapter .
5426
5427
5428 \return - 0 for success, non zero for failure
5429
5430 --------------------------------------------------------------------------*/
5431
5432VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx)
5433{
5434 VOS_STATUS status = VOS_STATUS_SUCCESS;
5435 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5436 ENTER();
5437
5438
5439 if (!strcmp(WLAN_FW_FILE, pFileName)) {
5440
5441 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName);
5442
5443 if(pHddCtx->fw) {
5444 release_firmware(pHddCtx->fw);
5445 pHddCtx->fw = NULL;
5446 }
5447 else
5448 status = VOS_STATUS_E_FAILURE;
5449 }
5450 else if (!strcmp(WLAN_NV_FILE,pFileName)) {
5451 if(pHddCtx->nv) {
5452 release_firmware(pHddCtx->nv);
5453 pHddCtx->nv = NULL;
5454 }
5455 else
5456 status = VOS_STATUS_E_FAILURE;
5457
5458 }
5459
5460 EXIT();
5461 return status;
5462}
5463
5464/**---------------------------------------------------------------------------
5465
5466 \brief hdd_request_firmware() -
5467
5468 This function reads the firmware file using the request firmware
5469 API and returns the the firmware data and the firmware file size.
5470
5471 \param - pfileName - Pointer to the file name.
5472 - pCtx - Pointer to the adapter .
5473 - ppfw_data - Pointer to the pointer of the firmware data.
5474 - pSize - Pointer to the file size.
5475
5476 \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure
5477
5478 --------------------------------------------------------------------------*/
5479
5480
5481VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize)
5482{
5483 int status;
5484 VOS_STATUS retval = VOS_STATUS_SUCCESS;
5485 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5486 ENTER();
5487
5488 if( (!strcmp(WLAN_FW_FILE, pfileName)) ) {
5489
5490 status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev);
5491
5492 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5493 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed",
5494 __func__, pfileName);
5495 retval = VOS_STATUS_E_FAILURE;
5496 }
5497
5498 else {
5499 *ppfw_data = (v_VOID_t *)pHddCtx->fw->data;
5500 *pSize = pHddCtx->fw->size;
5501 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d",
5502 __func__, *pSize);
5503 }
5504 }
5505 else if(!strcmp(WLAN_NV_FILE, pfileName)) {
5506
5507 status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev);
5508
5509 if(status || !pHddCtx->nv || !pHddCtx->nv->data) {
5510 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed",
5511 __func__, pfileName);
5512 retval = VOS_STATUS_E_FAILURE;
5513 }
5514
5515 else {
5516 *ppfw_data = (v_VOID_t *)pHddCtx->nv->data;
5517 *pSize = pHddCtx->nv->size;
5518 hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d",
5519 __func__, *pSize);
5520 }
5521 }
5522
5523 EXIT();
5524 return retval;
5525}
5526/**---------------------------------------------------------------------------
5527 \brief hdd_full_pwr_cbk() - HDD full power callbackfunction
5528
5529 This is the function invoked by SME to inform the result of a full power
5530 request issued by HDD
5531
5532 \param - callbackcontext - Pointer to cookie
5533 status - result of request
5534
5535 \return - None
5536
5537--------------------------------------------------------------------------*/
5538void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status)
5539{
5540 hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext;
5541
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005542 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"HDD full Power callback status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 if(&pHddCtx->full_pwr_comp_var)
5544 {
5545 complete(&pHddCtx->full_pwr_comp_var);
5546 }
5547}
5548
5549/**---------------------------------------------------------------------------
5550
5551 \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function
5552
5553 This is the function invoked by SME to inform the result of BMPS
5554 request issued by HDD
5555
5556 \param - callbackcontext - Pointer to cookie
5557 status - result of request
5558
5559 \return - None
5560
5561--------------------------------------------------------------------------*/
5562void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status)
5563{
5564
5565 struct completion *completion_var = (struct completion*) callbackContext;
5566
Arif Hussain6d2a3322013-11-17 19:50:10 -08005567 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 if(completion_var != NULL)
5569 {
5570 complete(completion_var);
5571 }
5572}
5573
5574/**---------------------------------------------------------------------------
5575
5576 \brief hdd_get_cfg_file_size() -
5577
5578 This function reads the configuration file using the request firmware
5579 API and returns the configuration file size.
5580
5581 \param - pCtx - Pointer to the adapter .
5582 - pFileName - Pointer to the file name.
5583 - pBufSize - Pointer to the buffer size.
5584
5585 \return - 0 for success, non zero for failure
5586
5587 --------------------------------------------------------------------------*/
5588
5589VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize)
5590{
5591 int status;
5592 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5593
5594 ENTER();
5595
5596 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5597
5598 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5599 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5600 status = VOS_STATUS_E_FAILURE;
5601 }
5602 else {
5603 *pBufSize = pHddCtx->fw->size;
5604 hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize);
5605 release_firmware(pHddCtx->fw);
5606 pHddCtx->fw = NULL;
5607 }
5608
5609 EXIT();
5610 return VOS_STATUS_SUCCESS;
5611}
5612
5613/**---------------------------------------------------------------------------
5614
5615 \brief hdd_read_cfg_file() -
5616
5617 This function reads the configuration file using the request firmware
5618 API and returns the cfg data and the buffer size of the configuration file.
5619
5620 \param - pCtx - Pointer to the adapter .
5621 - pFileName - Pointer to the file name.
5622 - pBuffer - Pointer to the data buffer.
5623 - pBufSize - Pointer to the buffer size.
5624
5625 \return - 0 for success, non zero for failure
5626
5627 --------------------------------------------------------------------------*/
5628
5629VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName,
5630 v_VOID_t *pBuffer, v_SIZE_t *pBufSize)
5631{
5632 int status;
5633 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5634
5635 ENTER();
5636
5637 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5638
5639 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5640 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5641 return VOS_STATUS_E_FAILURE;
5642 }
5643 else {
5644 if(*pBufSize != pHddCtx->fw->size) {
5645 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG "
5646 "file size", __func__);
5647 release_firmware(pHddCtx->fw);
5648 pHddCtx->fw = NULL;
5649 return VOS_STATUS_E_FAILURE;
5650 }
5651 else {
5652 if(pBuffer) {
5653 vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize);
5654 }
5655 release_firmware(pHddCtx->fw);
5656 pHddCtx->fw = NULL;
5657 }
5658 }
5659
5660 EXIT();
5661
5662 return VOS_STATUS_SUCCESS;
5663}
5664
5665/**---------------------------------------------------------------------------
5666
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305667 \brief __hdd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005668
5669 This function sets the user specified mac address using
5670 the command ifconfig wlanX hw ether <mac adress>.
5671
5672 \param - dev - Pointer to the net device.
5673 - addr - Pointer to the sockaddr.
5674 \return - 0 for success, non zero for failure
5675
5676 --------------------------------------------------------------------------*/
5677
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305678static int __hdd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -07005679{
5680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5681 struct sockaddr *psta_mac_addr = addr;
5682 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5683
5684 ENTER();
5685
5686 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
5688
5689 EXIT();
5690 return halStatus;
5691}
5692
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305693/**---------------------------------------------------------------------------
5694
5695 \brief hdd_set_mac_address() -
5696
5697 Wrapper function to protect __hdd_set_mac_address() function from ssr
5698
5699 \param - dev - Pointer to the net device.
5700 - addr - Pointer to the sockaddr.
5701 \return - 0 for success, non zero for failure
5702
5703 --------------------------------------------------------------------------*/
5704static int hdd_set_mac_address(struct net_device *dev, void *addr)
5705{
5706 int ret;
5707
5708 vos_ssr_protect(__func__);
5709 ret = __hdd_set_mac_address(dev, addr);
5710 vos_ssr_unprotect(__func__);
5711
5712 return ret;
5713}
5714
Jeff Johnson295189b2012-06-20 16:38:30 -07005715tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx)
5716{
5717 int i;
5718 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
5719 {
Abhishek Singheb183782014-02-06 13:37:21 +05305720 if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 break;
5722 }
5723
5724 if( VOS_MAX_CONCURRENCY_PERSONA == i)
5725 return NULL;
5726
5727 pHddCtx->cfg_ini->intfAddrMask |= (1 << i);
5728 return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0];
5729}
5730
5731void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr)
5732{
5733 int i;
5734 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
5735 {
5736 if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) )
5737 {
5738 pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i);
5739 break;
5740 }
5741 }
5742 return;
5743}
5744
5745#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
5746 static struct net_device_ops wlan_drv_ops = {
5747 .ndo_open = hdd_open,
5748 .ndo_stop = hdd_stop,
5749 .ndo_uninit = hdd_uninit,
5750 .ndo_start_xmit = hdd_hard_start_xmit,
5751 .ndo_tx_timeout = hdd_tx_timeout,
5752 .ndo_get_stats = hdd_stats,
5753 .ndo_do_ioctl = hdd_ioctl,
5754 .ndo_set_mac_address = hdd_set_mac_address,
5755 .ndo_select_queue = hdd_select_queue,
5756#ifdef WLAN_FEATURE_PACKET_FILTERING
5757#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0))
5758 .ndo_set_rx_mode = hdd_set_multicast_list,
5759#else
5760 .ndo_set_multicast_list = hdd_set_multicast_list,
5761#endif //LINUX_VERSION_CODE
5762#endif
5763 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 static struct net_device_ops wlan_mon_drv_ops = {
5765 .ndo_open = hdd_mon_open,
5766 .ndo_stop = hdd_stop,
5767 .ndo_uninit = hdd_uninit,
5768 .ndo_start_xmit = hdd_mon_hard_start_xmit,
5769 .ndo_tx_timeout = hdd_tx_timeout,
5770 .ndo_get_stats = hdd_stats,
5771 .ndo_do_ioctl = hdd_ioctl,
5772 .ndo_set_mac_address = hdd_set_mac_address,
5773 };
Jeff Johnson295189b2012-06-20 16:38:30 -07005774
5775#endif
5776
5777void hdd_set_station_ops( struct net_device *pWlanDev )
5778{
5779#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 pWlanDev->netdev_ops = &wlan_drv_ops;
5781#else
5782 pWlanDev->open = hdd_open;
5783 pWlanDev->stop = hdd_stop;
5784 pWlanDev->uninit = hdd_uninit;
5785 pWlanDev->hard_start_xmit = NULL;
5786 pWlanDev->tx_timeout = hdd_tx_timeout;
5787 pWlanDev->get_stats = hdd_stats;
5788 pWlanDev->do_ioctl = hdd_ioctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 pWlanDev->set_mac_address = hdd_set_mac_address;
5790#endif
5791}
5792
Jeff Johnsoneed415b2013-01-18 16:11:20 -08005793static hdd_adapter_t* hdd_alloc_station_adapter( hdd_context_t *pHddCtx, tSirMacAddr macAddr, const char* name )
Jeff Johnson295189b2012-06-20 16:38:30 -07005794{
5795 struct net_device *pWlanDev = NULL;
5796 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 /*
5798 * cfg80211 initialization and registration....
5799 */
5800 pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES);
5801
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 if(pWlanDev != NULL)
5803 {
5804
5805 //Save the pointer to the net_device in the HDD adapter
5806 pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev );
5807
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) );
5809
5810 pAdapter->dev = pWlanDev;
5811 pAdapter->pHddCtx = pHddCtx;
5812 pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
Agarwal Ashish47d18112014-08-04 19:55:07 +05305813 spin_lock_init(&pAdapter->lock_for_active_session);
Jeff Johnson295189b2012-06-20 16:38:30 -07005814
5815 init_completion(&pAdapter->session_open_comp_var);
5816 init_completion(&pAdapter->session_close_comp_var);
5817 init_completion(&pAdapter->disconnect_comp_var);
5818 init_completion(&pAdapter->linkup_event_var);
5819 init_completion(&pAdapter->cancel_rem_on_chan_var);
5820 init_completion(&pAdapter->rem_on_chan_ready_event);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05305821 init_completion(&pAdapter->pno_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07005822#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5823 init_completion(&pAdapter->offchannel_tx_event);
5824#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 init_completion(&pAdapter->tx_action_cnf_event);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005826#ifdef FEATURE_WLAN_TDLS
5827 init_completion(&pAdapter->tdls_add_station_comp);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07005828 init_completion(&pAdapter->tdls_del_station_comp);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08005829 init_completion(&pAdapter->tdls_mgmt_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305830 init_completion(&pAdapter->tdls_link_establish_req_comp);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005831#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 init_completion(&pHddCtx->mc_sus_event_var);
5833 init_completion(&pHddCtx->tx_sus_event_var);
Gopichand Nakkala05621412013-06-19 19:37:38 +05305834 init_completion(&pHddCtx->rx_sus_event_var);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07005835 init_completion(&pAdapter->ula_complete);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07005836 init_completion(&pAdapter->change_country_code);
Jeff Johnson295189b2012-06-20 16:38:30 -07005837
Rajeev79dbe4c2013-10-05 11:03:42 +05305838#ifdef FEATURE_WLAN_BATCH_SCAN
5839 init_completion(&pAdapter->hdd_set_batch_scan_req_var);
5840 init_completion(&pAdapter->hdd_get_batch_scan_req_var);
5841 pAdapter->pBatchScanRsp = NULL;
5842 pAdapter->numScanList = 0;
Rajeev Kumar20140c12013-10-21 19:39:02 -07005843 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08005844 pAdapter->prev_batch_id = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05305845 mutex_init(&pAdapter->hdd_batch_scan_lock);
5846#endif
5847
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 pAdapter->isLinkUpSvcNeeded = FALSE;
5849 pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE;
5850 //Init the net_device structure
5851 strlcpy(pWlanDev->name, name, IFNAMSIZ);
5852
5853 vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr));
5854 vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr));
5855 pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT;
5856 pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM;
5857
5858 hdd_set_station_ops( pAdapter->dev );
5859
5860 pWlanDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 pWlanDev->ieee80211_ptr = &pAdapter->wdev ;
5862 pAdapter->wdev.wiphy = pHddCtx->wiphy;
5863 pAdapter->wdev.netdev = pWlanDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 /* set pWlanDev's parent to underlying device */
5865 SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev);
Kumar Anand82c009f2014-05-29 00:29:42 -07005866
5867 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 }
5869
5870 return pAdapter;
5871}
5872
5873VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
5874{
5875 struct net_device *pWlanDev = pAdapter->dev;
5876 //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
5877 //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5878 //eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5879
5880 if( rtnl_lock_held )
5881 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08005882 if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 )
5884 {
5885 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__);
5886 return VOS_STATUS_E_FAILURE;
5887 }
5888 }
5889 if (register_netdevice(pWlanDev))
5890 {
5891 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__);
5892 return VOS_STATUS_E_FAILURE;
5893 }
5894 }
5895 else
5896 {
5897 if(register_netdev(pWlanDev))
5898 {
5899 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__);
5900 return VOS_STATUS_E_FAILURE;
5901 }
5902 }
5903 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
5904
5905 return VOS_STATUS_SUCCESS;
5906}
5907
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005908static eHalStatus hdd_smeCloseSessionCallback(void *pContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07005909{
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005910 hdd_adapter_t *pAdapter = pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07005911
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005912 if (NULL == pAdapter)
5913 {
5914 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__);
5915 return eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 }
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005917
5918 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5919 {
5920 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__);
5921 return eHAL_STATUS_NOT_INITIALIZED;
5922 }
5923
5924 clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
5925
Sameer Thalappilbee426e2013-10-30 10:30:30 -07005926#ifndef WLAN_OPEN_SOURCE
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005927 /* need to make sure all of our scheduled work has completed.
5928 * This callback is called from MC thread context, so it is safe to
5929 * to call below flush workqueue API from here.
Sameer Thalappilbee426e2013-10-30 10:30:30 -07005930 *
5931 * Even though this is called from MC thread context, if there is a faulty
5932 * work item in the system, that can hang this call forever. So flushing
5933 * this global work queue is not safe; and now we make sure that
5934 * individual work queues are stopped correctly. But the cancel work queue
5935 * is a GPL only API, so the proprietary version of the driver would still
5936 * rely on the global work queue flush.
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005937 */
5938 flush_scheduled_work();
Sameer Thalappilbee426e2013-10-30 10:30:30 -07005939#endif
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07005940
5941 /* We can be blocked while waiting for scheduled work to be
5942 * flushed, and the adapter structure can potentially be freed, in
5943 * which case the magic will have been reset. So make sure the
5944 * magic is still good, and hence the adapter structure is still
5945 * valid, before signaling completion */
5946 if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic)
5947 {
5948 complete(&pAdapter->session_close_comp_var);
5949 }
5950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 return eHAL_STATUS_SUCCESS;
5952}
5953
5954VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter )
5955{
5956 struct net_device *pWlanDev = pAdapter->dev;
5957 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
5958 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5959 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
5960 VOS_STATUS status = VOS_STATUS_E_FAILURE;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305961 long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005962
5963 INIT_COMPLETION(pAdapter->session_open_comp_var);
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005964 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 //Open a SME session for future operation
5966 halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005967 (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 if ( !HAL_STATUS_SUCCESS( halStatus ) )
5969 {
5970 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005971 "sme_OpenSession() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 halStatus, halStatus );
5973 status = VOS_STATUS_E_FAILURE;
5974 goto error_sme_open;
5975 }
5976
5977 //Block on a completion variable. Can't wait forever though.
Vinay Krishna Eranna0fe2e7c2014-04-09 21:32:08 +05305978 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 &pAdapter->session_open_comp_var,
5980 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305981 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 {
5983 hddLog(VOS_TRACE_LEVEL_FATAL,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305984 "Session is not opened within timeout period code %ld", rc );
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 status = VOS_STATUS_E_FAILURE;
5986 goto error_sme_open;
5987 }
5988
5989 // Register wireless extensions
5990 if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev)))
5991 {
5992 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005993 "hdd_register_wext() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 halStatus, halStatus );
5995 status = VOS_STATUS_E_FAILURE;
5996 goto error_register_wext;
5997 }
5998 //Safe to register the hard_start_xmit function again
5999#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6000 wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit;
6001#else
6002 pWlanDev->hard_start_xmit = hdd_hard_start_xmit;
6003#endif
6004
6005 //Set the Connection State to Not Connected
Abhishek Singhf4669da2014-05-26 15:07:49 +05306006 hddLog(VOS_TRACE_LEVEL_INFO,
6007 "%s: Set HDD connState to eConnectionState_NotConnected",
6008 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6010
6011 //Set the default operation channel
6012 pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel;
6013
6014 /* Make the default Auth Type as OPEN*/
6015 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6016
6017 if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) )
6018 {
6019 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006020 "hdd_init_tx_rx() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 status, status );
6022 goto error_init_txrx;
6023 }
6024
6025 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6026
6027 if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) )
6028 {
6029 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006030 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 status, status );
6032 goto error_wmm_init;
6033 }
6034
6035 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6036
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006037#ifdef FEATURE_WLAN_TDLS
Agarwal Ashish4b87f922014-06-18 03:03:21 +05306038 if(0 != wlan_hdd_sta_tdls_init(pAdapter))
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006039 {
6040 status = VOS_STATUS_E_FAILURE;
Agarwal Ashish4b87f922014-06-18 03:03:21 +05306041 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_sta_tdls_init failed",__func__);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006042 goto error_tdls_init;
6043 }
6044 set_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
6045#endif
6046
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 return VOS_STATUS_SUCCESS;
6048
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006049#ifdef FEATURE_WLAN_TDLS
6050error_tdls_init:
6051 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6052 hdd_wmm_adapter_close(pAdapter);
6053#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006054error_wmm_init:
6055 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6056 hdd_deinit_tx_rx(pAdapter);
6057error_init_txrx:
6058 hdd_UnregisterWext(pWlanDev);
6059error_register_wext:
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006060 if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 {
6062 INIT_COMPLETION(pAdapter->session_close_comp_var);
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006063 if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 pAdapter->sessionId,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006065 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306067 unsigned long rc;
6068
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306070 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 &pAdapter->session_close_comp_var,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006072 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306073 if (rc <= 0)
6074 hddLog(VOS_TRACE_LEVEL_ERROR,
6075 FL("Session is not opened within timeout period code %ld"), rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 }
6077}
6078error_sme_open:
6079 return status;
6080}
6081
Jeff Johnson295189b2012-06-20 16:38:30 -07006082void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
6083{
6084 hdd_cfg80211_state_t *cfgState;
6085
6086 cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
6087
6088 if( NULL != cfgState->buf )
6089 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306090 long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 INIT_COMPLETION(pAdapter->tx_action_cnf_event);
6092 rc = wait_for_completion_interruptible_timeout(
6093 &pAdapter->tx_action_cnf_event,
6094 msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306095 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 {
Sudhir Sattayappa Kohalli8ee532d2013-02-15 13:16:26 -08006097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306098 "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld"
6099 , __func__, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 }
6101 }
6102 return;
6103}
Jeff Johnson295189b2012-06-20 16:38:30 -07006104
6105void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
6106{
6107 ENTER();
6108 switch ( pAdapter->device_mode )
6109 {
6110 case WLAN_HDD_INFRA_STATION:
6111 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006112 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 {
6114 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6115 {
6116 hdd_deinit_tx_rx( pAdapter );
6117 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6118 }
6119
6120 if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6121 {
6122 hdd_wmm_adapter_close( pAdapter );
6123 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6124 }
6125
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006127#ifdef FEATURE_WLAN_TDLS
6128 if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags))
6129 {
6130 wlan_hdd_tdls_exit(pAdapter);
6131 clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
6132 }
6133#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006134
6135 break;
6136 }
6137
6138 case WLAN_HDD_SOFTAP:
6139 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 {
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05306141
6142 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6143 {
6144 hdd_wmm_adapter_close( pAdapter );
6145 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6146 }
6147
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006149
6150 hdd_unregister_hostapd(pAdapter);
6151 hdd_set_conparam( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 break;
6154 }
6155
6156 case WLAN_HDD_MONITOR:
6157 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6160 {
6161 hdd_deinit_tx_rx( pAdapter );
6162 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 if(NULL != pAdapterforTx)
6165 {
6166 hdd_cleanup_actionframe(pHddCtx, pAdapterforTx);
6167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 break;
6169 }
6170
6171
6172 default:
6173 break;
6174 }
6175
6176 EXIT();
6177}
6178
6179void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held )
6180{
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006181 struct net_device *pWlanDev = NULL;
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306182
6183 ENTER();
6184 if (NULL == pAdapter)
6185 {
6186 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6187 "%s: HDD adapter is Null", __func__);
6188 return;
6189 }
6190
6191 pWlanDev = pAdapter->dev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006192
Rajeev79dbe4c2013-10-05 11:03:42 +05306193#ifdef FEATURE_WLAN_BATCH_SCAN
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306194 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
6195 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Rajeev Kumarf999e582014-01-09 17:33:29 -08006196 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306197 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
6198 )
6199 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08006200 if (pAdapter)
Rajeev79dbe4c2013-10-05 11:03:42 +05306201 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08006202 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
6203 {
6204 hdd_deinit_batch_scan(pAdapter);
6205 }
Rajeev79dbe4c2013-10-05 11:03:42 +05306206 }
Rajeev Kumarf999e582014-01-09 17:33:29 -08006207 }
Rajeev79dbe4c2013-10-05 11:03:42 +05306208#endif
6209
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) {
6211 if( rtnl_held )
6212 {
6213 unregister_netdevice(pWlanDev);
6214 }
6215 else
6216 {
6217 unregister_netdev(pWlanDev);
6218 }
6219 // note that the pAdapter is no longer valid at this point
6220 // since the memory has been reclaimed
6221 }
6222
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306223 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006224}
6225
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006226void hdd_set_pwrparams(hdd_context_t *pHddCtx)
6227{
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306228 VOS_STATUS status;
6229 hdd_adapter_t *pAdapter = NULL;
6230 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006231
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306232 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006233
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306234 /*loop through all adapters.*/
6235 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006236 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306237 pAdapter = pAdapterNode->pAdapter;
6238 if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
6239 && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006240
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306241 { // we skip this registration for modes other than STA and P2P client modes.
6242 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6243 pAdapterNode = pNext;
6244 continue;
6245 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006246
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306247 //Apply Dynamic DTIM For P2P
6248 //Only if ignoreDynamicDtimInP2pMode is not set in ini
6249 if ((pHddCtx->cfg_ini->enableDynamicDTIM ||
6250 pHddCtx->cfg_ini->enableModulatedDTIM) &&
6251 ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6252 ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) &&
6253 !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) &&
6254 (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) &&
6255 (eConnectionState_Associated ==
6256 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) &&
6257 (pHddCtx->cfg_ini->fIsBmpsEnabled))
6258 {
6259 tSirSetPowerParamsReq powerRequest = { 0 };
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006260
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306261 powerRequest.uIgnoreDTIM = 1;
6262 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
6263
6264 if (pHddCtx->cfg_ini->enableModulatedDTIM)
6265 {
6266 powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM;
6267 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
6268 }
6269 else
6270 {
6271 powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM;
6272 }
6273
6274 /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM
6275 * specified during Enter/Exit BMPS when LCD off*/
6276 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
6277 NULL, eANI_BOOLEAN_FALSE);
6278 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
6279 NULL, eANI_BOOLEAN_FALSE);
6280
6281 /* switch to the DTIM specified in cfg.ini */
6282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6283 "Switch to DTIM %d", powerRequest.uListenInterval);
6284 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
6285 break;
6286
6287 }
6288
6289 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6290 pAdapterNode = pNext;
6291 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006292}
6293
6294void hdd_reset_pwrparams(hdd_context_t *pHddCtx)
6295{
6296 /*Switch back to DTIM 1*/
6297 tSirSetPowerParamsReq powerRequest = { 0 };
6298
6299 powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value;
6300 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
Yue Mac24062f2013-05-13 17:01:29 -07006301 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006302
6303 /* Update ignoreDTIM and ListedInterval in CFG with default values */
6304 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
6305 NULL, eANI_BOOLEAN_FALSE);
6306 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
6307 NULL, eANI_BOOLEAN_FALSE);
6308
6309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6310 "Switch to DTIM%d",powerRequest.uListenInterval);
6311 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
6312
6313}
6314
Jeff Johnson295189b2012-06-20 16:38:30 -07006315VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx)
6316{
6317 VOS_STATUS status = VOS_STATUS_SUCCESS;
6318
6319 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
6320 {
6321 sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
6322 }
6323
6324 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
6325 {
6326 sme_StartAutoBmpsTimer(pHddCtx->hHal);
6327 }
6328
6329 if (pHddCtx->cfg_ini->fIsImpsEnabled)
6330 {
6331 sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
6332 }
6333
6334 return status;
6335}
6336
6337VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type)
6338{
6339 hdd_adapter_t *pAdapter = NULL;
6340 eHalStatus halStatus;
6341 VOS_STATUS status = VOS_STATUS_E_INVAL;
6342 v_BOOL_t disableBmps = FALSE;
6343 v_BOOL_t disableImps = FALSE;
6344
6345 switch(session_type)
6346 {
6347 case WLAN_HDD_INFRA_STATION:
6348 case WLAN_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 case WLAN_HDD_P2P_CLIENT:
6350 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 //Exit BMPS -> Is Sta/P2P Client is already connected
6352 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6353 if((NULL != pAdapter)&&
6354 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6355 {
6356 disableBmps = TRUE;
6357 }
6358
6359 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6360 if((NULL != pAdapter)&&
6361 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6362 {
6363 disableBmps = TRUE;
6364 }
6365
6366 //Exit both Bmps and Imps incase of Go/SAP Mode
6367 if((WLAN_HDD_SOFTAP == session_type) ||
6368 (WLAN_HDD_P2P_GO == session_type))
6369 {
6370 disableBmps = TRUE;
6371 disableImps = TRUE;
6372 }
6373
6374 if(TRUE == disableImps)
6375 {
6376 if (pHddCtx->cfg_ini->fIsImpsEnabled)
6377 {
6378 sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
6379 }
6380 }
6381
6382 if(TRUE == disableBmps)
6383 {
6384 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
6385 {
6386 halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
6387
6388 if(eHAL_STATUS_SUCCESS != halStatus)
6389 {
6390 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006391 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 VOS_ASSERT(0);
6393 return status;
6394 }
6395 }
6396
6397 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
6398 {
6399 halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal);
6400
6401 if(eHAL_STATUS_SUCCESS != halStatus)
6402 {
6403 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006404 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Stop Auto Bmps Timer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 VOS_ASSERT(0);
6406 return status;
6407 }
6408 }
6409 }
6410
6411 if((TRUE == disableBmps) ||
6412 (TRUE == disableImps))
6413 {
6414 /* Now, get the chip into Full Power now */
6415 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
6416 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk,
6417 pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD);
6418
6419 if(halStatus != eHAL_STATUS_SUCCESS)
6420 {
6421 if(halStatus == eHAL_STATUS_PMC_PENDING)
6422 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306423 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 //Block on a completion variable. Can't wait forever though
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306425 ret = wait_for_completion_interruptible_timeout(
6426 &pHddCtx->full_pwr_comp_var,
6427 msecs_to_jiffies(1000));
6428 if (ret <= 0)
6429 {
6430 hddLog(VOS_TRACE_LEVEL_ERROR,
6431 "%s: wait on full_pwr_comp_var failed %ld",
6432 __func__, ret);
6433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 }
6435 else
6436 {
6437 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006438 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 VOS_ASSERT(0);
6440 return status;
6441 }
6442 }
6443
6444 status = VOS_STATUS_SUCCESS;
6445 }
6446
6447 break;
6448 }
6449 return status;
6450}
6451
6452hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type,
Jeff Johnsoneed415b2013-01-18 16:11:20 -08006453 const char *iface_name, tSirMacAddr macAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 tANI_U8 rtnl_held )
6455{
6456 hdd_adapter_t *pAdapter = NULL;
6457 hdd_adapter_list_node_t *pHddAdapterNode = NULL;
6458 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6459 VOS_STATUS exitbmpsStatus;
6460
Arif Hussain6d2a3322013-11-17 19:50:10 -08006461 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s iface =%s type = %d",__func__,iface_name,session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006462
Nirav Shah436658f2014-02-28 17:05:45 +05306463 if(macAddr == NULL)
6464 {
6465 /* Not received valid macAddr */
6466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6467 "%s:Unable to add virtual intf: Not able to get"
6468 "valid mac address",__func__);
6469 return NULL;
6470 }
6471
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 //Disable BMPS incase of Concurrency
6473 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type);
6474
6475 if(VOS_STATUS_E_FAILURE == exitbmpsStatus)
6476 {
6477 //Fail to Exit BMPS
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306478 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 VOS_ASSERT(0);
6480 return NULL;
6481 }
6482
6483 switch(session_type)
6484 {
6485 case WLAN_HDD_INFRA_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006487 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 {
6489 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6490
6491 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306492 {
6493 hddLog(VOS_TRACE_LEVEL_FATAL,
6494 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006497
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306498#ifdef FEATURE_WLAN_TDLS
6499 /* A Mutex Lock is introduced while changing/initializing the mode to
6500 * protect the concurrent access for the Adapters by TDLS module.
6501 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306502 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306503#endif
6504
Jeff Johnsone7245742012-09-05 17:12:55 -07006505 pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ?
6506 NL80211_IFTYPE_P2P_CLIENT:
6507 NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07006508
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 pAdapter->device_mode = session_type;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306510#ifdef FEATURE_WLAN_TDLS
6511 mutex_unlock(&pHddCtx->tdls_lock);
6512#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05306513
6514 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 if( VOS_STATUS_SUCCESS != status )
6516 goto err_free_netdev;
6517
6518 status = hdd_register_interface( pAdapter, rtnl_held );
6519 if( VOS_STATUS_SUCCESS != status )
6520 {
6521 hdd_deinit_adapter(pHddCtx, pAdapter);
6522 goto err_free_netdev;
6523 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306524
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306525 // Workqueue which gets scheduled in IPv4 notification callback.
6526 INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue);
6527
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306528#ifdef WLAN_NS_OFFLOAD
6529 // Workqueue which gets scheduled in IPv6 notification callback.
6530 INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue);
6531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 //Stop the Interface TX queue.
6533 netif_tx_disable(pAdapter->dev);
6534 //netif_tx_disable(pWlanDev);
6535 netif_carrier_off(pAdapter->dev);
6536
6537 break;
6538 }
6539
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 case WLAN_HDD_SOFTAP:
6542 {
6543 pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name );
6544 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306545 {
6546 hddLog(VOS_TRACE_LEVEL_FATAL,
6547 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006550
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ?
6552 NL80211_IFTYPE_AP:
6553 NL80211_IFTYPE_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 pAdapter->device_mode = session_type;
6555
6556 status = hdd_init_ap_mode(pAdapter);
6557 if( VOS_STATUS_SUCCESS != status )
6558 goto err_free_netdev;
6559
6560 status = hdd_register_hostapd( pAdapter, rtnl_held );
6561 if( VOS_STATUS_SUCCESS != status )
6562 {
6563 hdd_deinit_adapter(pHddCtx, pAdapter);
6564 goto err_free_netdev;
6565 }
6566
6567 netif_tx_disable(pAdapter->dev);
6568 netif_carrier_off(pAdapter->dev);
6569
6570 hdd_set_conparam( 1 );
6571 break;
6572 }
6573 case WLAN_HDD_MONITOR:
6574 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6576 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306577 {
6578 hddLog(VOS_TRACE_LEVEL_FATAL,
6579 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006582
6583 pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR;
6584 pAdapter->device_mode = session_type;
6585 status = hdd_register_interface( pAdapter, rtnl_held );
6586#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
6587 pAdapter->dev->netdev_ops = &wlan_mon_drv_ops;
6588#else
6589 pAdapter->dev->open = hdd_mon_open;
6590 pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit;
6591#endif
6592 hdd_init_tx_rx( pAdapter );
6593 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6594 //Set adapter to be used for data tx. It will use either GO or softap.
6595 pAdapter->sessionCtx.monitor.pAdapterForTx =
6596 hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx)
6598 {
6599 pAdapter->sessionCtx.monitor.pAdapterForTx =
6600 hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO);
6601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 /* This workqueue will be used to transmit management packet over
6603 * monitor interface. */
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006604 if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) {
6605 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__);
6606 return NULL;
6607 }
Madan Mohan Koyyalamudi9f40ceb2012-10-18 19:22:56 -07006608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue,
6610 hdd_mon_tx_work_queue);
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 }
6612 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 case WLAN_HDD_FTM:
6614 {
6615 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6616
6617 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306618 {
6619 hddLog(VOS_TRACE_LEVEL_FATAL,
6620 FL("failed to allocate adapter for session %d"), session_type);
6621 return NULL;
6622 }
6623
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning
6625 * message while loading driver in FTM mode. */
6626 pAdapter->wdev.iftype = NL80211_IFTYPE_STATION;
6627 pAdapter->device_mode = session_type;
6628 status = hdd_register_interface( pAdapter, rtnl_held );
Madan Mohan Koyyalamudif89ac9f2013-09-19 16:58:12 +05306629
6630 hdd_init_tx_rx( pAdapter );
6631
6632 //Stop the Interface TX queue.
6633 netif_tx_disable(pAdapter->dev);
6634 netif_carrier_off(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 }
6636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 default:
6638 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306639 hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d",
6640 __func__, session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 VOS_ASSERT(0);
6642 return NULL;
6643 }
6644 }
6645
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 if( VOS_STATUS_SUCCESS == status )
6647 {
6648 //Add it to the hdd's session list.
6649 pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) );
6650 if( NULL == pHddAdapterNode )
6651 {
6652 status = VOS_STATUS_E_NOMEM;
6653 }
6654 else
6655 {
6656 pHddAdapterNode->pAdapter = pAdapter;
6657 status = hdd_add_adapter_back ( pHddCtx,
6658 pHddAdapterNode );
6659 }
6660 }
6661
6662 if( VOS_STATUS_SUCCESS != status )
6663 {
6664 if( NULL != pAdapter )
6665 {
6666 hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held );
6667 pAdapter = NULL;
6668 }
6669 if( NULL != pHddAdapterNode )
6670 {
6671 vos_mem_free( pHddAdapterNode );
6672 }
6673
6674 goto resume_bmps;
6675 }
6676
6677 if(VOS_STATUS_SUCCESS == status)
6678 {
6679 wlan_hdd_set_concurrency_mode(pHddCtx, session_type);
6680
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006681 //Initialize the WoWL service
6682 if(!hdd_init_wowl(pAdapter))
6683 {
6684 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__);
6685 goto err_free_netdev;
6686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 return pAdapter;
6689
6690err_free_netdev:
6691 free_netdev(pAdapter->dev);
6692 wlan_hdd_release_intf_addr( pHddCtx,
6693 pAdapter->macAddressCurrent.bytes );
6694
6695resume_bmps:
6696 //If bmps disabled enable it
6697 if(VOS_STATUS_SUCCESS == exitbmpsStatus)
6698 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306699 if (pHddCtx->hdd_wlan_suspended)
6700 {
6701 hdd_set_pwrparams(pHddCtx);
6702 }
6703 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 return NULL;
6706}
6707
6708VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
6709 tANI_U8 rtnl_held )
6710{
6711 hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext;
6712 VOS_STATUS status;
6713
6714 status = hdd_get_front_adapter ( pHddCtx, &pCurrent );
6715 if( VOS_STATUS_SUCCESS != status )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306716 {
6717 hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d",
6718 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006721
6722 while ( pCurrent->pAdapter != pAdapter )
6723 {
6724 status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext );
6725 if( VOS_STATUS_SUCCESS != status )
6726 break;
6727
6728 pCurrent = pNext;
6729 }
6730 pAdapterNode = pCurrent;
6731 if( VOS_STATUS_SUCCESS == status )
6732 {
6733 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
6734 hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306735
6736#ifdef FEATURE_WLAN_TDLS
6737
6738 /* A Mutex Lock is introduced while changing/initializing the mode to
6739 * protect the concurrent access for the Adapters by TDLS module.
6740 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306741 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306742#endif
6743
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 hdd_remove_adapter( pHddCtx, pAdapterNode );
6745 vos_mem_free( pAdapterNode );
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08006746 pAdapterNode = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006747
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306748#ifdef FEATURE_WLAN_TDLS
6749 mutex_unlock(&pHddCtx->tdls_lock);
6750#endif
6751
Jeff Johnson295189b2012-06-20 16:38:30 -07006752
6753 /* If there is a single session of STA/P2P client, re-enable BMPS */
Agarwal Ashish51325b52014-06-16 16:50:49 +05306754 if ((!vos_concurrent_open_sessions_running()) &&
6755 ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) ||
6756 (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306758 if (pHddCtx->hdd_wlan_suspended)
6759 {
6760 hdd_set_pwrparams(pHddCtx);
6761 }
6762 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 }
6764
6765 return VOS_STATUS_SUCCESS;
6766 }
6767
6768 return VOS_STATUS_E_FAILURE;
6769}
6770
6771VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx )
6772{
6773 hdd_adapter_list_node_t *pHddAdapterNode;
6774 VOS_STATUS status;
6775
6776 ENTER();
6777
6778 do
6779 {
6780 status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode );
6781 if( pHddAdapterNode && VOS_STATUS_SUCCESS == status )
6782 {
6783 hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE );
6784 vos_mem_free( pHddAdapterNode );
6785 }
6786 }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status );
6787
6788 EXIT();
6789
6790 return VOS_STATUS_SUCCESS;
6791}
6792
6793void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter)
6794{
6795 v_U8_t addIE[1] = {0};
6796
6797 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6798 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL,
6799 eANI_BOOLEAN_FALSE) )
6800 {
6801 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006802 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 }
6804
6805 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6806 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6807 eANI_BOOLEAN_FALSE) )
6808 {
6809 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006810 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 }
6812
6813 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6814 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6815 eANI_BOOLEAN_FALSE) )
6816 {
6817 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006818 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 }
6820}
6821
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306822VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
6823 const v_BOOL_t bCloseSession )
Jeff Johnson295189b2012-06-20 16:38:30 -07006824{
6825 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
6826 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05306827 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006828 union iwreq_data wrqu;
Kaushik, Sushant7005e372014-04-08 11:36:54 +05306829 v_U8_t retry = 0;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306830 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006831
6832 ENTER();
Kaushik, Sushant4975a572014-10-21 16:07:48 +05306833 pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 switch(pAdapter->device_mode)
6835 {
6836 case WLAN_HDD_INFRA_STATION:
6837 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006838 case WLAN_HDD_P2P_DEVICE:
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05306839 {
6840 hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6841 if( hdd_connIsConnected(pstation) ||
6842 (pstation->conn_info.connState == eConnectionState_Connecting) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 {
6844 if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS)
6845 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
6846 pAdapter->sessionId,
6847 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6848 else
6849 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
6850 pAdapter->sessionId,
6851 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6852 //success implies disconnect command got queued up successfully
6853 if(halStatus == eHAL_STATUS_SUCCESS)
6854 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306855 ret = wait_for_completion_interruptible_timeout(
6856 &pAdapter->disconnect_comp_var,
6857 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6858 if (ret <= 0)
6859 {
6860 hddLog(VOS_TRACE_LEVEL_ERROR,
6861 "%s: wait on disconnect_comp_var failed %ld",
6862 __func__, ret);
6863 }
6864 }
6865 else
6866 {
6867 hddLog(LOGE, "%s: failed to post disconnect event to SME",
6868 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 }
6870 memset(&wrqu, '\0', sizeof(wrqu));
6871 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
6872 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
6873 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
6874 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05306875 else if(pstation->conn_info.connState ==
6876 eConnectionState_Disconnecting)
6877 {
6878 ret = wait_for_completion_interruptible_timeout(
6879 &pAdapter->disconnect_comp_var,
6880 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6881 if (ret <= 0)
6882 {
6883 hddLog(VOS_TRACE_LEVEL_ERROR,
6884 FL("wait on disconnect_comp_var failed %ld"), ret);
6885 }
6886 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05306887 else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending)
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05306889 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306890 eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05306892 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
6893 {
6894 while (pAdapter->is_roc_inprogress)
6895 {
6896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6897 "%s: ROC in progress for session %d!!!",
6898 __func__, pAdapter->sessionId);
6899 // waiting for ROC to expire
6900 msleep(500);
6901 /* In GO present case , if retry exceeds 3,
6902 it means something went wrong. */
6903 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION )
6904 {
6905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6906 "%s: ROC completion is not received.!!!", __func__);
6907 sme_CancelRemainOnChannel(WLAN_HDD_GET_HAL_CTX(pAdapter),
6908 pAdapter->sessionId);
6909 wait_for_completion_interruptible_timeout(
6910 &pAdapter->cancel_rem_on_chan_var,
6911 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
6912 break;
6913 }
6914 }
6915 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306916#ifdef WLAN_NS_OFFLOAD
Vinay Krishna Eranna941360f2014-01-16 15:38:22 +05306917#ifdef WLAN_OPEN_SOURCE
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306918 cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue);
6919#endif
Vinay Krishna Eranna941360f2014-01-16 15:38:22 +05306920 if (pAdapter->ipv6_notifier_registered)
6921 {
6922 hddLog(LOG1, FL("Unregistered IPv6 notifier"));
6923 unregister_inet6addr_notifier(&pAdapter->ipv6_notifier);
6924 pAdapter->ipv6_notifier_registered = false;
6925 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306926#endif
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +05306927 if (pAdapter->ipv4_notifier_registered)
6928 {
6929 hddLog(LOG1, FL("Unregistered IPv4 notifier"));
6930 unregister_inetaddr_notifier(&pAdapter->ipv4_notifier);
6931 pAdapter->ipv4_notifier_registered = false;
6932 }
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306933#ifdef WLAN_OPEN_SOURCE
6934 cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue);
6935#endif
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306936 /* It is possible that the caller of this function does not
6937 * wish to close the session
6938 */
6939 if (VOS_TRUE == bCloseSession &&
6940 test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 {
6942 INIT_COMPLETION(pAdapter->session_close_comp_var);
6943 if (eHAL_STATUS_SUCCESS ==
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306944 sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId,
6945 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306947 unsigned long ret;
6948
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306950 ret = wait_for_completion_timeout(
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306951 &pAdapter->session_close_comp_var,
6952 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306953 if ( 0 >= ret)
6954 {
6955 hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld",
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306956 __func__, ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 }
6959 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05306960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 break;
6962
6963 case WLAN_HDD_SOFTAP:
6964 case WLAN_HDD_P2P_GO:
6965 //Any softap specific cleanup here...
Kaushik, Sushant7005e372014-04-08 11:36:54 +05306966 if (pAdapter->device_mode == WLAN_HDD_P2P_GO) {
6967 while (pAdapter->is_roc_inprogress) {
6968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6969 "%s: ROC in progress for session %d!!!",
6970 __func__, pAdapter->sessionId);
6971 msleep(500);
6972 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) {
6973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6974 "%s: ROC completion is not received.!!!", __func__);
6975 WLANSAP_CancelRemainOnChannel(
6976 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
6977 wait_for_completion_interruptible_timeout(
6978 &pAdapter->cancel_rem_on_chan_var,
6979 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
6980 break;
6981 }
6982 }
6983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 mutex_lock(&pHddCtx->sap_lock);
6985 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6986 {
6987 VOS_STATUS status;
6988 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6989
6990 //Stop Bss.
6991 status = WLANSAP_StopBss(pHddCtx->pvosContext);
6992 if (VOS_IS_STATUS_SUCCESS(status))
6993 {
6994 hdd_hostapd_state_t *pHostapdState =
6995 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6996
6997 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6998
6999 if (!VOS_IS_STATUS_SUCCESS(status))
7000 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307001 hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d",
7002 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 }
7004 }
7005 else
7006 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007007 hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 }
7009 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307010 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007011
7012 if (eHAL_STATUS_FAILURE ==
7013 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG,
7014 0, NULL, eANI_BOOLEAN_FALSE))
7015 {
7016 hddLog(LOGE,
7017 "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007018 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 }
7020
7021 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7022 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7023 eANI_BOOLEAN_FALSE) )
7024 {
7025 hddLog(LOGE,
7026 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
7027 }
7028
7029 // Reset WNI_CFG_PROBE_RSP Flags
7030 wlan_hdd_reset_prob_rspies(pAdapter);
7031 kfree(pAdapter->sessionCtx.ap.beacon);
7032 pAdapter->sessionCtx.ap.beacon = NULL;
7033 }
7034 mutex_unlock(&pHddCtx->sap_lock);
7035 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007036
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 case WLAN_HDD_MONITOR:
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007038#ifdef WLAN_OPEN_SOURCE
7039 cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue);
7040#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007042
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 default:
7044 break;
7045 }
7046
7047 EXIT();
7048 return VOS_STATUS_SUCCESS;
7049}
7050
7051VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx )
7052{
7053 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7054 VOS_STATUS status;
7055 hdd_adapter_t *pAdapter;
7056
7057 ENTER();
7058
7059 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7060
7061 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7062 {
7063 pAdapter = pAdapterNode->pAdapter;
7064 netif_tx_disable(pAdapter->dev);
7065 netif_carrier_off(pAdapter->dev);
7066
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307067 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007068
7069 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7070 pAdapterNode = pNext;
7071 }
7072
7073 EXIT();
7074
7075 return VOS_STATUS_SUCCESS;
7076}
7077
Rajeev Kumarf999e582014-01-09 17:33:29 -08007078
7079#ifdef FEATURE_WLAN_BATCH_SCAN
7080/**---------------------------------------------------------------------------
7081
7082 \brief hdd_deinit_batch_scan () - This function cleans up batch scan data
7083 structures
7084
7085 \param - pAdapter Pointer to HDD adapter
7086
7087 \return - None
7088
7089 --------------------------------------------------------------------------*/
7090void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter)
7091{
7092 tHddBatchScanRsp *pNode;
7093 tHddBatchScanRsp *pPrev;
7094
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307095 if (NULL == pAdapter)
Rajeev Kumarf999e582014-01-09 17:33:29 -08007096 {
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307097 hddLog(VOS_TRACE_LEVEL_ERROR,
7098 "%s: Adapter context is Null", __func__);
7099 return;
7100 }
7101
7102 pNode = pAdapter->pBatchScanRsp;
7103 while (pNode)
7104 {
7105 pPrev = pNode;
7106 pNode = pNode->pNext;
7107 vos_mem_free((v_VOID_t * )pPrev);
Rajeev Kumarf999e582014-01-09 17:33:29 -08007108 }
7109
7110 pAdapter->pBatchScanRsp = NULL;
7111 pAdapter->numScanList = 0;
7112 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
7113 pAdapter->prev_batch_id = 0;
7114
7115 return;
7116}
7117#endif
7118
7119
Jeff Johnson295189b2012-06-20 16:38:30 -07007120VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx )
7121{
7122 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7123 VOS_STATUS status;
7124 hdd_adapter_t *pAdapter;
7125
7126 ENTER();
7127
7128 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7129
7130 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7131 {
7132 pAdapter = pAdapterNode->pAdapter;
7133 netif_tx_disable(pAdapter->dev);
7134 netif_carrier_off(pAdapter->dev);
7135
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007136 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
7137
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 hdd_deinit_tx_rx(pAdapter);
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307139
7140 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
7141
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05307142 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
7143 {
7144 hdd_wmm_adapter_close( pAdapter );
7145 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
7146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007147
Rajeev Kumarf999e582014-01-09 17:33:29 -08007148#ifdef FEATURE_WLAN_BATCH_SCAN
7149 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
7150 {
7151 hdd_deinit_batch_scan(pAdapter);
7152 }
7153#endif
7154
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7156 pAdapterNode = pNext;
7157 }
7158
7159 EXIT();
7160
7161 return VOS_STATUS_SUCCESS;
7162}
7163
7164VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx )
7165{
7166 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7167 VOS_STATUS status;
7168 hdd_adapter_t *pAdapter;
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307169 eConnectionState connState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007170
7171 ENTER();
7172
7173 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7174
7175 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7176 {
7177 pAdapter = pAdapterNode->pAdapter;
7178
Kumar Anand82c009f2014-05-29 00:29:42 -07007179 hdd_wmm_init( pAdapter );
7180
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 switch(pAdapter->device_mode)
7182 {
7183 case WLAN_HDD_INFRA_STATION:
7184 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007185 case WLAN_HDD_P2P_DEVICE:
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307186
7187 connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState;
7188
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 hdd_init_station_mode(pAdapter);
7190 /* Open the gates for HDD to receive Wext commands */
7191 pAdapter->isLinkUpSvcNeeded = FALSE;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007192 pHddCtx->scan_info.mScanPending = FALSE;
7193 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007194
7195 //Trigger the initial scan
7196 hdd_wlan_initial_scan(pAdapter);
7197
7198 //Indicate disconnect event to supplicant if associated previously
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307199 if (eConnectionState_Associated == connState ||
7200 eConnectionState_IbssConnected == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 {
7202 union iwreq_data wrqu;
7203 memset(&wrqu, '\0', sizeof(wrqu));
7204 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7205 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7206 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007207 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007208
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 /* indicate disconnected event to nl80211 */
7210 cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED,
7211 NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 }
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307213 else if (eConnectionState_Connecting == connState)
7214 {
7215 /*
7216 * Indicate connect failure to supplicant if we were in the
7217 * process of connecting
7218 */
7219 cfg80211_connect_result(pAdapter->dev, NULL,
7220 NULL, 0, NULL, 0,
7221 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
7222 GFP_KERNEL);
7223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 break;
7225
7226 case WLAN_HDD_SOFTAP:
7227 /* softAP can handle SSR */
7228 break;
7229
7230 case WLAN_HDD_P2P_GO:
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007231 hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant",
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 __func__);
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007233 cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 break;
7235
7236 case WLAN_HDD_MONITOR:
7237 /* monitor interface start */
7238 break;
7239 default:
7240 break;
7241 }
7242
7243 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7244 pAdapterNode = pNext;
7245 }
7246
7247 EXIT();
7248
7249 return VOS_STATUS_SUCCESS;
7250}
7251
7252VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx )
7253{
7254 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7255 hdd_adapter_t *pAdapter;
7256 VOS_STATUS status;
7257 v_U32_t roamId;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307258 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007259
7260 ENTER();
7261
7262 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7263
7264 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7265 {
7266 pAdapter = pAdapterNode->pAdapter;
7267
7268 if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
7269 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
7270 {
7271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7272 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7273
Abhishek Singhf4669da2014-05-26 15:07:49 +05307274 hddLog(VOS_TRACE_LEVEL_INFO,
7275 "%s: Set HDD connState to eConnectionState_NotConnected",
7276 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7278 init_completion(&pAdapter->disconnect_comp_var);
7279 sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId,
7280 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7281
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307282 ret = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 &pAdapter->disconnect_comp_var,
7284 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307285 if (0 >= ret)
7286 hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld",
7287 __func__, ret);
Jeff Johnson295189b2012-06-20 16:38:30 -07007288
7289 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
7290 pHddCtx->isAmpAllowed = VOS_FALSE;
7291 sme_RoamConnect(pHddCtx->hHal,
7292 pAdapter->sessionId, &(pWextState->roamProfile),
7293 &roamId);
7294 }
7295
7296 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7297 pAdapterNode = pNext;
7298 }
7299
7300 EXIT();
7301
7302 return VOS_STATUS_SUCCESS;
7303}
7304
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07007305void hdd_dump_concurrency_info(hdd_context_t *pHddCtx)
7306{
7307 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7308 VOS_STATUS status;
7309 hdd_adapter_t *pAdapter;
7310 hdd_station_ctx_t *pHddStaCtx;
7311 hdd_ap_ctx_t *pHddApCtx;
7312 hdd_hostapd_state_t * pHostapdState;
7313 tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 };
7314 v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0;
7315 const char *p2pMode = "DEV";
7316 const char *ccMode = "Standalone";
7317 int n;
7318
7319 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7320 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7321 {
7322 pAdapter = pAdapterNode->pAdapter;
7323 switch (pAdapter->device_mode) {
7324 case WLAN_HDD_INFRA_STATION:
7325 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7326 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7327 staChannel = pHddStaCtx->conn_info.operationChannel;
7328 memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid));
7329 }
7330 break;
7331 case WLAN_HDD_P2P_CLIENT:
7332 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7333 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7334 p2pChannel = pHddStaCtx->conn_info.operationChannel;
7335 memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid));
7336 p2pMode = "CLI";
7337 }
7338 break;
7339 case WLAN_HDD_P2P_GO:
7340 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7341 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7342 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7343 p2pChannel = pHddApCtx->operatingChannel;
7344 memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid));
7345 }
7346 p2pMode = "GO";
7347 break;
7348 case WLAN_HDD_SOFTAP:
7349 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7350 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7351 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7352 apChannel = pHddApCtx->operatingChannel;
7353 memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid));
7354 }
7355 break;
7356 default:
7357 break;
7358 }
7359 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7360 pAdapterNode = pNext;
7361 }
7362 if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) {
7363 ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC";
7364 }
7365 n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s",
7366 staChannel, MAC_ADDR_ARRAY(staBssid), ccMode);
7367 if (p2pChannel > 0) {
7368 n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR,
7369 p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid));
7370 }
7371 if (apChannel > 0) {
7372 n += pr_info("AP(%d) " MAC_ADDRESS_STR,
7373 apChannel, MAC_ADDR_ARRAY(apBssid));
7374 }
7375
7376 if (p2pChannel > 0 && apChannel > 0) {
7377 hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel);
7378 }
7379}
7380
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007381bool hdd_is_ssr_required( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07007382{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007383 return (isSsrRequired == HDD_SSR_REQUIRED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007384}
7385
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007386/* Once SSR is disabled then it cannot be set. */
7387void hdd_set_ssr_required( e_hdd_ssr_required value)
Jeff Johnson295189b2012-06-20 16:38:30 -07007388{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007389 if (HDD_SSR_DISABLED == isSsrRequired)
7390 return;
7391
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 isSsrRequired = value;
7393}
7394
7395VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx,
7396 hdd_adapter_list_node_t** ppAdapterNode)
7397{
7398 VOS_STATUS status;
7399 spin_lock(&pHddCtx->hddAdapters.lock);
7400 status = hdd_list_peek_front ( &pHddCtx->hddAdapters,
7401 (hdd_list_node_t**) ppAdapterNode );
7402 spin_unlock(&pHddCtx->hddAdapters.lock);
7403 return status;
7404}
7405
7406VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx,
7407 hdd_adapter_list_node_t* pAdapterNode,
7408 hdd_adapter_list_node_t** pNextAdapterNode)
7409{
7410 VOS_STATUS status;
7411 spin_lock(&pHddCtx->hddAdapters.lock);
7412 status = hdd_list_peek_next ( &pHddCtx->hddAdapters,
7413 (hdd_list_node_t*) pAdapterNode,
7414 (hdd_list_node_t**)pNextAdapterNode );
7415
7416 spin_unlock(&pHddCtx->hddAdapters.lock);
7417 return status;
7418}
7419
7420VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx,
7421 hdd_adapter_list_node_t* pAdapterNode)
7422{
7423 VOS_STATUS status;
7424 spin_lock(&pHddCtx->hddAdapters.lock);
7425 status = hdd_list_remove_node ( &pHddCtx->hddAdapters,
7426 &pAdapterNode->node );
7427 spin_unlock(&pHddCtx->hddAdapters.lock);
7428 return status;
7429}
7430
7431VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx,
7432 hdd_adapter_list_node_t** ppAdapterNode)
7433{
7434 VOS_STATUS status;
7435 spin_lock(&pHddCtx->hddAdapters.lock);
7436 status = hdd_list_remove_front( &pHddCtx->hddAdapters,
7437 (hdd_list_node_t**) ppAdapterNode );
7438 spin_unlock(&pHddCtx->hddAdapters.lock);
7439 return status;
7440}
7441
7442VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx,
7443 hdd_adapter_list_node_t* pAdapterNode)
7444{
7445 VOS_STATUS status;
7446 spin_lock(&pHddCtx->hddAdapters.lock);
7447 status = hdd_list_insert_back ( &pHddCtx->hddAdapters,
7448 (hdd_list_node_t*) pAdapterNode );
7449 spin_unlock(&pHddCtx->hddAdapters.lock);
7450 return status;
7451}
7452
7453VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx,
7454 hdd_adapter_list_node_t* pAdapterNode)
7455{
7456 VOS_STATUS status;
7457 spin_lock(&pHddCtx->hddAdapters.lock);
7458 status = hdd_list_insert_front ( &pHddCtx->hddAdapters,
7459 (hdd_list_node_t*) pAdapterNode );
7460 spin_unlock(&pHddCtx->hddAdapters.lock);
7461 return status;
7462}
7463
7464hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx,
7465 tSirMacAddr macAddr )
7466{
7467 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7468 hdd_adapter_t *pAdapter;
7469 VOS_STATUS status;
7470
7471 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7472
7473 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7474 {
7475 pAdapter = pAdapterNode->pAdapter;
7476
7477 if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes,
7478 macAddr, sizeof(tSirMacAddr) ) )
7479 {
7480 return pAdapter;
7481 }
7482 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7483 pAdapterNode = pNext;
7484 }
7485
7486 return NULL;
7487
7488}
7489
7490hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name )
7491{
7492 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7493 hdd_adapter_t *pAdapter;
7494 VOS_STATUS status;
7495
7496 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7497
7498 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7499 {
7500 pAdapter = pAdapterNode->pAdapter;
7501
7502 if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name,
7503 IFNAMSIZ ) )
7504 {
7505 return pAdapter;
7506 }
7507 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7508 pAdapterNode = pNext;
7509 }
7510
7511 return NULL;
7512
7513}
7514
7515hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode )
7516{
7517 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7518 hdd_adapter_t *pAdapter;
7519 VOS_STATUS status;
7520
7521 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7522
7523 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7524 {
7525 pAdapter = pAdapterNode->pAdapter;
7526
7527 if( pAdapter && (mode == pAdapter->device_mode) )
7528 {
7529 return pAdapter;
7530 }
7531 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7532 pAdapterNode = pNext;
7533 }
7534
7535 return NULL;
7536
7537}
7538
7539//Remove this function later
7540hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx )
7541{
7542 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7543 hdd_adapter_t *pAdapter;
7544 VOS_STATUS status;
7545
7546 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7547
7548 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7549 {
7550 pAdapter = pAdapterNode->pAdapter;
7551
7552 if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode )
7553 {
7554 return pAdapter;
7555 }
7556
7557 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7558 pAdapterNode = pNext;
7559 }
7560
7561 return NULL;
7562
7563}
7564
Jeff Johnson295189b2012-06-20 16:38:30 -07007565/**---------------------------------------------------------------------------
7566
7567 \brief hdd_set_monitor_tx_adapter() -
7568
7569 This API initializes the adapter to be used while transmitting on monitor
7570 adapter.
7571
7572 \param - pHddCtx - Pointer to the HDD context.
7573 pAdapter - Adapter that will used for TX. This can be NULL.
7574 \return - None.
7575 --------------------------------------------------------------------------*/
7576void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
7577{
7578 hdd_adapter_t *pMonAdapter;
7579
7580 pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR );
7581
7582 if( NULL != pMonAdapter )
7583 {
7584 pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter;
7585 }
7586}
Jeff Johnson295189b2012-06-20 16:38:30 -07007587/**---------------------------------------------------------------------------
7588
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05307589 \brief hdd_get_operating_channel() -
Jeff Johnson295189b2012-06-20 16:38:30 -07007590
7591 This API returns the operating channel of the requested device mode
7592
7593 \param - pHddCtx - Pointer to the HDD context.
7594 - mode - Device mode for which operating channel is required
7595 suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT
7596 WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO.
7597 \return - channel number. "0" id the requested device is not found OR it is not connected.
7598 --------------------------------------------------------------------------*/
7599v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode )
7600{
7601 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7602 VOS_STATUS status;
7603 hdd_adapter_t *pAdapter;
7604 v_U8_t operatingChannel = 0;
7605
7606 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7607
7608 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7609 {
7610 pAdapter = pAdapterNode->pAdapter;
7611
7612 if( mode == pAdapter->device_mode )
7613 {
7614 switch(pAdapter->device_mode)
7615 {
7616 case WLAN_HDD_INFRA_STATION:
7617 case WLAN_HDD_P2P_CLIENT:
7618 if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) )
7619 operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel;
7620 break;
7621 case WLAN_HDD_SOFTAP:
7622 case WLAN_HDD_P2P_GO:
7623 /*softap connection info */
7624 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7625 operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel;
7626 break;
7627 default:
7628 break;
7629 }
7630
7631 break; //Found the device of interest. break the loop
7632 }
7633
7634 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7635 pAdapterNode = pNext;
7636 }
7637 return operatingChannel;
7638}
7639
7640#ifdef WLAN_FEATURE_PACKET_FILTERING
7641/**---------------------------------------------------------------------------
7642
7643 \brief hdd_set_multicast_list() -
7644
7645 This used to set the multicast address list.
7646
7647 \param - dev - Pointer to the WLAN device.
7648 - skb - Pointer to OS packet (sk_buff).
7649 \return - success/fail
7650
7651 --------------------------------------------------------------------------*/
7652static void hdd_set_multicast_list(struct net_device *dev)
7653{
7654 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 int mc_count;
7656 int i = 0;
7657 struct netdev_hw_addr *ha;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307658
7659 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 {
7661 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307662 "%s: Adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 return;
7664 }
7665
7666 if (dev->flags & IFF_ALLMULTI)
7667 {
7668 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007669 "%s: allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307670 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 }
7672 else
7673 {
7674 mc_count = netdev_mc_count(dev);
7675 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007676 "%s: mc_count = %u", __func__, mc_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST)
7678 {
7679 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007680 "%s: No free filter available; allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307681 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 return;
7683 }
7684
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307685 pAdapter->mc_addr_list.mc_cnt = mc_count;
Jeff Johnson295189b2012-06-20 16:38:30 -07007686
7687 netdev_for_each_mc_addr(ha, dev) {
7688 if (i == mc_count)
7689 break;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307690 memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN);
7691 memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007692 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 __func__, i,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307694 MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i]));
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 i++;
7696 }
7697 }
7698 return;
7699}
7700#endif
7701
7702/**---------------------------------------------------------------------------
7703
7704 \brief hdd_select_queue() -
7705
7706 This function is registered with the Linux OS for network
7707 core to decide which queue to use first.
7708
7709 \param - dev - Pointer to the WLAN device.
7710 - skb - Pointer to OS packet (sk_buff).
7711 \return - ac, Queue Index/access category corresponding to UP in IP header
7712
7713 --------------------------------------------------------------------------*/
7714v_U16_t hdd_select_queue(struct net_device *dev,
7715 struct sk_buff *skb)
7716{
7717 return hdd_wmm_select_queue(dev, skb);
7718}
7719
7720
7721/**---------------------------------------------------------------------------
7722
7723 \brief hdd_wlan_initial_scan() -
7724
7725 This function triggers the initial scan
7726
7727 \param - pAdapter - Pointer to the HDD adapter.
7728
7729 --------------------------------------------------------------------------*/
7730void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter)
7731{
7732 tCsrScanRequest scanReq;
7733 tCsrChannelInfo channelInfo;
7734 eHalStatus halStatus;
Jeff Johnson02797792013-10-26 19:17:13 -07007735 tANI_U32 scanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7737
7738 vos_mem_zero(&scanReq, sizeof(tCsrScanRequest));
7739 vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff);
7740 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
7741
7742 if(sme_Is11dSupported(pHddCtx->hHal))
7743 {
7744 halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo );
7745 if ( HAL_STATUS_SUCCESS( halStatus ) )
7746 {
7747 scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels);
7748 if( !scanReq.ChannelInfo.ChannelList )
7749 {
7750 hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__);
7751 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08007752 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007753 return;
7754 }
7755 vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList,
7756 channelInfo.numOfChannels);
7757 scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels;
7758 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08007759 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 }
7761
7762 scanReq.scanType = eSIR_PASSIVE_SCAN;
7763 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
7764 scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime;
7765 scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime;
7766 }
7767 else
7768 {
7769 scanReq.scanType = eSIR_ACTIVE_SCAN;
7770 scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
7771 scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime;
7772 scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime;
7773 }
7774
7775 halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL);
7776 if ( !HAL_STATUS_SUCCESS( halStatus ) )
7777 {
7778 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d",
7779 __func__, halStatus );
7780 }
7781
7782 if(sme_Is11dSupported(pHddCtx->hHal))
7783 vos_mem_free(scanReq.ChannelInfo.ChannelList);
7784}
7785
Jeff Johnson295189b2012-06-20 16:38:30 -07007786/**---------------------------------------------------------------------------
7787
7788 \brief hdd_full_power_callback() - HDD full power callback function
7789
7790 This is the function invoked by SME to inform the result of a full power
7791 request issued by HDD
7792
7793 \param - callbackcontext - Pointer to cookie
7794 \param - status - result of request
7795
7796 \return - None
7797
7798 --------------------------------------------------------------------------*/
7799static void hdd_full_power_callback(void *callbackContext, eHalStatus status)
7800{
Jeff Johnson72a40512013-12-19 10:14:15 -08007801 struct statsContext *pContext = callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007802
7803 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307804 "%s: context = %p, status = %d", __func__, pContext, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007805
7806 if (NULL == callbackContext)
7807 {
7808 hddLog(VOS_TRACE_LEVEL_ERROR,
7809 "%s: Bad param, context [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007810 __func__, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 return;
7812 }
7813
Jeff Johnson72a40512013-12-19 10:14:15 -08007814 /* there is a race condition that exists between this callback
7815 function and the caller since the caller could time out either
7816 before or while this code is executing. we use a spinlock to
7817 serialize these actions */
7818 spin_lock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007819
7820 if (POWER_CONTEXT_MAGIC != pContext->magic)
7821 {
7822 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08007823 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 hddLog(VOS_TRACE_LEVEL_WARN,
7825 "%s: Invalid context, magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007826 __func__, pContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 return;
7828 }
7829
Jeff Johnson72a40512013-12-19 10:14:15 -08007830 /* context is valid so caller is still waiting */
7831
7832 /* paranoia: invalidate the magic */
7833 pContext->magic = 0;
7834
7835 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 complete(&pContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08007837
7838 /* serialization is complete */
7839 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007840}
7841
7842/**---------------------------------------------------------------------------
7843
7844 \brief hdd_wlan_exit() - HDD WLAN exit function
7845
7846 This is the driver exit point (invoked during rmmod)
7847
7848 \param - pHddCtx - Pointer to the HDD Context
7849
7850 \return - None
7851
7852 --------------------------------------------------------------------------*/
7853void hdd_wlan_exit(hdd_context_t *pHddCtx)
7854{
7855 eHalStatus halStatus;
7856 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
7857 VOS_STATUS vosStatus;
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05307858 struct wiphy *wiphy = pHddCtx->wiphy;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007859 hdd_adapter_t* pAdapter = NULL;
Jeff Johnson72a40512013-12-19 10:14:15 -08007860 struct statsContext powerContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 long lrc;
c_hpothu5ab05e92014-06-13 17:34:05 +05307862 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007863
7864 ENTER();
7865
Jeff Johnson88ba7742013-02-27 14:36:02 -08007866 if (VOS_FTM_MODE != hdd_get_conparam())
7867 {
7868 // Unloading, restart logic is no more required.
7869 wlan_hdd_restart_deinit(pHddCtx);
Jeff Johnsone7245742012-09-05 17:12:55 -07007870
c_hpothu5ab05e92014-06-13 17:34:05 +05307871 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7872 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 {
c_hpothu5ab05e92014-06-13 17:34:05 +05307874 pAdapter = pAdapterNode->pAdapter;
7875 if (NULL != pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 {
c_hpothu5ab05e92014-06-13 17:34:05 +05307877 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
7878 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
7879 {
7880 wlan_hdd_cfg80211_deregister_frames(pAdapter);
7881 hdd_UnregisterWext(pAdapter->dev);
7882 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307883
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 }
c_hpothu5ab05e92014-06-13 17:34:05 +05307885 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7886 pAdapterNode = pNext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307888 // Cancel any outstanding scan requests. We are about to close all
7889 // of our adapters, but an adapter structure is what SME passes back
7890 // to our callback function. Hence if there are any outstanding scan
7891 // requests then there is a race condition between when the adapter
7892 // is closed and when the callback is invoked.We try to resolve that
7893 // race condition here by canceling any outstanding scans before we
7894 // close the adapters.
7895 // Note that the scans may be cancelled in an asynchronous manner,
7896 // so ideally there needs to be some kind of synchronization. Rather
7897 // than introduce a new synchronization here, we will utilize the
7898 // fact that we are about to Request Full Power, and since that is
7899 // synchronized, the expectation is that by the time Request Full
7900 // Power has completed all scans will be cancelled.
7901 if (pHddCtx->scan_info.mScanPending)
7902 {
7903 hddLog(VOS_TRACE_LEVEL_INFO,
7904 FL("abort scan mode: %d sessionId: %d"),
7905 pAdapter->device_mode,
7906 pAdapter->sessionId);
7907 hdd_abort_mac_scan(pHddCtx,
7908 pHddCtx->scan_info.sessionId,
7909 eCSR_SCAN_ABORT_DEFAULT);
7910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 }
c_hpothu5ab05e92014-06-13 17:34:05 +05307912 else
Jeff Johnson88ba7742013-02-27 14:36:02 -08007913 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307914 hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__);
Jeff Johnson88ba7742013-02-27 14:36:02 -08007915 wlan_hdd_ftm_close(pHddCtx);
7916 goto free_hdd_ctx;
7917 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307918
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 /* DeRegister with platform driver as client for Suspend/Resume */
7920 vosStatus = hddDeregisterPmOps(pHddCtx);
7921 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
7922 {
7923 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__);
7924 VOS_ASSERT(0);
7925 }
7926
7927 vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx);
7928 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
7929 {
7930 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
7931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007932
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07007933 //Stop the traffic monitor timer
7934 if ( VOS_TIMER_STATE_RUNNING ==
7935 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))
7936 {
7937 vos_timer_stop(&pHddCtx->tx_rx_trafficTmr);
7938 }
7939
7940 // Destroy the traffic monitor timer
7941 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(
7942 &pHddCtx->tx_rx_trafficTmr)))
7943 {
7944 hddLog(VOS_TRACE_LEVEL_ERROR,
7945 "%s: Cannot deallocate Traffic monitor timer", __func__);
7946 }
7947
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 //Disable IMPS/BMPS as we do not want the device to enter any power
7949 //save mode during shutdown
7950 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
7951 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
7952 sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE);
7953
7954 //Ensure that device is in full power as we will touch H/W during vos_Stop
7955 init_completion(&powerContext.completion);
7956 powerContext.magic = POWER_CONTEXT_MAGIC;
7957
7958 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback,
7959 &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD);
7960
7961 if (eHAL_STATUS_SUCCESS != halStatus)
7962 {
7963 if (eHAL_STATUS_PMC_PENDING == halStatus)
7964 {
7965 /* request was sent -- wait for the response */
7966 lrc = wait_for_completion_interruptible_timeout(
7967 &powerContext.completion,
7968 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 if (lrc <= 0)
7970 {
7971 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007972 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 }
7974 }
7975 else
7976 {
7977 hddLog(VOS_TRACE_LEVEL_ERROR,
7978 "%s: Request for Full Power failed, status %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007979 __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 /* continue -- need to clean up as much as possible */
7981 }
7982 }
7983
Jeff Johnson72a40512013-12-19 10:14:15 -08007984 /* either we never sent a request, we sent a request and received a
7985 response or we sent a request and timed out. if we never sent a
7986 request or if we sent a request and got a response, we want to
7987 clear the magic out of paranoia. if we timed out there is a
7988 race condition such that the callback function could be
7989 executing at the same time we are. of primary concern is if the
7990 callback function had already verified the "magic" but had not
7991 yet set the completion variable when a timeout occurred. we
7992 serialize these activities by invalidating the magic while
7993 holding a shared spinlock which will cause us to block if the
7994 callback is currently executing */
7995 spin_lock(&hdd_context_lock);
7996 powerContext.magic = 0;
7997 spin_unlock(&hdd_context_lock);
7998
Yue Ma0d4891e2013-08-06 17:01:45 -07007999 hdd_debugfs_exit(pHddCtx);
8000
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 // Unregister the Net Device Notifier
8002 unregister_netdevice_notifier(&hdd_netdev_notifier);
8003
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 hdd_stop_all_adapters( pHddCtx );
8005
Jeff Johnson295189b2012-06-20 16:38:30 -07008006#ifdef WLAN_BTAMP_FEATURE
8007 vosStatus = WLANBAP_Stop(pVosContext);
8008 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8009 {
8010 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8011 "%s: Failed to stop BAP",__func__);
8012 }
8013#endif //WLAN_BTAMP_FEATURE
8014
8015 //Stop all the modules
8016 vosStatus = vos_stop( pVosContext );
8017 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8018 {
8019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8020 "%s: Failed to stop VOSS",__func__);
8021 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8022 }
8023
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 //This requires pMac access, Call this before vos_close().
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 hdd_unregister_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008026
8027 //Close the scheduler before calling vos_close to make sure no thread is
8028 // scheduled after the each module close is called i.e after all the data
8029 // structures are freed.
8030 vosStatus = vos_sched_close( pVosContext );
8031 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8032 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8033 "%s: Failed to close VOSS Scheduler",__func__);
8034 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8035 }
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008036#ifdef WLAN_OPEN_SOURCE
Jeff Johnsone7245742012-09-05 17:12:55 -07008037#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
8038 /* Destroy the wake lock */
8039 wake_lock_destroy(&pHddCtx->rx_wake_lock);
8040#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08008041 /* Destroy the wake lock */
8042 wake_lock_destroy(&pHddCtx->sap_wake_lock);
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008043#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008044
Mihir Shete7a24b5f2013-12-21 12:18:31 +05308045#ifdef CONFIG_ENABLE_LINUX_REG
8046 vosStatus = vos_nv_close();
8047 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8048 {
8049 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8050 "%s: Failed to close NV", __func__);
8051 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8052 }
8053#endif
8054
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 //Close VOSS
8056 //This frees pMac(HAL) context. There should not be any call that requires pMac access after this.
8057 vos_close(pVosContext);
8058
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 //Close Watchdog
8060 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8061 vos_watchdog_close(pVosContext);
8062
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308063 //Clean up HDD Nlink Service
8064 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308065
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308066#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05308067 if (pHddCtx->cfg_ini->wlanLoggingEnable)
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308068 {
8069 wlan_logging_sock_deactivate_svc();
8070 }
8071#endif
8072
Vinay Krishna Erannaef30b522014-08-26 17:48:16 +05308073#ifdef WLAN_KD_READY_NOTIFIER
8074 nl_srv_exit(pHddCtx->ptt_pid);
8075#else
8076 nl_srv_exit();
8077#endif /* WLAN_KD_READY_NOTIFIER */
8078
8079
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 hdd_close_all_adapters( pHddCtx );
8081
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 /* free the power on lock from platform driver */
8083 if (free_riva_power_on_lock("wlan"))
8084 {
8085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock",
8086 __func__);
8087 }
8088
Jeff Johnson88ba7742013-02-27 14:36:02 -08008089free_hdd_ctx:
c_hpothu78c7b602014-05-17 17:35:49 +05308090
8091 //Free up dynamically allocated members inside HDD Adapter
8092 if (pHddCtx->cfg_ini)
8093 {
8094 kfree(pHddCtx->cfg_ini);
8095 pHddCtx->cfg_ini= NULL;
8096 }
8097
Leo Changf04ddad2013-09-18 13:46:38 -07008098 /* FTM mode, WIPHY did not registered
8099 If un-register here, system crash will happen */
8100 if (VOS_FTM_MODE != hdd_get_conparam())
8101 {
8102 wiphy_unregister(wiphy) ;
8103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 wiphy_free(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 if (hdd_is_ssr_required())
8106 {
8107 /* WDI timeout had happened during unload, so SSR is needed here */
Madan Mohan Koyyalamudi3246f5b2012-10-15 15:40:02 -07008108 subsystem_restart("wcnss");
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 msleep(5000);
8110 }
8111 hdd_set_ssr_required (VOS_FALSE);
8112}
8113
8114
8115/**---------------------------------------------------------------------------
8116
8117 \brief hdd_update_config_from_nv() - Function to update the contents of
8118 the running configuration with parameters taken from NV storage
8119
8120 \param - pHddCtx - Pointer to the HDD global context
8121
8122 \return - VOS_STATUS_SUCCESS if successful
8123
8124 --------------------------------------------------------------------------*/
8125static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx)
8126{
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 v_BOOL_t itemIsValid = VOS_FALSE;
8128 VOS_STATUS status;
8129 v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA];
8130 v_U8_t macLoop;
8131
8132 /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/
8133 status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid);
8134 if(status != VOS_STATUS_SUCCESS)
8135 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008136 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 return VOS_STATUS_E_FAILURE;
8138 }
8139
8140 if (itemIsValid == VOS_TRUE)
8141 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008142 hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV");
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0],
8144 VOS_MAX_CONCURRENCY_PERSONA);
8145 if(status != VOS_STATUS_SUCCESS)
8146 {
8147 /* Get MAC from NV fail, not update CFG info
8148 * INI MAC value will be used for MAC setting */
Arif Hussain6d2a3322013-11-17 19:50:10 -08008149 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 return VOS_STATUS_E_FAILURE;
8151 }
8152
8153 /* If first MAC is not valid, treat all others are not valid
8154 * Then all MACs will be got from ini file */
8155 if(vos_is_macaddr_zero(&macFromNV[0]))
8156 {
8157 /* MAC address in NV file is not configured yet */
8158 hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file");
8159 return VOS_STATUS_E_INVAL;
8160 }
8161
8162 /* Get MAC address from NV, update CFG info */
8163 for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++)
8164 {
8165 if(vos_is_macaddr_zero(&macFromNV[macLoop]))
8166 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308167 hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop);
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 /* This MAC is not valid, skip it
8169 * This MAC will be got from ini file */
8170 }
8171 else
8172 {
8173 vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0],
8174 (v_U8_t *)&macFromNV[macLoop].bytes[0],
8175 VOS_MAC_ADDR_SIZE);
8176 }
8177 }
8178 }
8179 else
8180 {
8181 hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid");
8182 return VOS_STATUS_E_FAILURE;
8183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008184
Jeff Johnson295189b2012-06-20 16:38:30 -07008185
8186 return VOS_STATUS_SUCCESS;
8187}
8188
8189/**---------------------------------------------------------------------------
8190
8191 \brief hdd_post_voss_start_config() - HDD post voss start config helper
8192
8193 \param - pAdapter - Pointer to the HDD
8194
8195 \return - None
8196
8197 --------------------------------------------------------------------------*/
8198VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx)
8199{
8200 eHalStatus halStatus;
8201 v_U32_t listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308202 tANI_U32 ignoreDtim;
Jeff Johnson295189b2012-06-20 16:38:30 -07008203
Jeff Johnson295189b2012-06-20 16:38:30 -07008204
8205 // Send ready indication to the HDD. This will kick off the MAC
8206 // into a 'running' state and should kick off an initial scan.
8207 halStatus = sme_HDDReadyInd( pHddCtx->hHal );
8208 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8209 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308210 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status "
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 "code %08d [x%08x]",__func__, halStatus, halStatus );
8212 return VOS_STATUS_E_FAILURE;
8213 }
8214
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308215 // Set default LI and ignoreDtim into HDD context,
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 // otherwise under some race condition, HDD will set 0 LI value into RIVA,
8217 // And RIVA will crash
8218 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval);
8219 pHddCtx->hdd_actual_LI_value = listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308220 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim);
8221 pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim;
8222
8223
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 return VOS_STATUS_SUCCESS;
8225}
8226
Jeff Johnson295189b2012-06-20 16:38:30 -07008227/* wake lock APIs for HDD */
8228void hdd_prevent_suspend(void)
8229{
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008230#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 wake_lock(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008232#else
8233 wcnss_prevent_suspend();
8234#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008235}
8236
8237void hdd_allow_suspend(void)
8238{
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008239#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 wake_unlock(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008241#else
8242 wcnss_allow_suspend();
8243#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008244}
8245
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05308246void hdd_prevent_suspend_timeout(v_U32_t timeout)
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008247{
Sameer Thalappil50dc0092013-02-19 17:23:33 -08008248#ifdef WLAN_OPEN_SOURCE
Amar Singhal6144c002013-05-03 16:11:42 -07008249 wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout));
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008250#else
8251 /* Do nothing as there is no API in wcnss for timeout*/
8252#endif
8253}
8254
Jeff Johnson295189b2012-06-20 16:38:30 -07008255/**---------------------------------------------------------------------------
8256
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008257 \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability
8258 information between Host and Riva
8259
8260 This function gets reported version of FW
8261 It also finds the version of Riva headers used to compile the host
8262 It compares the above two and prints a warning if they are different
8263 It gets the SW and HW version string
8264 Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg
8265 indicating the features they support through a bitmap
8266
8267 \param - pHddCtx - Pointer to HDD context
8268
8269 \return - void
8270
8271 --------------------------------------------------------------------------*/
8272
8273void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx)
8274{
8275
8276 tSirVersionType versionCompiled;
8277 tSirVersionType versionReported;
8278 tSirVersionString versionString;
8279 tANI_U8 fwFeatCapsMsgSupported = 0;
8280 VOS_STATUS vstatus;
8281
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008282 memset(&versionCompiled, 0, sizeof(versionCompiled));
8283 memset(&versionReported, 0, sizeof(versionReported));
8284
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008285 /* retrieve and display WCNSS version information */
8286 do {
8287
8288 vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal,
8289 &versionCompiled);
8290 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8291 {
8292 hddLog(VOS_TRACE_LEVEL_FATAL,
8293 "%s: unable to retrieve WCNSS WLAN compiled version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008294 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008295 break;
8296 }
8297
8298 vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal,
8299 &versionReported);
8300 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8301 {
8302 hddLog(VOS_TRACE_LEVEL_FATAL,
8303 "%s: unable to retrieve WCNSS WLAN reported version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008304 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008305 break;
8306 }
8307
8308 if ((versionCompiled.major != versionReported.major) ||
8309 (versionCompiled.minor != versionReported.minor) ||
8310 (versionCompiled.version != versionReported.version) ||
8311 (versionCompiled.revision != versionReported.revision))
8312 {
8313 pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, "
8314 "Host expected %u.%u.%u.%u\n",
8315 WLAN_MODULE_NAME,
8316 (int)versionReported.major,
8317 (int)versionReported.minor,
8318 (int)versionReported.version,
8319 (int)versionReported.revision,
8320 (int)versionCompiled.major,
8321 (int)versionCompiled.minor,
8322 (int)versionCompiled.version,
8323 (int)versionCompiled.revision);
8324 }
8325 else
8326 {
8327 pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n",
8328 WLAN_MODULE_NAME,
8329 (int)versionReported.major,
8330 (int)versionReported.minor,
8331 (int)versionReported.version,
8332 (int)versionReported.revision);
8333 }
8334
8335 vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal,
8336 versionString,
8337 sizeof(versionString));
8338 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8339 {
8340 hddLog(VOS_TRACE_LEVEL_FATAL,
8341 "%s: unable to retrieve WCNSS software version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008342 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008343 break;
8344 }
8345
8346 pr_info("%s: WCNSS software version %s\n",
8347 WLAN_MODULE_NAME, versionString);
8348
8349 vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal,
8350 versionString,
8351 sizeof(versionString));
8352 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8353 {
8354 hddLog(VOS_TRACE_LEVEL_FATAL,
8355 "%s: unable to retrieve WCNSS hardware version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008356 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008357 break;
8358 }
8359
8360 pr_info("%s: WCNSS hardware version %s\n",
8361 WLAN_MODULE_NAME, versionString);
8362
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008363 /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message
8364 2.Host-FW capability exchange message is only present on riva 1.1 so
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008365 send the message only if it the riva is 1.1
8366 minor numbers for different riva branches:
8367 0 -> (1.0)Mainline Build
8368 1 -> (1.1)Mainline Build
8369 2->(1.04) Stability Build
8370 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008371 if (((versionReported.major>0) || (versionReported.minor>1) ||
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008372 ((versionReported.minor>=1) && (versionReported.version>=1)))
8373 && ((versionReported.major == 1) && (versionReported.minor >= 1)))
8374 fwFeatCapsMsgSupported = 1;
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008375
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008376 if (fwFeatCapsMsgSupported)
Yathish9f22e662012-12-10 14:21:35 -08008377 {
8378#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
8379 if(!pHddCtx->cfg_ini->fEnableActiveModeOffload)
8380 sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD);
8381#endif
Ravi Joshid2ca7c42013-07-23 08:37:49 -07008382 /* Indicate if IBSS heartbeat monitoring needs to be offloaded */
8383 if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload)
8384 {
8385 sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD);
8386 }
8387
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008388 sme_featureCapsExchange(pHddCtx->hHal);
Yathish9f22e662012-12-10 14:21:35 -08008389 }
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008390
8391 } while (0);
8392
8393}
Neelansh Mittaledafed22014-09-04 18:54:39 +05308394void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len)
8395{
8396 struct sk_buff *skb;
8397 struct nlmsghdr *nlh;
8398 tAniMsgHdr *ani_hdr;
8399
8400 skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), GFP_KERNEL);
8401
8402 if(skb == NULL) {
8403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8404 "%s: alloc_skb failed", __func__);
8405 return;
8406 }
8407
8408 nlh = (struct nlmsghdr *)skb->data;
8409 nlh->nlmsg_pid = 0; /* from kernel */
8410 nlh->nlmsg_flags = 0;
8411 nlh->nlmsg_seq = 0;
8412 nlh->nlmsg_type = WLAN_NL_MSG_SVC;
8413
8414 ani_hdr = NLMSG_DATA(nlh);
8415 ani_hdr->type = type;
8416
8417 switch(type) {
8418 case WLAN_SVC_SAP_RESTART_IND:
8419 ani_hdr->length = 0;
8420 nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr)));
8421 skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr)));
8422 break;
8423 default:
8424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8425 "Attempt to send unknown nlink message %d", type);
8426 kfree_skb(skb);
8427 return;
8428 }
8429
8430 nl_srv_bcast(skb);
8431
8432 return;
8433}
8434
8435
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008436
8437/**---------------------------------------------------------------------------
8438
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05308439 \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz
8440
8441 \param - pHddCtx - Pointer to the hdd context
8442
8443 \return - true if hardware supports 5GHz
8444
8445 --------------------------------------------------------------------------*/
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05308446boolean hdd_is_5g_supported(hdd_context_t * pHddCtx)
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05308447{
8448 /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1);
8449 * then hardware support 5Ghz.
8450 */
8451 if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode())
8452 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308453 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05308454 return true;
8455 }
8456 else
8457 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308458 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz",
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05308459 __func__);
8460 return false;
8461 }
8462}
8463
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308464/**---------------------------------------------------------------------------
8465
8466 \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto
8467 generate function
8468
8469 This is generate the random mac address for WLAN interface
8470
8471 \param - pHddCtx - Pointer to HDD context
8472 idx - Start interface index to get auto
8473 generated mac addr.
8474 mac_addr - Mac address
8475
8476 \return - 0 for success, < 0 for failure
8477
8478 --------------------------------------------------------------------------*/
8479
8480static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx,
8481 int idx, v_MACADDR_t mac_addr)
8482{
8483 int i;
8484 unsigned int serialno;
8485 serialno = wcnss_get_serial_number();
8486
8487 if (0 != serialno)
8488 {
8489 /* MAC address has 3 bytes of OUI so we have a maximum of 3
8490 bytes of the serial number that can be used to generate
8491 the other 3 bytes of the MAC address. Mask off all but
8492 the lower 3 bytes (this will also make sure we don't
8493 overflow in the next step) */
8494 serialno &= 0x00FFFFFF;
8495
8496 /* we need a unique address for each session */
8497 serialno *= VOS_MAX_CONCURRENCY_PERSONA;
8498
8499 /* autogen other Mac addresses */
8500 for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
8501 {
8502 /* start with the entire default address */
8503 pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr;
8504 /* then replace the lower 3 bytes */
8505 pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF;
8506 pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF;
8507 pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF;
8508
8509 serialno++;
8510 hddLog(VOS_TRACE_LEVEL_ERROR,
8511 "%s: Derived Mac Addr: "
8512 MAC_ADDRESS_STR, __func__,
8513 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes));
8514 }
8515
8516 }
8517 else
8518 {
8519 hddLog(LOGE, FL("Failed to Get Serial NO"));
8520 return -1;
8521 }
8522 return 0;
8523}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05308524
8525/**---------------------------------------------------------------------------
8526
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05308527 \brief hdd_11d_scan_done - callback to be executed when 11d scan is
8528 completed to flush out the scan results
8529
8530 11d scan is done during driver load and is a passive scan on all
8531 channels supported by the device, 11d scans may find some APs on
8532 frequencies which are forbidden to be used in the regulatory domain
8533 the device is operating in. If these APs are notified to the supplicant
8534 it may try to connect to these APs, thus flush out all the scan results
8535 which are present in SME after 11d scan is done.
8536
8537 \return - eHalStatus
8538
8539 --------------------------------------------------------------------------*/
8540static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext,
8541 tANI_U32 scanId, eCsrScanStatus status)
8542{
8543 ENTER();
8544
8545 sme_ScanFlushResult(halHandle, 0);
8546
8547 EXIT();
8548
8549 return eHAL_STATUS_SUCCESS;
8550}
8551
8552/**---------------------------------------------------------------------------
8553
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 \brief hdd_wlan_startup() - HDD init function
8555
8556 This is the driver startup code executed once a WLAN device has been detected
8557
8558 \param - dev - Pointer to the underlying device
8559
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08008560 \return - 0 for success, < 0 for failure
Jeff Johnson295189b2012-06-20 16:38:30 -07008561
8562 --------------------------------------------------------------------------*/
8563
8564int hdd_wlan_startup(struct device *dev )
8565{
8566 VOS_STATUS status;
8567 hdd_adapter_t *pAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008568 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 hdd_context_t *pHddCtx = NULL;
8570 v_CONTEXT_t pVosContext= NULL;
8571#ifdef WLAN_BTAMP_FEATURE
8572 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
8573 WLANBAP_ConfigType btAmpConfig;
8574 hdd_config_t *pConfig;
8575#endif
8576 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 struct wiphy *wiphy;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308578 v_MACADDR_t mac_addr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008579
8580 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008581 /*
8582 * cfg80211: wiphy allocation
8583 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308584 wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07008585
8586 if(wiphy == NULL)
8587 {
8588 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08008589 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 }
8591
8592 pHddCtx = wiphy_priv(wiphy);
8593
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 //Initialize the adapter context to zeros.
8595 vos_mem_zero(pHddCtx, sizeof( hdd_context_t ));
8596
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 pHddCtx->wiphy = wiphy;
Jeff Johnson295189b2012-06-20 16:38:30 -07008598 hdd_prevent_suspend();
Mihir Shete18156292014-03-11 15:38:30 +05308599 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008600
8601 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
8602
8603 /*Get vos context here bcoz vos_open requires it*/
8604 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
8605
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08008606 if(pVosContext == NULL)
8607 {
8608 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__);
8609 goto err_free_hdd_context;
8610 }
8611
Jeff Johnson295189b2012-06-20 16:38:30 -07008612 //Save the Global VOSS context in adapter context for future.
8613 pHddCtx->pvosContext = pVosContext;
8614
8615 //Save the adapter context in global context for future.
8616 ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx;
8617
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 pHddCtx->parent_dev = dev;
8619
8620 init_completion(&pHddCtx->full_pwr_comp_var);
8621 init_completion(&pHddCtx->standby_comp_var);
8622 init_completion(&pHddCtx->req_bmps_comp_var);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008623 init_completion(&pHddCtx->scan_info.scan_req_completion_event);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08008624 init_completion(&pHddCtx->scan_info.abortscan_event_var);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05308625 init_completion(&pHddCtx->wiphy_channel_update_event);
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05308626 init_completion(&pHddCtx->ssr_comp_var);
Amar Singhala49cbc52013-10-08 18:37:44 -07008627
8628#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhalfddc28c2013-09-05 13:03:40 -07008629 init_completion(&pHddCtx->linux_reg_req);
Amar Singhala49cbc52013-10-08 18:37:44 -07008630#else
8631 init_completion(&pHddCtx->driver_crda_req);
8632#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008633
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308634 spin_lock_init(&pHddCtx->schedScan_lock);
8635
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS );
8637
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308638#ifdef FEATURE_WLAN_TDLS
8639 /* tdls_lock is initialized before an hdd_open_adapter ( which is
8640 * invoked by other instances also) to protect the concurrent
8641 * access for the Adapters by TDLS module.
8642 */
8643 mutex_init(&pHddCtx->tdls_lock);
8644#endif
Siddharth Bhal76972212014-10-15 16:22:51 +05308645 mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock);
Agarwal Ashish1f422872014-07-22 00:11:55 +05308646 /* By default Strict Regulatory For FCC should be false */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308647
Agarwal Ashish1f422872014-07-22 00:11:55 +05308648 pHddCtx->nEnableStrictRegulatoryForFCC = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 // Load all config first as TL config is needed during vos_open
8650 pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL);
8651 if(pHddCtx->cfg_ini == NULL)
8652 {
8653 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__);
8654 goto err_free_hdd_context;
8655 }
8656
8657 vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t ));
8658
8659 // Read and parse the qcom_cfg.ini file
8660 status = hdd_parse_config_ini( pHddCtx );
8661 if ( VOS_STATUS_SUCCESS != status )
8662 {
8663 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s",
8664 __func__, WLAN_INI_FILE);
8665 goto err_config;
8666 }
Arif Hussaind5218912013-12-05 01:10:55 -08008667#ifdef MEMORY_DEBUG
8668 if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled)
8669 vos_mem_init();
8670
8671 hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d",
8672 __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled);
8673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008674
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308675 /* INI has been read, initialise the configuredMcastBcastFilter with
8676 * INI value as this will serve as the default value
8677 */
8678 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
8679 hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d",
8680 pHddCtx->cfg_ini->mcastBcastFilterSetting);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05308681
8682 if (false == hdd_is_5g_supported(pHddCtx))
8683 {
8684 //5Ghz is not supported.
8685 if (1 != pHddCtx->cfg_ini->nBandCapability)
8686 {
8687 hddLog(VOS_TRACE_LEVEL_INFO,
8688 "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__);
8689 pHddCtx->cfg_ini->nBandCapability = 1;
8690 }
8691 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308692
8693 /* If SNR Monitoring is enabled, FW has to parse all beacons
8694 * for calcaluting and storing the average SNR, so set Nth beacon
8695 * filter to 1 to enable FW to parse all the beaocons
8696 */
8697 if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring)
8698 {
8699 /* The log level is deliberately set to WARN as overriding
8700 * nthBeaconFilter to 1 will increase power cosumption and this
8701 * might just prove helpful to detect the power issue.
8702 */
8703 hddLog(VOS_TRACE_LEVEL_WARN,
8704 "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__);
8705 pHddCtx->cfg_ini->nthBeaconFilter = 1;
8706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 /*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308708 * cfg80211: Initialization ...
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 */
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08008710 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 {
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08008712 if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini))
8713 {
8714 hddLog(VOS_TRACE_LEVEL_FATAL,
8715 "%s: wlan_hdd_cfg80211_init return failure", __func__);
8716 goto err_config;
8717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008719
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008720 // Update VOS trace levels based upon the cfg.ini
8721 hdd_vos_trace_enable(VOS_MODULE_ID_BAP,
8722 pHddCtx->cfg_ini->vosTraceEnableBAP);
8723 hdd_vos_trace_enable(VOS_MODULE_ID_TL,
8724 pHddCtx->cfg_ini->vosTraceEnableTL);
8725 hdd_vos_trace_enable(VOS_MODULE_ID_WDI,
8726 pHddCtx->cfg_ini->vosTraceEnableWDI);
8727 hdd_vos_trace_enable(VOS_MODULE_ID_HDD,
8728 pHddCtx->cfg_ini->vosTraceEnableHDD);
8729 hdd_vos_trace_enable(VOS_MODULE_ID_SME,
8730 pHddCtx->cfg_ini->vosTraceEnableSME);
8731 hdd_vos_trace_enable(VOS_MODULE_ID_PE,
8732 pHddCtx->cfg_ini->vosTraceEnablePE);
Katya Nigam70d68332013-09-16 16:49:45 +05308733 hdd_vos_trace_enable(VOS_MODULE_ID_PMC,
8734 pHddCtx->cfg_ini->vosTraceEnablePMC);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008735 hdd_vos_trace_enable(VOS_MODULE_ID_WDA,
8736 pHddCtx->cfg_ini->vosTraceEnableWDA);
8737 hdd_vos_trace_enable(VOS_MODULE_ID_SYS,
8738 pHddCtx->cfg_ini->vosTraceEnableSYS);
8739 hdd_vos_trace_enable(VOS_MODULE_ID_VOSS,
8740 pHddCtx->cfg_ini->vosTraceEnableVOSS);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008741 hdd_vos_trace_enable(VOS_MODULE_ID_SAP,
8742 pHddCtx->cfg_ini->vosTraceEnableSAP);
8743 hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP,
8744 pHddCtx->cfg_ini->vosTraceEnableHDDSAP);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08008745
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 // Update WDI trace levels based upon the cfg.ini
8747 hdd_wdi_trace_enable(eWLAN_MODULE_DAL,
8748 pHddCtx->cfg_ini->wdiTraceEnableDAL);
8749 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL,
8750 pHddCtx->cfg_ini->wdiTraceEnableCTL);
8751 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA,
8752 pHddCtx->cfg_ini->wdiTraceEnableDAT);
8753 hdd_wdi_trace_enable(eWLAN_MODULE_PAL,
8754 pHddCtx->cfg_ini->wdiTraceEnablePAL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008755
Jeff Johnson88ba7742013-02-27 14:36:02 -08008756 if (VOS_FTM_MODE == hdd_get_conparam())
8757 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) )
8759 {
8760 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__);
8761 goto err_free_hdd_context;
8762 }
8763 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__);
c_hpothu2de0ef62014-04-15 16:16:15 +05308764
8765 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 return VOS_STATUS_SUCCESS;
Jeff Johnson88ba7742013-02-27 14:36:02 -08008767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008768
Jeff Johnson88ba7742013-02-27 14:36:02 -08008769 //Open watchdog module
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8771 {
8772 status = vos_watchdog_open(pVosContext,
8773 &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext));
8774
8775 if(!VOS_IS_STATUS_SUCCESS( status ))
8776 {
8777 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308778 goto err_wdclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
8780 }
8781
8782 pHddCtx->isLogpInProgress = FALSE;
8783 vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE);
8784
Amar Singhala49cbc52013-10-08 18:37:44 -07008785#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07008786 /* initialize the NV module. This is required so that
8787 we can initialize the channel information in wiphy
8788 from the NV.bin data. The channel information in
8789 wiphy needs to be initialized before wiphy registration */
8790
8791 status = vos_nv_open();
8792 if (!VOS_IS_STATUS_SUCCESS(status))
8793 {
8794 /* NV module cannot be initialized */
8795 hddLog( VOS_TRACE_LEVEL_FATAL,
8796 "%s: vos_nv_open failed", __func__);
Vinay Krishna Eranna2025d892014-09-18 16:51:42 +05308797 goto err_wdclose;
Amar Singhal0a402232013-10-11 20:57:16 -07008798 }
8799
8800 status = vos_init_wiphy_from_nv_bin();
8801 if (!VOS_IS_STATUS_SUCCESS(status))
8802 {
8803 /* NV module cannot be initialized */
8804 hddLog( VOS_TRACE_LEVEL_FATAL,
8805 "%s: vos_init_wiphy failed", __func__);
8806 goto err_vos_nv_close;
8807 }
8808
Amar Singhala49cbc52013-10-08 18:37:44 -07008809#endif
8810
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +05308811 status = vos_open( &pVosContext, pHddCtx->parent_dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 if ( !VOS_IS_STATUS_SUCCESS( status ))
8813 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008814 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05308815 goto err_vos_nv_close;
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 }
8817
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext );
8819
8820 if ( NULL == pHddCtx->hHal )
8821 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008822 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008823 goto err_vosclose;
8824 }
8825
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008826 status = vos_preStart( pHddCtx->pvosContext );
8827 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8828 {
8829 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05308830 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008831 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008832
Arif Hussaineaf68602013-12-30 23:10:44 -08008833 if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan)
8834 {
8835 pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan;
8836 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d",
8837 __func__, enable_dfs_chan_scan);
8838 }
8839 if (0 == enable_11d || 1 == enable_11d)
8840 {
8841 pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d;
8842 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d",
8843 __func__, enable_11d);
8844 }
8845
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008846 /* Note that the vos_preStart() sequence triggers the cfg download.
8847 The cfg download must occur before we update the SME config
8848 since the SME config operation must access the cfg database */
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 status = hdd_set_sme_config( pHddCtx );
8850
8851 if ( VOS_STATUS_SUCCESS != status )
8852 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008853 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05308854 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 /* In the integrated architecture we update the configuration from
8858 the INI file and from NV before vOSS has been started so that
8859 the final contents are available to send down to the cCPU */
8860
8861 // Apply the cfg.ini to cfg.dat
8862 if (FALSE == hdd_update_config_dat(pHddCtx))
8863 {
8864 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05308865 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 }
8867
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308868 // Get mac addr from platform driver
8869 ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes);
8870
8871 if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308873 /* Store the mac addr for first interface */
8874 pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr;
8875
8876 hddLog(VOS_TRACE_LEVEL_ERROR,
8877 "%s: WLAN Mac Addr: "
8878 MAC_ADDRESS_STR, __func__,
8879 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
8880
8881 /* Here, passing Arg2 as 1 because we do not want to change the
8882 last 3 bytes (means non OUI bytes) of first interface mac
8883 addr.
8884 */
8885 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr))
8886 {
8887 hddLog(VOS_TRACE_LEVEL_ERROR,
8888 "%s: Failed to generate wlan interface mac addr "
8889 "using MAC from ini file ", __func__);
8890 }
8891 }
8892 else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx))
8893 {
8894 // Apply the NV to cfg.dat
8895 /* Prima Update MAC address only at here */
Jeff Johnson295189b2012-06-20 16:38:30 -07008896#ifdef WLAN_AUTOGEN_MACADDR_FEATURE
8897 /* There was not a valid set of MAC Addresses in NV. See if the
8898 default addresses were modified by the cfg.ini settings. If so,
8899 we'll use them, but if not, we'll autogenerate a set of MAC
8900 addresses based upon the device serial number */
8901
8902 static const v_MACADDR_t default_address =
8903 {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}};
Jeff Johnson295189b2012-06-20 16:38:30 -07008904
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308905 if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0],
8906 sizeof(default_address)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 {
8908 /* cfg.ini has the default address, invoke autogen logic */
8909
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308910 /* Here, passing Arg2 as 0 because we want to change the
8911 last 3 bytes (means non OUI bytes) of all the interfaces
8912 mac addr.
8913 */
8914 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0,
8915 default_address))
Jeff Johnson295189b2012-06-20 16:38:30 -07008916 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308917 hddLog(VOS_TRACE_LEVEL_ERROR,
8918 "%s: Failed to generate wlan interface mac addr "
8919 "using MAC from ini file " MAC_ADDRESS_STR, __func__,
8920 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 }
8923 else
8924#endif //WLAN_AUTOGEN_MACADDR_FEATURE
8925 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08008926 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 "%s: Invalid MAC address in NV, using MAC from ini file "
8928 MAC_ADDRESS_STR, __func__,
8929 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
8930 }
8931 }
8932 {
8933 eHalStatus halStatus;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308934
8935 /* Set the MAC Address Currently this is used by HAL to
8936 * add self sta. Remove this once self sta is added as
8937 * part of session open.
8938 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008939 halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID,
8940 (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0],
8941 sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) );
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05308942
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 if (!HAL_STATUS_SUCCESS( halStatus ))
8944 {
8945 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. "
8946 "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05308947 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07008948 }
8949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008950
8951 /*Start VOSS which starts up the SME/MAC/HAL modules and everything else
8952 Note: Firmware image will be read and downloaded inside vos_start API */
8953 status = vos_start( pHddCtx->pvosContext );
8954 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8955 {
8956 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05308957 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07008958 }
8959
Leo Chang6cec3e22014-01-21 15:33:49 -08008960#ifdef FEATURE_WLAN_CH_AVOID
8961 /* Plug in avoid channel notification callback
8962 * This should happen before ADD_SELF_STA
8963 * FW will send first IND with ADD_SELF_STA REQ from host */
Pradeep Reddy POTTETI5c2e16d2014-06-27 16:47:38 +05308964
8965 /* check the Channel Avoidance is enabled */
8966 if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance)
8967 {
8968 sme_AddChAvoidCallback(pHddCtx->hHal,
8969 hdd_hostapd_ch_avoid_cb);
8970 }
Leo Chang6cec3e22014-01-21 15:33:49 -08008971#endif /* FEATURE_WLAN_CH_AVOID */
8972
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008973 /* Exchange capability info between Host and FW and also get versioning info from FW */
8974 hdd_exchange_version_and_caps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008975
Agarwal Ashishad9281b2014-06-10 14:57:30 +05308976#ifdef CONFIG_ENABLE_LINUX_REG
8977 status = wlan_hdd_init_channels(pHddCtx);
8978 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8979 {
8980 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed",
8981 __func__);
8982 goto err_vosstop;
8983 }
8984#endif
8985
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 status = hdd_post_voss_start_config( pHddCtx );
8987 if ( !VOS_IS_STATUS_SUCCESS( status ) )
8988 {
8989 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed",
8990 __func__);
8991 goto err_vosstop;
8992 }
Amar Singhala49cbc52013-10-08 18:37:44 -07008993
8994#ifndef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308995 wlan_hdd_cfg80211_update_reg_info( wiphy );
8996
8997 /* registration of wiphy dev with cfg80211 */
8998 if (0 > wlan_hdd_cfg80211_register(wiphy))
8999 {
9000 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9001 goto err_vosstop;
9002 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009003#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009004
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309005#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309006 /* registration of wiphy dev with cfg80211 */
9007 if (0 > wlan_hdd_cfg80211_register(wiphy))
9008 {
9009 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9010 goto err_vosstop;
9011 }
9012
Agarwal Ashish6db9d532014-09-30 18:19:10 +05309013 status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309014 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9015 {
9016 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed",
9017 __func__);
9018 goto err_unregister_wiphy;
9019 }
9020#endif
9021
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 if (VOS_STA_SAP_MODE == hdd_get_conparam())
9023 {
9024 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d",
9025 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9026 }
9027 else
9028 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d",
9030 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9031 if (pAdapter != NULL)
9032 {
kaidde69982014-06-18 13:23:21 +08009033 if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && !(pHddCtx->cfg_ini->intfMacAddr[0].bytes[0] &= 0x02))
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309035 vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes,
9036 pHddCtx->cfg_ini->intfMacAddr[0].bytes,
9037 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudiedfc1b72012-10-18 20:25:55 -07009038
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309039 /* Generate the P2P Device Address. This consists of the device's
9040 * primary MAC address with the locally administered bit set.
9041 */
9042 pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02;
Jeff Johnsone7245742012-09-05 17:12:55 -07009043 }
9044 else
9045 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309046 tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx);
9047 if (p2p_dev_addr != NULL)
9048 {
9049 vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0],
9050 p2p_dev_addr, VOS_MAC_ADDR_SIZE);
9051 }
9052 else
9053 {
9054 hddLog(VOS_TRACE_LEVEL_FATAL,
9055 "%s: Failed to allocate mac_address for p2p_device",
9056 __func__);
9057 goto err_close_adapter;
9058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009060
9061 pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d",
9062 &pHddCtx->p2pDeviceAddress.bytes[0], FALSE );
9063 if ( NULL == pP2pAdapter )
9064 {
9065 hddLog(VOS_TRACE_LEVEL_FATAL,
9066 "%s: Failed to do hdd_open_adapter for P2P Device Interface",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009067 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009068 goto err_close_adapter;
9069 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009072
9073 if( pAdapter == NULL )
9074 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009075 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9076 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009078
Arif Hussain66559122013-11-21 10:11:40 -08009079 if (country_code)
9080 {
9081 eHalStatus ret;
Arif Hussaincb607082013-12-20 11:57:42 -08009082 INIT_COMPLETION(pAdapter->change_country_code);
Arif Hussain66559122013-11-21 10:11:40 -08009083 hdd_checkandupdate_dfssetting(pAdapter, country_code);
9084#ifndef CONFIG_ENABLE_LINUX_REG
9085 hdd_checkandupdate_phymode(pAdapter, country_code);
9086#endif
Arif Hussaineaf68602013-12-30 23:10:44 -08009087 ret = sme_ChangeCountryCode(pHddCtx->hHal,
9088 (void *)(tSmeChangeCountryCallback)
9089 wlan_hdd_change_country_code_callback,
Arif Hussain66559122013-11-21 10:11:40 -08009090 country_code,
9091 pAdapter, pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05309092 eSIR_TRUE, eSIR_TRUE);
Arif Hussain66559122013-11-21 10:11:40 -08009093 if (eHAL_STATUS_SUCCESS == ret)
9094 {
Arif Hussaincb607082013-12-20 11:57:42 -08009095 ret = wait_for_completion_interruptible_timeout(
9096 &pAdapter->change_country_code,
9097 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
9098
9099 if (0 >= ret)
9100 {
9101 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9102 "%s: SME while setting country code timed out", __func__);
9103 }
Arif Hussain66559122013-11-21 10:11:40 -08009104 }
9105 else
9106 {
Arif Hussaincb607082013-12-20 11:57:42 -08009107 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9108 "%s: SME Change Country code from module param fail ret=%d",
9109 __func__, ret);
Arif Hussain66559122013-11-21 10:11:40 -08009110 }
9111 }
9112
Jeff Johnson295189b2012-06-20 16:38:30 -07009113#ifdef WLAN_BTAMP_FEATURE
9114 vStatus = WLANBAP_Open(pVosContext);
9115 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9116 {
9117 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9118 "%s: Failed to open BAP",__func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009119 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 }
9121
9122 vStatus = BSL_Init(pVosContext);
9123 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9124 {
9125 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9126 "%s: Failed to Init BSL",__func__);
9127 goto err_bap_close;
9128 }
9129 vStatus = WLANBAP_Start(pVosContext);
9130 if (!VOS_IS_STATUS_SUCCESS(vStatus))
9131 {
9132 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9133 "%s: Failed to start TL",__func__);
9134 goto err_bap_close;
9135 }
9136
9137 pConfig = pHddCtx->cfg_ini;
9138 btAmpConfig.ucPreferredChannel = pConfig->preferredChannel;
9139 status = WLANBAP_SetConfig(&btAmpConfig);
9140
9141#endif //WLAN_BTAMP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -07009142
Mihir Shete9c238772014-10-15 14:35:16 +05309143 /*
9144 * UapsdMask is 0xf if U-APSD is enbaled for all AC's...
9145 * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value)
9146 * which is greater than 0xf. So the below check is safe to make
9147 * sure that there is no entry for UapsdMask in the ini
9148 */
9149 if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask)
9150 {
9151 if(IS_DYNAMIC_WMM_PS_ENABLED)
9152 {
9153 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO",
9154 __func__);
9155 pHddCtx->cfg_ini->UapsdMask =
9156 CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT;
9157 }
9158 else
9159 {
9160 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD",
9161 __func__);
9162 pHddCtx->cfg_ini->UapsdMask =
9163 CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT;
9164 }
9165 }
9166
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009167#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9168 if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE))
9169 {
9170 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__);
9171 pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0;
9172 sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal),
9173 pHddCtx->cfg_ini->isRoamOffloadScanEnabled);
9174 }
9175#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009176
Agarwal Ashish4b87f922014-06-18 03:03:21 +05309177 wlan_hdd_tdls_init(pHddCtx);
9178
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309179 sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done);
9180
Jeff Johnson295189b2012-06-20 16:38:30 -07009181 /* Register with platform driver as client for Suspend/Resume */
9182 status = hddRegisterPmOps(pHddCtx);
9183 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9184 {
9185 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__);
9186#ifdef WLAN_BTAMP_FEATURE
9187 goto err_bap_stop;
9188#else
Jeff Johnsone7245742012-09-05 17:12:55 -07009189 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009190#endif //WLAN_BTAMP_FEATURE
9191 }
9192
Yue Ma0d4891e2013-08-06 17:01:45 -07009193 /* Open debugfs interface */
9194 if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter))
9195 {
9196 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9197 "%s: hdd_debugfs_init failed!", __func__);
Yue Ma0d4891e2013-08-06 17:01:45 -07009198 }
9199
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 /* Register TM level change handler function to the platform */
9201 status = hddDevTmRegisterNotifyCallback(pHddCtx);
9202 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9203 {
9204 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__);
9205 goto err_unregister_pmops;
9206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009207
9208 /* register for riva power on lock to platform driver */
9209 if (req_riva_power_on_lock("wlan"))
9210 {
9211 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed",
9212 __func__);
9213 goto err_unregister_pmops;
9214 }
9215
Jeff Johnson295189b2012-06-20 16:38:30 -07009216 // register net device notifier for device change notification
9217 ret = register_netdevice_notifier(&hdd_netdev_notifier);
9218
9219 if(ret < 0)
9220 {
9221 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__);
9222 goto err_free_power_on_lock;
9223 }
9224
9225 //Initialize the nlink service
9226 if(nl_srv_init() != 0)
9227 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309228 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 goto err_reg_netdev;
9230 }
9231
Leo Chang4ce1cc52013-10-21 18:27:15 -07009232#ifdef WLAN_KD_READY_NOTIFIER
9233 pHddCtx->kd_nl_init = 1;
9234#endif /* WLAN_KD_READY_NOTIFIER */
9235
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 //Initialize the BTC service
9237 if(btc_activate_service(pHddCtx) != 0)
9238 {
9239 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__);
9240 goto err_nl_srv;
9241 }
9242
9243#ifdef PTT_SOCK_SVC_ENABLE
9244 //Initialize the PTT service
9245 if(ptt_sock_activate_svc(pHddCtx) != 0)
9246 {
9247 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__);
9248 goto err_nl_srv;
9249 }
9250#endif
9251
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05309252#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
9253 if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable)
9254 {
9255 if(wlan_logging_sock_activate_svc(
9256 pHddCtx->cfg_ini->wlanLoggingFEToConsole,
9257 pHddCtx->cfg_ini->wlanLoggingNumBuf))
9258 {
9259 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc"
9260 " failed", __func__);
9261 goto err_nl_srv;
9262 }
9263 }
9264#endif
9265
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 hdd_register_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 if (VOS_STA_SAP_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07009268 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07009269 /* Action frame registered in one adapter which will
9270 * applicable to all interfaces
9271 */
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05309272 wlan_hdd_cfg80211_register_frames(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009274
9275 mutex_init(&pHddCtx->sap_lock);
Mahesh A Saptasagar60627942014-10-13 13:55:14 +05309276 mutex_init(&pHddCtx->roc_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07009277
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
Sameer Thalappil50dc0092013-02-19 17:23:33 -08009279#ifdef WLAN_OPEN_SOURCE
Jeff Johnsone7245742012-09-05 17:12:55 -07009280#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
9281 /* Initialize the wake lcok */
9282 wake_lock_init(&pHddCtx->rx_wake_lock,
9283 WAKE_LOCK_SUSPEND,
9284 "qcom_rx_wakelock");
9285#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08009286 /* Initialize the wake lcok */
9287 wake_lock_init(&pHddCtx->sap_wake_lock,
9288 WAKE_LOCK_SUSPEND,
9289 "qcom_sap_wakelock");
Sameer Thalappil50dc0092013-02-19 17:23:33 -08009290#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009291
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009292 vos_event_init(&pHddCtx->scan_info.scan_finished_event);
9293 pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009294
Katya Nigam5c306ea2014-06-19 15:39:54 +05309295 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9297 hdd_allow_suspend();
Katya Nigam5c306ea2014-06-19 15:39:54 +05309298
9299#ifdef FEATURE_WLAN_SCAN_PNO
9300 /*SME must send channel update configuration to RIVA*/
9301 sme_UpdateChannelConfig(pHddCtx->hHal);
9302#endif
Abhishek Singhf644b272014-08-21 02:59:39 +05309303 /* Send the update default channel list to the FW*/
9304 sme_UpdateChannelList(pHddCtx->hHal);
Abhishek Singha306a442013-11-07 18:39:01 +05309305#ifndef CONFIG_ENABLE_LINUX_REG
9306 /*updating wiphy so that regulatory user hints can be processed*/
9307 if (wiphy)
9308 {
9309 regulatory_hint(wiphy, "00");
9310 }
9311#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009312 // Initialize the restart logic
9313 wlan_hdd_restart_init(pHddCtx);
Chilam NG571c65a2013-01-19 12:27:36 +05309314
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07009315 //Register the traffic monitor timer now
9316 if ( pHddCtx->cfg_ini->dynSplitscan)
9317 {
9318 vos_timer_init(&pHddCtx->tx_rx_trafficTmr,
9319 VOS_TIMER_TYPE_SW,
9320 hdd_tx_rx_pkt_cnt_stat_timer_handler,
9321 (void *)pHddCtx);
9322 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05309323#ifdef WLAN_FEATURE_EXTSCAN
9324 sme_EXTScanRegisterCallback(pHddCtx->hHal,
9325 wlan_hdd_cfg80211_extscan_callback,
9326 pHddCtx);
9327#endif /* WLAN_FEATURE_EXTSCAN */
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 goto success;
9329
9330err_nl_srv:
Leo Chang59cdc7e2013-07-10 10:08:21 -07009331#ifdef WLAN_KD_READY_NOTIFIER
9332 nl_srv_exit(pHddCtx->ptt_pid);
9333#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -07009335#endif /* WLAN_KD_READY_NOTIFIER */
Jeff Johnson295189b2012-06-20 16:38:30 -07009336err_reg_netdev:
9337 unregister_netdevice_notifier(&hdd_netdev_notifier);
9338
9339err_free_power_on_lock:
9340 free_riva_power_on_lock("wlan");
9341
9342err_unregister_pmops:
9343 hddDevTmUnregisterNotifyCallback(pHddCtx);
9344 hddDeregisterPmOps(pHddCtx);
9345
Yue Ma0d4891e2013-08-06 17:01:45 -07009346 hdd_debugfs_exit(pHddCtx);
9347
Jeff Johnson295189b2012-06-20 16:38:30 -07009348#ifdef WLAN_BTAMP_FEATURE
9349err_bap_stop:
9350 WLANBAP_Stop(pVosContext);
9351#endif
9352
9353#ifdef WLAN_BTAMP_FEATURE
9354err_bap_close:
9355 WLANBAP_Close(pVosContext);
9356#endif
9357
Jeff Johnson295189b2012-06-20 16:38:30 -07009358err_close_adapter:
9359 hdd_close_all_adapters( pHddCtx );
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +05309360#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309361err_unregister_wiphy:
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +05309362#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309363 wiphy_unregister(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009364err_vosstop:
9365 vos_stop(pVosContext);
9366
Amar Singhala49cbc52013-10-08 18:37:44 -07009367err_vosclose:
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 status = vos_sched_close( pVosContext );
9369 if (!VOS_IS_STATUS_SUCCESS(status)) {
9370 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
9371 "%s: Failed to close VOSS Scheduler", __func__);
9372 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
9373 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009374 vos_close(pVosContext );
9375
Amar Singhal0a402232013-10-11 20:57:16 -07009376err_vos_nv_close:
9377
c_hpothue6a36282014-03-19 12:27:38 +05309378#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009379 vos_nv_close();
9380
c_hpothu70f8d812014-03-22 22:59:23 +05309381#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009382
9383err_wdclose:
9384 if(pHddCtx->cfg_ini->fIsLogpEnabled)
9385 vos_watchdog_close(pVosContext);
9386
Jeff Johnson295189b2012-06-20 16:38:30 -07009387err_config:
9388 kfree(pHddCtx->cfg_ini);
9389 pHddCtx->cfg_ini= NULL;
9390
9391err_free_hdd_context:
9392 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 wiphy_free(wiphy) ;
9394 //kfree(wdev) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 VOS_BUG(1);
9396
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -08009397 if (hdd_is_ssr_required())
9398 {
9399 /* WDI timeout had happened during load, so SSR is needed here */
9400 subsystem_restart("wcnss");
9401 msleep(5000);
9402 }
9403 hdd_set_ssr_required (VOS_FALSE);
9404
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009405 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07009406
9407success:
9408 EXIT();
9409 return 0;
9410}
9411
9412/**---------------------------------------------------------------------------
9413
Jeff Johnson32d95a32012-09-10 13:15:23 -07009414 \brief hdd_driver_init() - Core Driver Init Function
Jeff Johnson295189b2012-06-20 16:38:30 -07009415
Jeff Johnson32d95a32012-09-10 13:15:23 -07009416 This is the driver entry point - called in different timeline depending
9417 on whether the driver is statically or dynamically linked
Jeff Johnson295189b2012-06-20 16:38:30 -07009418
9419 \param - None
9420
9421 \return - 0 for success, non zero for failure
9422
9423 --------------------------------------------------------------------------*/
Jeff Johnson32d95a32012-09-10 13:15:23 -07009424static int hdd_driver_init( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07009425{
9426 VOS_STATUS status;
9427 v_CONTEXT_t pVosContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 struct device *dev = NULL;
9429 int ret_status = 0;
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07009430#ifdef HAVE_WCNSS_CAL_DOWNLOAD
9431 int max_retries = 0;
9432#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009433
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05309434#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
9435 wlan_logging_sock_init_svc();
9436#endif
9437
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 ENTER();
9439
Sameer Thalappil50dc0092013-02-19 17:23:33 -08009440#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan");
Jeff Johnsone7245742012-09-05 17:12:55 -07009442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009443
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309444 hddTraceInit();
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME,
9446 QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR);
9447
Jeff Johnson295189b2012-06-20 16:38:30 -07009448#ifdef ANI_BUS_TYPE_PCI
9449
9450 dev = wcnss_wlan_get_device();
9451
9452#endif // ANI_BUS_TYPE_PCI
9453
9454#ifdef ANI_BUS_TYPE_PLATFORM
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07009455
9456#ifdef HAVE_WCNSS_CAL_DOWNLOAD
9457 /* wait until WCNSS driver downloads NV */
9458 while (!wcnss_device_ready() && 5 >= ++max_retries) {
9459 msleep(1000);
9460 }
9461 if (max_retries >= 5) {
9462 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__);
madan mohan koyyalamudi8c96ce12013-07-10 19:14:39 +05309463#ifdef WLAN_OPEN_SOURCE
9464 wake_lock_destroy(&wlan_wake_lock);
9465#endif
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05309466
9467#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
9468 wlan_logging_sock_deinit_svc();
9469#endif
9470
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -07009471 return -ENODEV;
9472 }
9473#endif
9474
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 dev = wcnss_wlan_get_device();
9476#endif // ANI_BUS_TYPE_PLATFORM
9477
9478
9479 do {
9480 if (NULL == dev) {
9481 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__);
9482 ret_status = -1;
9483 break;
9484 }
9485
Jeff Johnson295189b2012-06-20 16:38:30 -07009486#ifdef TIMER_MANAGER
9487 vos_timer_manager_init();
9488#endif
9489
9490 /* Preopen VOSS so that it is ready to start at least SAL */
9491 status = vos_preOpen(&pVosContext);
9492
9493 if (!VOS_IS_STATUS_SUCCESS(status))
9494 {
9495 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__);
9496 ret_status = -1;
9497 break;
9498 }
9499
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009500#ifndef MODULE
9501 /* For statically linked driver, call hdd_set_conparam to update curr_con_mode
9502 */
9503 hdd_set_conparam((v_UINT_t)con_mode);
9504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009505
9506 // Call our main init function
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009507 if (hdd_wlan_startup(dev))
9508 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed",
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009510 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 vos_preClose( &pVosContext );
9512 ret_status = -1;
9513 break;
9514 }
9515
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 } while (0);
9517
9518 if (0 != ret_status)
9519 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009520#ifdef TIMER_MANAGER
9521 vos_timer_exit();
9522#endif
9523#ifdef MEMORY_DEBUG
9524 vos_mem_exit();
9525#endif
9526
Sameer Thalappil50dc0092013-02-19 17:23:33 -08009527#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 wake_lock_destroy(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07009529#endif
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05309530
9531#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
9532 wlan_logging_sock_deinit_svc();
9533#endif
9534
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 pr_err("%s: driver load failure\n", WLAN_MODULE_NAME);
9536 }
9537 else
9538 {
9539 //Send WLAN UP indication to Nlink Service
9540 send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0);
9541
9542 pr_info("%s: driver loaded\n", WLAN_MODULE_NAME);
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 }
9544
9545 EXIT();
9546
9547 return ret_status;
9548}
9549
Jeff Johnson32d95a32012-09-10 13:15:23 -07009550/**---------------------------------------------------------------------------
9551
9552 \brief hdd_module_init() - Init Function
9553
9554 This is the driver entry point (invoked when module is loaded using insmod)
9555
9556 \param - None
9557
9558 \return - 0 for success, non zero for failure
9559
9560 --------------------------------------------------------------------------*/
9561#ifdef MODULE
9562static int __init hdd_module_init ( void)
9563{
9564 return hdd_driver_init();
9565}
Jeff Johnson32d95a32012-09-10 13:15:23 -07009566#else /* #ifdef MODULE */
9567static int __init hdd_module_init ( void)
9568{
9569 /* Driver initialization is delayed to fwpath_changed_handler */
9570 return 0;
9571}
Jeff Johnson32d95a32012-09-10 13:15:23 -07009572#endif /* #ifdef MODULE */
9573
Jeff Johnson295189b2012-06-20 16:38:30 -07009574
9575/**---------------------------------------------------------------------------
9576
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009577 \brief hdd_driver_exit() - Exit function
Jeff Johnson295189b2012-06-20 16:38:30 -07009578
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009579 This is the driver exit point (invoked when module is unloaded using rmmod
9580 or con_mode was changed by userspace)
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
9582 \param - None
9583
9584 \return - None
9585
9586 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009587static void hdd_driver_exit(void)
Jeff Johnson295189b2012-06-20 16:38:30 -07009588{
9589 hdd_context_t *pHddCtx = NULL;
9590 v_CONTEXT_t pVosContext = NULL;
Agarwal Ashish5e414792014-06-08 15:25:23 +05309591 v_REGDOMAIN_t regId;
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309592 unsigned long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009593
9594 pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR);
9595
9596 //Get the global vos context
9597 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9598
9599 if(!pVosContext)
9600 {
9601 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
9602 goto done;
9603 }
9604
9605 //Get the HDD context.
9606 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
9607
9608 if(!pHddCtx)
9609 {
9610 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__);
9611 }
9612 else
9613 {
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309614 INIT_COMPLETION(pHddCtx->ssr_comp_var);
9615
9616 if (pHddCtx->isLogpInProgress)
9617 {
Sameer Thalappil451ebb92013-06-28 15:49:58 -07009618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309619 "%s:SSR in Progress; block rmmod !!!", __func__);
9620 rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var,
9621 msecs_to_jiffies(30000));
9622 if(!rc)
9623 {
9624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9625 "%s:SSR timedout, fatal error", __func__);
9626 VOS_BUG(0);
Sameer Thalappil451ebb92013-06-28 15:49:58 -07009627 }
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009629
Vinay Krishna Erannae362b452014-09-23 13:09:46 +05309630 rtnl_lock();
Mihir Shete18156292014-03-11 15:38:30 +05309631 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
Vinay Krishna Erannae362b452014-09-23 13:09:46 +05309633 rtnl_unlock();
Jeff Johnson295189b2012-06-20 16:38:30 -07009634
Agarwal Ashish8db39882014-07-30 21:56:07 +05309635 /* Driver Need to send country code 00 in below condition
9636 * 1) If gCountryCodePriority is set to 1; and last country
9637 * code set is through 11d. This needs to be done in case
9638 * when NV country code is 00.
9639 * This Needs to be done as when kernel store last country
9640 * code and if stored country code is not through 11d,
9641 * in sme_HandleChangeCountryCodeByUser we will disable 11d
9642 * in next load/unload as soon as we get any country through
9643 * 11d. In sme_HandleChangeCountryCodeByUser
9644 * pMsg->countryCode will be last countryCode and
9645 * pMac->scan.countryCode11d will be country through 11d so
9646 * due to mismatch driver will disable 11d.
9647 *
9648 * 2) When NV country Code is non-zero ;
9649 * There are chances that kernel last country and default
9650 * country can be same. In this case if Driver doesn't pass 00 to
9651 * kernel, at the time of driver loading next timer, driver will not
9652 * call any hint to kernel as country is same. This can add 3 sec
9653 * delay in driver loading.
9654 */
9655
9656 if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) &&
Agarwal Ashish8dcd2862014-07-25 11:58:52 +05309657 pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority &&
Agarwal Ashish8db39882014-07-30 21:56:07 +05309658 sme_Is11dSupported(pHddCtx->hHal)) || (vos_is_nv_country_non_zero() ))
Agarwal Ashish5e414792014-06-08 15:25:23 +05309659 {
Agarwal Ashish8dcd2862014-07-25 11:58:52 +05309660 hddLog(VOS_TRACE_LEVEL_INFO,
9661 FL("CountryCode 00 is being set while unloading driver"));
Agarwal Ashish5e414792014-06-08 15:25:23 +05309662 vos_nv_getRegDomainFromCountryCode(&regId , "00", COUNTRY_USER);
9663 }
9664
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 //Do all the cleanup before deregistering the driver
9666 hdd_wlan_exit(pHddCtx);
9667 }
9668
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 vos_preClose( &pVosContext );
9670
9671#ifdef TIMER_MANAGER
9672 vos_timer_exit();
9673#endif
9674#ifdef MEMORY_DEBUG
9675 vos_mem_exit();
9676#endif
9677
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05309678#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
9679 wlan_logging_sock_deinit_svc();
9680#endif
9681
Jeff Johnson295189b2012-06-20 16:38:30 -07009682done:
Sameer Thalappil50dc0092013-02-19 17:23:33 -08009683#ifdef WLAN_OPEN_SOURCE
Jeff Johnson295189b2012-06-20 16:38:30 -07009684 wake_lock_destroy(&wlan_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07009685#endif
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05309686
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME);
9688}
9689
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009690/**---------------------------------------------------------------------------
9691
9692 \brief hdd_module_exit() - Exit function
9693
9694 This is the driver exit point (invoked when module is unloaded using rmmod)
9695
9696 \param - None
9697
9698 \return - None
9699
9700 --------------------------------------------------------------------------*/
9701static void __exit hdd_module_exit(void)
9702{
9703 hdd_driver_exit();
9704}
9705
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009706#ifdef MODULE
9707static int fwpath_changed_handler(const char *kmessage,
9708 struct kernel_param *kp)
9709{
Jeff Johnson76052702013-04-16 13:55:05 -07009710 return param_set_copystring(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009711}
9712
9713static int con_mode_handler(const char *kmessage,
9714 struct kernel_param *kp)
9715{
Madan Mohan Koyyalamudif2f8d8b2012-10-11 17:06:59 -07009716 return param_set_int(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009717}
9718#else /* #ifdef MODULE */
9719/**---------------------------------------------------------------------------
9720
Jeff Johnson76052702013-04-16 13:55:05 -07009721 \brief kickstart_driver
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009722
Jeff Johnson76052702013-04-16 13:55:05 -07009723 This is the driver entry point
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009724 - delayed driver initialization when driver is statically linked
Jeff Johnson76052702013-04-16 13:55:05 -07009725 - invoked when module parameter fwpath is modified from userspace to signal
9726 initializing the WLAN driver or when con_mode is modified from userspace
9727 to signal a switch in operating mode
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009728
9729 \return - 0 for success, non zero for failure
9730
9731 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -07009732static int kickstart_driver(void)
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009733{
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -07009734 int ret_status;
9735
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009736 if (!wlan_hdd_inited) {
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -07009737 ret_status = hdd_driver_init();
9738 wlan_hdd_inited = ret_status ? 0 : 1;
9739 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009740 }
9741
9742 hdd_driver_exit();
Jeff Johnson76052702013-04-16 13:55:05 -07009743
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009744 msleep(200);
Jeff Johnson76052702013-04-16 13:55:05 -07009745
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -07009746 ret_status = hdd_driver_init();
9747 wlan_hdd_inited = ret_status ? 0 : 1;
9748 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -07009749}
9750
Jeff Johnson295189b2012-06-20 16:38:30 -07009751/**---------------------------------------------------------------------------
9752
Jeff Johnson76052702013-04-16 13:55:05 -07009753 \brief fwpath_changed_handler() - Handler Function
9754
9755 Handle changes to the fwpath parameter
9756
9757 \return - 0 for success, non zero for failure
9758
9759 --------------------------------------------------------------------------*/
9760static int fwpath_changed_handler(const char *kmessage,
9761 struct kernel_param *kp)
9762{
9763 int ret;
9764
9765 ret = param_set_copystring(kmessage, kp);
9766 if (0 == ret)
9767 ret = kickstart_driver();
9768 return ret;
9769}
9770
9771/**---------------------------------------------------------------------------
9772
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009773 \brief con_mode_handler() -
9774
9775 Handler function for module param con_mode when it is changed by userspace
9776 Dynamically linked - do nothing
9777 Statically linked - exit and init driver, as in rmmod and insmod
9778
Jeff Johnson76052702013-04-16 13:55:05 -07009779 \param -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009780
Jeff Johnson76052702013-04-16 13:55:05 -07009781 \return -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009782
9783 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -07009784static int con_mode_handler(const char *kmessage, struct kernel_param *kp)
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009785{
Jeff Johnson76052702013-04-16 13:55:05 -07009786 int ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009787
Jeff Johnson76052702013-04-16 13:55:05 -07009788 ret = param_set_int(kmessage, kp);
9789 if (0 == ret)
9790 ret = kickstart_driver();
9791 return ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009792}
9793#endif /* #ifdef MODULE */
9794
9795/**---------------------------------------------------------------------------
9796
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 \brief hdd_get_conparam() -
9798
9799 This is the driver exit point (invoked when module is unloaded using rmmod)
9800
9801 \param - None
9802
9803 \return - tVOS_CON_MODE
9804
9805 --------------------------------------------------------------------------*/
9806tVOS_CON_MODE hdd_get_conparam ( void )
9807{
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009808#ifdef MODULE
Jeff Johnson295189b2012-06-20 16:38:30 -07009809 return (tVOS_CON_MODE)con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009810#else
9811 return (tVOS_CON_MODE)curr_con_mode;
9812#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009813}
9814void hdd_set_conparam ( v_UINT_t newParam )
9815{
9816 con_mode = newParam;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -07009817#ifndef MODULE
9818 curr_con_mode = con_mode;
9819#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009820}
9821/**---------------------------------------------------------------------------
9822
9823 \brief hdd_softap_sta_deauth() - function
9824
9825 This to take counter measure to handle deauth req from HDD
9826
9827 \param - pAdapter - Pointer to the HDD
9828
9829 \param - enable - boolean value
9830
9831 \return - None
9832
9833 --------------------------------------------------------------------------*/
9834
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009835VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, v_U8_t *pDestMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009836{
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009838 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -07009839
9840 ENTER();
9841
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07009842 hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)",
9843 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07009844
9845 //Ignore request to deauth bcmc station
9846 if( pDestMacAddress[0] & 0x1 )
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009847 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07009848
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009849 vosStatus = WLANSAP_DeauthSta(pVosContext,pDestMacAddress);
Jeff Johnson295189b2012-06-20 16:38:30 -07009850
9851 EXIT();
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009852 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07009853}
9854
9855/**---------------------------------------------------------------------------
9856
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05309857 \brief hdd_del_all_sta() - function
9858
9859 This function removes all the stations associated on stopping AP/P2P GO.
9860
9861 \param - pAdapter - Pointer to the HDD
9862
9863 \return - None
9864
9865 --------------------------------------------------------------------------*/
9866
9867int hdd_del_all_sta(hdd_adapter_t *pAdapter)
9868{
9869 v_U16_t i;
9870 VOS_STATUS vos_status;
9871
9872 ENTER();
9873
9874 hddLog(VOS_TRACE_LEVEL_INFO,
9875 "%s: Delete all STAs associated.",__func__);
9876 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
9877 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
9878 )
9879 {
9880 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
9881 {
9882 if ((pAdapter->aStaInfo[i].isUsed) &&
9883 (!pAdapter->aStaInfo[i].isDeauthInProgress))
9884 {
9885 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
9886 hddLog(VOS_TRACE_LEVEL_ERROR,
9887 "%s: Delete STA with staid = %d and MAC::"
9888 MAC_ADDRESS_STR,
9889 __func__, i, MAC_ADDR_ARRAY(macAddr));
9890 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
9891 if (VOS_IS_STATUS_SUCCESS(vos_status))
9892 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
9893 }
9894 }
9895 }
9896
9897 EXIT();
9898 return 0;
9899}
9900
9901/**---------------------------------------------------------------------------
9902
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 \brief hdd_softap_sta_disassoc() - function
9904
9905 This to take counter measure to handle deauth req from HDD
9906
9907 \param - pAdapter - Pointer to the HDD
9908
9909 \param - enable - boolean value
9910
9911 \return - None
9912
9913 --------------------------------------------------------------------------*/
9914
9915void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress)
9916{
9917 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
9918
9919 ENTER();
9920
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309921 hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07009922
9923 //Ignore request to disassoc bcmc station
9924 if( pDestMacAddress[0] & 0x1 )
9925 return;
9926
9927 WLANSAP_DisassocSta(pVosContext,pDestMacAddress);
9928}
9929
9930void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable)
9931{
9932 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
9933
9934 ENTER();
9935
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05309936 hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07009937
9938 WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable);
9939}
9940
Jeff Johnson295189b2012-06-20 16:38:30 -07009941/**---------------------------------------------------------------------------
9942 *
9943 * \brief hdd_get__concurrency_mode() -
9944 *
9945 *
9946 * \param - None
9947 *
9948 * \return - CONCURRENCY MODE
9949 *
9950 * --------------------------------------------------------------------------*/
9951tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void )
9952{
9953 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
9954 hdd_context_t *pHddCtx;
9955
9956 if (NULL != pVosContext)
9957 {
9958 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
9959 if (NULL != pHddCtx)
9960 {
9961 return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode;
9962 }
9963 }
9964
9965 /* we are in an invalid state :( */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009966 hddLog(LOGE, "%s: Invalid context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 return VOS_STA;
9968}
Sushant Kaushikabb7ee62014-07-18 16:20:12 +05309969v_BOOL_t
9970wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx)
9971{
9972 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009973
Sushant Kaushikabb7ee62014-07-18 16:20:12 +05309974 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO);
9975 if (pAdapter == NULL)
9976 {
9977 hddLog(VOS_TRACE_LEVEL_INFO,
9978 FL("GO doesn't exist"));
9979 return TRUE;
9980 }
9981 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
9982 {
9983 hddLog(VOS_TRACE_LEVEL_INFO,
9984 FL("GO started"));
9985 return TRUE;
9986 }
9987 else
9988 /* wait till GO changes its interface to p2p device */
9989 hddLog(VOS_TRACE_LEVEL_INFO,
9990 FL("Del_bss called, avoid apps suspend"));
9991 return FALSE;
9992
9993}
Jeff Johnson295189b2012-06-20 16:38:30 -07009994/* Decide whether to allow/not the apps power collapse.
9995 * Allow apps power collapse if we are in connected state.
9996 * if not, allow only if we are in IMPS */
9997v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx)
9998{
9999 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
Srikant Kuppafef66a72013-01-30 17:32:44 -080010000 tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal);
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010001 tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10003 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10004 hdd_adapter_t *pAdapter = NULL;
10005 VOS_STATUS status;
Yathish9f22e662012-12-10 14:21:35 -080010006 tVOS_CONCURRENCY_MODE concurrent_state = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010007
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 if (VOS_STA_SAP_MODE == hdd_get_conparam())
10009 return TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010010
Yathish9f22e662012-12-10 14:21:35 -080010011 concurrent_state = hdd_get_concurrency_mode();
10012
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010013 if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) &&
10014 !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx)))
10015 return FALSE;
Yathish9f22e662012-12-10 14:21:35 -080010016#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010017
Yathish9f22e662012-12-10 14:21:35 -080010018 if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) ||
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010019 (concurrent_state == (VOS_STA | VOS_P2P_GO)))&&
Yathish9f22e662012-12-10 14:21:35 -080010020 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
10021 return TRUE;
10022#endif
10023
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 /*loop through all adapters. TBD fix for Concurrency */
10025 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10026 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10027 {
10028 pAdapter = pAdapterNode->pAdapter;
10029 if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
10030 || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10031 {
Srikant Kuppafef66a72013-01-30 17:32:44 -080010032 if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled)
c_hpothu4e8faac2014-05-16 17:38:44 +053010033 && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD
Srikant Kuppafef66a72013-01-30 17:32:44 -080010034 && pmcState != STOPPED && pmcState != STANDBY)) ||
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010035 (eANI_BOOLEAN_TRUE == scanRspPending) ||
10036 (eANI_BOOLEAN_TRUE == inMiddleOfRoaming))
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 {
Srikant Kuppafef66a72013-01-30 17:32:44 -080010038 hddLog( LOGE, "%s: do not allow APPS power collapse-"
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010039 "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d",
10040 __func__, pmcState, scanRspPending, inMiddleOfRoaming );
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 return FALSE;
10042 }
10043 }
10044 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10045 pAdapterNode = pNext;
10046 }
10047 return TRUE;
10048}
10049
Madan Mohan Koyyalamudic72a4d62012-11-08 14:59:34 -080010050/* Decides whether to send suspend notification to Riva
10051 * if any adapter is in BMPS; then it is required */
10052v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx)
10053{
10054 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
10055 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10056
10057 if (pConfig->fIsBmpsEnabled && (pmcState == BMPS))
10058 {
10059 return TRUE;
10060 }
10061 return FALSE;
10062}
10063
Jeff Johnson295189b2012-06-20 16:38:30 -070010064void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
10065{
10066 switch(mode)
10067 {
Chilam Ngc4244af2013-04-01 15:37:32 -070010068 case VOS_STA_MODE:
10069 case VOS_P2P_CLIENT_MODE:
10070 case VOS_P2P_GO_MODE:
10071 case VOS_STA_SAP_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -070010072 pHddCtx->concurrency_mode |= (1 << mode);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010073 pHddCtx->no_of_open_sessions[mode]++;
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 break;
10075 default:
10076 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053010078 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
10079 "Number of open sessions for mode %d = %d"),
10080 pHddCtx->concurrency_mode, mode,
10081 pHddCtx->no_of_open_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010082}
10083
10084
10085void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
10086{
10087 switch(mode)
10088 {
Chilam Ngc4244af2013-04-01 15:37:32 -070010089 case VOS_STA_MODE:
10090 case VOS_P2P_CLIENT_MODE:
10091 case VOS_P2P_GO_MODE:
10092 case VOS_STA_SAP_MODE:
Agarwal Ashish51325b52014-06-16 16:50:49 +053010093 pHddCtx->no_of_open_sessions[mode]--;
10094 if (!(pHddCtx->no_of_open_sessions[mode]))
10095 pHddCtx->concurrency_mode &= (~(1 << mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 break;
10097 default:
10098 break;
10099 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053010100 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
10101 "Number of open sessions for mode %d = %d"),
10102 pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]);
10103
10104}
10105/**---------------------------------------------------------------------------
10106 *
10107 * \brief wlan_hdd_incr_active_session()
10108 *
10109 * This function increments the number of active sessions
10110 * maintained per device mode
10111 * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented
10112 * Incase of SAP/P2P GO upon bss start it is incremented
10113 *
10114 * \param pHddCtx - HDD Context
10115 * \param mode - device mode
10116 *
10117 * \return - None
10118 *
10119 * --------------------------------------------------------------------------*/
10120void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
10121{
10122 switch (mode) {
10123 case VOS_STA_MODE:
10124 case VOS_P2P_CLIENT_MODE:
10125 case VOS_P2P_GO_MODE:
10126 case VOS_STA_SAP_MODE:
10127 pHddCtx->no_of_active_sessions[mode]++;
10128 break;
10129 default:
10130 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
10131 break;
10132 }
10133 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
10134 mode,
10135 pHddCtx->no_of_active_sessions[mode]);
10136}
10137
10138/**---------------------------------------------------------------------------
10139 *
10140 * \brief wlan_hdd_decr_active_session()
10141 *
10142 * This function decrements the number of active sessions
10143 * maintained per device mode
10144 * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented
10145 * Incase of SAP/P2P GO upon bss stop it is decremented
10146 *
10147 * \param pHddCtx - HDD Context
10148 * \param mode - device mode
10149 *
10150 * \return - None
10151 *
10152 * --------------------------------------------------------------------------*/
10153void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
10154{
10155 switch (mode) {
10156 case VOS_STA_MODE:
10157 case VOS_P2P_CLIENT_MODE:
10158 case VOS_P2P_GO_MODE:
10159 case VOS_STA_SAP_MODE:
Agarwal Ashish5325f522014-08-06 00:58:44 +053010160 if (pHddCtx->no_of_active_sessions[mode] > 0)
10161 pHddCtx->no_of_active_sessions[mode]--;
10162 else
10163 hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions"
10164 "is already Zero"));
Agarwal Ashish51325b52014-06-16 16:50:49 +053010165 break;
10166 default:
10167 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
10168 break;
10169 }
10170 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
10171 mode,
10172 pHddCtx->no_of_active_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010173}
10174
Jeff Johnsone7245742012-09-05 17:12:55 -070010175/**---------------------------------------------------------------------------
10176 *
10177 * \brief wlan_hdd_restart_init
10178 *
10179 * This function initalizes restart timer/flag. An internal function.
10180 *
10181 * \param - pHddCtx
10182 *
10183 * \return - None
10184 *
10185 * --------------------------------------------------------------------------*/
10186
10187static void wlan_hdd_restart_init(hdd_context_t *pHddCtx)
10188{
10189 /* Initialize */
10190 pHddCtx->hdd_restart_retries = 0;
10191 atomic_set(&pHddCtx->isRestartInProgress, 0);
10192 vos_timer_init(&pHddCtx->hdd_restart_timer,
10193 VOS_TIMER_TYPE_SW,
10194 wlan_hdd_restart_timer_cb,
10195 pHddCtx);
10196}
10197/**---------------------------------------------------------------------------
10198 *
10199 * \brief wlan_hdd_restart_deinit
10200 *
10201 * This function cleans up the resources used. An internal function.
10202 *
10203 * \param - pHddCtx
10204 *
10205 * \return - None
10206 *
10207 * --------------------------------------------------------------------------*/
10208
10209static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx)
10210{
10211
10212 VOS_STATUS vos_status;
10213 /* Block any further calls */
10214 atomic_set(&pHddCtx->isRestartInProgress, 1);
10215 /* Cleanup */
10216 vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer );
10217 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010218 hddLog(LOGE, FL("Failed to stop HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010219 vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer);
10220 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010221 hddLog(LOGE, FL("Failed to destroy HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010222
10223}
10224
10225/**---------------------------------------------------------------------------
10226 *
10227 * \brief wlan_hdd_framework_restart
10228 *
10229 * This function uses a cfg80211 API to start a framework initiated WLAN
10230 * driver module unload/load.
10231 *
10232 * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT).
10233 *
10234 *
10235 * \param - pHddCtx
10236 *
10237 * \return - VOS_STATUS_SUCCESS: Success
10238 * VOS_STATUS_E_EMPTY: Adapter is Empty
10239 * VOS_STATUS_E_NOMEM: No memory
10240
10241 * --------------------------------------------------------------------------*/
10242
10243static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx)
10244{
10245 VOS_STATUS status = VOS_STATUS_SUCCESS;
10246 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070010247 int len = (sizeof (struct ieee80211_mgmt));
10248 struct ieee80211_mgmt *mgmt = NULL;
10249
10250 /* Prepare the DEAUTH managment frame with reason code */
10251 mgmt = kzalloc(len, GFP_KERNEL);
10252 if(mgmt == NULL)
10253 {
10254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10255 "%s: memory allocation failed (%d bytes)", __func__, len);
10256 return VOS_STATUS_E_NOMEM;
10257 }
10258 mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK;
Jeff Johnsone7245742012-09-05 17:12:55 -070010259
10260 /* Iterate over all adapters/devices */
10261 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10262 do
10263 {
10264 if( (status == VOS_STATUS_SUCCESS) &&
10265 pAdapterNode &&
10266 pAdapterNode->pAdapter)
10267 {
10268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10269 "restarting the driver(intf:\'%s\' mode:%d :try %d)",
10270 pAdapterNode->pAdapter->dev->name,
10271 pAdapterNode->pAdapter->device_mode,
10272 pHddCtx->hdd_restart_retries + 1);
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070010273 /*
10274 * CFG80211 event to restart the driver
10275 *
10276 * 'cfg80211_send_unprot_deauth' sends a
10277 * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state
10278 * of SME(Linux Kernel) state machine.
10279 *
10280 * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart
10281 * the driver.
10282 *
10283 */
10284
10285 cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len );
Jeff Johnsone7245742012-09-05 17:12:55 -070010286 }
10287 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10288 pAdapterNode = pNext;
10289 } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status));
10290
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070010291
10292 /* Free the allocated management frame */
10293 kfree(mgmt);
10294
Jeff Johnsone7245742012-09-05 17:12:55 -070010295 /* Retry until we unload or reach max count */
10296 if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT)
10297 vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS);
10298
10299 return status;
10300
10301}
10302/**---------------------------------------------------------------------------
10303 *
10304 * \brief wlan_hdd_restart_timer_cb
10305 *
10306 * Restart timer callback. An internal function.
10307 *
10308 * \param - User data:
10309 *
10310 * \return - None
10311 *
10312 * --------------------------------------------------------------------------*/
10313
10314void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback)
10315{
10316 hdd_context_t *pHddCtx = usrDataForCallback;
10317 wlan_hdd_framework_restart(pHddCtx);
10318 return;
10319
10320}
10321
10322
10323/**---------------------------------------------------------------------------
10324 *
10325 * \brief wlan_hdd_restart_driver
10326 *
10327 * This function sends an event to supplicant to restart the WLAN driver.
10328 *
10329 * This function is called from vos_wlanRestart.
10330 *
10331 * \param - pHddCtx
10332 *
10333 * \return - VOS_STATUS_SUCCESS: Success
10334 * VOS_STATUS_E_EMPTY: Adapter is Empty
10335 * VOS_STATUS_E_ALREADY: Request already in progress
10336
10337 * --------------------------------------------------------------------------*/
10338VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx)
10339{
10340 VOS_STATUS status = VOS_STATUS_SUCCESS;
10341
10342 /* A tight check to make sure reentrancy */
10343 if(atomic_xchg(&pHddCtx->isRestartInProgress, 1))
10344 {
Mihir Shetefd528652014-06-23 19:07:50 +053010345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsone7245742012-09-05 17:12:55 -070010346 "%s: WLAN restart is already in progress", __func__);
10347
10348 return VOS_STATUS_E_ALREADY;
10349 }
Sameer Thalappil0c164f52013-03-28 15:27:56 -070010350 /* Send reset FIQ to WCNSS to invoke SSR. */
Madan Mohan Koyyalamudie388b342012-11-08 15:03:16 -080010351#ifdef HAVE_WCNSS_RESET_INTR
Madan Mohan Koyyalamudibb8f0172012-09-28 15:36:06 -070010352 wcnss_reset_intr();
10353#endif
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -070010354
Jeff Johnsone7245742012-09-05 17:12:55 -070010355 return status;
10356}
10357
Mihir Shetee1093ba2014-01-21 20:13:32 +053010358/**---------------------------------------------------------------------------
10359 *
10360 * \brief wlan_hdd_init_channels
10361 *
10362 * This function is used to initialize the channel list in CSR
10363 *
10364 * This function is called from hdd_wlan_startup
10365 *
10366 * \param - pHddCtx: HDD context
10367 *
10368 * \return - VOS_STATUS_SUCCESS: Success
10369 * VOS_STATUS_E_FAULT: Failure reported by SME
10370
10371 * --------------------------------------------------------------------------*/
10372static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx)
10373{
10374 eHalStatus status;
10375
10376 status = sme_InitChannels(pHddCtx->hHal);
10377 if (HAL_STATUS_SUCCESS(status))
10378 {
10379 return VOS_STATUS_SUCCESS;
10380 }
10381 else
10382 {
10383 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)",
10384 __func__, status);
10385 return VOS_STATUS_E_FAULT;
10386 }
10387}
10388
Agarwal Ashish6db9d532014-09-30 18:19:10 +053010389VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx, driver_load_type init )
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053010390{
10391 eHalStatus status;
10392
Agarwal Ashish6db9d532014-09-30 18:19:10 +053010393 status = sme_InitChannelsForCC(pHddCtx->hHal, init);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053010394 if (HAL_STATUS_SUCCESS(status))
10395 {
10396 return VOS_STATUS_SUCCESS;
10397 }
10398 else
10399 {
10400 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)",
10401 __func__, status);
10402 return VOS_STATUS_E_FAULT;
10403 }
10404}
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -070010405/*
10406 * API to find if there is any STA or P2P-Client is connected
10407 */
10408VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx)
10409{
10410 return sme_isSta_p2p_clientConnected(pHddCtx->hHal);
10411}
Jeff Johnsone7245742012-09-05 17:12:55 -070010412
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010413int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter)
10414{
10415 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10416 hdd_scaninfo_t *pScanInfo = NULL;
Girish Gowli4bf7a632014-06-12 13:42:11 +053010417 long status = 0;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010418
10419 pScanInfo = &pHddCtx->scan_info;
10420 if (pScanInfo->mScanPending)
10421 {
10422 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010423 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010424 eCSR_SCAN_ABORT_DEFAULT);
10425
10426 status = wait_for_completion_interruptible_timeout(
10427 &pScanInfo->abortscan_event_var,
10428 msecs_to_jiffies(5000));
Girish Gowli4bf7a632014-06-12 13:42:11 +053010429 if (0 >= status)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010430 {
10431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowli4bf7a632014-06-12 13:42:11 +053010432 "%s: Timeout or Interrupt occurred while waiting for abort"
10433 "scan, status- %ld", __func__, status);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010434 return -ETIMEDOUT;
10435 }
10436 }
Girish Gowli4bf7a632014-06-12 13:42:11 +053010437 return 0;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010438}
10439
c_hpothu225aa7c2014-10-22 17:45:13 +053010440VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx)
10441{
10442 hdd_adapter_t *pAdapter;
10443 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10444 VOS_STATUS vosStatus;
10445
10446 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10447 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
10448 {
10449 pAdapter = pAdapterNode->pAdapter;
10450 if (NULL != pAdapter)
10451 {
10452 if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ||
10453 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ||
10454 WLAN_HDD_P2P_GO == pAdapter->device_mode)
10455 {
10456 hddLog(LOG1, FL("abort ROC deviceMode: %d"),
10457 pAdapter->device_mode);
10458 if (VOS_STATUS_SUCCESS !=
10459 wlan_hdd_cancel_existing_remain_on_channel(pAdapter))
10460 {
10461 hddLog(LOGE, FL("failed to abort ROC"));
10462 return VOS_STATUS_E_FAILURE;
10463 }
10464 }
10465 }
10466 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10467 pAdapterNode = pNext;
10468 }
10469 return VOS_STATUS_SUCCESS;
10470}
Jeff Johnson295189b2012-06-20 16:38:30 -070010471//Register the module init/exit functions
10472module_init(hdd_module_init);
10473module_exit(hdd_module_exit);
10474
10475MODULE_LICENSE("Dual BSD/GPL");
10476MODULE_AUTHOR("Qualcomm Atheros, Inc.");
10477MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER");
10478
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010479module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode,
10480 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010481
Jeff Johnson76052702013-04-16 13:55:05 -070010482module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath,
Jeff Johnson32d95a32012-09-10 13:15:23 -070010483 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Arif Hussain66559122013-11-21 10:11:40 -080010484
10485module_param(enable_dfs_chan_scan, int,
10486 S_IRUSR | S_IRGRP | S_IROTH);
10487
10488module_param(enable_11d, int,
10489 S_IRUSR | S_IRGRP | S_IROTH);
10490
10491module_param(country_code, charp,
10492 S_IRUSR | S_IRGRP | S_IROTH);