blob: 4d165e4a18e1f2854eb5e5af737d387e622354fb [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
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
Jeff Johnson295189b2012-06-20 16:38:30 -070037
38 ========================================================================*/
39
40/**=========================================================================
41
42 EDIT HISTORY FOR FILE
43
44
45 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
47
48
49 $Header:$ $DateTime: $ $Author: $
50
51
52 when who what, where, why
53 -------- --- --------------------------------------------------------
54 04/5/09 Shailender Created module.
55 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module
56 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure
57 ==========================================================================*/
58
59/*--------------------------------------------------------------------------
60 Include Files
61 ------------------------------------------------------------------------*/
62//#include <wlan_qct_driver.h>
63#include <wlan_hdd_includes.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070064#include <vos_api.h>
65#include <vos_sched.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include <linux/etherdevice.h>
67#include <linux/firmware.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070068#ifdef ANI_BUS_TYPE_PLATFORM
69#include <linux/wcnss_wlan.h>
70#endif //ANI_BUS_TYPE_PLATFORM
71#ifdef ANI_BUS_TYPE_PCI
72#include "wcnss_wlan.h"
73#endif /* ANI_BUS_TYPE_PCI */
74#include <wlan_hdd_tx_rx.h>
75#include <palTimer.h>
76#include <wniApi.h>
77#include <wlan_nlink_srv.h>
78#include <wlan_btc_svc.h>
79#include <wlan_hdd_cfg.h>
80#include <wlan_ptt_sock_svc.h>
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053081#include <wlan_logging_sock_svc.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070082#include <wlan_hdd_wowl.h>
83#include <wlan_hdd_misc.h>
84#include <wlan_hdd_wext.h>
85#ifdef WLAN_BTAMP_FEATURE
86#include <bap_hdd_main.h>
87#include <bapInternal.h>
88#endif // WLAN_BTAMP_FEATURE
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053089#include "wlan_hdd_trace.h"
90#include "vos_types.h"
91#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Vinay Krishna Erannad9cbdb32014-01-16 12:59:10 +053094#include <linux/inetdevice.h>
95#include <net/addrconf.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070096#include "wlan_hdd_cfg80211.h"
97#include "wlan_hdd_p2p.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098#include <linux/rtnetlink.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070099int wlan_hdd_ftm_start(hdd_context_t *pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700100#include "sapApi.h"
101#include <linux/semaphore.h>
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -0700102#include <linux/ctype.h>
Arun Kumar Khandavalli74fe3032014-03-17 20:35:34 +0530103#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
104#include <soc/qcom/subsystem_restart.h>
105#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#include <mach/subsystem_restart.h>
Arun Kumar Khandavalli74fe3032014-03-17 20:35:34 +0530107#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#include <wlan_hdd_hostapd.h>
109#include <wlan_hdd_softap_tx_rx.h>
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#include "cfgApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700111#include "wlan_hdd_dev_pwr.h"
112#ifdef WLAN_BTAMP_FEATURE
113#include "bap_hdd_misc.h"
114#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700115#include "wlan_qct_pal_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700116#include "qwlan_version.h"
Yathish9f22e662012-12-10 14:21:35 -0800117#include "wlan_qct_wda.h"
Chilam NG571c65a2013-01-19 12:27:36 +0530118#ifdef FEATURE_WLAN_TDLS
119#include "wlan_hdd_tdls.h"
120#endif
Yue Ma0d4891e2013-08-06 17:01:45 -0700121#include "wlan_hdd_debugfs.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530122#include "sapInternal.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700123
124#ifdef MODULE
125#define WLAN_MODULE_NAME module_name(THIS_MODULE)
126#else
127#define WLAN_MODULE_NAME "wlan"
128#endif
129
130#ifdef TIMER_MANAGER
131#define TIMER_MANAGER_STR " +TIMER_MANAGER"
132#else
133#define TIMER_MANAGER_STR ""
134#endif
135
136#ifdef MEMORY_DEBUG
137#define MEMORY_DEBUG_STR " +MEMORY_DEBUG"
138#else
139#define MEMORY_DEBUG_STR ""
140#endif
Kaushik, Sushant7005e372014-04-08 11:36:54 +0530141#define MAX_WAIT_FOR_ROC_COMPLETION 3
Jeff Johnson295189b2012-06-20 16:38:30 -0700142/* the Android framework expects this param even though we don't use it */
143#define BUF_LEN 20
Jeff Johnson76052702013-04-16 13:55:05 -0700144static char fwpath_buffer[BUF_LEN];
145static struct kparam_string fwpath = {
146 .string = fwpath_buffer,
147 .maxlen = BUF_LEN,
148};
Arif Hussain66559122013-11-21 10:11:40 -0800149
150static char *country_code;
151static int enable_11d = -1;
152static int enable_dfs_chan_scan = -1;
c_hpothu92367912014-05-01 15:18:17 +0530153static int gbcnMissRate = -1;
Arif Hussain66559122013-11-21 10:11:40 -0800154
Madan Mohan Koyyalamudi05f313c2012-09-18 19:19:15 -0700155#ifndef MODULE
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700156static int wlan_hdd_inited;
Madan Mohan Koyyalamudi05f313c2012-09-18 19:19:15 -0700157#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700158
Jeff Johnsone7245742012-09-05 17:12:55 -0700159/*
Jeff Johnson72a40512013-12-19 10:14:15 -0800160 * spinlock for synchronizing asynchronous request/response
161 * (full description of use in wlan_hdd_main.h)
162 */
163DEFINE_SPINLOCK(hdd_context_lock);
164
165/*
Jeff Johnsone7245742012-09-05 17:12:55 -0700166 * The rate at which the driver sends RESTART event to supplicant
167 * once the function 'vos_wlanRestart()' is called
168 *
169 */
170#define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */
171#define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700172
173/*
174 * Size of Driver command strings from upper layer
175 */
176#define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */
177#define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */
178
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800179#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700180#define TID_MIN_VALUE 0
181#define TID_MAX_VALUE 15
182static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
183 tAniTrafStrmMetrics* pTsmMetrics);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800184static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue,
185 tCsrEseBeaconReq *pEseBcnReq);
186#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700187
Atul Mittal1d722422014-03-19 11:15:07 +0530188/*
189 * Maximum buffer size used for returning the data back to user space
190 */
191#define WLAN_MAX_BUF_SIZE 1024
192#define WLAN_PRIV_DATA_MAX_LEN 8192
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700193
c_hpothu92367912014-05-01 15:18:17 +0530194//wait time for beacon miss rate.
195#define BCN_MISS_RATE_TIME 500
196
Sushant Kaushik83392fa2015-05-05 17:44:40 +0530197static vos_wake_lock_t wlan_wake_lock;
198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199/* set when SSR is needed after unload */
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -0700200static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202//internal function declaration
Jeff Johnsone7245742012-09-05 17:12:55 -0700203static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx);
204static void wlan_hdd_restart_init(hdd_context_t *pHddCtx);
205static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx);
206void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback);
Sameer Thalappil45931fb2013-02-01 11:18:05 -0800207void hdd_set_wlan_suspend_mode(bool suspend);
Jeff Johnsone7245742012-09-05 17:12:55 -0700208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209v_U16_t hdd_select_queue(struct net_device *dev,
210 struct sk_buff *skb);
211
212#ifdef WLAN_FEATURE_PACKET_FILTERING
213static void hdd_set_multicast_list(struct net_device *dev);
214#endif
215
216void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter);
217
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800218#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -0800219void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand);
220static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels);
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700221static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid,
222 tANI_U8 *pChannel, tANI_U8 *pDwellTime,
223 tANI_U8 **pBuf, tANI_U8 *pBufLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -0700224static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
225 tANI_U8 *pTargetApBssid,
226 tANI_U8 *pChannel);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800227#endif
Ratheesh S P21280412015-05-19 14:21:52 +0530228
229/* Store WLAN driver info in a global variable such that crash debugger
230 can extract it from driver debug symbol and crashdump for post processing */
231tANI_U8 g_wlan_driver[ ] = "pronto_driver";
232
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800233#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700234VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800235#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700236
Mihir Shetee1093ba2014-01-21 20:13:32 +0530237static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx);
Sushant Kaushik8bc7df22014-04-09 17:55:29 +0530238const char * hdd_device_modetoString(v_U8_t device_mode)
239{
240 switch(device_mode)
241 {
242 CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION );
243 CASE_RETURN_STRING( WLAN_HDD_SOFTAP );
244 CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT );
245 CASE_RETURN_STRING( WLAN_HDD_P2P_GO );
246 CASE_RETURN_STRING( WLAN_HDD_MONITOR);
247 CASE_RETURN_STRING( WLAN_HDD_FTM );
248 CASE_RETURN_STRING( WLAN_HDD_IBSS );
249 CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE );
250 default:
251 return "device_mode Unknown";
252 }
253}
Mihir Shetee1093ba2014-01-21 20:13:32 +0530254
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +0530255static int __hdd_netdev_notifier_call(struct notifier_block * nb,
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 unsigned long state,
257 void *ndev)
258{
259 struct net_device *dev = ndev;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700260 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson27cee452013-03-27 11:10:24 -0700261 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700262#ifdef WLAN_BTAMP_FEATURE
263 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700264#endif
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530265 long result;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266
267 //Make sure that this callback corresponds to our device.
Jeff Johnson27cee452013-03-27 11:10:24 -0700268 if ((strncmp(dev->name, "wlan", 4)) &&
Amar Singhal4c723bd2013-03-25 18:14:15 -0700269 (strncmp(dev->name, "p2p", 3)))
270 return NOTIFY_DONE;
271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 if (!dev->ieee80211_ptr)
Jeff Johnson27cee452013-03-27 11:10:24 -0700273 return NOTIFY_DONE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
Jeff Johnson27cee452013-03-27 11:10:24 -0700275 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -0800277 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 VOS_ASSERT(0);
279 return NOTIFY_DONE;
280 }
281
Jeff Johnson27cee452013-03-27 11:10:24 -0700282 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
283 if (NULL == pHddCtx)
284 {
285 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__);
286 VOS_ASSERT(0);
287 return NOTIFY_DONE;
288 }
Sameer Thalappil14067972014-01-23 14:54:54 -0800289 if (pHddCtx->isLogpInProgress)
290 return NOTIFY_DONE;
291
Jeff Johnson27cee452013-03-27 11:10:24 -0700292
293 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu",
294 __func__, dev->name, state);
Jeff Johnson295189b2012-06-20 16:38:30 -0700295
296 switch (state) {
297 case NETDEV_REGISTER:
298 break;
299
300 case NETDEV_UNREGISTER:
301 break;
302
303 case NETDEV_UP:
304 break;
305
306 case NETDEV_DOWN:
307 break;
308
309 case NETDEV_CHANGE:
Jeff Johnsone7245742012-09-05 17:12:55 -0700310 if(TRUE == pAdapter->isLinkUpSvcNeeded)
311 complete(&pAdapter->linkup_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 break;
313
314 case NETDEV_GOING_DOWN:
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530315 result = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +0530316 if (result < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530317 {
318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
319 "%s: Timeout occurred while waiting for abortscan %ld",
320 __func__, result);
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 }
322 else
323 {
324 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530325 "%s: Scan Abort Successful" , __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 }
327#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 status = WLANBAP_StopAmp();
330 if(VOS_STATUS_SUCCESS != status )
331 {
332 pHddCtx->isAmpAllowed = VOS_TRUE;
333 hddLog(VOS_TRACE_LEVEL_FATAL,
334 "%s: Failed to stop AMP", __func__);
335 }
336 else
337 {
338 //a state m/c implementation in PAL is TBD to avoid this delay
339 msleep(500);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700340 if ( pHddCtx->isAmpAllowed )
341 {
342 WLANBAP_DeregisterFromHCI();
343 pHddCtx->isAmpAllowed = VOS_FALSE;
344 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 }
346#endif //WLAN_BTAMP_FEATURE
347 break;
348
349 default:
350 break;
351 }
352
353 return NOTIFY_DONE;
354}
355
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +0530356static int hdd_netdev_notifier_call(struct notifier_block * nb,
357 unsigned long state,
358 void *ndev)
359{
360 int ret;
361 vos_ssr_protect(__func__);
362 ret = __hdd_netdev_notifier_call( nb, state, ndev);
363 vos_ssr_unprotect(__func__);
364 return ret;
365}
366
Jeff Johnson295189b2012-06-20 16:38:30 -0700367struct notifier_block hdd_netdev_notifier = {
368 .notifier_call = hdd_netdev_notifier_call,
369};
370
371/*---------------------------------------------------------------------------
372 * Function definitions
373 *-------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700374void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx);
375void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700376//variable to hold the insmod parameters
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700377static int con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -0700378#ifndef MODULE
379/* current con_mode - used only for statically linked driver
380 * con_mode is changed by userspace to indicate a mode change which will
381 * result in calling the module exit and init functions. The module
382 * exit function will clean up based on the value of con_mode prior to it
383 * being changed by userspace. So curr_con_mode records the current con_mode
384 * for exit when con_mode becomes the next mode for init
385 */
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700386static int curr_con_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700387#endif
388
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -0800389/**---------------------------------------------------------------------------
390
391 \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable
392
393 Called immediately after the cfg.ini is read in order to configure
394 the desired trace levels.
395
396 \param - moduleId - module whose trace level is being configured
397 \param - bitmask - bitmask of log levels to be enabled
398
399 \return - void
400
401 --------------------------------------------------------------------------*/
402static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask)
403{
404 wpt_tracelevel level;
405
406 /* if the bitmask is the default value, then a bitmask was not
407 specified in cfg.ini, so leave the logging level alone (it
408 will remain at the "compiled in" default value) */
409 if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask)
410 {
411 return;
412 }
413
414 /* a mask was specified. start by disabling all logging */
415 vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0);
416
417 /* now cycle through the bitmask until all "set" bits are serviced */
418 level = VOS_TRACE_LEVEL_FATAL;
419 while (0 != bitmask)
420 {
421 if (bitmask & 1)
422 {
423 vos_trace_setValue(moduleId, level, 1);
424 }
425 level++;
426 bitmask >>= 1;
427 }
428}
429
430
Jeff Johnson295189b2012-06-20 16:38:30 -0700431/**---------------------------------------------------------------------------
432
433 \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable
434
435 Called immediately after the cfg.ini is read in order to configure
436 the desired trace levels in the WDI.
437
438 \param - moduleId - module whose trace level is being configured
439 \param - bitmask - bitmask of log levels to be enabled
440
441 \return - void
442
443 --------------------------------------------------------------------------*/
444static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask)
445{
446 wpt_tracelevel level;
447
448 /* if the bitmask is the default value, then a bitmask was not
449 specified in cfg.ini, so leave the logging level alone (it
450 will remain at the "compiled in" default value) */
451 if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask)
452 {
453 return;
454 }
455
456 /* a mask was specified. start by disabling all logging */
457 wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0);
458
459 /* now cycle through the bitmask until all "set" bits are serviced */
460 level = eWLAN_PAL_TRACE_LEVEL_FATAL;
461 while (0 != bitmask)
462 {
463 if (bitmask & 1)
464 {
465 wpalTraceSetLevel(moduleId, level, 1);
466 }
467 level++;
468 bitmask >>= 1;
469 }
470}
Jeff Johnson295189b2012-06-20 16:38:30 -0700471
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530472/*
473 * FUNCTION: wlan_hdd_validate_context
474 * This function is used to check the HDD context
475 */
476int wlan_hdd_validate_context(hdd_context_t *pHddCtx)
477{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530478
479 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
480 {
Mahesh A Saptasagar886997a2015-03-04 13:15:51 +0530481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530482 "%s: HDD context is Null", __func__);
483 return -ENODEV;
484 }
485
486 if (pHddCtx->isLogpInProgress)
487 {
Mahesh A Saptasagar886997a2015-03-04 13:15:51 +0530488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu8adb97b2014-12-08 19:38:20 +0530489 "%s: LOGP %s. Ignore!!", __func__,
490 vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL)
491 ?"failed":"in Progress");
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530492 return -EAGAIN;
493 }
494
Mihir Shete18156292014-03-11 15:38:30 +0530495 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530496 {
Mahesh A Saptasagar886997a2015-03-04 13:15:51 +0530497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530498 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
499 return -EAGAIN;
500 }
501 return 0;
502}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700503#ifdef CONFIG_ENABLE_LINUX_REG
504void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx)
505{
506 hdd_adapter_t *pAdapter = NULL;
507 hdd_station_ctx_t *pHddStaCtx = NULL;
508 eCsrPhyMode phyMode;
509 hdd_config_t *cfg_param = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530510
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700511 if (NULL == pHddCtx)
512 {
513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
514 "HDD Context is null !!");
515 return ;
516 }
517
518 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
519 if (NULL == pAdapter)
520 {
521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
522 "pAdapter is null !!");
523 return ;
524 }
525
526 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
527 if (NULL == pHddStaCtx)
528 {
529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
530 "pHddStaCtx is null !!");
531 return ;
532 }
533
534 cfg_param = pHddCtx->cfg_ini;
535 if (NULL == cfg_param)
536 {
537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
538 "cfg_params not available !!");
539 return ;
540 }
541
542 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
543
544 if (!pHddCtx->isVHT80Allowed)
545 {
546 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
547 (eCSR_DOT11_MODE_11ac == phyMode) ||
548 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
549 {
550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
551 "Setting phymode to 11n!!");
552 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
553 }
554 }
555 else
556 {
557 /*New country Supports 11ac as well resetting value back from .ini*/
558 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
559 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
560 return ;
561 }
562
563 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
564 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
565 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
566 {
567 VOS_STATUS vosStatus;
568
569 // need to issue a disconnect to CSR.
570 INIT_COMPLETION(pAdapter->disconnect_comp_var);
571 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
572 pAdapter->sessionId,
573 eCSR_DISCONNECT_REASON_UNSPECIFIED );
574
575 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530576 {
577 long ret;
578
579 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700580 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530581 if (0 >= ret)
582 hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"),
583 ret);
584 }
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700585
586 }
587}
588#else
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530589void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code)
590{
591 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
592 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
593 hdd_config_t *cfg_param;
594 eCsrPhyMode phyMode;
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530595 long ret;
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530596
597 if (NULL == pHddCtx)
598 {
599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
600 "HDD Context is null !!");
601 return ;
602 }
603
604 cfg_param = pHddCtx->cfg_ini;
605
606 if (NULL == cfg_param)
607 {
608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
609 "cfg_params not available !!");
610 return ;
611 }
612
613 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
614
615 if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code))
616 {
617 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
618 (eCSR_DOT11_MODE_11ac == phyMode) ||
619 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
620 {
621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
622 "Setting phymode to 11n!!");
623 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
624 }
625 }
626 else
627 {
628 /*New country Supports 11ac as well resetting value back from .ini*/
629 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
630 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
631 return ;
632 }
633
634 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
635 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
636 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
637 {
638 VOS_STATUS vosStatus;
639
640 // need to issue a disconnect to CSR.
641 INIT_COMPLETION(pAdapter->disconnect_comp_var);
642 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
643 pAdapter->sessionId,
644 eCSR_DISCONNECT_REASON_UNSPECIFIED );
645
646 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530647 {
648 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530649 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530650 if (ret <= 0)
651 {
652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
653 "wait on disconnect_comp_var is failed %ld", ret);
654 }
655 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530656
657 }
658}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700659#endif //CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530660
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700661void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code)
662{
663 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
664 hdd_config_t *cfg_param;
665
666 if (NULL == pHddCtx)
667 {
668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
669 "HDD Context is null !!");
670 return ;
671 }
672
673 cfg_param = pHddCtx->cfg_ini;
674
675 if (NULL == cfg_param)
676 {
677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
678 "cfg_params not available !!");
679 return ;
680 }
681
Agarwal Ashish738843c2014-09-25 12:27:56 +0530682 if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) ||
683 pHddCtx->disable_dfs_flag == TRUE)
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700684 {
685 /*New country doesn't support DFS */
686 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0);
687 }
688 else
689 {
690 /*New country Supports DFS as well resetting value back from .ini*/
691 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan);
692 }
693
694}
695
Rajeev79dbe4c2013-10-05 11:03:42 +0530696#ifdef FEATURE_WLAN_BATCH_SCAN
697
698/**---------------------------------------------------------------------------
699
700 \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from
701 input string
702
703 This function extracts assigned integer from string in below format:
704 "STRING=10" : extracts integer 10 from this string
705
706 \param - pInPtr Pointer to input string
707 \param - base Base for string to int conversion(10 for decimal 16 for hex)
708 \param - pOutPtr Pointer to variable in which extracted integer needs to be
709 assigned
710 \param - pLastArg to tell whether it is last arguement in input string or
711 not
712
713 \return - NULL for failure cases
714 pointer to next arguement in input string for success cases
715 --------------------------------------------------------------------------*/
716static tANI_U8 *
717hdd_extract_assigned_int_from_str
718(
719 tANI_U8 *pInPtr,
720 tANI_U8 base,
721 tANI_U32 *pOutPtr,
722 tANI_U8 *pLastArg
723)
724{
725 int tempInt;
726 int v = 0;
727 char buf[32];
728 int val = 0;
729 *pLastArg = FALSE;
730
731 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
732 if (NULL == pInPtr)
733 {
734 return NULL;
735 }
736
737 pInPtr++;
738
739 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
740
741 val = sscanf(pInPtr, "%32s ", buf);
742 if (val < 0 && val > strlen(pInPtr))
743 {
744 return NULL;
745 }
746 pInPtr += val;
747 v = kstrtos32(buf, base, &tempInt);
748 if (v < 0)
749 {
750 return NULL;
751 }
Rajeev Kumar4d93d842014-01-02 18:31:21 -0800752 if (tempInt < 0)
753 {
754 tempInt = 0;
755 }
Rajeev79dbe4c2013-10-05 11:03:42 +0530756 *pOutPtr = tempInt;
757
758 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
759 if (NULL == pInPtr)
760 {
761 *pLastArg = TRUE;
762 return NULL;
763 }
764 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
765
766 return pInPtr;
767}
768
769/**---------------------------------------------------------------------------
770
771 \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from
772 input string
773
774 This function extracts assigned character from string in below format:
775 "STRING=A" : extracts char 'A' from this string
776
777 \param - pInPtr Pointer to input string
778 \param - pOutPtr Pointer to variable in which extracted char needs to be
779 assigned
780 \param - pLastArg to tell whether it is last arguement in input string or
781 not
782
783 \return - NULL for failure cases
784 pointer to next arguement in input string for success cases
785 --------------------------------------------------------------------------*/
786static tANI_U8 *
787hdd_extract_assigned_char_from_str
788(
789 tANI_U8 *pInPtr,
790 tANI_U8 *pOutPtr,
791 tANI_U8 *pLastArg
792)
793{
794 *pLastArg = FALSE;
795
796 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
797 if (NULL == pInPtr)
798 {
799 return NULL;
800 }
801
802 pInPtr++;
803
804 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
805
806 *pOutPtr = *pInPtr;
807
808 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
809 if (NULL == pInPtr)
810 {
811 *pLastArg = TRUE;
812 return NULL;
813 }
814 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
815
816 return pInPtr;
817}
818
819
820/**---------------------------------------------------------------------------
821
822 \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command
823
824 This function parses set batch scan command in below format:
825 WLS_BATCHING_SET <space> followed by below arguements
826 "SCANFREQ=XX" : Optional defaults to 30 sec
827 "MSCAN=XX" : Required number of scans to attempt to batch
828 "BESTN=XX" : Best Network (RSSI) defaults to 16
829 "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B.
830 A. implies only 5 GHz , B. implies only 2.4GHz
831 "RTT=X" : optional defaults to 0
832 returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on
833 error
834
835 For example input commands:
836 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is
837 translated into set batch scan with following parameters:
838 a) Frequence 60 seconds
839 b) Batch 10 scans together
840 c) Best RSSI to be 20
841 d) 5GHz band only
842 e) RTT is equal to 0
843
844 \param - pValue Pointer to input channel list
845 \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure
846
847 \return - 0 for success non-zero for failure
848
849 --------------------------------------------------------------------------*/
850static int
851hdd_parse_set_batchscan_command
852(
853 tANI_U8 *pValue,
854 tSirSetBatchScanReq *pHddSetBatchScanReq
855)
856{
857 tANI_U8 *inPtr = pValue;
858 tANI_U8 val = 0;
859 tANI_U8 lastArg = 0;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800860 tANI_U32 nScanFreq;
861 tANI_U32 nMscan;
862 tANI_U32 nBestN;
863 tANI_U8 ucRfBand;
864 tANI_U32 nRtt;
Rajeev Kumarc933d982013-11-18 20:04:20 -0800865 tANI_U32 temp;
Rajeev79dbe4c2013-10-05 11:03:42 +0530866
867 /*initialize default values*/
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800868 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ;
869 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
870 nRtt = 0;
871 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK;
Rajeev79dbe4c2013-10-05 11:03:42 +0530872
873 /*go to space after WLS_BATCHING_SET command*/
874 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
875 /*no argument after the command*/
876 if (NULL == inPtr)
877 {
878 return -EINVAL;
879 }
880
881 /*no space after the command*/
882 else if (SPACE_ASCII_VALUE != *inPtr)
883 {
884 return -EINVAL;
885 }
886
887 /*removing empty spaces*/
888 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
889
890 /*no argument followed by spaces*/
891 if ('\0' == *inPtr)
892 {
893 return -EINVAL;
894 }
895
896 /*check and parse SCANFREQ*/
897 if ((strncmp(inPtr, "SCANFREQ", 8) == 0))
898 {
899 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800900 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800901
Rajeev Kumarc933d982013-11-18 20:04:20 -0800902 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800903 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800904 nScanFreq = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800905 }
906
Rajeev79dbe4c2013-10-05 11:03:42 +0530907 if ( (NULL == inPtr) || (TRUE == lastArg))
908 {
909 return -EINVAL;
910 }
911 }
912
913 /*check and parse MSCAN*/
914 if ((strncmp(inPtr, "MSCAN", 5) == 0))
915 {
916 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800917 &nMscan, &lastArg);
918
919 if (0 == nMscan)
920 {
921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
922 "invalid MSCAN=%d", nMscan);
923 return -EINVAL;
924 }
925
Rajeev79dbe4c2013-10-05 11:03:42 +0530926 if (TRUE == lastArg)
927 {
928 goto done;
929 }
930 else if (NULL == inPtr)
931 {
932 return -EINVAL;
933 }
934 }
935 else
936 {
937 return -EINVAL;
938 }
939
940 /*check and parse BESTN*/
941 if ((strncmp(inPtr, "BESTN", 5) == 0))
942 {
943 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800944 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800945
Rajeev Kumarc933d982013-11-18 20:04:20 -0800946 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800947 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800948 nBestN = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800949 }
950
Rajeev79dbe4c2013-10-05 11:03:42 +0530951 if (TRUE == lastArg)
952 {
953 goto done;
954 }
955 else if (NULL == inPtr)
956 {
957 return -EINVAL;
958 }
959 }
960
961 /*check and parse CHANNEL*/
962 if ((strncmp(inPtr, "CHANNEL", 7) == 0))
963 {
964 inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg);
Rajeev Kumarc933d982013-11-18 20:04:20 -0800965
Rajeev79dbe4c2013-10-05 11:03:42 +0530966 if (('A' == val) || ('a' == val))
967 {
c_hpothuebf89732014-02-25 13:00:24 +0530968 ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530969 }
970 else if (('B' == val) || ('b' == val))
971 {
c_hpothuebf89732014-02-25 13:00:24 +0530972 ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530973 }
974 else
975 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800976 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
977 }
978
979 if (TRUE == lastArg)
980 {
981 goto done;
982 }
983 else if (NULL == inPtr)
984 {
Rajeev79dbe4c2013-10-05 11:03:42 +0530985 return -EINVAL;
986 }
987 }
988
989 /*check and parse RTT*/
990 if ((strncmp(inPtr, "RTT", 3) == 0))
991 {
992 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800993 &nRtt, &lastArg);
Rajeev79dbe4c2013-10-05 11:03:42 +0530994 if (TRUE == lastArg)
995 {
996 goto done;
997 }
998 if (NULL == inPtr)
999 {
1000 return -EINVAL;
1001 }
1002 }
1003
1004
1005done:
1006
Rajeev Kumar45e64a72013-11-18 19:48:15 -08001007 pHddSetBatchScanReq->scanFrequency = nScanFreq;
1008 pHddSetBatchScanReq->numberOfScansToBatch = nMscan;
1009 pHddSetBatchScanReq->bestNetwork = nBestN;
1010 pHddSetBatchScanReq->rfBand = ucRfBand;
1011 pHddSetBatchScanReq->rtt = nRtt;
1012
Rajeev79dbe4c2013-10-05 11:03:42 +05301013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1014 "Received WLS_BATCHING_SET with SCANFREQ=%d "
1015 "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d",
1016 pHddSetBatchScanReq->scanFrequency,
1017 pHddSetBatchScanReq->numberOfScansToBatch,
1018 pHddSetBatchScanReq->bestNetwork,
1019 pHddSetBatchScanReq->rfBand,
1020 pHddSetBatchScanReq->rtt);
1021
1022 return 0;
1023}/*End of hdd_parse_set_batchscan_command*/
1024
1025/**---------------------------------------------------------------------------
1026
1027 \brief hdd_set_batch_scan_req_callback () - This function is called after
1028 receiving set batch scan response from FW and it saves set batch scan
1029 response data FW to HDD context and sets the completion event on
1030 which hdd_ioctl is waiting
1031
1032 \param - callbackContext Pointer to HDD adapter
1033 \param - pRsp Pointer to set batch scan response data received from FW
1034
1035 \return - nothing
1036
1037 --------------------------------------------------------------------------*/
1038static void hdd_set_batch_scan_req_callback
1039(
1040 void *callbackContext,
1041 tSirSetBatchScanRsp *pRsp
1042)
1043{
1044 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
1045 tSirSetBatchScanRsp *pHddSetBatchScanRsp;
1046
1047 /*sanity check*/
1048 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1049 {
1050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1051 "%s: Invalid pAdapter magic", __func__);
1052 VOS_ASSERT(0);
1053 return;
1054 }
1055 pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp;
1056
1057 /*save set batch scan response*/
1058 pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch;
1059
1060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1061 "Received set batch scan rsp from FW with nScansToBatch=%d",
1062 pHddSetBatchScanRsp->nScansToBatch);
1063
1064 pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE;
1065 complete(&pAdapter->hdd_set_batch_scan_req_var);
1066
1067 return;
1068}/*End of hdd_set_batch_scan_req_callback*/
1069
1070
1071/**---------------------------------------------------------------------------
1072
1073 \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta
1074 info in hdd batch scan response queue
1075
1076 \param - pAdapter Pointer to hdd adapter
1077 \param - pAPMetaInfo Pointer to access point meta info
1078 \param - scanId scan ID of batch scan response
1079 \param - isLastAp tells whether AP is last AP in batch scan response or not
1080
1081 \return - nothing
1082
1083 --------------------------------------------------------------------------*/
1084static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter,
1085 tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp)
1086{
1087 tHddBatchScanRsp *pHead;
1088 tHddBatchScanRsp *pNode;
1089 tHddBatchScanRsp *pPrev;
1090 tHddBatchScanRsp *pTemp;
1091 tANI_U8 ssidLen;
1092
1093 /*head of hdd batch scan response queue*/
1094 pHead = pAdapter->pBatchScanRsp;
1095
1096 pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp));
1097 if (NULL == pNode)
1098 {
1099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1100 "%s: Could not allocate memory", __func__);
1101 VOS_ASSERT(0);
1102 return;
1103 }
1104
1105 vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid,
1106 sizeof(pNode->ApInfo.bssid));
1107 ssidLen = strlen(pApMetaInfo->ssid);
1108 if (SIR_MAX_SSID_SIZE < ssidLen)
1109 {
1110 /*invalid scan result*/
1111 vos_mem_free(pNode);
1112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1113 "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen);
1114 return;
1115 }
1116 vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen);
1117 /*null terminate ssid*/
1118 pNode->ApInfo.ssid[ssidLen] = '\0';
1119 pNode->ApInfo.ch = pApMetaInfo->ch;
1120 pNode->ApInfo.rssi = pApMetaInfo->rssi;
1121 pNode->ApInfo.age = pApMetaInfo->timestamp;
1122 pNode->ApInfo.batchId = scanId;
1123 pNode->ApInfo.isLastAp = isLastAp;
1124
1125 pNode->pNext = NULL;
1126 if (NULL == pHead)
1127 {
1128 pAdapter->pBatchScanRsp = pNode;
1129 }
1130 else
1131 {
1132 pTemp = pHead;
1133 while (NULL != pTemp)
1134 {
1135 pPrev = pTemp;
1136 pTemp = pTemp->pNext;
1137 }
1138 pPrev->pNext = pNode;
1139 }
1140
1141 return;
1142}/*End of hdd_populate_batch_scan_rsp_queue*/
1143
1144/**---------------------------------------------------------------------------
1145
1146 \brief hdd_batch_scan_result_ind_callback () - This function is called after
1147 receiving batch scan response indication from FW. It saves get batch scan
1148 response data in HDD batch scan response queue. This callback sets the
1149 completion event on which hdd_ioctl is waiting only after getting complete
1150 batch scan response data from FW
1151
1152 \param - callbackContext Pointer to HDD adapter
1153 \param - pRsp Pointer to get batch scan response data received from FW
1154
1155 \return - nothing
1156
1157 --------------------------------------------------------------------------*/
1158static void hdd_batch_scan_result_ind_callback
1159(
1160 void *callbackContext,
1161 void *pRsp
1162)
1163{
1164 v_BOOL_t isLastAp;
1165 tANI_U32 numApMetaInfo;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001166 tANI_U32 numNetworkInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301167 tANI_U32 numberScanList;
1168 tANI_U32 nextScanListOffset;
1169 tANI_U32 nextApMetaInfoOffset;
1170 hdd_adapter_t* pAdapter;
1171 tpSirBatchScanList pScanList;
1172 tpSirBatchScanNetworkInfo pApMetaInfo;
1173 tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/
1174 tSirSetBatchScanReq *pReq;
1175
1176 pAdapter = (hdd_adapter_t *)callbackContext;
1177 /*sanity check*/
Rajeev Kumar5286bb92013-12-05 11:52:10 -08001178 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Rajeev79dbe4c2013-10-05 11:03:42 +05301179 {
1180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1181 "%s: Invalid pAdapter magic", __func__);
1182 VOS_ASSERT(0);
1183 return;
1184 }
1185
1186 /*initialize locals*/
1187 pReq = &pAdapter->hddSetBatchScanReq;
1188 pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp;
1189 isLastAp = FALSE;
1190 numApMetaInfo = 0;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001191 numNetworkInScanList = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05301192 numberScanList = 0;
1193 nextScanListOffset = 0;
1194 nextApMetaInfoOffset = 0;
1195 pScanList = NULL;
1196 pApMetaInfo = NULL;
1197
1198 if ((NULL == pBatchScanRsp) || (NULL == pReq))
1199 {
1200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1201 "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq);
1202 isLastAp = TRUE;
1203 goto done;
1204 }
1205
1206 pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists;
1207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1208 "Batch scan rsp: numberScalList %d", numberScanList);
1209
1210 if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch))
1211 {
1212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1213 "%s: numberScanList %d", __func__, numberScanList);
1214 isLastAp = TRUE;
1215 goto done;
1216 }
1217
1218 while (numberScanList)
1219 {
Rajeev Kumarce651e42013-10-21 18:57:15 -07001220 pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults +
Rajeev79dbe4c2013-10-05 11:03:42 +05301221 nextScanListOffset);
1222 if (NULL == pScanList)
1223 {
1224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1225 "%s: pScanList is %p", __func__, pScanList);
1226 isLastAp = TRUE;
1227 goto done;
1228 }
Rajeev Kumarce651e42013-10-21 18:57:15 -07001229 numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumarce651e42013-10-21 18:57:15 -07001231 "Batch scan rsp: numApMetaInfo %d scanId %d",
1232 numApMetaInfo, pScanList->scanId);
Rajeev79dbe4c2013-10-05 11:03:42 +05301233
1234 if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork))
1235 {
1236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1237 "%s: numApMetaInfo %d", __func__, numApMetaInfo);
1238 isLastAp = TRUE;
1239 goto done;
1240 }
1241
Rajeev Kumarce651e42013-10-21 18:57:15 -07001242 /*Initialize next AP meta info offset for next scan list*/
1243 nextApMetaInfoOffset = 0;
1244
Rajeev79dbe4c2013-10-05 11:03:42 +05301245 while (numApMetaInfo)
1246 {
1247 pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList +
1248 nextApMetaInfoOffset);
1249 if (NULL == pApMetaInfo)
1250 {
1251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1252 "%s: pApMetaInfo is %p", __func__, pApMetaInfo);
1253 isLastAp = TRUE;
1254 goto done;
1255 }
1256 /*calculate AP age*/
1257 pApMetaInfo->timestamp =
1258 pBatchScanRsp->timestamp - pApMetaInfo->timestamp;
1259
1260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussaina7c8e412013-11-20 11:06:42 -08001261 "%s: bssId "MAC_ADDRESS_STR
1262 " ch %d rssi %d timestamp %d", __func__,
1263 MAC_ADDR_ARRAY(pApMetaInfo->bssid),
1264 pApMetaInfo->ch, pApMetaInfo->rssi,
1265 pApMetaInfo->timestamp);
Rajeev79dbe4c2013-10-05 11:03:42 +05301266
1267 /*mark last AP in batch scan response*/
1268 if ((TRUE == pBatchScanRsp->isLastResult) &&
1269 (1 == numberScanList) && (1 == numApMetaInfo))
1270 {
1271 isLastAp = TRUE;
1272 }
1273
1274 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1275 /*store batch scan repsonse in hdd queue*/
1276 hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo,
1277 pScanList->scanId, isLastAp);
1278 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1279
1280 nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo);
1281 numApMetaInfo--;
1282 }
1283
Rajeev Kumarce651e42013-10-21 18:57:15 -07001284 nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8))
1285 + (sizeof(tSirBatchScanNetworkInfo)
1286 * numNetworkInScanList));
Rajeev79dbe4c2013-10-05 11:03:42 +05301287 numberScanList--;
1288 }
1289
1290done:
1291
1292 /*notify hdd_ioctl only if complete batch scan rsp is received and it was
1293 requested from hdd_ioctl*/
1294 if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) &&
1295 (TRUE == isLastAp))
1296 {
1297 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1298 complete(&pAdapter->hdd_get_batch_scan_req_var);
1299 }
1300
1301 return;
1302}/*End of hdd_batch_scan_result_ind_callback*/
1303
1304/**---------------------------------------------------------------------------
1305
1306 \brief hdd_format_batch_scan_rsp () - This function formats batch scan
1307 response as per batch scan FR request format by putting proper markers
1308
1309 \param - pDest pointer to destination buffer
1310 \param - cur_len current length
1311 \param - tot_len total remaining size which can be written to user space
1312 \param - pApMetaInfo Pointer to get batch scan response AP meta info
1313 \param - pAdapter Pointer to HDD adapter
1314
1315 \return - ret no of characters written
1316
1317 --------------------------------------------------------------------------*/
1318static tANI_U32
1319hdd_format_batch_scan_rsp
1320(
1321 tANI_U8 *pDest,
1322 tANI_U32 cur_len,
1323 tANI_U32 tot_len,
1324 tHddBatchScanRsp *pApMetaInfo,
1325 hdd_adapter_t* pAdapter
1326)
1327{
1328 tANI_U32 ret = 0;
1329 tANI_U32 rem_len = 0;
1330 tANI_U8 temp_len = 0;
1331 tANI_U8 temp_total_len = 0;
1332 tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE];
1333 tANI_U8 *pTemp = temp;
1334
1335 /*Batch scan reponse needs to be returned to user space in
1336 following format:
1337 "scancount=X\n" where X is the number of scans in current batch
1338 batch
1339 "trunc\n" optional present if current scan truncated
1340 "bssid=XX:XX:XX:XX:XX:XX\n"
1341 "ssid=XXXX\n"
1342 "freq=X\n" frequency in Mhz
1343 "level=XX\n"
1344 "age=X\n" ms
1345 "dist=X\n" cm (-1 if not available)
1346 "errror=X\n" (-1if not available)
1347 "====\n" (end of ap marker)
1348 "####\n" (end of scan marker)
1349 "----\n" (end of results)*/
1350 /*send scan result in above format to user space based on
1351 available length*/
1352 /*The GET response may have more data than the driver can return in its
1353 buffer. In that case the buffer should be filled to the nearest complete
1354 scan, ending with "%%%%".Subsequent callsshould return the remaining data
1355 starting with the next scan (optional .trunc\n., .apcount=X\n., etc).
1356 The final buffer should end with "----\n"*/
1357
1358 /*sanity*/
1359 if (cur_len > tot_len)
1360 {
1361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1362 "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len);
1363 return 0;
1364 }
1365 else
1366 {
1367 rem_len = (tot_len - cur_len);
1368 }
1369
1370 /*end scan marker*/
1371 if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id)
1372 {
1373 temp_len = snprintf(pTemp, sizeof(temp), "####\n");
1374 pTemp += temp_len;
1375 temp_total_len += temp_len;
1376 }
1377
1378 /*bssid*/
1379 temp_len = snprintf(pTemp, sizeof(temp),
1380 "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n",
1381 pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1],
1382 pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3],
1383 pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]);
1384 pTemp += temp_len;
1385 temp_total_len += temp_len;
1386
1387 /*ssid*/
1388 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n",
1389 pApMetaInfo->ApInfo.ssid);
1390 pTemp += temp_len;
1391 temp_total_len += temp_len;
1392
1393 /*freq*/
1394 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n",
Rajeev Kumarc40f7512013-11-04 14:13:23 -08001395 sme_ChnToFreq(pApMetaInfo->ApInfo.ch));
Rajeev79dbe4c2013-10-05 11:03:42 +05301396 pTemp += temp_len;
1397 temp_total_len += temp_len;
1398
1399 /*level*/
1400 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n",
1401 pApMetaInfo->ApInfo.rssi);
1402 pTemp += temp_len;
1403 temp_total_len += temp_len;
1404
1405 /*age*/
Jeff Johnson02797792013-10-26 19:17:13 -07001406 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n",
Rajeev79dbe4c2013-10-05 11:03:42 +05301407 pApMetaInfo->ApInfo.age);
1408 pTemp += temp_len;
1409 temp_total_len += temp_len;
1410
1411 /*dist*/
1412 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n");
1413 pTemp += temp_len;
1414 temp_total_len += temp_len;
1415
1416 /*error*/
1417 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n");
1418 pTemp += temp_len;
1419 temp_total_len += temp_len;
1420
1421 /*end AP marker*/
1422 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n");
1423 pTemp += temp_len;
1424 temp_total_len += temp_len;
1425
1426 /*last AP in batch scan response*/
1427 if(TRUE == pApMetaInfo->ApInfo.isLastAp)
1428 {
1429 /*end scan marker*/
1430 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n");
1431 pTemp += temp_len;
1432 temp_total_len += temp_len;
1433
1434 /*end batch scan result marker*/
1435 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n");
1436 pTemp += temp_len;
1437 temp_total_len += temp_len;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001438
Rajeev79dbe4c2013-10-05 11:03:42 +05301439 }
1440
1441 if (temp_total_len < rem_len)
1442 {
1443 ret = temp_total_len + 1;
1444 strlcpy(pDest, temp, ret);
1445 pAdapter->isTruncated = FALSE;
1446 }
1447 else
1448 {
1449 pAdapter->isTruncated = TRUE;
1450 if (rem_len >= strlen("%%%%"))
1451 {
Rajeev Kumarc933d982013-11-18 20:04:20 -08001452 ret = snprintf(pDest, sizeof(temp), "%%%%");
Rajeev79dbe4c2013-10-05 11:03:42 +05301453 }
Rajeev Kumarc933d982013-11-18 20:04:20 -08001454 else
Rajeev79dbe4c2013-10-05 11:03:42 +05301455 {
1456 ret = 0;
1457 }
1458 }
1459
1460 return ret;
1461
1462}/*End of hdd_format_batch_scan_rsp*/
1463
1464/**---------------------------------------------------------------------------
1465
1466 \brief hdd_populate_user_batch_scan_rsp() - This function populates user data
1467 buffer starting with head of hdd batch scan response queue
1468
1469 \param - pAdapter Pointer to HDD adapter
1470 \param - pDest Pointer to user data buffer
1471 \param - cur_len current offset in user buffer
1472 \param - rem_len remaining no of bytes in user buffer
1473
1474 \return - number of bytes written in user buffer
1475
1476 --------------------------------------------------------------------------*/
1477
1478tANI_U32 hdd_populate_user_batch_scan_rsp
1479(
1480 hdd_adapter_t* pAdapter,
1481 tANI_U8 *pDest,
1482 tANI_U32 cur_len,
1483 tANI_U32 rem_len
1484)
1485{
1486 tHddBatchScanRsp *pHead;
1487 tHddBatchScanRsp *pPrev;
1488 tANI_U32 len;
1489
Rajeev79dbe4c2013-10-05 11:03:42 +05301490 pAdapter->isTruncated = FALSE;
1491
1492 /*head of hdd batch scan response queue*/
1493 pHead = pAdapter->pBatchScanRsp;
1494 while (pHead)
1495 {
1496 len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead,
1497 pAdapter);
1498 pDest += len;
Rajeev Kumar292d2bb2013-10-23 15:01:44 -07001499 pDest--;
Rajeev79dbe4c2013-10-05 11:03:42 +05301500 cur_len += len;
1501 if(TRUE == pAdapter->isTruncated)
1502 {
1503 /*result is truncated return rest of scan rsp in next req*/
1504 cur_len = rem_len;
1505 break;
1506 }
1507 pPrev = pHead;
1508 pHead = pHead->pNext;
1509 pAdapter->pBatchScanRsp = pHead;
Rajeev Kumarbe17d8b2014-01-10 15:39:45 -08001510 if (TRUE == pPrev->ApInfo.isLastAp)
1511 {
1512 pAdapter->prev_batch_id = 0;
1513 }
1514 else
1515 {
1516 pAdapter->prev_batch_id = pPrev->ApInfo.batchId;
1517 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301518 vos_mem_free(pPrev);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001519 pPrev = NULL;
Rajeev79dbe4c2013-10-05 11:03:42 +05301520 }
1521
1522 return cur_len;
1523}/*End of hdd_populate_user_batch_scan_rsp*/
1524
1525/**---------------------------------------------------------------------------
1526
1527 \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch
1528 scan response data from HDD queue to user space
1529 It does following in detail:
1530 a) if HDD has enough data in its queue then it 1st copies data to user
1531 space and then send get batch scan indication message to FW. In this
1532 case it does not wait on any event and batch scan response data will
1533 be populated in HDD response queue in MC thread context after receiving
1534 indication from FW
1535 b) else send get batch scan indication message to FW and wait on an event
1536 which will be set once HDD receives complete batch scan response from
1537 FW and then this function returns batch scan response to user space
1538
1539 \param - pAdapter Pointer to HDD adapter
1540 \param - pPrivData Pointer to priv_data
1541
1542 \return - 0 for success -EFAULT for failure
1543
1544 --------------------------------------------------------------------------*/
1545
1546int hdd_return_batch_scan_rsp_to_user
1547(
1548 hdd_adapter_t* pAdapter,
1549 hdd_priv_data_t *pPrivData,
1550 tANI_U8 *command
1551)
1552{
1553 tANI_U8 *pDest;
1554 tANI_U32 count = 0;
1555 tANI_U32 len = 0;
1556 tANI_U32 cur_len = 0;
1557 tANI_U32 rem_len = 0;
1558 eHalStatus halStatus;
1559 unsigned long rc;
1560 tSirTriggerBatchScanResultInd *pReq;
1561
1562 pReq = &pAdapter->hddTriggerBatchScanResultInd;
1563 pReq->param = 0;/*batch scan client*/
1564 pDest = (tANI_U8 *)(command + pPrivData->used_len);
1565 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1566
1567 cur_len = pPrivData->used_len;
1568 if (pPrivData->total_len > pPrivData->used_len)
1569 {
1570 rem_len = pPrivData->total_len - pPrivData->used_len;
1571 }
1572 else
1573 {
1574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1575 "%s: Invalid user data buffer total_len %d used_len %d",
1576 __func__, pPrivData->total_len, pPrivData->used_len);
1577 return -EFAULT;
1578 }
1579
1580 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1581 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1582 cur_len, rem_len);
1583 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1584
1585 /*enough scan result available in cache to return to user space or
1586 scan result needs to be fetched 1st from fw and then return*/
Rajeev Kumar99db6262013-11-11 15:23:36 -08001587 if (len == cur_len)
Rajeev79dbe4c2013-10-05 11:03:42 +05301588 {
1589 pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE;
1590 halStatus = sme_TriggerBatchScanResultInd(
1591 WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1592 pAdapter->sessionId, hdd_batch_scan_result_ind_callback,
1593 pAdapter);
1594 if ( eHAL_STATUS_SUCCESS == halStatus )
1595 {
1596 if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp)
1597 {
1598 INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var);
1599 rc = wait_for_completion_timeout(
1600 &pAdapter->hdd_get_batch_scan_req_var,
1601 msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT));
1602 if (0 == rc)
1603 {
1604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1605 "%s: Timeout waiting to fetch batch scan rsp from fw",
1606 __func__);
1607 return -EFAULT;
1608 }
1609 }
1610
1611 len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE,
Jeff Johnson02797792013-10-26 19:17:13 -07001612 "scancount=%u\n", pAdapter->numScanList);
Rajeev79dbe4c2013-10-05 11:03:42 +05301613 pDest += len;
1614 cur_len += len;
1615
1616 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1617 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1618 cur_len, rem_len);
1619 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1620
1621 count = 0;
1622 len = (len - pPrivData->used_len);
1623 pDest = (command + pPrivData->used_len);
1624 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001625 "NEW BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301626 while(count < len)
1627 {
1628 printk("%c", *(pDest + count));
1629 count++;
1630 }
1631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1632 "%s: copy %d data to user buffer", __func__, len);
1633 if (copy_to_user(pPrivData->buf, pDest, len))
1634 {
1635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1636 "%s: failed to copy data to user buffer", __func__);
1637 return -EFAULT;
1638 }
1639 }
1640 else
1641 {
1642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1643 "sme_GetBatchScanScan returned failure halStatus %d",
1644 halStatus);
1645 return -EINVAL;
1646 }
1647 }
1648 else
1649 {
Rajeev79dbe4c2013-10-05 11:03:42 +05301650 count = 0;
1651 len = (len - pPrivData->used_len);
1652 pDest = (command + pPrivData->used_len);
1653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001654 "REMAINING TRUNCATED BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301655 while(count < len)
1656 {
1657 printk("%c", *(pDest + count));
1658 count++;
1659 }
Rajeev Kumar99db6262013-11-11 15:23:36 -08001660 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1661 "%s: copy %d data to user buffer", __func__, len);
Rajeev79dbe4c2013-10-05 11:03:42 +05301662 if (copy_to_user(pPrivData->buf, pDest, len))
1663 {
1664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1665 "%s: failed to copy data to user buffer", __func__);
1666 return -EFAULT;
1667 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301668 }
1669
1670 return 0;
1671} /*End of hdd_return_batch_scan_rsp_to_user*/
1672
Rajeev Kumar8b373292014-01-08 20:36:55 -08001673
1674/**---------------------------------------------------------------------------
1675
1676 \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING
1677 IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled:
1678 WLS_BATCHING VERSION
1679 WLS_BATCHING SET
1680 WLS_BATCHING GET
1681 WLS_BATCHING STOP
1682
1683 \param - pAdapter Pointer to HDD adapter
1684 \param - pPrivdata Pointer to priv_data
1685 \param - command Pointer to command
1686
1687 \return - 0 for success -EFAULT for failure
1688
1689 --------------------------------------------------------------------------*/
1690
1691int hdd_handle_batch_scan_ioctl
1692(
1693 hdd_adapter_t *pAdapter,
1694 hdd_priv_data_t *pPrivdata,
1695 tANI_U8 *command
1696)
1697{
1698 int ret = 0;
Yue Mae36e3552014-03-05 17:06:20 -08001699 hdd_context_t *pHddCtx;
1700
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301701 ENTER();
1702
Yue Mae36e3552014-03-05 17:06:20 -08001703 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1704 ret = wlan_hdd_validate_context(pHddCtx);
1705 if (ret)
1706 {
Yue Mae36e3552014-03-05 17:06:20 -08001707 goto exit;
1708 }
Rajeev Kumar8b373292014-01-08 20:36:55 -08001709
1710 if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0)
1711 {
1712 char extra[32];
1713 tANI_U8 len = 0;
1714 tANI_U8 version = HDD_BATCH_SCAN_VERSION;
1715
1716 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1717 {
1718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1719 "%s: Batch scan feature is not supported by FW", __func__);
1720 ret = -EINVAL;
1721 goto exit;
1722 }
1723
1724 len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d",
1725 version);
1726 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1727 {
1728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1729 "%s: failed to copy data to user buffer", __func__);
1730 ret = -EFAULT;
1731 goto exit;
1732 }
1733 ret = HDD_BATCH_SCAN_VERSION;
1734 }
1735 else if (strncmp(command, "WLS_BATCHING SET", 16) == 0)
1736 {
1737 int status;
1738 tANI_U8 *value = (command + 16);
1739 eHalStatus halStatus;
1740 unsigned long rc;
1741 tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq;
1742 tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp;
1743
1744 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1745 {
1746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1747 "%s: Batch scan feature is not supported by FW", __func__);
1748 ret = -EINVAL;
1749 goto exit;
1750 }
1751
1752 if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) &&
1753 (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) &&
1754 (WLAN_HDD_P2P_GO != pAdapter->device_mode) &&
1755 (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode))
1756 {
1757 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301758 "Received WLS_BATCHING SET command in invalid mode %s (%d) "
Rajeev Kumar8b373292014-01-08 20:36:55 -08001759 "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode",
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301760 hdd_device_modetoString(pAdapter->device_mode),
1761 pAdapter->device_mode);
Rajeev Kumar8b373292014-01-08 20:36:55 -08001762 ret = -EINVAL;
1763 goto exit;
1764 }
1765
1766 status = hdd_parse_set_batchscan_command(value, pReq);
1767 if (status)
1768 {
1769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1770 "Invalid WLS_BATCHING SET command");
1771 ret = -EINVAL;
1772 goto exit;
1773 }
1774
1775
1776 pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE;
1777 halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1778 pAdapter->sessionId, hdd_set_batch_scan_req_callback,
1779 pAdapter);
1780
1781 if ( eHAL_STATUS_SUCCESS == halStatus )
1782 {
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301783 char extra[32];
1784 tANI_U8 len = 0;
1785 tANI_U8 mScan = 0;
1786
Rajeev Kumar8b373292014-01-08 20:36:55 -08001787 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1788 "sme_SetBatchScanReq returned success halStatus %d",
1789 halStatus);
1790 if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp)
1791 {
1792 INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var);
1793 rc = wait_for_completion_timeout(
1794 &pAdapter->hdd_set_batch_scan_req_var,
1795 msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT));
1796 if (0 == rc)
1797 {
1798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1799 "%s: Timeout waiting for set batch scan to complete",
1800 __func__);
1801 ret = -EINVAL;
1802 goto exit;
1803 }
1804 }
1805 if ( !pRsp->nScansToBatch )
1806 {
1807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1808 "%s: Received set batch scan failure response from FW",
1809 __func__);
1810 ret = -EINVAL;
1811 goto exit;
1812 }
1813 /*As per the Batch Scan Framework API we should return the MIN of
1814 either MSCAN or the max # of scans firmware can cache*/
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301815 mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch);
Rajeev Kumar8b373292014-01-08 20:36:55 -08001816
1817 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED;
1818
1819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1820 "%s: request MSCAN %d response MSCAN %d ret %d",
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301821 __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan);
1822 len = scnprintf(extra, sizeof(extra), "%d", mScan);
1823 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1824 {
1825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1826 "%s: failed to copy MSCAN value to user buffer", __func__);
1827 ret = -EFAULT;
1828 goto exit;
1829 }
Rajeev Kumar8b373292014-01-08 20:36:55 -08001830 }
1831 else
1832 {
1833 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1834 "sme_SetBatchScanReq returned failure halStatus %d",
1835 halStatus);
1836 ret = -EINVAL;
1837 goto exit;
1838 }
1839 }
1840 else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0)
1841 {
1842 eHalStatus halStatus;
1843 tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd;
1844 pInd->param = 0;
1845
1846 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1847 {
1848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1849 "%s: Batch scan feature is not supported by FW", __func__);
1850 ret = -EINVAL;
1851 goto exit;
1852 }
1853
1854 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1855 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05301856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Rajeev Kumar8b373292014-01-08 20:36:55 -08001857 "Batch scan is not yet enabled batch scan state %d",
1858 pAdapter->batchScanState);
1859 ret = -EINVAL;
1860 goto exit;
1861 }
1862
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001863 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1864 hdd_deinit_batch_scan(pAdapter);
1865 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1866
Rajeev Kumar8b373292014-01-08 20:36:55 -08001867 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
1868
1869 halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd,
1870 pAdapter->sessionId);
1871 if ( eHAL_STATUS_SUCCESS == halStatus )
1872 {
1873 ret = 0;
1874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1875 "sme_StopBatchScanInd returned success halStatus %d",
1876 halStatus);
1877 }
1878 else
1879 {
1880 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1881 "sme_StopBatchScanInd returned failure halStatus %d",
1882 halStatus);
1883 ret = -EINVAL;
1884 goto exit;
1885 }
1886 }
1887 else if (strncmp(command, "WLS_BATCHING GET", 16) == 0)
1888 {
1889 tANI_U32 remain_len;
1890
1891 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1892 {
1893 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1894 "%s: Batch scan feature is not supported by FW", __func__);
1895 ret = -EINVAL;
1896 goto exit;
1897 }
1898
1899 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1900 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05301901 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Rajeev Kumar8b373292014-01-08 20:36:55 -08001902 "Batch scan is not yet enabled could not return results"
1903 "Batch Scan state %d",
1904 pAdapter->batchScanState);
1905 ret = -EINVAL;
1906 goto exit;
1907 }
1908
1909 pPrivdata->used_len = 16;
1910 remain_len = pPrivdata->total_len - pPrivdata->used_len;
1911 if (remain_len < pPrivdata->total_len)
1912 {
1913 /*Clear previous batch scan response data if any*/
1914 vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len);
1915 }
1916 else
1917 {
1918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1919 "Invalid total length from user space can't fetch batch"
1920 " scan response total_len %d used_len %d remain len %d",
1921 pPrivdata->total_len, pPrivdata->used_len, remain_len);
1922 ret = -EINVAL;
1923 goto exit;
1924 }
1925 ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command);
1926 }
1927
1928exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301929 EXIT();
Rajeev Kumar8b373292014-01-08 20:36:55 -08001930 return ret;
1931}
1932
1933
Rajeev79dbe4c2013-10-05 11:03:42 +05301934#endif/*End of FEATURE_WLAN_BATCH_SCAN*/
1935
c_hpothu92367912014-05-01 15:18:17 +05301936static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data)
1937{
c_hpothu39eb1e32014-06-26 16:31:50 +05301938 bcnMissRateContext_t *pCBCtx;
1939
1940 if (NULL == data)
1941 {
1942 hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL"));
1943 return;
1944 }
c_hpothu92367912014-05-01 15:18:17 +05301945
1946 /* there is a race condition that exists between this callback
1947 function and the caller since the caller could time out either
1948 before or while this code is executing. we use a spinlock to
1949 serialize these actions */
1950 spin_lock(&hdd_context_lock);
1951
c_hpothu39eb1e32014-06-26 16:31:50 +05301952 pCBCtx = (bcnMissRateContext_t *)data;
c_hpothu92367912014-05-01 15:18:17 +05301953 gbcnMissRate = -1;
1954
c_hpothu39eb1e32014-06-26 16:31:50 +05301955 if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC)
c_hpothu92367912014-05-01 15:18:17 +05301956 {
1957 hddLog(VOS_TRACE_LEVEL_ERROR,
c_hpothu39eb1e32014-06-26 16:31:50 +05301958 FL("invalid context magic: %08x"), pCBCtx->magic);
c_hpothu92367912014-05-01 15:18:17 +05301959 spin_unlock(&hdd_context_lock);
1960 return ;
1961 }
1962
1963 if (VOS_STATUS_SUCCESS == status)
1964 {
c_hpothu39eb1e32014-06-26 16:31:50 +05301965 gbcnMissRate = bcnMissRate;
c_hpothu92367912014-05-01 15:18:17 +05301966 }
c_hpothu39eb1e32014-06-26 16:31:50 +05301967 else
1968 {
1969 hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate"));
1970 }
1971
c_hpothu92367912014-05-01 15:18:17 +05301972 complete(&(pCBCtx->completion));
1973 spin_unlock(&hdd_context_lock);
1974
1975 return;
1976}
1977
Abhishek Singh08aa7762014-12-16 13:59:03 +05301978void hdd_FWStatisCB( VOS_STATUS status,
1979 tSirFwStatsResult *fwStatsResult, void *pContext )
Satyanarayana Dash72806012014-12-02 14:30:08 +05301980{
1981 fwStatsContext_t *fwStatsCtx;
Satyanarayana Dash72806012014-12-02 14:30:08 +05301982 hdd_adapter_t *pAdapter;
1983
1984 hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status);
1985
Abhishek Singh08aa7762014-12-16 13:59:03 +05301986 if (NULL == pContext)
Satyanarayana Dash72806012014-12-02 14:30:08 +05301987 {
1988 hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL"));
1989 return;
1990 }
1991 /* there is a race condition that exists between this callback
1992 function and the caller since the caller could time out either
1993 before or while this code is executing. we use a spinlock to
1994 serialize these actions */
1995 spin_lock(&hdd_context_lock);
Abhishek Singh08aa7762014-12-16 13:59:03 +05301996 fwStatsCtx = (fwStatsContext_t *) pContext;
Satyanarayana Dash72806012014-12-02 14:30:08 +05301997 if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC)
1998 {
1999 hddLog(VOS_TRACE_LEVEL_ERROR,
2000 FL("invalid context magic: %08x"), fwStatsCtx->magic);
2001 spin_unlock(&hdd_context_lock);
2002 return;
2003 }
2004 pAdapter = fwStatsCtx->pAdapter;
2005 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2006 {
2007 hddLog(VOS_TRACE_LEVEL_ERROR,
2008 FL("pAdapter returned is NULL or invalid"));
2009 spin_unlock(&hdd_context_lock);
2010 return;
2011 }
2012 pAdapter->fwStatsRsp.type = 0;
Abhishek Singh08aa7762014-12-16 13:59:03 +05302013 if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStatsResult))
Satyanarayana Dash72806012014-12-02 14:30:08 +05302014 {
Satyanarayana Dash72806012014-12-02 14:30:08 +05302015 switch( fwStatsResult->type )
2016 {
2017 case FW_UBSP_STATS:
2018 {
Abhishek Singh08aa7762014-12-16 13:59:03 +05302019 memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(tSirFwStatsResult));
Satyanarayana Dash72806012014-12-02 14:30:08 +05302020 hddLog(VOS_TRACE_LEVEL_INFO,
2021 FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"),
Abhishek Singh08aa7762014-12-16 13:59:03 +05302022 pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_enter_cnt,
2023 pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_jump_ddr_cnt);
Satyanarayana Dash72806012014-12-02 14:30:08 +05302024 }
2025 break;
2026 default:
2027 {
2028 hddLog(VOS_TRACE_LEVEL_ERROR,
2029 FL(" No handling for stats type %d"),fwStatsResult->type);
2030 }
2031 }
2032 }
2033 complete(&(fwStatsCtx->completion));
2034 spin_unlock(&hdd_context_lock);
2035 return;
2036}
2037
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302038static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len)
2039{
2040 int ret = 0;
2041
2042 if (!pCfg || !command || !extra || !len)
2043 {
2044 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2045 "%s: argument passsed for GETDWELLTIME is incorrect", __func__);
2046 ret = -EINVAL;
2047 return ret;
2048 }
2049
2050 if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0)
2051 {
2052 *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n",
2053 (int)pCfg->nActiveMaxChnTime);
2054 return ret;
2055 }
2056 else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0)
2057 {
2058 *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n",
2059 (int)pCfg->nActiveMinChnTime);
2060 return ret;
2061 }
2062 else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0)
2063 {
2064 *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n",
2065 (int)pCfg->nPassiveMaxChnTime);
2066 return ret;
2067 }
2068 else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0)
2069 {
2070 *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n",
2071 (int)pCfg->nPassiveMinChnTime);
2072 return ret;
2073 }
Rajesh Babu Prathipati0fd227e2014-07-05 12:50:00 +05302074 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
2075 {
2076 *len = scnprintf(extra, n, "GETDWELLTIME %u \n",
2077 (int)pCfg->nActiveMaxChnTime);
2078 return ret;
2079 }
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302080 else
2081 {
2082 ret = -EINVAL;
2083 }
2084
2085 return ret;
2086}
2087
2088static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command)
2089{
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302090 tHalHandle hHal;
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302091 hdd_config_t *pCfg;
2092 tANI_U8 *value = command;
2093 int val = 0, ret = 0, temp = 0;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302094 tSmeConfigParams smeConfig;
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302095
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302096 if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini)
2097 || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter))))
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302098 {
2099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2100 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
2101 ret = -EINVAL;
2102 return ret;
2103 }
2104
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302105 vos_mem_zero(&smeConfig, sizeof(smeConfig));
2106 sme_GetConfigParam(hHal, &smeConfig);
2107
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302108 if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 )
2109 {
2110 value = value + 24;
2111 temp = kstrtou32(value, 10, &val);
2112 if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
2113 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
2114 {
2115 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2116 "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__);
2117 ret = -EFAULT;
2118 return ret;
2119 }
2120 pCfg->nActiveMaxChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302121 smeConfig.csrConfig.nActiveMaxChnTime = val;
2122 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302123 }
2124 else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0)
2125 {
2126 value = value + 24;
2127 temp = kstrtou32(value, 10, &val);
2128 if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN ||
2129 val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX )
2130 {
2131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2132 "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__);
2133 ret = -EFAULT;
2134 return ret;
2135 }
2136 pCfg->nActiveMinChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302137 smeConfig.csrConfig.nActiveMinChnTime = val;
2138 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302139 }
2140 else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0)
2141 {
2142 value = value + 25;
2143 temp = kstrtou32(value, 10, &val);
2144 if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN ||
2145 val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX )
2146 {
2147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2148 "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__);
2149 ret = -EFAULT;
2150 return ret;
2151 }
2152 pCfg->nPassiveMaxChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302153 smeConfig.csrConfig.nPassiveMaxChnTime = val;
2154 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302155 }
2156 else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0)
2157 {
2158 value = value + 25;
2159 temp = kstrtou32(value, 10, &val);
2160 if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN ||
2161 val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX )
2162 {
2163 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2164 "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__);
2165 ret = -EFAULT;
2166 return ret;
2167 }
2168 pCfg->nPassiveMinChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302169 smeConfig.csrConfig.nPassiveMinChnTime = val;
2170 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302171 }
Rajesh Babu Prathipati0fd227e2014-07-05 12:50:00 +05302172 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
2173 {
2174 value = value + 13;
2175 temp = kstrtou32(value, 10, &val);
2176 if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
2177 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
2178 {
2179 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2180 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
2181 ret = -EFAULT;
2182 return ret;
2183 }
2184 pCfg->nActiveMaxChnTime = val;
2185 smeConfig.csrConfig.nActiveMaxChnTime = val;
2186 sme_UpdateConfig(hHal, &smeConfig);
2187 }
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302188 else
2189 {
2190 ret = -EINVAL;
2191 }
2192
2193 return ret;
2194}
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +05302195static int hdd_cmd_setFccChannel(hdd_context_t *pHddCtx, tANI_U8 *cmd,
2196 tANI_U8 cmd_len)
2197{
2198 tANI_U8 *value;
2199 tANI_U8 fcc_constraint;
2200
2201 eHalStatus status;
2202 int ret = 0;
2203 value = cmd + cmd_len + 1;
2204
2205 ret = kstrtou8(value, 10, &fcc_constraint);
2206 if ((ret < 0) || (fcc_constraint > 1)) {
2207 /*
2208 * If the input value is greater than max value of datatype,
2209 * then also it is a failure
2210 */
2211 hddLog(VOS_TRACE_LEVEL_ERROR,
2212 "%s: value out of range", __func__);
2213 return -EINVAL;
2214 }
2215
2216 status = sme_handleSetFccChannel(pHddCtx->hHal, fcc_constraint);
2217 if (status != eHAL_STATUS_SUCCESS)
2218 ret = -EPERM;
2219
2220 return ret;
2221}
2222
2223
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302224
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002225static int hdd_driver_command(hdd_adapter_t *pAdapter,
2226 hdd_priv_data_t *ppriv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -07002227{
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 hdd_priv_data_t priv_data;
2229 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302230 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2231 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002232 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302233 int status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302234
2235 ENTER();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002236 /*
2237 * Note that valid pointers are provided by caller
2238 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002240 /* copy to local struct to avoid numerous changes to legacy code */
2241 priv_data = *ppriv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002243 if (priv_data.total_len <= 0 ||
2244 priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN)
Sameer Thalappil8ef3a0e2013-04-05 14:36:04 -07002245 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002246 hddLog(VOS_TRACE_LEVEL_WARN,
2247 "%s:invalid priv_data.total_len(%d)!!!", __func__,
2248 priv_data.total_len);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002249 ret = -EINVAL;
2250 goto exit;
2251 }
Kaushik, Sushant96122442014-10-21 16:40:18 +05302252 status = wlan_hdd_validate_context(pHddCtx);
2253 if (0 != status)
2254 {
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302255 ret = -EINVAL;
2256 goto exit;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302257 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002258 /* Allocate +1 for '\0' */
2259 command = kmalloc(priv_data.total_len + 1, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if (!command)
2261 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002262 hddLog(VOS_TRACE_LEVEL_ERROR,
2263 "%s: failed to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 ret = -ENOMEM;
2265 goto exit;
2266 }
2267
2268 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
2269 {
2270 ret = -EFAULT;
2271 goto exit;
2272 }
2273
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002274 /* Make sure the command is NUL-terminated */
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002275 command[priv_data.total_len] = '\0';
2276
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002277 /* at one time the following block of code was conditional. braces
2278 * have been retained to avoid re-indenting the legacy code
2279 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 {
2281 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2282
2283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002284 "%s: Received %s cmd from Wi-Fi GUI***", __func__, command);
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
2286 if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 )
2287 {
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302288 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2289 TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL,
2290 pAdapter->sessionId, (unsigned)
2291 (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 |
2292 *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 |
2293 *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 |
2294 *(pHddCtx->p2pDeviceAddress.bytes+5))));
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes,
2296 sizeof(tSirMacAddr)))
2297 {
2298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002299 "%s: failed to copy data to user buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 ret = -EFAULT;
2301 }
2302 }
Amar Singhal0974e402013-02-12 14:27:46 -08002303 else if(strncmp(command, "SETBAND", 7) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 {
Amar Singhal0974e402013-02-12 14:27:46 -08002305 tANI_U8 *ptr = command ;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002306
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 /* Change band request received */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002308
2309 /* First 8 bytes will have "SETBAND " and
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 * 9 byte will have band setting value */
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal0974e402013-02-12 14:27:46 -08002312 "%s: SetBandCommand Info comm %s UL %d, TL %d", __func__, command, priv_data.used_len, priv_data.total_len);
Anand N Sunkad27354cf2015-07-13 14:39:11 +05302313 if(VOS_FTM_MODE != hdd_get_conparam())
2314 {
2315 /* Change band request received */
2316 ret = hdd_setBand_helper(pAdapter->dev, ptr);
2317 if(ret < 0)
2318 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2319 "%s: failed to set band ret=%d", __func__, ret);
2320 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002321 }
Kiet Lamf040f472013-11-20 21:15:23 +05302322 else if(strncmp(command, "SETWMMPS", 8) == 0)
2323 {
2324 tANI_U8 *ptr = command;
2325 ret = hdd_wmmps_helper(pAdapter, ptr);
2326 }
Agarwal Ashishef54a182014-12-16 15:07:31 +05302327
2328 else if(strncmp(command, "TDLSSCAN", 8) == 0)
2329 {
2330 tANI_U8 *ptr = command;
2331 ret = hdd_set_tdls_scan_type(pAdapter, ptr);
2332 }
2333
Jeff Johnson32d95a32012-09-10 13:15:23 -07002334 else if ( strncasecmp(command, "COUNTRY", 7) == 0 )
2335 {
2336 char *country_code;
2337
2338 country_code = command + 8;
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07002339
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002340 INIT_COMPLETION(pAdapter->change_country_code);
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07002341 hdd_checkandupdate_dfssetting(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002342#ifndef CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302343 hdd_checkandupdate_phymode(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002344#endif
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002345 ret = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2346 (void *)(tSmeChangeCountryCallback)
2347 wlan_hdd_change_country_code_callback,
Abhishek Singha306a442013-11-07 18:39:01 +05302348 country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002349 if (eHAL_STATUS_SUCCESS == ret)
2350 {
2351 ret = wait_for_completion_interruptible_timeout(
2352 &pAdapter->change_country_code,
2353 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2354 if (0 >= ret)
2355 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out %d",
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302357 __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002358 }
2359 }
2360 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07002361 {
2362 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002363 "%s: SME Change Country code fail ret=%d", __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002364 ret = -EINVAL;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002365 }
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002366
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002367 }
2368 /*
2369 command should be a string having format
2370 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
2371 */
Amar Singhal0974e402013-02-12 14:27:46 -08002372 else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002373 {
Amar Singhal0974e402013-02-12 14:27:46 -08002374 tANI_U8 *ptr = command;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002375
2376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002377 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002378
Mahesh Kumar Kalikot Veetil2aad8d82013-02-07 12:31:28 -08002379 ret = sapSetPreferredChannel(ptr);
Jeff Johnson32d95a32012-09-10 13:15:23 -07002380 }
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002381 else if(strncmp(command, "SETSUSPENDMODE", 14) == 0)
2382 {
2383 int suspend = 0;
2384 tANI_U8 *ptr = (tANI_U8*)command + 15;
2385
2386 suspend = *ptr - '0';
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302387 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2388 TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL,
2389 pAdapter->sessionId, suspend));
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002390 hdd_set_wlan_suspend_mode(suspend);
2391 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002392#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2393 else if (strncmp(command, "SETROAMTRIGGER", 14) == 0)
2394 {
2395 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002396 tANI_S8 rssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002397 tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT;
2398 eHalStatus status = eHAL_STATUS_SUCCESS;
2399
2400 /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */
2401 value = value + 15;
2402
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002403 /* Convert the value from ascii to integer */
2404 ret = kstrtos8(value, 10, &rssi);
2405 if (ret < 0)
2406 {
2407 /* If the input value is greater than max value of datatype, then also
2408 kstrtou8 fails */
2409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2410 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdafa7157d2013-10-31 10:14:22 -07002411 __func__,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002412 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2413 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2414 ret = -EINVAL;
2415 goto exit;
2416 }
2417
Srinivas Girigowdade697412013-02-14 16:31:48 -08002418 lookUpThreshold = abs(rssi);
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002419
Srinivas Girigowdade697412013-02-14 16:31:48 -08002420 if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) ||
2421 (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX))
2422 {
2423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2424 "Neighbor lookup threshold value %d is out of range"
2425 " (Min: %d Max: %d)", lookUpThreshold,
2426 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2427 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2428 ret = -EINVAL;
2429 goto exit;
2430 }
2431
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302432 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2433 TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL,
2434 pAdapter->sessionId, lookUpThreshold));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2436 "%s: Received Command to Set Roam trigger"
2437 " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold);
2438
2439 pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold;
2440 status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold);
2441 if (eHAL_STATUS_SUCCESS != status)
2442 {
2443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2444 "%s: Failed to set roam trigger, try again", __func__);
2445 ret = -EPERM;
2446 goto exit;
2447 }
2448
2449 /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */
mukul sharmad6e1fdd2014-06-23 19:19:09 +05302450 pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002451 sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5);
2452 }
2453 else if (strncmp(command, "GETROAMTRIGGER", 14) == 0)
2454 {
2455 tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal));
2456 int rssi = (-1) * lookUpThreshold;
2457 char extra[32];
2458 tANI_U8 len = 0;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302459 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2460 TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL,
2461 pAdapter->sessionId, lookUpThreshold));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002462 len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi);
Srinivas Girigowda91719232015-07-13 15:10:10 +05302463 len = VOS_MIN(priv_data.total_len, len + 1);
2464 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002465 {
2466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2467 "%s: failed to copy data to user buffer", __func__);
2468 ret = -EFAULT;
2469 goto exit;
2470 }
2471 }
2472 else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0)
2473 {
2474 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002475 tANI_U8 roamScanPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002476 tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002477
Srinivas Girigowdade697412013-02-14 16:31:48 -08002478 /* input refresh period is in terms of seconds */
2479 /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */
2480 value = value + 18;
2481 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002482 ret = kstrtou8(value, 10, &roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002483 if (ret < 0)
2484 {
2485 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002486 kstrtou8 fails */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002487 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002488 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdade697412013-02-14 16:31:48 -08002489 __func__,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002490 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2491 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002492 ret = -EINVAL;
2493 goto exit;
2494 }
2495
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002496 if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) ||
2497 (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002498 {
2499 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002500 "Roam scan period value %d is out of range"
2501 " (Min: %d Max: %d)", roamScanPeriod,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002502 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2503 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002504 ret = -EINVAL;
2505 goto exit;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302506 }
2507 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2508 TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL,
2509 pAdapter->sessionId, roamScanPeriod));
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002510 neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002511
2512 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2513 "%s: Received Command to Set roam scan period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002514 " (Empty Scan refresh period) = %d", __func__, roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002515
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002516 pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod;
2517 sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002518 }
2519 else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0)
2520 {
2521 tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2522 char extra[32];
2523 tANI_U8 len = 0;
2524
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302525 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2526 TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL,
2527 pAdapter->sessionId, nEmptyScanRefreshPeriod));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002528 len = scnprintf(extra, sizeof(extra), "%s %d",
2529 "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002530 /* Returned value is in units of seconds */
Ratnam Rachuria72ba112015-07-17 13:27:03 +05302531 len = VOS_MIN(priv_data.total_len, len + 1);
2532 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002533 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2534 "%s: failed to copy data to user buffer", __func__);
2535 ret = -EFAULT;
2536 goto exit;
2537 }
2538 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002539 else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0)
2540 {
2541 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002542 tANI_U8 roamScanRefreshPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002543 tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002544
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002545 /* input refresh period is in terms of seconds */
2546 /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */
2547 value = value + 25;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002548
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002549 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002550 ret = kstrtou8(value, 10, &roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002551 if (ret < 0)
2552 {
2553 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002554 kstrtou8 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002555 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002556 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002557 __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002558 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2559 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2560 ret = -EINVAL;
2561 goto exit;
2562 }
2563
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002564 if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) ||
2565 (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)))
2566 {
2567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2568 "Neighbor scan results refresh period value %d is out of range"
2569 " (Min: %d Max: %d)", roamScanRefreshPeriod,
2570 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2571 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2572 ret = -EINVAL;
2573 goto exit;
2574 }
2575 neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000;
2576
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2578 "%s: Received Command to Set roam scan refresh period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002579 " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002580
2581 pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod;
2582 sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod);
2583 }
2584 else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0)
2585 {
2586 tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2587 char extra[32];
2588 tANI_U8 len = 0;
2589
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002590 len = scnprintf(extra, sizeof(extra), "%s %d",
2591 "GETROAMSCANREFRESHPERIOD", (value/1000));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002592 /* Returned value is in units of seconds */
Ratnam Rachuri2c9d6702015-07-17 13:25:16 +05302593 len = VOS_MIN(priv_data.total_len, len + 1);
2594 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002595 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2596 "%s: failed to copy data to user buffer", __func__);
2597 ret = -EFAULT;
2598 goto exit;
2599 }
2600 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002601#ifdef FEATURE_WLAN_LFR
2602 /* SETROAMMODE */
2603 else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0)
2604 {
2605 tANI_U8 *value = command;
2606 tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
2607
2608 /* Move pointer to ahead of SETROAMMODE<delimiter> */
2609 value = value + SIZE_OF_SETROAMMODE + 1;
2610
2611 /* Convert the value from ascii to integer */
2612 ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode);
2613 if (ret < 0)
2614 {
2615 /* If the input value is greater than max value of datatype, then also
2616 kstrtou8 fails */
2617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2618 "%s: kstrtou8 failed range [%d - %d]", __func__,
2619 CFG_LFR_FEATURE_ENABLED_MIN,
2620 CFG_LFR_FEATURE_ENABLED_MAX);
2621 ret = -EINVAL;
2622 goto exit;
2623 }
2624 if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
2625 (roamMode > CFG_LFR_FEATURE_ENABLED_MAX))
2626 {
2627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2628 "Roam Mode value %d is out of range"
2629 " (Min: %d Max: %d)", roamMode,
2630 CFG_LFR_FEATURE_ENABLED_MIN,
2631 CFG_LFR_FEATURE_ENABLED_MAX);
2632 ret = -EINVAL;
2633 goto exit;
2634 }
2635
2636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2637 "%s: Received Command to Set Roam Mode = %d", __func__, roamMode);
2638 /*
2639 * Note that
2640 * SETROAMMODE 0 is to enable LFR while
2641 * SETROAMMODE 1 is to disable LFR, but
2642 * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable.
2643 * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled.
2644 */
2645 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2646 roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */
2647 else
2648 roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */
2649
2650 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode;
2651 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode);
2652 }
2653 /* GETROAMMODE */
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05302654 else if (strncmp(command, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0)
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002655 {
2656 tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2657 char extra[32];
2658 tANI_U8 len = 0;
2659
2660 /*
2661 * roamMode value shall be inverted because the sementics is different.
2662 */
2663 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2664 roamMode = CFG_LFR_FEATURE_ENABLED_MAX;
2665 else
2666 roamMode = CFG_LFR_FEATURE_ENABLED_MIN;
2667
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002668 len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode);
Ratnam Rachuri28693eb2015-07-17 13:23:42 +05302669 len = VOS_MIN(priv_data.total_len, len + 1);
2670 if (copy_to_user(priv_data.buf, &extra, len)) {
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2672 "%s: failed to copy data to user buffer", __func__);
2673 ret = -EFAULT;
2674 goto exit;
2675 }
2676 }
2677#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08002678#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002679#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002680 else if (strncmp(command, "SETROAMDELTA", 12) == 0)
2681 {
2682 tANI_U8 *value = command;
2683 tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT;
2684
2685 /* Move pointer to ahead of SETROAMDELTA<delimiter> */
2686 value = value + 13;
2687 /* Convert the value from ascii to integer */
2688 ret = kstrtou8(value, 10, &roamRssiDiff);
2689 if (ret < 0)
2690 {
2691 /* If the input value is greater than max value of datatype, then also
2692 kstrtou8 fails */
2693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2694 "%s: kstrtou8 failed range [%d - %d]", __func__,
2695 CFG_ROAM_RSSI_DIFF_MIN,
2696 CFG_ROAM_RSSI_DIFF_MAX);
2697 ret = -EINVAL;
2698 goto exit;
2699 }
2700
2701 if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) ||
2702 (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX))
2703 {
2704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2705 "Roam rssi diff value %d is out of range"
2706 " (Min: %d Max: %d)", roamRssiDiff,
2707 CFG_ROAM_RSSI_DIFF_MIN,
2708 CFG_ROAM_RSSI_DIFF_MAX);
2709 ret = -EINVAL;
2710 goto exit;
2711 }
2712
2713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2714 "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff);
2715
2716 pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff;
2717 sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff);
2718 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05302719 else if (strncmp(command, "GETROAMDELTA", 12) == 0)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002720 {
2721 tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal));
2722 char extra[32];
2723 tANI_U8 len = 0;
2724
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302725 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2726 TRACE_CODE_HDD_GETROAMDELTA_IOCTL,
2727 pAdapter->sessionId, roamRssiDiff));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002728 len = scnprintf(extra, sizeof(extra), "%s %d",
2729 command, roamRssiDiff);
Ratnam Rachuri22a3b402015-07-17 13:21:49 +05302730 len = VOS_MIN(priv_data.total_len, len + 1);
2731 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2733 "%s: failed to copy data to user buffer", __func__);
2734 ret = -EFAULT;
2735 goto exit;
2736 }
2737 }
2738#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002739#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002740 else if (strncmp(command, "GETBAND", 7) == 0)
2741 {
2742 int band = -1;
2743 char extra[32];
2744 tANI_U8 len = 0;
2745 hdd_getBand_helper(pHddCtx, &band);
2746
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302747 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2748 TRACE_CODE_HDD_GETBAND_IOCTL,
2749 pAdapter->sessionId, band));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002750 len = scnprintf(extra, sizeof(extra), "%s %d", command, band);
Ratnam Rachuri52139592015-07-17 13:17:29 +05302751 len = VOS_MIN(priv_data.total_len, len + 1);
2752 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2754 "%s: failed to copy data to user buffer", __func__);
2755 ret = -EFAULT;
2756 goto exit;
2757 }
2758 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002759 else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0)
2760 {
2761 tANI_U8 *value = command;
2762 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2763 tANI_U8 numChannels = 0;
2764 eHalStatus status = eHAL_STATUS_SUCCESS;
2765
2766 status = hdd_parse_channellist(value, ChannelList, &numChannels);
2767 if (eHAL_STATUS_SUCCESS != status)
2768 {
2769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2770 "%s: Failed to parse channel list information", __func__);
2771 ret = -EINVAL;
2772 goto exit;
2773 }
2774
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302775 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2776 TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL,
2777 pAdapter->sessionId, numChannels));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002778 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2779 {
2780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2781 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
2782 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
2783 ret = -EINVAL;
2784 goto exit;
2785 }
2786 status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList,
2787 numChannels);
2788 if (eHAL_STATUS_SUCCESS != status)
2789 {
2790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2791 "%s: Failed to update channel list information", __func__);
2792 ret = -EINVAL;
2793 goto exit;
2794 }
2795 }
2796 else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0)
2797 {
2798 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2799 tANI_U8 numChannels = 0;
Jeff Johnson51b67782013-04-05 12:35:41 -07002800 tANI_U8 j = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002801 char extra[128] = {0};
Jeff Johnson51b67782013-04-05 12:35:41 -07002802 int len;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002803
2804 if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal),
2805 ChannelList, &numChannels ))
2806 {
2807 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2808 "%s: failed to get roam scan channel list", __func__);
2809 ret = -EFAULT;
2810 goto exit;
2811 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302812 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2813 TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL,
2814 pAdapter->sessionId, numChannels));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002815 /* output channel list is of the format
2816 [Number of roam scan channels][Channel1][Channel2]... */
2817 /* copy the number of channels in the 0th index */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002818 len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002819 for (j = 0; (j < numChannels); j++)
2820 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002821 len += scnprintf(extra + len, sizeof(extra) - len, " %d",
2822 ChannelList[j]);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002823 }
2824
Sushant Kaushikc9b8be52015-07-15 16:41:27 +05302825 len = VOS_MIN(priv_data.total_len, len + 1);
2826 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002827 {
2828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2829 "%s: failed to copy data to user buffer", __func__);
2830 ret = -EFAULT;
2831 goto exit;
2832 }
2833 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002834 else if (strncmp(command, "GETCCXMODE", 10) == 0)
2835 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002836 tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002837 char extra[32];
2838 tANI_U8 len = 0;
2839
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002840 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002841 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002842 if (eseMode &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002843 hdd_is_okc_mode_enabled(pHddCtx) &&
2844 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2845 {
2846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002847 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002848 " hence this operation is not permitted!", __func__);
2849 ret = -EPERM;
2850 goto exit;
2851 }
2852
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002853 len = scnprintf(extra, sizeof(extra), "%s %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002854 "GETCCXMODE", eseMode);
Sushant Kaushikf8abd352015-07-15 16:37:49 +05302855 len = VOS_MIN(priv_data.total_len, len + 1);
2856 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002857 {
2858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2859 "%s: failed to copy data to user buffer", __func__);
2860 ret = -EFAULT;
2861 goto exit;
2862 }
2863 }
2864 else if (strncmp(command, "GETOKCMODE", 10) == 0)
2865 {
2866 tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx);
2867 char extra[32];
2868 tANI_U8 len = 0;
2869
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002870 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002871 then this operation is not permitted (return FAILURE) */
2872 if (okcMode &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002873 sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002874 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2875 {
2876 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002877 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002878 " hence this operation is not permitted!", __func__);
2879 ret = -EPERM;
2880 goto exit;
2881 }
2882
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002883 len = scnprintf(extra, sizeof(extra), "%s %d",
2884 "GETOKCMODE", okcMode);
Sushant Kaushikbc2fb5c2015-07-15 16:43:16 +05302885 len = VOS_MIN(priv_data.total_len, len + 1);
2886 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002887 {
2888 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2889 "%s: failed to copy data to user buffer", __func__);
2890 ret = -EFAULT;
2891 goto exit;
2892 }
2893 }
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002894 else if (strncmp(command, "GETFASTROAM", 11) == 0)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002895 {
2896 tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2897 char extra[32];
2898 tANI_U8 len = 0;
2899
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002900 len = scnprintf(extra, sizeof(extra), "%s %d",
2901 "GETFASTROAM", lfrMode);
Sushant Kaushik4da7ec92015-07-15 16:39:32 +05302902 len = VOS_MIN(priv_data.total_len, len + 1);
2903 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002904 {
2905 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2906 "%s: failed to copy data to user buffer", __func__);
2907 ret = -EFAULT;
2908 goto exit;
2909 }
2910 }
2911 else if (strncmp(command, "GETFASTTRANSITION", 17) == 0)
2912 {
2913 tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2914 char extra[32];
2915 tANI_U8 len = 0;
2916
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002917 len = scnprintf(extra, sizeof(extra), "%s %d",
2918 "GETFASTTRANSITION", ft);
Sushant Kaushik231a4452015-07-15 16:23:56 +05302919 len = VOS_MIN(priv_data.total_len, len + 1);
2920 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002921 {
2922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2923 "%s: failed to copy data to user buffer", __func__);
2924 ret = -EFAULT;
2925 goto exit;
2926 }
2927 }
2928 else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0)
2929 {
2930 tANI_U8 *value = command;
2931 tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT;
2932
2933 /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */
2934 value = value + 26;
2935 /* Convert the value from ascii to integer */
2936 ret = kstrtou8(value, 10, &minTime);
2937 if (ret < 0)
2938 {
2939 /* If the input value is greater than max value of datatype, then also
2940 kstrtou8 fails */
2941 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2942 "%s: kstrtou8 failed range [%d - %d]", __func__,
2943 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2944 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2945 ret = -EINVAL;
2946 goto exit;
2947 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002948 if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) ||
2949 (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX))
2950 {
2951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2952 "scan min channel time value %d is out of range"
2953 " (Min: %d Max: %d)", minTime,
2954 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2955 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2956 ret = -EINVAL;
2957 goto exit;
2958 }
2959
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302960 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2961 TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL,
2962 pAdapter->sessionId, minTime));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2964 "%s: Received Command to change channel min time = %d", __func__, minTime);
2965
2966 pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime;
2967 sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime);
2968 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002969 else if (strncmp(command, "SENDACTIONFRAME", 15) == 0)
2970 {
2971 tANI_U8 *value = command;
2972 tANI_U8 channel = 0;
2973 tANI_U8 dwellTime = 0;
2974 tANI_U8 bufLen = 0;
2975 tANI_U8 *buf = NULL;
2976 tSirMacAddr targetApBssid;
2977 eHalStatus status = eHAL_STATUS_SUCCESS;
2978 struct ieee80211_channel chan;
2979 tANI_U8 finalLen = 0;
2980 tANI_U8 *finalBuf = NULL;
2981 tANI_U8 temp = 0;
2982 u64 cookie;
2983 hdd_station_ctx_t *pHddStaCtx = NULL;
2984 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2985
2986 /* if not associated, no need to send action frame */
2987 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2988 {
2989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
2990 ret = -EINVAL;
2991 goto exit;
2992 }
2993
2994 status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel,
2995 &dwellTime, &buf, &bufLen);
2996 if (eHAL_STATUS_SUCCESS != status)
2997 {
2998 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2999 "%s: Failed to parse send action frame data", __func__);
3000 ret = -EINVAL;
3001 goto exit;
3002 }
3003
3004 /* if the target bssid is different from currently associated AP,
3005 then no need to send action frame */
3006 if (VOS_TRUE != vos_mem_compare(targetApBssid,
3007 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3008 {
3009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__);
3010 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07003011 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003012 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003013 goto exit;
3014 }
3015
3016 /* if the channel number is different from operating channel then
3017 no need to send action frame */
3018 if (channel != pHddStaCtx->conn_info.operationChannel)
3019 {
3020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3021 "%s: channel(%d) is different from operating channel(%d)",
3022 __func__, channel, pHddStaCtx->conn_info.operationChannel);
3023 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07003024 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003025 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003026 goto exit;
3027 }
3028 chan.center_freq = sme_ChnToFreq(channel);
3029
3030 finalLen = bufLen + 24;
3031 finalBuf = vos_mem_malloc(finalLen);
3032 if (NULL == finalBuf)
3033 {
3034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__);
3035 ret = -ENOMEM;
Jeff Johnson11c33152013-04-16 17:52:40 -07003036 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003037 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003038 goto exit;
3039 }
3040 vos_mem_zero(finalBuf, finalLen);
3041
3042 /* Fill subtype */
3043 temp = SIR_MAC_MGMT_ACTION << 4;
3044 vos_mem_copy(finalBuf + 0, &temp, sizeof(temp));
3045
3046 /* Fill type */
3047 temp = SIR_MAC_MGMT_FRAME;
3048 vos_mem_copy(finalBuf + 2, &temp, sizeof(temp));
3049
3050 /* Fill destination address (bssid of the AP) */
3051 vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid));
3052
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07003053 /* Fill source address (STA mac address) */
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003054 vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes));
3055
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07003056 /* Fill BSSID (AP mac address) */
3057 vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid));
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003058
3059 /* Fill received buffer from 24th address */
3060 vos_mem_copy(finalBuf + 24, buf, bufLen);
3061
Jeff Johnson11c33152013-04-16 17:52:40 -07003062 /* done with the parsed buffer */
3063 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003064 buf = NULL;
Jeff Johnson11c33152013-04-16 17:52:40 -07003065
DARAM SUDHA39eede62014-02-12 11:16:40 +05303066 wlan_hdd_mgmt_tx( NULL,
Yue Maf49ba872013-08-19 12:04:25 -07003067#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
3068 &(pAdapter->wdev),
3069#else
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07003070 pAdapter->dev,
Yue Maf49ba872013-08-19 12:04:25 -07003071#endif
3072 &chan, 0,
3073#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
3074 NL80211_CHAN_HT20, 1,
3075#endif
3076 dwellTime, finalBuf, finalLen, 1,
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003077 1, &cookie );
3078 vos_mem_free(finalBuf);
3079 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003080 else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0)
3081 {
3082 tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal));
3083 char extra[32];
3084 tANI_U8 len = 0;
3085
3086 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003087 len = scnprintf(extra, sizeof(extra), "%s %d",
3088 "GETROAMSCANCHANNELMINTIME", val);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303089 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3090 TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL,
3091 pAdapter->sessionId, val));
Sushant Kaushikbb8c52c2015-07-15 16:36:23 +05303092 len = VOS_MIN(priv_data.total_len, len + 1);
3093 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003094 {
3095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3096 "%s: failed to copy data to user buffer", __func__);
3097 ret = -EFAULT;
3098 goto exit;
3099 }
3100 }
3101 else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0)
3102 {
3103 tANI_U8 *value = command;
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003104 tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003105
3106 /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */
3107 value = value + 19;
3108 /* Convert the value from ascii to integer */
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003109 ret = kstrtou16(value, 10, &maxTime);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003110 if (ret < 0)
3111 {
3112 /* If the input value is greater than max value of datatype, then also
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003113 kstrtou16 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003114 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003115 "%s: kstrtou16 failed range [%d - %d]", __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003116 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
3117 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
3118 ret = -EINVAL;
3119 goto exit;
3120 }
3121
3122 if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) ||
3123 (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX))
3124 {
3125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3126 "lfr mode value %d is out of range"
3127 " (Min: %d Max: %d)", maxTime,
3128 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
3129 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
3130 ret = -EINVAL;
3131 goto exit;
3132 }
3133
3134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3135 "%s: Received Command to change channel max time = %d", __func__, maxTime);
3136
3137 pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime;
3138 sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime);
3139 }
3140 else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0)
3141 {
3142 tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal));
3143 char extra[32];
3144 tANI_U8 len = 0;
3145
3146 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003147 len = scnprintf(extra, sizeof(extra), "%s %d",
3148 "GETSCANCHANNELTIME", val);
Ratheesh S Pacbfa932015-07-16 15:27:18 +05303149 len = VOS_MIN(priv_data.total_len, len + 1);
3150 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003151 {
3152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3153 "%s: failed to copy data to user buffer", __func__);
3154 ret = -EFAULT;
3155 goto exit;
3156 }
3157 }
3158 else if (strncmp(command, "SETSCANHOMETIME", 15) == 0)
3159 {
3160 tANI_U8 *value = command;
3161 tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT;
3162
3163 /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */
3164 value = value + 16;
3165 /* Convert the value from ascii to integer */
3166 ret = kstrtou16(value, 10, &val);
3167 if (ret < 0)
3168 {
3169 /* If the input value is greater than max value of datatype, then also
3170 kstrtou16 fails */
3171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3172 "%s: kstrtou16 failed range [%d - %d]", __func__,
3173 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
3174 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
3175 ret = -EINVAL;
3176 goto exit;
3177 }
3178
3179 if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) ||
3180 (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX))
3181 {
3182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3183 "scan home time value %d is out of range"
3184 " (Min: %d Max: %d)", val,
3185 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
3186 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
3187 ret = -EINVAL;
3188 goto exit;
3189 }
3190
3191 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3192 "%s: Received Command to change scan home time = %d", __func__, val);
3193
3194 pHddCtx->cfg_ini->nNeighborScanPeriod = val;
3195 sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val);
3196 }
3197 else if (strncmp(command, "GETSCANHOMETIME", 15) == 0)
3198 {
3199 tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal));
3200 char extra[32];
3201 tANI_U8 len = 0;
3202
3203 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003204 len = scnprintf(extra, sizeof(extra), "%s %d",
3205 "GETSCANHOMETIME", val);
Ratheesh S P728d7c62015-07-16 15:38:58 +05303206 len = VOS_MIN(priv_data.total_len, len + 1);
3207 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003208 {
3209 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3210 "%s: failed to copy data to user buffer", __func__);
3211 ret = -EFAULT;
3212 goto exit;
3213 }
3214 }
3215 else if (strncmp(command, "SETROAMINTRABAND", 16) == 0)
3216 {
3217 tANI_U8 *value = command;
3218 tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT;
3219
3220 /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */
3221 value = value + 17;
3222 /* Convert the value from ascii to integer */
3223 ret = kstrtou8(value, 10, &val);
3224 if (ret < 0)
3225 {
3226 /* If the input value is greater than max value of datatype, then also
3227 kstrtou8 fails */
3228 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3229 "%s: kstrtou8 failed range [%d - %d]", __func__,
3230 CFG_ROAM_INTRA_BAND_MIN,
3231 CFG_ROAM_INTRA_BAND_MAX);
3232 ret = -EINVAL;
3233 goto exit;
3234 }
3235
3236 if ((val < CFG_ROAM_INTRA_BAND_MIN) ||
3237 (val > CFG_ROAM_INTRA_BAND_MAX))
3238 {
3239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3240 "intra band mode value %d is out of range"
3241 " (Min: %d Max: %d)", val,
3242 CFG_ROAM_INTRA_BAND_MIN,
3243 CFG_ROAM_INTRA_BAND_MAX);
3244 ret = -EINVAL;
3245 goto exit;
3246 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003247 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3248 "%s: Received Command to change intra band = %d", __func__, val);
3249
3250 pHddCtx->cfg_ini->nRoamIntraBand = val;
3251 sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val);
3252 }
3253 else if (strncmp(command, "GETROAMINTRABAND", 16) == 0)
3254 {
3255 tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal));
3256 char extra[32];
3257 tANI_U8 len = 0;
3258
3259 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003260 len = scnprintf(extra, sizeof(extra), "%s %d",
3261 "GETROAMINTRABAND", val);
Ratheesh S P2dd2a3e2015-07-16 15:34:23 +05303262 len = VOS_MIN(priv_data.total_len, len + 1);
3263 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003264 {
3265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3266 "%s: failed to copy data to user buffer", __func__);
3267 ret = -EFAULT;
3268 goto exit;
3269 }
3270 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003271 else if (strncmp(command, "SETSCANNPROBES", 14) == 0)
3272 {
3273 tANI_U8 *value = command;
3274 tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT;
3275
3276 /* Move pointer to ahead of SETSCANNPROBES<delimiter> */
3277 value = value + 15;
3278 /* Convert the value from ascii to integer */
3279 ret = kstrtou8(value, 10, &nProbes);
3280 if (ret < 0)
3281 {
3282 /* If the input value is greater than max value of datatype, then also
3283 kstrtou8 fails */
3284 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3285 "%s: kstrtou8 failed range [%d - %d]", __func__,
3286 CFG_ROAM_SCAN_N_PROBES_MIN,
3287 CFG_ROAM_SCAN_N_PROBES_MAX);
3288 ret = -EINVAL;
3289 goto exit;
3290 }
3291
3292 if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) ||
3293 (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX))
3294 {
3295 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3296 "NProbes value %d is out of range"
3297 " (Min: %d Max: %d)", nProbes,
3298 CFG_ROAM_SCAN_N_PROBES_MIN,
3299 CFG_ROAM_SCAN_N_PROBES_MAX);
3300 ret = -EINVAL;
3301 goto exit;
3302 }
3303
3304 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3305 "%s: Received Command to Set nProbes = %d", __func__, nProbes);
3306
3307 pHddCtx->cfg_ini->nProbes = nProbes;
3308 sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes);
3309 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303310 else if (strncmp(command, "GETSCANNPROBES", 14) == 0)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003311 {
3312 tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal));
3313 char extra[32];
3314 tANI_U8 len = 0;
3315
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003316 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Ratnam Rachuri6da525d2015-08-07 13:55:54 +05303317 len = VOS_MIN(priv_data.total_len, len + 1);
3318 if (copy_to_user(priv_data.buf, &extra, len)) {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3320 "%s: failed to copy data to user buffer", __func__);
3321 ret = -EFAULT;
3322 goto exit;
3323 }
3324 }
3325 else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0)
3326 {
3327 tANI_U8 *value = command;
3328 tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT;
3329
3330 /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */
3331 /* input value is in units of msec */
3332 value = value + 20;
3333 /* Convert the value from ascii to integer */
3334 ret = kstrtou16(value, 10, &homeAwayTime);
3335 if (ret < 0)
3336 {
3337 /* If the input value is greater than max value of datatype, then also
3338 kstrtou8 fails */
3339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3340 "%s: kstrtou8 failed range [%d - %d]", __func__,
3341 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
3342 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
3343 ret = -EINVAL;
3344 goto exit;
3345 }
3346
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003347 if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) ||
3348 (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX))
3349 {
3350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3351 "homeAwayTime value %d is out of range"
3352 " (Min: %d Max: %d)", homeAwayTime,
3353 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
3354 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
3355 ret = -EINVAL;
3356 goto exit;
3357 }
3358
3359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3360 "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07003361 if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime)
3362 {
3363 pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime;
3364 sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE);
3365 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003366 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303367 else if (strncmp(command, "GETSCANHOMEAWAYTIME", 19) == 0)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003368 {
3369 tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal));
3370 char extra[32];
3371 tANI_U8 len = 0;
3372
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003373 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003374 if (copy_to_user(priv_data.buf, &extra, len + 1))
3375 {
3376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3377 "%s: failed to copy data to user buffer", __func__);
3378 ret = -EFAULT;
3379 goto exit;
3380 }
3381 }
3382 else if (strncmp(command, "REASSOC", 7) == 0)
3383 {
3384 tANI_U8 *value = command;
3385 tANI_U8 channel = 0;
3386 tSirMacAddr targetApBssid;
3387 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003388#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3389 tCsrHandoffRequest handoffInfo;
3390#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003391 hdd_station_ctx_t *pHddStaCtx = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003392 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3393
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003394 /* if not associated, no need to proceed with reassoc */
3395 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3396 {
3397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3398 ret = -EINVAL;
3399 goto exit;
3400 }
3401
3402 status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel);
3403 if (eHAL_STATUS_SUCCESS != status)
3404 {
3405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3406 "%s: Failed to parse reassoc command data", __func__);
3407 ret = -EINVAL;
3408 goto exit;
3409 }
3410
3411 /* if the target bssid is same as currently associated AP,
3412 then no need to proceed with reassoc */
3413 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3414 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3415 {
3416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__);
3417 ret = -EINVAL;
3418 goto exit;
3419 }
3420
3421 /* Check channel number is a valid channel number */
3422 if(VOS_STATUS_SUCCESS !=
3423 wlan_hdd_validate_operation_channel(pAdapter, channel))
3424 {
3425 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003426 "%s: Invalid Channel [%d]", __func__, channel);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003427 return -EINVAL;
3428 }
3429
3430 /* Proceed with reassoc */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003431#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3432 handoffInfo.channel = channel;
3433 vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr));
3434 sme_HandoffRequest(pHddCtx->hHal, &handoffInfo);
3435#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003436 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003437 else if (strncmp(command, "SETWESMODE", 10) == 0)
3438 {
3439 tANI_U8 *value = command;
3440 tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT;
3441
3442 /* Move pointer to ahead of SETWESMODE<delimiter> */
3443 value = value + 11;
3444 /* Convert the value from ascii to integer */
3445 ret = kstrtou8(value, 10, &wesMode);
3446 if (ret < 0)
3447 {
3448 /* If the input value is greater than max value of datatype, then also
3449 kstrtou8 fails */
3450 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3451 "%s: kstrtou8 failed range [%d - %d]", __func__,
3452 CFG_ENABLE_WES_MODE_NAME_MIN,
3453 CFG_ENABLE_WES_MODE_NAME_MAX);
3454 ret = -EINVAL;
3455 goto exit;
3456 }
3457
3458 if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) ||
3459 (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX))
3460 {
3461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3462 "WES Mode value %d is out of range"
3463 " (Min: %d Max: %d)", wesMode,
3464 CFG_ENABLE_WES_MODE_NAME_MIN,
3465 CFG_ENABLE_WES_MODE_NAME_MAX);
3466 ret = -EINVAL;
3467 goto exit;
3468 }
3469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3470 "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode);
3471
3472 pHddCtx->cfg_ini->isWESModeEnabled = wesMode;
3473 sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode);
3474 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303475 else if (strncmp(command, "GETWESMODE", 10) == 0)
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003476 {
3477 tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal));
3478 char extra[32];
3479 tANI_U8 len = 0;
3480
Arif Hussain826d9412013-11-12 16:44:54 -08003481 len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode);
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003482 if (copy_to_user(priv_data.buf, &extra, len + 1))
3483 {
3484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3485 "%s: failed to copy data to user buffer", __func__);
3486 ret = -EFAULT;
3487 goto exit;
3488 }
3489 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003490#endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003491#ifdef FEATURE_WLAN_LFR
3492 else if (strncmp(command, "SETFASTROAM", 11) == 0)
3493 {
3494 tANI_U8 *value = command;
3495 tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
3496
3497 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3498 value = value + 12;
3499 /* Convert the value from ascii to integer */
3500 ret = kstrtou8(value, 10, &lfrMode);
3501 if (ret < 0)
3502 {
3503 /* If the input value is greater than max value of datatype, then also
3504 kstrtou8 fails */
3505 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3506 "%s: kstrtou8 failed range [%d - %d]", __func__,
3507 CFG_LFR_FEATURE_ENABLED_MIN,
3508 CFG_LFR_FEATURE_ENABLED_MAX);
3509 ret = -EINVAL;
3510 goto exit;
3511 }
3512
3513 if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
3514 (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX))
3515 {
3516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3517 "lfr mode value %d is out of range"
3518 " (Min: %d Max: %d)", lfrMode,
3519 CFG_LFR_FEATURE_ENABLED_MIN,
3520 CFG_LFR_FEATURE_ENABLED_MAX);
3521 ret = -EINVAL;
3522 goto exit;
3523 }
3524
3525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3526 "%s: Received Command to change lfr mode = %d", __func__, lfrMode);
3527
3528 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode;
3529 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode);
3530 }
3531#endif
3532#ifdef WLAN_FEATURE_VOWIFI_11R
3533 else if (strncmp(command, "SETFASTTRANSITION", 17) == 0)
3534 {
3535 tANI_U8 *value = command;
3536 tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT;
3537
3538 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3539 value = value + 18;
3540 /* Convert the value from ascii to integer */
3541 ret = kstrtou8(value, 10, &ft);
3542 if (ret < 0)
3543 {
3544 /* If the input value is greater than max value of datatype, then also
3545 kstrtou8 fails */
3546 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3547 "%s: kstrtou8 failed range [%d - %d]", __func__,
3548 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3549 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3550 ret = -EINVAL;
3551 goto exit;
3552 }
3553
3554 if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) ||
3555 (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX))
3556 {
3557 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3558 "ft mode value %d is out of range"
3559 " (Min: %d Max: %d)", ft,
3560 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3561 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3562 ret = -EINVAL;
3563 goto exit;
3564 }
3565
3566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3567 "%s: Received Command to change ft mode = %d", __func__, ft);
3568
3569 pHddCtx->cfg_ini->isFastTransitionEnabled = ft;
3570 sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft);
3571 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303572 else if (strncmp(command, "SETDFSSCANMODE", 14) == 0)
3573 {
3574 tANI_U8 *value = command;
3575 tANI_U8 dfsScanMode = DFS_CHNL_SCAN_ENABLED_NORMAL;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303576
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303577 /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */
3578 value = value + 15;
3579 /* Convert the value from ascii to integer */
3580 ret = kstrtou8(value, 10, &dfsScanMode);
3581 if (ret < 0)
3582 {
3583 /* If the input value is greater than max value of
3584 datatype, then also kstrtou8 fails
3585 */
3586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3587 "%s: kstrtou8 failed range [%d - %d]", __func__,
3588 CFG_ENABLE_DFS_CHNL_SCAN_MIN,
3589 CFG_ENABLE_DFS_CHNL_SCAN_MAX);
3590 ret = -EINVAL;
3591 goto exit;
3592 }
3593
3594 if ((dfsScanMode < CFG_ENABLE_DFS_CHNL_SCAN_MIN) ||
3595 (dfsScanMode > CFG_ENABLE_DFS_CHNL_SCAN_MAX))
3596 {
3597 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3598 "dfsScanMode value %d is out of range"
3599 " (Min: %d Max: %d)", dfsScanMode,
3600 CFG_ENABLE_DFS_CHNL_SCAN_MIN,
3601 CFG_ENABLE_DFS_CHNL_SCAN_MAX);
3602 ret = -EINVAL;
3603 goto exit;
3604 }
3605 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3606 "%s: Received Command to Set DFS Scan Mode = %d",
3607 __func__, dfsScanMode);
3608
3609 ret = wlan_hdd_handle_dfs_chan_scan(pHddCtx, dfsScanMode);
3610 }
3611 else if (strncmp(command, "GETDFSSCANMODE", 14) == 0)
3612 {
3613 tANI_U8 dfsScanMode = sme_GetDFSScanMode(pHddCtx->hHal);
3614 char extra[32];
3615 tANI_U8 len = 0;
3616
3617 len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode);
Ratheesh S P767224e2015-07-16 15:35:51 +05303618 len = VOS_MIN(priv_data.total_len, len + 1);
3619 if (copy_to_user(priv_data.buf, &extra, len))
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303620 {
3621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3622 "%s: failed to copy data to user buffer", __func__);
3623 ret = -EFAULT;
3624 goto exit;
3625 }
3626 }
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303627 else if (strncmp(command, "FASTREASSOC", 11) == 0)
3628 {
3629 tANI_U8 *value = command;
Padma, Santhosh Kumarf4582d32014-11-06 19:24:51 +05303630 tANI_U8 channel = 0;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303631 tSirMacAddr targetApBssid;
3632 tANI_U8 trigger = 0;
3633 eHalStatus status = eHAL_STATUS_SUCCESS;
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303634 tHalHandle hHal;
3635 v_U32_t roamId = 0;
3636 tCsrRoamModifyProfileFields modProfileFields;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303637 hdd_station_ctx_t *pHddStaCtx = NULL;
3638 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303639 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303640
3641 /* if not associated, no need to proceed with reassoc */
3642 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3643 {
3644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3645 ret = -EINVAL;
3646 goto exit;
3647 }
3648
Padma, Santhosh Kumarf4582d32014-11-06 19:24:51 +05303649 status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303650 if (eHAL_STATUS_SUCCESS != status)
3651 {
3652 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3653 "%s: Failed to parse reassoc command data", __func__);
3654 ret = -EINVAL;
3655 goto exit;
3656 }
3657
3658 /* if the target bssid is same as currently associated AP,
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303659 issue reassoc to same AP */
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303660 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3661 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3662 {
3663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3664 "%s:11r Reassoc BSSID is same as currently associated AP bssid",
3665 __func__);
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303666 sme_GetModifyProfileFields(hHal, pAdapter->sessionId,
3667 &modProfileFields);
3668 sme_RoamReassoc(hHal, pAdapter->sessionId,
3669 NULL, modProfileFields, &roamId, 1);
3670 return 0;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303671 }
Padma, Santhosh Kumar0fa809b2014-11-13 14:56:56 +05303672
3673 /* Check channel number is a valid channel number */
3674 if(VOS_STATUS_SUCCESS !=
3675 wlan_hdd_validate_operation_channel(pAdapter, channel))
3676 {
3677 hddLog(VOS_TRACE_LEVEL_ERROR,
3678 "%s: Invalid Channel [%d]", __func__, channel);
3679 return -EINVAL;
3680 }
3681
Padma, Santhosh Kumarf4582d32014-11-06 19:24:51 +05303682 trigger = eSME_ROAM_TRIGGER_SCAN;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303683
3684 /* Proceed with scan/roam */
3685 smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter),
3686 &targetApBssid[0],
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05303687 (tSmeFastRoamTrigger)(trigger),
3688 channel);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303689 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003690#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003691#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003692 else if (strncmp(command, "SETCCXMODE", 10) == 0)
3693 {
3694 tANI_U8 *value = command;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003695 tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003696
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003697 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003698 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003699 if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003700 hdd_is_okc_mode_enabled(pHddCtx) &&
3701 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3702 {
3703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003704 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003705 " hence this operation is not permitted!", __func__);
3706 ret = -EPERM;
3707 goto exit;
3708 }
3709
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003710 /* Move pointer to ahead of SETCCXMODE<delimiter> */
3711 value = value + 11;
3712 /* Convert the value from ascii to integer */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003713 ret = kstrtou8(value, 10, &eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003714 if (ret < 0)
3715 {
3716 /* If the input value is greater than max value of datatype, then also
3717 kstrtou8 fails */
3718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3719 "%s: kstrtou8 failed range [%d - %d]", __func__,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003720 CFG_ESE_FEATURE_ENABLED_MIN,
3721 CFG_ESE_FEATURE_ENABLED_MAX);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003722 ret = -EINVAL;
3723 goto exit;
3724 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003725 if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) ||
3726 (eseMode > CFG_ESE_FEATURE_ENABLED_MAX))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003727 {
3728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003729 "Ese mode value %d is out of range"
3730 " (Min: %d Max: %d)", eseMode,
3731 CFG_ESE_FEATURE_ENABLED_MIN,
3732 CFG_ESE_FEATURE_ENABLED_MAX);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003733 ret = -EINVAL;
3734 goto exit;
3735 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003737 "%s: Received Command to change ese mode = %d", __func__, eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003738
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003739 pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode;
3740 sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003741 }
3742#endif
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003743 else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0)
3744 {
3745 tANI_U8 *value = command;
3746 tANI_BOOLEAN roamScanControl = 0;
3747
3748 /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */
3749 value = value + 19;
3750 /* Convert the value from ascii to integer */
3751 ret = kstrtou8(value, 10, &roamScanControl);
3752 if (ret < 0)
3753 {
3754 /* If the input value is greater than max value of datatype, then also
3755 kstrtou8 fails */
3756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3757 "%s: kstrtou8 failed ", __func__);
3758 ret = -EINVAL;
3759 goto exit;
3760 }
3761
3762 if (0 != roamScanControl)
3763 {
3764 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3765 "roam scan control invalid value = %d",
3766 roamScanControl);
3767 ret = -EINVAL;
3768 goto exit;
3769 }
3770 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3771 "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl);
3772
3773 sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl);
3774 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003775#ifdef FEATURE_WLAN_OKC
3776 else if (strncmp(command, "SETOKCMODE", 10) == 0)
3777 {
3778 tANI_U8 *value = command;
3779 tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT;
3780
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003781 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003782 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003783 if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003784 hdd_is_okc_mode_enabled(pHddCtx) &&
3785 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3786 {
3787 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003788 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003789 " hence this operation is not permitted!", __func__);
3790 ret = -EPERM;
3791 goto exit;
3792 }
3793
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003794 /* Move pointer to ahead of SETOKCMODE<delimiter> */
3795 value = value + 11;
3796 /* Convert the value from ascii to integer */
3797 ret = kstrtou8(value, 10, &okcMode);
3798 if (ret < 0)
3799 {
3800 /* If the input value is greater than max value of datatype, then also
3801 kstrtou8 fails */
3802 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3803 "%s: kstrtou8 failed range [%d - %d]", __func__,
3804 CFG_OKC_FEATURE_ENABLED_MIN,
3805 CFG_OKC_FEATURE_ENABLED_MAX);
3806 ret = -EINVAL;
3807 goto exit;
3808 }
3809
3810 if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) ||
3811 (okcMode > CFG_OKC_FEATURE_ENABLED_MAX))
3812 {
3813 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3814 "Okc mode value %d is out of range"
3815 " (Min: %d Max: %d)", okcMode,
3816 CFG_OKC_FEATURE_ENABLED_MIN,
3817 CFG_OKC_FEATURE_ENABLED_MAX);
3818 ret = -EINVAL;
3819 goto exit;
3820 }
3821
3822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3823 "%s: Received Command to change okc mode = %d", __func__, okcMode);
3824
3825 pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode;
3826 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003827#endif /* FEATURE_WLAN_OKC */
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303828 else if (strncmp(command, "GETROAMSCANCONTROL", 18) == 0)
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003829 {
3830 tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal));
3831 char extra[32];
3832 tANI_U8 len = 0;
3833
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003834 len = scnprintf(extra, sizeof(extra), "%s %d",
3835 command, roamScanControl);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003836 if (copy_to_user(priv_data.buf, &extra, len + 1))
3837 {
3838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3839 "%s: failed to copy data to user buffer", __func__);
3840 ret = -EFAULT;
3841 goto exit;
3842 }
3843 }
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05303844#ifdef WLAN_FEATURE_PACKET_FILTERING
3845 else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0)
3846 {
3847 tANI_U8 filterType = 0;
3848 tANI_U8 *value = command;
3849
3850 /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */
3851 value = value + 22;
3852
3853 /* Convert the value from ascii to integer */
3854 ret = kstrtou8(value, 10, &filterType);
3855 if (ret < 0)
3856 {
3857 /* If the input value is greater than max value of datatype,
3858 * then also kstrtou8 fails
3859 */
3860 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3861 "%s: kstrtou8 failed range ", __func__);
3862 ret = -EINVAL;
3863 goto exit;
3864 }
3865
3866 if (filterType != 0 && filterType != 1)
3867 {
3868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3869 "%s: Accepted Values are 0 and 1 ", __func__);
3870 ret = -EINVAL;
3871 goto exit;
3872 }
3873 wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType,
3874 pAdapter->sessionId);
3875 }
3876#endif
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303877 else if (strncmp(command, "BTCOEXMODE", 10) == 0 )
3878 {
Kiet Lamad161252014-07-22 11:23:32 -07003879 char *dhcpPhase;
Satyanarayana Dash1faea4f2014-09-22 16:21:04 +05303880 int ret;
3881
Kiet Lamad161252014-07-22 11:23:32 -07003882 dhcpPhase = command + 11;
3883 if ('1' == *dhcpPhase)
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303884 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05303885 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Kiet Lamad161252014-07-22 11:23:32 -07003886 FL("send DHCP START indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303887
3888 pHddCtx->btCoexModeSet = TRUE;
Kiet Lamad161252014-07-22 11:23:32 -07003889
Satyanarayana Dash1faea4f2014-09-22 16:21:04 +05303890 ret = wlan_hdd_scan_abort(pAdapter);
3891 if (ret < 0)
3892 {
3893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3894 FL("failed to abort existing scan %d"), ret);
3895 }
3896
Kiet Lamad161252014-07-22 11:23:32 -07003897 sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode,
3898 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303899 }
Kiet Lamad161252014-07-22 11:23:32 -07003900 else if ('2' == *dhcpPhase)
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303901 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05303902 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Kiet Lamad161252014-07-22 11:23:32 -07003903 FL("send DHCP STOP indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303904
3905 pHddCtx->btCoexModeSet = FALSE;
Kiet Lamad161252014-07-22 11:23:32 -07003906
3907 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
3908 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303909 }
3910 }
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003911 else if (strncmp(command, "SCAN-ACTIVE", 11) == 0)
3912 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303913 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3914 FL("making default scan to ACTIVE"));
3915 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003916 }
3917 else if (strncmp(command, "SCAN-PASSIVE", 12) == 0)
3918 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3920 FL("making default scan to PASSIVE"));
3921 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003922 }
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303923 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
3924 {
3925 hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3926 char extra[32];
3927 tANI_U8 len = 0;
3928
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05303929 memset(extra, 0, sizeof(extra));
3930 ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len);
3931 if (ret != 0 || copy_to_user(priv_data.buf, &extra, len + 1))
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303932 {
3933 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3934 "%s: failed to copy data to user buffer", __func__);
3935 ret = -EFAULT;
3936 goto exit;
3937 }
3938 ret = len;
3939 }
3940 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
3941 {
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05303942 ret = hdd_set_dwell_time(pAdapter, command);
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303943 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003944 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
3945 {
3946 tANI_U8 filterType = 0;
3947 tANI_U8 *value;
3948 value = command + 9;
3949
3950 /* Convert the value from ascii to integer */
3951 ret = kstrtou8(value, 10, &filterType);
3952 if (ret < 0)
3953 {
3954 /* If the input value is greater than max value of datatype,
3955 * then also kstrtou8 fails
3956 */
3957 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3958 "%s: kstrtou8 failed range ", __func__);
3959 ret = -EINVAL;
3960 goto exit;
3961 }
3962 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
3963 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
3964 {
3965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3966 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
3967 " 2-Sink ", __func__);
3968 ret = -EINVAL;
3969 goto exit;
3970 }
3971 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
3972 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +05303973 pScanInfo = &pHddCtx->scan_info;
3974 if (filterType && pScanInfo != NULL &&
3975 pHddCtx->scan_info.mScanPending)
3976 {
3977 /*Miracast Session started. Abort Scan */
3978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3979 "%s, Aborting Scan For Miracast",__func__);
3980 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
3981 eCSR_SCAN_ABORT_DEFAULT);
3982 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003983 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05303984 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003985 }
Leo Chang614d2072013-08-22 14:59:44 -07003986 else if (strncmp(command, "SETMCRATE", 9) == 0)
3987 {
Leo Chang614d2072013-08-22 14:59:44 -07003988 tANI_U8 *value = command;
3989 int targetRate;
Leo Chang1f98cbd2013-10-17 15:03:52 -07003990 tSirRateUpdateInd *rateUpdate;
3991 eHalStatus status;
Leo Chang614d2072013-08-22 14:59:44 -07003992
3993 /* Only valid for SAP mode */
3994 if (WLAN_HDD_SOFTAP != pAdapter->device_mode)
3995 {
3996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3997 "%s: SAP mode is not running", __func__);
3998 ret = -EFAULT;
3999 goto exit;
4000 }
4001
4002 /* Move pointer to ahead of SETMCRATE<delimiter> */
4003 /* input value is in units of hundred kbps */
4004 value = value + 10;
4005 /* Convert the value from ascii to integer, decimal base */
4006 ret = kstrtouint(value, 10, &targetRate);
4007
Leo Chang1f98cbd2013-10-17 15:03:52 -07004008 rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd));
4009 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07004010 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07004011 hddLog(VOS_TRACE_LEVEL_ERROR,
4012 "%s: SETMCRATE indication alloc fail", __func__);
4013 ret = -EFAULT;
4014 goto exit;
4015 }
4016 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
4017
4018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4019 "MC Target rate %d", targetRate);
4020 /* Ignore unicast */
4021 rateUpdate->ucastDataRate = -1;
4022 rateUpdate->mcastDataRate24GHz = targetRate;
4023 rateUpdate->mcastDataRate5GHz = targetRate;
4024 rateUpdate->mcastDataRate24GHzTxFlag = 0;
4025 rateUpdate->mcastDataRate5GHzTxFlag = 0;
4026 status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate);
4027 if (eHAL_STATUS_SUCCESS != status)
4028 {
4029 hddLog(VOS_TRACE_LEVEL_ERROR,
4030 "%s: SET_MC_RATE failed", __func__);
4031 vos_mem_free(rateUpdate);
4032 ret = -EFAULT;
4033 goto exit;
Leo Chang614d2072013-08-22 14:59:44 -07004034 }
4035 }
Rajeev79dbe4c2013-10-05 11:03:42 +05304036#ifdef FEATURE_WLAN_BATCH_SCAN
Rajeev Kumar8b373292014-01-08 20:36:55 -08004037 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
Rajeev79dbe4c2013-10-05 11:03:42 +05304038 {
Rajeev Kumar8b373292014-01-08 20:36:55 -08004039 ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command);
Rajeev79dbe4c2013-10-05 11:03:42 +05304040 }
4041#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004042#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004043 else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0)
4044 {
4045 tANI_U8 *value = command;
4046 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4047 tANI_U8 numChannels = 0;
4048 eHalStatus status = eHAL_STATUS_SUCCESS;
4049
4050 status = hdd_parse_channellist(value, ChannelList, &numChannels);
4051 if (eHAL_STATUS_SUCCESS != status)
4052 {
4053 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4054 "%s: Failed to parse channel list information", __func__);
4055 ret = -EINVAL;
4056 goto exit;
4057 }
4058
4059 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
4060 {
4061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4062 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
4063 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
4064 ret = -EINVAL;
4065 goto exit;
4066 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004067 status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004068 ChannelList,
4069 numChannels);
4070 if (eHAL_STATUS_SUCCESS != status)
4071 {
4072 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4073 "%s: Failed to update channel list information", __func__);
4074 ret = -EINVAL;
4075 goto exit;
4076 }
4077 }
4078 else if (strncmp(command, "GETTSMSTATS", 11) == 0)
4079 {
4080 tANI_U8 *value = command;
4081 char extra[128] = {0};
4082 int len = 0;
4083 tANI_U8 tid = 0;
4084 hdd_station_ctx_t *pHddStaCtx = NULL;
4085 tAniTrafStrmMetrics tsmMetrics;
4086 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4087
4088 /* if not associated, return error */
4089 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4090 {
4091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__);
4092 ret = -EINVAL;
4093 goto exit;
4094 }
4095
4096 /* Move pointer to ahead of GETTSMSTATS<delimiter> */
4097 value = value + 12;
4098 /* Convert the value from ascii to integer */
4099 ret = kstrtou8(value, 10, &tid);
4100 if (ret < 0)
4101 {
4102 /* If the input value is greater than max value of datatype, then also
4103 kstrtou8 fails */
4104 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4105 "%s: kstrtou8 failed range [%d - %d]", __func__,
4106 TID_MIN_VALUE,
4107 TID_MAX_VALUE);
4108 ret = -EINVAL;
4109 goto exit;
4110 }
4111
4112 if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE))
4113 {
4114 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4115 "tid value %d is out of range"
4116 " (Min: %d Max: %d)", tid,
4117 TID_MIN_VALUE,
4118 TID_MAX_VALUE);
4119 ret = -EINVAL;
4120 goto exit;
4121 }
4122
4123 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4124 "%s: Received Command to get tsm stats tid = %d", __func__, tid);
4125
4126 if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics))
4127 {
4128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4129 "%s: failed to get tsm stats", __func__);
4130 ret = -EFAULT;
4131 goto exit;
4132 }
4133
4134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4135 "UplinkPktQueueDly(%d)\n"
4136 "UplinkPktQueueDlyHist[0](%d)\n"
4137 "UplinkPktQueueDlyHist[1](%d)\n"
4138 "UplinkPktQueueDlyHist[2](%d)\n"
4139 "UplinkPktQueueDlyHist[3](%d)\n"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304140 "UplinkPktTxDly(%u)\n"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004141 "UplinkPktLoss(%d)\n"
4142 "UplinkPktCount(%d)\n"
4143 "RoamingCount(%d)\n"
4144 "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly,
4145 tsmMetrics.UplinkPktQueueDlyHist[0],
4146 tsmMetrics.UplinkPktQueueDlyHist[1],
4147 tsmMetrics.UplinkPktQueueDlyHist[2],
4148 tsmMetrics.UplinkPktQueueDlyHist[3],
4149 tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss,
4150 tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly);
4151
4152 /* Output TSM stats is of the format
4153 GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly]
4154 eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004155 len = scnprintf(extra, sizeof(extra), "%s %d %d:%d:%d:%d %u %d %d %d %d", command,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004156 tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0],
4157 tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2],
4158 tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly,
4159 tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount,
4160 tsmMetrics.RoamingDly);
4161
Ratnam Rachurid53009c2015-08-07 13:59:00 +05304162 len = VOS_MIN(priv_data.total_len, len + 1);
4163 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4165 "%s: failed to copy data to user buffer", __func__);
4166 ret = -EFAULT;
4167 goto exit;
4168 }
4169 }
4170 else if (strncmp(command, "SETCCKMIE", 9) == 0)
4171 {
4172 tANI_U8 *value = command;
4173 tANI_U8 *cckmIe = NULL;
4174 tANI_U8 cckmIeLen = 0;
4175 eHalStatus status = eHAL_STATUS_SUCCESS;
4176
4177 status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen);
4178 if (eHAL_STATUS_SUCCESS != status)
4179 {
4180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4181 "%s: Failed to parse cckm ie data", __func__);
4182 ret = -EINVAL;
4183 goto exit;
4184 }
4185
4186 if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN)
4187 {
4188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4189 "%s: CCKM Ie input length is more than max[%d]", __func__,
4190 DOT11F_IE_RSN_MAX_LEN);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08004191 vos_mem_free(cckmIe);
4192 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004193 ret = -EINVAL;
4194 goto exit;
4195 }
4196 sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08004197 vos_mem_free(cckmIe);
4198 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004199 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004200 else if (strncmp(command, "CCXBEACONREQ", 12) == 0)
4201 {
4202 tANI_U8 *value = command;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004203 tCsrEseBeaconReq eseBcnReq;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004204 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004205
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004206 status = hdd_parse_ese_beacon_req(value, &eseBcnReq);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004207 if (eHAL_STATUS_SUCCESS != status)
4208 {
4209 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004210 "%s: Failed to parse ese beacon req", __func__);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004211 ret = -EINVAL;
4212 goto exit;
4213 }
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004214 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
4215 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated"));
4216 hdd_indicateEseBcnReportNoResults (pAdapter,
4217 eseBcnReq.bcnReq[0].measurementToken,
4218 0x02, //BIT(1) set for measurement done
4219 0); // no BSS
4220 goto exit;
4221 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004222
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004223 status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq);
4224 if (eHAL_STATUS_SUCCESS != status)
4225 {
4226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4227 "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status);
4228 ret = -EINVAL;
4229 goto exit;
4230 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004231 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004232#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
c_hpothu92367912014-05-01 15:18:17 +05304233 else if (strncmp(command, "GETBCNMISSRATE", 14) == 0)
4234 {
4235 eHalStatus status;
4236 char buf[32], len;
4237 long waitRet;
4238 bcnMissRateContext_t getBcnMissRateCtx;
4239
4240 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4241
4242 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4243 {
4244 hddLog(VOS_TRACE_LEVEL_WARN,
4245 FL("GETBCNMISSRATE: STA is not in connected state"));
4246 ret = -1;
4247 goto exit;
4248 }
4249
4250 init_completion(&(getBcnMissRateCtx.completion));
4251 getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC;
4252
4253 status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal),
4254 pAdapter->sessionId,
4255 (void *)getBcnMissRateCB,
4256 (void *)(&getBcnMissRateCtx));
4257 if( eHAL_STATUS_SUCCESS != status)
4258 {
4259 hddLog(VOS_TRACE_LEVEL_INFO,
4260 FL("GETBCNMISSRATE: fail to post WDA cmd"));
4261 ret = -EINVAL;
4262 goto exit;
4263 }
4264
4265 waitRet = wait_for_completion_interruptible_timeout
4266 (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME);
4267 if(waitRet <= 0)
4268 {
4269 hddLog(VOS_TRACE_LEVEL_ERROR,
4270 FL("failed to wait on bcnMissRateComp %d"), ret);
4271
4272 //Make magic number to zero so that callback is not called.
4273 spin_lock(&hdd_context_lock);
4274 getBcnMissRateCtx.magic = 0x0;
4275 spin_unlock(&hdd_context_lock);
4276 ret = -EINVAL;
4277 goto exit;
4278 }
4279
4280 hddLog(VOS_TRACE_LEVEL_INFO,
4281 FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate);
4282
4283 len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate);
4284 if (copy_to_user(priv_data.buf, &buf, len + 1))
4285 {
4286 hddLog(VOS_TRACE_LEVEL_ERROR,
4287 "%s: failed to copy data to user buffer", __func__);
4288 ret = -EFAULT;
4289 goto exit;
4290 }
4291 ret = len;
4292 }
Atul Mittal87ec2422014-09-24 13:12:50 +05304293#ifdef FEATURE_WLAN_TDLS
4294 else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) {
4295 tANI_U8 *value = command;
4296 int set_value;
4297 /* Move pointer to ahead of TDLSOFFCH*/
4298 value += 26;
4299 sscanf(value, "%d", &set_value);
4300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4301 "%s: Tdls offchannel offset:%d",
4302 __func__, set_value);
4303 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4304 if (ret < 0)
4305 {
4306 ret = -EINVAL;
4307 goto exit;
4308 }
4309
4310 } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) {
4311 tANI_U8 *value = command;
4312 int set_value;
4313 /* Move pointer to ahead of tdlsoffchnmode*/
4314 value += 18;
4315 sscanf(value, "%d", &set_value);
4316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4317 "%s: Tdls offchannel mode:%d",
4318 __func__, set_value);
4319 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4320 if (ret < 0)
4321 {
4322 ret = -EINVAL;
4323 goto exit;
4324 }
4325 } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) {
4326 tANI_U8 *value = command;
4327 int set_value;
4328 /* Move pointer to ahead of TDLSOFFCH*/
4329 value += 14;
4330 sscanf(value, "%d", &set_value);
4331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4332 "%s: Tdls offchannel num: %d",
4333 __func__, set_value);
4334 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4335 if (ret < 0)
4336 {
4337 ret = -EINVAL;
4338 goto exit;
4339 }
4340 }
4341#endif
Satyanarayana Dash72806012014-12-02 14:30:08 +05304342 else if (strncmp(command, "GETFWSTATS", 10) == 0)
4343 {
4344 eHalStatus status;
4345 char *buf = NULL;
4346 char len;
4347 long waitRet;
4348 fwStatsContext_t fwStatsCtx;
Abhishek Singh08aa7762014-12-16 13:59:03 +05304349 tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp);
Satyanarayana Dash72806012014-12-02 14:30:08 +05304350 tANI_U8 *ptr = command;
4351 int stats = *(ptr + 11) - '0';
4352
4353 hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats);
4354 if (!IS_FEATURE_FW_STATS_ENABLE)
4355 {
4356 hddLog(VOS_TRACE_LEVEL_INFO,
4357 FL("Get Firmware stats feature not supported"));
4358 ret = -EINVAL;
4359 goto exit;
4360 }
4361
4362 if (FW_STATS_MAX <= stats || 0 >= stats)
4363 {
4364 hddLog(VOS_TRACE_LEVEL_INFO,
4365 FL(" stats %d not supported"),stats);
4366 ret = -EINVAL;
4367 goto exit;
4368 }
4369
4370 init_completion(&(fwStatsCtx.completion));
4371 fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC;
4372 fwStatsCtx.pAdapter = pAdapter;
4373 fwStatsRsp->type = 0;
4374 status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats,
Abhishek Singh08aa7762014-12-16 13:59:03 +05304375 &fwStatsCtx, hdd_FWStatisCB);
Satyanarayana Dash72806012014-12-02 14:30:08 +05304376 if (eHAL_STATUS_SUCCESS != status)
4377 {
4378 hddLog(VOS_TRACE_LEVEL_ERROR,
4379 FL(" fail to post WDA cmd status = %d"), status);
4380 ret = -EINVAL;
4381 goto exit;
4382 }
4383 waitRet = wait_for_completion_timeout
4384 (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME);
4385 if (waitRet <= 0)
4386 {
4387 hddLog(VOS_TRACE_LEVEL_ERROR,
4388 FL("failed to wait on GwtFwstats"));
4389 //Make magic number to zero so that callback is not executed.
4390 spin_lock(&hdd_context_lock);
4391 fwStatsCtx.magic = 0x0;
4392 spin_unlock(&hdd_context_lock);
4393 ret = -EINVAL;
4394 goto exit;
4395 }
4396 if (fwStatsRsp->type)
4397 {
4398 buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL);
4399 if (!buf)
4400 {
4401 hddLog(VOS_TRACE_LEVEL_ERROR,
4402 FL(" failed to allocate memory"));
4403 ret = -ENOMEM;
4404 goto exit;
4405 }
4406 switch( fwStatsRsp->type )
4407 {
4408 case FW_UBSP_STATS:
4409 {
4410 len = snprintf(buf, FW_STATE_RSP_LEN,
4411 "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d",
Abhishek Singh08aa7762014-12-16 13:59:03 +05304412 fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt,
4413 fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt);
Satyanarayana Dash72806012014-12-02 14:30:08 +05304414 }
4415 break;
4416 default:
4417 {
4418 hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type);
4419 ret = -EFAULT;
4420 kfree(buf);
4421 goto exit;
4422 }
4423 }
4424 if (copy_to_user(priv_data.buf, buf, len + 1))
4425 {
4426 hddLog(VOS_TRACE_LEVEL_ERROR,
4427 FL(" failed to copy data to user buffer"));
4428 ret = -EFAULT;
4429 kfree(buf);
4430 goto exit;
4431 }
4432 ret = len;
4433 kfree(buf);
4434 }
4435 else
4436 {
4437 hddLog(VOS_TRACE_LEVEL_ERROR,
4438 FL("failed to fetch the stats"));
4439 ret = -EFAULT;
4440 goto exit;
4441 }
4442
4443 }
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +05304444 else if (strncasecmp(command, "SET_FCC_CHANNEL", 15) == 0)
4445 {
4446 /*
4447 * this command wld be called by user-space when it detects WLAN
4448 * ON after airplane mode is set. When APM is set, WLAN turns off.
4449 * But it can be turned back on. Otherwise; when APM is turned back
4450 * off, WLAN wld turn back on. So at that point the command is
4451 * expected to come down. 0 means disable, 1 means enable. The
4452 * constraint is removed when parameter 1 is set or different
4453 * country code is set
4454 */
4455 ret = hdd_cmd_setFccChannel(pHddCtx, command, 15);
4456 }
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004457 else {
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304458 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4459 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
4460 pAdapter->sessionId, 0));
Satyanarayana Dash72806012014-12-02 14:30:08 +05304461 hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"),
4462 command);
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 }
4465exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304466 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 if (command)
4468 {
4469 kfree(command);
4470 }
4471 return ret;
4472}
4473
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004474#ifdef CONFIG_COMPAT
4475static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4476{
4477 struct {
4478 compat_uptr_t buf;
4479 int used_len;
4480 int total_len;
4481 } compat_priv_data;
4482 hdd_priv_data_t priv_data;
4483 int ret = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004484
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004485 /*
4486 * Note that pAdapter and ifr have already been verified by caller,
4487 * and HDD context has also been validated
4488 */
4489 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
4490 sizeof(compat_priv_data))) {
4491 ret = -EFAULT;
4492 goto exit;
4493 }
4494 priv_data.buf = compat_ptr(compat_priv_data.buf);
4495 priv_data.used_len = compat_priv_data.used_len;
4496 priv_data.total_len = compat_priv_data.total_len;
4497 ret = hdd_driver_command(pAdapter, &priv_data);
4498 exit:
4499 return ret;
4500}
4501#else /* CONFIG_COMPAT */
4502static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4503{
4504 /* will never be invoked */
4505 return 0;
4506}
4507#endif /* CONFIG_COMPAT */
4508
4509static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4510{
4511 hdd_priv_data_t priv_data;
4512 int ret = 0;
4513
4514 /*
4515 * Note that pAdapter and ifr have already been verified by caller,
4516 * and HDD context has also been validated
4517 */
4518 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
4519 ret = -EFAULT;
4520 } else {
4521 ret = hdd_driver_command(pAdapter, &priv_data);
4522 }
4523 return ret;
4524}
4525
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05304526int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004527{
4528 hdd_adapter_t *pAdapter;
4529 hdd_context_t *pHddCtx;
4530 int ret;
4531
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304532 ENTER();
4533
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004534 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4535 if (NULL == pAdapter) {
4536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4537 "%s: HDD adapter context is Null", __func__);
4538 ret = -ENODEV;
4539 goto exit;
4540 }
4541 if (dev != pAdapter->dev) {
4542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4543 "%s: HDD adapter/dev inconsistency", __func__);
4544 ret = -ENODEV;
4545 goto exit;
4546 }
4547
4548 if ((!ifr) || (!ifr->ifr_data)) {
4549 ret = -EINVAL;
4550 goto exit;
4551 }
4552
4553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4554 ret = wlan_hdd_validate_context(pHddCtx);
4555 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004556 ret = -EBUSY;
4557 goto exit;
4558 }
4559
4560 switch (cmd) {
4561 case (SIOCDEVPRIVATE + 1):
4562 if (is_compat_task())
4563 ret = hdd_driver_compat_ioctl(pAdapter, ifr);
4564 else
4565 ret = hdd_driver_ioctl(pAdapter, ifr);
4566 break;
4567 default:
4568 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
4569 __func__, cmd);
4570 ret = -EINVAL;
4571 break;
4572 }
4573 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304574 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004575 return ret;
4576}
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004577
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05304578int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4579{
4580 int ret;
4581
4582 vos_ssr_protect(__func__);
4583 ret = __hdd_ioctl(dev, ifr, cmd);
4584 vos_ssr_unprotect(__func__);
4585
4586 return ret;
4587}
4588
Katya Nigame7b69a82015-04-28 15:24:06 +05304589int hdd_mon_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4590{
4591 return 0;
4592}
4593
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004594#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004595/**---------------------------------------------------------------------------
4596
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004597 \brief hdd_parse_ese_beacon_req() - Parse ese beacon request
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004598
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004599 This function parses the ese beacon request passed in the format
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004600 CCXBEACONREQ<space><Number of fields><space><Measurement token>
4601 <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N
4602 <space>Scan Mode N<space>Meas Duration N
4603 if the Number of bcn req fields (N) does not match with the actual number of fields passed
4604 then take N.
4605 <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair
4606 For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40.
4607 This function does not take care of removing duplicate channels from the list
4608
4609 \param - pValue Pointer to data
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004610 \param - pEseBcnReq output pointer to store parsed ie information
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004611
4612 \return - 0 for success non-zero for failure
4613
4614 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004615static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue,
4616 tCsrEseBeaconReq *pEseBcnReq)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004617{
4618 tANI_U8 *inPtr = pValue;
4619 int tempInt = 0;
4620 int j = 0, i = 0, v = 0;
4621 char buf[32];
4622
4623 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4624 /*no argument after the command*/
4625 if (NULL == inPtr)
4626 {
4627 return -EINVAL;
4628 }
4629 /*no space after the command*/
4630 else if (SPACE_ASCII_VALUE != *inPtr)
4631 {
4632 return -EINVAL;
4633 }
4634
4635 /*removing empty spaces*/
4636 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
4637
4638 /*no argument followed by spaces*/
4639 if ('\0' == *inPtr) return -EINVAL;
4640
4641 /*getting the first argument ie measurement token*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004642 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004643 if (1 != v) return -EINVAL;
4644
4645 v = kstrtos32(buf, 10, &tempInt);
4646 if ( v < 0) return -EINVAL;
4647
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004648 pEseBcnReq->numBcnReqIe = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004649
4650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004651 "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004652
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004653 for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004654 {
4655 for (i = 0; i < 4; i++)
4656 {
4657 /*inPtr pointing to the beginning of first space after number of ie fields*/
4658 inPtr = strpbrk( inPtr, " " );
4659 /*no ie data after the number of ie fields argument*/
4660 if (NULL == inPtr) return -EINVAL;
4661
4662 /*removing empty space*/
4663 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
4664
4665 /*no ie data after the number of ie fields argument and spaces*/
4666 if ( '\0' == *inPtr ) return -EINVAL;
4667
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004668 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004669 if (1 != v) return -EINVAL;
4670
4671 v = kstrtos32(buf, 10, &tempInt);
4672 if (v < 0) return -EINVAL;
4673
4674 switch (i)
4675 {
4676 case 0: /* Measurement token */
4677 if (tempInt <= 0)
4678 {
4679 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4680 "Invalid Measurement Token(%d)", tempInt);
4681 return -EINVAL;
4682 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004683 pEseBcnReq->bcnReq[j].measurementToken = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004684 break;
4685
4686 case 1: /* Channel number */
4687 if ((tempInt <= 0) ||
4688 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4689 {
4690 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4691 "Invalid Channel Number(%d)", tempInt);
4692 return -EINVAL;
4693 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004694 pEseBcnReq->bcnReq[j].channel = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004695 break;
4696
4697 case 2: /* Scan mode */
Varun Reddy Yeturu0b18d5a2013-12-04 11:42:23 -08004698 if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004699 {
4700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4701 "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt);
4702 return -EINVAL;
4703 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004704 pEseBcnReq->bcnReq[j].scanMode= tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004705 break;
4706
4707 case 3: /* Measurement duration */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004708 if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) ||
4709 ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE)))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004710 {
4711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4712 "Invalid Measurement Duration(%d)", tempInt);
4713 return -EINVAL;
4714 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004715 pEseBcnReq->bcnReq[j].measurementDuration = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004716 break;
4717 }
4718 }
4719 }
4720
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004721 for (j = 0; j < pEseBcnReq->numBcnReqIe; j++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004722 {
4723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304724 "Index(%d) Measurement Token(%u)Channel(%u) Scan Mode(%u) Measurement Duration(%u)\n",
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004725 j,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004726 pEseBcnReq->bcnReq[j].measurementToken,
4727 pEseBcnReq->bcnReq[j].channel,
4728 pEseBcnReq->bcnReq[j].scanMode,
4729 pEseBcnReq->bcnReq[j].measurementDuration);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004730 }
4731
4732 return VOS_STATUS_SUCCESS;
4733}
4734
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004735static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext )
4736{
4737 struct statsContext *pStatsContext = NULL;
4738 hdd_adapter_t *pAdapter = NULL;
4739
4740 if (NULL == pContext)
4741 {
4742 hddLog(VOS_TRACE_LEVEL_ERROR,
4743 "%s: Bad param, pContext [%p]",
4744 __func__, pContext);
4745 return;
4746 }
4747
Jeff Johnson72a40512013-12-19 10:14:15 -08004748 /* there is a race condition that exists between this callback
4749 function and the caller since the caller could time out either
4750 before or while this code is executing. we use a spinlock to
4751 serialize these actions */
4752 spin_lock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004753
4754 pStatsContext = pContext;
4755 pAdapter = pStatsContext->pAdapter;
4756 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
4757 {
4758 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08004759 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004760 hddLog(VOS_TRACE_LEVEL_WARN,
4761 "%s: Invalid context, pAdapter [%p] magic [%08x]",
4762 __func__, pAdapter, pStatsContext->magic);
4763 return;
4764 }
4765
Jeff Johnson72a40512013-12-19 10:14:15 -08004766 /* context is valid so caller is still waiting */
4767
4768 /* paranoia: invalidate the magic */
4769 pStatsContext->magic = 0;
4770
4771 /* copy over the tsm stats */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004772 pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly;
4773 vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist,
4774 tsmMetrics.UplinkPktQueueDlyHist,
4775 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4776 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4777 pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly;
4778 pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss;
4779 pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount;
4780 pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount;
4781 pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly;
4782
Jeff Johnson72a40512013-12-19 10:14:15 -08004783 /* notify the caller */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004784 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08004785
4786 /* serialization is complete */
4787 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004788}
4789
4790
4791
4792static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
4793 tAniTrafStrmMetrics* pTsmMetrics)
4794{
4795 hdd_station_ctx_t *pHddStaCtx = NULL;
4796 eHalStatus hstatus;
Jeff Johnson72a40512013-12-19 10:14:15 -08004797 VOS_STATUS vstatus = VOS_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004798 long lrc;
4799 struct statsContext context;
4800 hdd_context_t *pHddCtx = NULL;
4801
4802 if (NULL == pAdapter)
4803 {
4804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__);
4805 return VOS_STATUS_E_FAULT;
4806 }
4807
4808 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4809 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4810
4811 /* we are connected prepare our callback context */
4812 init_completion(&context.completion);
4813 context.pAdapter = pAdapter;
4814 context.magic = STATS_CONTEXT_MAGIC;
4815
4816 /* query tsm stats */
4817 hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB,
4818 pHddStaCtx->conn_info.staId[ 0 ],
4819 pHddStaCtx->conn_info.bssId,
4820 &context, pHddCtx->pvosContext, tid);
4821
4822 if (eHAL_STATUS_SUCCESS != hstatus)
4823 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004824 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics",
4825 __func__);
4826 vstatus = VOS_STATUS_E_FAULT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004827 }
4828 else
4829 {
4830 /* request was sent -- wait for the response */
4831 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4832 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004833 if (lrc <= 0)
4834 {
4835 hddLog(VOS_TRACE_LEVEL_ERROR,
4836 "%s: SME %s while retrieving statistics",
4837 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson72a40512013-12-19 10:14:15 -08004838 vstatus = VOS_STATUS_E_TIMEOUT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004839 }
4840 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004841
Jeff Johnson72a40512013-12-19 10:14:15 -08004842 /* either we never sent a request, we sent a request and received a
4843 response or we sent a request and timed out. if we never sent a
4844 request or if we sent a request and got a response, we want to
4845 clear the magic out of paranoia. if we timed out there is a
4846 race condition such that the callback function could be
4847 executing at the same time we are. of primary concern is if the
4848 callback function had already verified the "magic" but had not
4849 yet set the completion variable when a timeout occurred. we
4850 serialize these activities by invalidating the magic while
4851 holding a shared spinlock which will cause us to block if the
4852 callback is currently executing */
4853 spin_lock(&hdd_context_lock);
4854 context.magic = 0;
4855 spin_unlock(&hdd_context_lock);
4856
4857 if (VOS_STATUS_SUCCESS == vstatus)
4858 {
4859 pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly;
4860 vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist,
4861 pAdapter->tsmStats.UplinkPktQueueDlyHist,
4862 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4863 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4864 pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly;
4865 pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss;
4866 pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount;
4867 pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount;
4868 pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly;
4869 }
4870 return vstatus;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004871}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004872#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004873
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004874#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08004875void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand)
4876{
4877 eCsrBand band = -1;
4878 sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band);
4879 switch (band)
4880 {
4881 case eCSR_BAND_ALL:
4882 *pBand = WLAN_HDD_UI_BAND_AUTO;
4883 break;
4884
4885 case eCSR_BAND_24:
4886 *pBand = WLAN_HDD_UI_BAND_2_4_GHZ;
4887 break;
4888
4889 case eCSR_BAND_5G:
4890 *pBand = WLAN_HDD_UI_BAND_5_GHZ;
4891 break;
4892
4893 default:
4894 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band);
4895 *pBand = -1;
4896 break;
4897 }
4898}
4899
4900/**---------------------------------------------------------------------------
4901
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004902 \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data
4903
4904 This function parses the send action frame data passed in the format
4905 SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data>
4906
Srinivas Girigowda56076852013-08-20 14:00:50 -07004907 \param - pValue Pointer to input data
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004908 \param - pTargetApBssid Pointer to target Ap bssid
4909 \param - pChannel Pointer to the Target AP channel
4910 \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame
4911 \param - pBuf Pointer to data
4912 \param - pBufLen Pointer to data length
4913
4914 \return - 0 for success non-zero for failure
4915
4916 --------------------------------------------------------------------------*/
4917VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel,
4918 tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen)
4919{
4920 tANI_U8 *inPtr = pValue;
4921 tANI_U8 *dataEnd;
4922 int tempInt;
4923 int j = 0;
4924 int i = 0;
4925 int v = 0;
4926 tANI_U8 tempBuf[32];
4927 tANI_U8 tempByte = 0;
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004928 /* 12 hexa decimal digits, 5 ':' and '\0' */
4929 tANI_U8 macAddress[18];
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004930
4931 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4932 /*no argument after the command*/
4933 if (NULL == inPtr)
4934 {
4935 return -EINVAL;
4936 }
4937
4938 /*no space after the command*/
4939 else if (SPACE_ASCII_VALUE != *inPtr)
4940 {
4941 return -EINVAL;
4942 }
4943
4944 /*removing empty spaces*/
4945 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4946
4947 /*no argument followed by spaces*/
4948 if ('\0' == *inPtr)
4949 {
4950 return -EINVAL;
4951 }
4952
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004953 v = sscanf(inPtr, "%17s", macAddress);
4954 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004955 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4957 "Invalid MAC address or All hex inputs are not read (%d)", v);
4958 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004959 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004960
4961 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
4962 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
4963 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
4964 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
4965 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
4966 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004967
4968 /* point to the next argument */
4969 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4970 /*no argument after the command*/
4971 if (NULL == inPtr) return -EINVAL;
4972
4973 /*removing empty spaces*/
4974 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4975
4976 /*no argument followed by spaces*/
4977 if ('\0' == *inPtr)
4978 {
4979 return -EINVAL;
4980 }
4981
4982 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004983 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004984 if (1 != v) return -EINVAL;
4985
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004986 v = kstrtos32(tempBuf, 10, &tempInt);
Agarwal Ashish353b3a82014-04-08 14:55:11 +05304987 if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX )
Kiet Lambe150c22013-11-21 16:30:32 +05304988 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004989
4990 *pChannel = tempInt;
4991
4992 /* point to the next argument */
4993 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4994 /*no argument after the command*/
4995 if (NULL == inPtr) return -EINVAL;
4996 /*removing empty spaces*/
4997 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4998
4999 /*no argument followed by spaces*/
5000 if ('\0' == *inPtr)
5001 {
5002 return -EINVAL;
5003 }
5004
5005 /*getting the next argument ie the dwell time */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005006 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005007 if (1 != v) return -EINVAL;
5008
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005009 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda5a6e0672014-01-09 14:42:57 -08005010 if ( v < 0 || tempInt < 0) return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005011
5012 *pDwellTime = tempInt;
5013
5014 /* point to the next argument */
5015 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
5016 /*no argument after the command*/
5017 if (NULL == inPtr) return -EINVAL;
5018 /*removing empty spaces*/
5019 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5020
5021 /*no argument followed by spaces*/
5022 if ('\0' == *inPtr)
5023 {
5024 return -EINVAL;
5025 }
5026
5027 /* find the length of data */
5028 dataEnd = inPtr;
5029 while(('\0' != *dataEnd) )
5030 {
5031 dataEnd++;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005032 }
Kiet Lambe150c22013-11-21 16:30:32 +05305033 *pBufLen = dataEnd - inPtr ;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005034 if ( *pBufLen <= 0) return -EINVAL;
5035
Srinivas Girigowdab5ae85d2013-06-03 10:51:45 -07005036 /* Allocate the number of bytes based on the number of input characters
5037 whether it is even or odd.
5038 if the number of input characters are even, then we need N/2 byte.
5039 if the number of input characters are odd, then we need do (N+1)/2 to
5040 compensate rounding off.
5041 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
5042 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
5043 *pBuf = vos_mem_malloc((*pBufLen + 1)/2);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005044 if (NULL == *pBuf)
5045 {
5046 hddLog(VOS_TRACE_LEVEL_FATAL,
5047 "%s: vos_mem_alloc failed ", __func__);
5048 return -EINVAL;
5049 }
5050
5051 /* the buffer received from the upper layer is character buffer,
5052 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
5053 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
5054 and f0 in 3rd location */
5055 for (i = 0, j = 0; j < *pBufLen; j += 2)
5056 {
Kiet Lambe150c22013-11-21 16:30:32 +05305057 if( j+1 == *pBufLen)
5058 {
5059 tempByte = hdd_parse_hex(inPtr[j]);
5060 }
5061 else
5062 {
5063 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
5064 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005065 (*pBuf)[i++] = tempByte;
5066 }
5067 *pBufLen = i;
5068 return VOS_STATUS_SUCCESS;
5069}
5070
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005071/**---------------------------------------------------------------------------
5072
Srinivas Girigowdade697412013-02-14 16:31:48 -08005073 \brief hdd_parse_channellist() - HDD Parse channel list
5074
5075 This function parses the channel list passed in the format
5076 SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07005077 if the Number of channels (N) does not match with the actual number of channels passed
5078 then take the minimum of N and count of (Ch1, Ch2, ...Ch M)
5079 For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken.
5080 If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48.
5081 This function does not take care of removing duplicate channels from the list
Srinivas Girigowdade697412013-02-14 16:31:48 -08005082
5083 \param - pValue Pointer to input channel list
5084 \param - ChannelList Pointer to local output array to record channel list
5085 \param - pNumChannels Pointer to number of roam scan channels
5086
5087 \return - 0 for success non-zero for failure
5088
5089 --------------------------------------------------------------------------*/
5090VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels)
5091{
5092 tANI_U8 *inPtr = pValue;
5093 int tempInt;
5094 int j = 0;
5095 int v = 0;
5096 char buf[32];
5097
5098 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
5099 /*no argument after the command*/
5100 if (NULL == inPtr)
5101 {
5102 return -EINVAL;
5103 }
5104
5105 /*no space after the command*/
5106 else if (SPACE_ASCII_VALUE != *inPtr)
5107 {
5108 return -EINVAL;
5109 }
5110
5111 /*removing empty spaces*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005112 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08005113
5114 /*no argument followed by spaces*/
5115 if ('\0' == *inPtr)
5116 {
5117 return -EINVAL;
5118 }
5119
5120 /*getting the first argument ie the number of channels*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005121 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005122 if (1 != v) return -EINVAL;
5123
Srinivas Girigowdade697412013-02-14 16:31:48 -08005124 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005125 if ((v < 0) ||
5126 (tempInt <= 0) ||
5127 (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN))
5128 {
5129 return -EINVAL;
5130 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005131
5132 *pNumChannels = tempInt;
5133
5134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5135 "Number of channels are: %d", *pNumChannels);
5136
5137 for (j = 0; j < (*pNumChannels); j++)
5138 {
5139 /*inPtr pointing to the beginning of first space after number of channels*/
5140 inPtr = strpbrk( inPtr, " " );
5141 /*no channel list after the number of channels argument*/
5142 if (NULL == inPtr)
5143 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07005144 if (0 != j)
5145 {
5146 *pNumChannels = j;
5147 return VOS_STATUS_SUCCESS;
5148 }
5149 else
5150 {
5151 return -EINVAL;
5152 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005153 }
5154
5155 /*removing empty space*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005156 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08005157
5158 /*no channel list after the number of channels argument and spaces*/
5159 if ( '\0' == *inPtr )
5160 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07005161 if (0 != j)
5162 {
5163 *pNumChannels = j;
5164 return VOS_STATUS_SUCCESS;
5165 }
5166 else
5167 {
5168 return -EINVAL;
5169 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005170 }
5171
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005172 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005173 if (1 != v) return -EINVAL;
5174
Srinivas Girigowdade697412013-02-14 16:31:48 -08005175 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005176 if ((v < 0) ||
5177 (tempInt <= 0) ||
5178 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
5179 {
5180 return -EINVAL;
5181 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005182 pChannelList[j] = tempInt;
5183
5184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5185 "Channel %d added to preferred channel list",
5186 pChannelList[j] );
5187 }
5188
Srinivas Girigowdade697412013-02-14 16:31:48 -08005189 return VOS_STATUS_SUCCESS;
5190}
5191
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005192
5193/**---------------------------------------------------------------------------
5194
5195 \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data
5196
5197 This function parses the reasoc command data passed in the format
5198 REASSOC<space><bssid><space><channel>
5199
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005200 \param - pValue Pointer to input data (its a NUL terminated string)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005201 \param - pTargetApBssid Pointer to target Ap bssid
5202 \param - pChannel Pointer to the Target AP channel
5203
5204 \return - 0 for success non-zero for failure
5205
5206 --------------------------------------------------------------------------*/
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005207VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
5208 tANI_U8 *pTargetApBssid, tANI_U8 *pChannel)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005209{
5210 tANI_U8 *inPtr = pValue;
5211 int tempInt;
5212 int v = 0;
5213 tANI_U8 tempBuf[32];
Kiet Lamaa8e15a2014-02-11 23:30:06 -08005214 /* 12 hexa decimal digits, 5 ':' and '\0' */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005215 tANI_U8 macAddress[18];
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005216
5217 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
5218 /*no argument after the command*/
5219 if (NULL == inPtr)
5220 {
5221 return -EINVAL;
5222 }
5223
5224 /*no space after the command*/
5225 else if (SPACE_ASCII_VALUE != *inPtr)
5226 {
5227 return -EINVAL;
5228 }
5229
5230 /*removing empty spaces*/
5231 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5232
5233 /*no argument followed by spaces*/
5234 if ('\0' == *inPtr)
5235 {
5236 return -EINVAL;
5237 }
5238
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005239 v = sscanf(inPtr, "%17s", macAddress);
5240 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005241 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5243 "Invalid MAC address or All hex inputs are not read (%d)", v);
5244 return -EINVAL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005245 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005246
5247 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
5248 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
5249 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
5250 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
5251 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
5252 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005253
5254 /* point to the next argument */
5255 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
5256 /*no argument after the command*/
5257 if (NULL == inPtr) return -EINVAL;
5258
5259 /*removing empty spaces*/
5260 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5261
5262 /*no argument followed by spaces*/
5263 if ('\0' == *inPtr)
5264 {
5265 return -EINVAL;
5266 }
5267
5268 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005269 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005270 if (1 != v) return -EINVAL;
5271
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005272 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005273 if ((v < 0) ||
Padma, Santhosh Kumar0fa809b2014-11-13 14:56:56 +05305274 (tempInt < 0) ||
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005275 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
5276 {
5277 return -EINVAL;
5278 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005279
5280 *pChannel = tempInt;
5281 return VOS_STATUS_SUCCESS;
5282}
5283
5284#endif
5285
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005286#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005287/**---------------------------------------------------------------------------
5288
5289 \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE
5290
5291 This function parses the SETCCKM IE command
5292 SETCCKMIE<space><ie data>
5293
5294 \param - pValue Pointer to input data
5295 \param - pCckmIe Pointer to output cckm Ie
5296 \param - pCckmIeLen Pointer to output cckm ie length
5297
5298 \return - 0 for success non-zero for failure
5299
5300 --------------------------------------------------------------------------*/
5301VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe,
5302 tANI_U8 *pCckmIeLen)
5303{
5304 tANI_U8 *inPtr = pValue;
5305 tANI_U8 *dataEnd;
5306 int j = 0;
5307 int i = 0;
5308 tANI_U8 tempByte = 0;
5309
5310 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
5311 /*no argument after the command*/
5312 if (NULL == inPtr)
5313 {
5314 return -EINVAL;
5315 }
5316
5317 /*no space after the command*/
5318 else if (SPACE_ASCII_VALUE != *inPtr)
5319 {
5320 return -EINVAL;
5321 }
5322
5323 /*removing empty spaces*/
5324 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5325
5326 /*no argument followed by spaces*/
5327 if ('\0' == *inPtr)
5328 {
5329 return -EINVAL;
5330 }
5331
5332 /* find the length of data */
5333 dataEnd = inPtr;
5334 while(('\0' != *dataEnd) )
5335 {
5336 dataEnd++;
5337 ++(*pCckmIeLen);
5338 }
5339 if ( *pCckmIeLen <= 0) return -EINVAL;
5340
5341 /* Allocate the number of bytes based on the number of input characters
5342 whether it is even or odd.
5343 if the number of input characters are even, then we need N/2 byte.
5344 if the number of input characters are odd, then we need do (N+1)/2 to
5345 compensate rounding off.
5346 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
5347 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
5348 *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2);
5349 if (NULL == *pCckmIe)
5350 {
5351 hddLog(VOS_TRACE_LEVEL_FATAL,
5352 "%s: vos_mem_alloc failed ", __func__);
5353 return -EINVAL;
5354 }
5355 vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2);
5356 /* the buffer received from the upper layer is character buffer,
5357 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
5358 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
5359 and f0 in 3rd location */
5360 for (i = 0, j = 0; j < *pCckmIeLen; j += 2)
5361 {
5362 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
5363 (*pCckmIe)[i++] = tempByte;
5364 }
5365 *pCckmIeLen = i;
5366
5367 return VOS_STATUS_SUCCESS;
5368}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005369#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005370
Jeff Johnson295189b2012-06-20 16:38:30 -07005371/**---------------------------------------------------------------------------
5372
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005373 \brief hdd_is_valid_mac_address() - Validate MAC address
5374
5375 This function validates whether the given MAC address is valid or not
5376 Expected MAC address is of the format XX:XX:XX:XX:XX:XX
5377 where X is the hexa decimal digit character and separated by ':'
5378 This algorithm works even if MAC address is not separated by ':'
5379
5380 This code checks given input string mac contains exactly 12 hexadecimal digits.
5381 and a separator colon : appears in the input string only after
5382 an even number of hex digits.
5383
5384 \param - pMacAddr pointer to the input MAC address
5385 \return - 1 for valid and 0 for invalid
5386
5387 --------------------------------------------------------------------------*/
5388
5389v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr)
5390{
5391 int xdigit = 0;
5392 int separator = 0;
5393 while (*pMacAddr)
5394 {
5395 if (isxdigit(*pMacAddr))
5396 {
5397 xdigit++;
5398 }
5399 else if (':' == *pMacAddr)
5400 {
5401 if (0 == xdigit || ((xdigit / 2) - 1) != separator)
5402 break;
5403
5404 ++separator;
5405 }
5406 else
5407 {
5408 separator = -1;
5409 /* Invalid MAC found */
5410 return 0;
5411 }
5412 ++pMacAddr;
5413 }
5414 return (xdigit == 12 && (separator == 5 || separator == 0));
5415}
5416
5417/**---------------------------------------------------------------------------
5418
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305419 \brief __hdd_open() - HDD Open function
Jeff Johnson295189b2012-06-20 16:38:30 -07005420
5421 \param - dev Pointer to net_device structure
5422
5423 \return - 0 for success non-zero for failure
5424
5425 --------------------------------------------------------------------------*/
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305426int __hdd_open(struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005427{
5428 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5429 hdd_context_t *pHddCtx;
5430 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5431 VOS_STATUS status;
5432 v_BOOL_t in_standby = TRUE;
5433
5434 if (NULL == pAdapter)
5435 {
5436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05305437 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 return -ENODEV;
5439 }
5440
5441 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305442 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST,
5443 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 if (NULL == pHddCtx)
5445 {
5446 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005447 "%s: HDD context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 return -ENODEV;
5449 }
5450
5451 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5452 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
5453 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005454 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
5455 {
5456 hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby",
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305457 __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005458 in_standby = FALSE;
5459 break;
5460 }
5461 else
5462 {
5463 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5464 pAdapterNode = pNext;
5465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 }
5467
5468 if (TRUE == in_standby)
5469 {
5470 if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter))
5471 {
5472 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring "
5473 "wlan out of power save", __func__);
5474 return -EINVAL;
5475 }
5476 }
5477
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005478 set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5480 {
5481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005482 "%s: Enabling Tx Queues", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 /* Enable TX queues only when we are connected */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305484 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 netif_tx_start_all_queues(dev);
5486 }
5487
5488 return 0;
5489}
5490
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305491/**---------------------------------------------------------------------------
5492
5493 \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR
5494
5495 This is called in response to ifconfig up
5496
5497 \param - dev Pointer to net_device structure
5498
5499 \return - 0 for success non-zero for failure
5500
5501 --------------------------------------------------------------------------*/
5502int hdd_open(struct net_device *dev)
5503{
5504 int ret;
5505
5506 vos_ssr_protect(__func__);
5507 ret = __hdd_open(dev);
5508 vos_ssr_unprotect(__func__);
5509
5510 return ret;
5511}
5512
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305513int __hdd_mon_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005514{
5515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5516
5517 if(pAdapter == NULL) {
5518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005519 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005520 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 }
5522
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 return 0;
5524}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305525
5526int hdd_mon_open (struct net_device *dev)
5527{
5528 int ret;
5529
5530 vos_ssr_protect(__func__);
5531 ret = __hdd_mon_open(dev);
5532 vos_ssr_unprotect(__func__);
5533
5534 return ret;
5535}
5536
Katya Nigame7b69a82015-04-28 15:24:06 +05305537int hdd_mon_stop(struct net_device *dev)
5538{
5539 return 0;
5540}
5541
Jeff Johnson295189b2012-06-20 16:38:30 -07005542/**---------------------------------------------------------------------------
5543
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305544 \brief __hdd_stop() - HDD stop function
Jeff Johnson295189b2012-06-20 16:38:30 -07005545
5546 \param - dev Pointer to net_device structure
5547
5548 \return - 0 for success non-zero for failure
5549
5550 --------------------------------------------------------------------------*/
5551
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305552int __hdd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005553{
Vinay Krishna Eranna90f43532014-10-27 16:45:54 +05305554 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5556 hdd_context_t *pHddCtx;
5557 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5558 VOS_STATUS status;
5559 v_BOOL_t enter_standby = TRUE;
5560
5561 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 if (NULL == pAdapter)
5563 {
5564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05305565 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 return -ENODEV;
5567 }
Sachin Ahuja9b4958f2015-01-15 21:37:00 +05305568 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305569 pAdapter->sessionId, pAdapter->device_mode));
Vinay Krishna Eranna90f43532014-10-27 16:45:54 +05305570
5571 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5572 ret = wlan_hdd_validate_context(pHddCtx);
5573 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 {
Vinay Krishna Eranna90f43532014-10-27 16:45:54 +05305575 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 }
5577
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305578 /* Nothing to be done if the interface is not opened */
5579 if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags))
5580 {
5581 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5582 "%s: NETDEV Interface is not OPENED", __func__);
5583 return -ENODEV;
5584 }
5585
5586 /* Make sure the interface is marked as closed */
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005587 clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__);
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305589
5590 /* Disable TX on the interface, after this hard_start_xmit() will not
5591 * be called on that interface
5592 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305593 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 netif_tx_disable(pAdapter->dev);
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305595
5596 /* Mark the interface status as "down" for outside world */
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 netif_carrier_off(pAdapter->dev);
5598
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305599 /* The interface is marked as down for outside world (aka kernel)
5600 * But the driver is pretty much alive inside. The driver needs to
5601 * tear down the existing connection on the netdev (session)
5602 * cleanup the data pipes and wait until the control plane is stabilized
5603 * for this interface. The call also needs to wait until the above
5604 * mentioned actions are completed before returning to the caller.
5605 * Notice that the hdd_stop_adapter is requested not to close the session
5606 * That is intentional to be able to scan if it is a STA/P2P interface
5607 */
5608 hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305609#ifdef FEATURE_WLAN_TDLS
5610 mutex_lock(&pHddCtx->tdls_lock);
5611#endif
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305612 /* DeInit the adapter. This ensures datapath cleanup as well */
c_hpothu002231a2015-02-05 14:58:51 +05305613 hdd_deinit_adapter(pHddCtx, pAdapter, TRUE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305614#ifdef FEATURE_WLAN_TDLS
5615 mutex_unlock(&pHddCtx->tdls_lock);
5616#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 /* SoftAP ifaces should never go in power save mode
5618 making sure same here. */
5619 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode )
5620 || (WLAN_HDD_MONITOR == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 || (WLAN_HDD_P2P_GO == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 )
5623 {
5624 /* SoftAP mode, so return from here */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305625 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5626 "%s: In SAP MODE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 EXIT();
5628 return 0;
5629 }
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305630 /* Find if any iface is up. If any iface is up then can't put device to
5631 * sleep/power save mode
5632 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5634 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
5635 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005636 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
5637 {
5638 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305639 "put device to sleep", __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005640 enter_standby = FALSE;
5641 break;
5642 }
5643 else
5644 {
5645 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5646 pAdapterNode = pNext;
5647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 }
5649
5650 if (TRUE == enter_standby)
5651 {
5652 hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down "
5653 "entering standby", __func__);
5654 if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx))
5655 {
5656 /*log and return success*/
5657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put "
5658 "wlan in power save", __func__);
5659 }
5660 }
5661
5662 EXIT();
5663 return 0;
5664}
5665
5666/**---------------------------------------------------------------------------
5667
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305668 \brief hdd_stop() - wrapper_function for __hdd_stop to protect it from SSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005669
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305670 This is called in response to ifconfig down
5671
5672 \param - dev Pointer to net_device structure
5673
5674 \return - 0 for success non-zero for failure
5675-----------------------------------------------------------------------------*/
5676int hdd_stop (struct net_device *dev)
5677{
5678 int ret;
5679
5680 vos_ssr_protect(__func__);
5681 ret = __hdd_stop(dev);
5682 vos_ssr_unprotect(__func__);
5683
5684 return ret;
5685}
5686
5687/**---------------------------------------------------------------------------
5688
5689 \brief __hdd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -07005690
5691 \param - dev Pointer to net_device structure
5692
5693 \return - void
5694
5695 --------------------------------------------------------------------------*/
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305696static void __hdd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005697{
5698 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305699 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 ENTER();
5701
5702 do
5703 {
5704 if (NULL == pAdapter)
5705 {
5706 hddLog(VOS_TRACE_LEVEL_FATAL,
5707 "%s: NULL pAdapter", __func__);
5708 break;
5709 }
5710
5711 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5712 {
5713 hddLog(VOS_TRACE_LEVEL_FATAL,
5714 "%s: Invalid magic", __func__);
5715 break;
5716 }
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305717 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5718 if (NULL == pHddCtx)
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 {
5720 hddLog(VOS_TRACE_LEVEL_FATAL,
5721 "%s: NULL pHddCtx", __func__);
5722 break;
5723 }
5724
5725 if (dev != pAdapter->dev)
5726 {
5727 hddLog(VOS_TRACE_LEVEL_FATAL,
5728 "%s: Invalid device reference", __func__);
5729 /* we haven't validated all cases so let this go for now */
5730 }
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305731#ifdef FEATURE_WLAN_TDLS
5732 mutex_lock(&pHddCtx->tdls_lock);
5733#endif
c_hpothu002231a2015-02-05 14:58:51 +05305734 hdd_deinit_adapter(pHddCtx, pAdapter, TRUE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305735#ifdef FEATURE_WLAN_TDLS
5736 mutex_unlock(&pHddCtx->tdls_lock);
5737#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005738
5739 /* after uninit our adapter structure will no longer be valid */
5740 pAdapter->dev = NULL;
5741 pAdapter->magic = 0;
5742 } while (0);
5743
5744 EXIT();
5745}
5746
5747/**---------------------------------------------------------------------------
5748
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305749 \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR
5750
5751 This is called during the netdev unregister to uninitialize all data
5752associated with the device
5753
5754 \param - dev Pointer to net_device structure
5755
5756 \return - void
5757
5758 --------------------------------------------------------------------------*/
5759static void hdd_uninit (struct net_device *dev)
5760{
5761 vos_ssr_protect(__func__);
5762 __hdd_uninit(dev);
5763 vos_ssr_unprotect(__func__);
5764}
5765
5766/**---------------------------------------------------------------------------
5767
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 \brief hdd_release_firmware() -
5769
5770 This function calls the release firmware API to free the firmware buffer.
5771
5772 \param - pFileName Pointer to the File Name.
5773 pCtx - Pointer to the adapter .
5774
5775
5776 \return - 0 for success, non zero for failure
5777
5778 --------------------------------------------------------------------------*/
5779
5780VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx)
5781{
5782 VOS_STATUS status = VOS_STATUS_SUCCESS;
5783 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5784 ENTER();
5785
5786
5787 if (!strcmp(WLAN_FW_FILE, pFileName)) {
5788
5789 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName);
5790
5791 if(pHddCtx->fw) {
5792 release_firmware(pHddCtx->fw);
5793 pHddCtx->fw = NULL;
5794 }
5795 else
5796 status = VOS_STATUS_E_FAILURE;
5797 }
5798 else if (!strcmp(WLAN_NV_FILE,pFileName)) {
5799 if(pHddCtx->nv) {
5800 release_firmware(pHddCtx->nv);
5801 pHddCtx->nv = NULL;
5802 }
5803 else
5804 status = VOS_STATUS_E_FAILURE;
5805
5806 }
5807
5808 EXIT();
5809 return status;
5810}
5811
5812/**---------------------------------------------------------------------------
5813
5814 \brief hdd_request_firmware() -
5815
5816 This function reads the firmware file using the request firmware
5817 API and returns the the firmware data and the firmware file size.
5818
5819 \param - pfileName - Pointer to the file name.
5820 - pCtx - Pointer to the adapter .
5821 - ppfw_data - Pointer to the pointer of the firmware data.
5822 - pSize - Pointer to the file size.
5823
5824 \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure
5825
5826 --------------------------------------------------------------------------*/
5827
5828
5829VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize)
5830{
5831 int status;
5832 VOS_STATUS retval = VOS_STATUS_SUCCESS;
5833 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5834 ENTER();
5835
5836 if( (!strcmp(WLAN_FW_FILE, pfileName)) ) {
5837
5838 status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev);
5839
5840 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5841 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed",
5842 __func__, pfileName);
5843 retval = VOS_STATUS_E_FAILURE;
5844 }
5845
5846 else {
5847 *ppfw_data = (v_VOID_t *)pHddCtx->fw->data;
5848 *pSize = pHddCtx->fw->size;
5849 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d",
5850 __func__, *pSize);
5851 }
5852 }
5853 else if(!strcmp(WLAN_NV_FILE, pfileName)) {
5854
5855 status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev);
5856
5857 if(status || !pHddCtx->nv || !pHddCtx->nv->data) {
5858 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed",
5859 __func__, pfileName);
5860 retval = VOS_STATUS_E_FAILURE;
5861 }
5862
5863 else {
5864 *ppfw_data = (v_VOID_t *)pHddCtx->nv->data;
5865 *pSize = pHddCtx->nv->size;
5866 hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d",
5867 __func__, *pSize);
5868 }
5869 }
5870
5871 EXIT();
5872 return retval;
5873}
5874/**---------------------------------------------------------------------------
5875 \brief hdd_full_pwr_cbk() - HDD full power callbackfunction
5876
5877 This is the function invoked by SME to inform the result of a full power
5878 request issued by HDD
5879
5880 \param - callbackcontext - Pointer to cookie
5881 status - result of request
5882
5883 \return - None
5884
5885--------------------------------------------------------------------------*/
5886void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status)
5887{
5888 hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext;
5889
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005890 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"HDD full Power callback status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 if(&pHddCtx->full_pwr_comp_var)
5892 {
5893 complete(&pHddCtx->full_pwr_comp_var);
5894 }
5895}
5896
5897/**---------------------------------------------------------------------------
5898
5899 \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function
5900
5901 This is the function invoked by SME to inform the result of BMPS
5902 request issued by HDD
5903
5904 \param - callbackcontext - Pointer to cookie
5905 status - result of request
5906
5907 \return - None
5908
5909--------------------------------------------------------------------------*/
5910void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status)
5911{
5912
5913 struct completion *completion_var = (struct completion*) callbackContext;
5914
Arif Hussain6d2a3322013-11-17 19:50:10 -08005915 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 if(completion_var != NULL)
5917 {
5918 complete(completion_var);
5919 }
5920}
5921
5922/**---------------------------------------------------------------------------
5923
5924 \brief hdd_get_cfg_file_size() -
5925
5926 This function reads the configuration file using the request firmware
5927 API and returns the configuration file size.
5928
5929 \param - pCtx - Pointer to the adapter .
5930 - pFileName - Pointer to the file name.
5931 - pBufSize - Pointer to the buffer size.
5932
5933 \return - 0 for success, non zero for failure
5934
5935 --------------------------------------------------------------------------*/
5936
5937VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize)
5938{
5939 int status;
5940 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5941
5942 ENTER();
5943
5944 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5945
5946 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5947 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5948 status = VOS_STATUS_E_FAILURE;
5949 }
5950 else {
5951 *pBufSize = pHddCtx->fw->size;
5952 hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize);
5953 release_firmware(pHddCtx->fw);
5954 pHddCtx->fw = NULL;
5955 }
5956
5957 EXIT();
5958 return VOS_STATUS_SUCCESS;
5959}
5960
5961/**---------------------------------------------------------------------------
5962
5963 \brief hdd_read_cfg_file() -
5964
5965 This function reads the configuration file using the request firmware
5966 API and returns the cfg data and the buffer size of the configuration file.
5967
5968 \param - pCtx - Pointer to the adapter .
5969 - pFileName - Pointer to the file name.
5970 - pBuffer - Pointer to the data buffer.
5971 - pBufSize - Pointer to the buffer size.
5972
5973 \return - 0 for success, non zero for failure
5974
5975 --------------------------------------------------------------------------*/
5976
5977VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName,
5978 v_VOID_t *pBuffer, v_SIZE_t *pBufSize)
5979{
5980 int status;
5981 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5982
5983 ENTER();
5984
5985 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5986
5987 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5988 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5989 return VOS_STATUS_E_FAILURE;
5990 }
5991 else {
5992 if(*pBufSize != pHddCtx->fw->size) {
5993 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG "
5994 "file size", __func__);
5995 release_firmware(pHddCtx->fw);
5996 pHddCtx->fw = NULL;
5997 return VOS_STATUS_E_FAILURE;
5998 }
5999 else {
6000 if(pBuffer) {
6001 vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize);
6002 }
6003 release_firmware(pHddCtx->fw);
6004 pHddCtx->fw = NULL;
6005 }
6006 }
6007
6008 EXIT();
6009
6010 return VOS_STATUS_SUCCESS;
6011}
6012
6013/**---------------------------------------------------------------------------
6014
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05306015 \brief __hdd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07006016
6017 This function sets the user specified mac address using
6018 the command ifconfig wlanX hw ether <mac adress>.
6019
6020 \param - dev - Pointer to the net device.
6021 - addr - Pointer to the sockaddr.
6022 \return - 0 for success, non zero for failure
6023
6024 --------------------------------------------------------------------------*/
6025
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05306026static int __hdd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -07006027{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306028 hdd_adapter_t *pAdapter;
6029 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 struct sockaddr *psta_mac_addr = addr;
6031 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306032 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033
6034 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306035 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6036 if (NULL == pAdapter)
6037 {
6038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6039 "%s: Adapter is NULL",__func__);
6040 return -EINVAL;
6041 }
6042 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6043 ret = wlan_hdd_validate_context(pHddCtx);
6044 if (0 != ret)
6045 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306046 return ret;
6047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006048
6049 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
6051
6052 EXIT();
6053 return halStatus;
6054}
6055
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05306056/**---------------------------------------------------------------------------
6057
6058 \brief hdd_set_mac_address() -
6059
6060 Wrapper function to protect __hdd_set_mac_address() function from ssr
6061
6062 \param - dev - Pointer to the net device.
6063 - addr - Pointer to the sockaddr.
6064 \return - 0 for success, non zero for failure
6065
6066 --------------------------------------------------------------------------*/
6067static int hdd_set_mac_address(struct net_device *dev, void *addr)
6068{
6069 int ret;
6070
6071 vos_ssr_protect(__func__);
6072 ret = __hdd_set_mac_address(dev, addr);
6073 vos_ssr_unprotect(__func__);
6074
6075 return ret;
6076}
6077
Jeff Johnson295189b2012-06-20 16:38:30 -07006078tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx)
6079{
6080 int i;
6081 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
6082 {
Abhishek Singheb183782014-02-06 13:37:21 +05306083 if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 break;
6085 }
6086
6087 if( VOS_MAX_CONCURRENCY_PERSONA == i)
6088 return NULL;
6089
6090 pHddCtx->cfg_ini->intfAddrMask |= (1 << i);
6091 return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0];
6092}
6093
6094void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr)
6095{
6096 int i;
6097 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
6098 {
6099 if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) )
6100 {
6101 pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i);
6102 break;
6103 }
6104 }
6105 return;
6106}
6107
6108#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6109 static struct net_device_ops wlan_drv_ops = {
6110 .ndo_open = hdd_open,
6111 .ndo_stop = hdd_stop,
6112 .ndo_uninit = hdd_uninit,
6113 .ndo_start_xmit = hdd_hard_start_xmit,
6114 .ndo_tx_timeout = hdd_tx_timeout,
6115 .ndo_get_stats = hdd_stats,
6116 .ndo_do_ioctl = hdd_ioctl,
6117 .ndo_set_mac_address = hdd_set_mac_address,
6118 .ndo_select_queue = hdd_select_queue,
6119#ifdef WLAN_FEATURE_PACKET_FILTERING
6120#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0))
6121 .ndo_set_rx_mode = hdd_set_multicast_list,
6122#else
6123 .ndo_set_multicast_list = hdd_set_multicast_list,
6124#endif //LINUX_VERSION_CODE
6125#endif
6126 };
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 static struct net_device_ops wlan_mon_drv_ops = {
6128 .ndo_open = hdd_mon_open,
Katya Nigame7b69a82015-04-28 15:24:06 +05306129 .ndo_stop = hdd_mon_stop,
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 .ndo_uninit = hdd_uninit,
6131 .ndo_start_xmit = hdd_mon_hard_start_xmit,
6132 .ndo_tx_timeout = hdd_tx_timeout,
6133 .ndo_get_stats = hdd_stats,
Katya Nigame7b69a82015-04-28 15:24:06 +05306134 .ndo_do_ioctl = hdd_mon_ioctl,
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 .ndo_set_mac_address = hdd_set_mac_address,
6136 };
Mahesh A Saptasagar305e2632015-03-04 12:57:33 +05306137
Jeff Johnson295189b2012-06-20 16:38:30 -07006138#endif
6139
6140void hdd_set_station_ops( struct net_device *pWlanDev )
6141{
6142#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 pWlanDev->netdev_ops = &wlan_drv_ops;
6144#else
6145 pWlanDev->open = hdd_open;
6146 pWlanDev->stop = hdd_stop;
6147 pWlanDev->uninit = hdd_uninit;
6148 pWlanDev->hard_start_xmit = NULL;
6149 pWlanDev->tx_timeout = hdd_tx_timeout;
6150 pWlanDev->get_stats = hdd_stats;
6151 pWlanDev->do_ioctl = hdd_ioctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 pWlanDev->set_mac_address = hdd_set_mac_address;
6153#endif
6154}
6155
Katya Nigam1fd24402015-02-16 14:52:19 +05306156void hdd_set_ibss_ops( hdd_adapter_t *pAdapter )
6157{
6158 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6159 wlan_drv_ops.ndo_start_xmit = hdd_ibss_hard_start_xmit;
6160 #else
6161 pAdapter->dev->hard_start_xmit = hdd_ibss_hard_start_xmit;
6162 #endif
6163}
6164
Jeff Johnsoneed415b2013-01-18 16:11:20 -08006165static hdd_adapter_t* hdd_alloc_station_adapter( hdd_context_t *pHddCtx, tSirMacAddr macAddr, const char* name )
Jeff Johnson295189b2012-06-20 16:38:30 -07006166{
6167 struct net_device *pWlanDev = NULL;
6168 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 /*
6170 * cfg80211 initialization and registration....
6171 */
6172 pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES);
6173
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 if(pWlanDev != NULL)
6175 {
6176
6177 //Save the pointer to the net_device in the HDD adapter
6178 pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev );
6179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) );
6181
6182 pAdapter->dev = pWlanDev;
6183 pAdapter->pHddCtx = pHddCtx;
6184 pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
Agarwal Ashish47d18112014-08-04 19:55:07 +05306185 spin_lock_init(&pAdapter->lock_for_active_session);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186
6187 init_completion(&pAdapter->session_open_comp_var);
6188 init_completion(&pAdapter->session_close_comp_var);
6189 init_completion(&pAdapter->disconnect_comp_var);
6190 init_completion(&pAdapter->linkup_event_var);
6191 init_completion(&pAdapter->cancel_rem_on_chan_var);
6192 init_completion(&pAdapter->rem_on_chan_ready_event);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05306193 init_completion(&pAdapter->pno_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07006194#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6195 init_completion(&pAdapter->offchannel_tx_event);
6196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 init_completion(&pAdapter->tx_action_cnf_event);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006198#ifdef FEATURE_WLAN_TDLS
6199 init_completion(&pAdapter->tdls_add_station_comp);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006200 init_completion(&pAdapter->tdls_del_station_comp);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006201 init_completion(&pAdapter->tdls_mgmt_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05306202 init_completion(&pAdapter->tdls_link_establish_req_comp);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006203#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 init_completion(&pHddCtx->mc_sus_event_var);
6205 init_completion(&pHddCtx->tx_sus_event_var);
Gopichand Nakkala05621412013-06-19 19:37:38 +05306206 init_completion(&pHddCtx->rx_sus_event_var);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07006207 init_completion(&pAdapter->ula_complete);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07006208 init_completion(&pAdapter->change_country_code);
Jeff Johnson295189b2012-06-20 16:38:30 -07006209
Rajeev79dbe4c2013-10-05 11:03:42 +05306210#ifdef FEATURE_WLAN_BATCH_SCAN
6211 init_completion(&pAdapter->hdd_set_batch_scan_req_var);
6212 init_completion(&pAdapter->hdd_get_batch_scan_req_var);
6213 pAdapter->pBatchScanRsp = NULL;
6214 pAdapter->numScanList = 0;
Rajeev Kumar20140c12013-10-21 19:39:02 -07006215 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08006216 pAdapter->prev_batch_id = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05306217 mutex_init(&pAdapter->hdd_batch_scan_lock);
6218#endif
6219
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 pAdapter->isLinkUpSvcNeeded = FALSE;
6221 pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE;
6222 //Init the net_device structure
6223 strlcpy(pWlanDev->name, name, IFNAMSIZ);
6224
6225 vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr));
6226 vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr));
6227 pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT;
6228 pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM;
6229
6230 hdd_set_station_ops( pAdapter->dev );
6231
6232 pWlanDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 pWlanDev->ieee80211_ptr = &pAdapter->wdev ;
6234 pAdapter->wdev.wiphy = pHddCtx->wiphy;
6235 pAdapter->wdev.netdev = pWlanDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 /* set pWlanDev's parent to underlying device */
6237 SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev);
Kumar Anand82c009f2014-05-29 00:29:42 -07006238
6239 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 }
6241
6242 return pAdapter;
6243}
6244
6245VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
6246{
6247 struct net_device *pWlanDev = pAdapter->dev;
6248 //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
6249 //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6250 //eHalStatus halStatus = eHAL_STATUS_SUCCESS;
6251
6252 if( rtnl_lock_held )
6253 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08006254 if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 )
6256 {
6257 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__);
6258 return VOS_STATUS_E_FAILURE;
6259 }
6260 }
6261 if (register_netdevice(pWlanDev))
6262 {
6263 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__);
6264 return VOS_STATUS_E_FAILURE;
6265 }
6266 }
6267 else
6268 {
6269 if(register_netdev(pWlanDev))
6270 {
6271 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__);
6272 return VOS_STATUS_E_FAILURE;
6273 }
6274 }
6275 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
6276
6277 return VOS_STATUS_SUCCESS;
6278}
6279
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006280static eHalStatus hdd_smeCloseSessionCallback(void *pContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07006281{
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006282 hdd_adapter_t *pAdapter = pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07006283
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006284 if (NULL == pAdapter)
6285 {
6286 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__);
6287 return eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 }
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006289
6290 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6291 {
6292 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__);
6293 return eHAL_STATUS_NOT_INITIALIZED;
6294 }
6295
6296 clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
6297
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006298#ifndef WLAN_OPEN_SOURCE
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006299 /* need to make sure all of our scheduled work has completed.
6300 * This callback is called from MC thread context, so it is safe to
6301 * to call below flush workqueue API from here.
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006302 *
6303 * Even though this is called from MC thread context, if there is a faulty
6304 * work item in the system, that can hang this call forever. So flushing
6305 * this global work queue is not safe; and now we make sure that
6306 * individual work queues are stopped correctly. But the cancel work queue
6307 * is a GPL only API, so the proprietary version of the driver would still
6308 * rely on the global work queue flush.
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006309 */
6310 flush_scheduled_work();
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006311#endif
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006312
6313 /* We can be blocked while waiting for scheduled work to be
6314 * flushed, and the adapter structure can potentially be freed, in
6315 * which case the magic will have been reset. So make sure the
6316 * magic is still good, and hence the adapter structure is still
6317 * valid, before signaling completion */
6318 if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic)
6319 {
6320 complete(&pAdapter->session_close_comp_var);
6321 }
6322
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 return eHAL_STATUS_SUCCESS;
6324}
6325
6326VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter )
6327{
6328 struct net_device *pWlanDev = pAdapter->dev;
6329 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
6330 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6331 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
6332 VOS_STATUS status = VOS_STATUS_E_FAILURE;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306333 long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006334
Nirav Shah7e3c8132015-06-22 23:51:42 +05306335 spin_lock_init( &pAdapter->sta_hash_lock);
6336 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
6337
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 INIT_COMPLETION(pAdapter->session_open_comp_var);
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07006339 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 //Open a SME session for future operation
6341 halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07006342 (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 if ( !HAL_STATUS_SUCCESS( halStatus ) )
6344 {
6345 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006346 "sme_OpenSession() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 halStatus, halStatus );
6348 status = VOS_STATUS_E_FAILURE;
6349 goto error_sme_open;
6350 }
6351
6352 //Block on a completion variable. Can't wait forever though.
Vinay Krishna Eranna0fe2e7c2014-04-09 21:32:08 +05306353 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 &pAdapter->session_open_comp_var,
6355 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306356 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 {
6358 hddLog(VOS_TRACE_LEVEL_FATAL,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306359 "Session is not opened within timeout period code %ld", rc );
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 status = VOS_STATUS_E_FAILURE;
6361 goto error_sme_open;
6362 }
6363
6364 // Register wireless extensions
6365 if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev)))
6366 {
6367 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006368 "hdd_register_wext() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 halStatus, halStatus );
6370 status = VOS_STATUS_E_FAILURE;
6371 goto error_register_wext;
6372 }
Katya Nigam1fd24402015-02-16 14:52:19 +05306373
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 //Safe to register the hard_start_xmit function again
Katya Nigam1fd24402015-02-16 14:52:19 +05306375 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6376 wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit;
6377 #else
6378 pWlanDev->hard_start_xmit = hdd_hard_start_xmit;
6379 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006380
6381 //Set the Connection State to Not Connected
Abhishek Singhf4669da2014-05-26 15:07:49 +05306382 hddLog(VOS_TRACE_LEVEL_INFO,
6383 "%s: Set HDD connState to eConnectionState_NotConnected",
6384 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6386
6387 //Set the default operation channel
6388 pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel;
6389
6390 /* Make the default Auth Type as OPEN*/
6391 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6392
6393 if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) )
6394 {
6395 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006396 "hdd_init_tx_rx() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 status, status );
6398 goto error_init_txrx;
6399 }
6400
6401 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6402
6403 if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) )
6404 {
6405 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006406 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 status, status );
6408 goto error_wmm_init;
6409 }
6410
6411 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6412
6413 return VOS_STATUS_SUCCESS;
6414
6415error_wmm_init:
6416 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6417 hdd_deinit_tx_rx(pAdapter);
6418error_init_txrx:
6419 hdd_UnregisterWext(pWlanDev);
6420error_register_wext:
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006421 if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 {
6423 INIT_COMPLETION(pAdapter->session_close_comp_var);
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006424 if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal,
mukul sharmabab477d2015-06-11 17:14:55 +05306425 pAdapter->sessionId, VOS_TRUE,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006426 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306428 unsigned long rc;
6429
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306431 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 &pAdapter->session_close_comp_var,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006433 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306434 if (rc <= 0)
6435 hddLog(VOS_TRACE_LEVEL_ERROR,
6436 FL("Session is not opened within timeout period code %ld"), rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 }
6438}
6439error_sme_open:
6440 return status;
6441}
6442
Jeff Johnson295189b2012-06-20 16:38:30 -07006443void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
6444{
6445 hdd_cfg80211_state_t *cfgState;
6446
6447 cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
6448
6449 if( NULL != cfgState->buf )
6450 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306451 long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 INIT_COMPLETION(pAdapter->tx_action_cnf_event);
6453 rc = wait_for_completion_interruptible_timeout(
6454 &pAdapter->tx_action_cnf_event,
6455 msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306456 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 {
Sudhir Sattayappa Kohalli8ee532d2013-02-15 13:16:26 -08006458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306459 "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld"
6460 , __func__, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 }
6462 }
6463 return;
6464}
Jeff Johnson295189b2012-06-20 16:38:30 -07006465
c_hpothu002231a2015-02-05 14:58:51 +05306466void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held )
Jeff Johnson295189b2012-06-20 16:38:30 -07006467{
6468 ENTER();
6469 switch ( pAdapter->device_mode )
6470 {
Katya Nigam1fd24402015-02-16 14:52:19 +05306471 case WLAN_HDD_IBSS:
6472 {
6473 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6474 {
6475 hdd_ibss_deinit_tx_rx( pAdapter );
6476 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6477 }
6478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 case WLAN_HDD_INFRA_STATION:
6480 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006481 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 {
6483 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6484 {
6485 hdd_deinit_tx_rx( pAdapter );
6486 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6487 }
6488
6489 if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6490 {
6491 hdd_wmm_adapter_close( pAdapter );
6492 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6493 }
6494
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 break;
6497 }
6498
6499 case WLAN_HDD_SOFTAP:
6500 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 {
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05306502
6503 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6504 {
6505 hdd_wmm_adapter_close( pAdapter );
6506 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6507 }
6508
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006510
c_hpothu002231a2015-02-05 14:58:51 +05306511 hdd_unregister_hostapd(pAdapter, rtnl_held);
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 hdd_set_conparam( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 break;
6514 }
6515
6516 case WLAN_HDD_MONITOR:
6517 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6519 {
6520 hdd_deinit_tx_rx( pAdapter );
6521 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 break;
6524 }
6525
6526
6527 default:
6528 break;
6529 }
6530
6531 EXIT();
6532}
6533
6534void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held )
6535{
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006536 struct net_device *pWlanDev = NULL;
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306537
6538 ENTER();
6539 if (NULL == pAdapter)
6540 {
6541 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6542 "%s: HDD adapter is Null", __func__);
6543 return;
6544 }
6545
6546 pWlanDev = pAdapter->dev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006547
Rajeev79dbe4c2013-10-05 11:03:42 +05306548#ifdef FEATURE_WLAN_BATCH_SCAN
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306549 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
6550 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Rajeev Kumarf999e582014-01-09 17:33:29 -08006551 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306552 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
6553 )
6554 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08006555 if (pAdapter)
Rajeev79dbe4c2013-10-05 11:03:42 +05306556 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08006557 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
6558 {
6559 hdd_deinit_batch_scan(pAdapter);
6560 }
Rajeev79dbe4c2013-10-05 11:03:42 +05306561 }
Rajeev Kumarf999e582014-01-09 17:33:29 -08006562 }
Rajeev79dbe4c2013-10-05 11:03:42 +05306563#endif
6564
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) {
6566 if( rtnl_held )
6567 {
6568 unregister_netdevice(pWlanDev);
6569 }
6570 else
6571 {
6572 unregister_netdev(pWlanDev);
6573 }
6574 // note that the pAdapter is no longer valid at this point
6575 // since the memory has been reclaimed
6576 }
6577
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306578 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006579}
6580
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006581void hdd_set_pwrparams(hdd_context_t *pHddCtx)
6582{
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306583 VOS_STATUS status;
6584 hdd_adapter_t *pAdapter = NULL;
6585 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006586
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306587 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006588
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306589 /*loop through all adapters.*/
6590 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006591 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306592 pAdapter = pAdapterNode->pAdapter;
6593 if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
6594 && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006595
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306596 { // we skip this registration for modes other than STA and P2P client modes.
6597 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6598 pAdapterNode = pNext;
6599 continue;
6600 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006601
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306602 //Apply Dynamic DTIM For P2P
6603 //Only if ignoreDynamicDtimInP2pMode is not set in ini
6604 if ((pHddCtx->cfg_ini->enableDynamicDTIM ||
6605 pHddCtx->cfg_ini->enableModulatedDTIM) &&
6606 ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6607 ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) &&
6608 !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) &&
6609 (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) &&
6610 (eConnectionState_Associated ==
6611 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) &&
6612 (pHddCtx->cfg_ini->fIsBmpsEnabled))
6613 {
6614 tSirSetPowerParamsReq powerRequest = { 0 };
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006615
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306616 powerRequest.uIgnoreDTIM = 1;
6617 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
6618
6619 if (pHddCtx->cfg_ini->enableModulatedDTIM)
6620 {
6621 powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM;
6622 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
6623 }
6624 else
6625 {
6626 powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM;
6627 }
6628
6629 /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM
6630 * specified during Enter/Exit BMPS when LCD off*/
6631 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
6632 NULL, eANI_BOOLEAN_FALSE);
6633 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
6634 NULL, eANI_BOOLEAN_FALSE);
6635
6636 /* switch to the DTIM specified in cfg.ini */
6637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6638 "Switch to DTIM %d", powerRequest.uListenInterval);
6639 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
6640 break;
6641
6642 }
6643
6644 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6645 pAdapterNode = pNext;
6646 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006647}
6648
6649void hdd_reset_pwrparams(hdd_context_t *pHddCtx)
6650{
6651 /*Switch back to DTIM 1*/
6652 tSirSetPowerParamsReq powerRequest = { 0 };
6653
6654 powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value;
6655 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
Yue Mac24062f2013-05-13 17:01:29 -07006656 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006657
6658 /* Update ignoreDTIM and ListedInterval in CFG with default values */
6659 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
6660 NULL, eANI_BOOLEAN_FALSE);
6661 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
6662 NULL, eANI_BOOLEAN_FALSE);
6663
6664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6665 "Switch to DTIM%d",powerRequest.uListenInterval);
6666 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
6667
6668}
6669
Jeff Johnson295189b2012-06-20 16:38:30 -07006670VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx)
6671{
6672 VOS_STATUS status = VOS_STATUS_SUCCESS;
Sushant Kaushik4928e542014-12-29 15:25:54 +05306673 if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx))
6674 {
6675 hddLog( LOGE, FL("Wlan Unload in progress"));
6676 return VOS_STATUS_E_PERM;
6677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
6679 {
6680 sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
6681 }
6682
6683 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
6684 {
6685 sme_StartAutoBmpsTimer(pHddCtx->hHal);
6686 }
6687
6688 if (pHddCtx->cfg_ini->fIsImpsEnabled)
6689 {
6690 sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
6691 }
6692
6693 return status;
6694}
6695
6696VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type)
6697{
6698 hdd_adapter_t *pAdapter = NULL;
6699 eHalStatus halStatus;
6700 VOS_STATUS status = VOS_STATUS_E_INVAL;
6701 v_BOOL_t disableBmps = FALSE;
6702 v_BOOL_t disableImps = FALSE;
6703
6704 switch(session_type)
6705 {
6706 case WLAN_HDD_INFRA_STATION:
6707 case WLAN_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 case WLAN_HDD_P2P_CLIENT:
6709 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 //Exit BMPS -> Is Sta/P2P Client is already connected
6711 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6712 if((NULL != pAdapter)&&
6713 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6714 {
6715 disableBmps = TRUE;
6716 }
6717
6718 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6719 if((NULL != pAdapter)&&
6720 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6721 {
6722 disableBmps = TRUE;
6723 }
6724
6725 //Exit both Bmps and Imps incase of Go/SAP Mode
6726 if((WLAN_HDD_SOFTAP == session_type) ||
6727 (WLAN_HDD_P2P_GO == session_type))
6728 {
6729 disableBmps = TRUE;
6730 disableImps = TRUE;
6731 }
6732
6733 if(TRUE == disableImps)
6734 {
6735 if (pHddCtx->cfg_ini->fIsImpsEnabled)
6736 {
6737 sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
6738 }
6739 }
6740
6741 if(TRUE == disableBmps)
6742 {
6743 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
6744 {
6745 halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
6746
6747 if(eHAL_STATUS_SUCCESS != halStatus)
6748 {
6749 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006750 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 VOS_ASSERT(0);
6752 return status;
6753 }
6754 }
6755
6756 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
6757 {
6758 halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal);
6759
6760 if(eHAL_STATUS_SUCCESS != halStatus)
6761 {
6762 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006763 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Stop Auto Bmps Timer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 VOS_ASSERT(0);
6765 return status;
6766 }
6767 }
6768 }
6769
6770 if((TRUE == disableBmps) ||
6771 (TRUE == disableImps))
6772 {
6773 /* Now, get the chip into Full Power now */
6774 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
6775 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk,
6776 pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD);
6777
6778 if(halStatus != eHAL_STATUS_SUCCESS)
6779 {
6780 if(halStatus == eHAL_STATUS_PMC_PENDING)
6781 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306782 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 //Block on a completion variable. Can't wait forever though
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306784 ret = wait_for_completion_interruptible_timeout(
6785 &pHddCtx->full_pwr_comp_var,
6786 msecs_to_jiffies(1000));
6787 if (ret <= 0)
6788 {
6789 hddLog(VOS_TRACE_LEVEL_ERROR,
6790 "%s: wait on full_pwr_comp_var failed %ld",
6791 __func__, ret);
6792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 }
6794 else
6795 {
6796 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006797 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 VOS_ASSERT(0);
6799 return status;
6800 }
6801 }
6802
6803 status = VOS_STATUS_SUCCESS;
6804 }
6805
6806 break;
6807 }
6808 return status;
6809}
Katya Nigame7b69a82015-04-28 15:24:06 +05306810void hdd_init_mon_mode (hdd_adapter_t *pAdapter)
6811 {
6812 hdd_mon_ctx_t *pMonCtx = NULL;
6813 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6814
6815 pMonCtx->state = 0;
6816 pMonCtx->ChannelNo = 1;
6817 pMonCtx->ChannelBW = 20;
Katya Nigamd7d3a1f2015-06-11 14:04:24 +05306818 pMonCtx->crcCheckEnabled = 1;
6819 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
6820 pMonCtx->is80211to803ConReq = 1;
Katya Nigame7b69a82015-04-28 15:24:06 +05306821 pMonCtx->numOfMacFilters = 0;
6822 }
6823
Jeff Johnson295189b2012-06-20 16:38:30 -07006824
6825hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type,
Jeff Johnsoneed415b2013-01-18 16:11:20 -08006826 const char *iface_name, tSirMacAddr macAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 tANI_U8 rtnl_held )
6828{
6829 hdd_adapter_t *pAdapter = NULL;
6830 hdd_adapter_list_node_t *pHddAdapterNode = NULL;
6831 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6832 VOS_STATUS exitbmpsStatus;
6833
Arif Hussain6d2a3322013-11-17 19:50:10 -08006834 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s iface =%s type = %d",__func__,iface_name,session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006835
Nirav Shah436658f2014-02-28 17:05:45 +05306836 if(macAddr == NULL)
6837 {
6838 /* Not received valid macAddr */
6839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6840 "%s:Unable to add virtual intf: Not able to get"
6841 "valid mac address",__func__);
6842 return NULL;
6843 }
6844
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 //Disable BMPS incase of Concurrency
6846 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type);
6847
6848 if(VOS_STATUS_E_FAILURE == exitbmpsStatus)
6849 {
6850 //Fail to Exit BMPS
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306851 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 VOS_ASSERT(0);
6853 return NULL;
6854 }
6855
6856 switch(session_type)
6857 {
6858 case WLAN_HDD_INFRA_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006860 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 {
6862 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6863
6864 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306865 {
6866 hddLog(VOS_TRACE_LEVEL_FATAL,
6867 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006870
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306871#ifdef FEATURE_WLAN_TDLS
6872 /* A Mutex Lock is introduced while changing/initializing the mode to
6873 * protect the concurrent access for the Adapters by TDLS module.
6874 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306875 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306876#endif
6877
Jeff Johnsone7245742012-09-05 17:12:55 -07006878 pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ?
6879 NL80211_IFTYPE_P2P_CLIENT:
6880 NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07006881
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 pAdapter->device_mode = session_type;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306883#ifdef FEATURE_WLAN_TDLS
6884 mutex_unlock(&pHddCtx->tdls_lock);
6885#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05306886
6887 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 if( VOS_STATUS_SUCCESS != status )
6889 goto err_free_netdev;
6890
6891 status = hdd_register_interface( pAdapter, rtnl_held );
6892 if( VOS_STATUS_SUCCESS != status )
6893 {
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05306894#ifdef FEATURE_WLAN_TDLS
6895 mutex_lock(&pHddCtx->tdls_lock);
6896#endif
c_hpothu002231a2015-02-05 14:58:51 +05306897 hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05306898#ifdef FEATURE_WLAN_TDLS
6899 mutex_unlock(&pHddCtx->tdls_lock);
6900#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 goto err_free_netdev;
6902 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306903
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306904 // Workqueue which gets scheduled in IPv4 notification callback.
Anand N Sunkaddc63c792015-06-03 14:33:24 +05306905 vos_init_work(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue);
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306906
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306907#ifdef WLAN_NS_OFFLOAD
6908 // Workqueue which gets scheduled in IPv6 notification callback.
Anand N Sunkaddc63c792015-06-03 14:33:24 +05306909 vos_init_work(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue);
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 //Stop the Interface TX queue.
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05306912 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 netif_tx_disable(pAdapter->dev);
6914 //netif_tx_disable(pWlanDev);
6915 netif_carrier_off(pAdapter->dev);
6916
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05306917 if (WLAN_HDD_P2P_CLIENT == session_type ||
6918 WLAN_HDD_P2P_DEVICE == session_type)
6919 {
6920 /* Initialize the work queue to defer the
6921 * back to back RoC request */
Anand N Sunkaddc63c792015-06-03 14:33:24 +05306922 vos_init_delayed_work(&pAdapter->roc_work,
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05306923 hdd_p2p_roc_work_queue);
6924 }
6925
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 break;
6927 }
6928
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 case WLAN_HDD_SOFTAP:
6931 {
6932 pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name );
6933 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306934 {
6935 hddLog(VOS_TRACE_LEVEL_FATAL,
6936 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006939
Jeff Johnson295189b2012-06-20 16:38:30 -07006940 pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ?
6941 NL80211_IFTYPE_AP:
6942 NL80211_IFTYPE_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 pAdapter->device_mode = session_type;
6944
6945 status = hdd_init_ap_mode(pAdapter);
6946 if( VOS_STATUS_SUCCESS != status )
6947 goto err_free_netdev;
6948
Nirav Shah7e3c8132015-06-22 23:51:42 +05306949 status = hdd_sta_id_hash_attach(pAdapter);
6950 if (VOS_STATUS_SUCCESS != status)
6951 {
6952 hddLog(VOS_TRACE_LEVEL_FATAL,
6953 FL("failed to attach hash for session %d"), session_type);
6954 hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held);
6955 goto err_free_netdev;
6956 }
6957
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 status = hdd_register_hostapd( pAdapter, rtnl_held );
6959 if( VOS_STATUS_SUCCESS != status )
6960 {
c_hpothu002231a2015-02-05 14:58:51 +05306961 hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held);
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 goto err_free_netdev;
6963 }
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05306964 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 netif_tx_disable(pAdapter->dev);
6966 netif_carrier_off(pAdapter->dev);
6967
6968 hdd_set_conparam( 1 );
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05306969
6970 if (WLAN_HDD_P2P_GO == session_type)
6971 {
6972 /* Initialize the work queue to
6973 * defer the back to back RoC request */
6974 INIT_DELAYED_WORK(&pAdapter->roc_work,
6975 hdd_p2p_roc_work_queue);
6976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 break;
6978 }
6979 case WLAN_HDD_MONITOR:
6980 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6982 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306983 {
6984 hddLog(VOS_TRACE_LEVEL_FATAL,
6985 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006988
Katya Nigame7b69a82015-04-28 15:24:06 +05306989 // Register wireless extensions
6990 if( VOS_STATUS_SUCCESS != (status = hdd_register_wext(pAdapter->dev)))
6991 {
6992 hddLog(VOS_TRACE_LEVEL_FATAL,
6993 "hdd_register_wext() failed with status code %08d [x%08x]",
6994 status, status );
6995 status = VOS_STATUS_E_FAILURE;
6996 }
6997
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR;
6999 pAdapter->device_mode = session_type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007000#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
7001 pAdapter->dev->netdev_ops = &wlan_mon_drv_ops;
7002#else
7003 pAdapter->dev->open = hdd_mon_open;
7004 pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit;
Katya Nigame7b69a82015-04-28 15:24:06 +05307005 pAdapter->dev->stop = hdd_mon_stop;
7006 pAdapter->dev->do_ioctl = hdd_mon_ioctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07007007#endif
Katya Nigame7b69a82015-04-28 15:24:06 +05307008 status = hdd_register_interface( pAdapter, rtnl_held );
7009 hdd_init_mon_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 hdd_init_tx_rx( pAdapter );
7011 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
Katya Nigame7b69a82015-04-28 15:24:06 +05307012 //Stop the Interface TX queue.
7013 netif_tx_disable(pAdapter->dev);
7014 netif_carrier_off(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 }
7016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 case WLAN_HDD_FTM:
7018 {
7019 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
7020
7021 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307022 {
7023 hddLog(VOS_TRACE_LEVEL_FATAL,
7024 FL("failed to allocate adapter for session %d"), session_type);
7025 return NULL;
7026 }
7027
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning
7029 * message while loading driver in FTM mode. */
7030 pAdapter->wdev.iftype = NL80211_IFTYPE_STATION;
7031 pAdapter->device_mode = session_type;
7032 status = hdd_register_interface( pAdapter, rtnl_held );
Madan Mohan Koyyalamudif89ac9f2013-09-19 16:58:12 +05307033
7034 hdd_init_tx_rx( pAdapter );
7035
7036 //Stop the Interface TX queue.
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05307037 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Madan Mohan Koyyalamudif89ac9f2013-09-19 16:58:12 +05307038 netif_tx_disable(pAdapter->dev);
7039 netif_carrier_off(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 }
7041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 default:
7043 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307044 hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d",
7045 __func__, session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 VOS_ASSERT(0);
7047 return NULL;
7048 }
7049 }
7050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 if( VOS_STATUS_SUCCESS == status )
7052 {
7053 //Add it to the hdd's session list.
7054 pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) );
7055 if( NULL == pHddAdapterNode )
7056 {
7057 status = VOS_STATUS_E_NOMEM;
7058 }
7059 else
7060 {
7061 pHddAdapterNode->pAdapter = pAdapter;
7062 status = hdd_add_adapter_back ( pHddCtx,
7063 pHddAdapterNode );
7064 }
7065 }
7066
7067 if( VOS_STATUS_SUCCESS != status )
7068 {
7069 if( NULL != pAdapter )
7070 {
7071 hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held );
7072 pAdapter = NULL;
7073 }
7074 if( NULL != pHddAdapterNode )
7075 {
7076 vos_mem_free( pHddAdapterNode );
7077 }
7078
7079 goto resume_bmps;
7080 }
7081
7082 if(VOS_STATUS_SUCCESS == status)
7083 {
7084 wlan_hdd_set_concurrency_mode(pHddCtx, session_type);
7085
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007086 //Initialize the WoWL service
7087 if(!hdd_init_wowl(pAdapter))
7088 {
7089 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__);
7090 goto err_free_netdev;
7091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 return pAdapter;
7094
7095err_free_netdev:
7096 free_netdev(pAdapter->dev);
7097 wlan_hdd_release_intf_addr( pHddCtx,
7098 pAdapter->macAddressCurrent.bytes );
7099
7100resume_bmps:
7101 //If bmps disabled enable it
7102 if(VOS_STATUS_SUCCESS == exitbmpsStatus)
7103 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307104 if (pHddCtx->hdd_wlan_suspended)
7105 {
7106 hdd_set_pwrparams(pHddCtx);
7107 }
7108 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 }
7110 return NULL;
7111}
7112
7113VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
7114 tANI_U8 rtnl_held )
7115{
7116 hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext;
7117 VOS_STATUS status;
7118
7119 status = hdd_get_front_adapter ( pHddCtx, &pCurrent );
7120 if( VOS_STATUS_SUCCESS != status )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307121 {
7122 hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d",
7123 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007126
7127 while ( pCurrent->pAdapter != pAdapter )
7128 {
7129 status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext );
7130 if( VOS_STATUS_SUCCESS != status )
7131 break;
7132
7133 pCurrent = pNext;
7134 }
7135 pAdapterNode = pCurrent;
7136 if( VOS_STATUS_SUCCESS == status )
7137 {
7138 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
7139 hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307140
7141#ifdef FEATURE_WLAN_TDLS
7142
7143 /* A Mutex Lock is introduced while changing/initializing the mode to
7144 * protect the concurrent access for the Adapters by TDLS module.
7145 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307146 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307147#endif
7148
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 hdd_remove_adapter( pHddCtx, pAdapterNode );
7150 vos_mem_free( pAdapterNode );
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08007151 pAdapterNode = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007152
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307153#ifdef FEATURE_WLAN_TDLS
7154 mutex_unlock(&pHddCtx->tdls_lock);
7155#endif
7156
Jeff Johnson295189b2012-06-20 16:38:30 -07007157
7158 /* If there is a single session of STA/P2P client, re-enable BMPS */
Agarwal Ashish51325b52014-06-16 16:50:49 +05307159 if ((!vos_concurrent_open_sessions_running()) &&
7160 ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) ||
7161 (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307163 if (pHddCtx->hdd_wlan_suspended)
7164 {
7165 hdd_set_pwrparams(pHddCtx);
7166 }
7167 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 }
7169
7170 return VOS_STATUS_SUCCESS;
7171 }
7172
7173 return VOS_STATUS_E_FAILURE;
7174}
7175
7176VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx )
7177{
7178 hdd_adapter_list_node_t *pHddAdapterNode;
7179 VOS_STATUS status;
7180
7181 ENTER();
7182
7183 do
7184 {
7185 status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode );
7186 if( pHddAdapterNode && VOS_STATUS_SUCCESS == status )
7187 {
7188 hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE );
7189 vos_mem_free( pHddAdapterNode );
7190 }
7191 }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status );
7192
7193 EXIT();
7194
7195 return VOS_STATUS_SUCCESS;
7196}
7197
7198void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter)
7199{
7200 v_U8_t addIE[1] = {0};
7201
7202 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7203 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL,
7204 eANI_BOOLEAN_FALSE) )
7205 {
7206 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007207 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 }
7209
7210 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7211 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
7212 eANI_BOOLEAN_FALSE) )
7213 {
7214 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007215 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 }
7217
7218 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7219 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
7220 eANI_BOOLEAN_FALSE) )
7221 {
7222 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007223 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 }
7225}
7226
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307227VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
7228 const v_BOOL_t bCloseSession )
Jeff Johnson295189b2012-06-20 16:38:30 -07007229{
7230 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7231 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307232 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 union iwreq_data wrqu;
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307234 v_U8_t retry = 0;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307235 long ret;
Nirav Shah7e3c8132015-06-22 23:51:42 +05307236 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007237
Anand N Sunkad26d71b92014-12-24 18:08:22 +05307238 if (pHddCtx->isLogpInProgress) {
7239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7240 "%s:LOGP in Progress. Ignore!!!",__func__);
7241 return VOS_STATUS_E_FAILURE;
7242 }
7243
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 ENTER();
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307245
Bhargav Shah784e6a52015-07-22 16:52:35 +05307246 if ( VOS_TRUE == bCloseSession )
7247 {
7248 status = hdd_sta_id_hash_detach(pAdapter);
7249 if (status != VOS_STATUS_SUCCESS)
7250 hddLog(VOS_TRACE_LEVEL_ERROR,
7251 FL("sta id hash detach failed"));
7252 }
Nirav Shah7e3c8132015-06-22 23:51:42 +05307253
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307254 pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 switch(pAdapter->device_mode)
7256 {
7257 case WLAN_HDD_INFRA_STATION:
7258 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007259 case WLAN_HDD_P2P_DEVICE:
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307260 {
7261 hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagare4d05d42015-07-02 16:17:20 +05307262#ifdef FEATURE_WLAN_TDLS
7263 mutex_lock(&pHddCtx->tdls_lock);
7264 wlan_hdd_tdls_exit(pAdapter, TRUE);
7265 mutex_unlock(&pHddCtx->tdls_lock);
7266#endif
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307267 if( hdd_connIsConnected(pstation) ||
7268 (pstation->conn_info.connState == eConnectionState_Connecting) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 {
7270 if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS)
7271 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
7272 pAdapter->sessionId,
7273 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7274 else
7275 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
7276 pAdapter->sessionId,
7277 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7278 //success implies disconnect command got queued up successfully
7279 if(halStatus == eHAL_STATUS_SUCCESS)
7280 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307281 ret = wait_for_completion_interruptible_timeout(
7282 &pAdapter->disconnect_comp_var,
7283 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7284 if (ret <= 0)
7285 {
7286 hddLog(VOS_TRACE_LEVEL_ERROR,
7287 "%s: wait on disconnect_comp_var failed %ld",
7288 __func__, ret);
7289 }
7290 }
7291 else
7292 {
7293 hddLog(LOGE, "%s: failed to post disconnect event to SME",
7294 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 }
7296 memset(&wrqu, '\0', sizeof(wrqu));
7297 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7298 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7299 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
7300 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307301 else if(pstation->conn_info.connState ==
7302 eConnectionState_Disconnecting)
7303 {
7304 ret = wait_for_completion_interruptible_timeout(
7305 &pAdapter->disconnect_comp_var,
7306 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7307 if (ret <= 0)
7308 {
7309 hddLog(VOS_TRACE_LEVEL_ERROR,
7310 FL("wait on disconnect_comp_var failed %ld"), ret);
7311 }
7312 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307313 else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending)
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307315 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307316 eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307318 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
7319 {
7320 while (pAdapter->is_roc_inprogress)
7321 {
7322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7323 "%s: ROC in progress for session %d!!!",
7324 __func__, pAdapter->sessionId);
7325 // waiting for ROC to expire
7326 msleep(500);
7327 /* In GO present case , if retry exceeds 3,
7328 it means something went wrong. */
7329 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION )
7330 {
7331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7332 "%s: ROC completion is not received.!!!", __func__);
Deepthi Gowri70498252015-01-20 15:56:45 +05307333 if (eHAL_STATUS_SUCCESS !=
7334 sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter),
7335 pAdapter->sessionId ))
7336 {
7337 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7338 FL("Failed to Cancel Remain on Channel"));
7339 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307340 wait_for_completion_interruptible_timeout(
7341 &pAdapter->cancel_rem_on_chan_var,
7342 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
7343 break;
7344 }
7345 }
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307346 vos_flush_delayed_work(&pAdapter->roc_work);
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307347 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05307348#ifdef WLAN_NS_OFFLOAD
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307349 vos_flush_work(&pAdapter->ipv6NotifierWorkQueue);
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05307350#endif
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307351
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307352 vos_flush_work(&pAdapter->ipv4NotifierWorkQueue);
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307353
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307354 /* It is possible that the caller of this function does not
7355 * wish to close the session
7356 */
7357 if (VOS_TRUE == bCloseSession &&
7358 test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 {
7360 INIT_COMPLETION(pAdapter->session_close_comp_var);
7361 if (eHAL_STATUS_SUCCESS ==
mukul sharmabab477d2015-06-11 17:14:55 +05307362 sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, VOS_FALSE,
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307363 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307365 unsigned long ret;
7366
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307368 ret = wait_for_completion_timeout(
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307369 &pAdapter->session_close_comp_var,
7370 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307371 if ( 0 >= ret)
7372 {
7373 hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld",
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307374 __func__, ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 }
7377 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 break;
7380
7381 case WLAN_HDD_SOFTAP:
7382 case WLAN_HDD_P2P_GO:
7383 //Any softap specific cleanup here...
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307384 if (pAdapter->device_mode == WLAN_HDD_P2P_GO) {
7385 while (pAdapter->is_roc_inprogress) {
7386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7387 "%s: ROC in progress for session %d!!!",
7388 __func__, pAdapter->sessionId);
7389 msleep(500);
7390 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) {
7391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7392 "%s: ROC completion is not received.!!!", __func__);
7393 WLANSAP_CancelRemainOnChannel(
7394 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
7395 wait_for_completion_interruptible_timeout(
7396 &pAdapter->cancel_rem_on_chan_var,
7397 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
7398 break;
7399 }
7400 }
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05307401
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307402 vos_flush_delayed_work(&pAdapter->roc_work);
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 mutex_lock(&pHddCtx->sap_lock);
7405 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7406 {
7407 VOS_STATUS status;
7408 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7409
7410 //Stop Bss.
7411 status = WLANSAP_StopBss(pHddCtx->pvosContext);
7412 if (VOS_IS_STATUS_SUCCESS(status))
7413 {
7414 hdd_hostapd_state_t *pHostapdState =
7415 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7416
7417 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7418
7419 if (!VOS_IS_STATUS_SUCCESS(status))
7420 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307421 hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d",
7422 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 }
7424 }
7425 else
7426 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007427 hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 }
7429 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307430 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007431
7432 if (eHAL_STATUS_FAILURE ==
7433 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG,
7434 0, NULL, eANI_BOOLEAN_FALSE))
7435 {
7436 hddLog(LOGE,
7437 "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007438 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 }
7440
7441 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7442 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7443 eANI_BOOLEAN_FALSE) )
7444 {
7445 hddLog(LOGE,
7446 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
7447 }
7448
7449 // Reset WNI_CFG_PROBE_RSP Flags
7450 wlan_hdd_reset_prob_rspies(pAdapter);
7451 kfree(pAdapter->sessionCtx.ap.beacon);
7452 pAdapter->sessionCtx.ap.beacon = NULL;
7453 }
7454 mutex_unlock(&pHddCtx->sap_lock);
7455 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007456
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 case WLAN_HDD_MONITOR:
7458 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007459
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 default:
7461 break;
7462 }
7463
7464 EXIT();
7465 return VOS_STATUS_SUCCESS;
7466}
7467
7468VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx )
7469{
7470 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7471 VOS_STATUS status;
7472 hdd_adapter_t *pAdapter;
7473
7474 ENTER();
7475
7476 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7477
7478 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7479 {
7480 pAdapter = pAdapterNode->pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07007481
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307482 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007483
7484 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7485 pAdapterNode = pNext;
7486 }
7487
7488 EXIT();
7489
7490 return VOS_STATUS_SUCCESS;
7491}
7492
Rajeev Kumarf999e582014-01-09 17:33:29 -08007493
7494#ifdef FEATURE_WLAN_BATCH_SCAN
7495/**---------------------------------------------------------------------------
7496
7497 \brief hdd_deinit_batch_scan () - This function cleans up batch scan data
7498 structures
7499
7500 \param - pAdapter Pointer to HDD adapter
7501
7502 \return - None
7503
7504 --------------------------------------------------------------------------*/
7505void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter)
7506{
7507 tHddBatchScanRsp *pNode;
7508 tHddBatchScanRsp *pPrev;
7509
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307510 if (NULL == pAdapter)
Rajeev Kumarf999e582014-01-09 17:33:29 -08007511 {
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307512 hddLog(VOS_TRACE_LEVEL_ERROR,
7513 "%s: Adapter context is Null", __func__);
7514 return;
7515 }
7516
7517 pNode = pAdapter->pBatchScanRsp;
7518 while (pNode)
7519 {
7520 pPrev = pNode;
7521 pNode = pNode->pNext;
7522 vos_mem_free((v_VOID_t * )pPrev);
Rajeev Kumarf999e582014-01-09 17:33:29 -08007523 }
7524
7525 pAdapter->pBatchScanRsp = NULL;
7526 pAdapter->numScanList = 0;
7527 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
7528 pAdapter->prev_batch_id = 0;
7529
7530 return;
7531}
7532#endif
7533
7534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx )
7536{
7537 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7538 VOS_STATUS status;
7539 hdd_adapter_t *pAdapter;
7540
7541 ENTER();
7542
7543 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7544
7545 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7546 {
7547 pAdapter = pAdapterNode->pAdapter;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05307548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 netif_tx_disable(pAdapter->dev);
7550 netif_carrier_off(pAdapter->dev);
7551
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007552 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
7553
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 hdd_deinit_tx_rx(pAdapter);
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307555
Katya Nigam1fd24402015-02-16 14:52:19 +05307556 if(pAdapter->device_mode == WLAN_HDD_IBSS )
7557 hdd_ibss_deinit_tx_rx(pAdapter);
7558
Nirav Shah7e3c8132015-06-22 23:51:42 +05307559 status = hdd_sta_id_hash_detach(pAdapter);
7560 if (status != VOS_STATUS_SUCCESS)
7561 hddLog(VOS_TRACE_LEVEL_ERROR,
7562 FL("sta id hash detach failed for session id %d"),
7563 pAdapter->sessionId);
7564
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307565 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
7566
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05307567 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
7568 {
7569 hdd_wmm_adapter_close( pAdapter );
7570 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
7571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007572
Siddharth Bhal2db319d2014-12-03 12:37:18 +05307573 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7574 {
7575 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
7576 }
7577
Rajeev Kumarf999e582014-01-09 17:33:29 -08007578#ifdef FEATURE_WLAN_BATCH_SCAN
7579 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
7580 {
7581 hdd_deinit_batch_scan(pAdapter);
7582 }
7583#endif
7584
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05307585#ifdef FEATURE_WLAN_TDLS
7586 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETI2d4d5c42015-03-03 14:34:19 +05307587 wlan_hdd_tdls_exit(pAdapter, TRUE);
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05307588 mutex_unlock(&pHddCtx->tdls_lock);
7589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7591 pAdapterNode = pNext;
7592 }
7593
7594 EXIT();
7595
7596 return VOS_STATUS_SUCCESS;
7597}
7598
7599VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx )
7600{
7601 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7602 VOS_STATUS status;
7603 hdd_adapter_t *pAdapter;
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307604 eConnectionState connState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007605
7606 ENTER();
7607
7608 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7609
7610 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7611 {
7612 pAdapter = pAdapterNode->pAdapter;
7613
Kumar Anand82c009f2014-05-29 00:29:42 -07007614 hdd_wmm_init( pAdapter );
7615
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 switch(pAdapter->device_mode)
7617 {
7618 case WLAN_HDD_INFRA_STATION:
7619 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007620 case WLAN_HDD_P2P_DEVICE:
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307621
7622 connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState;
7623
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 hdd_init_station_mode(pAdapter);
7625 /* Open the gates for HDD to receive Wext commands */
7626 pAdapter->isLinkUpSvcNeeded = FALSE;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007627 pHddCtx->scan_info.mScanPending = FALSE;
7628 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007629
7630 //Trigger the initial scan
7631 hdd_wlan_initial_scan(pAdapter);
7632
7633 //Indicate disconnect event to supplicant if associated previously
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307634 if (eConnectionState_Associated == connState ||
7635 eConnectionState_IbssConnected == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 {
7637 union iwreq_data wrqu;
7638 memset(&wrqu, '\0', sizeof(wrqu));
7639 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7640 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7641 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007642 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007643
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 /* indicate disconnected event to nl80211 */
7645 cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED,
7646 NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 }
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307648 else if (eConnectionState_Connecting == connState)
7649 {
7650 /*
7651 * Indicate connect failure to supplicant if we were in the
7652 * process of connecting
7653 */
7654 cfg80211_connect_result(pAdapter->dev, NULL,
7655 NULL, 0, NULL, 0,
7656 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
7657 GFP_KERNEL);
7658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 break;
7660
7661 case WLAN_HDD_SOFTAP:
7662 /* softAP can handle SSR */
7663 break;
7664
7665 case WLAN_HDD_P2P_GO:
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007666 hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant",
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 __func__);
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007668 cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 break;
7670
7671 case WLAN_HDD_MONITOR:
7672 /* monitor interface start */
7673 break;
7674 default:
7675 break;
7676 }
7677
7678 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7679 pAdapterNode = pNext;
7680 }
7681
7682 EXIT();
7683
7684 return VOS_STATUS_SUCCESS;
7685}
7686
7687VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx )
7688{
7689 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7690 hdd_adapter_t *pAdapter;
7691 VOS_STATUS status;
7692 v_U32_t roamId;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307693 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007694
7695 ENTER();
7696
7697 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7698
7699 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7700 {
7701 pAdapter = pAdapterNode->pAdapter;
7702
7703 if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
7704 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
7705 {
7706 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7707 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7708
Abhishek Singhf4669da2014-05-26 15:07:49 +05307709 hddLog(VOS_TRACE_LEVEL_INFO,
7710 "%s: Set HDD connState to eConnectionState_NotConnected",
7711 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7713 init_completion(&pAdapter->disconnect_comp_var);
7714 sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId,
7715 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7716
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307717 ret = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 &pAdapter->disconnect_comp_var,
7719 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307720 if (0 >= ret)
7721 hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld",
7722 __func__, ret);
Jeff Johnson295189b2012-06-20 16:38:30 -07007723
7724 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
7725 pHddCtx->isAmpAllowed = VOS_FALSE;
7726 sme_RoamConnect(pHddCtx->hHal,
7727 pAdapter->sessionId, &(pWextState->roamProfile),
7728 &roamId);
7729 }
7730
7731 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7732 pAdapterNode = pNext;
7733 }
7734
7735 EXIT();
7736
7737 return VOS_STATUS_SUCCESS;
7738}
7739
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07007740void hdd_dump_concurrency_info(hdd_context_t *pHddCtx)
7741{
7742 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7743 VOS_STATUS status;
7744 hdd_adapter_t *pAdapter;
7745 hdd_station_ctx_t *pHddStaCtx;
7746 hdd_ap_ctx_t *pHddApCtx;
7747 hdd_hostapd_state_t * pHostapdState;
7748 tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 };
7749 v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0;
7750 const char *p2pMode = "DEV";
7751 const char *ccMode = "Standalone";
7752 int n;
7753
7754 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7755 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7756 {
7757 pAdapter = pAdapterNode->pAdapter;
7758 switch (pAdapter->device_mode) {
7759 case WLAN_HDD_INFRA_STATION:
7760 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7761 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7762 staChannel = pHddStaCtx->conn_info.operationChannel;
7763 memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid));
7764 }
7765 break;
7766 case WLAN_HDD_P2P_CLIENT:
7767 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7768 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7769 p2pChannel = pHddStaCtx->conn_info.operationChannel;
7770 memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid));
7771 p2pMode = "CLI";
7772 }
7773 break;
7774 case WLAN_HDD_P2P_GO:
7775 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7776 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7777 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7778 p2pChannel = pHddApCtx->operatingChannel;
7779 memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid));
7780 }
7781 p2pMode = "GO";
7782 break;
7783 case WLAN_HDD_SOFTAP:
7784 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7785 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7786 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7787 apChannel = pHddApCtx->operatingChannel;
7788 memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid));
7789 }
7790 break;
7791 default:
7792 break;
7793 }
7794 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7795 pAdapterNode = pNext;
7796 }
7797 if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) {
7798 ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC";
7799 }
7800 n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s",
7801 staChannel, MAC_ADDR_ARRAY(staBssid), ccMode);
7802 if (p2pChannel > 0) {
7803 n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR,
7804 p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid));
7805 }
7806 if (apChannel > 0) {
7807 n += pr_info("AP(%d) " MAC_ADDRESS_STR,
7808 apChannel, MAC_ADDR_ARRAY(apBssid));
7809 }
7810
7811 if (p2pChannel > 0 && apChannel > 0) {
7812 hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel);
7813 }
7814}
7815
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007816bool hdd_is_ssr_required( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07007817{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007818 return (isSsrRequired == HDD_SSR_REQUIRED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007819}
7820
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007821/* Once SSR is disabled then it cannot be set. */
7822void hdd_set_ssr_required( e_hdd_ssr_required value)
Jeff Johnson295189b2012-06-20 16:38:30 -07007823{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007824 if (HDD_SSR_DISABLED == isSsrRequired)
7825 return;
7826
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 isSsrRequired = value;
7828}
7829
Hema Aparna Medicharla6b4d4f32015-06-23 04:09:12 +05307830void hdd_set_pre_close( hdd_context_t *pHddCtx)
7831{
7832 sme_PreClose(pHddCtx->hHal);
7833}
7834
Jeff Johnson295189b2012-06-20 16:38:30 -07007835VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx,
7836 hdd_adapter_list_node_t** ppAdapterNode)
7837{
7838 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307839 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 status = hdd_list_peek_front ( &pHddCtx->hddAdapters,
7841 (hdd_list_node_t**) ppAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307842 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 return status;
7844}
7845
7846VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx,
7847 hdd_adapter_list_node_t* pAdapterNode,
7848 hdd_adapter_list_node_t** pNextAdapterNode)
7849{
7850 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307851 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 status = hdd_list_peek_next ( &pHddCtx->hddAdapters,
7853 (hdd_list_node_t*) pAdapterNode,
7854 (hdd_list_node_t**)pNextAdapterNode );
7855
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307856 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 return status;
7858}
7859
7860VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx,
7861 hdd_adapter_list_node_t* pAdapterNode)
7862{
7863 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307864 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 status = hdd_list_remove_node ( &pHddCtx->hddAdapters,
7866 &pAdapterNode->node );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307867 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 return status;
7869}
7870
7871VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx,
7872 hdd_adapter_list_node_t** ppAdapterNode)
7873{
7874 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307875 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 status = hdd_list_remove_front( &pHddCtx->hddAdapters,
7877 (hdd_list_node_t**) ppAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307878 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 return status;
7880}
7881
7882VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx,
7883 hdd_adapter_list_node_t* pAdapterNode)
7884{
7885 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307886 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 status = hdd_list_insert_back ( &pHddCtx->hddAdapters,
7888 (hdd_list_node_t*) pAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307889 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 return status;
7891}
7892
7893VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx,
7894 hdd_adapter_list_node_t* pAdapterNode)
7895{
7896 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307897 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007898 status = hdd_list_insert_front ( &pHddCtx->hddAdapters,
7899 (hdd_list_node_t*) pAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307900 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 return status;
7902}
7903
7904hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx,
7905 tSirMacAddr macAddr )
7906{
7907 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7908 hdd_adapter_t *pAdapter;
7909 VOS_STATUS status;
7910
7911 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7912
7913 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7914 {
7915 pAdapter = pAdapterNode->pAdapter;
7916
7917 if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes,
7918 macAddr, sizeof(tSirMacAddr) ) )
7919 {
7920 return pAdapter;
7921 }
7922 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7923 pAdapterNode = pNext;
7924 }
7925
7926 return NULL;
7927
7928}
7929
7930hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name )
7931{
7932 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7933 hdd_adapter_t *pAdapter;
7934 VOS_STATUS status;
7935
7936 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7937
7938 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7939 {
7940 pAdapter = pAdapterNode->pAdapter;
7941
7942 if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name,
7943 IFNAMSIZ ) )
7944 {
7945 return pAdapter;
7946 }
7947 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7948 pAdapterNode = pNext;
7949 }
7950
7951 return NULL;
7952
7953}
7954
7955hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode )
7956{
7957 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7958 hdd_adapter_t *pAdapter;
7959 VOS_STATUS status;
7960
7961 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7962
7963 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7964 {
7965 pAdapter = pAdapterNode->pAdapter;
7966
7967 if( pAdapter && (mode == pAdapter->device_mode) )
7968 {
7969 return pAdapter;
7970 }
7971 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7972 pAdapterNode = pNext;
7973 }
7974
7975 return NULL;
7976
7977}
7978
7979//Remove this function later
7980hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx )
7981{
7982 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7983 hdd_adapter_t *pAdapter;
7984 VOS_STATUS status;
7985
7986 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7987
7988 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7989 {
7990 pAdapter = pAdapterNode->pAdapter;
7991
7992 if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode )
7993 {
7994 return pAdapter;
7995 }
7996
7997 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7998 pAdapterNode = pNext;
7999 }
8000
8001 return NULL;
8002
8003}
8004
Jeff Johnson295189b2012-06-20 16:38:30 -07008005/**---------------------------------------------------------------------------
8006
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05308007 \brief hdd_get_operating_channel() -
Jeff Johnson295189b2012-06-20 16:38:30 -07008008
8009 This API returns the operating channel of the requested device mode
8010
8011 \param - pHddCtx - Pointer to the HDD context.
8012 - mode - Device mode for which operating channel is required
8013 suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT
8014 WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO.
8015 \return - channel number. "0" id the requested device is not found OR it is not connected.
8016 --------------------------------------------------------------------------*/
8017v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode )
8018{
8019 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8020 VOS_STATUS status;
8021 hdd_adapter_t *pAdapter;
8022 v_U8_t operatingChannel = 0;
8023
8024 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8025
8026 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8027 {
8028 pAdapter = pAdapterNode->pAdapter;
8029
8030 if( mode == pAdapter->device_mode )
8031 {
8032 switch(pAdapter->device_mode)
8033 {
8034 case WLAN_HDD_INFRA_STATION:
8035 case WLAN_HDD_P2P_CLIENT:
8036 if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) )
8037 operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel;
8038 break;
8039 case WLAN_HDD_SOFTAP:
8040 case WLAN_HDD_P2P_GO:
8041 /*softap connection info */
8042 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
8043 operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel;
8044 break;
8045 default:
8046 break;
8047 }
8048
8049 break; //Found the device of interest. break the loop
8050 }
8051
8052 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8053 pAdapterNode = pNext;
8054 }
8055 return operatingChannel;
8056}
8057
8058#ifdef WLAN_FEATURE_PACKET_FILTERING
8059/**---------------------------------------------------------------------------
8060
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308061 \brief __hdd_set_multicast_list() -
Jeff Johnson295189b2012-06-20 16:38:30 -07008062
8063 This used to set the multicast address list.
8064
8065 \param - dev - Pointer to the WLAN device.
8066 - skb - Pointer to OS packet (sk_buff).
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308067 \return - success/fail
Jeff Johnson295189b2012-06-20 16:38:30 -07008068
8069 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308070static void __hdd_set_multicast_list(struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07008071{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308072 hdd_adapter_t *pAdapter;
8073 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 int mc_count;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308075 int i = 0, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 struct netdev_hw_addr *ha;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308077
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308078 ENTER();
8079
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308080 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308081 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 {
8083 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308084 "%s: Adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 return;
8086 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8088 ret = wlan_hdd_validate_context(pHddCtx);
8089 if (0 != ret)
8090 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308091 return;
8092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 if (dev->flags & IFF_ALLMULTI)
8094 {
8095 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008096 "%s: allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308097 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308099 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 {
8101 mc_count = netdev_mc_count(dev);
8102 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008103 "%s: mc_count = %u", __func__, mc_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST)
8105 {
8106 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008107 "%s: No free filter available; allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308108 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 return;
8110 }
8111
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308112 pAdapter->mc_addr_list.mc_cnt = mc_count;
Jeff Johnson295189b2012-06-20 16:38:30 -07008113
8114 netdev_for_each_mc_addr(ha, dev) {
8115 if (i == mc_count)
8116 break;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308117 memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN);
8118 memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008119 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR,
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308120 __func__, i,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308121 MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 i++;
8123 }
8124 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308125
8126 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 return;
8128}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308129
8130static void hdd_set_multicast_list(struct net_device *dev)
8131{
8132 vos_ssr_protect(__func__);
8133 __hdd_set_multicast_list(dev);
8134 vos_ssr_unprotect(__func__);
8135}
Jeff Johnson295189b2012-06-20 16:38:30 -07008136#endif
8137
8138/**---------------------------------------------------------------------------
8139
8140 \brief hdd_select_queue() -
8141
8142 This function is registered with the Linux OS for network
8143 core to decide which queue to use first.
8144
8145 \param - dev - Pointer to the WLAN device.
8146 - skb - Pointer to OS packet (sk_buff).
8147 \return - ac, Queue Index/access category corresponding to UP in IP header
8148
8149 --------------------------------------------------------------------------*/
8150v_U16_t hdd_select_queue(struct net_device *dev,
8151 struct sk_buff *skb)
8152{
8153 return hdd_wmm_select_queue(dev, skb);
8154}
8155
8156
8157/**---------------------------------------------------------------------------
8158
8159 \brief hdd_wlan_initial_scan() -
8160
8161 This function triggers the initial scan
8162
8163 \param - pAdapter - Pointer to the HDD adapter.
8164
8165 --------------------------------------------------------------------------*/
8166void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter)
8167{
8168 tCsrScanRequest scanReq;
8169 tCsrChannelInfo channelInfo;
8170 eHalStatus halStatus;
Jeff Johnson02797792013-10-26 19:17:13 -07008171 tANI_U32 scanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8173
8174 vos_mem_zero(&scanReq, sizeof(tCsrScanRequest));
8175 vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff);
8176 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
8177
8178 if(sme_Is11dSupported(pHddCtx->hHal))
8179 {
8180 halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo );
8181 if ( HAL_STATUS_SUCCESS( halStatus ) )
8182 {
8183 scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels);
8184 if( !scanReq.ChannelInfo.ChannelList )
8185 {
8186 hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__);
8187 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08008188 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 return;
8190 }
8191 vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList,
8192 channelInfo.numOfChannels);
8193 scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels;
8194 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08008195 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 }
8197
8198 scanReq.scanType = eSIR_PASSIVE_SCAN;
8199 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
8200 scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime;
8201 scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime;
8202 }
8203 else
8204 {
8205 scanReq.scanType = eSIR_ACTIVE_SCAN;
8206 scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
8207 scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime;
8208 scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime;
8209 }
8210
8211 halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL);
8212 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8213 {
8214 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d",
8215 __func__, halStatus );
8216 }
8217
8218 if(sme_Is11dSupported(pHddCtx->hHal))
8219 vos_mem_free(scanReq.ChannelInfo.ChannelList);
8220}
8221
mukul sharmabab477d2015-06-11 17:14:55 +05308222void hdd_purge_cmd_list_all_adapters( hdd_context_t *pHddCtx )
8223{
8224 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8225 VOS_STATUS status;
8226 hdd_adapter_t *pAdapter;
8227
8228 ENTER();
8229
8230 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8231
8232 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8233 {
8234 pAdapter = pAdapterNode->pAdapter;
8235
8236 status = sme_PurgeCmdList(pHddCtx->hHal, pAdapter->sessionId);
8237 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8238 pAdapterNode = pNext;
8239 }
8240
8241 EXIT();
8242}
Jeff Johnson295189b2012-06-20 16:38:30 -07008243/**---------------------------------------------------------------------------
8244
8245 \brief hdd_full_power_callback() - HDD full power callback function
8246
8247 This is the function invoked by SME to inform the result of a full power
8248 request issued by HDD
8249
8250 \param - callbackcontext - Pointer to cookie
8251 \param - status - result of request
8252
8253 \return - None
8254
8255 --------------------------------------------------------------------------*/
8256static void hdd_full_power_callback(void *callbackContext, eHalStatus status)
8257{
Jeff Johnson72a40512013-12-19 10:14:15 -08008258 struct statsContext *pContext = callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008259
8260 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308261 "%s: context = %p, status = %d", __func__, pContext, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008262
8263 if (NULL == callbackContext)
8264 {
8265 hddLog(VOS_TRACE_LEVEL_ERROR,
8266 "%s: Bad param, context [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008267 __func__, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 return;
8269 }
8270
Jeff Johnson72a40512013-12-19 10:14:15 -08008271 /* there is a race condition that exists between this callback
8272 function and the caller since the caller could time out either
8273 before or while this code is executing. we use a spinlock to
8274 serialize these actions */
8275 spin_lock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008276
8277 if (POWER_CONTEXT_MAGIC != pContext->magic)
8278 {
8279 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08008280 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 hddLog(VOS_TRACE_LEVEL_WARN,
8282 "%s: Invalid context, magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008283 __func__, pContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 return;
8285 }
8286
Jeff Johnson72a40512013-12-19 10:14:15 -08008287 /* context is valid so caller is still waiting */
8288
8289 /* paranoia: invalidate the magic */
8290 pContext->magic = 0;
8291
8292 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 complete(&pContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08008294
8295 /* serialization is complete */
8296 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008297}
8298
Katya Nigamf0511f62015-05-05 16:40:57 +05308299void wlan_hdd_mon_set_typesubtype( hdd_mon_ctx_t *pMonCtx,int type)
8300{
8301 pMonCtx->typeSubtypeBitmap = 0;
8302 if( type%10 ) /* Management Packets */
8303 pMonCtx->typeSubtypeBitmap |= 0xFFFF;
8304 type/=10;
8305 if( type%10 ) /* Control Packets */
8306 pMonCtx->typeSubtypeBitmap |= 0xFFFF0000;
8307 type/=10;
8308 if( type%10 ) /* Data Packets */
8309 pMonCtx->typeSubtypeBitmap |= 0xFFFF00000000;
8310}
8311
8312VOS_STATUS wlan_hdd_mon_poststartmsg( hdd_mon_ctx_t *pMonCtx )
8313{
8314 vos_msg_t monMsg;
8315
8316 monMsg.type = WDA_MON_START_REQ;
8317 monMsg.reserved = 0;
8318 monMsg.bodyptr = (v_U8_t*)pMonCtx;
8319 monMsg.bodyval = 0;
8320
8321 if (VOS_STATUS_SUCCESS != vos_mq_post_message(
8322 VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) {
8323 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__);
8324 return VOS_STATUS_E_FAILURE;
8325 }
8326
8327 return VOS_STATUS_SUCCESS;
8328}
8329
8330void wlan_hdd_mon_poststopmsg(void)
8331{
8332 vos_msg_t monMsg;
8333
8334 monMsg.type = WDA_MON_STOP_REQ;
8335 monMsg.reserved = 0;
8336 monMsg.bodyptr = NULL;
8337 monMsg.bodyval = 0;
8338
8339 if (VOS_STATUS_SUCCESS != vos_mq_post_message(
8340 VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) {
8341 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__);
8342 }
8343}
8344
Katya Nigame7b69a82015-04-28 15:24:06 +05308345void wlan_hdd_mon_close(hdd_context_t *pHddCtx)
8346{
8347 VOS_STATUS vosStatus;
8348 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
8349 struct wiphy *wiphy = pHddCtx->wiphy;
8350
8351 hdd_adapter_t *pAdapter = hdd_get_adapter(pHddCtx,WLAN_HDD_MONITOR);
8352 if(pAdapter == NULL || pVosContext == NULL)
8353 {
8354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:pAdapter is NULL",__func__);
8355 return ;
8356 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308357
8358 wlan_hdd_mon_poststopmsg();
Katya Nigame7b69a82015-04-28 15:24:06 +05308359 hdd_UnregisterWext(pAdapter->dev);
8360
8361 vos_mon_stop( pVosContext );
8362
8363 vosStatus = vos_sched_close( pVosContext );
8364 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8365 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8366 "%s: Failed to close VOSS Scheduler",__func__);
8367 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8368 }
8369
8370 vosStatus = vos_nv_close();
8371 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8372 {
8373 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8374 "%s: Failed to close NV", __func__);
8375 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8376 }
8377
8378 vos_close(pVosContext);
8379
8380 #ifdef WLAN_KD_READY_NOTIFIER
8381 nl_srv_exit(pHddCtx->ptt_pid);
8382 #else
8383 nl_srv_exit();
8384 #endif
8385
8386 if (pHddCtx->cfg_ini)
8387 {
8388 kfree(pHddCtx->cfg_ini);
8389 pHddCtx->cfg_ini= NULL;
8390 }
8391 hdd_close_all_adapters( pHddCtx );
8392
8393 wiphy_free(wiphy) ;
8394
8395}
Jeff Johnson295189b2012-06-20 16:38:30 -07008396/**---------------------------------------------------------------------------
8397
8398 \brief hdd_wlan_exit() - HDD WLAN exit function
8399
8400 This is the driver exit point (invoked during rmmod)
8401
8402 \param - pHddCtx - Pointer to the HDD Context
8403
8404 \return - None
8405
8406 --------------------------------------------------------------------------*/
8407void hdd_wlan_exit(hdd_context_t *pHddCtx)
8408{
8409 eHalStatus halStatus;
8410 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
8411 VOS_STATUS vosStatus;
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05308412 struct wiphy *wiphy = pHddCtx->wiphy;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008413 hdd_adapter_t* pAdapter = NULL;
Jeff Johnson72a40512013-12-19 10:14:15 -08008414 struct statsContext powerContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 long lrc;
c_hpothu5ab05e92014-06-13 17:34:05 +05308416 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008417
8418 ENTER();
8419
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05308420
Katya Nigame7b69a82015-04-28 15:24:06 +05308421 if (VOS_MONITOR_MODE == hdd_get_conparam())
8422 {
8423 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: MONITOR MODE",__func__);
8424 wlan_hdd_mon_close(pHddCtx);
8425 return;
8426 }
8427 else if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson88ba7742013-02-27 14:36:02 -08008428 {
8429 // Unloading, restart logic is no more required.
8430 wlan_hdd_restart_deinit(pHddCtx);
Jeff Johnsone7245742012-09-05 17:12:55 -07008431
Agarwal Ashishb20e0ff2014-12-17 22:50:19 +05308432#ifdef FEATURE_WLAN_TDLS
8433 /* At the time of driver unloading; if tdls connection is present;
8434 * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer.
8435 * wlan_hdd_tdls_find_peer always checks for valid context;
8436 * as load/unload in progress there can be a race condition.
8437 * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only
8438 * when tdls state is enabled.
8439 * As soon as driver set load/unload flag; tdls flag also needs
8440 * to be disabled so that hdd_rx_packet_cbk won't call
8441 * wlan_hdd_tdls_find_peer.
8442 */
8443 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE);
8444#endif
8445
c_hpothu5ab05e92014-06-13 17:34:05 +05308446 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8447 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 {
c_hpothu5ab05e92014-06-13 17:34:05 +05308449 pAdapter = pAdapterNode->pAdapter;
8450 if (NULL != pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 {
Mahesh A Saptasagar305e2632015-03-04 12:57:33 +05308452 /* Disable TX on the interface, after this hard_start_xmit() will
8453 * not be called on that interface
8454 */
8455 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
8456 netif_tx_disable(pAdapter->dev);
8457
8458 /* Mark the interface status as "down" for outside world */
8459 netif_carrier_off(pAdapter->dev);
8460
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05308461 /* DeInit the adapter. This ensures that all data packets
8462 * are freed.
8463 */
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05308464#ifdef FEATURE_WLAN_TDLS
8465 mutex_lock(&pHddCtx->tdls_lock);
8466#endif
c_hpothu002231a2015-02-05 14:58:51 +05308467 hdd_deinit_adapter(pHddCtx, pAdapter, FALSE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05308468#ifdef FEATURE_WLAN_TDLS
8469 mutex_unlock(&pHddCtx->tdls_lock);
8470#endif
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05308471
c_hpothu5ab05e92014-06-13 17:34:05 +05308472 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
8473 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
8474 {
8475 wlan_hdd_cfg80211_deregister_frames(pAdapter);
8476 hdd_UnregisterWext(pAdapter->dev);
8477 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308478
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 }
c_hpothu5ab05e92014-06-13 17:34:05 +05308480 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8481 pAdapterNode = pNext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 }
mukul sharmabab477d2015-06-11 17:14:55 +05308483
8484 //Purge all sme cmd's for all interface
8485 hdd_purge_cmd_list_all_adapters(pHddCtx);
8486
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308487 // Cancel any outstanding scan requests. We are about to close all
8488 // of our adapters, but an adapter structure is what SME passes back
8489 // to our callback function. Hence if there are any outstanding scan
8490 // requests then there is a race condition between when the adapter
8491 // is closed and when the callback is invoked.We try to resolve that
8492 // race condition here by canceling any outstanding scans before we
8493 // close the adapters.
8494 // Note that the scans may be cancelled in an asynchronous manner,
8495 // so ideally there needs to be some kind of synchronization. Rather
8496 // than introduce a new synchronization here, we will utilize the
8497 // fact that we are about to Request Full Power, and since that is
8498 // synchronized, the expectation is that by the time Request Full
8499 // Power has completed all scans will be cancelled.
8500 if (pHddCtx->scan_info.mScanPending)
8501 {
Hema Aparna Medicharlaf05f6cd2015-01-21 14:44:19 +05308502 if(NULL != pAdapter)
8503 {
8504 hddLog(VOS_TRACE_LEVEL_INFO,
8505 FL("abort scan mode: %d sessionId: %d"),
8506 pAdapter->device_mode,
8507 pAdapter->sessionId);
8508 }
8509 hdd_abort_mac_scan(pHddCtx,
8510 pHddCtx->scan_info.sessionId,
8511 eCSR_SCAN_ABORT_DEFAULT);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 }
c_hpothu5ab05e92014-06-13 17:34:05 +05308514 else
Jeff Johnson88ba7742013-02-27 14:36:02 -08008515 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308516 hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__);
Hanumantha Reddy Pothula45af96b2015-02-12 16:07:58 +05308517 if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING)
8518 {
8519 INIT_COMPLETION(pHddCtx->ftm.startCmpVar);
8520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8521 "%s: in middle of FTM START", __func__);
8522 lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar,
8523 msecs_to_jiffies(20000));
8524 if(!lrc)
8525 {
8526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8527 "%s: timedout on ftmStartCmpVar fatal error", __func__);
8528 }
8529 }
Jeff Johnson88ba7742013-02-27 14:36:02 -08008530 wlan_hdd_ftm_close(pHddCtx);
8531 goto free_hdd_ctx;
8532 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308533
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 /* DeRegister with platform driver as client for Suspend/Resume */
8535 vosStatus = hddDeregisterPmOps(pHddCtx);
8536 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
8537 {
8538 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__);
8539 VOS_ASSERT(0);
8540 }
8541
8542 vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx);
8543 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
8544 {
8545 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
8546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008547
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07008548 //Stop the traffic monitor timer
8549 if ( VOS_TIMER_STATE_RUNNING ==
8550 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))
8551 {
8552 vos_timer_stop(&pHddCtx->tx_rx_trafficTmr);
8553 }
8554
8555 // Destroy the traffic monitor timer
8556 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(
8557 &pHddCtx->tx_rx_trafficTmr)))
8558 {
8559 hddLog(VOS_TRACE_LEVEL_ERROR,
8560 "%s: Cannot deallocate Traffic monitor timer", __func__);
8561 }
8562
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 //Disable IMPS/BMPS as we do not want the device to enter any power
8564 //save mode during shutdown
8565 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
8566 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
8567 sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE);
8568
8569 //Ensure that device is in full power as we will touch H/W during vos_Stop
8570 init_completion(&powerContext.completion);
8571 powerContext.magic = POWER_CONTEXT_MAGIC;
8572
8573 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback,
8574 &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD);
8575
8576 if (eHAL_STATUS_SUCCESS != halStatus)
8577 {
8578 if (eHAL_STATUS_PMC_PENDING == halStatus)
8579 {
8580 /* request was sent -- wait for the response */
8581 lrc = wait_for_completion_interruptible_timeout(
8582 &powerContext.completion,
8583 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07008584 if (lrc <= 0)
8585 {
8586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008587 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 }
8589 }
8590 else
8591 {
8592 hddLog(VOS_TRACE_LEVEL_ERROR,
8593 "%s: Request for Full Power failed, status %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008594 __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008595 /* continue -- need to clean up as much as possible */
8596 }
8597 }
Hanumantha Reddy Pothula81b42b22015-05-12 13:52:00 +05308598 if ((eHAL_STATUS_SUCCESS == halStatus) ||
8599 (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0))
8600 {
8601 /* This will issue a dump command which will clean up
8602 BTQM queues and unblock MC thread */
8603 vos_fwDumpReq(274, 0, 0, 0, 0, 1);
8604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008605
Jeff Johnson72a40512013-12-19 10:14:15 -08008606 /* either we never sent a request, we sent a request and received a
8607 response or we sent a request and timed out. if we never sent a
8608 request or if we sent a request and got a response, we want to
8609 clear the magic out of paranoia. if we timed out there is a
8610 race condition such that the callback function could be
8611 executing at the same time we are. of primary concern is if the
8612 callback function had already verified the "magic" but had not
8613 yet set the completion variable when a timeout occurred. we
8614 serialize these activities by invalidating the magic while
8615 holding a shared spinlock which will cause us to block if the
8616 callback is currently executing */
8617 spin_lock(&hdd_context_lock);
8618 powerContext.magic = 0;
8619 spin_unlock(&hdd_context_lock);
8620
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05308621 /* If Device is shutdown, no point for SME to wait for responses
8622 from device. Pre Close SME */
8623 if(wcnss_device_is_shutdown())
8624 {
8625 sme_PreClose(pHddCtx->hHal);
8626 }
Yue Ma0d4891e2013-08-06 17:01:45 -07008627 hdd_debugfs_exit(pHddCtx);
8628
Ratheesh S P35ed8b12015-04-27 14:01:07 +05308629#ifdef WLAN_NS_OFFLOAD
8630 hddLog(LOGE, FL("Unregister IPv6 notifier"));
8631 unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier);
8632#endif
8633 hddLog(LOGE, FL("Unregister IPv4 notifier"));
8634 unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier);
8635
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 // Unregister the Net Device Notifier
8637 unregister_netdevice_notifier(&hdd_netdev_notifier);
8638
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 hdd_stop_all_adapters( pHddCtx );
8640
Jeff Johnson295189b2012-06-20 16:38:30 -07008641#ifdef WLAN_BTAMP_FEATURE
8642 vosStatus = WLANBAP_Stop(pVosContext);
8643 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8644 {
8645 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8646 "%s: Failed to stop BAP",__func__);
8647 }
8648#endif //WLAN_BTAMP_FEATURE
8649
8650 //Stop all the modules
8651 vosStatus = vos_stop( pVosContext );
8652 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8653 {
8654 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8655 "%s: Failed to stop VOSS",__func__);
8656 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8657 }
8658
Jeff Johnson295189b2012-06-20 16:38:30 -07008659 //This requires pMac access, Call this before vos_close().
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 hdd_unregister_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008661
8662 //Close the scheduler before calling vos_close to make sure no thread is
8663 // scheduled after the each module close is called i.e after all the data
8664 // structures are freed.
8665 vosStatus = vos_sched_close( pVosContext );
8666 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8667 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8668 "%s: Failed to close VOSS Scheduler",__func__);
8669 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8670 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008671#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
8672 /* Destroy the wake lock */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308673 vos_wake_lock_destroy(&pHddCtx->rx_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008674#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08008675 /* Destroy the wake lock */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308676 vos_wake_lock_destroy(&pHddCtx->sap_wake_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008677
Mihir Shete7a24b5f2013-12-21 12:18:31 +05308678#ifdef CONFIG_ENABLE_LINUX_REG
8679 vosStatus = vos_nv_close();
8680 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8681 {
8682 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8683 "%s: Failed to close NV", __func__);
8684 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8685 }
8686#endif
8687
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 //Close VOSS
8689 //This frees pMac(HAL) context. There should not be any call that requires pMac access after this.
8690 vos_close(pVosContext);
8691
Jeff Johnson295189b2012-06-20 16:38:30 -07008692 //Close Watchdog
8693 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8694 vos_watchdog_close(pVosContext);
8695
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308696 //Clean up HDD Nlink Service
8697 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308698
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308699#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05308700 if (pHddCtx->cfg_ini->wlanLoggingEnable)
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308701 {
8702 wlan_logging_sock_deactivate_svc();
8703 }
8704#endif
8705
Vinay Krishna Erannaef30b522014-08-26 17:48:16 +05308706#ifdef WLAN_KD_READY_NOTIFIER
8707 nl_srv_exit(pHddCtx->ptt_pid);
8708#else
8709 nl_srv_exit();
8710#endif /* WLAN_KD_READY_NOTIFIER */
8711
8712
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 hdd_close_all_adapters( pHddCtx );
8714
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 /* free the power on lock from platform driver */
8716 if (free_riva_power_on_lock("wlan"))
8717 {
8718 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock",
8719 __func__);
8720 }
8721
Jeff Johnson88ba7742013-02-27 14:36:02 -08008722free_hdd_ctx:
c_hpothu78c7b602014-05-17 17:35:49 +05308723
8724 //Free up dynamically allocated members inside HDD Adapter
8725 if (pHddCtx->cfg_ini)
8726 {
8727 kfree(pHddCtx->cfg_ini);
8728 pHddCtx->cfg_ini= NULL;
8729 }
8730
Leo Changf04ddad2013-09-18 13:46:38 -07008731 /* FTM mode, WIPHY did not registered
8732 If un-register here, system crash will happen */
8733 if (VOS_FTM_MODE != hdd_get_conparam())
8734 {
8735 wiphy_unregister(wiphy) ;
8736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 wiphy_free(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 if (hdd_is_ssr_required())
8739 {
8740 /* WDI timeout had happened during unload, so SSR is needed here */
Madan Mohan Koyyalamudi3246f5b2012-10-15 15:40:02 -07008741 subsystem_restart("wcnss");
Jeff Johnson295189b2012-06-20 16:38:30 -07008742 msleep(5000);
8743 }
8744 hdd_set_ssr_required (VOS_FALSE);
8745}
8746
8747
8748/**---------------------------------------------------------------------------
8749
8750 \brief hdd_update_config_from_nv() - Function to update the contents of
8751 the running configuration with parameters taken from NV storage
8752
8753 \param - pHddCtx - Pointer to the HDD global context
8754
8755 \return - VOS_STATUS_SUCCESS if successful
8756
8757 --------------------------------------------------------------------------*/
8758static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx)
8759{
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 v_BOOL_t itemIsValid = VOS_FALSE;
8761 VOS_STATUS status;
8762 v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA];
8763 v_U8_t macLoop;
8764
8765 /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/
8766 status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid);
8767 if(status != VOS_STATUS_SUCCESS)
8768 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008769 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 return VOS_STATUS_E_FAILURE;
8771 }
8772
8773 if (itemIsValid == VOS_TRUE)
8774 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008775 hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV");
Jeff Johnson295189b2012-06-20 16:38:30 -07008776 status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0],
8777 VOS_MAX_CONCURRENCY_PERSONA);
8778 if(status != VOS_STATUS_SUCCESS)
8779 {
8780 /* Get MAC from NV fail, not update CFG info
8781 * INI MAC value will be used for MAC setting */
Arif Hussain6d2a3322013-11-17 19:50:10 -08008782 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 return VOS_STATUS_E_FAILURE;
8784 }
8785
8786 /* If first MAC is not valid, treat all others are not valid
8787 * Then all MACs will be got from ini file */
8788 if(vos_is_macaddr_zero(&macFromNV[0]))
8789 {
8790 /* MAC address in NV file is not configured yet */
8791 hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file");
8792 return VOS_STATUS_E_INVAL;
8793 }
8794
8795 /* Get MAC address from NV, update CFG info */
8796 for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++)
8797 {
8798 if(vos_is_macaddr_zero(&macFromNV[macLoop]))
8799 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308800 hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop);
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 /* This MAC is not valid, skip it
8802 * This MAC will be got from ini file */
8803 }
8804 else
8805 {
8806 vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0],
8807 (v_U8_t *)&macFromNV[macLoop].bytes[0],
8808 VOS_MAC_ADDR_SIZE);
8809 }
8810 }
8811 }
8812 else
8813 {
8814 hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid");
8815 return VOS_STATUS_E_FAILURE;
8816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008817
Jeff Johnson295189b2012-06-20 16:38:30 -07008818
8819 return VOS_STATUS_SUCCESS;
8820}
8821
8822/**---------------------------------------------------------------------------
8823
8824 \brief hdd_post_voss_start_config() - HDD post voss start config helper
8825
8826 \param - pAdapter - Pointer to the HDD
8827
8828 \return - None
8829
8830 --------------------------------------------------------------------------*/
8831VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx)
8832{
8833 eHalStatus halStatus;
8834 v_U32_t listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308835 tANI_U32 ignoreDtim;
Jeff Johnson295189b2012-06-20 16:38:30 -07008836
Jeff Johnson295189b2012-06-20 16:38:30 -07008837
8838 // Send ready indication to the HDD. This will kick off the MAC
8839 // into a 'running' state and should kick off an initial scan.
8840 halStatus = sme_HDDReadyInd( pHddCtx->hHal );
8841 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8842 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308843 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status "
Jeff Johnson295189b2012-06-20 16:38:30 -07008844 "code %08d [x%08x]",__func__, halStatus, halStatus );
8845 return VOS_STATUS_E_FAILURE;
8846 }
8847
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308848 // Set default LI and ignoreDtim into HDD context,
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 // otherwise under some race condition, HDD will set 0 LI value into RIVA,
8850 // And RIVA will crash
8851 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval);
8852 pHddCtx->hdd_actual_LI_value = listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308853 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim);
8854 pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim;
8855
8856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 return VOS_STATUS_SUCCESS;
8858}
8859
Jeff Johnson295189b2012-06-20 16:38:30 -07008860/* wake lock APIs for HDD */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308861void hdd_prevent_suspend(uint32_t reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07008862{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308863
8864 vos_wake_lock_acquire(&wlan_wake_lock, reason);
8865
Jeff Johnson295189b2012-06-20 16:38:30 -07008866}
8867
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308868void hdd_allow_suspend(uint32_t reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07008869{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308870
8871 vos_wake_lock_release(&wlan_wake_lock, reason);
8872
Jeff Johnson295189b2012-06-20 16:38:30 -07008873}
8874
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308875void hdd_prevent_suspend_timeout(v_U32_t timeout, uint32_t reason)
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008876{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308877
8878 vos_wake_lock_timeout_release(&wlan_wake_lock, timeout,
8879 reason);
8880
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008881}
8882
Jeff Johnson295189b2012-06-20 16:38:30 -07008883/**---------------------------------------------------------------------------
8884
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008885 \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability
8886 information between Host and Riva
8887
8888 This function gets reported version of FW
8889 It also finds the version of Riva headers used to compile the host
8890 It compares the above two and prints a warning if they are different
8891 It gets the SW and HW version string
8892 Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg
8893 indicating the features they support through a bitmap
8894
8895 \param - pHddCtx - Pointer to HDD context
8896
8897 \return - void
8898
8899 --------------------------------------------------------------------------*/
8900
8901void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx)
8902{
8903
8904 tSirVersionType versionCompiled;
8905 tSirVersionType versionReported;
8906 tSirVersionString versionString;
8907 tANI_U8 fwFeatCapsMsgSupported = 0;
8908 VOS_STATUS vstatus;
8909
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008910 memset(&versionCompiled, 0, sizeof(versionCompiled));
8911 memset(&versionReported, 0, sizeof(versionReported));
8912
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008913 /* retrieve and display WCNSS version information */
8914 do {
8915
8916 vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal,
8917 &versionCompiled);
8918 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8919 {
8920 hddLog(VOS_TRACE_LEVEL_FATAL,
8921 "%s: unable to retrieve WCNSS WLAN compiled version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008922 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008923 break;
8924 }
8925
8926 vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal,
8927 &versionReported);
8928 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8929 {
8930 hddLog(VOS_TRACE_LEVEL_FATAL,
8931 "%s: unable to retrieve WCNSS WLAN reported version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008932 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008933 break;
8934 }
8935
8936 if ((versionCompiled.major != versionReported.major) ||
8937 (versionCompiled.minor != versionReported.minor) ||
8938 (versionCompiled.version != versionReported.version) ||
8939 (versionCompiled.revision != versionReported.revision))
8940 {
8941 pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, "
8942 "Host expected %u.%u.%u.%u\n",
8943 WLAN_MODULE_NAME,
8944 (int)versionReported.major,
8945 (int)versionReported.minor,
8946 (int)versionReported.version,
8947 (int)versionReported.revision,
8948 (int)versionCompiled.major,
8949 (int)versionCompiled.minor,
8950 (int)versionCompiled.version,
8951 (int)versionCompiled.revision);
8952 }
8953 else
8954 {
8955 pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n",
8956 WLAN_MODULE_NAME,
8957 (int)versionReported.major,
8958 (int)versionReported.minor,
8959 (int)versionReported.version,
8960 (int)versionReported.revision);
8961 }
8962
8963 vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal,
8964 versionString,
8965 sizeof(versionString));
8966 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8967 {
8968 hddLog(VOS_TRACE_LEVEL_FATAL,
8969 "%s: unable to retrieve WCNSS software version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008970 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008971 break;
8972 }
8973
8974 pr_info("%s: WCNSS software version %s\n",
8975 WLAN_MODULE_NAME, versionString);
8976
8977 vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal,
8978 versionString,
8979 sizeof(versionString));
8980 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8981 {
8982 hddLog(VOS_TRACE_LEVEL_FATAL,
8983 "%s: unable to retrieve WCNSS hardware version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008984 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008985 break;
8986 }
8987
8988 pr_info("%s: WCNSS hardware version %s\n",
8989 WLAN_MODULE_NAME, versionString);
8990
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008991 /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message
8992 2.Host-FW capability exchange message is only present on riva 1.1 so
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008993 send the message only if it the riva is 1.1
8994 minor numbers for different riva branches:
8995 0 -> (1.0)Mainline Build
8996 1 -> (1.1)Mainline Build
8997 2->(1.04) Stability Build
8998 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008999 if (((versionReported.major>0) || (versionReported.minor>1) ||
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009000 ((versionReported.minor>=1) && (versionReported.version>=1)))
9001 && ((versionReported.major == 1) && (versionReported.minor >= 1)))
9002 fwFeatCapsMsgSupported = 1;
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07009003
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009004 if (fwFeatCapsMsgSupported)
Yathish9f22e662012-12-10 14:21:35 -08009005 {
9006#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9007 if(!pHddCtx->cfg_ini->fEnableActiveModeOffload)
9008 sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD);
9009#endif
Ravi Joshid2ca7c42013-07-23 08:37:49 -07009010 /* Indicate if IBSS heartbeat monitoring needs to be offloaded */
9011 if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload)
9012 {
9013 sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD);
9014 }
9015
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009016 sme_featureCapsExchange(pHddCtx->hHal);
Yathish9f22e662012-12-10 14:21:35 -08009017 }
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009018
9019 } while (0);
9020
9021}
Neelansh Mittaledafed22014-09-04 18:54:39 +05309022void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len)
9023{
9024 struct sk_buff *skb;
9025 struct nlmsghdr *nlh;
9026 tAniMsgHdr *ani_hdr;
Hanumantha Reddy Pothulacf2c7ea2015-04-27 14:50:47 +05309027 int flags = GFP_KERNEL;
Neelansh Mittaledafed22014-09-04 18:54:39 +05309028
Hanumantha Reddy Pothulacf2c7ea2015-04-27 14:50:47 +05309029 if (in_interrupt() || irqs_disabled() || in_atomic())
9030 flags = GFP_ATOMIC;
9031
9032 skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags);
Neelansh Mittaledafed22014-09-04 18:54:39 +05309033
9034 if(skb == NULL) {
9035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9036 "%s: alloc_skb failed", __func__);
9037 return;
9038 }
9039
9040 nlh = (struct nlmsghdr *)skb->data;
9041 nlh->nlmsg_pid = 0; /* from kernel */
9042 nlh->nlmsg_flags = 0;
9043 nlh->nlmsg_seq = 0;
9044 nlh->nlmsg_type = WLAN_NL_MSG_SVC;
9045
9046 ani_hdr = NLMSG_DATA(nlh);
9047 ani_hdr->type = type;
9048
9049 switch(type) {
9050 case WLAN_SVC_SAP_RESTART_IND:
9051 ani_hdr->length = 0;
9052 nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr)));
9053 skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr)));
9054 break;
9055 default:
9056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9057 "Attempt to send unknown nlink message %d", type);
9058 kfree_skb(skb);
9059 return;
9060 }
9061
9062 nl_srv_bcast(skb);
9063
9064 return;
9065}
9066
9067
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009068
9069/**---------------------------------------------------------------------------
9070
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309071 \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz
9072
9073 \param - pHddCtx - Pointer to the hdd context
9074
9075 \return - true if hardware supports 5GHz
9076
9077 --------------------------------------------------------------------------*/
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05309078boolean hdd_is_5g_supported(hdd_context_t * pHddCtx)
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309079{
9080 /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1);
9081 * then hardware support 5Ghz.
9082 */
9083 if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode())
9084 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309086 return true;
9087 }
9088 else
9089 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz",
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309091 __func__);
9092 return false;
9093 }
9094}
9095
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309096/**---------------------------------------------------------------------------
9097
9098 \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto
9099 generate function
9100
9101 This is generate the random mac address for WLAN interface
9102
9103 \param - pHddCtx - Pointer to HDD context
9104 idx - Start interface index to get auto
9105 generated mac addr.
9106 mac_addr - Mac address
9107
9108 \return - 0 for success, < 0 for failure
9109
9110 --------------------------------------------------------------------------*/
9111
9112static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx,
9113 int idx, v_MACADDR_t mac_addr)
9114{
9115 int i;
9116 unsigned int serialno;
9117 serialno = wcnss_get_serial_number();
9118
9119 if (0 != serialno)
9120 {
9121 /* MAC address has 3 bytes of OUI so we have a maximum of 3
9122 bytes of the serial number that can be used to generate
9123 the other 3 bytes of the MAC address. Mask off all but
9124 the lower 3 bytes (this will also make sure we don't
9125 overflow in the next step) */
9126 serialno &= 0x00FFFFFF;
9127
9128 /* we need a unique address for each session */
9129 serialno *= VOS_MAX_CONCURRENCY_PERSONA;
9130
9131 /* autogen other Mac addresses */
9132 for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
9133 {
9134 /* start with the entire default address */
9135 pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr;
9136 /* then replace the lower 3 bytes */
9137 pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF;
9138 pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF;
9139 pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF;
9140
9141 serialno++;
9142 hddLog(VOS_TRACE_LEVEL_ERROR,
9143 "%s: Derived Mac Addr: "
9144 MAC_ADDRESS_STR, __func__,
9145 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes));
9146 }
9147
9148 }
9149 else
9150 {
9151 hddLog(LOGE, FL("Failed to Get Serial NO"));
9152 return -1;
9153 }
9154 return 0;
9155}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309156
Katya Nigame7b69a82015-04-28 15:24:06 +05309157int wlan_hdd_mon_open(hdd_context_t *pHddCtx)
9158{
9159 VOS_STATUS status;
9160 v_CONTEXT_t pVosContext= NULL;
9161 hdd_adapter_t *pAdapter= NULL;
9162
9163 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9164
9165 if (NULL == pVosContext)
9166 {
9167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9168 "%s: Trying to open VOSS without a PreOpen", __func__);
9169 VOS_ASSERT(0);
9170 return VOS_STATUS_E_FAILURE;
9171 }
9172
9173 status = vos_nv_open();
9174 if (!VOS_IS_STATUS_SUCCESS(status))
9175 {
9176 /* NV module cannot be initialized */
9177 hddLog( VOS_TRACE_LEVEL_FATAL,
9178 "%s: vos_nv_open failed", __func__);
9179 return VOS_STATUS_E_FAILURE;
9180 }
9181
9182 status = vos_init_wiphy_from_nv_bin();
9183 if (!VOS_IS_STATUS_SUCCESS(status))
9184 {
9185 /* NV module cannot be initialized */
9186 hddLog( VOS_TRACE_LEVEL_FATAL,
9187 "%s: vos_init_wiphy failed", __func__);
9188 goto err_vos_nv_close;
9189 }
9190
9191 status = vos_open( &pVosContext, pHddCtx->parent_dev);
9192 if ( !VOS_IS_STATUS_SUCCESS( status ))
9193 {
9194 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
9195 goto err_vos_nv_close;
9196 }
9197
9198 status = vos_mon_start( pVosContext );
9199 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9200 {
9201 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
9202 goto err_vosclose;
9203 }
9204
9205 WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk );
9206 WDA_featureCapsExchange(pVosContext);
9207 wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx);
9208
9209 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_MONITOR, "wlan%d",
9210 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9211 if( pAdapter == NULL )
9212 {
9213 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9214 goto err_close_adapter;
9215 }
9216
9217 //Initialize the nlink service
9218 if(nl_srv_init() != 0)
9219 {
9220 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
9221 goto err_close_adapter;
9222 }
9223 return VOS_STATUS_SUCCESS;
9224
9225err_close_adapter:
9226 hdd_close_all_adapters( pHddCtx );
9227 vos_mon_stop( pVosContext );
9228err_vosclose:
9229 status = vos_sched_close( pVosContext );
9230 if (!VOS_IS_STATUS_SUCCESS(status)) {
9231 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
9232 "%s: Failed to close VOSS Scheduler", __func__);
9233 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
9234 }
9235 vos_close(pVosContext );
9236
9237err_vos_nv_close:
9238 vos_nv_close();
9239
9240return status;
9241}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309242/**---------------------------------------------------------------------------
9243
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309244 \brief hdd_11d_scan_done - callback to be executed when 11d scan is
9245 completed to flush out the scan results
9246
9247 11d scan is done during driver load and is a passive scan on all
9248 channels supported by the device, 11d scans may find some APs on
9249 frequencies which are forbidden to be used in the regulatory domain
9250 the device is operating in. If these APs are notified to the supplicant
9251 it may try to connect to these APs, thus flush out all the scan results
9252 which are present in SME after 11d scan is done.
9253
9254 \return - eHalStatus
9255
9256 --------------------------------------------------------------------------*/
9257static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext,
9258 tANI_U32 scanId, eCsrScanStatus status)
9259{
9260 ENTER();
9261
9262 sme_ScanFlushResult(halHandle, 0);
9263
9264 EXIT();
9265
9266 return eHAL_STATUS_SUCCESS;
9267}
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309268/**---------------------------------------------------------------------------
9269
9270 \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame
9271 logging is completed successfully.
9272
9273 \return - None
9274
9275 --------------------------------------------------------------------------*/
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309276void hdd_init_frame_logging_done(void *fwlogInitCbContext, VOS_STATUS status)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309277{
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309278 hdd_context_t* pHddCtx = (hdd_context_t*)fwlogInitCbContext;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309279
9280 if (NULL == pHddCtx)
9281 {
9282 hddLog(VOS_TRACE_LEVEL_ERROR,
9283 "%s: HDD context is NULL",__func__);
9284 return;
9285 }
9286
Mahesh A Saptasagarfabb1a02015-06-29 12:17:04 +05309287 if ((VOS_STATUS_SUCCESS == status) &&
9288 (TRUE == pHddCtx->cfg_ini->enableMgmtLogging))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309289 {
9290 hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful"));
9291 pHddCtx->mgmt_frame_logging = TRUE;
9292 }
9293 else
9294 {
9295 hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success"));
9296 pHddCtx->mgmt_frame_logging = FALSE;
9297 }
9298
9299 return;
9300}
9301/**---------------------------------------------------------------------------
9302
9303 \brief hdd_init_frame_logging - function to initialize frame logging.
9304 Currently only Mgmt Frames are logged in both TX
9305 and Rx direction and are sent to userspace
9306 application using logger thread when queried.
9307
9308 \return - None
9309
9310 --------------------------------------------------------------------------*/
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309311void hdd_init_frame_logging(hdd_context_t* pHddCtx)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309312{
9313 eHalStatus halStatus = eHAL_STATUS_FAILURE;
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309314 tpSirFWLoggingInitParam wlanFWLoggingInitParam;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309315
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309316 if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING) &&
9317 TRUE != sme_IsFeatureSupportedByFW(LOGGING_ENHANCEMENT))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309318 {
9319 hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW"));
9320 return;
9321 }
9322
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309323 wlanFWLoggingInitParam = vos_mem_malloc(sizeof(tSirFWLoggingInitParam));
9324 if(NULL == wlanFWLoggingInitParam)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309325 {
9326 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_mem_alloc failed ", __func__);
9327 return;
9328 }
9329
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309330 vos_mem_set(wlanFWLoggingInitParam, sizeof(tSirFWLoggingInitParam), 0);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309331
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309332 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Configuring %s %s %s Logging",__func__,
9333 pHddCtx->cfg_ini->enableFWLogging?"FW Log,":"",
9334 pHddCtx->cfg_ini->enableContFWLogging ? "Cont FW log,":"",
9335 pHddCtx->cfg_ini->enableMgmtLogging ? "Mgmt Pkt Log":"");
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309336
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309337 if (pHddCtx->cfg_ini->enableFWLogging ||
9338 pHddCtx->cfg_ini->enableContFWLogging)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309339 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309340 wlanFWLoggingInitParam->enableFlag |= WLAN_QXDM_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309341 }
9342
Sushant Kaushik46804902015-07-08 14:46:03 +05309343 if (pHddCtx->cfg_ini->enableMgmtLogging)
9344 {
9345 wlanFWLoggingInitParam->enableFlag |= WLAN_FRAME_LOG_EN;
9346 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309347 if (pHddCtx->cfg_ini->enableBMUHWtracing)
9348 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309349 wlanFWLoggingInitParam->enableFlag |= WLAN_BMUHW_TRACE_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309350 }
9351
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309352 wlanFWLoggingInitParam->frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT;
9353 wlanFWLoggingInitParam->frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES;
9354 wlanFWLoggingInitParam->bufferMode = WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR;
9355 wlanFWLoggingInitParam->continuousFrameLogging =
9356 pHddCtx->cfg_ini->enableContFWLogging;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309357
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309358 wlanFWLoggingInitParam->enableFlag &= ~WLAN_DPU_TXP_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309359
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309360 wlanFWLoggingInitParam->minLogBufferSize =
9361 pHddCtx->cfg_ini->minLoggingBufferSize;
9362 wlanFWLoggingInitParam->maxLogBufferSize =
9363 pHddCtx->cfg_ini->maxLoggingBufferSize;
9364 wlanFWLoggingInitParam->fwlogInitCallback = hdd_init_frame_logging_done;
9365 wlanFWLoggingInitParam->fwlogInitCbContext= pHddCtx;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309366
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309367 halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, wlanFWLoggingInitParam);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309368
9369 if (eHAL_STATUS_SUCCESS != halStatus)
9370 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309371 vos_mem_free(wlanFWLoggingInitParam);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309372 }
9373
9374 return;
9375}
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309376
9377/**---------------------------------------------------------------------------
9378
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 \brief hdd_wlan_startup() - HDD init function
9380
9381 This is the driver startup code executed once a WLAN device has been detected
9382
9383 \param - dev - Pointer to the underlying device
9384
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009385 \return - 0 for success, < 0 for failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009386
9387 --------------------------------------------------------------------------*/
9388
9389int hdd_wlan_startup(struct device *dev )
9390{
9391 VOS_STATUS status;
9392 hdd_adapter_t *pAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009393 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 hdd_context_t *pHddCtx = NULL;
9395 v_CONTEXT_t pVosContext= NULL;
9396#ifdef WLAN_BTAMP_FEATURE
9397 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
9398 WLANBAP_ConfigType btAmpConfig;
9399 hdd_config_t *pConfig;
9400#endif
9401 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 struct wiphy *wiphy;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309403 v_MACADDR_t mac_addr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009404
9405 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 /*
9407 * cfg80211: wiphy allocation
9408 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309409 wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009410
9411 if(wiphy == NULL)
9412 {
9413 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009414 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 pHddCtx = wiphy_priv(wiphy);
9417
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 //Initialize the adapter context to zeros.
9419 vos_mem_zero(pHddCtx, sizeof( hdd_context_t ));
9420
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 pHddCtx->wiphy = wiphy;
Sushant Kaushik83392fa2015-05-05 17:44:40 +05309422 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Mihir Shete18156292014-03-11 15:38:30 +05309423 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009424
9425 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
9426
Siddharth Bhalcd92b782015-06-29 12:25:40 +05309427 /* register for riva power on lock to platform driver
9428 * Locking power early to ensure FW doesn't reset by kernel while
9429 * host driver is busy initializing itself */
9430 if (req_riva_power_on_lock("wlan"))
9431 {
9432 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed",
9433 __func__);
9434 goto err_free_hdd_context;
9435 }
9436
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 /*Get vos context here bcoz vos_open requires it*/
9438 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9439
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08009440 if(pVosContext == NULL)
9441 {
9442 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__);
9443 goto err_free_hdd_context;
9444 }
9445
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 //Save the Global VOSS context in adapter context for future.
9447 pHddCtx->pvosContext = pVosContext;
9448
9449 //Save the adapter context in global context for future.
9450 ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx;
9451
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 pHddCtx->parent_dev = dev;
9453
9454 init_completion(&pHddCtx->full_pwr_comp_var);
9455 init_completion(&pHddCtx->standby_comp_var);
9456 init_completion(&pHddCtx->req_bmps_comp_var);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009457 init_completion(&pHddCtx->scan_info.scan_req_completion_event);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009458 init_completion(&pHddCtx->scan_info.abortscan_event_var);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309459 init_completion(&pHddCtx->wiphy_channel_update_event);
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309460 init_completion(&pHddCtx->ssr_comp_var);
Amar Singhala49cbc52013-10-08 18:37:44 -07009461
9462#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhalfddc28c2013-09-05 13:03:40 -07009463 init_completion(&pHddCtx->linux_reg_req);
Amar Singhala49cbc52013-10-08 18:37:44 -07009464#else
9465 init_completion(&pHddCtx->driver_crda_req);
9466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009467
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309468 spin_lock_init(&pHddCtx->schedScan_lock);
9469
Jeff Johnson295189b2012-06-20 16:38:30 -07009470 hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS );
9471
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309472#ifdef FEATURE_WLAN_TDLS
9473 /* tdls_lock is initialized before an hdd_open_adapter ( which is
9474 * invoked by other instances also) to protect the concurrent
9475 * access for the Adapters by TDLS module.
9476 */
9477 mutex_init(&pHddCtx->tdls_lock);
9478#endif
Siddharth Bhal76972212014-10-15 16:22:51 +05309479 mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05309480 mutex_init(&pHddCtx->wmmLock);
9481
Agarwal Ashish1f422872014-07-22 00:11:55 +05309482 /* By default Strict Regulatory For FCC should be false */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309483
Agarwal Ashish1f422872014-07-22 00:11:55 +05309484 pHddCtx->nEnableStrictRegulatoryForFCC = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 // Load all config first as TL config is needed during vos_open
9486 pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL);
9487 if(pHddCtx->cfg_ini == NULL)
9488 {
9489 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__);
9490 goto err_free_hdd_context;
9491 }
9492
9493 vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t ));
9494
9495 // Read and parse the qcom_cfg.ini file
9496 status = hdd_parse_config_ini( pHddCtx );
9497 if ( VOS_STATUS_SUCCESS != status )
9498 {
9499 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s",
9500 __func__, WLAN_INI_FILE);
9501 goto err_config;
9502 }
Arif Hussaind5218912013-12-05 01:10:55 -08009503#ifdef MEMORY_DEBUG
9504 if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled)
9505 vos_mem_init();
9506
9507 hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d",
9508 __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled);
9509#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009510
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309511 /* INI has been read, initialise the configuredMcastBcastFilter with
9512 * INI value as this will serve as the default value
9513 */
9514 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
9515 hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d",
9516 pHddCtx->cfg_ini->mcastBcastFilterSetting);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309517
9518 if (false == hdd_is_5g_supported(pHddCtx))
9519 {
9520 //5Ghz is not supported.
9521 if (1 != pHddCtx->cfg_ini->nBandCapability)
9522 {
9523 hddLog(VOS_TRACE_LEVEL_INFO,
9524 "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__);
9525 pHddCtx->cfg_ini->nBandCapability = 1;
9526 }
9527 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309528
9529 /* If SNR Monitoring is enabled, FW has to parse all beacons
9530 * for calcaluting and storing the average SNR, so set Nth beacon
9531 * filter to 1 to enable FW to parse all the beaocons
9532 */
9533 if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring)
9534 {
9535 /* The log level is deliberately set to WARN as overriding
9536 * nthBeaconFilter to 1 will increase power cosumption and this
9537 * might just prove helpful to detect the power issue.
9538 */
9539 hddLog(VOS_TRACE_LEVEL_WARN,
9540 "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__);
9541 pHddCtx->cfg_ini->nthBeaconFilter = 1;
9542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 /*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309544 * cfg80211: Initialization ...
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 */
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08009546 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 {
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08009548 if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini))
9549 {
9550 hddLog(VOS_TRACE_LEVEL_FATAL,
9551 "%s: wlan_hdd_cfg80211_init return failure", __func__);
9552 goto err_config;
9553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009555
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009556 // Update VOS trace levels based upon the cfg.ini
9557 hdd_vos_trace_enable(VOS_MODULE_ID_BAP,
9558 pHddCtx->cfg_ini->vosTraceEnableBAP);
9559 hdd_vos_trace_enable(VOS_MODULE_ID_TL,
9560 pHddCtx->cfg_ini->vosTraceEnableTL);
9561 hdd_vos_trace_enable(VOS_MODULE_ID_WDI,
9562 pHddCtx->cfg_ini->vosTraceEnableWDI);
9563 hdd_vos_trace_enable(VOS_MODULE_ID_HDD,
9564 pHddCtx->cfg_ini->vosTraceEnableHDD);
9565 hdd_vos_trace_enable(VOS_MODULE_ID_SME,
9566 pHddCtx->cfg_ini->vosTraceEnableSME);
9567 hdd_vos_trace_enable(VOS_MODULE_ID_PE,
9568 pHddCtx->cfg_ini->vosTraceEnablePE);
Katya Nigam70d68332013-09-16 16:49:45 +05309569 hdd_vos_trace_enable(VOS_MODULE_ID_PMC,
9570 pHddCtx->cfg_ini->vosTraceEnablePMC);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009571 hdd_vos_trace_enable(VOS_MODULE_ID_WDA,
9572 pHddCtx->cfg_ini->vosTraceEnableWDA);
9573 hdd_vos_trace_enable(VOS_MODULE_ID_SYS,
9574 pHddCtx->cfg_ini->vosTraceEnableSYS);
9575 hdd_vos_trace_enable(VOS_MODULE_ID_VOSS,
9576 pHddCtx->cfg_ini->vosTraceEnableVOSS);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009577 hdd_vos_trace_enable(VOS_MODULE_ID_SAP,
9578 pHddCtx->cfg_ini->vosTraceEnableSAP);
9579 hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP,
9580 pHddCtx->cfg_ini->vosTraceEnableHDDSAP);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009581
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 // Update WDI trace levels based upon the cfg.ini
9583 hdd_wdi_trace_enable(eWLAN_MODULE_DAL,
9584 pHddCtx->cfg_ini->wdiTraceEnableDAL);
9585 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL,
9586 pHddCtx->cfg_ini->wdiTraceEnableCTL);
9587 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA,
9588 pHddCtx->cfg_ini->wdiTraceEnableDAT);
9589 hdd_wdi_trace_enable(eWLAN_MODULE_PAL,
9590 pHddCtx->cfg_ini->wdiTraceEnablePAL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009591
Jeff Johnson88ba7742013-02-27 14:36:02 -08009592 if (VOS_FTM_MODE == hdd_get_conparam())
9593 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009594 if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) )
9595 {
9596 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__);
9597 goto err_free_hdd_context;
9598 }
9599 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__);
Sachin Ahuja38ef5e02015-03-13 17:31:16 +05309600 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
c_hpothu2de0ef62014-04-15 16:16:15 +05309601 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 return VOS_STATUS_SUCCESS;
Jeff Johnson88ba7742013-02-27 14:36:02 -08009603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009604
Katya Nigame7b69a82015-04-28 15:24:06 +05309605 if( VOS_MONITOR_MODE == hdd_get_conparam())
9606 {
9607 if ( VOS_STATUS_SUCCESS != wlan_hdd_mon_open(pHddCtx))
9608 {
9609 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_mon_open Failed",__func__);
9610 goto err_free_hdd_context;
9611 }
9612 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Driver loaded in Monitor Mode",__func__);
9613 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
9614 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9615 return VOS_STATUS_SUCCESS;
9616 }
9617
Jeff Johnson88ba7742013-02-27 14:36:02 -08009618 //Open watchdog module
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 if(pHddCtx->cfg_ini->fIsLogpEnabled)
9620 {
9621 status = vos_watchdog_open(pVosContext,
9622 &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext));
9623
9624 if(!VOS_IS_STATUS_SUCCESS( status ))
9625 {
9626 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309627 goto err_wdclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 }
9629 }
9630
9631 pHddCtx->isLogpInProgress = FALSE;
9632 vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9633
Amar Singhala49cbc52013-10-08 18:37:44 -07009634#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009635 /* initialize the NV module. This is required so that
9636 we can initialize the channel information in wiphy
9637 from the NV.bin data. The channel information in
9638 wiphy needs to be initialized before wiphy registration */
9639
9640 status = vos_nv_open();
9641 if (!VOS_IS_STATUS_SUCCESS(status))
9642 {
9643 /* NV module cannot be initialized */
9644 hddLog( VOS_TRACE_LEVEL_FATAL,
9645 "%s: vos_nv_open failed", __func__);
Vinay Krishna Eranna2025d892014-09-18 16:51:42 +05309646 goto err_wdclose;
Amar Singhal0a402232013-10-11 20:57:16 -07009647 }
9648
9649 status = vos_init_wiphy_from_nv_bin();
9650 if (!VOS_IS_STATUS_SUCCESS(status))
9651 {
9652 /* NV module cannot be initialized */
9653 hddLog( VOS_TRACE_LEVEL_FATAL,
9654 "%s: vos_init_wiphy failed", __func__);
9655 goto err_vos_nv_close;
9656 }
9657
Amar Singhala49cbc52013-10-08 18:37:44 -07009658#endif
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05309659 vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats);
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +05309660 status = vos_open( &pVosContext, pHddCtx->parent_dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 if ( !VOS_IS_STATUS_SUCCESS( status ))
9662 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009663 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05309664 goto err_vos_nv_close;
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 }
9666
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext );
9668
9669 if ( NULL == pHddCtx->hHal )
9670 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009671 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 goto err_vosclose;
9673 }
9674
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009675 status = vos_preStart( pHddCtx->pvosContext );
9676 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9677 {
9678 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309679 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009680 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009681
Arif Hussaineaf68602013-12-30 23:10:44 -08009682 if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan)
9683 {
9684 pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan;
9685 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d",
9686 __func__, enable_dfs_chan_scan);
9687 }
9688 if (0 == enable_11d || 1 == enable_11d)
9689 {
9690 pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d;
9691 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d",
9692 __func__, enable_11d);
9693 }
9694
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009695 /* Note that the vos_preStart() sequence triggers the cfg download.
9696 The cfg download must occur before we update the SME config
9697 since the SME config operation must access the cfg database */
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 status = hdd_set_sme_config( pHddCtx );
9699
9700 if ( VOS_STATUS_SUCCESS != status )
9701 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009702 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309703 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009705
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 /* In the integrated architecture we update the configuration from
9707 the INI file and from NV before vOSS has been started so that
9708 the final contents are available to send down to the cCPU */
9709
9710 // Apply the cfg.ini to cfg.dat
9711 if (FALSE == hdd_update_config_dat(pHddCtx))
9712 {
9713 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309714 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 }
9716
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309717 // Get mac addr from platform driver
9718 ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes);
9719
9720 if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309722 /* Store the mac addr for first interface */
9723 pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr;
9724
9725 hddLog(VOS_TRACE_LEVEL_ERROR,
9726 "%s: WLAN Mac Addr: "
9727 MAC_ADDRESS_STR, __func__,
9728 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
9729
9730 /* Here, passing Arg2 as 1 because we do not want to change the
9731 last 3 bytes (means non OUI bytes) of first interface mac
9732 addr.
9733 */
9734 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr))
9735 {
9736 hddLog(VOS_TRACE_LEVEL_ERROR,
9737 "%s: Failed to generate wlan interface mac addr "
9738 "using MAC from ini file ", __func__);
9739 }
9740 }
9741 else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx))
9742 {
9743 // Apply the NV to cfg.dat
9744 /* Prima Update MAC address only at here */
Jeff Johnson295189b2012-06-20 16:38:30 -07009745#ifdef WLAN_AUTOGEN_MACADDR_FEATURE
9746 /* There was not a valid set of MAC Addresses in NV. See if the
9747 default addresses were modified by the cfg.ini settings. If so,
9748 we'll use them, but if not, we'll autogenerate a set of MAC
9749 addresses based upon the device serial number */
9750
9751 static const v_MACADDR_t default_address =
9752 {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}};
Jeff Johnson295189b2012-06-20 16:38:30 -07009753
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309754 if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0],
9755 sizeof(default_address)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 {
9757 /* cfg.ini has the default address, invoke autogen logic */
9758
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309759 /* Here, passing Arg2 as 0 because we want to change the
9760 last 3 bytes (means non OUI bytes) of all the interfaces
9761 mac addr.
9762 */
9763 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0,
9764 default_address))
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309766 hddLog(VOS_TRACE_LEVEL_ERROR,
9767 "%s: Failed to generate wlan interface mac addr "
9768 "using MAC from ini file " MAC_ADDRESS_STR, __func__,
9769 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 }
9772 else
9773#endif //WLAN_AUTOGEN_MACADDR_FEATURE
9774 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009775 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 "%s: Invalid MAC address in NV, using MAC from ini file "
9777 MAC_ADDRESS_STR, __func__,
9778 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
9779 }
9780 }
9781 {
9782 eHalStatus halStatus;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309783
9784 /* Set the MAC Address Currently this is used by HAL to
9785 * add self sta. Remove this once self sta is added as
9786 * part of session open.
9787 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID,
9789 (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0],
9790 sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) );
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309791
Jeff Johnson295189b2012-06-20 16:38:30 -07009792 if (!HAL_STATUS_SUCCESS( halStatus ))
9793 {
9794 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. "
9795 "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309796 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 }
9798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009799
9800 /*Start VOSS which starts up the SME/MAC/HAL modules and everything else
9801 Note: Firmware image will be read and downloaded inside vos_start API */
9802 status = vos_start( pHddCtx->pvosContext );
9803 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9804 {
9805 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309806 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 }
9808
Leo Chang6cec3e22014-01-21 15:33:49 -08009809#ifdef FEATURE_WLAN_CH_AVOID
9810 /* Plug in avoid channel notification callback
9811 * This should happen before ADD_SELF_STA
9812 * FW will send first IND with ADD_SELF_STA REQ from host */
Pradeep Reddy POTTETI5c2e16d2014-06-27 16:47:38 +05309813
9814 /* check the Channel Avoidance is enabled */
9815 if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance)
9816 {
9817 sme_AddChAvoidCallback(pHddCtx->hHal,
9818 hdd_hostapd_ch_avoid_cb);
9819 }
Leo Chang6cec3e22014-01-21 15:33:49 -08009820#endif /* FEATURE_WLAN_CH_AVOID */
9821
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009822 /* Exchange capability info between Host and FW and also get versioning info from FW */
9823 hdd_exchange_version_and_caps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07009824
Agarwal Ashishad9281b2014-06-10 14:57:30 +05309825#ifdef CONFIG_ENABLE_LINUX_REG
9826 status = wlan_hdd_init_channels(pHddCtx);
9827 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9828 {
9829 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed",
9830 __func__);
9831 goto err_vosstop;
9832 }
9833#endif
9834
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 status = hdd_post_voss_start_config( pHddCtx );
9836 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9837 {
9838 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed",
9839 __func__);
9840 goto err_vosstop;
9841 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009842
9843#ifndef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309844 wlan_hdd_cfg80211_update_reg_info( wiphy );
9845
9846 /* registration of wiphy dev with cfg80211 */
9847 if (0 > wlan_hdd_cfg80211_register(wiphy))
9848 {
9849 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9850 goto err_vosstop;
9851 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009853
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309854#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309855 /* registration of wiphy dev with cfg80211 */
9856 if (0 > wlan_hdd_cfg80211_register(wiphy))
9857 {
9858 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9859 goto err_vosstop;
9860 }
9861
Agarwal Ashish6db9d532014-09-30 18:19:10 +05309862 status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309863 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9864 {
9865 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed",
9866 __func__);
9867 goto err_unregister_wiphy;
9868 }
9869#endif
9870
c_hpothu4a298be2014-12-22 21:12:51 +05309871 wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx);
9872
Jeff Johnson295189b2012-06-20 16:38:30 -07009873 if (VOS_STA_SAP_MODE == hdd_get_conparam())
9874 {
9875 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d",
9876 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9877 }
9878 else
9879 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d",
9881 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9882 if (pAdapter != NULL)
9883 {
Katya Nigama7d81d72014-11-12 12:44:34 +05309884 if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && !(pHddCtx->cfg_ini->intfMacAddr[0].bytes[0] & 0x02))
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309886 vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes,
9887 pHddCtx->cfg_ini->intfMacAddr[0].bytes,
9888 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudiedfc1b72012-10-18 20:25:55 -07009889
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309890 /* Generate the P2P Device Address. This consists of the device's
9891 * primary MAC address with the locally administered bit set.
9892 */
9893 pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02;
Jeff Johnsone7245742012-09-05 17:12:55 -07009894 }
9895 else
9896 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309897 tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx);
9898 if (p2p_dev_addr != NULL)
9899 {
9900 vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0],
9901 p2p_dev_addr, VOS_MAC_ADDR_SIZE);
9902 }
9903 else
9904 {
9905 hddLog(VOS_TRACE_LEVEL_FATAL,
9906 "%s: Failed to allocate mac_address for p2p_device",
9907 __func__);
9908 goto err_close_adapter;
9909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009911
9912 pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d",
9913 &pHddCtx->p2pDeviceAddress.bytes[0], FALSE );
9914 if ( NULL == pP2pAdapter )
9915 {
9916 hddLog(VOS_TRACE_LEVEL_FATAL,
9917 "%s: Failed to do hdd_open_adapter for P2P Device Interface",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009918 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009919 goto err_close_adapter;
9920 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009923
9924 if( pAdapter == NULL )
9925 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9927 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009929
Arif Hussain66559122013-11-21 10:11:40 -08009930 if (country_code)
9931 {
9932 eHalStatus ret;
Arif Hussaincb607082013-12-20 11:57:42 -08009933 INIT_COMPLETION(pAdapter->change_country_code);
Arif Hussain66559122013-11-21 10:11:40 -08009934 hdd_checkandupdate_dfssetting(pAdapter, country_code);
9935#ifndef CONFIG_ENABLE_LINUX_REG
9936 hdd_checkandupdate_phymode(pAdapter, country_code);
9937#endif
Arif Hussaineaf68602013-12-30 23:10:44 -08009938 ret = sme_ChangeCountryCode(pHddCtx->hHal,
9939 (void *)(tSmeChangeCountryCallback)
9940 wlan_hdd_change_country_code_callback,
Arif Hussain66559122013-11-21 10:11:40 -08009941 country_code,
9942 pAdapter, pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05309943 eSIR_TRUE, eSIR_TRUE);
Arif Hussain66559122013-11-21 10:11:40 -08009944 if (eHAL_STATUS_SUCCESS == ret)
9945 {
Arif Hussaincb607082013-12-20 11:57:42 -08009946 ret = wait_for_completion_interruptible_timeout(
9947 &pAdapter->change_country_code,
9948 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
9949
9950 if (0 >= ret)
9951 {
9952 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9953 "%s: SME while setting country code timed out", __func__);
9954 }
Arif Hussain66559122013-11-21 10:11:40 -08009955 }
9956 else
9957 {
Arif Hussaincb607082013-12-20 11:57:42 -08009958 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9959 "%s: SME Change Country code from module param fail ret=%d",
9960 __func__, ret);
Arif Hussain66559122013-11-21 10:11:40 -08009961 }
9962 }
9963
Jeff Johnson295189b2012-06-20 16:38:30 -07009964#ifdef WLAN_BTAMP_FEATURE
9965 vStatus = WLANBAP_Open(pVosContext);
9966 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9967 {
9968 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9969 "%s: Failed to open BAP",__func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009970 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009971 }
9972
9973 vStatus = BSL_Init(pVosContext);
9974 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9975 {
9976 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9977 "%s: Failed to Init BSL",__func__);
9978 goto err_bap_close;
9979 }
9980 vStatus = WLANBAP_Start(pVosContext);
9981 if (!VOS_IS_STATUS_SUCCESS(vStatus))
9982 {
9983 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9984 "%s: Failed to start TL",__func__);
9985 goto err_bap_close;
9986 }
9987
9988 pConfig = pHddCtx->cfg_ini;
9989 btAmpConfig.ucPreferredChannel = pConfig->preferredChannel;
9990 status = WLANBAP_SetConfig(&btAmpConfig);
9991
9992#endif //WLAN_BTAMP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -07009993
Mihir Shete9c238772014-10-15 14:35:16 +05309994 /*
9995 * UapsdMask is 0xf if U-APSD is enbaled for all AC's...
9996 * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value)
9997 * which is greater than 0xf. So the below check is safe to make
9998 * sure that there is no entry for UapsdMask in the ini
9999 */
10000 if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask)
10001 {
10002 if(IS_DYNAMIC_WMM_PS_ENABLED)
10003 {
10004 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO",
10005 __func__);
10006 pHddCtx->cfg_ini->UapsdMask =
10007 CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT;
10008 }
10009 else
10010 {
10011 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD",
10012 __func__);
10013 pHddCtx->cfg_ini->UapsdMask =
10014 CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT;
10015 }
10016 }
10017
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010018#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10019 if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE))
10020 {
10021 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__);
10022 pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0;
10023 sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal),
10024 pHddCtx->cfg_ini->isRoamOffloadScanEnabled);
10025 }
10026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010027
Agarwal Ashish4b87f922014-06-18 03:03:21 +053010028 wlan_hdd_tdls_init(pHddCtx);
10029
Mihir Shetefc7ff5b2014-01-27 11:30:05 +053010030 sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done);
10031
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 /* Register with platform driver as client for Suspend/Resume */
10033 status = hddRegisterPmOps(pHddCtx);
10034 if ( !VOS_IS_STATUS_SUCCESS( status ) )
10035 {
10036 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__);
10037#ifdef WLAN_BTAMP_FEATURE
10038 goto err_bap_stop;
10039#else
Jeff Johnsone7245742012-09-05 17:12:55 -070010040 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -070010041#endif //WLAN_BTAMP_FEATURE
10042 }
10043
Yue Ma0d4891e2013-08-06 17:01:45 -070010044 /* Open debugfs interface */
10045 if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter))
10046 {
10047 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
10048 "%s: hdd_debugfs_init failed!", __func__);
Yue Ma0d4891e2013-08-06 17:01:45 -070010049 }
10050
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 /* Register TM level change handler function to the platform */
10052 status = hddDevTmRegisterNotifyCallback(pHddCtx);
10053 if ( !VOS_IS_STATUS_SUCCESS( status ) )
10054 {
10055 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__);
10056 goto err_unregister_pmops;
10057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010058
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 // register net device notifier for device change notification
10060 ret = register_netdevice_notifier(&hdd_netdev_notifier);
10061
10062 if(ret < 0)
10063 {
10064 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__);
Siddharth Bhalcd92b782015-06-29 12:25:40 +053010065 goto err_unregister_pmops;
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 }
10067
10068 //Initialize the nlink service
10069 if(nl_srv_init() != 0)
10070 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010071 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 goto err_reg_netdev;
10073 }
10074
Leo Chang4ce1cc52013-10-21 18:27:15 -070010075#ifdef WLAN_KD_READY_NOTIFIER
10076 pHddCtx->kd_nl_init = 1;
10077#endif /* WLAN_KD_READY_NOTIFIER */
10078
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 //Initialize the BTC service
10080 if(btc_activate_service(pHddCtx) != 0)
10081 {
10082 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__);
10083 goto err_nl_srv;
10084 }
10085
10086#ifdef PTT_SOCK_SVC_ENABLE
10087 //Initialize the PTT service
10088 if(ptt_sock_activate_svc(pHddCtx) != 0)
10089 {
10090 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__);
10091 goto err_nl_srv;
10092 }
10093#endif
10094
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010095#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10096 if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable)
10097 {
Deepthi Gowri78083a32014-11-04 12:55:51 +053010098 if(wlan_logging_sock_activate_svc(
10099 pHddCtx->cfg_ini->wlanLoggingFEToConsole,
10100 pHddCtx->cfg_ini->wlanLoggingNumBuf))
10101 {
10102 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc"
10103 " failed", __func__);
10104 goto err_nl_srv;
10105 }
10106 //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for
10107 //EAPOL and DHCP
Sachin Ahuja8c65f382014-12-12 15:34:21 +053010108 if (!pHddCtx->cfg_ini->gEnableDebugLog)
10109 pHddCtx->cfg_ini->gEnableDebugLog =
10110 VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP;
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010111 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010112
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010113 if (pHddCtx->cfg_ini->wlanLoggingEnable &&
10114 (pHddCtx->cfg_ini->enableFWLogging ||
Siddharth Bhaldb963232015-06-25 19:34:35 +053010115 pHddCtx->cfg_ini->enableMgmtLogging ||
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010116 pHddCtx->cfg_ini->enableContFWLogging))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010117 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010118 hdd_init_frame_logging(pHddCtx);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010119 }
10120 else
10121 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010122 hddLog(VOS_TRACE_LEVEL_INFO, FL("Logging disabled in ini"));
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010123 }
10124
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010125#endif
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010126
10127
Sushant Kaushik215778f2015-05-21 14:05:36 +053010128 if (vos_is_multicast_logging())
10129 wlan_logging_set_log_level();
10130
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 hdd_register_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 if (VOS_STA_SAP_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -070010134 /* Action frame registered in one adapter which will
10135 * applicable to all interfaces
10136 */
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +053010137 wlan_hdd_cfg80211_register_frames(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010139
10140 mutex_init(&pHddCtx->sap_lock);
Mahesh A Saptasagar60627942014-10-13 13:55:14 +053010141 mutex_init(&pHddCtx->roc_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -070010142
Jeff Johnsone7245742012-09-05 17:12:55 -070010143#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
10144 /* Initialize the wake lcok */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010145 vos_wake_lock_init(&pHddCtx->rx_wake_lock,
Jeff Johnsone7245742012-09-05 17:12:55 -070010146 "qcom_rx_wakelock");
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010147
Jeff Johnsone7245742012-09-05 17:12:55 -070010148#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -080010149 /* Initialize the wake lcok */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010150 vos_wake_lock_init(&pHddCtx->sap_wake_lock,
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -080010151 "qcom_sap_wakelock");
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010152
Jeff Johnsone7245742012-09-05 17:12:55 -070010153
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010154 vos_event_init(&pHddCtx->scan_info.scan_finished_event);
10155 pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010156
Katya Nigam5c306ea2014-06-19 15:39:54 +053010157 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010159 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Katya Nigam5c306ea2014-06-19 15:39:54 +053010160
10161#ifdef FEATURE_WLAN_SCAN_PNO
10162 /*SME must send channel update configuration to RIVA*/
10163 sme_UpdateChannelConfig(pHddCtx->hHal);
10164#endif
Abhishek Singhf644b272014-08-21 02:59:39 +053010165 /* Send the update default channel list to the FW*/
10166 sme_UpdateChannelList(pHddCtx->hHal);
Mukul Sharma45063942015-04-01 20:07:59 +053010167
10168 /* Fwr capabilities received, Set the Dot11 mode */
10169 sme_SetDefDot11Mode(pHddCtx->hHal);
10170
Abhishek Singha306a442013-11-07 18:39:01 +053010171#ifndef CONFIG_ENABLE_LINUX_REG
10172 /*updating wiphy so that regulatory user hints can be processed*/
10173 if (wiphy)
10174 {
10175 regulatory_hint(wiphy, "00");
10176 }
10177#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010178 // Initialize the restart logic
10179 wlan_hdd_restart_init(pHddCtx);
Chilam NG571c65a2013-01-19 12:27:36 +053010180
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -070010181 //Register the traffic monitor timer now
10182 if ( pHddCtx->cfg_ini->dynSplitscan)
10183 {
10184 vos_timer_init(&pHddCtx->tx_rx_trafficTmr,
10185 VOS_TIMER_TYPE_SW,
10186 hdd_tx_rx_pkt_cnt_stat_timer_handler,
10187 (void *)pHddCtx);
10188 }
Srinivas Dasari030bad32015-02-18 23:23:54 +053010189 wlan_hdd_cfg80211_nan_init(pHddCtx);
10190
Dino Mycle6fb96c12014-06-10 11:52:40 +053010191#ifdef WLAN_FEATURE_EXTSCAN
10192 sme_EXTScanRegisterCallback(pHddCtx->hHal,
10193 wlan_hdd_cfg80211_extscan_callback,
10194 pHddCtx);
10195#endif /* WLAN_FEATURE_EXTSCAN */
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +053010196
10197#ifdef WLAN_NS_OFFLOAD
10198 // Register IPv6 notifier to notify if any change in IP
10199 // So that we can reconfigure the offload parameters
10200 pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed;
10201 ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier);
10202 if (ret)
10203 {
10204 hddLog(LOGE, FL("Failed to register IPv6 notifier"));
10205 }
10206 else
10207 {
10208 hddLog(LOGE, FL("Registered IPv6 notifier"));
10209 }
10210#endif
10211
10212 // Register IPv4 notifier to notify if any change in IP
10213 // So that we can reconfigure the offload parameters
10214 pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed;
10215 ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier);
10216 if (ret)
10217 {
10218 hddLog(LOGE, FL("Failed to register IPv4 notifier"));
10219 }
10220 else
10221 {
10222 hddLog(LOGE, FL("Registered IPv4 notifier"));
10223 }
10224
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 goto success;
10226
10227err_nl_srv:
Leo Chang59cdc7e2013-07-10 10:08:21 -070010228#ifdef WLAN_KD_READY_NOTIFIER
10229 nl_srv_exit(pHddCtx->ptt_pid);
10230#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -070010232#endif /* WLAN_KD_READY_NOTIFIER */
Jeff Johnson295189b2012-06-20 16:38:30 -070010233err_reg_netdev:
10234 unregister_netdevice_notifier(&hdd_netdev_notifier);
10235
Jeff Johnson295189b2012-06-20 16:38:30 -070010236err_unregister_pmops:
10237 hddDevTmUnregisterNotifyCallback(pHddCtx);
10238 hddDeregisterPmOps(pHddCtx);
10239
Yue Ma0d4891e2013-08-06 17:01:45 -070010240 hdd_debugfs_exit(pHddCtx);
10241
Jeff Johnson295189b2012-06-20 16:38:30 -070010242#ifdef WLAN_BTAMP_FEATURE
10243err_bap_stop:
10244 WLANBAP_Stop(pVosContext);
10245#endif
10246
10247#ifdef WLAN_BTAMP_FEATURE
10248err_bap_close:
10249 WLANBAP_Close(pVosContext);
10250#endif
10251
Jeff Johnson295189b2012-06-20 16:38:30 -070010252err_close_adapter:
10253 hdd_close_all_adapters( pHddCtx );
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +053010254#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053010255err_unregister_wiphy:
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +053010256#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010257 wiphy_unregister(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070010258err_vosstop:
10259 vos_stop(pVosContext);
10260
Amar Singhala49cbc52013-10-08 18:37:44 -070010261err_vosclose:
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 status = vos_sched_close( pVosContext );
10263 if (!VOS_IS_STATUS_SUCCESS(status)) {
10264 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
10265 "%s: Failed to close VOSS Scheduler", __func__);
10266 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
10267 }
Amar Singhala49cbc52013-10-08 18:37:44 -070010268 vos_close(pVosContext );
10269
Amar Singhal0a402232013-10-11 20:57:16 -070010270err_vos_nv_close:
10271
c_hpothue6a36282014-03-19 12:27:38 +053010272#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -070010273 vos_nv_close();
10274
c_hpothu70f8d812014-03-22 22:59:23 +053010275#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010276
10277err_wdclose:
10278 if(pHddCtx->cfg_ini->fIsLogpEnabled)
10279 vos_watchdog_close(pVosContext);
10280
Jeff Johnson295189b2012-06-20 16:38:30 -070010281err_config:
10282 kfree(pHddCtx->cfg_ini);
10283 pHddCtx->cfg_ini= NULL;
10284
10285err_free_hdd_context:
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010286 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Siddharth Bhalcd92b782015-06-29 12:25:40 +053010287 free_riva_power_on_lock("wlan");
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 wiphy_free(wiphy) ;
10289 //kfree(wdev) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070010290 VOS_BUG(1);
10291
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -080010292 if (hdd_is_ssr_required())
10293 {
10294 /* WDI timeout had happened during load, so SSR is needed here */
10295 subsystem_restart("wcnss");
10296 msleep(5000);
10297 }
10298 hdd_set_ssr_required (VOS_FALSE);
10299
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080010300 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010301
10302success:
10303 EXIT();
10304 return 0;
10305}
10306
10307/**---------------------------------------------------------------------------
10308
Jeff Johnson32d95a32012-09-10 13:15:23 -070010309 \brief hdd_driver_init() - Core Driver Init Function
Jeff Johnson295189b2012-06-20 16:38:30 -070010310
Jeff Johnson32d95a32012-09-10 13:15:23 -070010311 This is the driver entry point - called in different timeline depending
10312 on whether the driver is statically or dynamically linked
Jeff Johnson295189b2012-06-20 16:38:30 -070010313
10314 \param - None
10315
10316 \return - 0 for success, non zero for failure
10317
10318 --------------------------------------------------------------------------*/
Jeff Johnson32d95a32012-09-10 13:15:23 -070010319static int hdd_driver_init( void)
Jeff Johnson295189b2012-06-20 16:38:30 -070010320{
10321 VOS_STATUS status;
10322 v_CONTEXT_t pVosContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 struct device *dev = NULL;
10324 int ret_status = 0;
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010325#ifdef HAVE_WCNSS_CAL_DOWNLOAD
10326 int max_retries = 0;
10327#endif
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010328#ifdef HAVE_CBC_DONE
10329 int max_cbc_retries = 0;
10330#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010331
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010332#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10333 wlan_logging_sock_init_svc();
10334#endif
10335
Jeff Johnson295189b2012-06-20 16:38:30 -070010336 ENTER();
10337
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010338 vos_wake_lock_init(&wlan_wake_lock, "wlan");
Jeff Johnson295189b2012-06-20 16:38:30 -070010339
10340 pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME,
10341 QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR);
10342
Jeff Johnson295189b2012-06-20 16:38:30 -070010343#ifdef ANI_BUS_TYPE_PCI
10344
10345 dev = wcnss_wlan_get_device();
10346
10347#endif // ANI_BUS_TYPE_PCI
10348
10349#ifdef ANI_BUS_TYPE_PLATFORM
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010350
10351#ifdef HAVE_WCNSS_CAL_DOWNLOAD
10352 /* wait until WCNSS driver downloads NV */
10353 while (!wcnss_device_ready() && 5 >= ++max_retries) {
10354 msleep(1000);
10355 }
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010356
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010357 if (max_retries >= 5) {
10358 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__);
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010359 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010360#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10361 wlan_logging_sock_deinit_svc();
10362#endif
10363
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010364 return -ENODEV;
10365 }
10366#endif
10367
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010368#ifdef HAVE_CBC_DONE
10369 while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) {
10370 msleep(1000);
10371 }
10372 if (max_cbc_retries >= 10) {
10373 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__);
10374 }
10375#endif
10376
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 dev = wcnss_wlan_get_device();
10378#endif // ANI_BUS_TYPE_PLATFORM
10379
10380
10381 do {
10382 if (NULL == dev) {
10383 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__);
10384 ret_status = -1;
10385 break;
10386 }
10387
Jeff Johnson295189b2012-06-20 16:38:30 -070010388#ifdef TIMER_MANAGER
10389 vos_timer_manager_init();
10390#endif
10391
10392 /* Preopen VOSS so that it is ready to start at least SAL */
10393 status = vos_preOpen(&pVosContext);
10394
10395 if (!VOS_IS_STATUS_SUCCESS(status))
10396 {
10397 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__);
10398 ret_status = -1;
10399 break;
10400 }
10401
Sushant Kaushik02beb352015-06-04 15:15:01 +053010402 hddTraceInit();
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010403#ifndef MODULE
10404 /* For statically linked driver, call hdd_set_conparam to update curr_con_mode
10405 */
10406 hdd_set_conparam((v_UINT_t)con_mode);
10407#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010408
10409 // Call our main init function
Jeff Johnsonbc676b42013-02-14 16:04:08 -080010410 if (hdd_wlan_startup(dev))
10411 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed",
Jeff Johnsonbc676b42013-02-14 16:04:08 -080010413 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 vos_preClose( &pVosContext );
10415 ret_status = -1;
10416 break;
10417 }
10418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 } while (0);
10420
10421 if (0 != ret_status)
10422 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010423#ifdef TIMER_MANAGER
10424 vos_timer_exit();
10425#endif
10426#ifdef MEMORY_DEBUG
10427 vos_mem_exit();
10428#endif
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010429 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010430#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10431 wlan_logging_sock_deinit_svc();
10432#endif
10433
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 pr_err("%s: driver load failure\n", WLAN_MODULE_NAME);
10435 }
10436 else
10437 {
10438 //Send WLAN UP indication to Nlink Service
10439 send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0);
10440
10441 pr_info("%s: driver loaded\n", WLAN_MODULE_NAME);
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 }
10443
10444 EXIT();
10445
10446 return ret_status;
10447}
10448
Jeff Johnson32d95a32012-09-10 13:15:23 -070010449/**---------------------------------------------------------------------------
10450
10451 \brief hdd_module_init() - Init Function
10452
10453 This is the driver entry point (invoked when module is loaded using insmod)
10454
10455 \param - None
10456
10457 \return - 0 for success, non zero for failure
10458
10459 --------------------------------------------------------------------------*/
10460#ifdef MODULE
10461static int __init hdd_module_init ( void)
10462{
10463 return hdd_driver_init();
10464}
Jeff Johnson32d95a32012-09-10 13:15:23 -070010465#else /* #ifdef MODULE */
10466static int __init hdd_module_init ( void)
10467{
10468 /* Driver initialization is delayed to fwpath_changed_handler */
10469 return 0;
10470}
Jeff Johnson32d95a32012-09-10 13:15:23 -070010471#endif /* #ifdef MODULE */
10472
Jeff Johnson295189b2012-06-20 16:38:30 -070010473
10474/**---------------------------------------------------------------------------
10475
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010476 \brief hdd_driver_exit() - Exit function
Jeff Johnson295189b2012-06-20 16:38:30 -070010477
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010478 This is the driver exit point (invoked when module is unloaded using rmmod
10479 or con_mode was changed by userspace)
Jeff Johnson295189b2012-06-20 16:38:30 -070010480
10481 \param - None
10482
10483 \return - None
10484
10485 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010486static void hdd_driver_exit(void)
Jeff Johnson295189b2012-06-20 16:38:30 -070010487{
10488 hdd_context_t *pHddCtx = NULL;
10489 v_CONTEXT_t pVosContext = NULL;
Agarwal Ashish5e414792014-06-08 15:25:23 +053010490 v_REGDOMAIN_t regId;
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +053010491 unsigned long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010492
10493 pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR);
10494
10495 //Get the global vos context
10496 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
10497
10498 if(!pVosContext)
10499 {
10500 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
10501 goto done;
10502 }
10503
10504 //Get the HDD context.
10505 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
10506
10507 if(!pHddCtx)
10508 {
10509 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__);
10510 }
Katya Nigame7b69a82015-04-28 15:24:06 +053010511 else if (VOS_MONITOR_MODE == hdd_get_conparam())
10512 {
10513 hddLog(VOS_TRACE_LEVEL_INFO,"%s: MONITOR MODE",__func__);
10514 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
10515 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
10516 hdd_wlan_exit(pHddCtx);
10517 vos_preClose( &pVosContext );
10518 goto done;
10519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 else
10521 {
Siddharth Bhal2e5871b2015-03-24 16:20:51 +053010522 /* We wait for active entry threads to exit from driver
10523 * by waiting until rtnl_lock is available.
10524 */
10525 rtnl_lock();
10526 rtnl_unlock();
10527
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010528 INIT_COMPLETION(pHddCtx->ssr_comp_var);
10529 if ((pHddCtx->isLogpInProgress) && (FALSE ==
10530 vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL)))
10531 {
Siddharth Bhala204f572015-01-17 02:03:36 +053010532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010533 "%s:SSR in Progress; block rmmod !!!", __func__);
Siddharth Bhala204f572015-01-17 02:03:36 +053010534 rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var,
10535 msecs_to_jiffies(30000));
10536 if(!rc)
10537 {
10538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10539 "%s:SSR timedout, fatal error", __func__);
10540 VOS_BUG(0);
10541 }
10542 }
10543
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010544 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
10545 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010546
c_hpothu8adb97b2014-12-08 19:38:20 +053010547 /* Driver Need to send country code 00 in below condition
10548 * 1) If gCountryCodePriority is set to 1; and last country
10549 * code set is through 11d. This needs to be done in case
10550 * when NV country code is 00.
10551 * This Needs to be done as when kernel store last country
10552 * code and if stored country code is not through 11d,
10553 * in sme_HandleChangeCountryCodeByUser we will disable 11d
10554 * in next load/unload as soon as we get any country through
10555 * 11d. In sme_HandleChangeCountryCodeByUser
10556 * pMsg->countryCode will be last countryCode and
10557 * pMac->scan.countryCode11d will be country through 11d so
10558 * due to mismatch driver will disable 11d.
10559 *
10560 */
Agarwal Ashish8db39882014-07-30 21:56:07 +053010561
c_hpothu8adb97b2014-12-08 19:38:20 +053010562 if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) &&
Agarwal Ashish8dcd2862014-07-25 11:58:52 +053010563 pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority &&
Abhishek Singh2a705962014-10-30 14:47:28 +053010564 sme_Is11dSupported(pHddCtx->hHal)))
c_hpothu8adb97b2014-12-08 19:38:20 +053010565 {
10566 hddLog(VOS_TRACE_LEVEL_INFO,
Agarwal Ashish8dcd2862014-07-25 11:58:52 +053010567 FL("CountryCode 00 is being set while unloading driver"));
c_hpothu8adb97b2014-12-08 19:38:20 +053010568 vos_nv_getRegDomainFromCountryCode(&regId , "00", COUNTRY_USER);
10569 }
Agarwal Ashish5e414792014-06-08 15:25:23 +053010570
c_hpothu8adb97b2014-12-08 19:38:20 +053010571 //Do all the cleanup before deregistering the driver
10572 hdd_wlan_exit(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 }
10574
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 vos_preClose( &pVosContext );
10576
10577#ifdef TIMER_MANAGER
10578 vos_timer_exit();
10579#endif
10580#ifdef MEMORY_DEBUG
10581 vos_mem_exit();
10582#endif
10583
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010584#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10585 wlan_logging_sock_deinit_svc();
10586#endif
10587
Jeff Johnson295189b2012-06-20 16:38:30 -070010588done:
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010589 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010590
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME);
10592}
10593
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010594/**---------------------------------------------------------------------------
10595
10596 \brief hdd_module_exit() - Exit function
10597
10598 This is the driver exit point (invoked when module is unloaded using rmmod)
10599
10600 \param - None
10601
10602 \return - None
10603
10604 --------------------------------------------------------------------------*/
10605static void __exit hdd_module_exit(void)
10606{
10607 hdd_driver_exit();
10608}
10609
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010610#ifdef MODULE
10611static int fwpath_changed_handler(const char *kmessage,
10612 struct kernel_param *kp)
10613{
Jeff Johnson76052702013-04-16 13:55:05 -070010614 return param_set_copystring(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010615}
10616
10617static int con_mode_handler(const char *kmessage,
10618 struct kernel_param *kp)
10619{
Madan Mohan Koyyalamudif2f8d8b2012-10-11 17:06:59 -070010620 return param_set_int(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010621}
10622#else /* #ifdef MODULE */
10623/**---------------------------------------------------------------------------
10624
Jeff Johnson76052702013-04-16 13:55:05 -070010625 \brief kickstart_driver
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010626
Jeff Johnson76052702013-04-16 13:55:05 -070010627 This is the driver entry point
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010628 - delayed driver initialization when driver is statically linked
Jeff Johnson76052702013-04-16 13:55:05 -070010629 - invoked when module parameter fwpath is modified from userspace to signal
10630 initializing the WLAN driver or when con_mode is modified from userspace
10631 to signal a switch in operating mode
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010632
10633 \return - 0 for success, non zero for failure
10634
10635 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -070010636static int kickstart_driver(void)
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010637{
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010638 int ret_status;
10639
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010640 if (!wlan_hdd_inited) {
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010641 ret_status = hdd_driver_init();
10642 wlan_hdd_inited = ret_status ? 0 : 1;
10643 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010644 }
10645
10646 hdd_driver_exit();
Jeff Johnson76052702013-04-16 13:55:05 -070010647
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010648 msleep(200);
Jeff Johnson76052702013-04-16 13:55:05 -070010649
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010650 ret_status = hdd_driver_init();
10651 wlan_hdd_inited = ret_status ? 0 : 1;
10652 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010653}
10654
Jeff Johnson295189b2012-06-20 16:38:30 -070010655/**---------------------------------------------------------------------------
10656
Jeff Johnson76052702013-04-16 13:55:05 -070010657 \brief fwpath_changed_handler() - Handler Function
10658
10659 Handle changes to the fwpath parameter
10660
10661 \return - 0 for success, non zero for failure
10662
10663 --------------------------------------------------------------------------*/
10664static int fwpath_changed_handler(const char *kmessage,
10665 struct kernel_param *kp)
10666{
10667 int ret;
10668
10669 ret = param_set_copystring(kmessage, kp);
10670 if (0 == ret)
10671 ret = kickstart_driver();
10672 return ret;
10673}
10674
10675/**---------------------------------------------------------------------------
10676
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010677 \brief con_mode_handler() -
10678
10679 Handler function for module param con_mode when it is changed by userspace
10680 Dynamically linked - do nothing
10681 Statically linked - exit and init driver, as in rmmod and insmod
10682
Jeff Johnson76052702013-04-16 13:55:05 -070010683 \param -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010684
Jeff Johnson76052702013-04-16 13:55:05 -070010685 \return -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010686
10687 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -070010688static int con_mode_handler(const char *kmessage, struct kernel_param *kp)
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010689{
Jeff Johnson76052702013-04-16 13:55:05 -070010690 int ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010691
Jeff Johnson76052702013-04-16 13:55:05 -070010692 ret = param_set_int(kmessage, kp);
10693 if (0 == ret)
10694 ret = kickstart_driver();
10695 return ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010696}
10697#endif /* #ifdef MODULE */
10698
10699/**---------------------------------------------------------------------------
10700
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 \brief hdd_get_conparam() -
10702
10703 This is the driver exit point (invoked when module is unloaded using rmmod)
10704
10705 \param - None
10706
10707 \return - tVOS_CON_MODE
10708
10709 --------------------------------------------------------------------------*/
10710tVOS_CON_MODE hdd_get_conparam ( void )
10711{
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010712#ifdef MODULE
Jeff Johnson295189b2012-06-20 16:38:30 -070010713 return (tVOS_CON_MODE)con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010714#else
10715 return (tVOS_CON_MODE)curr_con_mode;
10716#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010717}
10718void hdd_set_conparam ( v_UINT_t newParam )
10719{
10720 con_mode = newParam;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010721#ifndef MODULE
10722 curr_con_mode = con_mode;
10723#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010724}
10725/**---------------------------------------------------------------------------
10726
10727 \brief hdd_softap_sta_deauth() - function
10728
10729 This to take counter measure to handle deauth req from HDD
10730
10731 \param - pAdapter - Pointer to the HDD
10732
10733 \param - enable - boolean value
10734
10735 \return - None
10736
10737 --------------------------------------------------------------------------*/
10738
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010739VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter,
10740 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070010741{
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010743 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -070010744
10745 ENTER();
10746
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070010747 hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)",
10748 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010749
10750 //Ignore request to deauth bcmc station
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010751 if (pDelStaParams->peerMacAddr[0] & 0x1)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010752 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -070010753
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010754 vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010755
10756 EXIT();
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010757 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -070010758}
10759
10760/**---------------------------------------------------------------------------
10761
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010762 \brief hdd_del_all_sta() - function
10763
10764 This function removes all the stations associated on stopping AP/P2P GO.
10765
10766 \param - pAdapter - Pointer to the HDD
10767
10768 \return - None
10769
10770 --------------------------------------------------------------------------*/
10771
10772int hdd_del_all_sta(hdd_adapter_t *pAdapter)
10773{
10774 v_U16_t i;
10775 VOS_STATUS vos_status;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010776 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10777 ptSapContext pSapCtx = NULL;
10778 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10779 if(pSapCtx == NULL){
10780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10781 FL("psapCtx is NULL"));
10782 return 1;
10783 }
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010784 ENTER();
10785
10786 hddLog(VOS_TRACE_LEVEL_INFO,
10787 "%s: Delete all STAs associated.",__func__);
10788 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10789 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
10790 )
10791 {
10792 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
10793 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010794 if ((pSapCtx->aStaInfo[i].isUsed) &&
10795 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010796 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010797 struct tagCsrDelStaParams delStaParams;
10798
10799 WLANSAP_PopulateDelStaParams(
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010800 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053010801 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
10802 SIR_MAC_MGMT_DEAUTH >> 4,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010803 &delStaParams);
10804 vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams);
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010805 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010806 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010807 }
10808 }
10809 }
10810
10811 EXIT();
10812 return 0;
10813}
10814
10815/**---------------------------------------------------------------------------
10816
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 \brief hdd_softap_sta_disassoc() - function
10818
10819 This to take counter measure to handle deauth req from HDD
10820
10821 \param - pAdapter - Pointer to the HDD
10822
10823 \param - enable - boolean value
10824
10825 \return - None
10826
10827 --------------------------------------------------------------------------*/
10828
10829void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress)
10830{
10831 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10832
10833 ENTER();
10834
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010835 hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010836
10837 //Ignore request to disassoc bcmc station
10838 if( pDestMacAddress[0] & 0x1 )
10839 return;
10840
10841 WLANSAP_DisassocSta(pVosContext,pDestMacAddress);
10842}
10843
10844void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable)
10845{
10846 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10847
10848 ENTER();
10849
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010850 hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010851
10852 WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable);
10853}
10854
Jeff Johnson295189b2012-06-20 16:38:30 -070010855/**---------------------------------------------------------------------------
10856 *
10857 * \brief hdd_get__concurrency_mode() -
10858 *
10859 *
10860 * \param - None
10861 *
10862 * \return - CONCURRENCY MODE
10863 *
10864 * --------------------------------------------------------------------------*/
10865tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void )
10866{
10867 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
10868 hdd_context_t *pHddCtx;
10869
10870 if (NULL != pVosContext)
10871 {
10872 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
10873 if (NULL != pHddCtx)
10874 {
10875 return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode;
10876 }
10877 }
10878
10879 /* we are in an invalid state :( */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010880 hddLog(LOGE, "%s: Invalid context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010881 return VOS_STA;
10882}
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010883v_BOOL_t
10884wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx)
10885{
10886 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010887
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010888 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO);
10889 if (pAdapter == NULL)
10890 {
10891 hddLog(VOS_TRACE_LEVEL_INFO,
10892 FL("GO doesn't exist"));
10893 return TRUE;
10894 }
10895 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10896 {
10897 hddLog(VOS_TRACE_LEVEL_INFO,
10898 FL("GO started"));
10899 return TRUE;
10900 }
10901 else
10902 /* wait till GO changes its interface to p2p device */
10903 hddLog(VOS_TRACE_LEVEL_INFO,
10904 FL("Del_bss called, avoid apps suspend"));
10905 return FALSE;
10906
10907}
Jeff Johnson295189b2012-06-20 16:38:30 -070010908/* Decide whether to allow/not the apps power collapse.
10909 * Allow apps power collapse if we are in connected state.
10910 * if not, allow only if we are in IMPS */
10911v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx)
10912{
10913 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
Srikant Kuppafef66a72013-01-30 17:32:44 -080010914 tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal);
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010915 tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010916 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10917 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10918 hdd_adapter_t *pAdapter = NULL;
10919 VOS_STATUS status;
Yathish9f22e662012-12-10 14:21:35 -080010920 tVOS_CONCURRENCY_MODE concurrent_state = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010921
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 if (VOS_STA_SAP_MODE == hdd_get_conparam())
10923 return TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010924
Yathish9f22e662012-12-10 14:21:35 -080010925 concurrent_state = hdd_get_concurrency_mode();
10926
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010927 if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) &&
10928 !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx)))
10929 return FALSE;
Yathish9f22e662012-12-10 14:21:35 -080010930#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010931
Yathish9f22e662012-12-10 14:21:35 -080010932 if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) ||
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010933 (concurrent_state == (VOS_STA | VOS_P2P_GO)))&&
Yathish9f22e662012-12-10 14:21:35 -080010934 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
10935 return TRUE;
10936#endif
10937
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 /*loop through all adapters. TBD fix for Concurrency */
10939 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10940 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10941 {
10942 pAdapter = pAdapterNode->pAdapter;
10943 if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
10944 || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10945 {
Srikant Kuppafef66a72013-01-30 17:32:44 -080010946 if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled)
c_hpothu4e8faac2014-05-16 17:38:44 +053010947 && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD
c_hpothu1c6957d2015-01-06 18:19:47 +053010948 && pmcState != STOPPED && pmcState != STANDBY &&
10949 pmcState != WOWL)) ||
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010950 (eANI_BOOLEAN_TRUE == scanRspPending) ||
10951 (eANI_BOOLEAN_TRUE == inMiddleOfRoaming))
Jeff Johnson295189b2012-06-20 16:38:30 -070010952 {
Mukul Sharma4be88422015-03-09 20:29:07 +053010953 if(pmcState == FULL_POWER &&
10954 sme_IsCoexScoIndicationSet(pHddCtx->hHal))
10955 {
10956 /*
10957 * When SCO indication comes from Coex module , host will
10958 * enter in to full power mode, but this should not prevent
10959 * apps processor power collapse.
10960 */
10961 hddLog(LOG1,
10962 FL("Allow apps power collapse"
10963 "even when sco indication is set"));
10964 return TRUE;
10965 }
Srikant Kuppafef66a72013-01-30 17:32:44 -080010966 hddLog( LOGE, "%s: do not allow APPS power collapse-"
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010967 "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d",
10968 __func__, pmcState, scanRspPending, inMiddleOfRoaming );
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 return FALSE;
10970 }
10971 }
10972 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10973 pAdapterNode = pNext;
10974 }
10975 return TRUE;
10976}
10977
Madan Mohan Koyyalamudic72a4d62012-11-08 14:59:34 -080010978/* Decides whether to send suspend notification to Riva
10979 * if any adapter is in BMPS; then it is required */
10980v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx)
10981{
10982 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
10983 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10984
10985 if (pConfig->fIsBmpsEnabled && (pmcState == BMPS))
10986 {
10987 return TRUE;
10988 }
10989 return FALSE;
10990}
10991
Jeff Johnson295189b2012-06-20 16:38:30 -070010992void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
10993{
10994 switch(mode)
10995 {
Chilam Ngc4244af2013-04-01 15:37:32 -070010996 case VOS_STA_MODE:
10997 case VOS_P2P_CLIENT_MODE:
10998 case VOS_P2P_GO_MODE:
10999 case VOS_STA_SAP_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -070011000 pHddCtx->concurrency_mode |= (1 << mode);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011001 pHddCtx->no_of_open_sessions[mode]++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 break;
11003 default:
11004 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011005 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011006 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
11007 "Number of open sessions for mode %d = %d"),
11008 pHddCtx->concurrency_mode, mode,
11009 pHddCtx->no_of_open_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070011010}
11011
11012
11013void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11014{
11015 switch(mode)
11016 {
Chilam Ngc4244af2013-04-01 15:37:32 -070011017 case VOS_STA_MODE:
11018 case VOS_P2P_CLIENT_MODE:
11019 case VOS_P2P_GO_MODE:
11020 case VOS_STA_SAP_MODE:
Agarwal Ashish51325b52014-06-16 16:50:49 +053011021 pHddCtx->no_of_open_sessions[mode]--;
11022 if (!(pHddCtx->no_of_open_sessions[mode]))
11023 pHddCtx->concurrency_mode &= (~(1 << mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 break;
11025 default:
11026 break;
11027 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011028 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
11029 "Number of open sessions for mode %d = %d"),
11030 pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]);
11031
11032}
11033/**---------------------------------------------------------------------------
11034 *
11035 * \brief wlan_hdd_incr_active_session()
11036 *
11037 * This function increments the number of active sessions
11038 * maintained per device mode
11039 * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented
11040 * Incase of SAP/P2P GO upon bss start it is incremented
11041 *
11042 * \param pHddCtx - HDD Context
11043 * \param mode - device mode
11044 *
11045 * \return - None
11046 *
11047 * --------------------------------------------------------------------------*/
11048void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11049{
11050 switch (mode) {
11051 case VOS_STA_MODE:
11052 case VOS_P2P_CLIENT_MODE:
11053 case VOS_P2P_GO_MODE:
11054 case VOS_STA_SAP_MODE:
11055 pHddCtx->no_of_active_sessions[mode]++;
11056 break;
11057 default:
11058 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
11059 break;
11060 }
11061 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
11062 mode,
11063 pHddCtx->no_of_active_sessions[mode]);
11064}
11065
11066/**---------------------------------------------------------------------------
11067 *
11068 * \brief wlan_hdd_decr_active_session()
11069 *
11070 * This function decrements the number of active sessions
11071 * maintained per device mode
11072 * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented
11073 * Incase of SAP/P2P GO upon bss stop it is decremented
11074 *
11075 * \param pHddCtx - HDD Context
11076 * \param mode - device mode
11077 *
11078 * \return - None
11079 *
11080 * --------------------------------------------------------------------------*/
11081void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11082{
11083 switch (mode) {
11084 case VOS_STA_MODE:
11085 case VOS_P2P_CLIENT_MODE:
11086 case VOS_P2P_GO_MODE:
11087 case VOS_STA_SAP_MODE:
Agarwal Ashish5325f522014-08-06 00:58:44 +053011088 if (pHddCtx->no_of_active_sessions[mode] > 0)
11089 pHddCtx->no_of_active_sessions[mode]--;
11090 else
11091 hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions"
11092 "is already Zero"));
Agarwal Ashish51325b52014-06-16 16:50:49 +053011093 break;
11094 default:
11095 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
11096 break;
11097 }
11098 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
11099 mode,
11100 pHddCtx->no_of_active_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070011101}
11102
Jeff Johnsone7245742012-09-05 17:12:55 -070011103/**---------------------------------------------------------------------------
11104 *
11105 * \brief wlan_hdd_restart_init
11106 *
11107 * This function initalizes restart timer/flag. An internal function.
11108 *
11109 * \param - pHddCtx
11110 *
11111 * \return - None
11112 *
11113 * --------------------------------------------------------------------------*/
11114
11115static void wlan_hdd_restart_init(hdd_context_t *pHddCtx)
11116{
11117 /* Initialize */
11118 pHddCtx->hdd_restart_retries = 0;
11119 atomic_set(&pHddCtx->isRestartInProgress, 0);
11120 vos_timer_init(&pHddCtx->hdd_restart_timer,
11121 VOS_TIMER_TYPE_SW,
11122 wlan_hdd_restart_timer_cb,
11123 pHddCtx);
11124}
11125/**---------------------------------------------------------------------------
11126 *
11127 * \brief wlan_hdd_restart_deinit
11128 *
11129 * This function cleans up the resources used. An internal function.
11130 *
11131 * \param - pHddCtx
11132 *
11133 * \return - None
11134 *
11135 * --------------------------------------------------------------------------*/
11136
11137static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx)
11138{
11139
11140 VOS_STATUS vos_status;
11141 /* Block any further calls */
11142 atomic_set(&pHddCtx->isRestartInProgress, 1);
11143 /* Cleanup */
11144 vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer );
11145 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011146 hddLog(LOGE, FL("Failed to stop HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011147 vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer);
11148 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011149 hddLog(LOGE, FL("Failed to destroy HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011150
11151}
11152
11153/**---------------------------------------------------------------------------
11154 *
11155 * \brief wlan_hdd_framework_restart
11156 *
11157 * This function uses a cfg80211 API to start a framework initiated WLAN
11158 * driver module unload/load.
11159 *
11160 * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT).
11161 *
11162 *
11163 * \param - pHddCtx
11164 *
11165 * \return - VOS_STATUS_SUCCESS: Success
11166 * VOS_STATUS_E_EMPTY: Adapter is Empty
11167 * VOS_STATUS_E_NOMEM: No memory
11168
11169 * --------------------------------------------------------------------------*/
11170
11171static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx)
11172{
11173 VOS_STATUS status = VOS_STATUS_SUCCESS;
11174 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011175 int len = (sizeof (struct ieee80211_mgmt));
11176 struct ieee80211_mgmt *mgmt = NULL;
11177
11178 /* Prepare the DEAUTH managment frame with reason code */
11179 mgmt = kzalloc(len, GFP_KERNEL);
11180 if(mgmt == NULL)
11181 {
11182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11183 "%s: memory allocation failed (%d bytes)", __func__, len);
11184 return VOS_STATUS_E_NOMEM;
11185 }
11186 mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK;
Jeff Johnsone7245742012-09-05 17:12:55 -070011187
11188 /* Iterate over all adapters/devices */
11189 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011190 if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status))
11191 {
11192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11193 FL("fail to get adapter: %p %d"), pAdapterNode, status);
11194 goto end;
11195 }
11196
Jeff Johnsone7245742012-09-05 17:12:55 -070011197 do
11198 {
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011199 if(pAdapterNode->pAdapter &&
11200 WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic)
Jeff Johnsone7245742012-09-05 17:12:55 -070011201 {
11202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11203 "restarting the driver(intf:\'%s\' mode:%d :try %d)",
11204 pAdapterNode->pAdapter->dev->name,
11205 pAdapterNode->pAdapter->device_mode,
11206 pHddCtx->hdd_restart_retries + 1);
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011207 /*
11208 * CFG80211 event to restart the driver
11209 *
11210 * 'cfg80211_send_unprot_deauth' sends a
11211 * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state
11212 * of SME(Linux Kernel) state machine.
11213 *
11214 * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart
11215 * the driver.
11216 *
11217 */
11218
11219 cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len );
Jeff Johnsone7245742012-09-05 17:12:55 -070011220 }
11221 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11222 pAdapterNode = pNext;
11223 } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status));
11224
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011225 end:
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011226 /* Free the allocated management frame */
11227 kfree(mgmt);
11228
Jeff Johnsone7245742012-09-05 17:12:55 -070011229 /* Retry until we unload or reach max count */
11230 if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT)
11231 vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS);
11232
11233 return status;
11234
11235}
11236/**---------------------------------------------------------------------------
11237 *
11238 * \brief wlan_hdd_restart_timer_cb
11239 *
11240 * Restart timer callback. An internal function.
11241 *
11242 * \param - User data:
11243 *
11244 * \return - None
11245 *
11246 * --------------------------------------------------------------------------*/
11247
11248void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback)
11249{
11250 hdd_context_t *pHddCtx = usrDataForCallback;
11251 wlan_hdd_framework_restart(pHddCtx);
11252 return;
11253
11254}
11255
11256
11257/**---------------------------------------------------------------------------
11258 *
11259 * \brief wlan_hdd_restart_driver
11260 *
11261 * This function sends an event to supplicant to restart the WLAN driver.
11262 *
11263 * This function is called from vos_wlanRestart.
11264 *
11265 * \param - pHddCtx
11266 *
11267 * \return - VOS_STATUS_SUCCESS: Success
11268 * VOS_STATUS_E_EMPTY: Adapter is Empty
11269 * VOS_STATUS_E_ALREADY: Request already in progress
11270
11271 * --------------------------------------------------------------------------*/
11272VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx)
11273{
11274 VOS_STATUS status = VOS_STATUS_SUCCESS;
11275
11276 /* A tight check to make sure reentrancy */
11277 if(atomic_xchg(&pHddCtx->isRestartInProgress, 1))
11278 {
Mihir Shetefd528652014-06-23 19:07:50 +053011279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsone7245742012-09-05 17:12:55 -070011280 "%s: WLAN restart is already in progress", __func__);
11281
11282 return VOS_STATUS_E_ALREADY;
11283 }
Sameer Thalappil0c164f52013-03-28 15:27:56 -070011284 /* Send reset FIQ to WCNSS to invoke SSR. */
Madan Mohan Koyyalamudie388b342012-11-08 15:03:16 -080011285#ifdef HAVE_WCNSS_RESET_INTR
Siddharth Bhal864e7e82015-04-07 20:07:24 +053011286 wcnss_reset_fiq(TRUE);
Madan Mohan Koyyalamudibb8f0172012-09-28 15:36:06 -070011287#endif
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -070011288
Jeff Johnsone7245742012-09-05 17:12:55 -070011289 return status;
11290}
11291
Mihir Shetee1093ba2014-01-21 20:13:32 +053011292/**---------------------------------------------------------------------------
11293 *
11294 * \brief wlan_hdd_init_channels
11295 *
11296 * This function is used to initialize the channel list in CSR
11297 *
11298 * This function is called from hdd_wlan_startup
11299 *
11300 * \param - pHddCtx: HDD context
11301 *
11302 * \return - VOS_STATUS_SUCCESS: Success
11303 * VOS_STATUS_E_FAULT: Failure reported by SME
11304
11305 * --------------------------------------------------------------------------*/
11306static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx)
11307{
11308 eHalStatus status;
11309
11310 status = sme_InitChannels(pHddCtx->hHal);
11311 if (HAL_STATUS_SUCCESS(status))
11312 {
11313 return VOS_STATUS_SUCCESS;
11314 }
11315 else
11316 {
11317 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)",
11318 __func__, status);
11319 return VOS_STATUS_E_FAULT;
11320 }
11321}
11322
Mihir Shete04206452014-11-20 17:50:58 +053011323#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +053011324VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx, driver_load_type init )
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053011325{
11326 eHalStatus status;
11327
Agarwal Ashish6db9d532014-09-30 18:19:10 +053011328 status = sme_InitChannelsForCC(pHddCtx->hHal, init);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053011329 if (HAL_STATUS_SUCCESS(status))
11330 {
11331 return VOS_STATUS_SUCCESS;
11332 }
11333 else
11334 {
11335 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)",
11336 __func__, status);
11337 return VOS_STATUS_E_FAULT;
11338 }
11339}
Mihir Shete04206452014-11-20 17:50:58 +053011340#endif
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -070011341/*
11342 * API to find if there is any STA or P2P-Client is connected
11343 */
11344VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx)
11345{
11346 return sme_isSta_p2p_clientConnected(pHddCtx->hHal);
11347}
Jeff Johnsone7245742012-09-05 17:12:55 -070011348
Mihir Shetee2ae82a2015-03-16 14:08:49 +053011349
11350/*
11351 * API to find if the firmware will send logs using DXE channel
11352 */
11353v_U8_t hdd_is_fw_logging_enabled(void)
11354{
11355 hdd_context_t *pHddCtx;
11356
11357 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD,
11358 vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
11359
Sachin Ahuja084313e2015-05-21 17:57:10 +053011360 return (pHddCtx && pHddCtx->cfg_ini->enableMgmtLogging);
Mihir Shetee2ae82a2015-03-16 14:08:49 +053011361}
11362
Agarwal Ashish57e84372014-12-05 18:26:53 +053011363/*
Mihir Shetebe94ebb2015-05-26 12:07:14 +053011364 * API to find if the firmware will send trace logs using DXE channel
11365 */
11366v_U8_t hdd_is_fw_ev_logging_enabled(void)
11367{
11368 hdd_context_t *pHddCtx;
11369
11370 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD,
11371 vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
11372
11373 return (pHddCtx && pHddCtx->cfg_ini->enableFWLogging);
11374}
11375/*
Agarwal Ashish57e84372014-12-05 18:26:53 +053011376 * API to find if there is any session connected
11377 */
11378VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx)
11379{
11380 return sme_is_any_session_connected(pHddCtx->hHal);
11381}
11382
11383
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011384int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter)
11385{
11386 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11387 hdd_scaninfo_t *pScanInfo = NULL;
Girish Gowli4bf7a632014-06-12 13:42:11 +053011388 long status = 0;
c_hpothua3d45d52015-01-05 14:11:17 +053011389 tSirAbortScanStatus abortScanStatus;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011390
11391 pScanInfo = &pHddCtx->scan_info;
Ratnam Rachuric7681132015-06-30 10:35:13 +053011392 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011393 if (pScanInfo->mScanPending)
11394 {
c_hpothua3d45d52015-01-05 14:11:17 +053011395 abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
11396 eCSR_SCAN_ABORT_DEFAULT);
11397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11398 FL("abortScanStatus: %d"), abortScanStatus);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011399
c_hpothua3d45d52015-01-05 14:11:17 +053011400 /* If there is active scan command lets wait for the completion else
11401 * there is no need to wait as scan command might be in the SME pending
11402 * command list.
11403 */
11404 if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY)
11405 {
c_hpothua3d45d52015-01-05 14:11:17 +053011406 status = wait_for_completion_interruptible_timeout(
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011407 &pScanInfo->abortscan_event_var,
11408 msecs_to_jiffies(5000));
c_hpothua3d45d52015-01-05 14:11:17 +053011409 if (0 >= status)
11410 {
11411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowli4bf7a632014-06-12 13:42:11 +053011412 "%s: Timeout or Interrupt occurred while waiting for abort"
11413 "scan, status- %ld", __func__, status);
c_hpothua3d45d52015-01-05 14:11:17 +053011414 return -ETIMEDOUT;
11415 }
11416 }
11417 else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE)
11418 {
11419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11420 FL("hdd_abort_mac_scan failed"));
11421 return -VOS_STATUS_E_FAILURE;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011422 }
11423 }
Girish Gowli4bf7a632014-06-12 13:42:11 +053011424 return 0;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011425}
11426
c_hpothu225aa7c2014-10-22 17:45:13 +053011427VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx)
11428{
11429 hdd_adapter_t *pAdapter;
11430 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11431 VOS_STATUS vosStatus;
11432
11433 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
11434 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
11435 {
11436 pAdapter = pAdapterNode->pAdapter;
11437 if (NULL != pAdapter)
11438 {
11439 if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ||
11440 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ||
11441 WLAN_HDD_P2P_GO == pAdapter->device_mode)
11442 {
11443 hddLog(LOG1, FL("abort ROC deviceMode: %d"),
11444 pAdapter->device_mode);
11445 if (VOS_STATUS_SUCCESS !=
11446 wlan_hdd_cancel_existing_remain_on_channel(pAdapter))
11447 {
11448 hddLog(LOGE, FL("failed to abort ROC"));
11449 return VOS_STATUS_E_FAILURE;
11450 }
11451 }
11452 }
11453 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11454 pAdapterNode = pNext;
11455 }
11456 return VOS_STATUS_SUCCESS;
11457}
Mahesh A Saptasagard477b092015-02-06 15:12:16 +053011458
Mihir Shete0be28772015-02-17 18:42:14 +053011459hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx)
11460{
11461 hdd_adapter_t *pAdapter;
11462 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11463 hdd_cfg80211_state_t *cfgState;
11464 hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL;
11465 VOS_STATUS vosStatus;
11466
11467 vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode);
11468 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
11469 {
11470 pAdapter = pAdapterNode->pAdapter;
11471 if (NULL != pAdapter)
11472 {
11473 cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter);
11474 pRemainChanCtx = cfgState->remain_on_chan_ctx;
11475 if (pRemainChanCtx)
11476 break;
11477 }
11478 vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext);
11479 pAdapterNode = pNext;
11480 }
11481 return pRemainChanCtx;
11482}
11483
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011484/**
11485 * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels
11486 *
11487 * @pHddCtx: HDD context within host driver
11488 * @dfsScanMode: dfsScanMode passed from ioctl
11489 *
11490 */
11491
11492VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx,
11493 tANI_U8 dfsScanMode)
11494{
11495 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11496 hdd_adapter_t *pAdapter;
11497 VOS_STATUS vosStatus;
11498 hdd_station_ctx_t *pHddStaCtx;
11499 eHalStatus status = eHAL_STATUS_SUCCESS;
11500
11501 if(!pHddCtx)
11502 {
11503 hddLog(LOGE, FL("HDD context is Null"));
11504 return eHAL_STATUS_FAILURE;
11505 }
11506
11507 if (pHddCtx->scan_info.mScanPending)
11508 {
11509 hddLog(LOG1, FL("Aborting scan for sessionId: %d"),
11510 pHddCtx->scan_info.sessionId);
11511 hdd_abort_mac_scan(pHddCtx,
11512 pHddCtx->scan_info.sessionId,
11513 eCSR_SCAN_ABORT_DEFAULT);
11514 }
11515
11516 if (!dfsScanMode)
11517 {
11518 vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode);
11519 while ((NULL != pAdapterNode) &&
11520 (VOS_STATUS_SUCCESS == vosStatus))
11521 {
11522 pAdapter = pAdapterNode->pAdapter;
11523
11524 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
11525 {
11526 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11527
11528 if(!pHddStaCtx)
11529 {
11530 hddLog(LOGE, FL("HDD STA context is Null"));
11531 return eHAL_STATUS_FAILURE;
11532 }
11533
11534 /* if STA is already connected on DFS channel,
11535 disconnect immediately*/
11536 if (hdd_connIsConnected(pHddStaCtx) &&
11537 (NV_CHANNEL_DFS ==
11538 vos_nv_getChannelEnabledState(
11539 pHddStaCtx->conn_info.operationChannel)))
11540 {
11541 status = sme_RoamDisconnect(pHddCtx->hHal,
11542 pAdapter->sessionId,
11543 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11544 hddLog(LOG1, FL("Client connected on DFS channel %d,"
11545 "sme_RoamDisconnect returned with status: %d"
11546 "for sessionid: %d"), pHddStaCtx->conn_info.
11547 operationChannel, status, pAdapter->sessionId);
11548 }
11549 }
11550
11551 vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode,
11552 &pNext);
11553 pAdapterNode = pNext;
11554 }
11555 }
11556
11557 sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode);
11558 sme_UpdateDFSRoamMode(pHddCtx->hHal,
11559 (dfsScanMode != DFS_CHNL_SCAN_DISABLED));
11560
11561 status = sme_HandleDFSChanScan(pHddCtx->hHal);
11562 if (!HAL_STATUS_SUCCESS(status))
11563 {
11564 hddLog(LOGE,
11565 FL("Failed in sme_HandleDFSChanScan (err=%d)"), status);
11566 return status;
11567 }
11568
11569 return status;
11570}
11571
Nirav Shah7e3c8132015-06-22 23:51:42 +053011572static int hdd_log2_ceil(unsigned value)
11573{
11574 /* need to switch to unsigned math so that negative values
11575 * will right-shift towards 0 instead of -1
11576 */
11577 unsigned tmp = value;
11578 int log2 = -1;
11579
11580 if (value == 0)
11581 return 0;
11582
11583 while (tmp) {
11584 log2++;
11585 tmp >>= 1;
11586 }
11587 if (1U << log2 != value)
11588 log2++;
11589
11590 return log2;
11591}
11592
11593/**
11594 * hdd_sta_id_hash_attach() - initialize sta id to macaddr hash
11595 * @pAdapter: adapter handle
11596 *
11597 * Return: vos status
11598 */
11599VOS_STATUS hdd_sta_id_hash_attach(hdd_adapter_t *pAdapter)
11600{
11601 int hash_elem, log2, i;
11602
11603 spin_lock_bh( &pAdapter->sta_hash_lock);
11604 if (pAdapter->is_sta_id_hash_initialized == VOS_TRUE) {
11605 spin_unlock_bh( &pAdapter->sta_hash_lock);
11606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11607 "%s: hash already attached for session id %d",
11608 __func__, pAdapter->sessionId);
11609 return VOS_STATUS_SUCCESS;
11610 }
11611 spin_unlock_bh( &pAdapter->sta_hash_lock);
11612
11613 hash_elem = WLAN_MAX_STA_COUNT;
11614 hash_elem *= HDD_STA_ID_HASH_MULTIPLIER;
11615 log2 = hdd_log2_ceil(hash_elem);
11616 hash_elem = 1 << log2;
11617
11618 pAdapter->sta_id_hash.mask = hash_elem - 1;
11619 pAdapter->sta_id_hash.idx_bits = log2;
11620 pAdapter->sta_id_hash.bins =
11621 vos_mem_malloc(hash_elem *sizeof(hdd_list_t));
11622 if (!pAdapter->sta_id_hash.bins) {
11623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11624 "%s: malloc failed for session %d",
11625 __func__, pAdapter->sessionId);
11626 return VOS_STATUS_E_NOMEM;
11627 }
11628
11629 for (i = 0; i < hash_elem; i++)
11630 hdd_list_init(&pAdapter->sta_id_hash.bins[i], WLAN_MAX_STA_COUNT);
11631
11632 spin_lock_bh( &pAdapter->sta_hash_lock);
11633 pAdapter->is_sta_id_hash_initialized = VOS_TRUE;
11634 spin_unlock_bh( &pAdapter->sta_hash_lock);
11635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11636 "%s: Station ID Hash attached for session id %d",
11637 __func__, pAdapter->sessionId);
11638
11639 return VOS_STATUS_SUCCESS;
11640}
11641
11642/**
11643 * hdd_sta_id_hash_detach() - deinit sta_id to macaddr hash
11644 * @pAdapter: adapter handle
11645 *
11646 * Return: vos status
11647 */
11648VOS_STATUS hdd_sta_id_hash_detach(hdd_adapter_t *pAdapter)
11649{
11650 int hash_elem, i;
11651 v_SIZE_t size;
11652
11653 spin_lock_bh( &pAdapter->sta_hash_lock);
11654 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11655 spin_unlock_bh( &pAdapter->sta_hash_lock);
11656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11657 "%s: hash not initialized for session id %d",
11658 __func__, pAdapter->sessionId);
11659 return VOS_STATUS_SUCCESS;
11660 }
11661
11662 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
11663 spin_unlock_bh( &pAdapter->sta_hash_lock);
11664
11665 hash_elem = 1 << pAdapter->sta_id_hash.idx_bits;
11666
11667 /* free all station info*/
11668 for (i = 0; i < hash_elem; i++) {
11669 hdd_list_size(&pAdapter->sta_id_hash.bins[i], &size);
11670 if (size != 0) {
11671 VOS_STATUS status;
11672 hdd_staid_hash_node_t *sta_info_node = NULL;
11673 hdd_staid_hash_node_t *next_node = NULL;
11674 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[i],
11675 (hdd_list_node_t**) &sta_info_node );
11676
11677 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11678 {
11679 status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[i],
11680 &sta_info_node->node);
11681 vos_mem_free(sta_info_node);
11682
11683 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[i],
11684 (hdd_list_node_t*)sta_info_node,
11685 (hdd_list_node_t**)&next_node);
11686 sta_info_node = next_node;
11687 }
11688 }
11689 }
11690
11691 vos_mem_free(pAdapter->sta_id_hash.bins);
11692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11693 "%s: Station ID Hash detached for session id %d",
11694 __func__, pAdapter->sessionId);
11695 return VOS_STATUS_SUCCESS;
11696}
11697
11698/**
11699 * hdd_sta_id_hash_calculate_index() - derive index from macaddr
11700 * @pAdapter: adapter handle
11701 * @mac_addr_in: input mac address
11702 *
11703 * Return: index derived from mac address
11704 */
11705int hdd_sta_id_hash_calculate_index(hdd_adapter_t *pAdapter,
11706 v_MACADDR_t *mac_addr_in)
11707{
11708 uint16 index;
11709 struct hdd_align_mac_addr_t * mac_addr =
11710 (struct hdd_align_mac_addr_t *)mac_addr_in;
11711
11712 index = mac_addr->bytes_ab ^
11713 mac_addr->bytes_cd ^ mac_addr->bytes_ef;
11714 index ^= index >> pAdapter->sta_id_hash.idx_bits;
11715 index &= pAdapter->sta_id_hash.mask;
11716 return index;
11717}
11718
11719/**
11720 * hdd_sta_id_hash_add_entry() - add entry in hash
11721 * @pAdapter: adapter handle
11722 * @sta_id: station id
11723 * @mac_addr: mac address
11724 *
11725 * Return: vos status
11726 */
11727VOS_STATUS hdd_sta_id_hash_add_entry(hdd_adapter_t *pAdapter,
11728 v_U8_t sta_id, v_MACADDR_t *mac_addr)
11729{
11730 uint16 index;
11731 hdd_staid_hash_node_t *sta_info_node = NULL;
11732
11733 spin_lock_bh( &pAdapter->sta_hash_lock);
11734 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11735 spin_unlock_bh( &pAdapter->sta_hash_lock);
Bhargav Shah784e6a52015-07-22 16:52:35 +053011736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Nirav Shah7e3c8132015-06-22 23:51:42 +053011737 "%s: hash is not initialized for session id %d",
11738 __func__, pAdapter->sessionId);
11739 return VOS_STATUS_E_FAILURE;
11740 }
11741
11742 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr);
11743 sta_info_node = vos_mem_malloc(sizeof(hdd_staid_hash_node_t));
11744 if (!sta_info_node) {
11745 spin_unlock_bh( &pAdapter->sta_hash_lock);
11746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11747 "%s: malloc failed", __func__);
11748 return VOS_STATUS_E_NOMEM;
11749 }
11750
11751 sta_info_node->sta_id = sta_id;
11752 vos_mem_copy(&sta_info_node->mac_addr, mac_addr, sizeof(v_MACADDR_t));
11753
11754 hdd_list_insert_back ( &pAdapter->sta_id_hash.bins[index],
11755 (hdd_list_node_t*) sta_info_node );
11756 spin_unlock_bh( &pAdapter->sta_hash_lock);
11757 return VOS_STATUS_SUCCESS;
11758}
11759
11760/**
11761 * hdd_sta_id_hash_remove_entry() - remove entry from hash
11762 * @pAdapter: adapter handle
11763 * @sta_id: station id
11764 * @mac_addr: mac address
11765 *
11766 * Return: vos status
11767 */
11768VOS_STATUS hdd_sta_id_hash_remove_entry(hdd_adapter_t *pAdapter,
11769 v_U8_t sta_id, v_MACADDR_t *mac_addr)
11770{
11771 uint16 index;
11772 VOS_STATUS status;
11773 hdd_staid_hash_node_t *sta_info_node = NULL;
11774 hdd_staid_hash_node_t *next_node = NULL;
11775
11776 spin_lock_bh( &pAdapter->sta_hash_lock);
11777 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11778 spin_unlock_bh( &pAdapter->sta_hash_lock);
11779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11780 "%s: hash is not initialized for session id %d",
11781 __func__, pAdapter->sessionId);
11782 return VOS_STATUS_E_FAILURE;
11783 }
11784
11785 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr);
11786 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index],
11787 (hdd_list_node_t**) &sta_info_node );
11788
11789 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11790 {
11791 if (sta_info_node->sta_id == sta_id) {
11792 status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[index],
11793 &sta_info_node->node);
11794 vos_mem_free(sta_info_node);
11795 break;
11796 }
11797 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index],
11798 (hdd_list_node_t*)sta_info_node, (hdd_list_node_t**)&next_node);
11799 sta_info_node = next_node;
11800 }
11801 spin_unlock_bh( &pAdapter->sta_hash_lock);
11802 return status;
11803}
11804
11805/**
11806 * hdd_sta_id_find_from_mac_addr() - find sta id from mac address
11807 * @pAdapter: adapter handle
11808 * @mac_addr_in: mac address
11809 *
11810 * Return: station id
11811 */
11812int hdd_sta_id_find_from_mac_addr(hdd_adapter_t *pAdapter,
11813 v_MACADDR_t *mac_addr_in)
11814{
11815 uint8 is_found = 0;
11816 uint8 sta_id = HDD_WLAN_INVALID_STA_ID;
11817 uint16 index;
11818 VOS_STATUS status;
11819 hdd_staid_hash_node_t *sta_info_node = NULL;
11820 hdd_staid_hash_node_t *next_node = NULL;
11821
11822 spin_lock_bh( &pAdapter->sta_hash_lock);
11823 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11824 spin_unlock_bh( &pAdapter->sta_hash_lock);
11825 hddLog(VOS_TRACE_LEVEL_ERROR,
11826 FL("hash is not initialized for session id %d"),
11827 pAdapter->sessionId);
11828 return HDD_WLAN_INVALID_STA_ID;
11829 }
11830
11831 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr_in);
11832 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index],
11833 (hdd_list_node_t**) &sta_info_node );
11834
11835 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11836 {
11837 if (vos_mem_compare(&sta_info_node->mac_addr,
11838 mac_addr_in, sizeof(v_MACADDR_t))) {
11839 is_found = 1;
11840 sta_id = sta_info_node->sta_id;
11841 break;
11842 }
11843 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index],
11844 (hdd_list_node_t*)sta_info_node,
11845 (hdd_list_node_t**)&next_node);
11846 sta_info_node = next_node;
11847 }
11848 spin_unlock_bh( &pAdapter->sta_hash_lock);
11849 return sta_id;
11850}
11851
Jeff Johnson295189b2012-06-20 16:38:30 -070011852//Register the module init/exit functions
11853module_init(hdd_module_init);
11854module_exit(hdd_module_exit);
11855
11856MODULE_LICENSE("Dual BSD/GPL");
11857MODULE_AUTHOR("Qualcomm Atheros, Inc.");
11858MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER");
11859
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070011860module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode,
11861 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011862
Jeff Johnson76052702013-04-16 13:55:05 -070011863module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011864 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Arif Hussain66559122013-11-21 10:11:40 -080011865
11866module_param(enable_dfs_chan_scan, int,
11867 S_IRUSR | S_IRGRP | S_IROTH);
11868
11869module_param(enable_11d, int,
11870 S_IRUSR | S_IRGRP | S_IROTH);
11871
11872module_param(country_code, charp,
11873 S_IRUSR | S_IRGRP | S_IROTH);