blob: fc99199db5b9b9dd5ef0f187d392e01b0902884a [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 */
2531 if (copy_to_user(priv_data.buf, &extra, len + 1))
2532 {
2533 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 */
2593 if (copy_to_user(priv_data.buf, &extra, len + 1))
2594 {
2595 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);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003317 if (copy_to_user(priv_data.buf, &extra, len + 1))
3318 {
3319 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
4162 if (copy_to_user(priv_data.buf, &extra, len + 1))
4163 {
4164 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
Nirav Shah7e3c8132015-06-22 23:51:42 +05307246 status = hdd_sta_id_hash_detach(pAdapter);
7247 if (status != VOS_STATUS_SUCCESS)
7248 hddLog(VOS_TRACE_LEVEL_ERROR,
7249 FL("sta id hash detach failed"));
7250
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307251 pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 switch(pAdapter->device_mode)
7253 {
7254 case WLAN_HDD_INFRA_STATION:
7255 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007256 case WLAN_HDD_P2P_DEVICE:
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307257 {
7258 hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagare4d05d42015-07-02 16:17:20 +05307259#ifdef FEATURE_WLAN_TDLS
7260 mutex_lock(&pHddCtx->tdls_lock);
7261 wlan_hdd_tdls_exit(pAdapter, TRUE);
7262 mutex_unlock(&pHddCtx->tdls_lock);
7263#endif
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307264 if( hdd_connIsConnected(pstation) ||
7265 (pstation->conn_info.connState == eConnectionState_Connecting) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 {
7267 if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS)
7268 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
7269 pAdapter->sessionId,
7270 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7271 else
7272 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
7273 pAdapter->sessionId,
7274 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7275 //success implies disconnect command got queued up successfully
7276 if(halStatus == eHAL_STATUS_SUCCESS)
7277 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307278 ret = wait_for_completion_interruptible_timeout(
7279 &pAdapter->disconnect_comp_var,
7280 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7281 if (ret <= 0)
7282 {
7283 hddLog(VOS_TRACE_LEVEL_ERROR,
7284 "%s: wait on disconnect_comp_var failed %ld",
7285 __func__, ret);
7286 }
7287 }
7288 else
7289 {
7290 hddLog(LOGE, "%s: failed to post disconnect event to SME",
7291 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 }
7293 memset(&wrqu, '\0', sizeof(wrqu));
7294 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7295 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7296 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
7297 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307298 else if(pstation->conn_info.connState ==
7299 eConnectionState_Disconnecting)
7300 {
7301 ret = wait_for_completion_interruptible_timeout(
7302 &pAdapter->disconnect_comp_var,
7303 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7304 if (ret <= 0)
7305 {
7306 hddLog(VOS_TRACE_LEVEL_ERROR,
7307 FL("wait on disconnect_comp_var failed %ld"), ret);
7308 }
7309 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307310 else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending)
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307312 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307313 eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307315 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
7316 {
7317 while (pAdapter->is_roc_inprogress)
7318 {
7319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7320 "%s: ROC in progress for session %d!!!",
7321 __func__, pAdapter->sessionId);
7322 // waiting for ROC to expire
7323 msleep(500);
7324 /* In GO present case , if retry exceeds 3,
7325 it means something went wrong. */
7326 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION )
7327 {
7328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7329 "%s: ROC completion is not received.!!!", __func__);
Deepthi Gowri70498252015-01-20 15:56:45 +05307330 if (eHAL_STATUS_SUCCESS !=
7331 sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter),
7332 pAdapter->sessionId ))
7333 {
7334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7335 FL("Failed to Cancel Remain on Channel"));
7336 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307337 wait_for_completion_interruptible_timeout(
7338 &pAdapter->cancel_rem_on_chan_var,
7339 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
7340 break;
7341 }
7342 }
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307343 vos_flush_delayed_work(&pAdapter->roc_work);
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307344 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05307345#ifdef WLAN_NS_OFFLOAD
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307346 vos_flush_work(&pAdapter->ipv6NotifierWorkQueue);
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05307347#endif
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307348
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307349 vos_flush_work(&pAdapter->ipv4NotifierWorkQueue);
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307350
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307351 /* It is possible that the caller of this function does not
7352 * wish to close the session
7353 */
7354 if (VOS_TRUE == bCloseSession &&
7355 test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 {
7357 INIT_COMPLETION(pAdapter->session_close_comp_var);
7358 if (eHAL_STATUS_SUCCESS ==
mukul sharmabab477d2015-06-11 17:14:55 +05307359 sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, VOS_FALSE,
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307360 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307362 unsigned long ret;
7363
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307365 ret = wait_for_completion_timeout(
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307366 &pAdapter->session_close_comp_var,
7367 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307368 if ( 0 >= ret)
7369 {
7370 hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld",
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307371 __func__, ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 }
7374 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 break;
7377
7378 case WLAN_HDD_SOFTAP:
7379 case WLAN_HDD_P2P_GO:
7380 //Any softap specific cleanup here...
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307381 if (pAdapter->device_mode == WLAN_HDD_P2P_GO) {
7382 while (pAdapter->is_roc_inprogress) {
7383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7384 "%s: ROC in progress for session %d!!!",
7385 __func__, pAdapter->sessionId);
7386 msleep(500);
7387 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) {
7388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7389 "%s: ROC completion is not received.!!!", __func__);
7390 WLANSAP_CancelRemainOnChannel(
7391 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
7392 wait_for_completion_interruptible_timeout(
7393 &pAdapter->cancel_rem_on_chan_var,
7394 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
7395 break;
7396 }
7397 }
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05307398
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307399 vos_flush_delayed_work(&pAdapter->roc_work);
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 mutex_lock(&pHddCtx->sap_lock);
7402 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7403 {
7404 VOS_STATUS status;
7405 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7406
7407 //Stop Bss.
7408 status = WLANSAP_StopBss(pHddCtx->pvosContext);
7409 if (VOS_IS_STATUS_SUCCESS(status))
7410 {
7411 hdd_hostapd_state_t *pHostapdState =
7412 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7413
7414 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7415
7416 if (!VOS_IS_STATUS_SUCCESS(status))
7417 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307418 hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d",
7419 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 }
7421 }
7422 else
7423 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007424 hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 }
7426 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307427 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 if (eHAL_STATUS_FAILURE ==
7430 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG,
7431 0, NULL, eANI_BOOLEAN_FALSE))
7432 {
7433 hddLog(LOGE,
7434 "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007435 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007436 }
7437
7438 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7439 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7440 eANI_BOOLEAN_FALSE) )
7441 {
7442 hddLog(LOGE,
7443 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
7444 }
7445
7446 // Reset WNI_CFG_PROBE_RSP Flags
7447 wlan_hdd_reset_prob_rspies(pAdapter);
7448 kfree(pAdapter->sessionCtx.ap.beacon);
7449 pAdapter->sessionCtx.ap.beacon = NULL;
7450 }
7451 mutex_unlock(&pHddCtx->sap_lock);
7452 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007453
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 case WLAN_HDD_MONITOR:
7455 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007456
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 default:
7458 break;
7459 }
7460
7461 EXIT();
7462 return VOS_STATUS_SUCCESS;
7463}
7464
7465VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx )
7466{
7467 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7468 VOS_STATUS status;
7469 hdd_adapter_t *pAdapter;
7470
7471 ENTER();
7472
7473 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7474
7475 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7476 {
7477 pAdapter = pAdapterNode->pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07007478
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307479 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007480
7481 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7482 pAdapterNode = pNext;
7483 }
7484
7485 EXIT();
7486
7487 return VOS_STATUS_SUCCESS;
7488}
7489
Rajeev Kumarf999e582014-01-09 17:33:29 -08007490
7491#ifdef FEATURE_WLAN_BATCH_SCAN
7492/**---------------------------------------------------------------------------
7493
7494 \brief hdd_deinit_batch_scan () - This function cleans up batch scan data
7495 structures
7496
7497 \param - pAdapter Pointer to HDD adapter
7498
7499 \return - None
7500
7501 --------------------------------------------------------------------------*/
7502void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter)
7503{
7504 tHddBatchScanRsp *pNode;
7505 tHddBatchScanRsp *pPrev;
7506
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307507 if (NULL == pAdapter)
Rajeev Kumarf999e582014-01-09 17:33:29 -08007508 {
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307509 hddLog(VOS_TRACE_LEVEL_ERROR,
7510 "%s: Adapter context is Null", __func__);
7511 return;
7512 }
7513
7514 pNode = pAdapter->pBatchScanRsp;
7515 while (pNode)
7516 {
7517 pPrev = pNode;
7518 pNode = pNode->pNext;
7519 vos_mem_free((v_VOID_t * )pPrev);
Rajeev Kumarf999e582014-01-09 17:33:29 -08007520 }
7521
7522 pAdapter->pBatchScanRsp = NULL;
7523 pAdapter->numScanList = 0;
7524 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
7525 pAdapter->prev_batch_id = 0;
7526
7527 return;
7528}
7529#endif
7530
7531
Jeff Johnson295189b2012-06-20 16:38:30 -07007532VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx )
7533{
7534 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7535 VOS_STATUS status;
7536 hdd_adapter_t *pAdapter;
7537
7538 ENTER();
7539
7540 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7541
7542 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7543 {
7544 pAdapter = pAdapterNode->pAdapter;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05307545 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 netif_tx_disable(pAdapter->dev);
7547 netif_carrier_off(pAdapter->dev);
7548
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007549 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
7550
Jeff Johnson295189b2012-06-20 16:38:30 -07007551 hdd_deinit_tx_rx(pAdapter);
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307552
Katya Nigam1fd24402015-02-16 14:52:19 +05307553 if(pAdapter->device_mode == WLAN_HDD_IBSS )
7554 hdd_ibss_deinit_tx_rx(pAdapter);
7555
Nirav Shah7e3c8132015-06-22 23:51:42 +05307556 status = hdd_sta_id_hash_detach(pAdapter);
7557 if (status != VOS_STATUS_SUCCESS)
7558 hddLog(VOS_TRACE_LEVEL_ERROR,
7559 FL("sta id hash detach failed for session id %d"),
7560 pAdapter->sessionId);
7561
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307562 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
7563
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05307564 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
7565 {
7566 hdd_wmm_adapter_close( pAdapter );
7567 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
7568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007569
Siddharth Bhal2db319d2014-12-03 12:37:18 +05307570 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7571 {
7572 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
7573 }
7574
Rajeev Kumarf999e582014-01-09 17:33:29 -08007575#ifdef FEATURE_WLAN_BATCH_SCAN
7576 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
7577 {
7578 hdd_deinit_batch_scan(pAdapter);
7579 }
7580#endif
7581
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05307582#ifdef FEATURE_WLAN_TDLS
7583 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETI2d4d5c42015-03-03 14:34:19 +05307584 wlan_hdd_tdls_exit(pAdapter, TRUE);
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05307585 mutex_unlock(&pHddCtx->tdls_lock);
7586#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7588 pAdapterNode = pNext;
7589 }
7590
7591 EXIT();
7592
7593 return VOS_STATUS_SUCCESS;
7594}
7595
7596VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx )
7597{
7598 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7599 VOS_STATUS status;
7600 hdd_adapter_t *pAdapter;
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307601 eConnectionState connState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007602
7603 ENTER();
7604
7605 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7606
7607 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7608 {
7609 pAdapter = pAdapterNode->pAdapter;
7610
Kumar Anand82c009f2014-05-29 00:29:42 -07007611 hdd_wmm_init( pAdapter );
7612
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 switch(pAdapter->device_mode)
7614 {
7615 case WLAN_HDD_INFRA_STATION:
7616 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007617 case WLAN_HDD_P2P_DEVICE:
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307618
7619 connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState;
7620
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 hdd_init_station_mode(pAdapter);
7622 /* Open the gates for HDD to receive Wext commands */
7623 pAdapter->isLinkUpSvcNeeded = FALSE;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007624 pHddCtx->scan_info.mScanPending = FALSE;
7625 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007626
7627 //Trigger the initial scan
7628 hdd_wlan_initial_scan(pAdapter);
7629
7630 //Indicate disconnect event to supplicant if associated previously
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307631 if (eConnectionState_Associated == connState ||
7632 eConnectionState_IbssConnected == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 {
7634 union iwreq_data wrqu;
7635 memset(&wrqu, '\0', sizeof(wrqu));
7636 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7637 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7638 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007639 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007640
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 /* indicate disconnected event to nl80211 */
7642 cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED,
7643 NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 }
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307645 else if (eConnectionState_Connecting == connState)
7646 {
7647 /*
7648 * Indicate connect failure to supplicant if we were in the
7649 * process of connecting
7650 */
7651 cfg80211_connect_result(pAdapter->dev, NULL,
7652 NULL, 0, NULL, 0,
7653 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
7654 GFP_KERNEL);
7655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 break;
7657
7658 case WLAN_HDD_SOFTAP:
7659 /* softAP can handle SSR */
7660 break;
7661
7662 case WLAN_HDD_P2P_GO:
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007663 hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant",
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 __func__);
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007665 cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 break;
7667
7668 case WLAN_HDD_MONITOR:
7669 /* monitor interface start */
7670 break;
7671 default:
7672 break;
7673 }
7674
7675 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7676 pAdapterNode = pNext;
7677 }
7678
7679 EXIT();
7680
7681 return VOS_STATUS_SUCCESS;
7682}
7683
7684VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx )
7685{
7686 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7687 hdd_adapter_t *pAdapter;
7688 VOS_STATUS status;
7689 v_U32_t roamId;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307690 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007691
7692 ENTER();
7693
7694 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7695
7696 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7697 {
7698 pAdapter = pAdapterNode->pAdapter;
7699
7700 if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
7701 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
7702 {
7703 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7704 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7705
Abhishek Singhf4669da2014-05-26 15:07:49 +05307706 hddLog(VOS_TRACE_LEVEL_INFO,
7707 "%s: Set HDD connState to eConnectionState_NotConnected",
7708 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7710 init_completion(&pAdapter->disconnect_comp_var);
7711 sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId,
7712 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7713
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307714 ret = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 &pAdapter->disconnect_comp_var,
7716 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307717 if (0 >= ret)
7718 hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld",
7719 __func__, ret);
Jeff Johnson295189b2012-06-20 16:38:30 -07007720
7721 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
7722 pHddCtx->isAmpAllowed = VOS_FALSE;
7723 sme_RoamConnect(pHddCtx->hHal,
7724 pAdapter->sessionId, &(pWextState->roamProfile),
7725 &roamId);
7726 }
7727
7728 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7729 pAdapterNode = pNext;
7730 }
7731
7732 EXIT();
7733
7734 return VOS_STATUS_SUCCESS;
7735}
7736
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07007737void hdd_dump_concurrency_info(hdd_context_t *pHddCtx)
7738{
7739 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7740 VOS_STATUS status;
7741 hdd_adapter_t *pAdapter;
7742 hdd_station_ctx_t *pHddStaCtx;
7743 hdd_ap_ctx_t *pHddApCtx;
7744 hdd_hostapd_state_t * pHostapdState;
7745 tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 };
7746 v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0;
7747 const char *p2pMode = "DEV";
7748 const char *ccMode = "Standalone";
7749 int n;
7750
7751 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7752 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7753 {
7754 pAdapter = pAdapterNode->pAdapter;
7755 switch (pAdapter->device_mode) {
7756 case WLAN_HDD_INFRA_STATION:
7757 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7758 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7759 staChannel = pHddStaCtx->conn_info.operationChannel;
7760 memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid));
7761 }
7762 break;
7763 case WLAN_HDD_P2P_CLIENT:
7764 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7765 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7766 p2pChannel = pHddStaCtx->conn_info.operationChannel;
7767 memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid));
7768 p2pMode = "CLI";
7769 }
7770 break;
7771 case WLAN_HDD_P2P_GO:
7772 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7773 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7774 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7775 p2pChannel = pHddApCtx->operatingChannel;
7776 memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid));
7777 }
7778 p2pMode = "GO";
7779 break;
7780 case WLAN_HDD_SOFTAP:
7781 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7782 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7783 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7784 apChannel = pHddApCtx->operatingChannel;
7785 memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid));
7786 }
7787 break;
7788 default:
7789 break;
7790 }
7791 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7792 pAdapterNode = pNext;
7793 }
7794 if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) {
7795 ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC";
7796 }
7797 n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s",
7798 staChannel, MAC_ADDR_ARRAY(staBssid), ccMode);
7799 if (p2pChannel > 0) {
7800 n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR,
7801 p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid));
7802 }
7803 if (apChannel > 0) {
7804 n += pr_info("AP(%d) " MAC_ADDRESS_STR,
7805 apChannel, MAC_ADDR_ARRAY(apBssid));
7806 }
7807
7808 if (p2pChannel > 0 && apChannel > 0) {
7809 hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel);
7810 }
7811}
7812
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007813bool hdd_is_ssr_required( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07007814{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007815 return (isSsrRequired == HDD_SSR_REQUIRED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007816}
7817
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007818/* Once SSR is disabled then it cannot be set. */
7819void hdd_set_ssr_required( e_hdd_ssr_required value)
Jeff Johnson295189b2012-06-20 16:38:30 -07007820{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007821 if (HDD_SSR_DISABLED == isSsrRequired)
7822 return;
7823
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 isSsrRequired = value;
7825}
7826
Hema Aparna Medicharla6b4d4f32015-06-23 04:09:12 +05307827void hdd_set_pre_close( hdd_context_t *pHddCtx)
7828{
7829 sme_PreClose(pHddCtx->hHal);
7830}
7831
Jeff Johnson295189b2012-06-20 16:38:30 -07007832VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx,
7833 hdd_adapter_list_node_t** ppAdapterNode)
7834{
7835 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307836 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 status = hdd_list_peek_front ( &pHddCtx->hddAdapters,
7838 (hdd_list_node_t**) ppAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307839 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 return status;
7841}
7842
7843VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx,
7844 hdd_adapter_list_node_t* pAdapterNode,
7845 hdd_adapter_list_node_t** pNextAdapterNode)
7846{
7847 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307848 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 status = hdd_list_peek_next ( &pHddCtx->hddAdapters,
7850 (hdd_list_node_t*) pAdapterNode,
7851 (hdd_list_node_t**)pNextAdapterNode );
7852
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307853 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 return status;
7855}
7856
7857VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx,
7858 hdd_adapter_list_node_t* pAdapterNode)
7859{
7860 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307861 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 status = hdd_list_remove_node ( &pHddCtx->hddAdapters,
7863 &pAdapterNode->node );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307864 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 return status;
7866}
7867
7868VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx,
7869 hdd_adapter_list_node_t** ppAdapterNode)
7870{
7871 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307872 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 status = hdd_list_remove_front( &pHddCtx->hddAdapters,
7874 (hdd_list_node_t**) ppAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307875 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 return status;
7877}
7878
7879VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx,
7880 hdd_adapter_list_node_t* pAdapterNode)
7881{
7882 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307883 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 status = hdd_list_insert_back ( &pHddCtx->hddAdapters,
7885 (hdd_list_node_t*) pAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307886 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 return status;
7888}
7889
7890VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx,
7891 hdd_adapter_list_node_t* pAdapterNode)
7892{
7893 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307894 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 status = hdd_list_insert_front ( &pHddCtx->hddAdapters,
7896 (hdd_list_node_t*) pAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307897 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007898 return status;
7899}
7900
7901hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx,
7902 tSirMacAddr macAddr )
7903{
7904 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7905 hdd_adapter_t *pAdapter;
7906 VOS_STATUS status;
7907
7908 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7909
7910 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7911 {
7912 pAdapter = pAdapterNode->pAdapter;
7913
7914 if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes,
7915 macAddr, sizeof(tSirMacAddr) ) )
7916 {
7917 return pAdapter;
7918 }
7919 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7920 pAdapterNode = pNext;
7921 }
7922
7923 return NULL;
7924
7925}
7926
7927hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name )
7928{
7929 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7930 hdd_adapter_t *pAdapter;
7931 VOS_STATUS status;
7932
7933 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7934
7935 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7936 {
7937 pAdapter = pAdapterNode->pAdapter;
7938
7939 if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name,
7940 IFNAMSIZ ) )
7941 {
7942 return pAdapter;
7943 }
7944 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7945 pAdapterNode = pNext;
7946 }
7947
7948 return NULL;
7949
7950}
7951
7952hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode )
7953{
7954 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7955 hdd_adapter_t *pAdapter;
7956 VOS_STATUS status;
7957
7958 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7959
7960 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7961 {
7962 pAdapter = pAdapterNode->pAdapter;
7963
7964 if( pAdapter && (mode == pAdapter->device_mode) )
7965 {
7966 return pAdapter;
7967 }
7968 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7969 pAdapterNode = pNext;
7970 }
7971
7972 return NULL;
7973
7974}
7975
7976//Remove this function later
7977hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx )
7978{
7979 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7980 hdd_adapter_t *pAdapter;
7981 VOS_STATUS status;
7982
7983 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7984
7985 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7986 {
7987 pAdapter = pAdapterNode->pAdapter;
7988
7989 if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode )
7990 {
7991 return pAdapter;
7992 }
7993
7994 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7995 pAdapterNode = pNext;
7996 }
7997
7998 return NULL;
7999
8000}
8001
Jeff Johnson295189b2012-06-20 16:38:30 -07008002/**---------------------------------------------------------------------------
8003
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05308004 \brief hdd_get_operating_channel() -
Jeff Johnson295189b2012-06-20 16:38:30 -07008005
8006 This API returns the operating channel of the requested device mode
8007
8008 \param - pHddCtx - Pointer to the HDD context.
8009 - mode - Device mode for which operating channel is required
8010 suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT
8011 WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO.
8012 \return - channel number. "0" id the requested device is not found OR it is not connected.
8013 --------------------------------------------------------------------------*/
8014v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode )
8015{
8016 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8017 VOS_STATUS status;
8018 hdd_adapter_t *pAdapter;
8019 v_U8_t operatingChannel = 0;
8020
8021 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8022
8023 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8024 {
8025 pAdapter = pAdapterNode->pAdapter;
8026
8027 if( mode == pAdapter->device_mode )
8028 {
8029 switch(pAdapter->device_mode)
8030 {
8031 case WLAN_HDD_INFRA_STATION:
8032 case WLAN_HDD_P2P_CLIENT:
8033 if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) )
8034 operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel;
8035 break;
8036 case WLAN_HDD_SOFTAP:
8037 case WLAN_HDD_P2P_GO:
8038 /*softap connection info */
8039 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
8040 operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel;
8041 break;
8042 default:
8043 break;
8044 }
8045
8046 break; //Found the device of interest. break the loop
8047 }
8048
8049 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8050 pAdapterNode = pNext;
8051 }
8052 return operatingChannel;
8053}
8054
8055#ifdef WLAN_FEATURE_PACKET_FILTERING
8056/**---------------------------------------------------------------------------
8057
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308058 \brief __hdd_set_multicast_list() -
Jeff Johnson295189b2012-06-20 16:38:30 -07008059
8060 This used to set the multicast address list.
8061
8062 \param - dev - Pointer to the WLAN device.
8063 - skb - Pointer to OS packet (sk_buff).
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308064 \return - success/fail
Jeff Johnson295189b2012-06-20 16:38:30 -07008065
8066 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308067static void __hdd_set_multicast_list(struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07008068{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308069 hdd_adapter_t *pAdapter;
8070 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008071 int mc_count;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308072 int i = 0, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 struct netdev_hw_addr *ha;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308074
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308075 ENTER();
8076
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308077 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308078 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 {
8080 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308081 "%s: Adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 return;
8083 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308084 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8085 ret = wlan_hdd_validate_context(pHddCtx);
8086 if (0 != ret)
8087 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308088 return;
8089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 if (dev->flags & IFF_ALLMULTI)
8091 {
8092 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008093 "%s: allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308094 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308096 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 {
8098 mc_count = netdev_mc_count(dev);
8099 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008100 "%s: mc_count = %u", __func__, mc_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST)
8102 {
8103 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008104 "%s: No free filter available; allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308105 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 return;
8107 }
8108
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308109 pAdapter->mc_addr_list.mc_cnt = mc_count;
Jeff Johnson295189b2012-06-20 16:38:30 -07008110
8111 netdev_for_each_mc_addr(ha, dev) {
8112 if (i == mc_count)
8113 break;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308114 memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN);
8115 memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008116 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR,
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308117 __func__, i,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308118 MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 i++;
8120 }
8121 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308122
8123 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 return;
8125}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308126
8127static void hdd_set_multicast_list(struct net_device *dev)
8128{
8129 vos_ssr_protect(__func__);
8130 __hdd_set_multicast_list(dev);
8131 vos_ssr_unprotect(__func__);
8132}
Jeff Johnson295189b2012-06-20 16:38:30 -07008133#endif
8134
8135/**---------------------------------------------------------------------------
8136
8137 \brief hdd_select_queue() -
8138
8139 This function is registered with the Linux OS for network
8140 core to decide which queue to use first.
8141
8142 \param - dev - Pointer to the WLAN device.
8143 - skb - Pointer to OS packet (sk_buff).
8144 \return - ac, Queue Index/access category corresponding to UP in IP header
8145
8146 --------------------------------------------------------------------------*/
8147v_U16_t hdd_select_queue(struct net_device *dev,
8148 struct sk_buff *skb)
8149{
8150 return hdd_wmm_select_queue(dev, skb);
8151}
8152
8153
8154/**---------------------------------------------------------------------------
8155
8156 \brief hdd_wlan_initial_scan() -
8157
8158 This function triggers the initial scan
8159
8160 \param - pAdapter - Pointer to the HDD adapter.
8161
8162 --------------------------------------------------------------------------*/
8163void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter)
8164{
8165 tCsrScanRequest scanReq;
8166 tCsrChannelInfo channelInfo;
8167 eHalStatus halStatus;
Jeff Johnson02797792013-10-26 19:17:13 -07008168 tANI_U32 scanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8170
8171 vos_mem_zero(&scanReq, sizeof(tCsrScanRequest));
8172 vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff);
8173 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
8174
8175 if(sme_Is11dSupported(pHddCtx->hHal))
8176 {
8177 halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo );
8178 if ( HAL_STATUS_SUCCESS( halStatus ) )
8179 {
8180 scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels);
8181 if( !scanReq.ChannelInfo.ChannelList )
8182 {
8183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__);
8184 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08008185 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 return;
8187 }
8188 vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList,
8189 channelInfo.numOfChannels);
8190 scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels;
8191 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08008192 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 }
8194
8195 scanReq.scanType = eSIR_PASSIVE_SCAN;
8196 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
8197 scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime;
8198 scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime;
8199 }
8200 else
8201 {
8202 scanReq.scanType = eSIR_ACTIVE_SCAN;
8203 scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
8204 scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime;
8205 scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime;
8206 }
8207
8208 halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL);
8209 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8210 {
8211 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d",
8212 __func__, halStatus );
8213 }
8214
8215 if(sme_Is11dSupported(pHddCtx->hHal))
8216 vos_mem_free(scanReq.ChannelInfo.ChannelList);
8217}
8218
mukul sharmabab477d2015-06-11 17:14:55 +05308219void hdd_purge_cmd_list_all_adapters( hdd_context_t *pHddCtx )
8220{
8221 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8222 VOS_STATUS status;
8223 hdd_adapter_t *pAdapter;
8224
8225 ENTER();
8226
8227 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8228
8229 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8230 {
8231 pAdapter = pAdapterNode->pAdapter;
8232
8233 status = sme_PurgeCmdList(pHddCtx->hHal, pAdapter->sessionId);
8234 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8235 pAdapterNode = pNext;
8236 }
8237
8238 EXIT();
8239}
Jeff Johnson295189b2012-06-20 16:38:30 -07008240/**---------------------------------------------------------------------------
8241
8242 \brief hdd_full_power_callback() - HDD full power callback function
8243
8244 This is the function invoked by SME to inform the result of a full power
8245 request issued by HDD
8246
8247 \param - callbackcontext - Pointer to cookie
8248 \param - status - result of request
8249
8250 \return - None
8251
8252 --------------------------------------------------------------------------*/
8253static void hdd_full_power_callback(void *callbackContext, eHalStatus status)
8254{
Jeff Johnson72a40512013-12-19 10:14:15 -08008255 struct statsContext *pContext = callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008256
8257 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308258 "%s: context = %p, status = %d", __func__, pContext, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008259
8260 if (NULL == callbackContext)
8261 {
8262 hddLog(VOS_TRACE_LEVEL_ERROR,
8263 "%s: Bad param, context [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008264 __func__, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 return;
8266 }
8267
Jeff Johnson72a40512013-12-19 10:14:15 -08008268 /* there is a race condition that exists between this callback
8269 function and the caller since the caller could time out either
8270 before or while this code is executing. we use a spinlock to
8271 serialize these actions */
8272 spin_lock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008273
8274 if (POWER_CONTEXT_MAGIC != pContext->magic)
8275 {
8276 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08008277 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 hddLog(VOS_TRACE_LEVEL_WARN,
8279 "%s: Invalid context, magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008280 __func__, pContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 return;
8282 }
8283
Jeff Johnson72a40512013-12-19 10:14:15 -08008284 /* context is valid so caller is still waiting */
8285
8286 /* paranoia: invalidate the magic */
8287 pContext->magic = 0;
8288
8289 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 complete(&pContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08008291
8292 /* serialization is complete */
8293 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008294}
8295
Katya Nigamf0511f62015-05-05 16:40:57 +05308296void wlan_hdd_mon_set_typesubtype( hdd_mon_ctx_t *pMonCtx,int type)
8297{
8298 pMonCtx->typeSubtypeBitmap = 0;
8299 if( type%10 ) /* Management Packets */
8300 pMonCtx->typeSubtypeBitmap |= 0xFFFF;
8301 type/=10;
8302 if( type%10 ) /* Control Packets */
8303 pMonCtx->typeSubtypeBitmap |= 0xFFFF0000;
8304 type/=10;
8305 if( type%10 ) /* Data Packets */
8306 pMonCtx->typeSubtypeBitmap |= 0xFFFF00000000;
8307}
8308
8309VOS_STATUS wlan_hdd_mon_poststartmsg( hdd_mon_ctx_t *pMonCtx )
8310{
8311 vos_msg_t monMsg;
8312
8313 monMsg.type = WDA_MON_START_REQ;
8314 monMsg.reserved = 0;
8315 monMsg.bodyptr = (v_U8_t*)pMonCtx;
8316 monMsg.bodyval = 0;
8317
8318 if (VOS_STATUS_SUCCESS != vos_mq_post_message(
8319 VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) {
8320 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__);
8321 return VOS_STATUS_E_FAILURE;
8322 }
8323
8324 return VOS_STATUS_SUCCESS;
8325}
8326
8327void wlan_hdd_mon_poststopmsg(void)
8328{
8329 vos_msg_t monMsg;
8330
8331 monMsg.type = WDA_MON_STOP_REQ;
8332 monMsg.reserved = 0;
8333 monMsg.bodyptr = NULL;
8334 monMsg.bodyval = 0;
8335
8336 if (VOS_STATUS_SUCCESS != vos_mq_post_message(
8337 VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) {
8338 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__);
8339 }
8340}
8341
Katya Nigame7b69a82015-04-28 15:24:06 +05308342void wlan_hdd_mon_close(hdd_context_t *pHddCtx)
8343{
8344 VOS_STATUS vosStatus;
8345 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
8346 struct wiphy *wiphy = pHddCtx->wiphy;
8347
8348 hdd_adapter_t *pAdapter = hdd_get_adapter(pHddCtx,WLAN_HDD_MONITOR);
8349 if(pAdapter == NULL || pVosContext == NULL)
8350 {
8351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:pAdapter is NULL",__func__);
8352 return ;
8353 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308354
8355 wlan_hdd_mon_poststopmsg();
Katya Nigame7b69a82015-04-28 15:24:06 +05308356 hdd_UnregisterWext(pAdapter->dev);
8357
8358 vos_mon_stop( pVosContext );
8359
8360 vosStatus = vos_sched_close( pVosContext );
8361 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8362 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8363 "%s: Failed to close VOSS Scheduler",__func__);
8364 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8365 }
8366
8367 vosStatus = vos_nv_close();
8368 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8369 {
8370 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8371 "%s: Failed to close NV", __func__);
8372 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8373 }
8374
8375 vos_close(pVosContext);
8376
8377 #ifdef WLAN_KD_READY_NOTIFIER
8378 nl_srv_exit(pHddCtx->ptt_pid);
8379 #else
8380 nl_srv_exit();
8381 #endif
8382
8383 if (pHddCtx->cfg_ini)
8384 {
8385 kfree(pHddCtx->cfg_ini);
8386 pHddCtx->cfg_ini= NULL;
8387 }
8388 hdd_close_all_adapters( pHddCtx );
8389
8390 wiphy_free(wiphy) ;
8391
8392}
Jeff Johnson295189b2012-06-20 16:38:30 -07008393/**---------------------------------------------------------------------------
8394
8395 \brief hdd_wlan_exit() - HDD WLAN exit function
8396
8397 This is the driver exit point (invoked during rmmod)
8398
8399 \param - pHddCtx - Pointer to the HDD Context
8400
8401 \return - None
8402
8403 --------------------------------------------------------------------------*/
8404void hdd_wlan_exit(hdd_context_t *pHddCtx)
8405{
8406 eHalStatus halStatus;
8407 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
8408 VOS_STATUS vosStatus;
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05308409 struct wiphy *wiphy = pHddCtx->wiphy;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008410 hdd_adapter_t* pAdapter = NULL;
Jeff Johnson72a40512013-12-19 10:14:15 -08008411 struct statsContext powerContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 long lrc;
c_hpothu5ab05e92014-06-13 17:34:05 +05308413 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008414
8415 ENTER();
8416
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05308417
Katya Nigame7b69a82015-04-28 15:24:06 +05308418 if (VOS_MONITOR_MODE == hdd_get_conparam())
8419 {
8420 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: MONITOR MODE",__func__);
8421 wlan_hdd_mon_close(pHddCtx);
8422 return;
8423 }
8424 else if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson88ba7742013-02-27 14:36:02 -08008425 {
8426 // Unloading, restart logic is no more required.
8427 wlan_hdd_restart_deinit(pHddCtx);
Jeff Johnsone7245742012-09-05 17:12:55 -07008428
Agarwal Ashishb20e0ff2014-12-17 22:50:19 +05308429#ifdef FEATURE_WLAN_TDLS
8430 /* At the time of driver unloading; if tdls connection is present;
8431 * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer.
8432 * wlan_hdd_tdls_find_peer always checks for valid context;
8433 * as load/unload in progress there can be a race condition.
8434 * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only
8435 * when tdls state is enabled.
8436 * As soon as driver set load/unload flag; tdls flag also needs
8437 * to be disabled so that hdd_rx_packet_cbk won't call
8438 * wlan_hdd_tdls_find_peer.
8439 */
8440 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE);
8441#endif
8442
c_hpothu5ab05e92014-06-13 17:34:05 +05308443 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8444 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 {
c_hpothu5ab05e92014-06-13 17:34:05 +05308446 pAdapter = pAdapterNode->pAdapter;
8447 if (NULL != pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 {
Mahesh A Saptasagar305e2632015-03-04 12:57:33 +05308449 /* Disable TX on the interface, after this hard_start_xmit() will
8450 * not be called on that interface
8451 */
8452 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
8453 netif_tx_disable(pAdapter->dev);
8454
8455 /* Mark the interface status as "down" for outside world */
8456 netif_carrier_off(pAdapter->dev);
8457
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05308458 /* DeInit the adapter. This ensures that all data packets
8459 * are freed.
8460 */
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05308461#ifdef FEATURE_WLAN_TDLS
8462 mutex_lock(&pHddCtx->tdls_lock);
8463#endif
c_hpothu002231a2015-02-05 14:58:51 +05308464 hdd_deinit_adapter(pHddCtx, pAdapter, FALSE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05308465#ifdef FEATURE_WLAN_TDLS
8466 mutex_unlock(&pHddCtx->tdls_lock);
8467#endif
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05308468
c_hpothu5ab05e92014-06-13 17:34:05 +05308469 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
8470 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
8471 {
8472 wlan_hdd_cfg80211_deregister_frames(pAdapter);
8473 hdd_UnregisterWext(pAdapter->dev);
8474 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308475
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 }
c_hpothu5ab05e92014-06-13 17:34:05 +05308477 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8478 pAdapterNode = pNext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 }
mukul sharmabab477d2015-06-11 17:14:55 +05308480
8481 //Purge all sme cmd's for all interface
8482 hdd_purge_cmd_list_all_adapters(pHddCtx);
8483
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308484 // Cancel any outstanding scan requests. We are about to close all
8485 // of our adapters, but an adapter structure is what SME passes back
8486 // to our callback function. Hence if there are any outstanding scan
8487 // requests then there is a race condition between when the adapter
8488 // is closed and when the callback is invoked.We try to resolve that
8489 // race condition here by canceling any outstanding scans before we
8490 // close the adapters.
8491 // Note that the scans may be cancelled in an asynchronous manner,
8492 // so ideally there needs to be some kind of synchronization. Rather
8493 // than introduce a new synchronization here, we will utilize the
8494 // fact that we are about to Request Full Power, and since that is
8495 // synchronized, the expectation is that by the time Request Full
8496 // Power has completed all scans will be cancelled.
8497 if (pHddCtx->scan_info.mScanPending)
8498 {
Hema Aparna Medicharlaf05f6cd2015-01-21 14:44:19 +05308499 if(NULL != pAdapter)
8500 {
8501 hddLog(VOS_TRACE_LEVEL_INFO,
8502 FL("abort scan mode: %d sessionId: %d"),
8503 pAdapter->device_mode,
8504 pAdapter->sessionId);
8505 }
8506 hdd_abort_mac_scan(pHddCtx,
8507 pHddCtx->scan_info.sessionId,
8508 eCSR_SCAN_ABORT_DEFAULT);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 }
c_hpothu5ab05e92014-06-13 17:34:05 +05308511 else
Jeff Johnson88ba7742013-02-27 14:36:02 -08008512 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308513 hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__);
Hanumantha Reddy Pothula45af96b2015-02-12 16:07:58 +05308514 if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING)
8515 {
8516 INIT_COMPLETION(pHddCtx->ftm.startCmpVar);
8517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8518 "%s: in middle of FTM START", __func__);
8519 lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar,
8520 msecs_to_jiffies(20000));
8521 if(!lrc)
8522 {
8523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8524 "%s: timedout on ftmStartCmpVar fatal error", __func__);
8525 }
8526 }
Jeff Johnson88ba7742013-02-27 14:36:02 -08008527 wlan_hdd_ftm_close(pHddCtx);
8528 goto free_hdd_ctx;
8529 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308530
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 /* DeRegister with platform driver as client for Suspend/Resume */
8532 vosStatus = hddDeregisterPmOps(pHddCtx);
8533 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
8534 {
8535 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__);
8536 VOS_ASSERT(0);
8537 }
8538
8539 vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx);
8540 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
8541 {
8542 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
8543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008544
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07008545 //Stop the traffic monitor timer
8546 if ( VOS_TIMER_STATE_RUNNING ==
8547 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))
8548 {
8549 vos_timer_stop(&pHddCtx->tx_rx_trafficTmr);
8550 }
8551
8552 // Destroy the traffic monitor timer
8553 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(
8554 &pHddCtx->tx_rx_trafficTmr)))
8555 {
8556 hddLog(VOS_TRACE_LEVEL_ERROR,
8557 "%s: Cannot deallocate Traffic monitor timer", __func__);
8558 }
8559
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 //Disable IMPS/BMPS as we do not want the device to enter any power
8561 //save mode during shutdown
8562 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
8563 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
8564 sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE);
8565
8566 //Ensure that device is in full power as we will touch H/W during vos_Stop
8567 init_completion(&powerContext.completion);
8568 powerContext.magic = POWER_CONTEXT_MAGIC;
8569
8570 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback,
8571 &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD);
8572
8573 if (eHAL_STATUS_SUCCESS != halStatus)
8574 {
8575 if (eHAL_STATUS_PMC_PENDING == halStatus)
8576 {
8577 /* request was sent -- wait for the response */
8578 lrc = wait_for_completion_interruptible_timeout(
8579 &powerContext.completion,
8580 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07008581 if (lrc <= 0)
8582 {
8583 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008584 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 }
8586 }
8587 else
8588 {
8589 hddLog(VOS_TRACE_LEVEL_ERROR,
8590 "%s: Request for Full Power failed, status %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008591 __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 /* continue -- need to clean up as much as possible */
8593 }
8594 }
Hanumantha Reddy Pothula81b42b22015-05-12 13:52:00 +05308595 if ((eHAL_STATUS_SUCCESS == halStatus) ||
8596 (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0))
8597 {
8598 /* This will issue a dump command which will clean up
8599 BTQM queues and unblock MC thread */
8600 vos_fwDumpReq(274, 0, 0, 0, 0, 1);
8601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008602
Jeff Johnson72a40512013-12-19 10:14:15 -08008603 /* either we never sent a request, we sent a request and received a
8604 response or we sent a request and timed out. if we never sent a
8605 request or if we sent a request and got a response, we want to
8606 clear the magic out of paranoia. if we timed out there is a
8607 race condition such that the callback function could be
8608 executing at the same time we are. of primary concern is if the
8609 callback function had already verified the "magic" but had not
8610 yet set the completion variable when a timeout occurred. we
8611 serialize these activities by invalidating the magic while
8612 holding a shared spinlock which will cause us to block if the
8613 callback is currently executing */
8614 spin_lock(&hdd_context_lock);
8615 powerContext.magic = 0;
8616 spin_unlock(&hdd_context_lock);
8617
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05308618 /* If Device is shutdown, no point for SME to wait for responses
8619 from device. Pre Close SME */
8620 if(wcnss_device_is_shutdown())
8621 {
8622 sme_PreClose(pHddCtx->hHal);
8623 }
Yue Ma0d4891e2013-08-06 17:01:45 -07008624 hdd_debugfs_exit(pHddCtx);
8625
Ratheesh S P35ed8b12015-04-27 14:01:07 +05308626#ifdef WLAN_NS_OFFLOAD
8627 hddLog(LOGE, FL("Unregister IPv6 notifier"));
8628 unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier);
8629#endif
8630 hddLog(LOGE, FL("Unregister IPv4 notifier"));
8631 unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier);
8632
Jeff Johnson295189b2012-06-20 16:38:30 -07008633 // Unregister the Net Device Notifier
8634 unregister_netdevice_notifier(&hdd_netdev_notifier);
8635
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 hdd_stop_all_adapters( pHddCtx );
8637
Jeff Johnson295189b2012-06-20 16:38:30 -07008638#ifdef WLAN_BTAMP_FEATURE
8639 vosStatus = WLANBAP_Stop(pVosContext);
8640 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8641 {
8642 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8643 "%s: Failed to stop BAP",__func__);
8644 }
8645#endif //WLAN_BTAMP_FEATURE
8646
8647 //Stop all the modules
8648 vosStatus = vos_stop( pVosContext );
8649 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8650 {
8651 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8652 "%s: Failed to stop VOSS",__func__);
8653 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8654 }
8655
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 //This requires pMac access, Call this before vos_close().
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 hdd_unregister_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008658
8659 //Close the scheduler before calling vos_close to make sure no thread is
8660 // scheduled after the each module close is called i.e after all the data
8661 // structures are freed.
8662 vosStatus = vos_sched_close( pVosContext );
8663 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8664 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8665 "%s: Failed to close VOSS Scheduler",__func__);
8666 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8667 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008668#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
8669 /* Destroy the wake lock */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308670 vos_wake_lock_destroy(&pHddCtx->rx_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008671#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08008672 /* Destroy the wake lock */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308673 vos_wake_lock_destroy(&pHddCtx->sap_wake_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008674
Mihir Shete7a24b5f2013-12-21 12:18:31 +05308675#ifdef CONFIG_ENABLE_LINUX_REG
8676 vosStatus = vos_nv_close();
8677 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8678 {
8679 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8680 "%s: Failed to close NV", __func__);
8681 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8682 }
8683#endif
8684
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 //Close VOSS
8686 //This frees pMac(HAL) context. There should not be any call that requires pMac access after this.
8687 vos_close(pVosContext);
8688
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 //Close Watchdog
8690 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8691 vos_watchdog_close(pVosContext);
8692
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308693 //Clean up HDD Nlink Service
8694 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308695
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308696#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05308697 if (pHddCtx->cfg_ini->wlanLoggingEnable)
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308698 {
8699 wlan_logging_sock_deactivate_svc();
8700 }
8701#endif
8702
Vinay Krishna Erannaef30b522014-08-26 17:48:16 +05308703#ifdef WLAN_KD_READY_NOTIFIER
8704 nl_srv_exit(pHddCtx->ptt_pid);
8705#else
8706 nl_srv_exit();
8707#endif /* WLAN_KD_READY_NOTIFIER */
8708
8709
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 hdd_close_all_adapters( pHddCtx );
8711
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 /* free the power on lock from platform driver */
8713 if (free_riva_power_on_lock("wlan"))
8714 {
8715 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock",
8716 __func__);
8717 }
8718
Jeff Johnson88ba7742013-02-27 14:36:02 -08008719free_hdd_ctx:
c_hpothu78c7b602014-05-17 17:35:49 +05308720
8721 //Free up dynamically allocated members inside HDD Adapter
8722 if (pHddCtx->cfg_ini)
8723 {
8724 kfree(pHddCtx->cfg_ini);
8725 pHddCtx->cfg_ini= NULL;
8726 }
8727
Leo Changf04ddad2013-09-18 13:46:38 -07008728 /* FTM mode, WIPHY did not registered
8729 If un-register here, system crash will happen */
8730 if (VOS_FTM_MODE != hdd_get_conparam())
8731 {
8732 wiphy_unregister(wiphy) ;
8733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 wiphy_free(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 if (hdd_is_ssr_required())
8736 {
8737 /* WDI timeout had happened during unload, so SSR is needed here */
Madan Mohan Koyyalamudi3246f5b2012-10-15 15:40:02 -07008738 subsystem_restart("wcnss");
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 msleep(5000);
8740 }
8741 hdd_set_ssr_required (VOS_FALSE);
8742}
8743
8744
8745/**---------------------------------------------------------------------------
8746
8747 \brief hdd_update_config_from_nv() - Function to update the contents of
8748 the running configuration with parameters taken from NV storage
8749
8750 \param - pHddCtx - Pointer to the HDD global context
8751
8752 \return - VOS_STATUS_SUCCESS if successful
8753
8754 --------------------------------------------------------------------------*/
8755static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx)
8756{
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 v_BOOL_t itemIsValid = VOS_FALSE;
8758 VOS_STATUS status;
8759 v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA];
8760 v_U8_t macLoop;
8761
8762 /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/
8763 status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid);
8764 if(status != VOS_STATUS_SUCCESS)
8765 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008766 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 return VOS_STATUS_E_FAILURE;
8768 }
8769
8770 if (itemIsValid == VOS_TRUE)
8771 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008772 hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV");
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0],
8774 VOS_MAX_CONCURRENCY_PERSONA);
8775 if(status != VOS_STATUS_SUCCESS)
8776 {
8777 /* Get MAC from NV fail, not update CFG info
8778 * INI MAC value will be used for MAC setting */
Arif Hussain6d2a3322013-11-17 19:50:10 -08008779 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 return VOS_STATUS_E_FAILURE;
8781 }
8782
8783 /* If first MAC is not valid, treat all others are not valid
8784 * Then all MACs will be got from ini file */
8785 if(vos_is_macaddr_zero(&macFromNV[0]))
8786 {
8787 /* MAC address in NV file is not configured yet */
8788 hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file");
8789 return VOS_STATUS_E_INVAL;
8790 }
8791
8792 /* Get MAC address from NV, update CFG info */
8793 for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++)
8794 {
8795 if(vos_is_macaddr_zero(&macFromNV[macLoop]))
8796 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308797 hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop);
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 /* This MAC is not valid, skip it
8799 * This MAC will be got from ini file */
8800 }
8801 else
8802 {
8803 vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0],
8804 (v_U8_t *)&macFromNV[macLoop].bytes[0],
8805 VOS_MAC_ADDR_SIZE);
8806 }
8807 }
8808 }
8809 else
8810 {
8811 hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid");
8812 return VOS_STATUS_E_FAILURE;
8813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008814
Jeff Johnson295189b2012-06-20 16:38:30 -07008815
8816 return VOS_STATUS_SUCCESS;
8817}
8818
8819/**---------------------------------------------------------------------------
8820
8821 \brief hdd_post_voss_start_config() - HDD post voss start config helper
8822
8823 \param - pAdapter - Pointer to the HDD
8824
8825 \return - None
8826
8827 --------------------------------------------------------------------------*/
8828VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx)
8829{
8830 eHalStatus halStatus;
8831 v_U32_t listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308832 tANI_U32 ignoreDtim;
Jeff Johnson295189b2012-06-20 16:38:30 -07008833
Jeff Johnson295189b2012-06-20 16:38:30 -07008834
8835 // Send ready indication to the HDD. This will kick off the MAC
8836 // into a 'running' state and should kick off an initial scan.
8837 halStatus = sme_HDDReadyInd( pHddCtx->hHal );
8838 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8839 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308840 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status "
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 "code %08d [x%08x]",__func__, halStatus, halStatus );
8842 return VOS_STATUS_E_FAILURE;
8843 }
8844
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308845 // Set default LI and ignoreDtim into HDD context,
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 // otherwise under some race condition, HDD will set 0 LI value into RIVA,
8847 // And RIVA will crash
8848 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval);
8849 pHddCtx->hdd_actual_LI_value = listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308850 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim);
8851 pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim;
8852
8853
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 return VOS_STATUS_SUCCESS;
8855}
8856
Jeff Johnson295189b2012-06-20 16:38:30 -07008857/* wake lock APIs for HDD */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308858void hdd_prevent_suspend(uint32_t reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07008859{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308860
8861 vos_wake_lock_acquire(&wlan_wake_lock, reason);
8862
Jeff Johnson295189b2012-06-20 16:38:30 -07008863}
8864
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308865void hdd_allow_suspend(uint32_t reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07008866{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308867
8868 vos_wake_lock_release(&wlan_wake_lock, reason);
8869
Jeff Johnson295189b2012-06-20 16:38:30 -07008870}
8871
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308872void hdd_prevent_suspend_timeout(v_U32_t timeout, uint32_t reason)
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008873{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308874
8875 vos_wake_lock_timeout_release(&wlan_wake_lock, timeout,
8876 reason);
8877
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008878}
8879
Jeff Johnson295189b2012-06-20 16:38:30 -07008880/**---------------------------------------------------------------------------
8881
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008882 \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability
8883 information between Host and Riva
8884
8885 This function gets reported version of FW
8886 It also finds the version of Riva headers used to compile the host
8887 It compares the above two and prints a warning if they are different
8888 It gets the SW and HW version string
8889 Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg
8890 indicating the features they support through a bitmap
8891
8892 \param - pHddCtx - Pointer to HDD context
8893
8894 \return - void
8895
8896 --------------------------------------------------------------------------*/
8897
8898void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx)
8899{
8900
8901 tSirVersionType versionCompiled;
8902 tSirVersionType versionReported;
8903 tSirVersionString versionString;
8904 tANI_U8 fwFeatCapsMsgSupported = 0;
8905 VOS_STATUS vstatus;
8906
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008907 memset(&versionCompiled, 0, sizeof(versionCompiled));
8908 memset(&versionReported, 0, sizeof(versionReported));
8909
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008910 /* retrieve and display WCNSS version information */
8911 do {
8912
8913 vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal,
8914 &versionCompiled);
8915 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8916 {
8917 hddLog(VOS_TRACE_LEVEL_FATAL,
8918 "%s: unable to retrieve WCNSS WLAN compiled version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008919 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008920 break;
8921 }
8922
8923 vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal,
8924 &versionReported);
8925 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8926 {
8927 hddLog(VOS_TRACE_LEVEL_FATAL,
8928 "%s: unable to retrieve WCNSS WLAN reported version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008929 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008930 break;
8931 }
8932
8933 if ((versionCompiled.major != versionReported.major) ||
8934 (versionCompiled.minor != versionReported.minor) ||
8935 (versionCompiled.version != versionReported.version) ||
8936 (versionCompiled.revision != versionReported.revision))
8937 {
8938 pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, "
8939 "Host expected %u.%u.%u.%u\n",
8940 WLAN_MODULE_NAME,
8941 (int)versionReported.major,
8942 (int)versionReported.minor,
8943 (int)versionReported.version,
8944 (int)versionReported.revision,
8945 (int)versionCompiled.major,
8946 (int)versionCompiled.minor,
8947 (int)versionCompiled.version,
8948 (int)versionCompiled.revision);
8949 }
8950 else
8951 {
8952 pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n",
8953 WLAN_MODULE_NAME,
8954 (int)versionReported.major,
8955 (int)versionReported.minor,
8956 (int)versionReported.version,
8957 (int)versionReported.revision);
8958 }
8959
8960 vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal,
8961 versionString,
8962 sizeof(versionString));
8963 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8964 {
8965 hddLog(VOS_TRACE_LEVEL_FATAL,
8966 "%s: unable to retrieve WCNSS software version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008967 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008968 break;
8969 }
8970
8971 pr_info("%s: WCNSS software version %s\n",
8972 WLAN_MODULE_NAME, versionString);
8973
8974 vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal,
8975 versionString,
8976 sizeof(versionString));
8977 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8978 {
8979 hddLog(VOS_TRACE_LEVEL_FATAL,
8980 "%s: unable to retrieve WCNSS hardware version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008981 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008982 break;
8983 }
8984
8985 pr_info("%s: WCNSS hardware version %s\n",
8986 WLAN_MODULE_NAME, versionString);
8987
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008988 /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message
8989 2.Host-FW capability exchange message is only present on riva 1.1 so
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008990 send the message only if it the riva is 1.1
8991 minor numbers for different riva branches:
8992 0 -> (1.0)Mainline Build
8993 1 -> (1.1)Mainline Build
8994 2->(1.04) Stability Build
8995 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07008996 if (((versionReported.major>0) || (versionReported.minor>1) ||
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008997 ((versionReported.minor>=1) && (versionReported.version>=1)))
8998 && ((versionReported.major == 1) && (versionReported.minor >= 1)))
8999 fwFeatCapsMsgSupported = 1;
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07009000
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009001 if (fwFeatCapsMsgSupported)
Yathish9f22e662012-12-10 14:21:35 -08009002 {
9003#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9004 if(!pHddCtx->cfg_ini->fEnableActiveModeOffload)
9005 sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD);
9006#endif
Ravi Joshid2ca7c42013-07-23 08:37:49 -07009007 /* Indicate if IBSS heartbeat monitoring needs to be offloaded */
9008 if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload)
9009 {
9010 sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD);
9011 }
9012
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009013 sme_featureCapsExchange(pHddCtx->hHal);
Yathish9f22e662012-12-10 14:21:35 -08009014 }
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009015
9016 } while (0);
9017
9018}
Neelansh Mittaledafed22014-09-04 18:54:39 +05309019void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len)
9020{
9021 struct sk_buff *skb;
9022 struct nlmsghdr *nlh;
9023 tAniMsgHdr *ani_hdr;
Hanumantha Reddy Pothulacf2c7ea2015-04-27 14:50:47 +05309024 int flags = GFP_KERNEL;
Neelansh Mittaledafed22014-09-04 18:54:39 +05309025
Hanumantha Reddy Pothulacf2c7ea2015-04-27 14:50:47 +05309026 if (in_interrupt() || irqs_disabled() || in_atomic())
9027 flags = GFP_ATOMIC;
9028
9029 skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags);
Neelansh Mittaledafed22014-09-04 18:54:39 +05309030
9031 if(skb == NULL) {
9032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9033 "%s: alloc_skb failed", __func__);
9034 return;
9035 }
9036
9037 nlh = (struct nlmsghdr *)skb->data;
9038 nlh->nlmsg_pid = 0; /* from kernel */
9039 nlh->nlmsg_flags = 0;
9040 nlh->nlmsg_seq = 0;
9041 nlh->nlmsg_type = WLAN_NL_MSG_SVC;
9042
9043 ani_hdr = NLMSG_DATA(nlh);
9044 ani_hdr->type = type;
9045
9046 switch(type) {
9047 case WLAN_SVC_SAP_RESTART_IND:
9048 ani_hdr->length = 0;
9049 nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr)));
9050 skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr)));
9051 break;
9052 default:
9053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9054 "Attempt to send unknown nlink message %d", type);
9055 kfree_skb(skb);
9056 return;
9057 }
9058
9059 nl_srv_bcast(skb);
9060
9061 return;
9062}
9063
9064
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009065
9066/**---------------------------------------------------------------------------
9067
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309068 \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz
9069
9070 \param - pHddCtx - Pointer to the hdd context
9071
9072 \return - true if hardware supports 5GHz
9073
9074 --------------------------------------------------------------------------*/
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05309075boolean hdd_is_5g_supported(hdd_context_t * pHddCtx)
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309076{
9077 /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1);
9078 * then hardware support 5Ghz.
9079 */
9080 if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode())
9081 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309082 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309083 return true;
9084 }
9085 else
9086 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309087 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz",
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309088 __func__);
9089 return false;
9090 }
9091}
9092
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309093/**---------------------------------------------------------------------------
9094
9095 \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto
9096 generate function
9097
9098 This is generate the random mac address for WLAN interface
9099
9100 \param - pHddCtx - Pointer to HDD context
9101 idx - Start interface index to get auto
9102 generated mac addr.
9103 mac_addr - Mac address
9104
9105 \return - 0 for success, < 0 for failure
9106
9107 --------------------------------------------------------------------------*/
9108
9109static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx,
9110 int idx, v_MACADDR_t mac_addr)
9111{
9112 int i;
9113 unsigned int serialno;
9114 serialno = wcnss_get_serial_number();
9115
9116 if (0 != serialno)
9117 {
9118 /* MAC address has 3 bytes of OUI so we have a maximum of 3
9119 bytes of the serial number that can be used to generate
9120 the other 3 bytes of the MAC address. Mask off all but
9121 the lower 3 bytes (this will also make sure we don't
9122 overflow in the next step) */
9123 serialno &= 0x00FFFFFF;
9124
9125 /* we need a unique address for each session */
9126 serialno *= VOS_MAX_CONCURRENCY_PERSONA;
9127
9128 /* autogen other Mac addresses */
9129 for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
9130 {
9131 /* start with the entire default address */
9132 pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr;
9133 /* then replace the lower 3 bytes */
9134 pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF;
9135 pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF;
9136 pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF;
9137
9138 serialno++;
9139 hddLog(VOS_TRACE_LEVEL_ERROR,
9140 "%s: Derived Mac Addr: "
9141 MAC_ADDRESS_STR, __func__,
9142 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes));
9143 }
9144
9145 }
9146 else
9147 {
9148 hddLog(LOGE, FL("Failed to Get Serial NO"));
9149 return -1;
9150 }
9151 return 0;
9152}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309153
Katya Nigame7b69a82015-04-28 15:24:06 +05309154int wlan_hdd_mon_open(hdd_context_t *pHddCtx)
9155{
9156 VOS_STATUS status;
9157 v_CONTEXT_t pVosContext= NULL;
9158 hdd_adapter_t *pAdapter= NULL;
9159
9160 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9161
9162 if (NULL == pVosContext)
9163 {
9164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9165 "%s: Trying to open VOSS without a PreOpen", __func__);
9166 VOS_ASSERT(0);
9167 return VOS_STATUS_E_FAILURE;
9168 }
9169
9170 status = vos_nv_open();
9171 if (!VOS_IS_STATUS_SUCCESS(status))
9172 {
9173 /* NV module cannot be initialized */
9174 hddLog( VOS_TRACE_LEVEL_FATAL,
9175 "%s: vos_nv_open failed", __func__);
9176 return VOS_STATUS_E_FAILURE;
9177 }
9178
9179 status = vos_init_wiphy_from_nv_bin();
9180 if (!VOS_IS_STATUS_SUCCESS(status))
9181 {
9182 /* NV module cannot be initialized */
9183 hddLog( VOS_TRACE_LEVEL_FATAL,
9184 "%s: vos_init_wiphy failed", __func__);
9185 goto err_vos_nv_close;
9186 }
9187
9188 status = vos_open( &pVosContext, pHddCtx->parent_dev);
9189 if ( !VOS_IS_STATUS_SUCCESS( status ))
9190 {
9191 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
9192 goto err_vos_nv_close;
9193 }
9194
9195 status = vos_mon_start( pVosContext );
9196 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9197 {
9198 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
9199 goto err_vosclose;
9200 }
9201
9202 WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk );
9203 WDA_featureCapsExchange(pVosContext);
9204 wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx);
9205
9206 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_MONITOR, "wlan%d",
9207 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9208 if( pAdapter == NULL )
9209 {
9210 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9211 goto err_close_adapter;
9212 }
9213
9214 //Initialize the nlink service
9215 if(nl_srv_init() != 0)
9216 {
9217 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
9218 goto err_close_adapter;
9219 }
9220 return VOS_STATUS_SUCCESS;
9221
9222err_close_adapter:
9223 hdd_close_all_adapters( pHddCtx );
9224 vos_mon_stop( pVosContext );
9225err_vosclose:
9226 status = vos_sched_close( pVosContext );
9227 if (!VOS_IS_STATUS_SUCCESS(status)) {
9228 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
9229 "%s: Failed to close VOSS Scheduler", __func__);
9230 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
9231 }
9232 vos_close(pVosContext );
9233
9234err_vos_nv_close:
9235 vos_nv_close();
9236
9237return status;
9238}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309239/**---------------------------------------------------------------------------
9240
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309241 \brief hdd_11d_scan_done - callback to be executed when 11d scan is
9242 completed to flush out the scan results
9243
9244 11d scan is done during driver load and is a passive scan on all
9245 channels supported by the device, 11d scans may find some APs on
9246 frequencies which are forbidden to be used in the regulatory domain
9247 the device is operating in. If these APs are notified to the supplicant
9248 it may try to connect to these APs, thus flush out all the scan results
9249 which are present in SME after 11d scan is done.
9250
9251 \return - eHalStatus
9252
9253 --------------------------------------------------------------------------*/
9254static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext,
9255 tANI_U32 scanId, eCsrScanStatus status)
9256{
9257 ENTER();
9258
9259 sme_ScanFlushResult(halHandle, 0);
9260
9261 EXIT();
9262
9263 return eHAL_STATUS_SUCCESS;
9264}
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309265/**---------------------------------------------------------------------------
9266
9267 \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame
9268 logging is completed successfully.
9269
9270 \return - None
9271
9272 --------------------------------------------------------------------------*/
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309273void hdd_init_frame_logging_done(void *fwlogInitCbContext, VOS_STATUS status)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309274{
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309275 hdd_context_t* pHddCtx = (hdd_context_t*)fwlogInitCbContext;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309276
9277 if (NULL == pHddCtx)
9278 {
9279 hddLog(VOS_TRACE_LEVEL_ERROR,
9280 "%s: HDD context is NULL",__func__);
9281 return;
9282 }
9283
Mahesh A Saptasagarfabb1a02015-06-29 12:17:04 +05309284 if ((VOS_STATUS_SUCCESS == status) &&
9285 (TRUE == pHddCtx->cfg_ini->enableMgmtLogging))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309286 {
9287 hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful"));
9288 pHddCtx->mgmt_frame_logging = TRUE;
9289 }
9290 else
9291 {
9292 hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success"));
9293 pHddCtx->mgmt_frame_logging = FALSE;
9294 }
9295
9296 return;
9297}
9298/**---------------------------------------------------------------------------
9299
9300 \brief hdd_init_frame_logging - function to initialize frame logging.
9301 Currently only Mgmt Frames are logged in both TX
9302 and Rx direction and are sent to userspace
9303 application using logger thread when queried.
9304
9305 \return - None
9306
9307 --------------------------------------------------------------------------*/
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309308void hdd_init_frame_logging(hdd_context_t* pHddCtx)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309309{
9310 eHalStatus halStatus = eHAL_STATUS_FAILURE;
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309311 tpSirFWLoggingInitParam wlanFWLoggingInitParam;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309312
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309313 if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING) &&
9314 TRUE != sme_IsFeatureSupportedByFW(LOGGING_ENHANCEMENT))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309315 {
9316 hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW"));
9317 return;
9318 }
9319
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309320 wlanFWLoggingInitParam = vos_mem_malloc(sizeof(tSirFWLoggingInitParam));
9321 if(NULL == wlanFWLoggingInitParam)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309322 {
9323 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_mem_alloc failed ", __func__);
9324 return;
9325 }
9326
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309327 vos_mem_set(wlanFWLoggingInitParam, sizeof(tSirFWLoggingInitParam), 0);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309328
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309329 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Configuring %s %s %s Logging",__func__,
9330 pHddCtx->cfg_ini->enableFWLogging?"FW Log,":"",
9331 pHddCtx->cfg_ini->enableContFWLogging ? "Cont FW log,":"",
9332 pHddCtx->cfg_ini->enableMgmtLogging ? "Mgmt Pkt Log":"");
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309333
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309334 if (pHddCtx->cfg_ini->enableFWLogging ||
9335 pHddCtx->cfg_ini->enableContFWLogging)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309336 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309337 wlanFWLoggingInitParam->enableFlag |= WLAN_QXDM_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309338 }
9339
Sushant Kaushik46804902015-07-08 14:46:03 +05309340 if (pHddCtx->cfg_ini->enableMgmtLogging)
9341 {
9342 wlanFWLoggingInitParam->enableFlag |= WLAN_FRAME_LOG_EN;
9343 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309344 if (pHddCtx->cfg_ini->enableBMUHWtracing)
9345 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309346 wlanFWLoggingInitParam->enableFlag |= WLAN_BMUHW_TRACE_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309347 }
9348
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309349 wlanFWLoggingInitParam->frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT;
9350 wlanFWLoggingInitParam->frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES;
9351 wlanFWLoggingInitParam->bufferMode = WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR;
9352 wlanFWLoggingInitParam->continuousFrameLogging =
9353 pHddCtx->cfg_ini->enableContFWLogging;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309354
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309355 wlanFWLoggingInitParam->enableFlag &= ~WLAN_DPU_TXP_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309356
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309357 wlanFWLoggingInitParam->minLogBufferSize =
9358 pHddCtx->cfg_ini->minLoggingBufferSize;
9359 wlanFWLoggingInitParam->maxLogBufferSize =
9360 pHddCtx->cfg_ini->maxLoggingBufferSize;
9361 wlanFWLoggingInitParam->fwlogInitCallback = hdd_init_frame_logging_done;
9362 wlanFWLoggingInitParam->fwlogInitCbContext= pHddCtx;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309363
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309364 halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, wlanFWLoggingInitParam);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309365
9366 if (eHAL_STATUS_SUCCESS != halStatus)
9367 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309368 vos_mem_free(wlanFWLoggingInitParam);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309369 }
9370
9371 return;
9372}
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309373
9374/**---------------------------------------------------------------------------
9375
Jeff Johnson295189b2012-06-20 16:38:30 -07009376 \brief hdd_wlan_startup() - HDD init function
9377
9378 This is the driver startup code executed once a WLAN device has been detected
9379
9380 \param - dev - Pointer to the underlying device
9381
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009382 \return - 0 for success, < 0 for failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009383
9384 --------------------------------------------------------------------------*/
9385
9386int hdd_wlan_startup(struct device *dev )
9387{
9388 VOS_STATUS status;
9389 hdd_adapter_t *pAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009390 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009391 hdd_context_t *pHddCtx = NULL;
9392 v_CONTEXT_t pVosContext= NULL;
9393#ifdef WLAN_BTAMP_FEATURE
9394 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
9395 WLANBAP_ConfigType btAmpConfig;
9396 hdd_config_t *pConfig;
9397#endif
9398 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 struct wiphy *wiphy;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309400 v_MACADDR_t mac_addr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009401
9402 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 /*
9404 * cfg80211: wiphy allocation
9405 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309406 wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009407
9408 if(wiphy == NULL)
9409 {
9410 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009411 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009413 pHddCtx = wiphy_priv(wiphy);
9414
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 //Initialize the adapter context to zeros.
9416 vos_mem_zero(pHddCtx, sizeof( hdd_context_t ));
9417
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 pHddCtx->wiphy = wiphy;
Sushant Kaushik83392fa2015-05-05 17:44:40 +05309419 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Mihir Shete18156292014-03-11 15:38:30 +05309420 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009421
9422 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
9423
Siddharth Bhalcd92b782015-06-29 12:25:40 +05309424 /* register for riva power on lock to platform driver
9425 * Locking power early to ensure FW doesn't reset by kernel while
9426 * host driver is busy initializing itself */
9427 if (req_riva_power_on_lock("wlan"))
9428 {
9429 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed",
9430 __func__);
9431 goto err_free_hdd_context;
9432 }
9433
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 /*Get vos context here bcoz vos_open requires it*/
9435 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9436
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08009437 if(pVosContext == NULL)
9438 {
9439 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__);
9440 goto err_free_hdd_context;
9441 }
9442
Jeff Johnson295189b2012-06-20 16:38:30 -07009443 //Save the Global VOSS context in adapter context for future.
9444 pHddCtx->pvosContext = pVosContext;
9445
9446 //Save the adapter context in global context for future.
9447 ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx;
9448
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 pHddCtx->parent_dev = dev;
9450
9451 init_completion(&pHddCtx->full_pwr_comp_var);
9452 init_completion(&pHddCtx->standby_comp_var);
9453 init_completion(&pHddCtx->req_bmps_comp_var);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009454 init_completion(&pHddCtx->scan_info.scan_req_completion_event);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009455 init_completion(&pHddCtx->scan_info.abortscan_event_var);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309456 init_completion(&pHddCtx->wiphy_channel_update_event);
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309457 init_completion(&pHddCtx->ssr_comp_var);
Amar Singhala49cbc52013-10-08 18:37:44 -07009458
9459#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhalfddc28c2013-09-05 13:03:40 -07009460 init_completion(&pHddCtx->linux_reg_req);
Amar Singhala49cbc52013-10-08 18:37:44 -07009461#else
9462 init_completion(&pHddCtx->driver_crda_req);
9463#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009464
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309465 spin_lock_init(&pHddCtx->schedScan_lock);
9466
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS );
9468
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309469#ifdef FEATURE_WLAN_TDLS
9470 /* tdls_lock is initialized before an hdd_open_adapter ( which is
9471 * invoked by other instances also) to protect the concurrent
9472 * access for the Adapters by TDLS module.
9473 */
9474 mutex_init(&pHddCtx->tdls_lock);
9475#endif
Siddharth Bhal76972212014-10-15 16:22:51 +05309476 mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05309477 mutex_init(&pHddCtx->wmmLock);
9478
Agarwal Ashish1f422872014-07-22 00:11:55 +05309479 /* By default Strict Regulatory For FCC should be false */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309480
Agarwal Ashish1f422872014-07-22 00:11:55 +05309481 pHddCtx->nEnableStrictRegulatoryForFCC = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 // Load all config first as TL config is needed during vos_open
9483 pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL);
9484 if(pHddCtx->cfg_ini == NULL)
9485 {
9486 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__);
9487 goto err_free_hdd_context;
9488 }
9489
9490 vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t ));
9491
9492 // Read and parse the qcom_cfg.ini file
9493 status = hdd_parse_config_ini( pHddCtx );
9494 if ( VOS_STATUS_SUCCESS != status )
9495 {
9496 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s",
9497 __func__, WLAN_INI_FILE);
9498 goto err_config;
9499 }
Arif Hussaind5218912013-12-05 01:10:55 -08009500#ifdef MEMORY_DEBUG
9501 if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled)
9502 vos_mem_init();
9503
9504 hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d",
9505 __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled);
9506#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009507
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309508 /* INI has been read, initialise the configuredMcastBcastFilter with
9509 * INI value as this will serve as the default value
9510 */
9511 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
9512 hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d",
9513 pHddCtx->cfg_ini->mcastBcastFilterSetting);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309514
9515 if (false == hdd_is_5g_supported(pHddCtx))
9516 {
9517 //5Ghz is not supported.
9518 if (1 != pHddCtx->cfg_ini->nBandCapability)
9519 {
9520 hddLog(VOS_TRACE_LEVEL_INFO,
9521 "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__);
9522 pHddCtx->cfg_ini->nBandCapability = 1;
9523 }
9524 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309525
9526 /* If SNR Monitoring is enabled, FW has to parse all beacons
9527 * for calcaluting and storing the average SNR, so set Nth beacon
9528 * filter to 1 to enable FW to parse all the beaocons
9529 */
9530 if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring)
9531 {
9532 /* The log level is deliberately set to WARN as overriding
9533 * nthBeaconFilter to 1 will increase power cosumption and this
9534 * might just prove helpful to detect the power issue.
9535 */
9536 hddLog(VOS_TRACE_LEVEL_WARN,
9537 "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__);
9538 pHddCtx->cfg_ini->nthBeaconFilter = 1;
9539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 /*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309541 * cfg80211: Initialization ...
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 */
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08009543 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 {
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08009545 if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini))
9546 {
9547 hddLog(VOS_TRACE_LEVEL_FATAL,
9548 "%s: wlan_hdd_cfg80211_init return failure", __func__);
9549 goto err_config;
9550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009553 // Update VOS trace levels based upon the cfg.ini
9554 hdd_vos_trace_enable(VOS_MODULE_ID_BAP,
9555 pHddCtx->cfg_ini->vosTraceEnableBAP);
9556 hdd_vos_trace_enable(VOS_MODULE_ID_TL,
9557 pHddCtx->cfg_ini->vosTraceEnableTL);
9558 hdd_vos_trace_enable(VOS_MODULE_ID_WDI,
9559 pHddCtx->cfg_ini->vosTraceEnableWDI);
9560 hdd_vos_trace_enable(VOS_MODULE_ID_HDD,
9561 pHddCtx->cfg_ini->vosTraceEnableHDD);
9562 hdd_vos_trace_enable(VOS_MODULE_ID_SME,
9563 pHddCtx->cfg_ini->vosTraceEnableSME);
9564 hdd_vos_trace_enable(VOS_MODULE_ID_PE,
9565 pHddCtx->cfg_ini->vosTraceEnablePE);
Katya Nigam70d68332013-09-16 16:49:45 +05309566 hdd_vos_trace_enable(VOS_MODULE_ID_PMC,
9567 pHddCtx->cfg_ini->vosTraceEnablePMC);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009568 hdd_vos_trace_enable(VOS_MODULE_ID_WDA,
9569 pHddCtx->cfg_ini->vosTraceEnableWDA);
9570 hdd_vos_trace_enable(VOS_MODULE_ID_SYS,
9571 pHddCtx->cfg_ini->vosTraceEnableSYS);
9572 hdd_vos_trace_enable(VOS_MODULE_ID_VOSS,
9573 pHddCtx->cfg_ini->vosTraceEnableVOSS);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009574 hdd_vos_trace_enable(VOS_MODULE_ID_SAP,
9575 pHddCtx->cfg_ini->vosTraceEnableSAP);
9576 hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP,
9577 pHddCtx->cfg_ini->vosTraceEnableHDDSAP);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009578
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 // Update WDI trace levels based upon the cfg.ini
9580 hdd_wdi_trace_enable(eWLAN_MODULE_DAL,
9581 pHddCtx->cfg_ini->wdiTraceEnableDAL);
9582 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL,
9583 pHddCtx->cfg_ini->wdiTraceEnableCTL);
9584 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA,
9585 pHddCtx->cfg_ini->wdiTraceEnableDAT);
9586 hdd_wdi_trace_enable(eWLAN_MODULE_PAL,
9587 pHddCtx->cfg_ini->wdiTraceEnablePAL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009588
Jeff Johnson88ba7742013-02-27 14:36:02 -08009589 if (VOS_FTM_MODE == hdd_get_conparam())
9590 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) )
9592 {
9593 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__);
9594 goto err_free_hdd_context;
9595 }
9596 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__);
Sachin Ahuja38ef5e02015-03-13 17:31:16 +05309597 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
c_hpothu2de0ef62014-04-15 16:16:15 +05309598 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 return VOS_STATUS_SUCCESS;
Jeff Johnson88ba7742013-02-27 14:36:02 -08009600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009601
Katya Nigame7b69a82015-04-28 15:24:06 +05309602 if( VOS_MONITOR_MODE == hdd_get_conparam())
9603 {
9604 if ( VOS_STATUS_SUCCESS != wlan_hdd_mon_open(pHddCtx))
9605 {
9606 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_mon_open Failed",__func__);
9607 goto err_free_hdd_context;
9608 }
9609 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Driver loaded in Monitor Mode",__func__);
9610 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
9611 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9612 return VOS_STATUS_SUCCESS;
9613 }
9614
Jeff Johnson88ba7742013-02-27 14:36:02 -08009615 //Open watchdog module
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 if(pHddCtx->cfg_ini->fIsLogpEnabled)
9617 {
9618 status = vos_watchdog_open(pVosContext,
9619 &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext));
9620
9621 if(!VOS_IS_STATUS_SUCCESS( status ))
9622 {
9623 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309624 goto err_wdclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 }
9626 }
9627
9628 pHddCtx->isLogpInProgress = FALSE;
9629 vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9630
Amar Singhala49cbc52013-10-08 18:37:44 -07009631#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009632 /* initialize the NV module. This is required so that
9633 we can initialize the channel information in wiphy
9634 from the NV.bin data. The channel information in
9635 wiphy needs to be initialized before wiphy registration */
9636
9637 status = vos_nv_open();
9638 if (!VOS_IS_STATUS_SUCCESS(status))
9639 {
9640 /* NV module cannot be initialized */
9641 hddLog( VOS_TRACE_LEVEL_FATAL,
9642 "%s: vos_nv_open failed", __func__);
Vinay Krishna Eranna2025d892014-09-18 16:51:42 +05309643 goto err_wdclose;
Amar Singhal0a402232013-10-11 20:57:16 -07009644 }
9645
9646 status = vos_init_wiphy_from_nv_bin();
9647 if (!VOS_IS_STATUS_SUCCESS(status))
9648 {
9649 /* NV module cannot be initialized */
9650 hddLog( VOS_TRACE_LEVEL_FATAL,
9651 "%s: vos_init_wiphy failed", __func__);
9652 goto err_vos_nv_close;
9653 }
9654
Amar Singhala49cbc52013-10-08 18:37:44 -07009655#endif
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05309656 vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats);
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +05309657 status = vos_open( &pVosContext, pHddCtx->parent_dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 if ( !VOS_IS_STATUS_SUCCESS( status ))
9659 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009660 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05309661 goto err_vos_nv_close;
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 }
9663
Jeff Johnson295189b2012-06-20 16:38:30 -07009664 pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext );
9665
9666 if ( NULL == pHddCtx->hHal )
9667 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009668 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 goto err_vosclose;
9670 }
9671
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009672 status = vos_preStart( pHddCtx->pvosContext );
9673 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9674 {
9675 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309676 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009677 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009678
Arif Hussaineaf68602013-12-30 23:10:44 -08009679 if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan)
9680 {
9681 pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan;
9682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d",
9683 __func__, enable_dfs_chan_scan);
9684 }
9685 if (0 == enable_11d || 1 == enable_11d)
9686 {
9687 pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d;
9688 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d",
9689 __func__, enable_11d);
9690 }
9691
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009692 /* Note that the vos_preStart() sequence triggers the cfg download.
9693 The cfg download must occur before we update the SME config
9694 since the SME config operation must access the cfg database */
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 status = hdd_set_sme_config( pHddCtx );
9696
9697 if ( VOS_STATUS_SUCCESS != status )
9698 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009699 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309700 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009702
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 /* In the integrated architecture we update the configuration from
9704 the INI file and from NV before vOSS has been started so that
9705 the final contents are available to send down to the cCPU */
9706
9707 // Apply the cfg.ini to cfg.dat
9708 if (FALSE == hdd_update_config_dat(pHddCtx))
9709 {
9710 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309711 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 }
9713
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309714 // Get mac addr from platform driver
9715 ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes);
9716
9717 if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309719 /* Store the mac addr for first interface */
9720 pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr;
9721
9722 hddLog(VOS_TRACE_LEVEL_ERROR,
9723 "%s: WLAN Mac Addr: "
9724 MAC_ADDRESS_STR, __func__,
9725 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
9726
9727 /* Here, passing Arg2 as 1 because we do not want to change the
9728 last 3 bytes (means non OUI bytes) of first interface mac
9729 addr.
9730 */
9731 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr))
9732 {
9733 hddLog(VOS_TRACE_LEVEL_ERROR,
9734 "%s: Failed to generate wlan interface mac addr "
9735 "using MAC from ini file ", __func__);
9736 }
9737 }
9738 else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx))
9739 {
9740 // Apply the NV to cfg.dat
9741 /* Prima Update MAC address only at here */
Jeff Johnson295189b2012-06-20 16:38:30 -07009742#ifdef WLAN_AUTOGEN_MACADDR_FEATURE
9743 /* There was not a valid set of MAC Addresses in NV. See if the
9744 default addresses were modified by the cfg.ini settings. If so,
9745 we'll use them, but if not, we'll autogenerate a set of MAC
9746 addresses based upon the device serial number */
9747
9748 static const v_MACADDR_t default_address =
9749 {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}};
Jeff Johnson295189b2012-06-20 16:38:30 -07009750
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309751 if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0],
9752 sizeof(default_address)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009753 {
9754 /* cfg.ini has the default address, invoke autogen logic */
9755
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309756 /* Here, passing Arg2 as 0 because we want to change the
9757 last 3 bytes (means non OUI bytes) of all the interfaces
9758 mac addr.
9759 */
9760 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0,
9761 default_address))
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309763 hddLog(VOS_TRACE_LEVEL_ERROR,
9764 "%s: Failed to generate wlan interface mac addr "
9765 "using MAC from ini file " MAC_ADDRESS_STR, __func__,
9766 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07009767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 }
9769 else
9770#endif //WLAN_AUTOGEN_MACADDR_FEATURE
9771 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009772 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 "%s: Invalid MAC address in NV, using MAC from ini file "
9774 MAC_ADDRESS_STR, __func__,
9775 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
9776 }
9777 }
9778 {
9779 eHalStatus halStatus;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309780
9781 /* Set the MAC Address Currently this is used by HAL to
9782 * add self sta. Remove this once self sta is added as
9783 * part of session open.
9784 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009785 halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID,
9786 (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0],
9787 sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) );
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309788
Jeff Johnson295189b2012-06-20 16:38:30 -07009789 if (!HAL_STATUS_SUCCESS( halStatus ))
9790 {
9791 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. "
9792 "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309793 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 }
9795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009796
9797 /*Start VOSS which starts up the SME/MAC/HAL modules and everything else
9798 Note: Firmware image will be read and downloaded inside vos_start API */
9799 status = vos_start( pHddCtx->pvosContext );
9800 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9801 {
9802 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309803 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 }
9805
Leo Chang6cec3e22014-01-21 15:33:49 -08009806#ifdef FEATURE_WLAN_CH_AVOID
9807 /* Plug in avoid channel notification callback
9808 * This should happen before ADD_SELF_STA
9809 * FW will send first IND with ADD_SELF_STA REQ from host */
Pradeep Reddy POTTETI5c2e16d2014-06-27 16:47:38 +05309810
9811 /* check the Channel Avoidance is enabled */
9812 if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance)
9813 {
9814 sme_AddChAvoidCallback(pHddCtx->hHal,
9815 hdd_hostapd_ch_avoid_cb);
9816 }
Leo Chang6cec3e22014-01-21 15:33:49 -08009817#endif /* FEATURE_WLAN_CH_AVOID */
9818
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009819 /* Exchange capability info between Host and FW and also get versioning info from FW */
9820 hdd_exchange_version_and_caps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07009821
Agarwal Ashishad9281b2014-06-10 14:57:30 +05309822#ifdef CONFIG_ENABLE_LINUX_REG
9823 status = wlan_hdd_init_channels(pHddCtx);
9824 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9825 {
9826 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed",
9827 __func__);
9828 goto err_vosstop;
9829 }
9830#endif
9831
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 status = hdd_post_voss_start_config( pHddCtx );
9833 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9834 {
9835 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed",
9836 __func__);
9837 goto err_vosstop;
9838 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009839
9840#ifndef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309841 wlan_hdd_cfg80211_update_reg_info( wiphy );
9842
9843 /* registration of wiphy dev with cfg80211 */
9844 if (0 > wlan_hdd_cfg80211_register(wiphy))
9845 {
9846 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9847 goto err_vosstop;
9848 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009850
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309851#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309852 /* registration of wiphy dev with cfg80211 */
9853 if (0 > wlan_hdd_cfg80211_register(wiphy))
9854 {
9855 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9856 goto err_vosstop;
9857 }
9858
Agarwal Ashish6db9d532014-09-30 18:19:10 +05309859 status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309860 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9861 {
9862 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed",
9863 __func__);
9864 goto err_unregister_wiphy;
9865 }
9866#endif
9867
c_hpothu4a298be2014-12-22 21:12:51 +05309868 wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx);
9869
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 if (VOS_STA_SAP_MODE == hdd_get_conparam())
9871 {
9872 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d",
9873 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9874 }
9875 else
9876 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d",
9878 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9879 if (pAdapter != NULL)
9880 {
Katya Nigama7d81d72014-11-12 12:44:34 +05309881 if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && !(pHddCtx->cfg_ini->intfMacAddr[0].bytes[0] & 0x02))
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309883 vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes,
9884 pHddCtx->cfg_ini->intfMacAddr[0].bytes,
9885 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudiedfc1b72012-10-18 20:25:55 -07009886
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309887 /* Generate the P2P Device Address. This consists of the device's
9888 * primary MAC address with the locally administered bit set.
9889 */
9890 pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02;
Jeff Johnsone7245742012-09-05 17:12:55 -07009891 }
9892 else
9893 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309894 tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx);
9895 if (p2p_dev_addr != NULL)
9896 {
9897 vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0],
9898 p2p_dev_addr, VOS_MAC_ADDR_SIZE);
9899 }
9900 else
9901 {
9902 hddLog(VOS_TRACE_LEVEL_FATAL,
9903 "%s: Failed to allocate mac_address for p2p_device",
9904 __func__);
9905 goto err_close_adapter;
9906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009908
9909 pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d",
9910 &pHddCtx->p2pDeviceAddress.bytes[0], FALSE );
9911 if ( NULL == pP2pAdapter )
9912 {
9913 hddLog(VOS_TRACE_LEVEL_FATAL,
9914 "%s: Failed to do hdd_open_adapter for P2P Device Interface",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009915 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009916 goto err_close_adapter;
9917 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009920
9921 if( pAdapter == NULL )
9922 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009923 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9924 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009926
Arif Hussain66559122013-11-21 10:11:40 -08009927 if (country_code)
9928 {
9929 eHalStatus ret;
Arif Hussaincb607082013-12-20 11:57:42 -08009930 INIT_COMPLETION(pAdapter->change_country_code);
Arif Hussain66559122013-11-21 10:11:40 -08009931 hdd_checkandupdate_dfssetting(pAdapter, country_code);
9932#ifndef CONFIG_ENABLE_LINUX_REG
9933 hdd_checkandupdate_phymode(pAdapter, country_code);
9934#endif
Arif Hussaineaf68602013-12-30 23:10:44 -08009935 ret = sme_ChangeCountryCode(pHddCtx->hHal,
9936 (void *)(tSmeChangeCountryCallback)
9937 wlan_hdd_change_country_code_callback,
Arif Hussain66559122013-11-21 10:11:40 -08009938 country_code,
9939 pAdapter, pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05309940 eSIR_TRUE, eSIR_TRUE);
Arif Hussain66559122013-11-21 10:11:40 -08009941 if (eHAL_STATUS_SUCCESS == ret)
9942 {
Arif Hussaincb607082013-12-20 11:57:42 -08009943 ret = wait_for_completion_interruptible_timeout(
9944 &pAdapter->change_country_code,
9945 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
9946
9947 if (0 >= ret)
9948 {
9949 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9950 "%s: SME while setting country code timed out", __func__);
9951 }
Arif Hussain66559122013-11-21 10:11:40 -08009952 }
9953 else
9954 {
Arif Hussaincb607082013-12-20 11:57:42 -08009955 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9956 "%s: SME Change Country code from module param fail ret=%d",
9957 __func__, ret);
Arif Hussain66559122013-11-21 10:11:40 -08009958 }
9959 }
9960
Jeff Johnson295189b2012-06-20 16:38:30 -07009961#ifdef WLAN_BTAMP_FEATURE
9962 vStatus = WLANBAP_Open(pVosContext);
9963 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9964 {
9965 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9966 "%s: Failed to open BAP",__func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009967 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 }
9969
9970 vStatus = BSL_Init(pVosContext);
9971 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9972 {
9973 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9974 "%s: Failed to Init BSL",__func__);
9975 goto err_bap_close;
9976 }
9977 vStatus = WLANBAP_Start(pVosContext);
9978 if (!VOS_IS_STATUS_SUCCESS(vStatus))
9979 {
9980 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9981 "%s: Failed to start TL",__func__);
9982 goto err_bap_close;
9983 }
9984
9985 pConfig = pHddCtx->cfg_ini;
9986 btAmpConfig.ucPreferredChannel = pConfig->preferredChannel;
9987 status = WLANBAP_SetConfig(&btAmpConfig);
9988
9989#endif //WLAN_BTAMP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -07009990
Mihir Shete9c238772014-10-15 14:35:16 +05309991 /*
9992 * UapsdMask is 0xf if U-APSD is enbaled for all AC's...
9993 * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value)
9994 * which is greater than 0xf. So the below check is safe to make
9995 * sure that there is no entry for UapsdMask in the ini
9996 */
9997 if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask)
9998 {
9999 if(IS_DYNAMIC_WMM_PS_ENABLED)
10000 {
10001 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO",
10002 __func__);
10003 pHddCtx->cfg_ini->UapsdMask =
10004 CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT;
10005 }
10006 else
10007 {
10008 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD",
10009 __func__);
10010 pHddCtx->cfg_ini->UapsdMask =
10011 CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT;
10012 }
10013 }
10014
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010015#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10016 if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE))
10017 {
10018 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__);
10019 pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0;
10020 sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal),
10021 pHddCtx->cfg_ini->isRoamOffloadScanEnabled);
10022 }
10023#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010024
Agarwal Ashish4b87f922014-06-18 03:03:21 +053010025 wlan_hdd_tdls_init(pHddCtx);
10026
Mihir Shetefc7ff5b2014-01-27 11:30:05 +053010027 sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done);
10028
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 /* Register with platform driver as client for Suspend/Resume */
10030 status = hddRegisterPmOps(pHddCtx);
10031 if ( !VOS_IS_STATUS_SUCCESS( status ) )
10032 {
10033 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__);
10034#ifdef WLAN_BTAMP_FEATURE
10035 goto err_bap_stop;
10036#else
Jeff Johnsone7245742012-09-05 17:12:55 -070010037 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -070010038#endif //WLAN_BTAMP_FEATURE
10039 }
10040
Yue Ma0d4891e2013-08-06 17:01:45 -070010041 /* Open debugfs interface */
10042 if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter))
10043 {
10044 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
10045 "%s: hdd_debugfs_init failed!", __func__);
Yue Ma0d4891e2013-08-06 17:01:45 -070010046 }
10047
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 /* Register TM level change handler function to the platform */
10049 status = hddDevTmRegisterNotifyCallback(pHddCtx);
10050 if ( !VOS_IS_STATUS_SUCCESS( status ) )
10051 {
10052 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__);
10053 goto err_unregister_pmops;
10054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010055
Jeff Johnson295189b2012-06-20 16:38:30 -070010056 // register net device notifier for device change notification
10057 ret = register_netdevice_notifier(&hdd_netdev_notifier);
10058
10059 if(ret < 0)
10060 {
10061 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__);
Siddharth Bhalcd92b782015-06-29 12:25:40 +053010062 goto err_unregister_pmops;
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 }
10064
10065 //Initialize the nlink service
10066 if(nl_srv_init() != 0)
10067 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010068 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 goto err_reg_netdev;
10070 }
10071
Leo Chang4ce1cc52013-10-21 18:27:15 -070010072#ifdef WLAN_KD_READY_NOTIFIER
10073 pHddCtx->kd_nl_init = 1;
10074#endif /* WLAN_KD_READY_NOTIFIER */
10075
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 //Initialize the BTC service
10077 if(btc_activate_service(pHddCtx) != 0)
10078 {
10079 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__);
10080 goto err_nl_srv;
10081 }
10082
10083#ifdef PTT_SOCK_SVC_ENABLE
10084 //Initialize the PTT service
10085 if(ptt_sock_activate_svc(pHddCtx) != 0)
10086 {
10087 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__);
10088 goto err_nl_srv;
10089 }
10090#endif
10091
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010092#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10093 if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable)
10094 {
Deepthi Gowri78083a32014-11-04 12:55:51 +053010095 if(wlan_logging_sock_activate_svc(
10096 pHddCtx->cfg_ini->wlanLoggingFEToConsole,
10097 pHddCtx->cfg_ini->wlanLoggingNumBuf))
10098 {
10099 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc"
10100 " failed", __func__);
10101 goto err_nl_srv;
10102 }
10103 //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for
10104 //EAPOL and DHCP
Sachin Ahuja8c65f382014-12-12 15:34:21 +053010105 if (!pHddCtx->cfg_ini->gEnableDebugLog)
10106 pHddCtx->cfg_ini->gEnableDebugLog =
10107 VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP;
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010108 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010109
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010110 if (pHddCtx->cfg_ini->wlanLoggingEnable &&
10111 (pHddCtx->cfg_ini->enableFWLogging ||
Siddharth Bhaldb963232015-06-25 19:34:35 +053010112 pHddCtx->cfg_ini->enableMgmtLogging ||
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010113 pHddCtx->cfg_ini->enableContFWLogging))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010114 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010115 hdd_init_frame_logging(pHddCtx);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010116 }
10117 else
10118 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Logging disabled in ini"));
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010120 }
10121
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010122#endif
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010123
10124
Sushant Kaushik215778f2015-05-21 14:05:36 +053010125 if (vos_is_multicast_logging())
10126 wlan_logging_set_log_level();
10127
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 hdd_register_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 if (VOS_STA_SAP_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -070010131 /* Action frame registered in one adapter which will
10132 * applicable to all interfaces
10133 */
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +053010134 wlan_hdd_cfg80211_register_frames(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010136
10137 mutex_init(&pHddCtx->sap_lock);
Mahesh A Saptasagar60627942014-10-13 13:55:14 +053010138 mutex_init(&pHddCtx->roc_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -070010139
Jeff Johnsone7245742012-09-05 17:12:55 -070010140#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
10141 /* Initialize the wake lcok */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010142 vos_wake_lock_init(&pHddCtx->rx_wake_lock,
Jeff Johnsone7245742012-09-05 17:12:55 -070010143 "qcom_rx_wakelock");
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010144
Jeff Johnsone7245742012-09-05 17:12:55 -070010145#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -080010146 /* Initialize the wake lcok */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010147 vos_wake_lock_init(&pHddCtx->sap_wake_lock,
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -080010148 "qcom_sap_wakelock");
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010149
Jeff Johnsone7245742012-09-05 17:12:55 -070010150
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010151 vos_event_init(&pHddCtx->scan_info.scan_finished_event);
10152 pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010153
Katya Nigam5c306ea2014-06-19 15:39:54 +053010154 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010156 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Katya Nigam5c306ea2014-06-19 15:39:54 +053010157
10158#ifdef FEATURE_WLAN_SCAN_PNO
10159 /*SME must send channel update configuration to RIVA*/
10160 sme_UpdateChannelConfig(pHddCtx->hHal);
10161#endif
Abhishek Singhf644b272014-08-21 02:59:39 +053010162 /* Send the update default channel list to the FW*/
10163 sme_UpdateChannelList(pHddCtx->hHal);
Mukul Sharma45063942015-04-01 20:07:59 +053010164
10165 /* Fwr capabilities received, Set the Dot11 mode */
10166 sme_SetDefDot11Mode(pHddCtx->hHal);
10167
Abhishek Singha306a442013-11-07 18:39:01 +053010168#ifndef CONFIG_ENABLE_LINUX_REG
10169 /*updating wiphy so that regulatory user hints can be processed*/
10170 if (wiphy)
10171 {
10172 regulatory_hint(wiphy, "00");
10173 }
10174#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010175 // Initialize the restart logic
10176 wlan_hdd_restart_init(pHddCtx);
Chilam NG571c65a2013-01-19 12:27:36 +053010177
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -070010178 //Register the traffic monitor timer now
10179 if ( pHddCtx->cfg_ini->dynSplitscan)
10180 {
10181 vos_timer_init(&pHddCtx->tx_rx_trafficTmr,
10182 VOS_TIMER_TYPE_SW,
10183 hdd_tx_rx_pkt_cnt_stat_timer_handler,
10184 (void *)pHddCtx);
10185 }
Srinivas Dasari030bad32015-02-18 23:23:54 +053010186 wlan_hdd_cfg80211_nan_init(pHddCtx);
10187
Dino Mycle6fb96c12014-06-10 11:52:40 +053010188#ifdef WLAN_FEATURE_EXTSCAN
10189 sme_EXTScanRegisterCallback(pHddCtx->hHal,
10190 wlan_hdd_cfg80211_extscan_callback,
10191 pHddCtx);
10192#endif /* WLAN_FEATURE_EXTSCAN */
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +053010193
10194#ifdef WLAN_NS_OFFLOAD
10195 // Register IPv6 notifier to notify if any change in IP
10196 // So that we can reconfigure the offload parameters
10197 pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed;
10198 ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier);
10199 if (ret)
10200 {
10201 hddLog(LOGE, FL("Failed to register IPv6 notifier"));
10202 }
10203 else
10204 {
10205 hddLog(LOGE, FL("Registered IPv6 notifier"));
10206 }
10207#endif
10208
10209 // Register IPv4 notifier to notify if any change in IP
10210 // So that we can reconfigure the offload parameters
10211 pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed;
10212 ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier);
10213 if (ret)
10214 {
10215 hddLog(LOGE, FL("Failed to register IPv4 notifier"));
10216 }
10217 else
10218 {
10219 hddLog(LOGE, FL("Registered IPv4 notifier"));
10220 }
10221
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 goto success;
10223
10224err_nl_srv:
Leo Chang59cdc7e2013-07-10 10:08:21 -070010225#ifdef WLAN_KD_READY_NOTIFIER
10226 nl_srv_exit(pHddCtx->ptt_pid);
10227#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -070010229#endif /* WLAN_KD_READY_NOTIFIER */
Jeff Johnson295189b2012-06-20 16:38:30 -070010230err_reg_netdev:
10231 unregister_netdevice_notifier(&hdd_netdev_notifier);
10232
Jeff Johnson295189b2012-06-20 16:38:30 -070010233err_unregister_pmops:
10234 hddDevTmUnregisterNotifyCallback(pHddCtx);
10235 hddDeregisterPmOps(pHddCtx);
10236
Yue Ma0d4891e2013-08-06 17:01:45 -070010237 hdd_debugfs_exit(pHddCtx);
10238
Jeff Johnson295189b2012-06-20 16:38:30 -070010239#ifdef WLAN_BTAMP_FEATURE
10240err_bap_stop:
10241 WLANBAP_Stop(pVosContext);
10242#endif
10243
10244#ifdef WLAN_BTAMP_FEATURE
10245err_bap_close:
10246 WLANBAP_Close(pVosContext);
10247#endif
10248
Jeff Johnson295189b2012-06-20 16:38:30 -070010249err_close_adapter:
10250 hdd_close_all_adapters( pHddCtx );
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +053010251#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053010252err_unregister_wiphy:
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +053010253#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010254 wiphy_unregister(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070010255err_vosstop:
10256 vos_stop(pVosContext);
10257
Amar Singhala49cbc52013-10-08 18:37:44 -070010258err_vosclose:
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 status = vos_sched_close( pVosContext );
10260 if (!VOS_IS_STATUS_SUCCESS(status)) {
10261 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
10262 "%s: Failed to close VOSS Scheduler", __func__);
10263 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
10264 }
Amar Singhala49cbc52013-10-08 18:37:44 -070010265 vos_close(pVosContext );
10266
Amar Singhal0a402232013-10-11 20:57:16 -070010267err_vos_nv_close:
10268
c_hpothue6a36282014-03-19 12:27:38 +053010269#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -070010270 vos_nv_close();
10271
c_hpothu70f8d812014-03-22 22:59:23 +053010272#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010273
10274err_wdclose:
10275 if(pHddCtx->cfg_ini->fIsLogpEnabled)
10276 vos_watchdog_close(pVosContext);
10277
Jeff Johnson295189b2012-06-20 16:38:30 -070010278err_config:
10279 kfree(pHddCtx->cfg_ini);
10280 pHddCtx->cfg_ini= NULL;
10281
10282err_free_hdd_context:
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010283 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Siddharth Bhalcd92b782015-06-29 12:25:40 +053010284 free_riva_power_on_lock("wlan");
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 wiphy_free(wiphy) ;
10286 //kfree(wdev) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 VOS_BUG(1);
10288
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -080010289 if (hdd_is_ssr_required())
10290 {
10291 /* WDI timeout had happened during load, so SSR is needed here */
10292 subsystem_restart("wcnss");
10293 msleep(5000);
10294 }
10295 hdd_set_ssr_required (VOS_FALSE);
10296
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080010297 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298
10299success:
10300 EXIT();
10301 return 0;
10302}
10303
10304/**---------------------------------------------------------------------------
10305
Jeff Johnson32d95a32012-09-10 13:15:23 -070010306 \brief hdd_driver_init() - Core Driver Init Function
Jeff Johnson295189b2012-06-20 16:38:30 -070010307
Jeff Johnson32d95a32012-09-10 13:15:23 -070010308 This is the driver entry point - called in different timeline depending
10309 on whether the driver is statically or dynamically linked
Jeff Johnson295189b2012-06-20 16:38:30 -070010310
10311 \param - None
10312
10313 \return - 0 for success, non zero for failure
10314
10315 --------------------------------------------------------------------------*/
Jeff Johnson32d95a32012-09-10 13:15:23 -070010316static int hdd_driver_init( void)
Jeff Johnson295189b2012-06-20 16:38:30 -070010317{
10318 VOS_STATUS status;
10319 v_CONTEXT_t pVosContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010320 struct device *dev = NULL;
10321 int ret_status = 0;
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010322#ifdef HAVE_WCNSS_CAL_DOWNLOAD
10323 int max_retries = 0;
10324#endif
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010325#ifdef HAVE_CBC_DONE
10326 int max_cbc_retries = 0;
10327#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010328
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010329#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10330 wlan_logging_sock_init_svc();
10331#endif
10332
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 ENTER();
10334
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010335 vos_wake_lock_init(&wlan_wake_lock, "wlan");
Jeff Johnson295189b2012-06-20 16:38:30 -070010336
10337 pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME,
10338 QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR);
10339
Jeff Johnson295189b2012-06-20 16:38:30 -070010340#ifdef ANI_BUS_TYPE_PCI
10341
10342 dev = wcnss_wlan_get_device();
10343
10344#endif // ANI_BUS_TYPE_PCI
10345
10346#ifdef ANI_BUS_TYPE_PLATFORM
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010347
10348#ifdef HAVE_WCNSS_CAL_DOWNLOAD
10349 /* wait until WCNSS driver downloads NV */
10350 while (!wcnss_device_ready() && 5 >= ++max_retries) {
10351 msleep(1000);
10352 }
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010353
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010354 if (max_retries >= 5) {
10355 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__);
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010356 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010357#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10358 wlan_logging_sock_deinit_svc();
10359#endif
10360
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010361 return -ENODEV;
10362 }
10363#endif
10364
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010365#ifdef HAVE_CBC_DONE
10366 while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) {
10367 msleep(1000);
10368 }
10369 if (max_cbc_retries >= 10) {
10370 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__);
10371 }
10372#endif
10373
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 dev = wcnss_wlan_get_device();
10375#endif // ANI_BUS_TYPE_PLATFORM
10376
10377
10378 do {
10379 if (NULL == dev) {
10380 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__);
10381 ret_status = -1;
10382 break;
10383 }
10384
Jeff Johnson295189b2012-06-20 16:38:30 -070010385#ifdef TIMER_MANAGER
10386 vos_timer_manager_init();
10387#endif
10388
10389 /* Preopen VOSS so that it is ready to start at least SAL */
10390 status = vos_preOpen(&pVosContext);
10391
10392 if (!VOS_IS_STATUS_SUCCESS(status))
10393 {
10394 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__);
10395 ret_status = -1;
10396 break;
10397 }
10398
Sushant Kaushik02beb352015-06-04 15:15:01 +053010399 hddTraceInit();
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010400#ifndef MODULE
10401 /* For statically linked driver, call hdd_set_conparam to update curr_con_mode
10402 */
10403 hdd_set_conparam((v_UINT_t)con_mode);
10404#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010405
10406 // Call our main init function
Jeff Johnsonbc676b42013-02-14 16:04:08 -080010407 if (hdd_wlan_startup(dev))
10408 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed",
Jeff Johnsonbc676b42013-02-14 16:04:08 -080010410 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 vos_preClose( &pVosContext );
10412 ret_status = -1;
10413 break;
10414 }
10415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 } while (0);
10417
10418 if (0 != ret_status)
10419 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010420#ifdef TIMER_MANAGER
10421 vos_timer_exit();
10422#endif
10423#ifdef MEMORY_DEBUG
10424 vos_mem_exit();
10425#endif
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010426 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010427#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10428 wlan_logging_sock_deinit_svc();
10429#endif
10430
Jeff Johnson295189b2012-06-20 16:38:30 -070010431 pr_err("%s: driver load failure\n", WLAN_MODULE_NAME);
10432 }
10433 else
10434 {
10435 //Send WLAN UP indication to Nlink Service
10436 send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0);
10437
10438 pr_info("%s: driver loaded\n", WLAN_MODULE_NAME);
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 }
10440
10441 EXIT();
10442
10443 return ret_status;
10444}
10445
Jeff Johnson32d95a32012-09-10 13:15:23 -070010446/**---------------------------------------------------------------------------
10447
10448 \brief hdd_module_init() - Init Function
10449
10450 This is the driver entry point (invoked when module is loaded using insmod)
10451
10452 \param - None
10453
10454 \return - 0 for success, non zero for failure
10455
10456 --------------------------------------------------------------------------*/
10457#ifdef MODULE
10458static int __init hdd_module_init ( void)
10459{
10460 return hdd_driver_init();
10461}
Jeff Johnson32d95a32012-09-10 13:15:23 -070010462#else /* #ifdef MODULE */
10463static int __init hdd_module_init ( void)
10464{
10465 /* Driver initialization is delayed to fwpath_changed_handler */
10466 return 0;
10467}
Jeff Johnson32d95a32012-09-10 13:15:23 -070010468#endif /* #ifdef MODULE */
10469
Jeff Johnson295189b2012-06-20 16:38:30 -070010470
10471/**---------------------------------------------------------------------------
10472
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010473 \brief hdd_driver_exit() - Exit function
Jeff Johnson295189b2012-06-20 16:38:30 -070010474
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010475 This is the driver exit point (invoked when module is unloaded using rmmod
10476 or con_mode was changed by userspace)
Jeff Johnson295189b2012-06-20 16:38:30 -070010477
10478 \param - None
10479
10480 \return - None
10481
10482 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010483static void hdd_driver_exit(void)
Jeff Johnson295189b2012-06-20 16:38:30 -070010484{
10485 hdd_context_t *pHddCtx = NULL;
10486 v_CONTEXT_t pVosContext = NULL;
Agarwal Ashish5e414792014-06-08 15:25:23 +053010487 v_REGDOMAIN_t regId;
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +053010488 unsigned long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010489
10490 pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR);
10491
10492 //Get the global vos context
10493 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
10494
10495 if(!pVosContext)
10496 {
10497 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
10498 goto done;
10499 }
10500
10501 //Get the HDD context.
10502 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
10503
10504 if(!pHddCtx)
10505 {
10506 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__);
10507 }
Katya Nigame7b69a82015-04-28 15:24:06 +053010508 else if (VOS_MONITOR_MODE == hdd_get_conparam())
10509 {
10510 hddLog(VOS_TRACE_LEVEL_INFO,"%s: MONITOR MODE",__func__);
10511 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
10512 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
10513 hdd_wlan_exit(pHddCtx);
10514 vos_preClose( &pVosContext );
10515 goto done;
10516 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 else
10518 {
Siddharth Bhal2e5871b2015-03-24 16:20:51 +053010519 /* We wait for active entry threads to exit from driver
10520 * by waiting until rtnl_lock is available.
10521 */
10522 rtnl_lock();
10523 rtnl_unlock();
10524
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010525 INIT_COMPLETION(pHddCtx->ssr_comp_var);
10526 if ((pHddCtx->isLogpInProgress) && (FALSE ==
10527 vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL)))
10528 {
Siddharth Bhala204f572015-01-17 02:03:36 +053010529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010530 "%s:SSR in Progress; block rmmod !!!", __func__);
Siddharth Bhala204f572015-01-17 02:03:36 +053010531 rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var,
10532 msecs_to_jiffies(30000));
10533 if(!rc)
10534 {
10535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10536 "%s:SSR timedout, fatal error", __func__);
10537 VOS_BUG(0);
10538 }
10539 }
10540
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010541 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
10542 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010543
c_hpothu8adb97b2014-12-08 19:38:20 +053010544 /* Driver Need to send country code 00 in below condition
10545 * 1) If gCountryCodePriority is set to 1; and last country
10546 * code set is through 11d. This needs to be done in case
10547 * when NV country code is 00.
10548 * This Needs to be done as when kernel store last country
10549 * code and if stored country code is not through 11d,
10550 * in sme_HandleChangeCountryCodeByUser we will disable 11d
10551 * in next load/unload as soon as we get any country through
10552 * 11d. In sme_HandleChangeCountryCodeByUser
10553 * pMsg->countryCode will be last countryCode and
10554 * pMac->scan.countryCode11d will be country through 11d so
10555 * due to mismatch driver will disable 11d.
10556 *
10557 */
Agarwal Ashish8db39882014-07-30 21:56:07 +053010558
c_hpothu8adb97b2014-12-08 19:38:20 +053010559 if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) &&
Agarwal Ashish8dcd2862014-07-25 11:58:52 +053010560 pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority &&
Abhishek Singh2a705962014-10-30 14:47:28 +053010561 sme_Is11dSupported(pHddCtx->hHal)))
c_hpothu8adb97b2014-12-08 19:38:20 +053010562 {
10563 hddLog(VOS_TRACE_LEVEL_INFO,
Agarwal Ashish8dcd2862014-07-25 11:58:52 +053010564 FL("CountryCode 00 is being set while unloading driver"));
c_hpothu8adb97b2014-12-08 19:38:20 +053010565 vos_nv_getRegDomainFromCountryCode(&regId , "00", COUNTRY_USER);
10566 }
Agarwal Ashish5e414792014-06-08 15:25:23 +053010567
c_hpothu8adb97b2014-12-08 19:38:20 +053010568 //Do all the cleanup before deregistering the driver
10569 hdd_wlan_exit(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 }
10571
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 vos_preClose( &pVosContext );
10573
10574#ifdef TIMER_MANAGER
10575 vos_timer_exit();
10576#endif
10577#ifdef MEMORY_DEBUG
10578 vos_mem_exit();
10579#endif
10580
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010581#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10582 wlan_logging_sock_deinit_svc();
10583#endif
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585done:
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010586 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010587
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME);
10589}
10590
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010591/**---------------------------------------------------------------------------
10592
10593 \brief hdd_module_exit() - Exit function
10594
10595 This is the driver exit point (invoked when module is unloaded using rmmod)
10596
10597 \param - None
10598
10599 \return - None
10600
10601 --------------------------------------------------------------------------*/
10602static void __exit hdd_module_exit(void)
10603{
10604 hdd_driver_exit();
10605}
10606
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010607#ifdef MODULE
10608static int fwpath_changed_handler(const char *kmessage,
10609 struct kernel_param *kp)
10610{
Jeff Johnson76052702013-04-16 13:55:05 -070010611 return param_set_copystring(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010612}
10613
10614static int con_mode_handler(const char *kmessage,
10615 struct kernel_param *kp)
10616{
Madan Mohan Koyyalamudif2f8d8b2012-10-11 17:06:59 -070010617 return param_set_int(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010618}
10619#else /* #ifdef MODULE */
10620/**---------------------------------------------------------------------------
10621
Jeff Johnson76052702013-04-16 13:55:05 -070010622 \brief kickstart_driver
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010623
Jeff Johnson76052702013-04-16 13:55:05 -070010624 This is the driver entry point
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010625 - delayed driver initialization when driver is statically linked
Jeff Johnson76052702013-04-16 13:55:05 -070010626 - invoked when module parameter fwpath is modified from userspace to signal
10627 initializing the WLAN driver or when con_mode is modified from userspace
10628 to signal a switch in operating mode
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010629
10630 \return - 0 for success, non zero for failure
10631
10632 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -070010633static int kickstart_driver(void)
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010634{
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010635 int ret_status;
10636
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010637 if (!wlan_hdd_inited) {
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010638 ret_status = hdd_driver_init();
10639 wlan_hdd_inited = ret_status ? 0 : 1;
10640 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010641 }
10642
10643 hdd_driver_exit();
Jeff Johnson76052702013-04-16 13:55:05 -070010644
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010645 msleep(200);
Jeff Johnson76052702013-04-16 13:55:05 -070010646
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010647 ret_status = hdd_driver_init();
10648 wlan_hdd_inited = ret_status ? 0 : 1;
10649 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010650}
10651
Jeff Johnson295189b2012-06-20 16:38:30 -070010652/**---------------------------------------------------------------------------
10653
Jeff Johnson76052702013-04-16 13:55:05 -070010654 \brief fwpath_changed_handler() - Handler Function
10655
10656 Handle changes to the fwpath parameter
10657
10658 \return - 0 for success, non zero for failure
10659
10660 --------------------------------------------------------------------------*/
10661static int fwpath_changed_handler(const char *kmessage,
10662 struct kernel_param *kp)
10663{
10664 int ret;
10665
10666 ret = param_set_copystring(kmessage, kp);
10667 if (0 == ret)
10668 ret = kickstart_driver();
10669 return ret;
10670}
10671
10672/**---------------------------------------------------------------------------
10673
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010674 \brief con_mode_handler() -
10675
10676 Handler function for module param con_mode when it is changed by userspace
10677 Dynamically linked - do nothing
10678 Statically linked - exit and init driver, as in rmmod and insmod
10679
Jeff Johnson76052702013-04-16 13:55:05 -070010680 \param -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010681
Jeff Johnson76052702013-04-16 13:55:05 -070010682 \return -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010683
10684 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -070010685static int con_mode_handler(const char *kmessage, struct kernel_param *kp)
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010686{
Jeff Johnson76052702013-04-16 13:55:05 -070010687 int ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010688
Jeff Johnson76052702013-04-16 13:55:05 -070010689 ret = param_set_int(kmessage, kp);
10690 if (0 == ret)
10691 ret = kickstart_driver();
10692 return ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010693}
10694#endif /* #ifdef MODULE */
10695
10696/**---------------------------------------------------------------------------
10697
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 \brief hdd_get_conparam() -
10699
10700 This is the driver exit point (invoked when module is unloaded using rmmod)
10701
10702 \param - None
10703
10704 \return - tVOS_CON_MODE
10705
10706 --------------------------------------------------------------------------*/
10707tVOS_CON_MODE hdd_get_conparam ( void )
10708{
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010709#ifdef MODULE
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 return (tVOS_CON_MODE)con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010711#else
10712 return (tVOS_CON_MODE)curr_con_mode;
10713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010714}
10715void hdd_set_conparam ( v_UINT_t newParam )
10716{
10717 con_mode = newParam;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010718#ifndef MODULE
10719 curr_con_mode = con_mode;
10720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010721}
10722/**---------------------------------------------------------------------------
10723
10724 \brief hdd_softap_sta_deauth() - function
10725
10726 This to take counter measure to handle deauth req from HDD
10727
10728 \param - pAdapter - Pointer to the HDD
10729
10730 \param - enable - boolean value
10731
10732 \return - None
10733
10734 --------------------------------------------------------------------------*/
10735
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010736VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter,
10737 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070010738{
Jeff Johnson295189b2012-06-20 16:38:30 -070010739 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010740 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -070010741
10742 ENTER();
10743
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070010744 hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)",
10745 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010746
10747 //Ignore request to deauth bcmc station
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010748 if (pDelStaParams->peerMacAddr[0] & 0x1)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010749 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -070010750
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010751 vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010752
10753 EXIT();
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010754 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -070010755}
10756
10757/**---------------------------------------------------------------------------
10758
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010759 \brief hdd_del_all_sta() - function
10760
10761 This function removes all the stations associated on stopping AP/P2P GO.
10762
10763 \param - pAdapter - Pointer to the HDD
10764
10765 \return - None
10766
10767 --------------------------------------------------------------------------*/
10768
10769int hdd_del_all_sta(hdd_adapter_t *pAdapter)
10770{
10771 v_U16_t i;
10772 VOS_STATUS vos_status;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010773 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10774 ptSapContext pSapCtx = NULL;
10775 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10776 if(pSapCtx == NULL){
10777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10778 FL("psapCtx is NULL"));
10779 return 1;
10780 }
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010781 ENTER();
10782
10783 hddLog(VOS_TRACE_LEVEL_INFO,
10784 "%s: Delete all STAs associated.",__func__);
10785 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10786 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
10787 )
10788 {
10789 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
10790 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010791 if ((pSapCtx->aStaInfo[i].isUsed) &&
10792 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010793 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010794 struct tagCsrDelStaParams delStaParams;
10795
10796 WLANSAP_PopulateDelStaParams(
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010797 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053010798 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
10799 SIR_MAC_MGMT_DEAUTH >> 4,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010800 &delStaParams);
10801 vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams);
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010802 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010803 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010804 }
10805 }
10806 }
10807
10808 EXIT();
10809 return 0;
10810}
10811
10812/**---------------------------------------------------------------------------
10813
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 \brief hdd_softap_sta_disassoc() - function
10815
10816 This to take counter measure to handle deauth req from HDD
10817
10818 \param - pAdapter - Pointer to the HDD
10819
10820 \param - enable - boolean value
10821
10822 \return - None
10823
10824 --------------------------------------------------------------------------*/
10825
10826void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress)
10827{
10828 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10829
10830 ENTER();
10831
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010832 hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010833
10834 //Ignore request to disassoc bcmc station
10835 if( pDestMacAddress[0] & 0x1 )
10836 return;
10837
10838 WLANSAP_DisassocSta(pVosContext,pDestMacAddress);
10839}
10840
10841void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable)
10842{
10843 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10844
10845 ENTER();
10846
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010847 hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010848
10849 WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable);
10850}
10851
Jeff Johnson295189b2012-06-20 16:38:30 -070010852/**---------------------------------------------------------------------------
10853 *
10854 * \brief hdd_get__concurrency_mode() -
10855 *
10856 *
10857 * \param - None
10858 *
10859 * \return - CONCURRENCY MODE
10860 *
10861 * --------------------------------------------------------------------------*/
10862tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void )
10863{
10864 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
10865 hdd_context_t *pHddCtx;
10866
10867 if (NULL != pVosContext)
10868 {
10869 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
10870 if (NULL != pHddCtx)
10871 {
10872 return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode;
10873 }
10874 }
10875
10876 /* we are in an invalid state :( */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010877 hddLog(LOGE, "%s: Invalid context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 return VOS_STA;
10879}
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010880v_BOOL_t
10881wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx)
10882{
10883 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010884
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010885 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO);
10886 if (pAdapter == NULL)
10887 {
10888 hddLog(VOS_TRACE_LEVEL_INFO,
10889 FL("GO doesn't exist"));
10890 return TRUE;
10891 }
10892 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10893 {
10894 hddLog(VOS_TRACE_LEVEL_INFO,
10895 FL("GO started"));
10896 return TRUE;
10897 }
10898 else
10899 /* wait till GO changes its interface to p2p device */
10900 hddLog(VOS_TRACE_LEVEL_INFO,
10901 FL("Del_bss called, avoid apps suspend"));
10902 return FALSE;
10903
10904}
Jeff Johnson295189b2012-06-20 16:38:30 -070010905/* Decide whether to allow/not the apps power collapse.
10906 * Allow apps power collapse if we are in connected state.
10907 * if not, allow only if we are in IMPS */
10908v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx)
10909{
10910 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
Srikant Kuppafef66a72013-01-30 17:32:44 -080010911 tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal);
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010912 tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10914 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10915 hdd_adapter_t *pAdapter = NULL;
10916 VOS_STATUS status;
Yathish9f22e662012-12-10 14:21:35 -080010917 tVOS_CONCURRENCY_MODE concurrent_state = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010918
Jeff Johnson295189b2012-06-20 16:38:30 -070010919 if (VOS_STA_SAP_MODE == hdd_get_conparam())
10920 return TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010921
Yathish9f22e662012-12-10 14:21:35 -080010922 concurrent_state = hdd_get_concurrency_mode();
10923
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010924 if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) &&
10925 !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx)))
10926 return FALSE;
Yathish9f22e662012-12-10 14:21:35 -080010927#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010928
Yathish9f22e662012-12-10 14:21:35 -080010929 if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) ||
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010930 (concurrent_state == (VOS_STA | VOS_P2P_GO)))&&
Yathish9f22e662012-12-10 14:21:35 -080010931 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
10932 return TRUE;
10933#endif
10934
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 /*loop through all adapters. TBD fix for Concurrency */
10936 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10937 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10938 {
10939 pAdapter = pAdapterNode->pAdapter;
10940 if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
10941 || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10942 {
Srikant Kuppafef66a72013-01-30 17:32:44 -080010943 if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled)
c_hpothu4e8faac2014-05-16 17:38:44 +053010944 && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD
c_hpothu1c6957d2015-01-06 18:19:47 +053010945 && pmcState != STOPPED && pmcState != STANDBY &&
10946 pmcState != WOWL)) ||
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010947 (eANI_BOOLEAN_TRUE == scanRspPending) ||
10948 (eANI_BOOLEAN_TRUE == inMiddleOfRoaming))
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 {
Mukul Sharma4be88422015-03-09 20:29:07 +053010950 if(pmcState == FULL_POWER &&
10951 sme_IsCoexScoIndicationSet(pHddCtx->hHal))
10952 {
10953 /*
10954 * When SCO indication comes from Coex module , host will
10955 * enter in to full power mode, but this should not prevent
10956 * apps processor power collapse.
10957 */
10958 hddLog(LOG1,
10959 FL("Allow apps power collapse"
10960 "even when sco indication is set"));
10961 return TRUE;
10962 }
Srikant Kuppafef66a72013-01-30 17:32:44 -080010963 hddLog( LOGE, "%s: do not allow APPS power collapse-"
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010964 "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d",
10965 __func__, pmcState, scanRspPending, inMiddleOfRoaming );
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 return FALSE;
10967 }
10968 }
10969 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10970 pAdapterNode = pNext;
10971 }
10972 return TRUE;
10973}
10974
Madan Mohan Koyyalamudic72a4d62012-11-08 14:59:34 -080010975/* Decides whether to send suspend notification to Riva
10976 * if any adapter is in BMPS; then it is required */
10977v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx)
10978{
10979 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
10980 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10981
10982 if (pConfig->fIsBmpsEnabled && (pmcState == BMPS))
10983 {
10984 return TRUE;
10985 }
10986 return FALSE;
10987}
10988
Jeff Johnson295189b2012-06-20 16:38:30 -070010989void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
10990{
10991 switch(mode)
10992 {
Chilam Ngc4244af2013-04-01 15:37:32 -070010993 case VOS_STA_MODE:
10994 case VOS_P2P_CLIENT_MODE:
10995 case VOS_P2P_GO_MODE:
10996 case VOS_STA_SAP_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -070010997 pHddCtx->concurrency_mode |= (1 << mode);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010998 pHddCtx->no_of_open_sessions[mode]++;
Jeff Johnson295189b2012-06-20 16:38:30 -070010999 break;
11000 default:
11001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011003 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
11004 "Number of open sessions for mode %d = %d"),
11005 pHddCtx->concurrency_mode, mode,
11006 pHddCtx->no_of_open_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070011007}
11008
11009
11010void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11011{
11012 switch(mode)
11013 {
Chilam Ngc4244af2013-04-01 15:37:32 -070011014 case VOS_STA_MODE:
11015 case VOS_P2P_CLIENT_MODE:
11016 case VOS_P2P_GO_MODE:
11017 case VOS_STA_SAP_MODE:
Agarwal Ashish51325b52014-06-16 16:50:49 +053011018 pHddCtx->no_of_open_sessions[mode]--;
11019 if (!(pHddCtx->no_of_open_sessions[mode]))
11020 pHddCtx->concurrency_mode &= (~(1 << mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 break;
11022 default:
11023 break;
11024 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011025 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
11026 "Number of open sessions for mode %d = %d"),
11027 pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]);
11028
11029}
11030/**---------------------------------------------------------------------------
11031 *
11032 * \brief wlan_hdd_incr_active_session()
11033 *
11034 * This function increments the number of active sessions
11035 * maintained per device mode
11036 * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented
11037 * Incase of SAP/P2P GO upon bss start it is incremented
11038 *
11039 * \param pHddCtx - HDD Context
11040 * \param mode - device mode
11041 *
11042 * \return - None
11043 *
11044 * --------------------------------------------------------------------------*/
11045void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11046{
11047 switch (mode) {
11048 case VOS_STA_MODE:
11049 case VOS_P2P_CLIENT_MODE:
11050 case VOS_P2P_GO_MODE:
11051 case VOS_STA_SAP_MODE:
11052 pHddCtx->no_of_active_sessions[mode]++;
11053 break;
11054 default:
11055 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
11056 break;
11057 }
11058 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
11059 mode,
11060 pHddCtx->no_of_active_sessions[mode]);
11061}
11062
11063/**---------------------------------------------------------------------------
11064 *
11065 * \brief wlan_hdd_decr_active_session()
11066 *
11067 * This function decrements the number of active sessions
11068 * maintained per device mode
11069 * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented
11070 * Incase of SAP/P2P GO upon bss stop it is decremented
11071 *
11072 * \param pHddCtx - HDD Context
11073 * \param mode - device mode
11074 *
11075 * \return - None
11076 *
11077 * --------------------------------------------------------------------------*/
11078void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11079{
11080 switch (mode) {
11081 case VOS_STA_MODE:
11082 case VOS_P2P_CLIENT_MODE:
11083 case VOS_P2P_GO_MODE:
11084 case VOS_STA_SAP_MODE:
Agarwal Ashish5325f522014-08-06 00:58:44 +053011085 if (pHddCtx->no_of_active_sessions[mode] > 0)
11086 pHddCtx->no_of_active_sessions[mode]--;
11087 else
11088 hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions"
11089 "is already Zero"));
Agarwal Ashish51325b52014-06-16 16:50:49 +053011090 break;
11091 default:
11092 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
11093 break;
11094 }
11095 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
11096 mode,
11097 pHddCtx->no_of_active_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070011098}
11099
Jeff Johnsone7245742012-09-05 17:12:55 -070011100/**---------------------------------------------------------------------------
11101 *
11102 * \brief wlan_hdd_restart_init
11103 *
11104 * This function initalizes restart timer/flag. An internal function.
11105 *
11106 * \param - pHddCtx
11107 *
11108 * \return - None
11109 *
11110 * --------------------------------------------------------------------------*/
11111
11112static void wlan_hdd_restart_init(hdd_context_t *pHddCtx)
11113{
11114 /* Initialize */
11115 pHddCtx->hdd_restart_retries = 0;
11116 atomic_set(&pHddCtx->isRestartInProgress, 0);
11117 vos_timer_init(&pHddCtx->hdd_restart_timer,
11118 VOS_TIMER_TYPE_SW,
11119 wlan_hdd_restart_timer_cb,
11120 pHddCtx);
11121}
11122/**---------------------------------------------------------------------------
11123 *
11124 * \brief wlan_hdd_restart_deinit
11125 *
11126 * This function cleans up the resources used. An internal function.
11127 *
11128 * \param - pHddCtx
11129 *
11130 * \return - None
11131 *
11132 * --------------------------------------------------------------------------*/
11133
11134static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx)
11135{
11136
11137 VOS_STATUS vos_status;
11138 /* Block any further calls */
11139 atomic_set(&pHddCtx->isRestartInProgress, 1);
11140 /* Cleanup */
11141 vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer );
11142 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011143 hddLog(LOGE, FL("Failed to stop HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011144 vos_status = vos_timer_destroy(&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 destroy HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011147
11148}
11149
11150/**---------------------------------------------------------------------------
11151 *
11152 * \brief wlan_hdd_framework_restart
11153 *
11154 * This function uses a cfg80211 API to start a framework initiated WLAN
11155 * driver module unload/load.
11156 *
11157 * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT).
11158 *
11159 *
11160 * \param - pHddCtx
11161 *
11162 * \return - VOS_STATUS_SUCCESS: Success
11163 * VOS_STATUS_E_EMPTY: Adapter is Empty
11164 * VOS_STATUS_E_NOMEM: No memory
11165
11166 * --------------------------------------------------------------------------*/
11167
11168static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx)
11169{
11170 VOS_STATUS status = VOS_STATUS_SUCCESS;
11171 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011172 int len = (sizeof (struct ieee80211_mgmt));
11173 struct ieee80211_mgmt *mgmt = NULL;
11174
11175 /* Prepare the DEAUTH managment frame with reason code */
11176 mgmt = kzalloc(len, GFP_KERNEL);
11177 if(mgmt == NULL)
11178 {
11179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11180 "%s: memory allocation failed (%d bytes)", __func__, len);
11181 return VOS_STATUS_E_NOMEM;
11182 }
11183 mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK;
Jeff Johnsone7245742012-09-05 17:12:55 -070011184
11185 /* Iterate over all adapters/devices */
11186 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011187 if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status))
11188 {
11189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11190 FL("fail to get adapter: %p %d"), pAdapterNode, status);
11191 goto end;
11192 }
11193
Jeff Johnsone7245742012-09-05 17:12:55 -070011194 do
11195 {
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011196 if(pAdapterNode->pAdapter &&
11197 WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic)
Jeff Johnsone7245742012-09-05 17:12:55 -070011198 {
11199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11200 "restarting the driver(intf:\'%s\' mode:%d :try %d)",
11201 pAdapterNode->pAdapter->dev->name,
11202 pAdapterNode->pAdapter->device_mode,
11203 pHddCtx->hdd_restart_retries + 1);
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011204 /*
11205 * CFG80211 event to restart the driver
11206 *
11207 * 'cfg80211_send_unprot_deauth' sends a
11208 * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state
11209 * of SME(Linux Kernel) state machine.
11210 *
11211 * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart
11212 * the driver.
11213 *
11214 */
11215
11216 cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len );
Jeff Johnsone7245742012-09-05 17:12:55 -070011217 }
11218 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11219 pAdapterNode = pNext;
11220 } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status));
11221
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011222 end:
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011223 /* Free the allocated management frame */
11224 kfree(mgmt);
11225
Jeff Johnsone7245742012-09-05 17:12:55 -070011226 /* Retry until we unload or reach max count */
11227 if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT)
11228 vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS);
11229
11230 return status;
11231
11232}
11233/**---------------------------------------------------------------------------
11234 *
11235 * \brief wlan_hdd_restart_timer_cb
11236 *
11237 * Restart timer callback. An internal function.
11238 *
11239 * \param - User data:
11240 *
11241 * \return - None
11242 *
11243 * --------------------------------------------------------------------------*/
11244
11245void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback)
11246{
11247 hdd_context_t *pHddCtx = usrDataForCallback;
11248 wlan_hdd_framework_restart(pHddCtx);
11249 return;
11250
11251}
11252
11253
11254/**---------------------------------------------------------------------------
11255 *
11256 * \brief wlan_hdd_restart_driver
11257 *
11258 * This function sends an event to supplicant to restart the WLAN driver.
11259 *
11260 * This function is called from vos_wlanRestart.
11261 *
11262 * \param - pHddCtx
11263 *
11264 * \return - VOS_STATUS_SUCCESS: Success
11265 * VOS_STATUS_E_EMPTY: Adapter is Empty
11266 * VOS_STATUS_E_ALREADY: Request already in progress
11267
11268 * --------------------------------------------------------------------------*/
11269VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx)
11270{
11271 VOS_STATUS status = VOS_STATUS_SUCCESS;
11272
11273 /* A tight check to make sure reentrancy */
11274 if(atomic_xchg(&pHddCtx->isRestartInProgress, 1))
11275 {
Mihir Shetefd528652014-06-23 19:07:50 +053011276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsone7245742012-09-05 17:12:55 -070011277 "%s: WLAN restart is already in progress", __func__);
11278
11279 return VOS_STATUS_E_ALREADY;
11280 }
Sameer Thalappil0c164f52013-03-28 15:27:56 -070011281 /* Send reset FIQ to WCNSS to invoke SSR. */
Madan Mohan Koyyalamudie388b342012-11-08 15:03:16 -080011282#ifdef HAVE_WCNSS_RESET_INTR
Siddharth Bhal864e7e82015-04-07 20:07:24 +053011283 wcnss_reset_fiq(TRUE);
Madan Mohan Koyyalamudibb8f0172012-09-28 15:36:06 -070011284#endif
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -070011285
Jeff Johnsone7245742012-09-05 17:12:55 -070011286 return status;
11287}
11288
Mihir Shetee1093ba2014-01-21 20:13:32 +053011289/**---------------------------------------------------------------------------
11290 *
11291 * \brief wlan_hdd_init_channels
11292 *
11293 * This function is used to initialize the channel list in CSR
11294 *
11295 * This function is called from hdd_wlan_startup
11296 *
11297 * \param - pHddCtx: HDD context
11298 *
11299 * \return - VOS_STATUS_SUCCESS: Success
11300 * VOS_STATUS_E_FAULT: Failure reported by SME
11301
11302 * --------------------------------------------------------------------------*/
11303static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx)
11304{
11305 eHalStatus status;
11306
11307 status = sme_InitChannels(pHddCtx->hHal);
11308 if (HAL_STATUS_SUCCESS(status))
11309 {
11310 return VOS_STATUS_SUCCESS;
11311 }
11312 else
11313 {
11314 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)",
11315 __func__, status);
11316 return VOS_STATUS_E_FAULT;
11317 }
11318}
11319
Mihir Shete04206452014-11-20 17:50:58 +053011320#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +053011321VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx, driver_load_type init )
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053011322{
11323 eHalStatus status;
11324
Agarwal Ashish6db9d532014-09-30 18:19:10 +053011325 status = sme_InitChannelsForCC(pHddCtx->hHal, init);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053011326 if (HAL_STATUS_SUCCESS(status))
11327 {
11328 return VOS_STATUS_SUCCESS;
11329 }
11330 else
11331 {
11332 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)",
11333 __func__, status);
11334 return VOS_STATUS_E_FAULT;
11335 }
11336}
Mihir Shete04206452014-11-20 17:50:58 +053011337#endif
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -070011338/*
11339 * API to find if there is any STA or P2P-Client is connected
11340 */
11341VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx)
11342{
11343 return sme_isSta_p2p_clientConnected(pHddCtx->hHal);
11344}
Jeff Johnsone7245742012-09-05 17:12:55 -070011345
Mihir Shetee2ae82a2015-03-16 14:08:49 +053011346
11347/*
11348 * API to find if the firmware will send logs using DXE channel
11349 */
11350v_U8_t hdd_is_fw_logging_enabled(void)
11351{
11352 hdd_context_t *pHddCtx;
11353
11354 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD,
11355 vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
11356
Sachin Ahuja084313e2015-05-21 17:57:10 +053011357 return (pHddCtx && pHddCtx->cfg_ini->enableMgmtLogging);
Mihir Shetee2ae82a2015-03-16 14:08:49 +053011358}
11359
Agarwal Ashish57e84372014-12-05 18:26:53 +053011360/*
Mihir Shetebe94ebb2015-05-26 12:07:14 +053011361 * API to find if the firmware will send trace logs using DXE channel
11362 */
11363v_U8_t hdd_is_fw_ev_logging_enabled(void)
11364{
11365 hdd_context_t *pHddCtx;
11366
11367 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD,
11368 vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
11369
11370 return (pHddCtx && pHddCtx->cfg_ini->enableFWLogging);
11371}
11372/*
Agarwal Ashish57e84372014-12-05 18:26:53 +053011373 * API to find if there is any session connected
11374 */
11375VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx)
11376{
11377 return sme_is_any_session_connected(pHddCtx->hHal);
11378}
11379
11380
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011381int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter)
11382{
11383 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11384 hdd_scaninfo_t *pScanInfo = NULL;
Girish Gowli4bf7a632014-06-12 13:42:11 +053011385 long status = 0;
c_hpothua3d45d52015-01-05 14:11:17 +053011386 tSirAbortScanStatus abortScanStatus;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011387
11388 pScanInfo = &pHddCtx->scan_info;
Ratnam Rachuric7681132015-06-30 10:35:13 +053011389 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011390 if (pScanInfo->mScanPending)
11391 {
c_hpothua3d45d52015-01-05 14:11:17 +053011392 abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
11393 eCSR_SCAN_ABORT_DEFAULT);
11394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11395 FL("abortScanStatus: %d"), abortScanStatus);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011396
c_hpothua3d45d52015-01-05 14:11:17 +053011397 /* If there is active scan command lets wait for the completion else
11398 * there is no need to wait as scan command might be in the SME pending
11399 * command list.
11400 */
11401 if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY)
11402 {
c_hpothua3d45d52015-01-05 14:11:17 +053011403 status = wait_for_completion_interruptible_timeout(
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011404 &pScanInfo->abortscan_event_var,
11405 msecs_to_jiffies(5000));
c_hpothua3d45d52015-01-05 14:11:17 +053011406 if (0 >= status)
11407 {
11408 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowli4bf7a632014-06-12 13:42:11 +053011409 "%s: Timeout or Interrupt occurred while waiting for abort"
11410 "scan, status- %ld", __func__, status);
c_hpothua3d45d52015-01-05 14:11:17 +053011411 return -ETIMEDOUT;
11412 }
11413 }
11414 else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE)
11415 {
11416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11417 FL("hdd_abort_mac_scan failed"));
11418 return -VOS_STATUS_E_FAILURE;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011419 }
11420 }
Girish Gowli4bf7a632014-06-12 13:42:11 +053011421 return 0;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011422}
11423
c_hpothu225aa7c2014-10-22 17:45:13 +053011424VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx)
11425{
11426 hdd_adapter_t *pAdapter;
11427 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11428 VOS_STATUS vosStatus;
11429
11430 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
11431 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
11432 {
11433 pAdapter = pAdapterNode->pAdapter;
11434 if (NULL != pAdapter)
11435 {
11436 if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ||
11437 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ||
11438 WLAN_HDD_P2P_GO == pAdapter->device_mode)
11439 {
11440 hddLog(LOG1, FL("abort ROC deviceMode: %d"),
11441 pAdapter->device_mode);
11442 if (VOS_STATUS_SUCCESS !=
11443 wlan_hdd_cancel_existing_remain_on_channel(pAdapter))
11444 {
11445 hddLog(LOGE, FL("failed to abort ROC"));
11446 return VOS_STATUS_E_FAILURE;
11447 }
11448 }
11449 }
11450 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11451 pAdapterNode = pNext;
11452 }
11453 return VOS_STATUS_SUCCESS;
11454}
Mahesh A Saptasagard477b092015-02-06 15:12:16 +053011455
Mihir Shete0be28772015-02-17 18:42:14 +053011456hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx)
11457{
11458 hdd_adapter_t *pAdapter;
11459 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11460 hdd_cfg80211_state_t *cfgState;
11461 hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL;
11462 VOS_STATUS vosStatus;
11463
11464 vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode);
11465 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
11466 {
11467 pAdapter = pAdapterNode->pAdapter;
11468 if (NULL != pAdapter)
11469 {
11470 cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter);
11471 pRemainChanCtx = cfgState->remain_on_chan_ctx;
11472 if (pRemainChanCtx)
11473 break;
11474 }
11475 vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext);
11476 pAdapterNode = pNext;
11477 }
11478 return pRemainChanCtx;
11479}
11480
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011481/**
11482 * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels
11483 *
11484 * @pHddCtx: HDD context within host driver
11485 * @dfsScanMode: dfsScanMode passed from ioctl
11486 *
11487 */
11488
11489VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx,
11490 tANI_U8 dfsScanMode)
11491{
11492 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11493 hdd_adapter_t *pAdapter;
11494 VOS_STATUS vosStatus;
11495 hdd_station_ctx_t *pHddStaCtx;
11496 eHalStatus status = eHAL_STATUS_SUCCESS;
11497
11498 if(!pHddCtx)
11499 {
11500 hddLog(LOGE, FL("HDD context is Null"));
11501 return eHAL_STATUS_FAILURE;
11502 }
11503
11504 if (pHddCtx->scan_info.mScanPending)
11505 {
11506 hddLog(LOG1, FL("Aborting scan for sessionId: %d"),
11507 pHddCtx->scan_info.sessionId);
11508 hdd_abort_mac_scan(pHddCtx,
11509 pHddCtx->scan_info.sessionId,
11510 eCSR_SCAN_ABORT_DEFAULT);
11511 }
11512
11513 if (!dfsScanMode)
11514 {
11515 vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode);
11516 while ((NULL != pAdapterNode) &&
11517 (VOS_STATUS_SUCCESS == vosStatus))
11518 {
11519 pAdapter = pAdapterNode->pAdapter;
11520
11521 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
11522 {
11523 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11524
11525 if(!pHddStaCtx)
11526 {
11527 hddLog(LOGE, FL("HDD STA context is Null"));
11528 return eHAL_STATUS_FAILURE;
11529 }
11530
11531 /* if STA is already connected on DFS channel,
11532 disconnect immediately*/
11533 if (hdd_connIsConnected(pHddStaCtx) &&
11534 (NV_CHANNEL_DFS ==
11535 vos_nv_getChannelEnabledState(
11536 pHddStaCtx->conn_info.operationChannel)))
11537 {
11538 status = sme_RoamDisconnect(pHddCtx->hHal,
11539 pAdapter->sessionId,
11540 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11541 hddLog(LOG1, FL("Client connected on DFS channel %d,"
11542 "sme_RoamDisconnect returned with status: %d"
11543 "for sessionid: %d"), pHddStaCtx->conn_info.
11544 operationChannel, status, pAdapter->sessionId);
11545 }
11546 }
11547
11548 vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode,
11549 &pNext);
11550 pAdapterNode = pNext;
11551 }
11552 }
11553
11554 sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode);
11555 sme_UpdateDFSRoamMode(pHddCtx->hHal,
11556 (dfsScanMode != DFS_CHNL_SCAN_DISABLED));
11557
11558 status = sme_HandleDFSChanScan(pHddCtx->hHal);
11559 if (!HAL_STATUS_SUCCESS(status))
11560 {
11561 hddLog(LOGE,
11562 FL("Failed in sme_HandleDFSChanScan (err=%d)"), status);
11563 return status;
11564 }
11565
11566 return status;
11567}
11568
Nirav Shah7e3c8132015-06-22 23:51:42 +053011569static int hdd_log2_ceil(unsigned value)
11570{
11571 /* need to switch to unsigned math so that negative values
11572 * will right-shift towards 0 instead of -1
11573 */
11574 unsigned tmp = value;
11575 int log2 = -1;
11576
11577 if (value == 0)
11578 return 0;
11579
11580 while (tmp) {
11581 log2++;
11582 tmp >>= 1;
11583 }
11584 if (1U << log2 != value)
11585 log2++;
11586
11587 return log2;
11588}
11589
11590/**
11591 * hdd_sta_id_hash_attach() - initialize sta id to macaddr hash
11592 * @pAdapter: adapter handle
11593 *
11594 * Return: vos status
11595 */
11596VOS_STATUS hdd_sta_id_hash_attach(hdd_adapter_t *pAdapter)
11597{
11598 int hash_elem, log2, i;
11599
11600 spin_lock_bh( &pAdapter->sta_hash_lock);
11601 if (pAdapter->is_sta_id_hash_initialized == VOS_TRUE) {
11602 spin_unlock_bh( &pAdapter->sta_hash_lock);
11603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11604 "%s: hash already attached for session id %d",
11605 __func__, pAdapter->sessionId);
11606 return VOS_STATUS_SUCCESS;
11607 }
11608 spin_unlock_bh( &pAdapter->sta_hash_lock);
11609
11610 hash_elem = WLAN_MAX_STA_COUNT;
11611 hash_elem *= HDD_STA_ID_HASH_MULTIPLIER;
11612 log2 = hdd_log2_ceil(hash_elem);
11613 hash_elem = 1 << log2;
11614
11615 pAdapter->sta_id_hash.mask = hash_elem - 1;
11616 pAdapter->sta_id_hash.idx_bits = log2;
11617 pAdapter->sta_id_hash.bins =
11618 vos_mem_malloc(hash_elem *sizeof(hdd_list_t));
11619 if (!pAdapter->sta_id_hash.bins) {
11620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11621 "%s: malloc failed for session %d",
11622 __func__, pAdapter->sessionId);
11623 return VOS_STATUS_E_NOMEM;
11624 }
11625
11626 for (i = 0; i < hash_elem; i++)
11627 hdd_list_init(&pAdapter->sta_id_hash.bins[i], WLAN_MAX_STA_COUNT);
11628
11629 spin_lock_bh( &pAdapter->sta_hash_lock);
11630 pAdapter->is_sta_id_hash_initialized = VOS_TRUE;
11631 spin_unlock_bh( &pAdapter->sta_hash_lock);
11632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11633 "%s: Station ID Hash attached for session id %d",
11634 __func__, pAdapter->sessionId);
11635
11636 return VOS_STATUS_SUCCESS;
11637}
11638
11639/**
11640 * hdd_sta_id_hash_detach() - deinit sta_id to macaddr hash
11641 * @pAdapter: adapter handle
11642 *
11643 * Return: vos status
11644 */
11645VOS_STATUS hdd_sta_id_hash_detach(hdd_adapter_t *pAdapter)
11646{
11647 int hash_elem, i;
11648 v_SIZE_t size;
11649
11650 spin_lock_bh( &pAdapter->sta_hash_lock);
11651 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11652 spin_unlock_bh( &pAdapter->sta_hash_lock);
11653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11654 "%s: hash not initialized for session id %d",
11655 __func__, pAdapter->sessionId);
11656 return VOS_STATUS_SUCCESS;
11657 }
11658
11659 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
11660 spin_unlock_bh( &pAdapter->sta_hash_lock);
11661
11662 hash_elem = 1 << pAdapter->sta_id_hash.idx_bits;
11663
11664 /* free all station info*/
11665 for (i = 0; i < hash_elem; i++) {
11666 hdd_list_size(&pAdapter->sta_id_hash.bins[i], &size);
11667 if (size != 0) {
11668 VOS_STATUS status;
11669 hdd_staid_hash_node_t *sta_info_node = NULL;
11670 hdd_staid_hash_node_t *next_node = NULL;
11671 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[i],
11672 (hdd_list_node_t**) &sta_info_node );
11673
11674 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11675 {
11676 status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[i],
11677 &sta_info_node->node);
11678 vos_mem_free(sta_info_node);
11679
11680 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[i],
11681 (hdd_list_node_t*)sta_info_node,
11682 (hdd_list_node_t**)&next_node);
11683 sta_info_node = next_node;
11684 }
11685 }
11686 }
11687
11688 vos_mem_free(pAdapter->sta_id_hash.bins);
11689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11690 "%s: Station ID Hash detached for session id %d",
11691 __func__, pAdapter->sessionId);
11692 return VOS_STATUS_SUCCESS;
11693}
11694
11695/**
11696 * hdd_sta_id_hash_calculate_index() - derive index from macaddr
11697 * @pAdapter: adapter handle
11698 * @mac_addr_in: input mac address
11699 *
11700 * Return: index derived from mac address
11701 */
11702int hdd_sta_id_hash_calculate_index(hdd_adapter_t *pAdapter,
11703 v_MACADDR_t *mac_addr_in)
11704{
11705 uint16 index;
11706 struct hdd_align_mac_addr_t * mac_addr =
11707 (struct hdd_align_mac_addr_t *)mac_addr_in;
11708
11709 index = mac_addr->bytes_ab ^
11710 mac_addr->bytes_cd ^ mac_addr->bytes_ef;
11711 index ^= index >> pAdapter->sta_id_hash.idx_bits;
11712 index &= pAdapter->sta_id_hash.mask;
11713 return index;
11714}
11715
11716/**
11717 * hdd_sta_id_hash_add_entry() - add entry in hash
11718 * @pAdapter: adapter handle
11719 * @sta_id: station id
11720 * @mac_addr: mac address
11721 *
11722 * Return: vos status
11723 */
11724VOS_STATUS hdd_sta_id_hash_add_entry(hdd_adapter_t *pAdapter,
11725 v_U8_t sta_id, v_MACADDR_t *mac_addr)
11726{
11727 uint16 index;
11728 hdd_staid_hash_node_t *sta_info_node = NULL;
11729
11730 spin_lock_bh( &pAdapter->sta_hash_lock);
11731 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11732 spin_unlock_bh( &pAdapter->sta_hash_lock);
11733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11734 "%s: hash is not initialized for session id %d",
11735 __func__, pAdapter->sessionId);
11736 return VOS_STATUS_E_FAILURE;
11737 }
11738
11739 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr);
11740 sta_info_node = vos_mem_malloc(sizeof(hdd_staid_hash_node_t));
11741 if (!sta_info_node) {
11742 spin_unlock_bh( &pAdapter->sta_hash_lock);
11743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11744 "%s: malloc failed", __func__);
11745 return VOS_STATUS_E_NOMEM;
11746 }
11747
11748 sta_info_node->sta_id = sta_id;
11749 vos_mem_copy(&sta_info_node->mac_addr, mac_addr, sizeof(v_MACADDR_t));
11750
11751 hdd_list_insert_back ( &pAdapter->sta_id_hash.bins[index],
11752 (hdd_list_node_t*) sta_info_node );
11753 spin_unlock_bh( &pAdapter->sta_hash_lock);
11754 return VOS_STATUS_SUCCESS;
11755}
11756
11757/**
11758 * hdd_sta_id_hash_remove_entry() - remove entry from hash
11759 * @pAdapter: adapter handle
11760 * @sta_id: station id
11761 * @mac_addr: mac address
11762 *
11763 * Return: vos status
11764 */
11765VOS_STATUS hdd_sta_id_hash_remove_entry(hdd_adapter_t *pAdapter,
11766 v_U8_t sta_id, v_MACADDR_t *mac_addr)
11767{
11768 uint16 index;
11769 VOS_STATUS status;
11770 hdd_staid_hash_node_t *sta_info_node = NULL;
11771 hdd_staid_hash_node_t *next_node = NULL;
11772
11773 spin_lock_bh( &pAdapter->sta_hash_lock);
11774 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11775 spin_unlock_bh( &pAdapter->sta_hash_lock);
11776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11777 "%s: hash is not initialized for session id %d",
11778 __func__, pAdapter->sessionId);
11779 return VOS_STATUS_E_FAILURE;
11780 }
11781
11782 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr);
11783 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index],
11784 (hdd_list_node_t**) &sta_info_node );
11785
11786 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11787 {
11788 if (sta_info_node->sta_id == sta_id) {
11789 status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[index],
11790 &sta_info_node->node);
11791 vos_mem_free(sta_info_node);
11792 break;
11793 }
11794 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index],
11795 (hdd_list_node_t*)sta_info_node, (hdd_list_node_t**)&next_node);
11796 sta_info_node = next_node;
11797 }
11798 spin_unlock_bh( &pAdapter->sta_hash_lock);
11799 return status;
11800}
11801
11802/**
11803 * hdd_sta_id_find_from_mac_addr() - find sta id from mac address
11804 * @pAdapter: adapter handle
11805 * @mac_addr_in: mac address
11806 *
11807 * Return: station id
11808 */
11809int hdd_sta_id_find_from_mac_addr(hdd_adapter_t *pAdapter,
11810 v_MACADDR_t *mac_addr_in)
11811{
11812 uint8 is_found = 0;
11813 uint8 sta_id = HDD_WLAN_INVALID_STA_ID;
11814 uint16 index;
11815 VOS_STATUS status;
11816 hdd_staid_hash_node_t *sta_info_node = NULL;
11817 hdd_staid_hash_node_t *next_node = NULL;
11818
11819 spin_lock_bh( &pAdapter->sta_hash_lock);
11820 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11821 spin_unlock_bh( &pAdapter->sta_hash_lock);
11822 hddLog(VOS_TRACE_LEVEL_ERROR,
11823 FL("hash is not initialized for session id %d"),
11824 pAdapter->sessionId);
11825 return HDD_WLAN_INVALID_STA_ID;
11826 }
11827
11828 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr_in);
11829 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index],
11830 (hdd_list_node_t**) &sta_info_node );
11831
11832 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11833 {
11834 if (vos_mem_compare(&sta_info_node->mac_addr,
11835 mac_addr_in, sizeof(v_MACADDR_t))) {
11836 is_found = 1;
11837 sta_id = sta_info_node->sta_id;
11838 break;
11839 }
11840 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index],
11841 (hdd_list_node_t*)sta_info_node,
11842 (hdd_list_node_t**)&next_node);
11843 sta_info_node = next_node;
11844 }
11845 spin_unlock_bh( &pAdapter->sta_hash_lock);
11846 return sta_id;
11847}
11848
Jeff Johnson295189b2012-06-20 16:38:30 -070011849//Register the module init/exit functions
11850module_init(hdd_module_init);
11851module_exit(hdd_module_exit);
11852
11853MODULE_LICENSE("Dual BSD/GPL");
11854MODULE_AUTHOR("Qualcomm Atheros, Inc.");
11855MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER");
11856
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070011857module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode,
11858 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011859
Jeff Johnson76052702013-04-16 13:55:05 -070011860module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011861 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Arif Hussain66559122013-11-21 10:11:40 -080011862
11863module_param(enable_dfs_chan_scan, int,
11864 S_IRUSR | S_IRGRP | S_IROTH);
11865
11866module_param(enable_11d, int,
11867 S_IRUSR | S_IRGRP | S_IROTH);
11868
11869module_param(country_code, charp,
11870 S_IRUSR | S_IRGRP | S_IROTH);