blob: 2b1d0821c16c0d22607a4236991d0a95b6aa74d7 [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,
Anand N Sunkade9adb1b2015-07-29 09:56:45 +0530210 struct sk_buff *skb
211#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
212 , void *accel_priv
213#endif
214#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
215 , select_queue_fallback_t fallback
216#endif
217);
Jeff Johnson295189b2012-06-20 16:38:30 -0700218
219#ifdef WLAN_FEATURE_PACKET_FILTERING
220static void hdd_set_multicast_list(struct net_device *dev);
221#endif
222
223void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter);
224
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800225#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -0800226void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand);
227static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels);
Srinivas Girigowda100eb322013-03-15 16:48:20 -0700228static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid,
229 tANI_U8 *pChannel, tANI_U8 *pDwellTime,
230 tANI_U8 **pBuf, tANI_U8 *pBufLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -0700231static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
232 tANI_U8 *pTargetApBssid,
233 tANI_U8 *pChannel);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800234#endif
Ratheesh S P21280412015-05-19 14:21:52 +0530235
236/* Store WLAN driver info in a global variable such that crash debugger
237 can extract it from driver debug symbol and crashdump for post processing */
238tANI_U8 g_wlan_driver[ ] = "pronto_driver";
239
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800240#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700241VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800242#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700243
Mihir Shetee1093ba2014-01-21 20:13:32 +0530244static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx);
Sushant Kaushik8bc7df22014-04-09 17:55:29 +0530245const char * hdd_device_modetoString(v_U8_t device_mode)
246{
247 switch(device_mode)
248 {
249 CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION );
250 CASE_RETURN_STRING( WLAN_HDD_SOFTAP );
251 CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT );
252 CASE_RETURN_STRING( WLAN_HDD_P2P_GO );
253 CASE_RETURN_STRING( WLAN_HDD_MONITOR);
254 CASE_RETURN_STRING( WLAN_HDD_FTM );
255 CASE_RETURN_STRING( WLAN_HDD_IBSS );
256 CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE );
257 default:
258 return "device_mode Unknown";
259 }
260}
Mihir Shetee1093ba2014-01-21 20:13:32 +0530261
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +0530262static int __hdd_netdev_notifier_call(struct notifier_block * nb,
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 unsigned long state,
264 void *ndev)
265{
266 struct net_device *dev = ndev;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson27cee452013-03-27 11:10:24 -0700268 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700269#ifdef WLAN_BTAMP_FEATURE
270 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -0700271#endif
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530272 long result;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274 //Make sure that this callback corresponds to our device.
Jeff Johnson27cee452013-03-27 11:10:24 -0700275 if ((strncmp(dev->name, "wlan", 4)) &&
Amar Singhal4c723bd2013-03-25 18:14:15 -0700276 (strncmp(dev->name, "p2p", 3)))
277 return NOTIFY_DONE;
278
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 if (!dev->ieee80211_ptr)
Jeff Johnson27cee452013-03-27 11:10:24 -0700280 return NOTIFY_DONE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
Jeff Johnson27cee452013-03-27 11:10:24 -0700282 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -0800284 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 VOS_ASSERT(0);
286 return NOTIFY_DONE;
287 }
288
Jeff Johnson27cee452013-03-27 11:10:24 -0700289 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
290 if (NULL == pHddCtx)
291 {
292 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__);
293 VOS_ASSERT(0);
294 return NOTIFY_DONE;
295 }
Sameer Thalappil14067972014-01-23 14:54:54 -0800296 if (pHddCtx->isLogpInProgress)
297 return NOTIFY_DONE;
298
Jeff Johnson27cee452013-03-27 11:10:24 -0700299
300 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu",
301 __func__, dev->name, state);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302
303 switch (state) {
304 case NETDEV_REGISTER:
305 break;
306
307 case NETDEV_UNREGISTER:
308 break;
309
310 case NETDEV_UP:
311 break;
312
313 case NETDEV_DOWN:
314 break;
315
316 case NETDEV_CHANGE:
Jeff Johnsone7245742012-09-05 17:12:55 -0700317 if(TRUE == pAdapter->isLinkUpSvcNeeded)
318 complete(&pAdapter->linkup_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 break;
320
321 case NETDEV_GOING_DOWN:
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530322 result = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +0530323 if (result < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530324 {
325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
326 "%s: Timeout occurred while waiting for abortscan %ld",
327 __func__, result);
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 }
329 else
330 {
331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +0530332 "%s: Scan Abort Successful" , __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 }
334#ifdef WLAN_BTAMP_FEATURE
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 status = WLANBAP_StopAmp();
337 if(VOS_STATUS_SUCCESS != status )
338 {
339 pHddCtx->isAmpAllowed = VOS_TRUE;
340 hddLog(VOS_TRACE_LEVEL_FATAL,
341 "%s: Failed to stop AMP", __func__);
342 }
343 else
344 {
345 //a state m/c implementation in PAL is TBD to avoid this delay
346 msleep(500);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700347 if ( pHddCtx->isAmpAllowed )
348 {
349 WLANBAP_DeregisterFromHCI();
350 pHddCtx->isAmpAllowed = VOS_FALSE;
351 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 }
353#endif //WLAN_BTAMP_FEATURE
354 break;
355
356 default:
357 break;
358 }
359
360 return NOTIFY_DONE;
361}
362
Mukul Sharmaa78cf6b2015-02-24 16:59:01 +0530363static int hdd_netdev_notifier_call(struct notifier_block * nb,
364 unsigned long state,
365 void *ndev)
366{
367 int ret;
368 vos_ssr_protect(__func__);
369 ret = __hdd_netdev_notifier_call( nb, state, ndev);
370 vos_ssr_unprotect(__func__);
371 return ret;
372}
373
Jeff Johnson295189b2012-06-20 16:38:30 -0700374struct notifier_block hdd_netdev_notifier = {
375 .notifier_call = hdd_netdev_notifier_call,
376};
377
378/*---------------------------------------------------------------------------
379 * Function definitions
380 *-------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700381void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx);
382void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700383//variable to hold the insmod parameters
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700384static int con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -0700385#ifndef MODULE
386/* current con_mode - used only for statically linked driver
387 * con_mode is changed by userspace to indicate a mode change which will
388 * result in calling the module exit and init functions. The module
389 * exit function will clean up based on the value of con_mode prior to it
390 * being changed by userspace. So curr_con_mode records the current con_mode
391 * for exit when con_mode becomes the next mode for init
392 */
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700393static int curr_con_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700394#endif
395
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -0800396/**---------------------------------------------------------------------------
397
398 \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable
399
400 Called immediately after the cfg.ini is read in order to configure
401 the desired trace levels.
402
403 \param - moduleId - module whose trace level is being configured
404 \param - bitmask - bitmask of log levels to be enabled
405
406 \return - void
407
408 --------------------------------------------------------------------------*/
409static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask)
410{
411 wpt_tracelevel level;
412
413 /* if the bitmask is the default value, then a bitmask was not
414 specified in cfg.ini, so leave the logging level alone (it
415 will remain at the "compiled in" default value) */
416 if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask)
417 {
418 return;
419 }
420
421 /* a mask was specified. start by disabling all logging */
422 vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0);
423
424 /* now cycle through the bitmask until all "set" bits are serviced */
425 level = VOS_TRACE_LEVEL_FATAL;
426 while (0 != bitmask)
427 {
428 if (bitmask & 1)
429 {
430 vos_trace_setValue(moduleId, level, 1);
431 }
432 level++;
433 bitmask >>= 1;
434 }
435}
436
437
Jeff Johnson295189b2012-06-20 16:38:30 -0700438/**---------------------------------------------------------------------------
439
440 \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable
441
442 Called immediately after the cfg.ini is read in order to configure
443 the desired trace levels in the WDI.
444
445 \param - moduleId - module whose trace level is being configured
446 \param - bitmask - bitmask of log levels to be enabled
447
448 \return - void
449
450 --------------------------------------------------------------------------*/
451static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask)
452{
453 wpt_tracelevel level;
454
455 /* if the bitmask is the default value, then a bitmask was not
456 specified in cfg.ini, so leave the logging level alone (it
457 will remain at the "compiled in" default value) */
458 if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask)
459 {
460 return;
461 }
462
463 /* a mask was specified. start by disabling all logging */
464 wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0);
465
466 /* now cycle through the bitmask until all "set" bits are serviced */
467 level = eWLAN_PAL_TRACE_LEVEL_FATAL;
468 while (0 != bitmask)
469 {
470 if (bitmask & 1)
471 {
472 wpalTraceSetLevel(moduleId, level, 1);
473 }
474 level++;
475 bitmask >>= 1;
476 }
477}
Jeff Johnson295189b2012-06-20 16:38:30 -0700478
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530479/*
480 * FUNCTION: wlan_hdd_validate_context
481 * This function is used to check the HDD context
482 */
483int wlan_hdd_validate_context(hdd_context_t *pHddCtx)
484{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530485
486 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
487 {
Mahesh A Saptasagar886997a2015-03-04 13:15:51 +0530488 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530489 "%s: HDD context is Null", __func__);
490 return -ENODEV;
491 }
492
493 if (pHddCtx->isLogpInProgress)
494 {
Mahesh A Saptasagar886997a2015-03-04 13:15:51 +0530495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
c_hpothu8adb97b2014-12-08 19:38:20 +0530496 "%s: LOGP %s. Ignore!!", __func__,
497 vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL)
498 ?"failed":"in Progress");
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530499 return -EAGAIN;
500 }
501
Mihir Shete18156292014-03-11 15:38:30 +0530502 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530503 {
Mahesh A Saptasagar886997a2015-03-04 13:15:51 +0530504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530505 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
506 return -EAGAIN;
507 }
508 return 0;
509}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700510#ifdef CONFIG_ENABLE_LINUX_REG
511void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx)
512{
513 hdd_adapter_t *pAdapter = NULL;
514 hdd_station_ctx_t *pHddStaCtx = NULL;
515 eCsrPhyMode phyMode;
516 hdd_config_t *cfg_param = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +0530517
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700518 if (NULL == pHddCtx)
519 {
520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
521 "HDD Context is null !!");
522 return ;
523 }
524
525 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
526 if (NULL == pAdapter)
527 {
528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
529 "pAdapter is null !!");
530 return ;
531 }
532
533 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
534 if (NULL == pHddStaCtx)
535 {
536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
537 "pHddStaCtx is null !!");
538 return ;
539 }
540
541 cfg_param = pHddCtx->cfg_ini;
542 if (NULL == cfg_param)
543 {
544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
545 "cfg_params not available !!");
546 return ;
547 }
548
549 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
550
551 if (!pHddCtx->isVHT80Allowed)
552 {
553 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
554 (eCSR_DOT11_MODE_11ac == phyMode) ||
555 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
556 {
557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
558 "Setting phymode to 11n!!");
559 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
560 }
561 }
562 else
563 {
564 /*New country Supports 11ac as well resetting value back from .ini*/
565 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
566 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
567 return ;
568 }
569
570 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
571 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
572 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
573 {
574 VOS_STATUS vosStatus;
575
576 // need to issue a disconnect to CSR.
577 INIT_COMPLETION(pAdapter->disconnect_comp_var);
578 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
579 pAdapter->sessionId,
580 eCSR_DISCONNECT_REASON_UNSPECIFIED );
581
582 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530583 {
584 long ret;
585
586 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700587 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530588 if (0 >= ret)
589 hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"),
590 ret);
591 }
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700592
593 }
594}
595#else
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530596void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code)
597{
598 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
599 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
600 hdd_config_t *cfg_param;
601 eCsrPhyMode phyMode;
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530602 long ret;
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530603
604 if (NULL == pHddCtx)
605 {
606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
607 "HDD Context is null !!");
608 return ;
609 }
610
611 cfg_param = pHddCtx->cfg_ini;
612
613 if (NULL == cfg_param)
614 {
615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
616 "cfg_params not available !!");
617 return ;
618 }
619
620 phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter));
621
622 if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code))
623 {
624 if ((eCSR_DOT11_MODE_AUTO == phyMode) ||
625 (eCSR_DOT11_MODE_11ac == phyMode) ||
626 (eCSR_DOT11_MODE_11ac_ONLY == phyMode))
627 {
628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
629 "Setting phymode to 11n!!");
630 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n);
631 }
632 }
633 else
634 {
635 /*New country Supports 11ac as well resetting value back from .ini*/
636 sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter),
637 hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode));
638 return ;
639 }
640
641 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
642 ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) ||
643 (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode)))
644 {
645 VOS_STATUS vosStatus;
646
647 // need to issue a disconnect to CSR.
648 INIT_COMPLETION(pAdapter->disconnect_comp_var);
649 vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
650 pAdapter->sessionId,
651 eCSR_DISCONNECT_REASON_UNSPECIFIED );
652
653 if (VOS_STATUS_SUCCESS == vosStatus)
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530654 {
655 ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530656 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +0530657 if (ret <= 0)
658 {
659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
660 "wait on disconnect_comp_var is failed %ld", ret);
661 }
662 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530663
664 }
665}
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -0700666#endif //CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530667
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700668void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code)
669{
670 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
671 hdd_config_t *cfg_param;
672
673 if (NULL == pHddCtx)
674 {
675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
676 "HDD Context is null !!");
677 return ;
678 }
679
680 cfg_param = pHddCtx->cfg_ini;
681
682 if (NULL == cfg_param)
683 {
684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
685 "cfg_params not available !!");
686 return ;
687 }
688
Agarwal Ashish738843c2014-09-25 12:27:56 +0530689 if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) ||
690 pHddCtx->disable_dfs_flag == TRUE)
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -0700691 {
692 /*New country doesn't support DFS */
693 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0);
694 }
695 else
696 {
697 /*New country Supports DFS as well resetting value back from .ini*/
698 sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan);
699 }
700
701}
702
Rajeev79dbe4c2013-10-05 11:03:42 +0530703#ifdef FEATURE_WLAN_BATCH_SCAN
704
705/**---------------------------------------------------------------------------
706
707 \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from
708 input string
709
710 This function extracts assigned integer from string in below format:
711 "STRING=10" : extracts integer 10 from this string
712
713 \param - pInPtr Pointer to input string
714 \param - base Base for string to int conversion(10 for decimal 16 for hex)
715 \param - pOutPtr Pointer to variable in which extracted integer needs to be
716 assigned
717 \param - pLastArg to tell whether it is last arguement in input string or
718 not
719
720 \return - NULL for failure cases
721 pointer to next arguement in input string for success cases
722 --------------------------------------------------------------------------*/
723static tANI_U8 *
724hdd_extract_assigned_int_from_str
725(
726 tANI_U8 *pInPtr,
727 tANI_U8 base,
728 tANI_U32 *pOutPtr,
729 tANI_U8 *pLastArg
730)
731{
732 int tempInt;
733 int v = 0;
734 char buf[32];
735 int val = 0;
736 *pLastArg = FALSE;
737
738 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
739 if (NULL == pInPtr)
740 {
741 return NULL;
742 }
743
744 pInPtr++;
745
746 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
747
748 val = sscanf(pInPtr, "%32s ", buf);
749 if (val < 0 && val > strlen(pInPtr))
750 {
751 return NULL;
752 }
753 pInPtr += val;
754 v = kstrtos32(buf, base, &tempInt);
755 if (v < 0)
756 {
757 return NULL;
758 }
Rajeev Kumar4d93d842014-01-02 18:31:21 -0800759 if (tempInt < 0)
760 {
761 tempInt = 0;
762 }
Rajeev79dbe4c2013-10-05 11:03:42 +0530763 *pOutPtr = tempInt;
764
765 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
766 if (NULL == pInPtr)
767 {
768 *pLastArg = TRUE;
769 return NULL;
770 }
771 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
772
773 return pInPtr;
774}
775
776/**---------------------------------------------------------------------------
777
778 \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from
779 input string
780
781 This function extracts assigned character from string in below format:
782 "STRING=A" : extracts char 'A' from this string
783
784 \param - pInPtr Pointer to input string
785 \param - pOutPtr Pointer to variable in which extracted char needs to be
786 assigned
787 \param - pLastArg to tell whether it is last arguement in input string or
788 not
789
790 \return - NULL for failure cases
791 pointer to next arguement in input string for success cases
792 --------------------------------------------------------------------------*/
793static tANI_U8 *
794hdd_extract_assigned_char_from_str
795(
796 tANI_U8 *pInPtr,
797 tANI_U8 *pOutPtr,
798 tANI_U8 *pLastArg
799)
800{
801 *pLastArg = FALSE;
802
803 pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE);
804 if (NULL == pInPtr)
805 {
806 return NULL;
807 }
808
809 pInPtr++;
810
811 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
812
813 *pOutPtr = *pInPtr;
814
815 pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE);
816 if (NULL == pInPtr)
817 {
818 *pLastArg = TRUE;
819 return NULL;
820 }
821 while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++;
822
823 return pInPtr;
824}
825
826
827/**---------------------------------------------------------------------------
828
829 \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command
830
831 This function parses set batch scan command in below format:
832 WLS_BATCHING_SET <space> followed by below arguements
833 "SCANFREQ=XX" : Optional defaults to 30 sec
834 "MSCAN=XX" : Required number of scans to attempt to batch
835 "BESTN=XX" : Best Network (RSSI) defaults to 16
836 "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B.
837 A. implies only 5 GHz , B. implies only 2.4GHz
838 "RTT=X" : optional defaults to 0
839 returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on
840 error
841
842 For example input commands:
843 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is
844 translated into set batch scan with following parameters:
845 a) Frequence 60 seconds
846 b) Batch 10 scans together
847 c) Best RSSI to be 20
848 d) 5GHz band only
849 e) RTT is equal to 0
850
851 \param - pValue Pointer to input channel list
852 \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure
853
854 \return - 0 for success non-zero for failure
855
856 --------------------------------------------------------------------------*/
857static int
858hdd_parse_set_batchscan_command
859(
860 tANI_U8 *pValue,
861 tSirSetBatchScanReq *pHddSetBatchScanReq
862)
863{
864 tANI_U8 *inPtr = pValue;
865 tANI_U8 val = 0;
866 tANI_U8 lastArg = 0;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800867 tANI_U32 nScanFreq;
868 tANI_U32 nMscan;
869 tANI_U32 nBestN;
870 tANI_U8 ucRfBand;
871 tANI_U32 nRtt;
Rajeev Kumarc933d982013-11-18 20:04:20 -0800872 tANI_U32 temp;
Rajeev79dbe4c2013-10-05 11:03:42 +0530873
874 /*initialize default values*/
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800875 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ;
876 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
877 nRtt = 0;
878 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK;
Rajeev79dbe4c2013-10-05 11:03:42 +0530879
880 /*go to space after WLS_BATCHING_SET command*/
881 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
882 /*no argument after the command*/
883 if (NULL == inPtr)
884 {
885 return -EINVAL;
886 }
887
888 /*no space after the command*/
889 else if (SPACE_ASCII_VALUE != *inPtr)
890 {
891 return -EINVAL;
892 }
893
894 /*removing empty spaces*/
895 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
896
897 /*no argument followed by spaces*/
898 if ('\0' == *inPtr)
899 {
900 return -EINVAL;
901 }
902
903 /*check and parse SCANFREQ*/
904 if ((strncmp(inPtr, "SCANFREQ", 8) == 0))
905 {
906 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800907 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800908
Rajeev Kumarc933d982013-11-18 20:04:20 -0800909 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800910 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800911 nScanFreq = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800912 }
913
Rajeev79dbe4c2013-10-05 11:03:42 +0530914 if ( (NULL == inPtr) || (TRUE == lastArg))
915 {
916 return -EINVAL;
917 }
918 }
919
920 /*check and parse MSCAN*/
921 if ((strncmp(inPtr, "MSCAN", 5) == 0))
922 {
923 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800924 &nMscan, &lastArg);
925
926 if (0 == nMscan)
927 {
928 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
929 "invalid MSCAN=%d", nMscan);
930 return -EINVAL;
931 }
932
Rajeev79dbe4c2013-10-05 11:03:42 +0530933 if (TRUE == lastArg)
934 {
935 goto done;
936 }
937 else if (NULL == inPtr)
938 {
939 return -EINVAL;
940 }
941 }
942 else
943 {
944 return -EINVAL;
945 }
946
947 /*check and parse BESTN*/
948 if ((strncmp(inPtr, "BESTN", 5) == 0))
949 {
950 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumarc933d982013-11-18 20:04:20 -0800951 &temp, &lastArg);
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800952
Rajeev Kumarc933d982013-11-18 20:04:20 -0800953 if (0 != temp)
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800954 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800955 nBestN = temp;
Rajeev Kumar45e64a72013-11-18 19:48:15 -0800956 }
957
Rajeev79dbe4c2013-10-05 11:03:42 +0530958 if (TRUE == lastArg)
959 {
960 goto done;
961 }
962 else if (NULL == inPtr)
963 {
964 return -EINVAL;
965 }
966 }
967
968 /*check and parse CHANNEL*/
969 if ((strncmp(inPtr, "CHANNEL", 7) == 0))
970 {
971 inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg);
Rajeev Kumarc933d982013-11-18 20:04:20 -0800972
Rajeev79dbe4c2013-10-05 11:03:42 +0530973 if (('A' == val) || ('a' == val))
974 {
c_hpothuebf89732014-02-25 13:00:24 +0530975 ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530976 }
977 else if (('B' == val) || ('b' == val))
978 {
c_hpothuebf89732014-02-25 13:00:24 +0530979 ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY;
Rajeev79dbe4c2013-10-05 11:03:42 +0530980 }
981 else
982 {
Rajeev Kumarc933d982013-11-18 20:04:20 -0800983 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
984 }
985
986 if (TRUE == lastArg)
987 {
988 goto done;
989 }
990 else if (NULL == inPtr)
991 {
Rajeev79dbe4c2013-10-05 11:03:42 +0530992 return -EINVAL;
993 }
994 }
995
996 /*check and parse RTT*/
997 if ((strncmp(inPtr, "RTT", 3) == 0))
998 {
999 inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
Rajeev Kumar45e64a72013-11-18 19:48:15 -08001000 &nRtt, &lastArg);
Rajeev79dbe4c2013-10-05 11:03:42 +05301001 if (TRUE == lastArg)
1002 {
1003 goto done;
1004 }
1005 if (NULL == inPtr)
1006 {
1007 return -EINVAL;
1008 }
1009 }
1010
1011
1012done:
1013
Rajeev Kumar45e64a72013-11-18 19:48:15 -08001014 pHddSetBatchScanReq->scanFrequency = nScanFreq;
1015 pHddSetBatchScanReq->numberOfScansToBatch = nMscan;
1016 pHddSetBatchScanReq->bestNetwork = nBestN;
1017 pHddSetBatchScanReq->rfBand = ucRfBand;
1018 pHddSetBatchScanReq->rtt = nRtt;
1019
Rajeev79dbe4c2013-10-05 11:03:42 +05301020 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1021 "Received WLS_BATCHING_SET with SCANFREQ=%d "
1022 "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d",
1023 pHddSetBatchScanReq->scanFrequency,
1024 pHddSetBatchScanReq->numberOfScansToBatch,
1025 pHddSetBatchScanReq->bestNetwork,
1026 pHddSetBatchScanReq->rfBand,
1027 pHddSetBatchScanReq->rtt);
1028
1029 return 0;
1030}/*End of hdd_parse_set_batchscan_command*/
1031
1032/**---------------------------------------------------------------------------
1033
1034 \brief hdd_set_batch_scan_req_callback () - This function is called after
1035 receiving set batch scan response from FW and it saves set batch scan
1036 response data FW to HDD context and sets the completion event on
1037 which hdd_ioctl is waiting
1038
1039 \param - callbackContext Pointer to HDD adapter
1040 \param - pRsp Pointer to set batch scan response data received from FW
1041
1042 \return - nothing
1043
1044 --------------------------------------------------------------------------*/
1045static void hdd_set_batch_scan_req_callback
1046(
1047 void *callbackContext,
1048 tSirSetBatchScanRsp *pRsp
1049)
1050{
1051 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
1052 tSirSetBatchScanRsp *pHddSetBatchScanRsp;
1053
1054 /*sanity check*/
1055 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1056 {
1057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1058 "%s: Invalid pAdapter magic", __func__);
1059 VOS_ASSERT(0);
1060 return;
1061 }
1062 pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp;
1063
1064 /*save set batch scan response*/
1065 pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch;
1066
1067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1068 "Received set batch scan rsp from FW with nScansToBatch=%d",
1069 pHddSetBatchScanRsp->nScansToBatch);
1070
1071 pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE;
1072 complete(&pAdapter->hdd_set_batch_scan_req_var);
1073
1074 return;
1075}/*End of hdd_set_batch_scan_req_callback*/
1076
1077
1078/**---------------------------------------------------------------------------
1079
1080 \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta
1081 info in hdd batch scan response queue
1082
1083 \param - pAdapter Pointer to hdd adapter
1084 \param - pAPMetaInfo Pointer to access point meta info
1085 \param - scanId scan ID of batch scan response
1086 \param - isLastAp tells whether AP is last AP in batch scan response or not
1087
1088 \return - nothing
1089
1090 --------------------------------------------------------------------------*/
1091static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter,
1092 tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp)
1093{
1094 tHddBatchScanRsp *pHead;
1095 tHddBatchScanRsp *pNode;
1096 tHddBatchScanRsp *pPrev;
1097 tHddBatchScanRsp *pTemp;
1098 tANI_U8 ssidLen;
1099
1100 /*head of hdd batch scan response queue*/
1101 pHead = pAdapter->pBatchScanRsp;
1102
1103 pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp));
1104 if (NULL == pNode)
1105 {
1106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1107 "%s: Could not allocate memory", __func__);
1108 VOS_ASSERT(0);
1109 return;
1110 }
1111
1112 vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid,
1113 sizeof(pNode->ApInfo.bssid));
1114 ssidLen = strlen(pApMetaInfo->ssid);
1115 if (SIR_MAX_SSID_SIZE < ssidLen)
1116 {
1117 /*invalid scan result*/
1118 vos_mem_free(pNode);
1119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1120 "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen);
1121 return;
1122 }
1123 vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen);
1124 /*null terminate ssid*/
1125 pNode->ApInfo.ssid[ssidLen] = '\0';
1126 pNode->ApInfo.ch = pApMetaInfo->ch;
1127 pNode->ApInfo.rssi = pApMetaInfo->rssi;
1128 pNode->ApInfo.age = pApMetaInfo->timestamp;
1129 pNode->ApInfo.batchId = scanId;
1130 pNode->ApInfo.isLastAp = isLastAp;
1131
1132 pNode->pNext = NULL;
1133 if (NULL == pHead)
1134 {
1135 pAdapter->pBatchScanRsp = pNode;
1136 }
1137 else
1138 {
1139 pTemp = pHead;
1140 while (NULL != pTemp)
1141 {
1142 pPrev = pTemp;
1143 pTemp = pTemp->pNext;
1144 }
1145 pPrev->pNext = pNode;
1146 }
1147
1148 return;
1149}/*End of hdd_populate_batch_scan_rsp_queue*/
1150
1151/**---------------------------------------------------------------------------
1152
1153 \brief hdd_batch_scan_result_ind_callback () - This function is called after
1154 receiving batch scan response indication from FW. It saves get batch scan
1155 response data in HDD batch scan response queue. This callback sets the
1156 completion event on which hdd_ioctl is waiting only after getting complete
1157 batch scan response data from FW
1158
1159 \param - callbackContext Pointer to HDD adapter
1160 \param - pRsp Pointer to get batch scan response data received from FW
1161
1162 \return - nothing
1163
1164 --------------------------------------------------------------------------*/
1165static void hdd_batch_scan_result_ind_callback
1166(
1167 void *callbackContext,
1168 void *pRsp
1169)
1170{
1171 v_BOOL_t isLastAp;
1172 tANI_U32 numApMetaInfo;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001173 tANI_U32 numNetworkInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301174 tANI_U32 numberScanList;
1175 tANI_U32 nextScanListOffset;
1176 tANI_U32 nextApMetaInfoOffset;
1177 hdd_adapter_t* pAdapter;
1178 tpSirBatchScanList pScanList;
1179 tpSirBatchScanNetworkInfo pApMetaInfo;
1180 tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/
1181 tSirSetBatchScanReq *pReq;
1182
1183 pAdapter = (hdd_adapter_t *)callbackContext;
1184 /*sanity check*/
Rajeev Kumar5286bb92013-12-05 11:52:10 -08001185 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Rajeev79dbe4c2013-10-05 11:03:42 +05301186 {
1187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1188 "%s: Invalid pAdapter magic", __func__);
1189 VOS_ASSERT(0);
1190 return;
1191 }
1192
1193 /*initialize locals*/
1194 pReq = &pAdapter->hddSetBatchScanReq;
1195 pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp;
1196 isLastAp = FALSE;
1197 numApMetaInfo = 0;
Rajeev Kumarce651e42013-10-21 18:57:15 -07001198 numNetworkInScanList = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05301199 numberScanList = 0;
1200 nextScanListOffset = 0;
1201 nextApMetaInfoOffset = 0;
1202 pScanList = NULL;
1203 pApMetaInfo = NULL;
1204
1205 if ((NULL == pBatchScanRsp) || (NULL == pReq))
1206 {
1207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1208 "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq);
1209 isLastAp = TRUE;
1210 goto done;
1211 }
1212
1213 pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists;
1214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1215 "Batch scan rsp: numberScalList %d", numberScanList);
1216
1217 if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch))
1218 {
1219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1220 "%s: numberScanList %d", __func__, numberScanList);
1221 isLastAp = TRUE;
1222 goto done;
1223 }
1224
1225 while (numberScanList)
1226 {
Rajeev Kumarce651e42013-10-21 18:57:15 -07001227 pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults +
Rajeev79dbe4c2013-10-05 11:03:42 +05301228 nextScanListOffset);
1229 if (NULL == pScanList)
1230 {
1231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1232 "%s: pScanList is %p", __func__, pScanList);
1233 isLastAp = TRUE;
1234 goto done;
1235 }
Rajeev Kumarce651e42013-10-21 18:57:15 -07001236 numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList;
Rajeev79dbe4c2013-10-05 11:03:42 +05301237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumarce651e42013-10-21 18:57:15 -07001238 "Batch scan rsp: numApMetaInfo %d scanId %d",
1239 numApMetaInfo, pScanList->scanId);
Rajeev79dbe4c2013-10-05 11:03:42 +05301240
1241 if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork))
1242 {
1243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1244 "%s: numApMetaInfo %d", __func__, numApMetaInfo);
1245 isLastAp = TRUE;
1246 goto done;
1247 }
1248
Rajeev Kumarce651e42013-10-21 18:57:15 -07001249 /*Initialize next AP meta info offset for next scan list*/
1250 nextApMetaInfoOffset = 0;
1251
Rajeev79dbe4c2013-10-05 11:03:42 +05301252 while (numApMetaInfo)
1253 {
1254 pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList +
1255 nextApMetaInfoOffset);
1256 if (NULL == pApMetaInfo)
1257 {
1258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1259 "%s: pApMetaInfo is %p", __func__, pApMetaInfo);
1260 isLastAp = TRUE;
1261 goto done;
1262 }
1263 /*calculate AP age*/
1264 pApMetaInfo->timestamp =
1265 pBatchScanRsp->timestamp - pApMetaInfo->timestamp;
1266
1267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussaina7c8e412013-11-20 11:06:42 -08001268 "%s: bssId "MAC_ADDRESS_STR
1269 " ch %d rssi %d timestamp %d", __func__,
1270 MAC_ADDR_ARRAY(pApMetaInfo->bssid),
1271 pApMetaInfo->ch, pApMetaInfo->rssi,
1272 pApMetaInfo->timestamp);
Rajeev79dbe4c2013-10-05 11:03:42 +05301273
1274 /*mark last AP in batch scan response*/
1275 if ((TRUE == pBatchScanRsp->isLastResult) &&
1276 (1 == numberScanList) && (1 == numApMetaInfo))
1277 {
1278 isLastAp = TRUE;
1279 }
1280
1281 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1282 /*store batch scan repsonse in hdd queue*/
1283 hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo,
1284 pScanList->scanId, isLastAp);
1285 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1286
1287 nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo);
1288 numApMetaInfo--;
1289 }
1290
Rajeev Kumarce651e42013-10-21 18:57:15 -07001291 nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8))
1292 + (sizeof(tSirBatchScanNetworkInfo)
1293 * numNetworkInScanList));
Rajeev79dbe4c2013-10-05 11:03:42 +05301294 numberScanList--;
1295 }
1296
1297done:
1298
1299 /*notify hdd_ioctl only if complete batch scan rsp is received and it was
1300 requested from hdd_ioctl*/
1301 if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) &&
1302 (TRUE == isLastAp))
1303 {
1304 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1305 complete(&pAdapter->hdd_get_batch_scan_req_var);
1306 }
1307
1308 return;
1309}/*End of hdd_batch_scan_result_ind_callback*/
1310
1311/**---------------------------------------------------------------------------
1312
1313 \brief hdd_format_batch_scan_rsp () - This function formats batch scan
1314 response as per batch scan FR request format by putting proper markers
1315
1316 \param - pDest pointer to destination buffer
1317 \param - cur_len current length
1318 \param - tot_len total remaining size which can be written to user space
1319 \param - pApMetaInfo Pointer to get batch scan response AP meta info
1320 \param - pAdapter Pointer to HDD adapter
1321
1322 \return - ret no of characters written
1323
1324 --------------------------------------------------------------------------*/
1325static tANI_U32
1326hdd_format_batch_scan_rsp
1327(
1328 tANI_U8 *pDest,
1329 tANI_U32 cur_len,
1330 tANI_U32 tot_len,
1331 tHddBatchScanRsp *pApMetaInfo,
1332 hdd_adapter_t* pAdapter
1333)
1334{
1335 tANI_U32 ret = 0;
1336 tANI_U32 rem_len = 0;
1337 tANI_U8 temp_len = 0;
1338 tANI_U8 temp_total_len = 0;
1339 tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE];
1340 tANI_U8 *pTemp = temp;
1341
1342 /*Batch scan reponse needs to be returned to user space in
1343 following format:
1344 "scancount=X\n" where X is the number of scans in current batch
1345 batch
1346 "trunc\n" optional present if current scan truncated
1347 "bssid=XX:XX:XX:XX:XX:XX\n"
1348 "ssid=XXXX\n"
1349 "freq=X\n" frequency in Mhz
1350 "level=XX\n"
1351 "age=X\n" ms
1352 "dist=X\n" cm (-1 if not available)
1353 "errror=X\n" (-1if not available)
1354 "====\n" (end of ap marker)
1355 "####\n" (end of scan marker)
1356 "----\n" (end of results)*/
1357 /*send scan result in above format to user space based on
1358 available length*/
1359 /*The GET response may have more data than the driver can return in its
1360 buffer. In that case the buffer should be filled to the nearest complete
1361 scan, ending with "%%%%".Subsequent callsshould return the remaining data
1362 starting with the next scan (optional .trunc\n., .apcount=X\n., etc).
1363 The final buffer should end with "----\n"*/
1364
1365 /*sanity*/
1366 if (cur_len > tot_len)
1367 {
1368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1369 "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len);
1370 return 0;
1371 }
1372 else
1373 {
1374 rem_len = (tot_len - cur_len);
1375 }
1376
1377 /*end scan marker*/
1378 if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id)
1379 {
1380 temp_len = snprintf(pTemp, sizeof(temp), "####\n");
1381 pTemp += temp_len;
1382 temp_total_len += temp_len;
1383 }
1384
1385 /*bssid*/
1386 temp_len = snprintf(pTemp, sizeof(temp),
1387 "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n",
1388 pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1],
1389 pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3],
1390 pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]);
1391 pTemp += temp_len;
1392 temp_total_len += temp_len;
1393
1394 /*ssid*/
1395 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n",
1396 pApMetaInfo->ApInfo.ssid);
1397 pTemp += temp_len;
1398 temp_total_len += temp_len;
1399
1400 /*freq*/
1401 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n",
Rajeev Kumarc40f7512013-11-04 14:13:23 -08001402 sme_ChnToFreq(pApMetaInfo->ApInfo.ch));
Rajeev79dbe4c2013-10-05 11:03:42 +05301403 pTemp += temp_len;
1404 temp_total_len += temp_len;
1405
1406 /*level*/
1407 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n",
1408 pApMetaInfo->ApInfo.rssi);
1409 pTemp += temp_len;
1410 temp_total_len += temp_len;
1411
1412 /*age*/
Jeff Johnson02797792013-10-26 19:17:13 -07001413 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n",
Rajeev79dbe4c2013-10-05 11:03:42 +05301414 pApMetaInfo->ApInfo.age);
1415 pTemp += temp_len;
1416 temp_total_len += temp_len;
1417
1418 /*dist*/
1419 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n");
1420 pTemp += temp_len;
1421 temp_total_len += temp_len;
1422
1423 /*error*/
1424 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n");
1425 pTemp += temp_len;
1426 temp_total_len += temp_len;
1427
1428 /*end AP marker*/
1429 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n");
1430 pTemp += temp_len;
1431 temp_total_len += temp_len;
1432
1433 /*last AP in batch scan response*/
1434 if(TRUE == pApMetaInfo->ApInfo.isLastAp)
1435 {
1436 /*end scan marker*/
1437 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n");
1438 pTemp += temp_len;
1439 temp_total_len += temp_len;
1440
1441 /*end batch scan result marker*/
1442 temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n");
1443 pTemp += temp_len;
1444 temp_total_len += temp_len;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001445
Rajeev79dbe4c2013-10-05 11:03:42 +05301446 }
1447
1448 if (temp_total_len < rem_len)
1449 {
1450 ret = temp_total_len + 1;
1451 strlcpy(pDest, temp, ret);
1452 pAdapter->isTruncated = FALSE;
1453 }
1454 else
1455 {
1456 pAdapter->isTruncated = TRUE;
1457 if (rem_len >= strlen("%%%%"))
1458 {
Rajeev Kumarc933d982013-11-18 20:04:20 -08001459 ret = snprintf(pDest, sizeof(temp), "%%%%");
Rajeev79dbe4c2013-10-05 11:03:42 +05301460 }
Rajeev Kumarc933d982013-11-18 20:04:20 -08001461 else
Rajeev79dbe4c2013-10-05 11:03:42 +05301462 {
1463 ret = 0;
1464 }
1465 }
1466
1467 return ret;
1468
1469}/*End of hdd_format_batch_scan_rsp*/
1470
1471/**---------------------------------------------------------------------------
1472
1473 \brief hdd_populate_user_batch_scan_rsp() - This function populates user data
1474 buffer starting with head of hdd batch scan response queue
1475
1476 \param - pAdapter Pointer to HDD adapter
1477 \param - pDest Pointer to user data buffer
1478 \param - cur_len current offset in user buffer
1479 \param - rem_len remaining no of bytes in user buffer
1480
1481 \return - number of bytes written in user buffer
1482
1483 --------------------------------------------------------------------------*/
1484
1485tANI_U32 hdd_populate_user_batch_scan_rsp
1486(
1487 hdd_adapter_t* pAdapter,
1488 tANI_U8 *pDest,
1489 tANI_U32 cur_len,
1490 tANI_U32 rem_len
1491)
1492{
1493 tHddBatchScanRsp *pHead;
1494 tHddBatchScanRsp *pPrev;
1495 tANI_U32 len;
1496
Rajeev79dbe4c2013-10-05 11:03:42 +05301497 pAdapter->isTruncated = FALSE;
1498
1499 /*head of hdd batch scan response queue*/
1500 pHead = pAdapter->pBatchScanRsp;
1501 while (pHead)
1502 {
1503 len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead,
1504 pAdapter);
1505 pDest += len;
Rajeev Kumar292d2bb2013-10-23 15:01:44 -07001506 pDest--;
Rajeev79dbe4c2013-10-05 11:03:42 +05301507 cur_len += len;
1508 if(TRUE == pAdapter->isTruncated)
1509 {
1510 /*result is truncated return rest of scan rsp in next req*/
1511 cur_len = rem_len;
1512 break;
1513 }
1514 pPrev = pHead;
1515 pHead = pHead->pNext;
1516 pAdapter->pBatchScanRsp = pHead;
Rajeev Kumarbe17d8b2014-01-10 15:39:45 -08001517 if (TRUE == pPrev->ApInfo.isLastAp)
1518 {
1519 pAdapter->prev_batch_id = 0;
1520 }
1521 else
1522 {
1523 pAdapter->prev_batch_id = pPrev->ApInfo.batchId;
1524 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301525 vos_mem_free(pPrev);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08001526 pPrev = NULL;
Rajeev79dbe4c2013-10-05 11:03:42 +05301527 }
1528
1529 return cur_len;
1530}/*End of hdd_populate_user_batch_scan_rsp*/
1531
1532/**---------------------------------------------------------------------------
1533
1534 \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch
1535 scan response data from HDD queue to user space
1536 It does following in detail:
1537 a) if HDD has enough data in its queue then it 1st copies data to user
1538 space and then send get batch scan indication message to FW. In this
1539 case it does not wait on any event and batch scan response data will
1540 be populated in HDD response queue in MC thread context after receiving
1541 indication from FW
1542 b) else send get batch scan indication message to FW and wait on an event
1543 which will be set once HDD receives complete batch scan response from
1544 FW and then this function returns batch scan response to user space
1545
1546 \param - pAdapter Pointer to HDD adapter
1547 \param - pPrivData Pointer to priv_data
1548
1549 \return - 0 for success -EFAULT for failure
1550
1551 --------------------------------------------------------------------------*/
1552
1553int hdd_return_batch_scan_rsp_to_user
1554(
1555 hdd_adapter_t* pAdapter,
1556 hdd_priv_data_t *pPrivData,
1557 tANI_U8 *command
1558)
1559{
1560 tANI_U8 *pDest;
1561 tANI_U32 count = 0;
1562 tANI_U32 len = 0;
1563 tANI_U32 cur_len = 0;
1564 tANI_U32 rem_len = 0;
1565 eHalStatus halStatus;
1566 unsigned long rc;
1567 tSirTriggerBatchScanResultInd *pReq;
1568
1569 pReq = &pAdapter->hddTriggerBatchScanResultInd;
1570 pReq->param = 0;/*batch scan client*/
1571 pDest = (tANI_U8 *)(command + pPrivData->used_len);
1572 pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE;
1573
1574 cur_len = pPrivData->used_len;
1575 if (pPrivData->total_len > pPrivData->used_len)
1576 {
1577 rem_len = pPrivData->total_len - pPrivData->used_len;
1578 }
1579 else
1580 {
1581 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1582 "%s: Invalid user data buffer total_len %d used_len %d",
1583 __func__, pPrivData->total_len, pPrivData->used_len);
1584 return -EFAULT;
1585 }
1586
1587 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1588 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1589 cur_len, rem_len);
1590 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1591
1592 /*enough scan result available in cache to return to user space or
1593 scan result needs to be fetched 1st from fw and then return*/
Rajeev Kumar99db6262013-11-11 15:23:36 -08001594 if (len == cur_len)
Rajeev79dbe4c2013-10-05 11:03:42 +05301595 {
1596 pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE;
1597 halStatus = sme_TriggerBatchScanResultInd(
1598 WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1599 pAdapter->sessionId, hdd_batch_scan_result_ind_callback,
1600 pAdapter);
1601 if ( eHAL_STATUS_SUCCESS == halStatus )
1602 {
1603 if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp)
1604 {
1605 INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var);
1606 rc = wait_for_completion_timeout(
1607 &pAdapter->hdd_get_batch_scan_req_var,
1608 msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT));
1609 if (0 == rc)
1610 {
1611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1612 "%s: Timeout waiting to fetch batch scan rsp from fw",
1613 __func__);
1614 return -EFAULT;
1615 }
1616 }
1617
1618 len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE,
Jeff Johnson02797792013-10-26 19:17:13 -07001619 "scancount=%u\n", pAdapter->numScanList);
Rajeev79dbe4c2013-10-05 11:03:42 +05301620 pDest += len;
1621 cur_len += len;
1622
1623 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1624 len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest,
1625 cur_len, rem_len);
1626 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1627
1628 count = 0;
1629 len = (len - pPrivData->used_len);
1630 pDest = (command + pPrivData->used_len);
1631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001632 "NEW BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301633 while(count < len)
1634 {
1635 printk("%c", *(pDest + count));
1636 count++;
1637 }
1638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1639 "%s: copy %d data to user buffer", __func__, len);
1640 if (copy_to_user(pPrivData->buf, pDest, len))
1641 {
1642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1643 "%s: failed to copy data to user buffer", __func__);
1644 return -EFAULT;
1645 }
1646 }
1647 else
1648 {
1649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1650 "sme_GetBatchScanScan returned failure halStatus %d",
1651 halStatus);
1652 return -EINVAL;
1653 }
1654 }
1655 else
1656 {
Rajeev79dbe4c2013-10-05 11:03:42 +05301657 count = 0;
1658 len = (len - pPrivData->used_len);
1659 pDest = (command + pPrivData->used_len);
1660 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Rajeev Kumar99db6262013-11-11 15:23:36 -08001661 "REMAINING TRUNCATED BATCH SCAN RESULT:");
Rajeev79dbe4c2013-10-05 11:03:42 +05301662 while(count < len)
1663 {
1664 printk("%c", *(pDest + count));
1665 count++;
1666 }
Rajeev Kumar99db6262013-11-11 15:23:36 -08001667 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1668 "%s: copy %d data to user buffer", __func__, len);
Rajeev79dbe4c2013-10-05 11:03:42 +05301669 if (copy_to_user(pPrivData->buf, pDest, len))
1670 {
1671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1672 "%s: failed to copy data to user buffer", __func__);
1673 return -EFAULT;
1674 }
Rajeev79dbe4c2013-10-05 11:03:42 +05301675 }
1676
1677 return 0;
1678} /*End of hdd_return_batch_scan_rsp_to_user*/
1679
Rajeev Kumar8b373292014-01-08 20:36:55 -08001680
1681/**---------------------------------------------------------------------------
1682
1683 \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING
1684 IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled:
1685 WLS_BATCHING VERSION
1686 WLS_BATCHING SET
1687 WLS_BATCHING GET
1688 WLS_BATCHING STOP
1689
1690 \param - pAdapter Pointer to HDD adapter
1691 \param - pPrivdata Pointer to priv_data
1692 \param - command Pointer to command
1693
1694 \return - 0 for success -EFAULT for failure
1695
1696 --------------------------------------------------------------------------*/
1697
1698int hdd_handle_batch_scan_ioctl
1699(
1700 hdd_adapter_t *pAdapter,
1701 hdd_priv_data_t *pPrivdata,
1702 tANI_U8 *command
1703)
1704{
1705 int ret = 0;
Yue Mae36e3552014-03-05 17:06:20 -08001706 hdd_context_t *pHddCtx;
1707
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301708 ENTER();
1709
Yue Mae36e3552014-03-05 17:06:20 -08001710 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1711 ret = wlan_hdd_validate_context(pHddCtx);
1712 if (ret)
1713 {
Yue Mae36e3552014-03-05 17:06:20 -08001714 goto exit;
1715 }
Rajeev Kumar8b373292014-01-08 20:36:55 -08001716
1717 if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0)
1718 {
1719 char extra[32];
1720 tANI_U8 len = 0;
1721 tANI_U8 version = HDD_BATCH_SCAN_VERSION;
1722
1723 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1724 {
1725 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1726 "%s: Batch scan feature is not supported by FW", __func__);
1727 ret = -EINVAL;
1728 goto exit;
1729 }
1730
1731 len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d",
1732 version);
1733 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1734 {
1735 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1736 "%s: failed to copy data to user buffer", __func__);
1737 ret = -EFAULT;
1738 goto exit;
1739 }
1740 ret = HDD_BATCH_SCAN_VERSION;
1741 }
1742 else if (strncmp(command, "WLS_BATCHING SET", 16) == 0)
1743 {
1744 int status;
1745 tANI_U8 *value = (command + 16);
1746 eHalStatus halStatus;
1747 unsigned long rc;
1748 tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq;
1749 tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp;
1750
1751 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1752 {
1753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1754 "%s: Batch scan feature is not supported by FW", __func__);
1755 ret = -EINVAL;
1756 goto exit;
1757 }
1758
1759 if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) &&
1760 (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) &&
1761 (WLAN_HDD_P2P_GO != pAdapter->device_mode) &&
1762 (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode))
1763 {
1764 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301765 "Received WLS_BATCHING SET command in invalid mode %s (%d) "
Rajeev Kumar8b373292014-01-08 20:36:55 -08001766 "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode",
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05301767 hdd_device_modetoString(pAdapter->device_mode),
1768 pAdapter->device_mode);
Rajeev Kumar8b373292014-01-08 20:36:55 -08001769 ret = -EINVAL;
1770 goto exit;
1771 }
1772
1773 status = hdd_parse_set_batchscan_command(value, pReq);
1774 if (status)
1775 {
1776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1777 "Invalid WLS_BATCHING SET command");
1778 ret = -EINVAL;
1779 goto exit;
1780 }
1781
1782
1783 pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE;
1784 halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq,
1785 pAdapter->sessionId, hdd_set_batch_scan_req_callback,
1786 pAdapter);
1787
1788 if ( eHAL_STATUS_SUCCESS == halStatus )
1789 {
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301790 char extra[32];
1791 tANI_U8 len = 0;
1792 tANI_U8 mScan = 0;
1793
Rajeev Kumar8b373292014-01-08 20:36:55 -08001794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1795 "sme_SetBatchScanReq returned success halStatus %d",
1796 halStatus);
1797 if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp)
1798 {
1799 INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var);
1800 rc = wait_for_completion_timeout(
1801 &pAdapter->hdd_set_batch_scan_req_var,
1802 msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT));
1803 if (0 == rc)
1804 {
1805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1806 "%s: Timeout waiting for set batch scan to complete",
1807 __func__);
1808 ret = -EINVAL;
1809 goto exit;
1810 }
1811 }
1812 if ( !pRsp->nScansToBatch )
1813 {
1814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1815 "%s: Received set batch scan failure response from FW",
1816 __func__);
1817 ret = -EINVAL;
1818 goto exit;
1819 }
1820 /*As per the Batch Scan Framework API we should return the MIN of
1821 either MSCAN or the max # of scans firmware can cache*/
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301822 mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch);
Rajeev Kumar8b373292014-01-08 20:36:55 -08001823
1824 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED;
1825
1826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1827 "%s: request MSCAN %d response MSCAN %d ret %d",
Mahesh A Saptasagar5f568172014-05-14 17:02:33 +05301828 __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan);
1829 len = scnprintf(extra, sizeof(extra), "%d", mScan);
1830 if (copy_to_user(pPrivdata->buf, &extra, len + 1))
1831 {
1832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1833 "%s: failed to copy MSCAN value to user buffer", __func__);
1834 ret = -EFAULT;
1835 goto exit;
1836 }
Rajeev Kumar8b373292014-01-08 20:36:55 -08001837 }
1838 else
1839 {
1840 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1841 "sme_SetBatchScanReq returned failure halStatus %d",
1842 halStatus);
1843 ret = -EINVAL;
1844 goto exit;
1845 }
1846 }
1847 else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0)
1848 {
1849 eHalStatus halStatus;
1850 tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd;
1851 pInd->param = 0;
1852
1853 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1854 {
1855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1856 "%s: Batch scan feature is not supported by FW", __func__);
1857 ret = -EINVAL;
1858 goto exit;
1859 }
1860
1861 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1862 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05301863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Rajeev Kumar8b373292014-01-08 20:36:55 -08001864 "Batch scan is not yet enabled batch scan state %d",
1865 pAdapter->batchScanState);
1866 ret = -EINVAL;
1867 goto exit;
1868 }
1869
Kiet Lamaa8e15a2014-02-11 23:30:06 -08001870 mutex_lock(&pAdapter->hdd_batch_scan_lock);
1871 hdd_deinit_batch_scan(pAdapter);
1872 mutex_unlock(&pAdapter->hdd_batch_scan_lock);
1873
Rajeev Kumar8b373292014-01-08 20:36:55 -08001874 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
1875
1876 halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd,
1877 pAdapter->sessionId);
1878 if ( eHAL_STATUS_SUCCESS == halStatus )
1879 {
1880 ret = 0;
1881 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1882 "sme_StopBatchScanInd returned success halStatus %d",
1883 halStatus);
1884 }
1885 else
1886 {
1887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1888 "sme_StopBatchScanInd returned failure halStatus %d",
1889 halStatus);
1890 ret = -EINVAL;
1891 goto exit;
1892 }
1893 }
1894 else if (strncmp(command, "WLS_BATCHING GET", 16) == 0)
1895 {
1896 tANI_U32 remain_len;
1897
1898 if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN))
1899 {
1900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1901 "%s: Batch scan feature is not supported by FW", __func__);
1902 ret = -EINVAL;
1903 goto exit;
1904 }
1905
1906 if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState)
1907 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05301908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Rajeev Kumar8b373292014-01-08 20:36:55 -08001909 "Batch scan is not yet enabled could not return results"
1910 "Batch Scan state %d",
1911 pAdapter->batchScanState);
1912 ret = -EINVAL;
1913 goto exit;
1914 }
1915
1916 pPrivdata->used_len = 16;
1917 remain_len = pPrivdata->total_len - pPrivdata->used_len;
1918 if (remain_len < pPrivdata->total_len)
1919 {
1920 /*Clear previous batch scan response data if any*/
1921 vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len);
1922 }
1923 else
1924 {
1925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1926 "Invalid total length from user space can't fetch batch"
1927 " scan response total_len %d used_len %d remain len %d",
1928 pPrivdata->total_len, pPrivdata->used_len, remain_len);
1929 ret = -EINVAL;
1930 goto exit;
1931 }
1932 ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command);
1933 }
1934
1935exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301936 EXIT();
Rajeev Kumar8b373292014-01-08 20:36:55 -08001937 return ret;
1938}
1939
1940
Rajeev79dbe4c2013-10-05 11:03:42 +05301941#endif/*End of FEATURE_WLAN_BATCH_SCAN*/
1942
c_hpothu92367912014-05-01 15:18:17 +05301943static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data)
1944{
c_hpothu39eb1e32014-06-26 16:31:50 +05301945 bcnMissRateContext_t *pCBCtx;
1946
1947 if (NULL == data)
1948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL"));
1950 return;
1951 }
c_hpothu92367912014-05-01 15:18:17 +05301952
1953 /* there is a race condition that exists between this callback
1954 function and the caller since the caller could time out either
1955 before or while this code is executing. we use a spinlock to
1956 serialize these actions */
1957 spin_lock(&hdd_context_lock);
1958
c_hpothu39eb1e32014-06-26 16:31:50 +05301959 pCBCtx = (bcnMissRateContext_t *)data;
c_hpothu92367912014-05-01 15:18:17 +05301960 gbcnMissRate = -1;
1961
c_hpothu39eb1e32014-06-26 16:31:50 +05301962 if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC)
c_hpothu92367912014-05-01 15:18:17 +05301963 {
1964 hddLog(VOS_TRACE_LEVEL_ERROR,
c_hpothu39eb1e32014-06-26 16:31:50 +05301965 FL("invalid context magic: %08x"), pCBCtx->magic);
c_hpothu92367912014-05-01 15:18:17 +05301966 spin_unlock(&hdd_context_lock);
1967 return ;
1968 }
1969
1970 if (VOS_STATUS_SUCCESS == status)
1971 {
c_hpothu39eb1e32014-06-26 16:31:50 +05301972 gbcnMissRate = bcnMissRate;
c_hpothu92367912014-05-01 15:18:17 +05301973 }
c_hpothu39eb1e32014-06-26 16:31:50 +05301974 else
1975 {
1976 hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate"));
1977 }
1978
c_hpothu92367912014-05-01 15:18:17 +05301979 complete(&(pCBCtx->completion));
1980 spin_unlock(&hdd_context_lock);
1981
1982 return;
1983}
1984
Abhishek Singh08aa7762014-12-16 13:59:03 +05301985void hdd_FWStatisCB( VOS_STATUS status,
1986 tSirFwStatsResult *fwStatsResult, void *pContext )
Satyanarayana Dash72806012014-12-02 14:30:08 +05301987{
1988 fwStatsContext_t *fwStatsCtx;
Satyanarayana Dash72806012014-12-02 14:30:08 +05301989 hdd_adapter_t *pAdapter;
1990
1991 hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status);
1992
Abhishek Singh08aa7762014-12-16 13:59:03 +05301993 if (NULL == pContext)
Satyanarayana Dash72806012014-12-02 14:30:08 +05301994 {
1995 hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL"));
1996 return;
1997 }
1998 /* there is a race condition that exists between this callback
1999 function and the caller since the caller could time out either
2000 before or while this code is executing. we use a spinlock to
2001 serialize these actions */
2002 spin_lock(&hdd_context_lock);
Abhishek Singh08aa7762014-12-16 13:59:03 +05302003 fwStatsCtx = (fwStatsContext_t *) pContext;
Satyanarayana Dash72806012014-12-02 14:30:08 +05302004 if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC)
2005 {
2006 hddLog(VOS_TRACE_LEVEL_ERROR,
2007 FL("invalid context magic: %08x"), fwStatsCtx->magic);
2008 spin_unlock(&hdd_context_lock);
2009 return;
2010 }
2011 pAdapter = fwStatsCtx->pAdapter;
2012 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2013 {
2014 hddLog(VOS_TRACE_LEVEL_ERROR,
2015 FL("pAdapter returned is NULL or invalid"));
2016 spin_unlock(&hdd_context_lock);
2017 return;
2018 }
2019 pAdapter->fwStatsRsp.type = 0;
Abhishek Singh08aa7762014-12-16 13:59:03 +05302020 if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStatsResult))
Satyanarayana Dash72806012014-12-02 14:30:08 +05302021 {
Satyanarayana Dash72806012014-12-02 14:30:08 +05302022 switch( fwStatsResult->type )
2023 {
2024 case FW_UBSP_STATS:
2025 {
Abhishek Singh08aa7762014-12-16 13:59:03 +05302026 memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(tSirFwStatsResult));
Satyanarayana Dash72806012014-12-02 14:30:08 +05302027 hddLog(VOS_TRACE_LEVEL_INFO,
2028 FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"),
Abhishek Singh08aa7762014-12-16 13:59:03 +05302029 pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_enter_cnt,
2030 pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_jump_ddr_cnt);
Satyanarayana Dash72806012014-12-02 14:30:08 +05302031 }
2032 break;
2033 default:
2034 {
2035 hddLog(VOS_TRACE_LEVEL_ERROR,
2036 FL(" No handling for stats type %d"),fwStatsResult->type);
2037 }
2038 }
2039 }
2040 complete(&(fwStatsCtx->completion));
2041 spin_unlock(&hdd_context_lock);
2042 return;
2043}
2044
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302045static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len)
2046{
2047 int ret = 0;
2048
2049 if (!pCfg || !command || !extra || !len)
2050 {
2051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2052 "%s: argument passsed for GETDWELLTIME is incorrect", __func__);
2053 ret = -EINVAL;
2054 return ret;
2055 }
2056
2057 if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0)
2058 {
2059 *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n",
2060 (int)pCfg->nActiveMaxChnTime);
2061 return ret;
2062 }
2063 else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0)
2064 {
2065 *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n",
2066 (int)pCfg->nActiveMinChnTime);
2067 return ret;
2068 }
2069 else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0)
2070 {
2071 *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n",
2072 (int)pCfg->nPassiveMaxChnTime);
2073 return ret;
2074 }
2075 else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0)
2076 {
2077 *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n",
2078 (int)pCfg->nPassiveMinChnTime);
2079 return ret;
2080 }
Rajesh Babu Prathipati0fd227e2014-07-05 12:50:00 +05302081 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
2082 {
2083 *len = scnprintf(extra, n, "GETDWELLTIME %u \n",
2084 (int)pCfg->nActiveMaxChnTime);
2085 return ret;
2086 }
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302087 else
2088 {
2089 ret = -EINVAL;
2090 }
2091
2092 return ret;
2093}
2094
2095static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command)
2096{
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302097 tHalHandle hHal;
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302098 hdd_config_t *pCfg;
2099 tANI_U8 *value = command;
2100 int val = 0, ret = 0, temp = 0;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302101 tSmeConfigParams smeConfig;
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302102
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302103 if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini)
2104 || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter))))
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302105 {
2106 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2107 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
2108 ret = -EINVAL;
2109 return ret;
2110 }
2111
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302112 vos_mem_zero(&smeConfig, sizeof(smeConfig));
2113 sme_GetConfigParam(hHal, &smeConfig);
2114
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302115 if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 )
2116 {
2117 value = value + 24;
2118 temp = kstrtou32(value, 10, &val);
2119 if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
2120 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
2121 {
2122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2123 "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__);
2124 ret = -EFAULT;
2125 return ret;
2126 }
2127 pCfg->nActiveMaxChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302128 smeConfig.csrConfig.nActiveMaxChnTime = val;
2129 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302130 }
2131 else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0)
2132 {
2133 value = value + 24;
2134 temp = kstrtou32(value, 10, &val);
2135 if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN ||
2136 val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX )
2137 {
2138 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2139 "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__);
2140 ret = -EFAULT;
2141 return ret;
2142 }
2143 pCfg->nActiveMinChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302144 smeConfig.csrConfig.nActiveMinChnTime = val;
2145 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302146 }
2147 else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0)
2148 {
2149 value = value + 25;
2150 temp = kstrtou32(value, 10, &val);
2151 if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN ||
2152 val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX )
2153 {
2154 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2155 "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__);
2156 ret = -EFAULT;
2157 return ret;
2158 }
2159 pCfg->nPassiveMaxChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302160 smeConfig.csrConfig.nPassiveMaxChnTime = val;
2161 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302162 }
2163 else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0)
2164 {
2165 value = value + 25;
2166 temp = kstrtou32(value, 10, &val);
2167 if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN ||
2168 val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX )
2169 {
2170 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2171 "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__);
2172 ret = -EFAULT;
2173 return ret;
2174 }
2175 pCfg->nPassiveMinChnTime = val;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05302176 smeConfig.csrConfig.nPassiveMinChnTime = val;
2177 sme_UpdateConfig(hHal, &smeConfig);
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302178 }
Rajesh Babu Prathipati0fd227e2014-07-05 12:50:00 +05302179 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
2180 {
2181 value = value + 13;
2182 temp = kstrtou32(value, 10, &val);
2183 if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN ||
2184 val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX )
2185 {
2186 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2187 "%s: argument passed for SETDWELLTIME is incorrect", __func__);
2188 ret = -EFAULT;
2189 return ret;
2190 }
2191 pCfg->nActiveMaxChnTime = val;
2192 smeConfig.csrConfig.nActiveMaxChnTime = val;
2193 sme_UpdateConfig(hHal, &smeConfig);
2194 }
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302195 else
2196 {
2197 ret = -EINVAL;
2198 }
2199
2200 return ret;
2201}
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +05302202static int hdd_cmd_setFccChannel(hdd_context_t *pHddCtx, tANI_U8 *cmd,
2203 tANI_U8 cmd_len)
2204{
2205 tANI_U8 *value;
2206 tANI_U8 fcc_constraint;
2207
2208 eHalStatus status;
2209 int ret = 0;
2210 value = cmd + cmd_len + 1;
2211
2212 ret = kstrtou8(value, 10, &fcc_constraint);
2213 if ((ret < 0) || (fcc_constraint > 1)) {
2214 /*
2215 * If the input value is greater than max value of datatype,
2216 * then also it is a failure
2217 */
2218 hddLog(VOS_TRACE_LEVEL_ERROR,
2219 "%s: value out of range", __func__);
2220 return -EINVAL;
2221 }
2222
2223 status = sme_handleSetFccChannel(pHddCtx->hHal, fcc_constraint);
2224 if (status != eHAL_STATUS_SUCCESS)
2225 ret = -EPERM;
2226
2227 return ret;
2228}
2229
2230
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05302231
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002232static int hdd_driver_command(hdd_adapter_t *pAdapter,
2233 hdd_priv_data_t *ppriv_data)
Jeff Johnson295189b2012-06-20 16:38:30 -07002234{
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 hdd_priv_data_t priv_data;
2236 tANI_U8 *command = NULL;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302237 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2238 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002239 int ret = 0;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302240 int status;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05302241#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
2242 struct cfg80211_mgmt_tx_params params;
2243#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302244
2245 ENTER();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002246 /*
2247 * Note that valid pointers are provided by caller
2248 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002249
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002250 /* copy to local struct to avoid numerous changes to legacy code */
2251 priv_data = *ppriv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07002252
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002253 if (priv_data.total_len <= 0 ||
2254 priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN)
Sameer Thalappil8ef3a0e2013-04-05 14:36:04 -07002255 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002256 hddLog(VOS_TRACE_LEVEL_WARN,
2257 "%s:invalid priv_data.total_len(%d)!!!", __func__,
2258 priv_data.total_len);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002259 ret = -EINVAL;
2260 goto exit;
2261 }
Kaushik, Sushant96122442014-10-21 16:40:18 +05302262 status = wlan_hdd_validate_context(pHddCtx);
2263 if (0 != status)
2264 {
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302265 ret = -EINVAL;
2266 goto exit;
Kaushik, Sushant96122442014-10-21 16:40:18 +05302267 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002268 /* Allocate +1 for '\0' */
2269 command = kmalloc(priv_data.total_len + 1, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 if (!command)
2271 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002272 hddLog(VOS_TRACE_LEVEL_ERROR,
2273 "%s: failed to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 ret = -ENOMEM;
2275 goto exit;
2276 }
2277
2278 if (copy_from_user(command, priv_data.buf, priv_data.total_len))
2279 {
2280 ret = -EFAULT;
2281 goto exit;
2282 }
2283
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002284 /* Make sure the command is NUL-terminated */
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07002285 command[priv_data.total_len] = '\0';
2286
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002287 /* at one time the following block of code was conditional. braces
2288 * have been retained to avoid re-indenting the legacy code
2289 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 {
2291 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2292
2293 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07002294 "%s: Received %s cmd from Wi-Fi GUI***", __func__, command);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295
2296 if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 )
2297 {
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302298 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2299 TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL,
2300 pAdapter->sessionId, (unsigned)
2301 (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 |
2302 *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 |
2303 *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 |
2304 *(pHddCtx->p2pDeviceAddress.bytes+5))));
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes,
2306 sizeof(tSirMacAddr)))
2307 {
2308 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002309 "%s: failed to copy data to user buffer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 ret = -EFAULT;
2311 }
2312 }
Amar Singhal0974e402013-02-12 14:27:46 -08002313 else if(strncmp(command, "SETBAND", 7) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 {
Amar Singhal0974e402013-02-12 14:27:46 -08002315 tANI_U8 *ptr = command ;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 /* Change band request received */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002318
2319 /* First 8 bytes will have "SETBAND " and
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 * 9 byte will have band setting value */
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Amar Singhal0974e402013-02-12 14:27:46 -08002322 "%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 +05302323 if(VOS_FTM_MODE != hdd_get_conparam())
2324 {
2325 /* Change band request received */
2326 ret = hdd_setBand_helper(pAdapter->dev, ptr);
2327 if(ret < 0)
2328 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
2329 "%s: failed to set band ret=%d", __func__, ret);
2330 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002331 }
Kiet Lamf040f472013-11-20 21:15:23 +05302332 else if(strncmp(command, "SETWMMPS", 8) == 0)
2333 {
2334 tANI_U8 *ptr = command;
2335 ret = hdd_wmmps_helper(pAdapter, ptr);
2336 }
Agarwal Ashishef54a182014-12-16 15:07:31 +05302337
2338 else if(strncmp(command, "TDLSSCAN", 8) == 0)
2339 {
2340 tANI_U8 *ptr = command;
2341 ret = hdd_set_tdls_scan_type(pAdapter, ptr);
2342 }
2343
Jeff Johnson32d95a32012-09-10 13:15:23 -07002344 else if ( strncasecmp(command, "COUNTRY", 7) == 0 )
2345 {
2346 char *country_code;
2347
2348 country_code = command + 8;
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07002349
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002350 INIT_COMPLETION(pAdapter->change_country_code);
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07002351 hdd_checkandupdate_dfssetting(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002352#ifndef CONFIG_ENABLE_LINUX_REG
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302353 hdd_checkandupdate_phymode(pAdapter, country_code);
Tushnim Bhattacharyya71ccecc2013-10-14 16:22:56 -07002354#endif
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002355 ret = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2356 (void *)(tSmeChangeCountryCallback)
2357 wlan_hdd_change_country_code_callback,
Abhishek Singha306a442013-11-07 18:39:01 +05302358 country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002359 if (eHAL_STATUS_SUCCESS == ret)
2360 {
2361 ret = wait_for_completion_interruptible_timeout(
2362 &pAdapter->change_country_code,
2363 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2364 if (0 >= ret)
2365 {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002366 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out %d",
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302367 __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002368 }
2369 }
2370 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07002371 {
2372 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07002373 "%s: SME Change Country code fail ret=%d", __func__, ret);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002374 ret = -EINVAL;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002375 }
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07002376
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002377 }
2378 /*
2379 command should be a string having format
2380 SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces>
2381 */
Amar Singhal0974e402013-02-12 14:27:46 -08002382 else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0)
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002383 {
Amar Singhal0974e402013-02-12 14:27:46 -08002384 tANI_U8 *ptr = command;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002385
2386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002387 " Received Command to Set Preferred Channels for SAP in %s", __func__);
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002388
Mahesh Kumar Kalikot Veetil2aad8d82013-02-07 12:31:28 -08002389 ret = sapSetPreferredChannel(ptr);
Jeff Johnson32d95a32012-09-10 13:15:23 -07002390 }
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002391 else if(strncmp(command, "SETSUSPENDMODE", 14) == 0)
2392 {
2393 int suspend = 0;
2394 tANI_U8 *ptr = (tANI_U8*)command + 15;
2395
2396 suspend = *ptr - '0';
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302397 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2398 TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL,
2399 pAdapter->sessionId, suspend));
Sameer Thalappil45931fb2013-02-01 11:18:05 -08002400 hdd_set_wlan_suspend_mode(suspend);
2401 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002402#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2403 else if (strncmp(command, "SETROAMTRIGGER", 14) == 0)
2404 {
2405 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002406 tANI_S8 rssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002407 tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT;
2408 eHalStatus status = eHAL_STATUS_SUCCESS;
2409
2410 /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */
2411 value = value + 15;
2412
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002413 /* Convert the value from ascii to integer */
2414 ret = kstrtos8(value, 10, &rssi);
2415 if (ret < 0)
2416 {
2417 /* If the input value is greater than max value of datatype, then also
2418 kstrtou8 fails */
2419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2420 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdafa7157d2013-10-31 10:14:22 -07002421 __func__,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002422 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2423 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2424 ret = -EINVAL;
2425 goto exit;
2426 }
2427
Srinivas Girigowdade697412013-02-14 16:31:48 -08002428 lookUpThreshold = abs(rssi);
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002429
Srinivas Girigowdade697412013-02-14 16:31:48 -08002430 if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) ||
2431 (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX))
2432 {
2433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2434 "Neighbor lookup threshold value %d is out of range"
2435 " (Min: %d Max: %d)", lookUpThreshold,
2436 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN,
2437 CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX);
2438 ret = -EINVAL;
2439 goto exit;
2440 }
2441
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302442 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2443 TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL,
2444 pAdapter->sessionId, lookUpThreshold));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2446 "%s: Received Command to Set Roam trigger"
2447 " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold);
2448
2449 pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold;
2450 status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold);
2451 if (eHAL_STATUS_SUCCESS != status)
2452 {
2453 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2454 "%s: Failed to set roam trigger, try again", __func__);
2455 ret = -EPERM;
2456 goto exit;
2457 }
2458
2459 /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */
mukul sharmad6e1fdd2014-06-23 19:19:09 +05302460 pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002461 sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5);
2462 }
2463 else if (strncmp(command, "GETROAMTRIGGER", 14) == 0)
2464 {
2465 tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal));
2466 int rssi = (-1) * lookUpThreshold;
2467 char extra[32];
2468 tANI_U8 len = 0;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302469 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2470 TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL,
2471 pAdapter->sessionId, lookUpThreshold));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002472 len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi);
Srinivas Girigowda91719232015-07-13 15:10:10 +05302473 len = VOS_MIN(priv_data.total_len, len + 1);
2474 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002475 {
2476 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2477 "%s: failed to copy data to user buffer", __func__);
2478 ret = -EFAULT;
2479 goto exit;
2480 }
2481 }
2482 else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0)
2483 {
2484 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002485 tANI_U8 roamScanPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002486 tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002487
Srinivas Girigowdade697412013-02-14 16:31:48 -08002488 /* input refresh period is in terms of seconds */
2489 /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */
2490 value = value + 18;
2491 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002492 ret = kstrtou8(value, 10, &roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002493 if (ret < 0)
2494 {
2495 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002496 kstrtou8 fails */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002498 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdade697412013-02-14 16:31:48 -08002499 __func__,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002500 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2501 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002502 ret = -EINVAL;
2503 goto exit;
2504 }
2505
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002506 if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) ||
2507 (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002508 {
2509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002510 "Roam scan period value %d is out of range"
2511 " (Min: %d Max: %d)", roamScanPeriod,
Srinivas Girigowdab8edd1e2013-03-19 11:42:08 -07002512 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000),
2513 (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002514 ret = -EINVAL;
2515 goto exit;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302516 }
2517 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2518 TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL,
2519 pAdapter->sessionId, roamScanPeriod));
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002520 neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002521
2522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2523 "%s: Received Command to Set roam scan period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002524 " (Empty Scan refresh period) = %d", __func__, roamScanPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002525
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002526 pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod;
2527 sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002528 }
2529 else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0)
2530 {
2531 tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2532 char extra[32];
2533 tANI_U8 len = 0;
2534
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302535 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2536 TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL,
2537 pAdapter->sessionId, nEmptyScanRefreshPeriod));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002538 len = scnprintf(extra, sizeof(extra), "%s %d",
2539 "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002540 /* Returned value is in units of seconds */
Ratnam Rachuria72ba112015-07-17 13:27:03 +05302541 len = VOS_MIN(priv_data.total_len, len + 1);
2542 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002543 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2544 "%s: failed to copy data to user buffer", __func__);
2545 ret = -EFAULT;
2546 goto exit;
2547 }
2548 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002549 else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0)
2550 {
2551 tANI_U8 *value = command;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002552 tANI_U8 roamScanRefreshPeriod = 0;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002553 tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002554
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002555 /* input refresh period is in terms of seconds */
2556 /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */
2557 value = value + 25;
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002558
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002559 /* Convert the value from ascii to integer */
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002560 ret = kstrtou8(value, 10, &roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002561 if (ret < 0)
2562 {
2563 /* If the input value is greater than max value of datatype, then also
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002564 kstrtou8 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002566 "%s: kstrtou8 failed Input value may be out of range[%d - %d]",
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002567 __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002568 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2569 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2570 ret = -EINVAL;
2571 goto exit;
2572 }
2573
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002574 if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) ||
2575 (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)))
2576 {
2577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2578 "Neighbor scan results refresh period value %d is out of range"
2579 " (Min: %d Max: %d)", roamScanRefreshPeriod,
2580 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000),
2581 (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000));
2582 ret = -EINVAL;
2583 goto exit;
2584 }
2585 neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000;
2586
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2588 "%s: Received Command to Set roam scan refresh period"
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002589 " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002590
2591 pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod;
2592 sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod);
2593 }
2594 else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0)
2595 {
2596 tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal));
2597 char extra[32];
2598 tANI_U8 len = 0;
2599
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002600 len = scnprintf(extra, sizeof(extra), "%s %d",
2601 "GETROAMSCANREFRESHPERIOD", (value/1000));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002602 /* Returned value is in units of seconds */
Ratnam Rachuri2c9d6702015-07-17 13:25:16 +05302603 len = VOS_MIN(priv_data.total_len, len + 1);
2604 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002605 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2606 "%s: failed to copy data to user buffer", __func__);
2607 ret = -EFAULT;
2608 goto exit;
2609 }
2610 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002611#ifdef FEATURE_WLAN_LFR
2612 /* SETROAMMODE */
2613 else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0)
2614 {
2615 tANI_U8 *value = command;
2616 tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
2617
2618 /* Move pointer to ahead of SETROAMMODE<delimiter> */
2619 value = value + SIZE_OF_SETROAMMODE + 1;
2620
2621 /* Convert the value from ascii to integer */
2622 ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode);
2623 if (ret < 0)
2624 {
2625 /* If the input value is greater than max value of datatype, then also
2626 kstrtou8 fails */
2627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2628 "%s: kstrtou8 failed range [%d - %d]", __func__,
2629 CFG_LFR_FEATURE_ENABLED_MIN,
2630 CFG_LFR_FEATURE_ENABLED_MAX);
2631 ret = -EINVAL;
2632 goto exit;
2633 }
2634 if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
2635 (roamMode > CFG_LFR_FEATURE_ENABLED_MAX))
2636 {
2637 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2638 "Roam Mode value %d is out of range"
2639 " (Min: %d Max: %d)", roamMode,
2640 CFG_LFR_FEATURE_ENABLED_MIN,
2641 CFG_LFR_FEATURE_ENABLED_MAX);
2642 ret = -EINVAL;
2643 goto exit;
2644 }
2645
2646 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2647 "%s: Received Command to Set Roam Mode = %d", __func__, roamMode);
2648 /*
2649 * Note that
2650 * SETROAMMODE 0 is to enable LFR while
2651 * SETROAMMODE 1 is to disable LFR, but
2652 * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable.
2653 * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled.
2654 */
2655 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2656 roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */
2657 else
2658 roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */
2659
2660 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode;
2661 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode);
2662 }
2663 /* GETROAMMODE */
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05302664 else if (strncmp(command, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0)
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002665 {
2666 tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2667 char extra[32];
2668 tANI_U8 len = 0;
2669
2670 /*
2671 * roamMode value shall be inverted because the sementics is different.
2672 */
2673 if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode)
2674 roamMode = CFG_LFR_FEATURE_ENABLED_MAX;
2675 else
2676 roamMode = CFG_LFR_FEATURE_ENABLED_MIN;
2677
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002678 len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode);
Ratnam Rachuri28693eb2015-07-17 13:23:42 +05302679 len = VOS_MIN(priv_data.total_len, len + 1);
2680 if (copy_to_user(priv_data.buf, &extra, len)) {
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -07002681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2682 "%s: failed to copy data to user buffer", __func__);
2683 ret = -EFAULT;
2684 goto exit;
2685 }
2686 }
2687#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08002688#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002689#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002690 else if (strncmp(command, "SETROAMDELTA", 12) == 0)
2691 {
2692 tANI_U8 *value = command;
2693 tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT;
2694
2695 /* Move pointer to ahead of SETROAMDELTA<delimiter> */
2696 value = value + 13;
2697 /* Convert the value from ascii to integer */
2698 ret = kstrtou8(value, 10, &roamRssiDiff);
2699 if (ret < 0)
2700 {
2701 /* If the input value is greater than max value of datatype, then also
2702 kstrtou8 fails */
2703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2704 "%s: kstrtou8 failed range [%d - %d]", __func__,
2705 CFG_ROAM_RSSI_DIFF_MIN,
2706 CFG_ROAM_RSSI_DIFF_MAX);
2707 ret = -EINVAL;
2708 goto exit;
2709 }
2710
2711 if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) ||
2712 (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX))
2713 {
2714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2715 "Roam rssi diff value %d is out of range"
2716 " (Min: %d Max: %d)", roamRssiDiff,
2717 CFG_ROAM_RSSI_DIFF_MIN,
2718 CFG_ROAM_RSSI_DIFF_MAX);
2719 ret = -EINVAL;
2720 goto exit;
2721 }
2722
2723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2724 "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff);
2725
2726 pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff;
2727 sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff);
2728 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05302729 else if (strncmp(command, "GETROAMDELTA", 12) == 0)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002730 {
2731 tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal));
2732 char extra[32];
2733 tANI_U8 len = 0;
2734
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302735 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2736 TRACE_CODE_HDD_GETROAMDELTA_IOCTL,
2737 pAdapter->sessionId, roamRssiDiff));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002738 len = scnprintf(extra, sizeof(extra), "%s %d",
2739 command, roamRssiDiff);
Ratnam Rachuri22a3b402015-07-17 13:21:49 +05302740 len = VOS_MIN(priv_data.total_len, len + 1);
2741 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2743 "%s: failed to copy data to user buffer", __func__);
2744 ret = -EFAULT;
2745 goto exit;
2746 }
2747 }
2748#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002749#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08002750 else if (strncmp(command, "GETBAND", 7) == 0)
2751 {
2752 int band = -1;
2753 char extra[32];
2754 tANI_U8 len = 0;
2755 hdd_getBand_helper(pHddCtx, &band);
2756
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302757 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2758 TRACE_CODE_HDD_GETBAND_IOCTL,
2759 pAdapter->sessionId, band));
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002760 len = scnprintf(extra, sizeof(extra), "%s %d", command, band);
Ratnam Rachuri52139592015-07-17 13:17:29 +05302761 len = VOS_MIN(priv_data.total_len, len + 1);
2762 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2764 "%s: failed to copy data to user buffer", __func__);
2765 ret = -EFAULT;
2766 goto exit;
2767 }
2768 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002769 else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0)
2770 {
2771 tANI_U8 *value = command;
2772 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2773 tANI_U8 numChannels = 0;
2774 eHalStatus status = eHAL_STATUS_SUCCESS;
2775
2776 status = hdd_parse_channellist(value, ChannelList, &numChannels);
2777 if (eHAL_STATUS_SUCCESS != status)
2778 {
2779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2780 "%s: Failed to parse channel list information", __func__);
2781 ret = -EINVAL;
2782 goto exit;
2783 }
2784
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302785 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2786 TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL,
2787 pAdapter->sessionId, numChannels));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002788 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2789 {
2790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2791 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
2792 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
2793 ret = -EINVAL;
2794 goto exit;
2795 }
2796 status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList,
2797 numChannels);
2798 if (eHAL_STATUS_SUCCESS != status)
2799 {
2800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2801 "%s: Failed to update channel list information", __func__);
2802 ret = -EINVAL;
2803 goto exit;
2804 }
2805 }
2806 else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0)
2807 {
2808 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
2809 tANI_U8 numChannels = 0;
Jeff Johnson51b67782013-04-05 12:35:41 -07002810 tANI_U8 j = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002811 char extra[128] = {0};
Jeff Johnson51b67782013-04-05 12:35:41 -07002812 int len;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002813
2814 if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal),
2815 ChannelList, &numChannels ))
2816 {
2817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2818 "%s: failed to get roam scan channel list", __func__);
2819 ret = -EFAULT;
2820 goto exit;
2821 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302822 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2823 TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL,
2824 pAdapter->sessionId, numChannels));
Srinivas Girigowdade697412013-02-14 16:31:48 -08002825 /* output channel list is of the format
2826 [Number of roam scan channels][Channel1][Channel2]... */
2827 /* copy the number of channels in the 0th index */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002828 len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002829 for (j = 0; (j < numChannels); j++)
2830 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002831 len += scnprintf(extra + len, sizeof(extra) - len, " %d",
2832 ChannelList[j]);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002833 }
2834
Sushant Kaushikc9b8be52015-07-15 16:41:27 +05302835 len = VOS_MIN(priv_data.total_len, len + 1);
2836 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdade697412013-02-14 16:31:48 -08002837 {
2838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2839 "%s: failed to copy data to user buffer", __func__);
2840 ret = -EFAULT;
2841 goto exit;
2842 }
2843 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002844 else if (strncmp(command, "GETCCXMODE", 10) == 0)
2845 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002846 tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002847 char extra[32];
2848 tANI_U8 len = 0;
2849
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002850 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002851 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002852 if (eseMode &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002853 hdd_is_okc_mode_enabled(pHddCtx) &&
2854 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2855 {
2856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002857 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002858 " hence this operation is not permitted!", __func__);
2859 ret = -EPERM;
2860 goto exit;
2861 }
2862
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002863 len = scnprintf(extra, sizeof(extra), "%s %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002864 "GETCCXMODE", eseMode);
Sushant Kaushikf8abd352015-07-15 16:37:49 +05302865 len = VOS_MIN(priv_data.total_len, len + 1);
2866 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002867 {
2868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2869 "%s: failed to copy data to user buffer", __func__);
2870 ret = -EFAULT;
2871 goto exit;
2872 }
2873 }
2874 else if (strncmp(command, "GETOKCMODE", 10) == 0)
2875 {
2876 tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx);
2877 char extra[32];
2878 tANI_U8 len = 0;
2879
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002880 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002881 then this operation is not permitted (return FAILURE) */
2882 if (okcMode &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002883 sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002884 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
2885 {
2886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002887 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07002888 " hence this operation is not permitted!", __func__);
2889 ret = -EPERM;
2890 goto exit;
2891 }
2892
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002893 len = scnprintf(extra, sizeof(extra), "%s %d",
2894 "GETOKCMODE", okcMode);
Sushant Kaushikbc2fb5c2015-07-15 16:43:16 +05302895 len = VOS_MIN(priv_data.total_len, len + 1);
2896 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002897 {
2898 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2899 "%s: failed to copy data to user buffer", __func__);
2900 ret = -EFAULT;
2901 goto exit;
2902 }
2903 }
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07002904 else if (strncmp(command, "GETFASTROAM", 11) == 0)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002905 {
2906 tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2907 char extra[32];
2908 tANI_U8 len = 0;
2909
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002910 len = scnprintf(extra, sizeof(extra), "%s %d",
2911 "GETFASTROAM", lfrMode);
Sushant Kaushik4da7ec92015-07-15 16:39:32 +05302912 len = VOS_MIN(priv_data.total_len, len + 1);
2913 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002914 {
2915 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2916 "%s: failed to copy data to user buffer", __func__);
2917 ret = -EFAULT;
2918 goto exit;
2919 }
2920 }
2921 else if (strncmp(command, "GETFASTTRANSITION", 17) == 0)
2922 {
2923 tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal));
2924 char extra[32];
2925 tANI_U8 len = 0;
2926
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002927 len = scnprintf(extra, sizeof(extra), "%s %d",
2928 "GETFASTTRANSITION", ft);
Sushant Kaushik231a4452015-07-15 16:23:56 +05302929 len = VOS_MIN(priv_data.total_len, len + 1);
2930 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002931 {
2932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2933 "%s: failed to copy data to user buffer", __func__);
2934 ret = -EFAULT;
2935 goto exit;
2936 }
2937 }
2938 else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0)
2939 {
2940 tANI_U8 *value = command;
2941 tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT;
2942
2943 /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */
2944 value = value + 26;
2945 /* Convert the value from ascii to integer */
2946 ret = kstrtou8(value, 10, &minTime);
2947 if (ret < 0)
2948 {
2949 /* If the input value is greater than max value of datatype, then also
2950 kstrtou8 fails */
2951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2952 "%s: kstrtou8 failed range [%d - %d]", __func__,
2953 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2954 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2955 ret = -EINVAL;
2956 goto exit;
2957 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002958 if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) ||
2959 (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX))
2960 {
2961 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2962 "scan min channel time value %d is out of range"
2963 " (Min: %d Max: %d)", minTime,
2964 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN,
2965 CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX);
2966 ret = -EINVAL;
2967 goto exit;
2968 }
2969
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05302970 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
2971 TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL,
2972 pAdapter->sessionId, minTime));
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2974 "%s: Received Command to change channel min time = %d", __func__, minTime);
2975
2976 pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime;
2977 sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime);
2978 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07002979 else if (strncmp(command, "SENDACTIONFRAME", 15) == 0)
2980 {
2981 tANI_U8 *value = command;
2982 tANI_U8 channel = 0;
2983 tANI_U8 dwellTime = 0;
2984 tANI_U8 bufLen = 0;
2985 tANI_U8 *buf = NULL;
2986 tSirMacAddr targetApBssid;
2987 eHalStatus status = eHAL_STATUS_SUCCESS;
2988 struct ieee80211_channel chan;
2989 tANI_U8 finalLen = 0;
2990 tANI_U8 *finalBuf = NULL;
2991 tANI_U8 temp = 0;
2992 u64 cookie;
2993 hdd_station_ctx_t *pHddStaCtx = NULL;
2994 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2995
2996 /* if not associated, no need to send action frame */
2997 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2998 {
2999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3000 ret = -EINVAL;
3001 goto exit;
3002 }
3003
3004 status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel,
3005 &dwellTime, &buf, &bufLen);
3006 if (eHAL_STATUS_SUCCESS != status)
3007 {
3008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3009 "%s: Failed to parse send action frame data", __func__);
3010 ret = -EINVAL;
3011 goto exit;
3012 }
3013
3014 /* if the target bssid is different from currently associated AP,
3015 then no need to send action frame */
3016 if (VOS_TRUE != vos_mem_compare(targetApBssid,
3017 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3018 {
3019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__);
3020 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07003021 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003022 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003023 goto exit;
3024 }
3025
3026 /* if the channel number is different from operating channel then
3027 no need to send action frame */
3028 if (channel != pHddStaCtx->conn_info.operationChannel)
3029 {
3030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3031 "%s: channel(%d) is different from operating channel(%d)",
3032 __func__, channel, pHddStaCtx->conn_info.operationChannel);
3033 ret = -EINVAL;
Jeff Johnson11c33152013-04-16 17:52:40 -07003034 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003035 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003036 goto exit;
3037 }
3038 chan.center_freq = sme_ChnToFreq(channel);
3039
3040 finalLen = bufLen + 24;
3041 finalBuf = vos_mem_malloc(finalLen);
3042 if (NULL == finalBuf)
3043 {
3044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__);
3045 ret = -ENOMEM;
Jeff Johnson11c33152013-04-16 17:52:40 -07003046 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003047 buf = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003048 goto exit;
3049 }
3050 vos_mem_zero(finalBuf, finalLen);
3051
3052 /* Fill subtype */
3053 temp = SIR_MAC_MGMT_ACTION << 4;
3054 vos_mem_copy(finalBuf + 0, &temp, sizeof(temp));
3055
3056 /* Fill type */
3057 temp = SIR_MAC_MGMT_FRAME;
3058 vos_mem_copy(finalBuf + 2, &temp, sizeof(temp));
3059
3060 /* Fill destination address (bssid of the AP) */
3061 vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid));
3062
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07003063 /* Fill source address (STA mac address) */
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003064 vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes));
3065
Srinivas Girigowdab27c0192013-06-03 10:19:56 -07003066 /* Fill BSSID (AP mac address) */
3067 vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid));
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003068
3069 /* Fill received buffer from 24th address */
3070 vos_mem_copy(finalBuf + 24, buf, bufLen);
3071
Jeff Johnson11c33152013-04-16 17:52:40 -07003072 /* done with the parsed buffer */
3073 vos_mem_free(buf);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08003074 buf = NULL;
Jeff Johnson11c33152013-04-16 17:52:40 -07003075
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05303076#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
3077 params.chan = &chan;
3078 params.offchan = 0;
3079 params.wait = dwellTime;
3080 params.buf = finalBuf;
3081 params.len = finalLen;
3082 params.no_cck = 1;
3083 params.dont_wait_for_ack = 1;
3084 ret = wlan_hdd_mgmt_tx(NULL, &pAdapter->wdev, &params, &cookie);
3085#else
DARAM SUDHA39eede62014-02-12 11:16:40 +05303086 wlan_hdd_mgmt_tx( NULL,
Yue Maf49ba872013-08-19 12:04:25 -07003087#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
3088 &(pAdapter->wdev),
3089#else
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07003090 pAdapter->dev,
Yue Maf49ba872013-08-19 12:04:25 -07003091#endif
3092 &chan, 0,
3093#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
3094 NL80211_CHAN_HT20, 1,
3095#endif
3096 dwellTime, finalBuf, finalLen, 1,
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003097 1, &cookie );
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05303098#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003099 vos_mem_free(finalBuf);
3100 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003101 else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0)
3102 {
3103 tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal));
3104 char extra[32];
3105 tANI_U8 len = 0;
3106
3107 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003108 len = scnprintf(extra, sizeof(extra), "%s %d",
3109 "GETROAMSCANCHANNELMINTIME", val);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3111 TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL,
3112 pAdapter->sessionId, val));
Sushant Kaushikbb8c52c2015-07-15 16:36:23 +05303113 len = VOS_MIN(priv_data.total_len, len + 1);
3114 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003115 {
3116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3117 "%s: failed to copy data to user buffer", __func__);
3118 ret = -EFAULT;
3119 goto exit;
3120 }
3121 }
3122 else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0)
3123 {
3124 tANI_U8 *value = command;
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003125 tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003126
3127 /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */
3128 value = value + 19;
3129 /* Convert the value from ascii to integer */
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003130 ret = kstrtou16(value, 10, &maxTime);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003131 if (ret < 0)
3132 {
3133 /* If the input value is greater than max value of datatype, then also
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003134 kstrtou16 fails */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003135 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu3885a662013-06-19 07:10:37 -07003136 "%s: kstrtou16 failed range [%d - %d]", __func__,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003137 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
3138 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
3139 ret = -EINVAL;
3140 goto exit;
3141 }
3142
3143 if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) ||
3144 (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX))
3145 {
3146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3147 "lfr mode value %d is out of range"
3148 " (Min: %d Max: %d)", maxTime,
3149 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN,
3150 CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX);
3151 ret = -EINVAL;
3152 goto exit;
3153 }
3154
3155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3156 "%s: Received Command to change channel max time = %d", __func__, maxTime);
3157
3158 pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime;
3159 sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime);
3160 }
3161 else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0)
3162 {
3163 tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal));
3164 char extra[32];
3165 tANI_U8 len = 0;
3166
3167 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003168 len = scnprintf(extra, sizeof(extra), "%s %d",
3169 "GETSCANCHANNELTIME", val);
Ratheesh S Pacbfa932015-07-16 15:27:18 +05303170 len = VOS_MIN(priv_data.total_len, len + 1);
3171 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003172 {
3173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3174 "%s: failed to copy data to user buffer", __func__);
3175 ret = -EFAULT;
3176 goto exit;
3177 }
3178 }
3179 else if (strncmp(command, "SETSCANHOMETIME", 15) == 0)
3180 {
3181 tANI_U8 *value = command;
3182 tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT;
3183
3184 /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */
3185 value = value + 16;
3186 /* Convert the value from ascii to integer */
3187 ret = kstrtou16(value, 10, &val);
3188 if (ret < 0)
3189 {
3190 /* If the input value is greater than max value of datatype, then also
3191 kstrtou16 fails */
3192 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3193 "%s: kstrtou16 failed range [%d - %d]", __func__,
3194 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
3195 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
3196 ret = -EINVAL;
3197 goto exit;
3198 }
3199
3200 if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) ||
3201 (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX))
3202 {
3203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3204 "scan home time value %d is out of range"
3205 " (Min: %d Max: %d)", val,
3206 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN,
3207 CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX);
3208 ret = -EINVAL;
3209 goto exit;
3210 }
3211
3212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3213 "%s: Received Command to change scan home time = %d", __func__, val);
3214
3215 pHddCtx->cfg_ini->nNeighborScanPeriod = val;
3216 sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val);
3217 }
3218 else if (strncmp(command, "GETSCANHOMETIME", 15) == 0)
3219 {
3220 tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal));
3221 char extra[32];
3222 tANI_U8 len = 0;
3223
3224 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003225 len = scnprintf(extra, sizeof(extra), "%s %d",
3226 "GETSCANHOMETIME", val);
Ratheesh S P728d7c62015-07-16 15:38:58 +05303227 len = VOS_MIN(priv_data.total_len, len + 1);
3228 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003229 {
3230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3231 "%s: failed to copy data to user buffer", __func__);
3232 ret = -EFAULT;
3233 goto exit;
3234 }
3235 }
3236 else if (strncmp(command, "SETROAMINTRABAND", 16) == 0)
3237 {
3238 tANI_U8 *value = command;
3239 tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT;
3240
3241 /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */
3242 value = value + 17;
3243 /* Convert the value from ascii to integer */
3244 ret = kstrtou8(value, 10, &val);
3245 if (ret < 0)
3246 {
3247 /* If the input value is greater than max value of datatype, then also
3248 kstrtou8 fails */
3249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3250 "%s: kstrtou8 failed range [%d - %d]", __func__,
3251 CFG_ROAM_INTRA_BAND_MIN,
3252 CFG_ROAM_INTRA_BAND_MAX);
3253 ret = -EINVAL;
3254 goto exit;
3255 }
3256
3257 if ((val < CFG_ROAM_INTRA_BAND_MIN) ||
3258 (val > CFG_ROAM_INTRA_BAND_MAX))
3259 {
3260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3261 "intra band mode value %d is out of range"
3262 " (Min: %d Max: %d)", val,
3263 CFG_ROAM_INTRA_BAND_MIN,
3264 CFG_ROAM_INTRA_BAND_MAX);
3265 ret = -EINVAL;
3266 goto exit;
3267 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3269 "%s: Received Command to change intra band = %d", __func__, val);
3270
3271 pHddCtx->cfg_ini->nRoamIntraBand = val;
3272 sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val);
3273 }
3274 else if (strncmp(command, "GETROAMINTRABAND", 16) == 0)
3275 {
3276 tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal));
3277 char extra[32];
3278 tANI_U8 len = 0;
3279
3280 /* value is interms of msec */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003281 len = scnprintf(extra, sizeof(extra), "%s %d",
3282 "GETROAMINTRABAND", val);
Ratheesh S P2dd2a3e2015-07-16 15:34:23 +05303283 len = VOS_MIN(priv_data.total_len, len + 1);
3284 if (copy_to_user(priv_data.buf, &extra, len))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003285 {
3286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3287 "%s: failed to copy data to user buffer", __func__);
3288 ret = -EFAULT;
3289 goto exit;
3290 }
3291 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003292 else if (strncmp(command, "SETSCANNPROBES", 14) == 0)
3293 {
3294 tANI_U8 *value = command;
3295 tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT;
3296
3297 /* Move pointer to ahead of SETSCANNPROBES<delimiter> */
3298 value = value + 15;
3299 /* Convert the value from ascii to integer */
3300 ret = kstrtou8(value, 10, &nProbes);
3301 if (ret < 0)
3302 {
3303 /* If the input value is greater than max value of datatype, then also
3304 kstrtou8 fails */
3305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3306 "%s: kstrtou8 failed range [%d - %d]", __func__,
3307 CFG_ROAM_SCAN_N_PROBES_MIN,
3308 CFG_ROAM_SCAN_N_PROBES_MAX);
3309 ret = -EINVAL;
3310 goto exit;
3311 }
3312
3313 if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) ||
3314 (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX))
3315 {
3316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3317 "NProbes value %d is out of range"
3318 " (Min: %d Max: %d)", nProbes,
3319 CFG_ROAM_SCAN_N_PROBES_MIN,
3320 CFG_ROAM_SCAN_N_PROBES_MAX);
3321 ret = -EINVAL;
3322 goto exit;
3323 }
3324
3325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3326 "%s: Received Command to Set nProbes = %d", __func__, nProbes);
3327
3328 pHddCtx->cfg_ini->nProbes = nProbes;
3329 sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes);
3330 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303331 else if (strncmp(command, "GETSCANNPROBES", 14) == 0)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003332 {
3333 tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal));
3334 char extra[32];
3335 tANI_U8 len = 0;
3336
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003337 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Ratnam Rachuri6da525d2015-08-07 13:55:54 +05303338 len = VOS_MIN(priv_data.total_len, len + 1);
3339 if (copy_to_user(priv_data.buf, &extra, len)) {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3341 "%s: failed to copy data to user buffer", __func__);
3342 ret = -EFAULT;
3343 goto exit;
3344 }
3345 }
3346 else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0)
3347 {
3348 tANI_U8 *value = command;
3349 tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT;
3350
3351 /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */
3352 /* input value is in units of msec */
3353 value = value + 20;
3354 /* Convert the value from ascii to integer */
3355 ret = kstrtou16(value, 10, &homeAwayTime);
3356 if (ret < 0)
3357 {
3358 /* If the input value is greater than max value of datatype, then also
3359 kstrtou8 fails */
3360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3361 "%s: kstrtou8 failed range [%d - %d]", __func__,
3362 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
3363 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
3364 ret = -EINVAL;
3365 goto exit;
3366 }
3367
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003368 if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) ||
3369 (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX))
3370 {
3371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3372 "homeAwayTime value %d is out of range"
3373 " (Min: %d Max: %d)", homeAwayTime,
3374 CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN,
3375 CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX);
3376 ret = -EINVAL;
3377 goto exit;
3378 }
3379
3380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3381 "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07003382 if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime)
3383 {
3384 pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime;
3385 sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE);
3386 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003387 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303388 else if (strncmp(command, "GETSCANHOMEAWAYTIME", 19) == 0)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003389 {
3390 tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal));
3391 char extra[32];
3392 tANI_U8 len = 0;
3393
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003394 len = scnprintf(extra, sizeof(extra), "%s %d", command, val);
Ratnam Rachuri51a5ad12015-08-07 14:06:37 +05303395 len = VOS_MIN(priv_data.total_len, len + 1);
3396 if (copy_to_user(priv_data.buf, &extra, len)) {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3398 "%s: failed to copy data to user buffer", __func__);
3399 ret = -EFAULT;
3400 goto exit;
3401 }
3402 }
3403 else if (strncmp(command, "REASSOC", 7) == 0)
3404 {
3405 tANI_U8 *value = command;
3406 tANI_U8 channel = 0;
3407 tSirMacAddr targetApBssid;
3408 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003409#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3410 tCsrHandoffRequest handoffInfo;
3411#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003412 hdd_station_ctx_t *pHddStaCtx = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003413 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3414
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003415 /* if not associated, no need to proceed with reassoc */
3416 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3417 {
3418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3419 ret = -EINVAL;
3420 goto exit;
3421 }
3422
3423 status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel);
3424 if (eHAL_STATUS_SUCCESS != status)
3425 {
3426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3427 "%s: Failed to parse reassoc command data", __func__);
3428 ret = -EINVAL;
3429 goto exit;
3430 }
3431
3432 /* if the target bssid is same as currently associated AP,
3433 then no need to proceed with reassoc */
3434 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3435 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3436 {
3437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__);
3438 ret = -EINVAL;
3439 goto exit;
3440 }
3441
3442 /* Check channel number is a valid channel number */
3443 if(VOS_STATUS_SUCCESS !=
3444 wlan_hdd_validate_operation_channel(pAdapter, channel))
3445 {
3446 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003447 "%s: Invalid Channel [%d]", __func__, channel);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003448 return -EINVAL;
3449 }
3450
3451 /* Proceed with reassoc */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003452#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3453 handoffInfo.channel = channel;
3454 vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr));
3455 sme_HandoffRequest(pHddCtx->hHal, &handoffInfo);
3456#endif
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07003457 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003458 else if (strncmp(command, "SETWESMODE", 10) == 0)
3459 {
3460 tANI_U8 *value = command;
3461 tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT;
3462
3463 /* Move pointer to ahead of SETWESMODE<delimiter> */
3464 value = value + 11;
3465 /* Convert the value from ascii to integer */
3466 ret = kstrtou8(value, 10, &wesMode);
3467 if (ret < 0)
3468 {
3469 /* If the input value is greater than max value of datatype, then also
3470 kstrtou8 fails */
3471 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3472 "%s: kstrtou8 failed range [%d - %d]", __func__,
3473 CFG_ENABLE_WES_MODE_NAME_MIN,
3474 CFG_ENABLE_WES_MODE_NAME_MAX);
3475 ret = -EINVAL;
3476 goto exit;
3477 }
3478
3479 if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) ||
3480 (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX))
3481 {
3482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3483 "WES Mode value %d is out of range"
3484 " (Min: %d Max: %d)", wesMode,
3485 CFG_ENABLE_WES_MODE_NAME_MIN,
3486 CFG_ENABLE_WES_MODE_NAME_MAX);
3487 ret = -EINVAL;
3488 goto exit;
3489 }
3490 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3491 "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode);
3492
3493 pHddCtx->cfg_ini->isWESModeEnabled = wesMode;
3494 sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode);
3495 }
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303496 else if (strncmp(command, "GETWESMODE", 10) == 0)
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003497 {
3498 tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal));
3499 char extra[32];
3500 tANI_U8 len = 0;
3501
Arif Hussain826d9412013-11-12 16:44:54 -08003502 len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode);
Ratnam Rachuri8fe90c62015-08-07 14:03:26 +05303503 len = VOS_MIN(priv_data.total_len, len + 1);
3504 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003505 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3506 "%s: failed to copy data to user buffer", __func__);
3507 ret = -EFAULT;
3508 goto exit;
3509 }
3510 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003511#endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003512#ifdef FEATURE_WLAN_LFR
3513 else if (strncmp(command, "SETFASTROAM", 11) == 0)
3514 {
3515 tANI_U8 *value = command;
3516 tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT;
3517
3518 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3519 value = value + 12;
3520 /* Convert the value from ascii to integer */
3521 ret = kstrtou8(value, 10, &lfrMode);
3522 if (ret < 0)
3523 {
3524 /* If the input value is greater than max value of datatype, then also
3525 kstrtou8 fails */
3526 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3527 "%s: kstrtou8 failed range [%d - %d]", __func__,
3528 CFG_LFR_FEATURE_ENABLED_MIN,
3529 CFG_LFR_FEATURE_ENABLED_MAX);
3530 ret = -EINVAL;
3531 goto exit;
3532 }
3533
3534 if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) ||
3535 (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX))
3536 {
3537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3538 "lfr mode value %d is out of range"
3539 " (Min: %d Max: %d)", lfrMode,
3540 CFG_LFR_FEATURE_ENABLED_MIN,
3541 CFG_LFR_FEATURE_ENABLED_MAX);
3542 ret = -EINVAL;
3543 goto exit;
3544 }
3545
3546 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3547 "%s: Received Command to change lfr mode = %d", __func__, lfrMode);
3548
3549 pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode;
3550 sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode);
3551 }
3552#endif
3553#ifdef WLAN_FEATURE_VOWIFI_11R
3554 else if (strncmp(command, "SETFASTTRANSITION", 17) == 0)
3555 {
3556 tANI_U8 *value = command;
3557 tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT;
3558
3559 /* Move pointer to ahead of SETFASTROAM<delimiter> */
3560 value = value + 18;
3561 /* Convert the value from ascii to integer */
3562 ret = kstrtou8(value, 10, &ft);
3563 if (ret < 0)
3564 {
3565 /* If the input value is greater than max value of datatype, then also
3566 kstrtou8 fails */
3567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3568 "%s: kstrtou8 failed range [%d - %d]", __func__,
3569 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3570 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3571 ret = -EINVAL;
3572 goto exit;
3573 }
3574
3575 if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) ||
3576 (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX))
3577 {
3578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3579 "ft mode value %d is out of range"
3580 " (Min: %d Max: %d)", ft,
3581 CFG_FAST_TRANSITION_ENABLED_NAME_MIN,
3582 CFG_FAST_TRANSITION_ENABLED_NAME_MAX);
3583 ret = -EINVAL;
3584 goto exit;
3585 }
3586
3587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3588 "%s: Received Command to change ft mode = %d", __func__, ft);
3589
3590 pHddCtx->cfg_ini->isFastTransitionEnabled = ft;
3591 sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft);
3592 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303593 else if (strncmp(command, "SETDFSSCANMODE", 14) == 0)
3594 {
3595 tANI_U8 *value = command;
3596 tANI_U8 dfsScanMode = DFS_CHNL_SCAN_ENABLED_NORMAL;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303597
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303598 /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */
3599 value = value + 15;
3600 /* Convert the value from ascii to integer */
3601 ret = kstrtou8(value, 10, &dfsScanMode);
3602 if (ret < 0)
3603 {
3604 /* If the input value is greater than max value of
3605 datatype, then also kstrtou8 fails
3606 */
3607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3608 "%s: kstrtou8 failed range [%d - %d]", __func__,
3609 CFG_ENABLE_DFS_CHNL_SCAN_MIN,
3610 CFG_ENABLE_DFS_CHNL_SCAN_MAX);
3611 ret = -EINVAL;
3612 goto exit;
3613 }
3614
3615 if ((dfsScanMode < CFG_ENABLE_DFS_CHNL_SCAN_MIN) ||
3616 (dfsScanMode > CFG_ENABLE_DFS_CHNL_SCAN_MAX))
3617 {
3618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3619 "dfsScanMode value %d is out of range"
3620 " (Min: %d Max: %d)", dfsScanMode,
3621 CFG_ENABLE_DFS_CHNL_SCAN_MIN,
3622 CFG_ENABLE_DFS_CHNL_SCAN_MAX);
3623 ret = -EINVAL;
3624 goto exit;
3625 }
3626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3627 "%s: Received Command to Set DFS Scan Mode = %d",
3628 __func__, dfsScanMode);
3629
3630 ret = wlan_hdd_handle_dfs_chan_scan(pHddCtx, dfsScanMode);
3631 }
3632 else if (strncmp(command, "GETDFSSCANMODE", 14) == 0)
3633 {
3634 tANI_U8 dfsScanMode = sme_GetDFSScanMode(pHddCtx->hHal);
3635 char extra[32];
3636 tANI_U8 len = 0;
3637
3638 len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode);
Ratheesh S P767224e2015-07-16 15:35:51 +05303639 len = VOS_MIN(priv_data.total_len, len + 1);
3640 if (copy_to_user(priv_data.buf, &extra, len))
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05303641 {
3642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3643 "%s: failed to copy data to user buffer", __func__);
3644 ret = -EFAULT;
3645 goto exit;
3646 }
3647 }
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303648 else if (strncmp(command, "FASTREASSOC", 11) == 0)
3649 {
3650 tANI_U8 *value = command;
Padma, Santhosh Kumarf4582d32014-11-06 19:24:51 +05303651 tANI_U8 channel = 0;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303652 tSirMacAddr targetApBssid;
3653 tANI_U8 trigger = 0;
3654 eHalStatus status = eHAL_STATUS_SUCCESS;
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303655 tHalHandle hHal;
3656 v_U32_t roamId = 0;
3657 tCsrRoamModifyProfileFields modProfileFields;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303658 hdd_station_ctx_t *pHddStaCtx = NULL;
3659 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303660 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303661
3662 /* if not associated, no need to proceed with reassoc */
3663 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3664 {
3665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
3666 ret = -EINVAL;
3667 goto exit;
3668 }
3669
Padma, Santhosh Kumarf4582d32014-11-06 19:24:51 +05303670 status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303671 if (eHAL_STATUS_SUCCESS != status)
3672 {
3673 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3674 "%s: Failed to parse reassoc command data", __func__);
3675 ret = -EINVAL;
3676 goto exit;
3677 }
3678
3679 /* if the target bssid is same as currently associated AP,
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303680 issue reassoc to same AP */
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303681 if (VOS_TRUE == vos_mem_compare(targetApBssid,
3682 pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr)))
3683 {
3684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3685 "%s:11r Reassoc BSSID is same as currently associated AP bssid",
3686 __func__);
Padma, Santhosh Kumarb980a6f2014-11-06 19:07:24 +05303687 sme_GetModifyProfileFields(hHal, pAdapter->sessionId,
3688 &modProfileFields);
3689 sme_RoamReassoc(hHal, pAdapter->sessionId,
3690 NULL, modProfileFields, &roamId, 1);
3691 return 0;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303692 }
Padma, Santhosh Kumar0fa809b2014-11-13 14:56:56 +05303693
3694 /* Check channel number is a valid channel number */
3695 if(VOS_STATUS_SUCCESS !=
3696 wlan_hdd_validate_operation_channel(pAdapter, channel))
3697 {
3698 hddLog(VOS_TRACE_LEVEL_ERROR,
3699 "%s: Invalid Channel [%d]", __func__, channel);
3700 return -EINVAL;
3701 }
3702
Padma, Santhosh Kumarf4582d32014-11-06 19:24:51 +05303703 trigger = eSME_ROAM_TRIGGER_SCAN;
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303704
3705 /* Proceed with scan/roam */
3706 smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter),
3707 &targetApBssid[0],
Mukul Sharma9e4e0f92015-02-13 18:45:20 +05303708 (tSmeFastRoamTrigger)(trigger),
3709 channel);
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05303710 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003711#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003712#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003713 else if (strncmp(command, "SETCCXMODE", 10) == 0)
3714 {
3715 tANI_U8 *value = command;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003716 tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003717
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003718 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003719 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003720 if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003721 hdd_is_okc_mode_enabled(pHddCtx) &&
3722 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3723 {
3724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003725 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003726 " hence this operation is not permitted!", __func__);
3727 ret = -EPERM;
3728 goto exit;
3729 }
3730
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003731 /* Move pointer to ahead of SETCCXMODE<delimiter> */
3732 value = value + 11;
3733 /* Convert the value from ascii to integer */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003734 ret = kstrtou8(value, 10, &eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003735 if (ret < 0)
3736 {
3737 /* If the input value is greater than max value of datatype, then also
3738 kstrtou8 fails */
3739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3740 "%s: kstrtou8 failed range [%d - %d]", __func__,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003741 CFG_ESE_FEATURE_ENABLED_MIN,
3742 CFG_ESE_FEATURE_ENABLED_MAX);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003743 ret = -EINVAL;
3744 goto exit;
3745 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003746 if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) ||
3747 (eseMode > CFG_ESE_FEATURE_ENABLED_MAX))
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003748 {
3749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003750 "Ese mode value %d is out of range"
3751 " (Min: %d Max: %d)", eseMode,
3752 CFG_ESE_FEATURE_ENABLED_MIN,
3753 CFG_ESE_FEATURE_ENABLED_MAX);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003754 ret = -EINVAL;
3755 goto exit;
3756 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003757 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003758 "%s: Received Command to change ese mode = %d", __func__, eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003759
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003760 pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode;
3761 sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003762 }
3763#endif
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003764 else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0)
3765 {
3766 tANI_U8 *value = command;
3767 tANI_BOOLEAN roamScanControl = 0;
3768
3769 /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */
3770 value = value + 19;
3771 /* Convert the value from ascii to integer */
3772 ret = kstrtou8(value, 10, &roamScanControl);
3773 if (ret < 0)
3774 {
3775 /* If the input value is greater than max value of datatype, then also
3776 kstrtou8 fails */
3777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3778 "%s: kstrtou8 failed ", __func__);
3779 ret = -EINVAL;
3780 goto exit;
3781 }
3782
3783 if (0 != roamScanControl)
3784 {
3785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3786 "roam scan control invalid value = %d",
3787 roamScanControl);
3788 ret = -EINVAL;
3789 goto exit;
3790 }
3791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3792 "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl);
3793
3794 sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl);
3795 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003796#ifdef FEATURE_WLAN_OKC
3797 else if (strncmp(command, "SETOKCMODE", 10) == 0)
3798 {
3799 tANI_U8 *value = command;
3800 tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT;
3801
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003802 /* Check if the features OKC/ESE/11R are supported simultaneously,
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003803 then this operation is not permitted (return FAILURE) */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003804 if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) &&
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003805 hdd_is_okc_mode_enabled(pHddCtx) &&
3806 sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)))
3807 {
3808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003809 "%s: OKC/ESE/11R are supported simultaneously"
Srinivas Girigowdac6745a32013-07-15 19:19:10 -07003810 " hence this operation is not permitted!", __func__);
3811 ret = -EPERM;
3812 goto exit;
3813 }
3814
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003815 /* Move pointer to ahead of SETOKCMODE<delimiter> */
3816 value = value + 11;
3817 /* Convert the value from ascii to integer */
3818 ret = kstrtou8(value, 10, &okcMode);
3819 if (ret < 0)
3820 {
3821 /* If the input value is greater than max value of datatype, then also
3822 kstrtou8 fails */
3823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3824 "%s: kstrtou8 failed range [%d - %d]", __func__,
3825 CFG_OKC_FEATURE_ENABLED_MIN,
3826 CFG_OKC_FEATURE_ENABLED_MAX);
3827 ret = -EINVAL;
3828 goto exit;
3829 }
3830
3831 if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) ||
3832 (okcMode > CFG_OKC_FEATURE_ENABLED_MAX))
3833 {
3834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3835 "Okc mode value %d is out of range"
3836 " (Min: %d Max: %d)", okcMode,
3837 CFG_OKC_FEATURE_ENABLED_MIN,
3838 CFG_OKC_FEATURE_ENABLED_MAX);
3839 ret = -EINVAL;
3840 goto exit;
3841 }
3842
3843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3844 "%s: Received Command to change okc mode = %d", __func__, okcMode);
3845
3846 pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode;
3847 }
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07003848#endif /* FEATURE_WLAN_OKC */
Mahesh A Saptasagarec7d1092015-04-02 13:41:34 +05303849 else if (strncmp(command, "GETROAMSCANCONTROL", 18) == 0)
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003850 {
3851 tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal));
3852 char extra[32];
3853 tANI_U8 len = 0;
3854
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003855 len = scnprintf(extra, sizeof(extra), "%s %d",
3856 command, roamScanControl);
Ratnam Rachuri083ada82015-08-07 14:01:05 +05303857 len = VOS_MIN(priv_data.total_len, len + 1);
3858 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07003859 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3860 "%s: failed to copy data to user buffer", __func__);
3861 ret = -EFAULT;
3862 goto exit;
3863 }
3864 }
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05303865#ifdef WLAN_FEATURE_PACKET_FILTERING
3866 else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0)
3867 {
3868 tANI_U8 filterType = 0;
3869 tANI_U8 *value = command;
3870
3871 /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */
3872 value = value + 22;
3873
3874 /* Convert the value from ascii to integer */
3875 ret = kstrtou8(value, 10, &filterType);
3876 if (ret < 0)
3877 {
3878 /* If the input value is greater than max value of datatype,
3879 * then also kstrtou8 fails
3880 */
3881 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3882 "%s: kstrtou8 failed range ", __func__);
3883 ret = -EINVAL;
3884 goto exit;
3885 }
3886
3887 if (filterType != 0 && filterType != 1)
3888 {
3889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3890 "%s: Accepted Values are 0 and 1 ", __func__);
3891 ret = -EINVAL;
3892 goto exit;
3893 }
3894 wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType,
3895 pAdapter->sessionId);
3896 }
3897#endif
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303898 else if (strncmp(command, "BTCOEXMODE", 10) == 0 )
3899 {
Kiet Lamad161252014-07-22 11:23:32 -07003900 char *dhcpPhase;
Satyanarayana Dash1faea4f2014-09-22 16:21:04 +05303901 int ret;
3902
Kiet Lamad161252014-07-22 11:23:32 -07003903 dhcpPhase = command + 11;
3904 if ('1' == *dhcpPhase)
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303905 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05303906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Kiet Lamad161252014-07-22 11:23:32 -07003907 FL("send DHCP START indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303908
3909 pHddCtx->btCoexModeSet = TRUE;
Kiet Lamad161252014-07-22 11:23:32 -07003910
Satyanarayana Dash1faea4f2014-09-22 16:21:04 +05303911 ret = wlan_hdd_scan_abort(pAdapter);
3912 if (ret < 0)
3913 {
3914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3915 FL("failed to abort existing scan %d"), ret);
3916 }
3917
Kiet Lamad161252014-07-22 11:23:32 -07003918 sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode,
3919 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303920 }
Kiet Lamad161252014-07-22 11:23:32 -07003921 else if ('2' == *dhcpPhase)
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303922 {
Deepthi Gowribfd17132014-11-14 17:59:04 +05303923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Kiet Lamad161252014-07-22 11:23:32 -07003924 FL("send DHCP STOP indication"));
c_hpothu9b781ba2013-12-30 20:57:45 +05303925
3926 pHddCtx->btCoexModeSet = FALSE;
Kiet Lamad161252014-07-22 11:23:32 -07003927
3928 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
3929 pAdapter->sessionId);
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05303930 }
3931 }
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003932 else if (strncmp(command, "SCAN-ACTIVE", 11) == 0)
3933 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303934 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3935 FL("making default scan to ACTIVE"));
3936 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003937 }
3938 else if (strncmp(command, "SCAN-PASSIVE", 12) == 0)
3939 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3941 FL("making default scan to PASSIVE"));
3942 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnsonf54df2c2013-07-24 11:43:39 -07003943 }
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303944 else if (strncmp(command, "GETDWELLTIME", 12) == 0)
3945 {
3946 hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3947 char extra[32];
3948 tANI_U8 len = 0;
3949
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05303950 memset(extra, 0, sizeof(extra));
3951 ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len);
Ratnam Rachuri12d5d462015-08-07 14:10:23 +05303952 len = VOS_MIN(priv_data.total_len, len + 1);
3953 if (ret != 0 || copy_to_user(priv_data.buf, &extra, len)) {
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3955 "%s: failed to copy data to user buffer", __func__);
3956 ret = -EFAULT;
3957 goto exit;
3958 }
3959 ret = len;
3960 }
3961 else if (strncmp(command, "SETDWELLTIME", 12) == 0)
3962 {
Rajesh Babu Prathipatic7baf6f2014-05-30 10:08:16 +05303963 ret = hdd_set_dwell_time(pAdapter, command);
Hanumantha Reddy Pothula212243c2013-08-01 17:28:31 +05303964 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003965 else if ( strncasecmp(command, "MIRACAST", 8) == 0 )
3966 {
3967 tANI_U8 filterType = 0;
3968 tANI_U8 *value;
3969 value = command + 9;
3970
3971 /* Convert the value from ascii to integer */
3972 ret = kstrtou8(value, 10, &filterType);
3973 if (ret < 0)
3974 {
3975 /* If the input value is greater than max value of datatype,
3976 * then also kstrtou8 fails
3977 */
3978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3979 "%s: kstrtou8 failed range ", __func__);
3980 ret = -EINVAL;
3981 goto exit;
3982 }
3983 if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) ||
3984 (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL))
3985 {
3986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3987 "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source,"
3988 " 2-Sink ", __func__);
3989 ret = -EINVAL;
3990 goto exit;
3991 }
3992 //Filtertype value should be either 0-Disabled, 1-Source, 2-sink
3993 pHddCtx->drvr_miracast = filterType;
Kaushik, Sushant96122442014-10-21 16:40:18 +05303994 pScanInfo = &pHddCtx->scan_info;
3995 if (filterType && pScanInfo != NULL &&
3996 pHddCtx->scan_info.mScanPending)
3997 {
3998 /*Miracast Session started. Abort Scan */
3999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4000 "%s, Aborting Scan For Miracast",__func__);
4001 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
4002 eCSR_SCAN_ABORT_DEFAULT);
4003 }
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07004004 hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx);
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05304005 sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07004006 }
Leo Chang614d2072013-08-22 14:59:44 -07004007 else if (strncmp(command, "SETMCRATE", 9) == 0)
4008 {
Leo Chang614d2072013-08-22 14:59:44 -07004009 tANI_U8 *value = command;
4010 int targetRate;
Leo Chang1f98cbd2013-10-17 15:03:52 -07004011 tSirRateUpdateInd *rateUpdate;
4012 eHalStatus status;
Leo Chang614d2072013-08-22 14:59:44 -07004013
4014 /* Only valid for SAP mode */
4015 if (WLAN_HDD_SOFTAP != pAdapter->device_mode)
4016 {
4017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4018 "%s: SAP mode is not running", __func__);
4019 ret = -EFAULT;
4020 goto exit;
4021 }
4022
4023 /* Move pointer to ahead of SETMCRATE<delimiter> */
4024 /* input value is in units of hundred kbps */
4025 value = value + 10;
4026 /* Convert the value from ascii to integer, decimal base */
4027 ret = kstrtouint(value, 10, &targetRate);
4028
Leo Chang1f98cbd2013-10-17 15:03:52 -07004029 rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd));
4030 if (NULL == rateUpdate)
Leo Chang614d2072013-08-22 14:59:44 -07004031 {
Leo Chang1f98cbd2013-10-17 15:03:52 -07004032 hddLog(VOS_TRACE_LEVEL_ERROR,
4033 "%s: SETMCRATE indication alloc fail", __func__);
4034 ret = -EFAULT;
4035 goto exit;
4036 }
4037 vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd ));
4038
4039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4040 "MC Target rate %d", targetRate);
4041 /* Ignore unicast */
4042 rateUpdate->ucastDataRate = -1;
4043 rateUpdate->mcastDataRate24GHz = targetRate;
4044 rateUpdate->mcastDataRate5GHz = targetRate;
4045 rateUpdate->mcastDataRate24GHzTxFlag = 0;
4046 rateUpdate->mcastDataRate5GHzTxFlag = 0;
4047 status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate);
4048 if (eHAL_STATUS_SUCCESS != status)
4049 {
4050 hddLog(VOS_TRACE_LEVEL_ERROR,
4051 "%s: SET_MC_RATE failed", __func__);
4052 vos_mem_free(rateUpdate);
4053 ret = -EFAULT;
4054 goto exit;
Leo Chang614d2072013-08-22 14:59:44 -07004055 }
4056 }
Rajeev79dbe4c2013-10-05 11:03:42 +05304057#ifdef FEATURE_WLAN_BATCH_SCAN
Rajeev Kumar8b373292014-01-08 20:36:55 -08004058 else if (strncmp(command, "WLS_BATCHING", 12) == 0)
Rajeev79dbe4c2013-10-05 11:03:42 +05304059 {
Rajeev Kumar8b373292014-01-08 20:36:55 -08004060 ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command);
Rajeev79dbe4c2013-10-05 11:03:42 +05304061 }
4062#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004063#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004064 else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0)
4065 {
4066 tANI_U8 *value = command;
4067 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4068 tANI_U8 numChannels = 0;
4069 eHalStatus status = eHAL_STATUS_SUCCESS;
4070
4071 status = hdd_parse_channellist(value, ChannelList, &numChannels);
4072 if (eHAL_STATUS_SUCCESS != status)
4073 {
4074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4075 "%s: Failed to parse channel list information", __func__);
4076 ret = -EINVAL;
4077 goto exit;
4078 }
4079
4080 if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
4081 {
4082 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4083 "%s: number of channels (%d) supported exceeded max (%d)", __func__,
4084 numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
4085 ret = -EINVAL;
4086 goto exit;
4087 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004088 status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004089 ChannelList,
4090 numChannels);
4091 if (eHAL_STATUS_SUCCESS != status)
4092 {
4093 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4094 "%s: Failed to update channel list information", __func__);
4095 ret = -EINVAL;
4096 goto exit;
4097 }
4098 }
4099 else if (strncmp(command, "GETTSMSTATS", 11) == 0)
4100 {
4101 tANI_U8 *value = command;
4102 char extra[128] = {0};
4103 int len = 0;
4104 tANI_U8 tid = 0;
4105 hdd_station_ctx_t *pHddStaCtx = NULL;
4106 tAniTrafStrmMetrics tsmMetrics;
4107 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4108
4109 /* if not associated, return error */
4110 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4111 {
4112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__);
4113 ret = -EINVAL;
4114 goto exit;
4115 }
4116
4117 /* Move pointer to ahead of GETTSMSTATS<delimiter> */
4118 value = value + 12;
4119 /* Convert the value from ascii to integer */
4120 ret = kstrtou8(value, 10, &tid);
4121 if (ret < 0)
4122 {
4123 /* If the input value is greater than max value of datatype, then also
4124 kstrtou8 fails */
4125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4126 "%s: kstrtou8 failed range [%d - %d]", __func__,
4127 TID_MIN_VALUE,
4128 TID_MAX_VALUE);
4129 ret = -EINVAL;
4130 goto exit;
4131 }
4132
4133 if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE))
4134 {
4135 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4136 "tid value %d is out of range"
4137 " (Min: %d Max: %d)", tid,
4138 TID_MIN_VALUE,
4139 TID_MAX_VALUE);
4140 ret = -EINVAL;
4141 goto exit;
4142 }
4143
4144 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4145 "%s: Received Command to get tsm stats tid = %d", __func__, tid);
4146
4147 if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics))
4148 {
4149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4150 "%s: failed to get tsm stats", __func__);
4151 ret = -EFAULT;
4152 goto exit;
4153 }
4154
4155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4156 "UplinkPktQueueDly(%d)\n"
4157 "UplinkPktQueueDlyHist[0](%d)\n"
4158 "UplinkPktQueueDlyHist[1](%d)\n"
4159 "UplinkPktQueueDlyHist[2](%d)\n"
4160 "UplinkPktQueueDlyHist[3](%d)\n"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304161 "UplinkPktTxDly(%u)\n"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004162 "UplinkPktLoss(%d)\n"
4163 "UplinkPktCount(%d)\n"
4164 "RoamingCount(%d)\n"
4165 "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly,
4166 tsmMetrics.UplinkPktQueueDlyHist[0],
4167 tsmMetrics.UplinkPktQueueDlyHist[1],
4168 tsmMetrics.UplinkPktQueueDlyHist[2],
4169 tsmMetrics.UplinkPktQueueDlyHist[3],
4170 tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss,
4171 tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly);
4172
4173 /* Output TSM stats is of the format
4174 GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly]
4175 eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004176 len = scnprintf(extra, sizeof(extra), "%s %d %d:%d:%d:%d %u %d %d %d %d", command,
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004177 tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0],
4178 tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2],
4179 tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly,
4180 tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount,
4181 tsmMetrics.RoamingDly);
4182
Ratnam Rachurid53009c2015-08-07 13:59:00 +05304183 len = VOS_MIN(priv_data.total_len, len + 1);
4184 if (copy_to_user(priv_data.buf, &extra, len)) {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4186 "%s: failed to copy data to user buffer", __func__);
4187 ret = -EFAULT;
4188 goto exit;
4189 }
4190 }
4191 else if (strncmp(command, "SETCCKMIE", 9) == 0)
4192 {
4193 tANI_U8 *value = command;
4194 tANI_U8 *cckmIe = NULL;
4195 tANI_U8 cckmIeLen = 0;
4196 eHalStatus status = eHAL_STATUS_SUCCESS;
4197
4198 status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen);
4199 if (eHAL_STATUS_SUCCESS != status)
4200 {
4201 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4202 "%s: Failed to parse cckm ie data", __func__);
4203 ret = -EINVAL;
4204 goto exit;
4205 }
4206
4207 if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN)
4208 {
4209 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4210 "%s: CCKM Ie input length is more than max[%d]", __func__,
4211 DOT11F_IE_RSN_MAX_LEN);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08004212 vos_mem_free(cckmIe);
4213 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004214 ret = -EINVAL;
4215 goto exit;
4216 }
4217 sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08004218 vos_mem_free(cckmIe);
4219 cckmIe = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004220 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004221 else if (strncmp(command, "CCXBEACONREQ", 12) == 0)
4222 {
4223 tANI_U8 *value = command;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004224 tCsrEseBeaconReq eseBcnReq;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004225 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004226
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004227 status = hdd_parse_ese_beacon_req(value, &eseBcnReq);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004228 if (eHAL_STATUS_SUCCESS != status)
4229 {
4230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004231 "%s: Failed to parse ese beacon req", __func__);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004232 ret = -EINVAL;
4233 goto exit;
4234 }
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004235 if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
4236 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated"));
4237 hdd_indicateEseBcnReportNoResults (pAdapter,
4238 eseBcnReq.bcnReq[0].measurementToken,
4239 0x02, //BIT(1) set for measurement done
4240 0); // no BSS
4241 goto exit;
4242 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004243
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004244 status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq);
4245 if (eHAL_STATUS_SUCCESS != status)
4246 {
4247 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4248 "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status);
4249 ret = -EINVAL;
4250 goto exit;
4251 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004252 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004253#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
c_hpothu92367912014-05-01 15:18:17 +05304254 else if (strncmp(command, "GETBCNMISSRATE", 14) == 0)
4255 {
4256 eHalStatus status;
4257 char buf[32], len;
4258 long waitRet;
4259 bcnMissRateContext_t getBcnMissRateCtx;
4260
4261 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4262
4263 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
4264 {
4265 hddLog(VOS_TRACE_LEVEL_WARN,
4266 FL("GETBCNMISSRATE: STA is not in connected state"));
4267 ret = -1;
4268 goto exit;
4269 }
4270
4271 init_completion(&(getBcnMissRateCtx.completion));
4272 getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC;
4273
4274 status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal),
4275 pAdapter->sessionId,
4276 (void *)getBcnMissRateCB,
4277 (void *)(&getBcnMissRateCtx));
4278 if( eHAL_STATUS_SUCCESS != status)
4279 {
4280 hddLog(VOS_TRACE_LEVEL_INFO,
4281 FL("GETBCNMISSRATE: fail to post WDA cmd"));
4282 ret = -EINVAL;
4283 goto exit;
4284 }
4285
4286 waitRet = wait_for_completion_interruptible_timeout
4287 (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME);
4288 if(waitRet <= 0)
4289 {
4290 hddLog(VOS_TRACE_LEVEL_ERROR,
4291 FL("failed to wait on bcnMissRateComp %d"), ret);
4292
4293 //Make magic number to zero so that callback is not called.
4294 spin_lock(&hdd_context_lock);
4295 getBcnMissRateCtx.magic = 0x0;
4296 spin_unlock(&hdd_context_lock);
4297 ret = -EINVAL;
4298 goto exit;
4299 }
4300
4301 hddLog(VOS_TRACE_LEVEL_INFO,
4302 FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate);
4303
4304 len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate);
4305 if (copy_to_user(priv_data.buf, &buf, len + 1))
4306 {
4307 hddLog(VOS_TRACE_LEVEL_ERROR,
4308 "%s: failed to copy data to user buffer", __func__);
4309 ret = -EFAULT;
4310 goto exit;
4311 }
4312 ret = len;
4313 }
Atul Mittal87ec2422014-09-24 13:12:50 +05304314#ifdef FEATURE_WLAN_TDLS
4315 else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) {
4316 tANI_U8 *value = command;
4317 int set_value;
4318 /* Move pointer to ahead of TDLSOFFCH*/
4319 value += 26;
4320 sscanf(value, "%d", &set_value);
4321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4322 "%s: Tdls offchannel offset:%d",
4323 __func__, set_value);
4324 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4325 if (ret < 0)
4326 {
4327 ret = -EINVAL;
4328 goto exit;
4329 }
4330
4331 } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) {
4332 tANI_U8 *value = command;
4333 int set_value;
4334 /* Move pointer to ahead of tdlsoffchnmode*/
4335 value += 18;
4336 sscanf(value, "%d", &set_value);
4337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4338 "%s: Tdls offchannel mode:%d",
4339 __func__, set_value);
4340 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4341 if (ret < 0)
4342 {
4343 ret = -EINVAL;
4344 goto exit;
4345 }
4346 } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) {
4347 tANI_U8 *value = command;
4348 int set_value;
4349 /* Move pointer to ahead of TDLSOFFCH*/
4350 value += 14;
4351 sscanf(value, "%d", &set_value);
4352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4353 "%s: Tdls offchannel num: %d",
4354 __func__, set_value);
4355 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4356 if (ret < 0)
4357 {
4358 ret = -EINVAL;
4359 goto exit;
4360 }
4361 }
4362#endif
Satyanarayana Dash72806012014-12-02 14:30:08 +05304363 else if (strncmp(command, "GETFWSTATS", 10) == 0)
4364 {
4365 eHalStatus status;
4366 char *buf = NULL;
4367 char len;
4368 long waitRet;
4369 fwStatsContext_t fwStatsCtx;
Abhishek Singh08aa7762014-12-16 13:59:03 +05304370 tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp);
Satyanarayana Dash72806012014-12-02 14:30:08 +05304371 tANI_U8 *ptr = command;
4372 int stats = *(ptr + 11) - '0';
4373
4374 hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats);
4375 if (!IS_FEATURE_FW_STATS_ENABLE)
4376 {
4377 hddLog(VOS_TRACE_LEVEL_INFO,
4378 FL("Get Firmware stats feature not supported"));
4379 ret = -EINVAL;
4380 goto exit;
4381 }
4382
4383 if (FW_STATS_MAX <= stats || 0 >= stats)
4384 {
4385 hddLog(VOS_TRACE_LEVEL_INFO,
4386 FL(" stats %d not supported"),stats);
4387 ret = -EINVAL;
4388 goto exit;
4389 }
4390
4391 init_completion(&(fwStatsCtx.completion));
4392 fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC;
4393 fwStatsCtx.pAdapter = pAdapter;
4394 fwStatsRsp->type = 0;
4395 status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats,
Abhishek Singh08aa7762014-12-16 13:59:03 +05304396 &fwStatsCtx, hdd_FWStatisCB);
Satyanarayana Dash72806012014-12-02 14:30:08 +05304397 if (eHAL_STATUS_SUCCESS != status)
4398 {
4399 hddLog(VOS_TRACE_LEVEL_ERROR,
4400 FL(" fail to post WDA cmd status = %d"), status);
4401 ret = -EINVAL;
4402 goto exit;
4403 }
4404 waitRet = wait_for_completion_timeout
4405 (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME);
4406 if (waitRet <= 0)
4407 {
4408 hddLog(VOS_TRACE_LEVEL_ERROR,
4409 FL("failed to wait on GwtFwstats"));
4410 //Make magic number to zero so that callback is not executed.
4411 spin_lock(&hdd_context_lock);
4412 fwStatsCtx.magic = 0x0;
4413 spin_unlock(&hdd_context_lock);
4414 ret = -EINVAL;
4415 goto exit;
4416 }
4417 if (fwStatsRsp->type)
4418 {
4419 buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL);
4420 if (!buf)
4421 {
4422 hddLog(VOS_TRACE_LEVEL_ERROR,
4423 FL(" failed to allocate memory"));
4424 ret = -ENOMEM;
4425 goto exit;
4426 }
4427 switch( fwStatsRsp->type )
4428 {
4429 case FW_UBSP_STATS:
4430 {
4431 len = snprintf(buf, FW_STATE_RSP_LEN,
4432 "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d",
Abhishek Singh08aa7762014-12-16 13:59:03 +05304433 fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt,
4434 fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt);
Satyanarayana Dash72806012014-12-02 14:30:08 +05304435 }
4436 break;
4437 default:
4438 {
4439 hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type);
4440 ret = -EFAULT;
4441 kfree(buf);
4442 goto exit;
4443 }
4444 }
4445 if (copy_to_user(priv_data.buf, buf, len + 1))
4446 {
4447 hddLog(VOS_TRACE_LEVEL_ERROR,
4448 FL(" failed to copy data to user buffer"));
4449 ret = -EFAULT;
4450 kfree(buf);
4451 goto exit;
4452 }
4453 ret = len;
4454 kfree(buf);
4455 }
4456 else
4457 {
4458 hddLog(VOS_TRACE_LEVEL_ERROR,
4459 FL("failed to fetch the stats"));
4460 ret = -EFAULT;
4461 goto exit;
4462 }
4463
4464 }
Agarwal Ashish8bd53ae2015-06-12 18:03:45 +05304465 else if (strncasecmp(command, "SET_FCC_CHANNEL", 15) == 0)
4466 {
4467 /*
4468 * this command wld be called by user-space when it detects WLAN
4469 * ON after airplane mode is set. When APM is set, WLAN turns off.
4470 * But it can be turned back on. Otherwise; when APM is turned back
4471 * off, WLAN wld turn back on. So at that point the command is
4472 * expected to come down. 0 means disable, 1 means enable. The
4473 * constraint is removed when parameter 1 is set or different
4474 * country code is set
4475 */
4476 ret = hdd_cmd_setFccChannel(pHddCtx, command, 15);
4477 }
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004478 else {
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304479 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4480 TRACE_CODE_HDD_UNSUPPORTED_IOCTL,
4481 pAdapter->sessionId, 0));
Satyanarayana Dash72806012014-12-02 14:30:08 +05304482 hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"),
4483 command);
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 }
4486exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304487 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 if (command)
4489 {
4490 kfree(command);
4491 }
4492 return ret;
4493}
4494
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004495#ifdef CONFIG_COMPAT
4496static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4497{
4498 struct {
4499 compat_uptr_t buf;
4500 int used_len;
4501 int total_len;
4502 } compat_priv_data;
4503 hdd_priv_data_t priv_data;
4504 int ret = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004505
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004506 /*
4507 * Note that pAdapter and ifr have already been verified by caller,
4508 * and HDD context has also been validated
4509 */
4510 if (copy_from_user(&compat_priv_data, ifr->ifr_data,
4511 sizeof(compat_priv_data))) {
4512 ret = -EFAULT;
4513 goto exit;
4514 }
4515 priv_data.buf = compat_ptr(compat_priv_data.buf);
4516 priv_data.used_len = compat_priv_data.used_len;
4517 priv_data.total_len = compat_priv_data.total_len;
4518 ret = hdd_driver_command(pAdapter, &priv_data);
4519 exit:
4520 return ret;
4521}
4522#else /* CONFIG_COMPAT */
4523static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4524{
4525 /* will never be invoked */
4526 return 0;
4527}
4528#endif /* CONFIG_COMPAT */
4529
4530static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr)
4531{
4532 hdd_priv_data_t priv_data;
4533 int ret = 0;
4534
4535 /*
4536 * Note that pAdapter and ifr have already been verified by caller,
4537 * and HDD context has also been validated
4538 */
4539 if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) {
4540 ret = -EFAULT;
4541 } else {
4542 ret = hdd_driver_command(pAdapter, &priv_data);
4543 }
4544 return ret;
4545}
4546
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05304547int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004548{
4549 hdd_adapter_t *pAdapter;
4550 hdd_context_t *pHddCtx;
4551 int ret;
4552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304553 ENTER();
4554
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004555 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4556 if (NULL == pAdapter) {
4557 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4558 "%s: HDD adapter context is Null", __func__);
4559 ret = -ENODEV;
4560 goto exit;
4561 }
4562 if (dev != pAdapter->dev) {
4563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4564 "%s: HDD adapter/dev inconsistency", __func__);
4565 ret = -ENODEV;
4566 goto exit;
4567 }
4568
4569 if ((!ifr) || (!ifr->ifr_data)) {
4570 ret = -EINVAL;
4571 goto exit;
4572 }
4573
4574 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4575 ret = wlan_hdd_validate_context(pHddCtx);
4576 if (ret) {
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004577 ret = -EBUSY;
4578 goto exit;
4579 }
4580
4581 switch (cmd) {
4582 case (SIOCDEVPRIVATE + 1):
4583 if (is_compat_task())
4584 ret = hdd_driver_compat_ioctl(pAdapter, ifr);
4585 else
4586 ret = hdd_driver_ioctl(pAdapter, ifr);
4587 break;
4588 default:
4589 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d",
4590 __func__, cmd);
4591 ret = -EINVAL;
4592 break;
4593 }
4594 exit:
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304595 EXIT();
Jeff Johnsond6e7b3f2014-03-20 12:12:11 -07004596 return ret;
4597}
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004598
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05304599int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4600{
4601 int ret;
4602
4603 vos_ssr_protect(__func__);
4604 ret = __hdd_ioctl(dev, ifr, cmd);
4605 vos_ssr_unprotect(__func__);
4606
4607 return ret;
4608}
4609
Katya Nigame7b69a82015-04-28 15:24:06 +05304610int hdd_mon_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4611{
4612 return 0;
4613}
4614
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004615#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004616/**---------------------------------------------------------------------------
4617
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004618 \brief hdd_parse_ese_beacon_req() - Parse ese beacon request
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004619
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004620 This function parses the ese beacon request passed in the format
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004621 CCXBEACONREQ<space><Number of fields><space><Measurement token>
4622 <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N
4623 <space>Scan Mode N<space>Meas Duration N
4624 if the Number of bcn req fields (N) does not match with the actual number of fields passed
4625 then take N.
4626 <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair
4627 For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40.
4628 This function does not take care of removing duplicate channels from the list
4629
4630 \param - pValue Pointer to data
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004631 \param - pEseBcnReq output pointer to store parsed ie information
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004632
4633 \return - 0 for success non-zero for failure
4634
4635 --------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004636static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue,
4637 tCsrEseBeaconReq *pEseBcnReq)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004638{
4639 tANI_U8 *inPtr = pValue;
4640 int tempInt = 0;
4641 int j = 0, i = 0, v = 0;
4642 char buf[32];
4643
4644 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4645 /*no argument after the command*/
4646 if (NULL == inPtr)
4647 {
4648 return -EINVAL;
4649 }
4650 /*no space after the command*/
4651 else if (SPACE_ASCII_VALUE != *inPtr)
4652 {
4653 return -EINVAL;
4654 }
4655
4656 /*removing empty spaces*/
4657 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
4658
4659 /*no argument followed by spaces*/
4660 if ('\0' == *inPtr) return -EINVAL;
4661
4662 /*getting the first argument ie measurement token*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004663 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004664 if (1 != v) return -EINVAL;
4665
4666 v = kstrtos32(buf, 10, &tempInt);
4667 if ( v < 0) return -EINVAL;
4668
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004669 pEseBcnReq->numBcnReqIe = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004670
4671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004672 "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004673
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004674 for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004675 {
4676 for (i = 0; i < 4; i++)
4677 {
4678 /*inPtr pointing to the beginning of first space after number of ie fields*/
4679 inPtr = strpbrk( inPtr, " " );
4680 /*no ie data after the number of ie fields argument*/
4681 if (NULL == inPtr) return -EINVAL;
4682
4683 /*removing empty space*/
4684 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
4685
4686 /*no ie data after the number of ie fields argument and spaces*/
4687 if ( '\0' == *inPtr ) return -EINVAL;
4688
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004689 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004690 if (1 != v) return -EINVAL;
4691
4692 v = kstrtos32(buf, 10, &tempInt);
4693 if (v < 0) return -EINVAL;
4694
4695 switch (i)
4696 {
4697 case 0: /* Measurement token */
4698 if (tempInt <= 0)
4699 {
4700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4701 "Invalid Measurement Token(%d)", tempInt);
4702 return -EINVAL;
4703 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004704 pEseBcnReq->bcnReq[j].measurementToken = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004705 break;
4706
4707 case 1: /* Channel number */
4708 if ((tempInt <= 0) ||
4709 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
4710 {
4711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4712 "Invalid Channel Number(%d)", tempInt);
4713 return -EINVAL;
4714 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004715 pEseBcnReq->bcnReq[j].channel = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004716 break;
4717
4718 case 2: /* Scan mode */
Varun Reddy Yeturu0b18d5a2013-12-04 11:42:23 -08004719 if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004720 {
4721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4722 "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt);
4723 return -EINVAL;
4724 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004725 pEseBcnReq->bcnReq[j].scanMode= tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004726 break;
4727
4728 case 3: /* Measurement duration */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004729 if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) ||
4730 ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE)))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004731 {
4732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4733 "Invalid Measurement Duration(%d)", tempInt);
4734 return -EINVAL;
4735 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004736 pEseBcnReq->bcnReq[j].measurementDuration = tempInt;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004737 break;
4738 }
4739 }
4740 }
4741
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004742 for (j = 0; j < pEseBcnReq->numBcnReqIe; j++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004743 {
4744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304745 "Index(%d) Measurement Token(%u)Channel(%u) Scan Mode(%u) Measurement Duration(%u)\n",
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004746 j,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004747 pEseBcnReq->bcnReq[j].measurementToken,
4748 pEseBcnReq->bcnReq[j].channel,
4749 pEseBcnReq->bcnReq[j].scanMode,
4750 pEseBcnReq->bcnReq[j].measurementDuration);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004751 }
4752
4753 return VOS_STATUS_SUCCESS;
4754}
4755
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004756static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext )
4757{
4758 struct statsContext *pStatsContext = NULL;
4759 hdd_adapter_t *pAdapter = NULL;
4760
4761 if (NULL == pContext)
4762 {
4763 hddLog(VOS_TRACE_LEVEL_ERROR,
4764 "%s: Bad param, pContext [%p]",
4765 __func__, pContext);
4766 return;
4767 }
4768
Jeff Johnson72a40512013-12-19 10:14:15 -08004769 /* there is a race condition that exists between this callback
4770 function and the caller since the caller could time out either
4771 before or while this code is executing. we use a spinlock to
4772 serialize these actions */
4773 spin_lock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004774
4775 pStatsContext = pContext;
4776 pAdapter = pStatsContext->pAdapter;
4777 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
4778 {
4779 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08004780 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004781 hddLog(VOS_TRACE_LEVEL_WARN,
4782 "%s: Invalid context, pAdapter [%p] magic [%08x]",
4783 __func__, pAdapter, pStatsContext->magic);
4784 return;
4785 }
4786
Jeff Johnson72a40512013-12-19 10:14:15 -08004787 /* context is valid so caller is still waiting */
4788
4789 /* paranoia: invalidate the magic */
4790 pStatsContext->magic = 0;
4791
4792 /* copy over the tsm stats */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004793 pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly;
4794 vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist,
4795 tsmMetrics.UplinkPktQueueDlyHist,
4796 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4797 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4798 pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly;
4799 pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss;
4800 pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount;
4801 pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount;
4802 pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly;
4803
Jeff Johnson72a40512013-12-19 10:14:15 -08004804 /* notify the caller */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004805 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08004806
4807 /* serialization is complete */
4808 spin_unlock(&hdd_context_lock);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004809}
4810
4811
4812
4813static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid,
4814 tAniTrafStrmMetrics* pTsmMetrics)
4815{
4816 hdd_station_ctx_t *pHddStaCtx = NULL;
4817 eHalStatus hstatus;
Jeff Johnson72a40512013-12-19 10:14:15 -08004818 VOS_STATUS vstatus = VOS_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004819 long lrc;
4820 struct statsContext context;
4821 hdd_context_t *pHddCtx = NULL;
4822
4823 if (NULL == pAdapter)
4824 {
4825 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__);
4826 return VOS_STATUS_E_FAULT;
4827 }
4828
4829 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4830 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4831
4832 /* we are connected prepare our callback context */
4833 init_completion(&context.completion);
4834 context.pAdapter = pAdapter;
4835 context.magic = STATS_CONTEXT_MAGIC;
4836
4837 /* query tsm stats */
4838 hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB,
4839 pHddStaCtx->conn_info.staId[ 0 ],
4840 pHddStaCtx->conn_info.bssId,
4841 &context, pHddCtx->pvosContext, tid);
4842
4843 if (eHAL_STATUS_SUCCESS != hstatus)
4844 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004845 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics",
4846 __func__);
4847 vstatus = VOS_STATUS_E_FAULT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004848 }
4849 else
4850 {
4851 /* request was sent -- wait for the response */
4852 lrc = wait_for_completion_interruptible_timeout(&context.completion,
4853 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004854 if (lrc <= 0)
4855 {
4856 hddLog(VOS_TRACE_LEVEL_ERROR,
4857 "%s: SME %s while retrieving statistics",
4858 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson72a40512013-12-19 10:14:15 -08004859 vstatus = VOS_STATUS_E_TIMEOUT;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004860 }
4861 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004862
Jeff Johnson72a40512013-12-19 10:14:15 -08004863 /* either we never sent a request, we sent a request and received a
4864 response or we sent a request and timed out. if we never sent a
4865 request or if we sent a request and got a response, we want to
4866 clear the magic out of paranoia. if we timed out there is a
4867 race condition such that the callback function could be
4868 executing at the same time we are. of primary concern is if the
4869 callback function had already verified the "magic" but had not
4870 yet set the completion variable when a timeout occurred. we
4871 serialize these activities by invalidating the magic while
4872 holding a shared spinlock which will cause us to block if the
4873 callback is currently executing */
4874 spin_lock(&hdd_context_lock);
4875 context.magic = 0;
4876 spin_unlock(&hdd_context_lock);
4877
4878 if (VOS_STATUS_SUCCESS == vstatus)
4879 {
4880 pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly;
4881 vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist,
4882 pAdapter->tsmStats.UplinkPktQueueDlyHist,
4883 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
4884 sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
4885 pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly;
4886 pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss;
4887 pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount;
4888 pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount;
4889 pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly;
4890 }
4891 return vstatus;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004892}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004893#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004894
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004895#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08004896void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand)
4897{
4898 eCsrBand band = -1;
4899 sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band);
4900 switch (band)
4901 {
4902 case eCSR_BAND_ALL:
4903 *pBand = WLAN_HDD_UI_BAND_AUTO;
4904 break;
4905
4906 case eCSR_BAND_24:
4907 *pBand = WLAN_HDD_UI_BAND_2_4_GHZ;
4908 break;
4909
4910 case eCSR_BAND_5G:
4911 *pBand = WLAN_HDD_UI_BAND_5_GHZ;
4912 break;
4913
4914 default:
4915 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band);
4916 *pBand = -1;
4917 break;
4918 }
4919}
4920
4921/**---------------------------------------------------------------------------
4922
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004923 \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data
4924
4925 This function parses the send action frame data passed in the format
4926 SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data>
4927
Srinivas Girigowda56076852013-08-20 14:00:50 -07004928 \param - pValue Pointer to input data
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004929 \param - pTargetApBssid Pointer to target Ap bssid
4930 \param - pChannel Pointer to the Target AP channel
4931 \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame
4932 \param - pBuf Pointer to data
4933 \param - pBufLen Pointer to data length
4934
4935 \return - 0 for success non-zero for failure
4936
4937 --------------------------------------------------------------------------*/
4938VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel,
4939 tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen)
4940{
4941 tANI_U8 *inPtr = pValue;
4942 tANI_U8 *dataEnd;
4943 int tempInt;
4944 int j = 0;
4945 int i = 0;
4946 int v = 0;
4947 tANI_U8 tempBuf[32];
4948 tANI_U8 tempByte = 0;
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08004949 /* 12 hexa decimal digits, 5 ':' and '\0' */
4950 tANI_U8 macAddress[18];
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004951
4952 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
4953 /*no argument after the command*/
4954 if (NULL == inPtr)
4955 {
4956 return -EINVAL;
4957 }
4958
4959 /*no space after the command*/
4960 else if (SPACE_ASCII_VALUE != *inPtr)
4961 {
4962 return -EINVAL;
4963 }
4964
4965 /*removing empty spaces*/
4966 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4967
4968 /*no argument followed by spaces*/
4969 if ('\0' == *inPtr)
4970 {
4971 return -EINVAL;
4972 }
4973
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004974 v = sscanf(inPtr, "%17s", macAddress);
4975 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004976 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4978 "Invalid MAC address or All hex inputs are not read (%d)", v);
4979 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004980 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07004981
4982 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
4983 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
4984 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
4985 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
4986 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
4987 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07004988
4989 /* point to the next argument */
4990 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
4991 /*no argument after the command*/
4992 if (NULL == inPtr) return -EINVAL;
4993
4994 /*removing empty spaces*/
4995 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
4996
4997 /*no argument followed by spaces*/
4998 if ('\0' == *inPtr)
4999 {
5000 return -EINVAL;
5001 }
5002
5003 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005004 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005005 if (1 != v) return -EINVAL;
5006
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005007 v = kstrtos32(tempBuf, 10, &tempInt);
Agarwal Ashish353b3a82014-04-08 14:55:11 +05305008 if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX )
Kiet Lambe150c22013-11-21 16:30:32 +05305009 return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005010
5011 *pChannel = tempInt;
5012
5013 /* point to the next argument */
5014 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
5015 /*no argument after the command*/
5016 if (NULL == inPtr) return -EINVAL;
5017 /*removing empty spaces*/
5018 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5019
5020 /*no argument followed by spaces*/
5021 if ('\0' == *inPtr)
5022 {
5023 return -EINVAL;
5024 }
5025
5026 /*getting the next argument ie the dwell time */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005027 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005028 if (1 != v) return -EINVAL;
5029
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005030 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda5a6e0672014-01-09 14:42:57 -08005031 if ( v < 0 || tempInt < 0) return -EINVAL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005032
5033 *pDwellTime = tempInt;
5034
5035 /* point to the next argument */
5036 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
5037 /*no argument after the command*/
5038 if (NULL == inPtr) return -EINVAL;
5039 /*removing empty spaces*/
5040 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5041
5042 /*no argument followed by spaces*/
5043 if ('\0' == *inPtr)
5044 {
5045 return -EINVAL;
5046 }
5047
5048 /* find the length of data */
5049 dataEnd = inPtr;
5050 while(('\0' != *dataEnd) )
5051 {
5052 dataEnd++;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005053 }
Kiet Lambe150c22013-11-21 16:30:32 +05305054 *pBufLen = dataEnd - inPtr ;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005055 if ( *pBufLen <= 0) return -EINVAL;
5056
Srinivas Girigowdab5ae85d2013-06-03 10:51:45 -07005057 /* Allocate the number of bytes based on the number of input characters
5058 whether it is even or odd.
5059 if the number of input characters are even, then we need N/2 byte.
5060 if the number of input characters are odd, then we need do (N+1)/2 to
5061 compensate rounding off.
5062 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
5063 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
5064 *pBuf = vos_mem_malloc((*pBufLen + 1)/2);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005065 if (NULL == *pBuf)
5066 {
5067 hddLog(VOS_TRACE_LEVEL_FATAL,
5068 "%s: vos_mem_alloc failed ", __func__);
5069 return -EINVAL;
5070 }
5071
5072 /* the buffer received from the upper layer is character buffer,
5073 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
5074 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
5075 and f0 in 3rd location */
5076 for (i = 0, j = 0; j < *pBufLen; j += 2)
5077 {
Kiet Lambe150c22013-11-21 16:30:32 +05305078 if( j+1 == *pBufLen)
5079 {
5080 tempByte = hdd_parse_hex(inPtr[j]);
5081 }
5082 else
5083 {
5084 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
5085 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005086 (*pBuf)[i++] = tempByte;
5087 }
5088 *pBufLen = i;
5089 return VOS_STATUS_SUCCESS;
5090}
5091
Srinivas Girigowda100eb322013-03-15 16:48:20 -07005092/**---------------------------------------------------------------------------
5093
Srinivas Girigowdade697412013-02-14 16:31:48 -08005094 \brief hdd_parse_channellist() - HDD Parse channel list
5095
5096 This function parses the channel list passed in the format
5097 SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07005098 if the Number of channels (N) does not match with the actual number of channels passed
5099 then take the minimum of N and count of (Ch1, Ch2, ...Ch M)
5100 For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken.
5101 If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48.
5102 This function does not take care of removing duplicate channels from the list
Srinivas Girigowdade697412013-02-14 16:31:48 -08005103
5104 \param - pValue Pointer to input channel list
5105 \param - ChannelList Pointer to local output array to record channel list
5106 \param - pNumChannels Pointer to number of roam scan channels
5107
5108 \return - 0 for success non-zero for failure
5109
5110 --------------------------------------------------------------------------*/
5111VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels)
5112{
5113 tANI_U8 *inPtr = pValue;
5114 int tempInt;
5115 int j = 0;
5116 int v = 0;
5117 char buf[32];
5118
5119 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
5120 /*no argument after the command*/
5121 if (NULL == inPtr)
5122 {
5123 return -EINVAL;
5124 }
5125
5126 /*no space after the command*/
5127 else if (SPACE_ASCII_VALUE != *inPtr)
5128 {
5129 return -EINVAL;
5130 }
5131
5132 /*removing empty spaces*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005133 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08005134
5135 /*no argument followed by spaces*/
5136 if ('\0' == *inPtr)
5137 {
5138 return -EINVAL;
5139 }
5140
5141 /*getting the first argument ie the number of channels*/
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005142 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005143 if (1 != v) return -EINVAL;
5144
Srinivas Girigowdade697412013-02-14 16:31:48 -08005145 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005146 if ((v < 0) ||
5147 (tempInt <= 0) ||
5148 (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN))
5149 {
5150 return -EINVAL;
5151 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005152
5153 *pNumChannels = tempInt;
5154
5155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5156 "Number of channels are: %d", *pNumChannels);
5157
5158 for (j = 0; j < (*pNumChannels); j++)
5159 {
5160 /*inPtr pointing to the beginning of first space after number of channels*/
5161 inPtr = strpbrk( inPtr, " " );
5162 /*no channel list after the number of channels argument*/
5163 if (NULL == inPtr)
5164 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07005165 if (0 != j)
5166 {
5167 *pNumChannels = j;
5168 return VOS_STATUS_SUCCESS;
5169 }
5170 else
5171 {
5172 return -EINVAL;
5173 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005174 }
5175
5176 /*removing empty space*/
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005177 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++;
Srinivas Girigowdade697412013-02-14 16:31:48 -08005178
5179 /*no channel list after the number of channels argument and spaces*/
5180 if ( '\0' == *inPtr )
5181 {
Srinivas Girigowdacf9a9b42013-03-21 11:55:24 -07005182 if (0 != j)
5183 {
5184 *pNumChannels = j;
5185 return VOS_STATUS_SUCCESS;
5186 }
5187 else
5188 {
5189 return -EINVAL;
5190 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005191 }
5192
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005193 v = sscanf(inPtr, "%31s ", buf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005194 if (1 != v) return -EINVAL;
5195
Srinivas Girigowdade697412013-02-14 16:31:48 -08005196 v = kstrtos32(buf, 10, &tempInt);
Jeff Johnsona1f9afb2013-04-03 09:13:31 -07005197 if ((v < 0) ||
5198 (tempInt <= 0) ||
5199 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
5200 {
5201 return -EINVAL;
5202 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08005203 pChannelList[j] = tempInt;
5204
5205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5206 "Channel %d added to preferred channel list",
5207 pChannelList[j] );
5208 }
5209
Srinivas Girigowdade697412013-02-14 16:31:48 -08005210 return VOS_STATUS_SUCCESS;
5211}
5212
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005213
5214/**---------------------------------------------------------------------------
5215
5216 \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data
5217
5218 This function parses the reasoc command data passed in the format
5219 REASSOC<space><bssid><space><channel>
5220
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005221 \param - pValue Pointer to input data (its a NUL terminated string)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005222 \param - pTargetApBssid Pointer to target Ap bssid
5223 \param - pChannel Pointer to the Target AP channel
5224
5225 \return - 0 for success non-zero for failure
5226
5227 --------------------------------------------------------------------------*/
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005228VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue,
5229 tANI_U8 *pTargetApBssid, tANI_U8 *pChannel)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005230{
5231 tANI_U8 *inPtr = pValue;
5232 int tempInt;
5233 int v = 0;
5234 tANI_U8 tempBuf[32];
Kiet Lamaa8e15a2014-02-11 23:30:06 -08005235 /* 12 hexa decimal digits, 5 ':' and '\0' */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005236 tANI_U8 macAddress[18];
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005237
5238 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
5239 /*no argument after the command*/
5240 if (NULL == inPtr)
5241 {
5242 return -EINVAL;
5243 }
5244
5245 /*no space after the command*/
5246 else if (SPACE_ASCII_VALUE != *inPtr)
5247 {
5248 return -EINVAL;
5249 }
5250
5251 /*removing empty spaces*/
5252 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5253
5254 /*no argument followed by spaces*/
5255 if ('\0' == *inPtr)
5256 {
5257 return -EINVAL;
5258 }
5259
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005260 v = sscanf(inPtr, "%17s", macAddress);
5261 if (!((1 == v) && hdd_is_valid_mac_address(macAddress)))
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005262 {
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5264 "Invalid MAC address or All hex inputs are not read (%d)", v);
5265 return -EINVAL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005266 }
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005267
5268 pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]);
5269 pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]);
5270 pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]);
5271 pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]);
5272 pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]);
5273 pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005274
5275 /* point to the next argument */
5276 inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE);
5277 /*no argument after the command*/
5278 if (NULL == inPtr) return -EINVAL;
5279
5280 /*removing empty spaces*/
5281 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5282
5283 /*no argument followed by spaces*/
5284 if ('\0' == *inPtr)
5285 {
5286 return -EINVAL;
5287 }
5288
5289 /*getting the next argument ie the channel number */
Srinivas Girigowda4081bb12014-01-06 17:12:58 -08005290 v = sscanf(inPtr, "%31s ", tempBuf);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005291 if (1 != v) return -EINVAL;
5292
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005293 v = kstrtos32(tempBuf, 10, &tempInt);
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005294 if ((v < 0) ||
Padma, Santhosh Kumar0fa809b2014-11-13 14:56:56 +05305295 (tempInt < 0) ||
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005296 (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX))
5297 {
5298 return -EINVAL;
5299 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005300
5301 *pChannel = tempInt;
5302 return VOS_STATUS_SUCCESS;
5303}
5304
5305#endif
5306
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005307#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005308/**---------------------------------------------------------------------------
5309
5310 \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE
5311
5312 This function parses the SETCCKM IE command
5313 SETCCKMIE<space><ie data>
5314
5315 \param - pValue Pointer to input data
5316 \param - pCckmIe Pointer to output cckm Ie
5317 \param - pCckmIeLen Pointer to output cckm ie length
5318
5319 \return - 0 for success non-zero for failure
5320
5321 --------------------------------------------------------------------------*/
5322VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe,
5323 tANI_U8 *pCckmIeLen)
5324{
5325 tANI_U8 *inPtr = pValue;
5326 tANI_U8 *dataEnd;
5327 int j = 0;
5328 int i = 0;
5329 tANI_U8 tempByte = 0;
5330
5331 inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE);
5332 /*no argument after the command*/
5333 if (NULL == inPtr)
5334 {
5335 return -EINVAL;
5336 }
5337
5338 /*no space after the command*/
5339 else if (SPACE_ASCII_VALUE != *inPtr)
5340 {
5341 return -EINVAL;
5342 }
5343
5344 /*removing empty spaces*/
5345 while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++;
5346
5347 /*no argument followed by spaces*/
5348 if ('\0' == *inPtr)
5349 {
5350 return -EINVAL;
5351 }
5352
5353 /* find the length of data */
5354 dataEnd = inPtr;
5355 while(('\0' != *dataEnd) )
5356 {
5357 dataEnd++;
5358 ++(*pCckmIeLen);
5359 }
5360 if ( *pCckmIeLen <= 0) return -EINVAL;
5361
5362 /* Allocate the number of bytes based on the number of input characters
5363 whether it is even or odd.
5364 if the number of input characters are even, then we need N/2 byte.
5365 if the number of input characters are odd, then we need do (N+1)/2 to
5366 compensate rounding off.
5367 For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough.
5368 If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */
5369 *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2);
5370 if (NULL == *pCckmIe)
5371 {
5372 hddLog(VOS_TRACE_LEVEL_FATAL,
5373 "%s: vos_mem_alloc failed ", __func__);
5374 return -EINVAL;
5375 }
5376 vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2);
5377 /* the buffer received from the upper layer is character buffer,
5378 we need to prepare the buffer taking 2 characters in to a U8 hex decimal number
5379 for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st
5380 and f0 in 3rd location */
5381 for (i = 0, j = 0; j < *pCckmIeLen; j += 2)
5382 {
5383 tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1]));
5384 (*pCckmIe)[i++] = tempByte;
5385 }
5386 *pCckmIeLen = i;
5387
5388 return VOS_STATUS_SUCCESS;
5389}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005390#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005391
Jeff Johnson295189b2012-06-20 16:38:30 -07005392/**---------------------------------------------------------------------------
5393
Srinivas Girigowda0c69aee2013-10-09 17:21:01 -07005394 \brief hdd_is_valid_mac_address() - Validate MAC address
5395
5396 This function validates whether the given MAC address is valid or not
5397 Expected MAC address is of the format XX:XX:XX:XX:XX:XX
5398 where X is the hexa decimal digit character and separated by ':'
5399 This algorithm works even if MAC address is not separated by ':'
5400
5401 This code checks given input string mac contains exactly 12 hexadecimal digits.
5402 and a separator colon : appears in the input string only after
5403 an even number of hex digits.
5404
5405 \param - pMacAddr pointer to the input MAC address
5406 \return - 1 for valid and 0 for invalid
5407
5408 --------------------------------------------------------------------------*/
5409
5410v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr)
5411{
5412 int xdigit = 0;
5413 int separator = 0;
5414 while (*pMacAddr)
5415 {
5416 if (isxdigit(*pMacAddr))
5417 {
5418 xdigit++;
5419 }
5420 else if (':' == *pMacAddr)
5421 {
5422 if (0 == xdigit || ((xdigit / 2) - 1) != separator)
5423 break;
5424
5425 ++separator;
5426 }
5427 else
5428 {
5429 separator = -1;
5430 /* Invalid MAC found */
5431 return 0;
5432 }
5433 ++pMacAddr;
5434 }
5435 return (xdigit == 12 && (separator == 5 || separator == 0));
5436}
5437
5438/**---------------------------------------------------------------------------
5439
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305440 \brief __hdd_open() - HDD Open function
Jeff Johnson295189b2012-06-20 16:38:30 -07005441
5442 \param - dev Pointer to net_device structure
5443
5444 \return - 0 for success non-zero for failure
5445
5446 --------------------------------------------------------------------------*/
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305447int __hdd_open(struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005448{
5449 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5450 hdd_context_t *pHddCtx;
5451 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5452 VOS_STATUS status;
5453 v_BOOL_t in_standby = TRUE;
5454
5455 if (NULL == pAdapter)
5456 {
5457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05305458 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 return -ENODEV;
5460 }
5461
5462 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305463 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST,
5464 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 if (NULL == pHddCtx)
5466 {
5467 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005468 "%s: HDD context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 return -ENODEV;
5470 }
5471
5472 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5473 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
5474 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005475 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
5476 {
5477 hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby",
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305478 __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005479 in_standby = FALSE;
5480 break;
5481 }
5482 else
5483 {
5484 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5485 pAdapterNode = pNext;
5486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 }
5488
5489 if (TRUE == in_standby)
5490 {
5491 if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter))
5492 {
5493 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring "
5494 "wlan out of power save", __func__);
5495 return -EINVAL;
5496 }
5497 }
5498
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005499 set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
5501 {
5502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005503 "%s: Enabling Tx Queues", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 /* Enable TX queues only when we are connected */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 netif_tx_start_all_queues(dev);
5507 }
5508
5509 return 0;
5510}
5511
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305512/**---------------------------------------------------------------------------
5513
5514 \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR
5515
5516 This is called in response to ifconfig up
5517
5518 \param - dev Pointer to net_device structure
5519
5520 \return - 0 for success non-zero for failure
5521
5522 --------------------------------------------------------------------------*/
5523int hdd_open(struct net_device *dev)
5524{
5525 int ret;
5526
5527 vos_ssr_protect(__func__);
5528 ret = __hdd_open(dev);
5529 vos_ssr_unprotect(__func__);
5530
5531 return ret;
5532}
5533
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305534int __hdd_mon_open (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005535{
5536 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5537
5538 if(pAdapter == NULL) {
5539 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005540 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005541 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 }
5543
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 return 0;
5545}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305546
5547int hdd_mon_open (struct net_device *dev)
5548{
5549 int ret;
5550
5551 vos_ssr_protect(__func__);
5552 ret = __hdd_mon_open(dev);
5553 vos_ssr_unprotect(__func__);
5554
5555 return ret;
5556}
5557
Katya Nigame7b69a82015-04-28 15:24:06 +05305558int hdd_mon_stop(struct net_device *dev)
5559{
5560 return 0;
5561}
5562
Jeff Johnson295189b2012-06-20 16:38:30 -07005563/**---------------------------------------------------------------------------
5564
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305565 \brief __hdd_stop() - HDD stop function
Jeff Johnson295189b2012-06-20 16:38:30 -07005566
5567 \param - dev Pointer to net_device structure
5568
5569 \return - 0 for success non-zero for failure
5570
5571 --------------------------------------------------------------------------*/
5572
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305573int __hdd_stop (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005574{
Vinay Krishna Eranna90f43532014-10-27 16:45:54 +05305575 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5577 hdd_context_t *pHddCtx;
5578 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
5579 VOS_STATUS status;
5580 v_BOOL_t enter_standby = TRUE;
5581
5582 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 if (NULL == pAdapter)
5584 {
5585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Agarwal Ashish971c2882013-10-30 20:11:12 +05305586 "%s: pAdapter is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 return -ENODEV;
5588 }
Sachin Ahuja9b4958f2015-01-15 21:37:00 +05305589 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305590 pAdapter->sessionId, pAdapter->device_mode));
Vinay Krishna Eranna90f43532014-10-27 16:45:54 +05305591
5592 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5593 ret = wlan_hdd_validate_context(pHddCtx);
5594 if (ret)
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 {
Vinay Krishna Eranna90f43532014-10-27 16:45:54 +05305596 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 }
5598
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305599 /* Nothing to be done if the interface is not opened */
5600 if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags))
5601 {
5602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5603 "%s: NETDEV Interface is not OPENED", __func__);
5604 return -ENODEV;
5605 }
5606
5607 /* Make sure the interface is marked as closed */
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005608 clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags);
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__);
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305610
5611 /* Disable TX on the interface, after this hard_start_xmit() will not
5612 * be called on that interface
5613 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305614 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 netif_tx_disable(pAdapter->dev);
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305616
5617 /* Mark the interface status as "down" for outside world */
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 netif_carrier_off(pAdapter->dev);
5619
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305620 /* The interface is marked as down for outside world (aka kernel)
5621 * But the driver is pretty much alive inside. The driver needs to
5622 * tear down the existing connection on the netdev (session)
5623 * cleanup the data pipes and wait until the control plane is stabilized
5624 * for this interface. The call also needs to wait until the above
5625 * mentioned actions are completed before returning to the caller.
5626 * Notice that the hdd_stop_adapter is requested not to close the session
5627 * That is intentional to be able to scan if it is a STA/P2P interface
5628 */
5629 hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305630#ifdef FEATURE_WLAN_TDLS
5631 mutex_lock(&pHddCtx->tdls_lock);
5632#endif
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305633 /* DeInit the adapter. This ensures datapath cleanup as well */
c_hpothu002231a2015-02-05 14:58:51 +05305634 hdd_deinit_adapter(pHddCtx, pAdapter, TRUE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305635#ifdef FEATURE_WLAN_TDLS
5636 mutex_unlock(&pHddCtx->tdls_lock);
5637#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 /* SoftAP ifaces should never go in power save mode
5639 making sure same here. */
5640 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode )
5641 || (WLAN_HDD_MONITOR == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 || (WLAN_HDD_P2P_GO == pAdapter->device_mode )
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 )
5644 {
5645 /* SoftAP mode, so return from here */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305646 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5647 "%s: In SAP MODE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 EXIT();
5649 return 0;
5650 }
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305651 /* Find if any iface is up. If any iface is up then can't put device to
5652 * sleep/power save mode
5653 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
5655 while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) )
5656 {
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005657 if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags))
5658 {
5659 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305660 "put device to sleep", __func__);
Jeff Johnson6a81ca42013-04-05 10:37:08 -07005661 enter_standby = FALSE;
5662 break;
5663 }
5664 else
5665 {
5666 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
5667 pAdapterNode = pNext;
5668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 }
5670
5671 if (TRUE == enter_standby)
5672 {
5673 hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down "
5674 "entering standby", __func__);
5675 if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx))
5676 {
5677 /*log and return success*/
5678 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put "
5679 "wlan in power save", __func__);
5680 }
5681 }
5682
5683 EXIT();
5684 return 0;
5685}
5686
5687/**---------------------------------------------------------------------------
5688
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305689 \brief hdd_stop() - wrapper_function for __hdd_stop to protect it from SSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005690
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305691 This is called in response to ifconfig down
5692
5693 \param - dev Pointer to net_device structure
5694
5695 \return - 0 for success non-zero for failure
5696-----------------------------------------------------------------------------*/
5697int hdd_stop (struct net_device *dev)
5698{
5699 int ret;
5700
5701 vos_ssr_protect(__func__);
5702 ret = __hdd_stop(dev);
5703 vos_ssr_unprotect(__func__);
5704
5705 return ret;
5706}
5707
5708/**---------------------------------------------------------------------------
5709
5710 \brief __hdd_uninit() - HDD uninit function
Jeff Johnson295189b2012-06-20 16:38:30 -07005711
5712 \param - dev Pointer to net_device structure
5713
5714 \return - void
5715
5716 --------------------------------------------------------------------------*/
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305717static void __hdd_uninit (struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07005718{
5719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305720 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 ENTER();
5722
5723 do
5724 {
5725 if (NULL == pAdapter)
5726 {
5727 hddLog(VOS_TRACE_LEVEL_FATAL,
5728 "%s: NULL pAdapter", __func__);
5729 break;
5730 }
5731
5732 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5733 {
5734 hddLog(VOS_TRACE_LEVEL_FATAL,
5735 "%s: Invalid magic", __func__);
5736 break;
5737 }
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305738 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5739 if (NULL == pHddCtx)
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 {
5741 hddLog(VOS_TRACE_LEVEL_FATAL,
5742 "%s: NULL pHddCtx", __func__);
5743 break;
5744 }
5745
5746 if (dev != pAdapter->dev)
5747 {
5748 hddLog(VOS_TRACE_LEVEL_FATAL,
5749 "%s: Invalid device reference", __func__);
5750 /* we haven't validated all cases so let this go for now */
5751 }
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305752#ifdef FEATURE_WLAN_TDLS
5753 mutex_lock(&pHddCtx->tdls_lock);
5754#endif
c_hpothu002231a2015-02-05 14:58:51 +05305755 hdd_deinit_adapter(pHddCtx, pAdapter, TRUE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05305756#ifdef FEATURE_WLAN_TDLS
5757 mutex_unlock(&pHddCtx->tdls_lock);
5758#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005759
5760 /* after uninit our adapter structure will no longer be valid */
5761 pAdapter->dev = NULL;
5762 pAdapter->magic = 0;
5763 } while (0);
5764
5765 EXIT();
5766}
5767
5768/**---------------------------------------------------------------------------
5769
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05305770 \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR
5771
5772 This is called during the netdev unregister to uninitialize all data
5773associated with the device
5774
5775 \param - dev Pointer to net_device structure
5776
5777 \return - void
5778
5779 --------------------------------------------------------------------------*/
5780static void hdd_uninit (struct net_device *dev)
5781{
5782 vos_ssr_protect(__func__);
5783 __hdd_uninit(dev);
5784 vos_ssr_unprotect(__func__);
5785}
5786
5787/**---------------------------------------------------------------------------
5788
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 \brief hdd_release_firmware() -
5790
5791 This function calls the release firmware API to free the firmware buffer.
5792
5793 \param - pFileName Pointer to the File Name.
5794 pCtx - Pointer to the adapter .
5795
5796
5797 \return - 0 for success, non zero for failure
5798
5799 --------------------------------------------------------------------------*/
5800
5801VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx)
5802{
5803 VOS_STATUS status = VOS_STATUS_SUCCESS;
5804 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5805 ENTER();
5806
5807
5808 if (!strcmp(WLAN_FW_FILE, pFileName)) {
5809
5810 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName);
5811
5812 if(pHddCtx->fw) {
5813 release_firmware(pHddCtx->fw);
5814 pHddCtx->fw = NULL;
5815 }
5816 else
5817 status = VOS_STATUS_E_FAILURE;
5818 }
5819 else if (!strcmp(WLAN_NV_FILE,pFileName)) {
5820 if(pHddCtx->nv) {
5821 release_firmware(pHddCtx->nv);
5822 pHddCtx->nv = NULL;
5823 }
5824 else
5825 status = VOS_STATUS_E_FAILURE;
5826
5827 }
5828
5829 EXIT();
5830 return status;
5831}
5832
5833/**---------------------------------------------------------------------------
5834
5835 \brief hdd_request_firmware() -
5836
5837 This function reads the firmware file using the request firmware
5838 API and returns the the firmware data and the firmware file size.
5839
5840 \param - pfileName - Pointer to the file name.
5841 - pCtx - Pointer to the adapter .
5842 - ppfw_data - Pointer to the pointer of the firmware data.
5843 - pSize - Pointer to the file size.
5844
5845 \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure
5846
5847 --------------------------------------------------------------------------*/
5848
5849
5850VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize)
5851{
5852 int status;
5853 VOS_STATUS retval = VOS_STATUS_SUCCESS;
5854 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5855 ENTER();
5856
5857 if( (!strcmp(WLAN_FW_FILE, pfileName)) ) {
5858
5859 status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev);
5860
5861 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5862 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed",
5863 __func__, pfileName);
5864 retval = VOS_STATUS_E_FAILURE;
5865 }
5866
5867 else {
5868 *ppfw_data = (v_VOID_t *)pHddCtx->fw->data;
5869 *pSize = pHddCtx->fw->size;
5870 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d",
5871 __func__, *pSize);
5872 }
5873 }
5874 else if(!strcmp(WLAN_NV_FILE, pfileName)) {
5875
5876 status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev);
5877
5878 if(status || !pHddCtx->nv || !pHddCtx->nv->data) {
5879 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed",
5880 __func__, pfileName);
5881 retval = VOS_STATUS_E_FAILURE;
5882 }
5883
5884 else {
5885 *ppfw_data = (v_VOID_t *)pHddCtx->nv->data;
5886 *pSize = pHddCtx->nv->size;
5887 hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d",
5888 __func__, *pSize);
5889 }
5890 }
5891
5892 EXIT();
5893 return retval;
5894}
5895/**---------------------------------------------------------------------------
5896 \brief hdd_full_pwr_cbk() - HDD full power callbackfunction
5897
5898 This is the function invoked by SME to inform the result of a full power
5899 request issued by HDD
5900
5901 \param - callbackcontext - Pointer to cookie
5902 status - result of request
5903
5904 \return - None
5905
5906--------------------------------------------------------------------------*/
5907void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status)
5908{
5909 hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext;
5910
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005911 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"HDD full Power callback status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 if(&pHddCtx->full_pwr_comp_var)
5913 {
5914 complete(&pHddCtx->full_pwr_comp_var);
5915 }
5916}
5917
5918/**---------------------------------------------------------------------------
5919
5920 \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function
5921
5922 This is the function invoked by SME to inform the result of BMPS
5923 request issued by HDD
5924
5925 \param - callbackcontext - Pointer to cookie
5926 status - result of request
5927
5928 \return - None
5929
5930--------------------------------------------------------------------------*/
5931void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status)
5932{
5933
5934 struct completion *completion_var = (struct completion*) callbackContext;
5935
Arif Hussain6d2a3322013-11-17 19:50:10 -08005936 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 if(completion_var != NULL)
5938 {
5939 complete(completion_var);
5940 }
5941}
5942
5943/**---------------------------------------------------------------------------
5944
5945 \brief hdd_get_cfg_file_size() -
5946
5947 This function reads the configuration file using the request firmware
5948 API and returns the configuration file size.
5949
5950 \param - pCtx - Pointer to the adapter .
5951 - pFileName - Pointer to the file name.
5952 - pBufSize - Pointer to the buffer size.
5953
5954 \return - 0 for success, non zero for failure
5955
5956 --------------------------------------------------------------------------*/
5957
5958VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize)
5959{
5960 int status;
5961 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
5962
5963 ENTER();
5964
5965 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
5966
5967 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
5968 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
5969 status = VOS_STATUS_E_FAILURE;
5970 }
5971 else {
5972 *pBufSize = pHddCtx->fw->size;
5973 hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize);
5974 release_firmware(pHddCtx->fw);
5975 pHddCtx->fw = NULL;
5976 }
5977
5978 EXIT();
5979 return VOS_STATUS_SUCCESS;
5980}
5981
5982/**---------------------------------------------------------------------------
5983
5984 \brief hdd_read_cfg_file() -
5985
5986 This function reads the configuration file using the request firmware
5987 API and returns the cfg data and the buffer size of the configuration file.
5988
5989 \param - pCtx - Pointer to the adapter .
5990 - pFileName - Pointer to the file name.
5991 - pBuffer - Pointer to the data buffer.
5992 - pBufSize - Pointer to the buffer size.
5993
5994 \return - 0 for success, non zero for failure
5995
5996 --------------------------------------------------------------------------*/
5997
5998VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName,
5999 v_VOID_t *pBuffer, v_SIZE_t *pBufSize)
6000{
6001 int status;
6002 hdd_context_t *pHddCtx = (hdd_context_t*)pCtx;
6003
6004 ENTER();
6005
6006 status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev);
6007
6008 if(status || !pHddCtx->fw || !pHddCtx->fw->data) {
6009 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__);
6010 return VOS_STATUS_E_FAILURE;
6011 }
6012 else {
6013 if(*pBufSize != pHddCtx->fw->size) {
6014 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG "
6015 "file size", __func__);
6016 release_firmware(pHddCtx->fw);
6017 pHddCtx->fw = NULL;
6018 return VOS_STATUS_E_FAILURE;
6019 }
6020 else {
6021 if(pBuffer) {
6022 vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize);
6023 }
6024 release_firmware(pHddCtx->fw);
6025 pHddCtx->fw = NULL;
6026 }
6027 }
6028
6029 EXIT();
6030
6031 return VOS_STATUS_SUCCESS;
6032}
6033
6034/**---------------------------------------------------------------------------
6035
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05306036 \brief __hdd_set_mac_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07006037
6038 This function sets the user specified mac address using
6039 the command ifconfig wlanX hw ether <mac adress>.
6040
6041 \param - dev - Pointer to the net device.
6042 - addr - Pointer to the sockaddr.
6043 \return - 0 for success, non zero for failure
6044
6045 --------------------------------------------------------------------------*/
6046
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05306047static int __hdd_set_mac_address(struct net_device *dev, void *addr)
Jeff Johnson295189b2012-06-20 16:38:30 -07006048{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306049 hdd_adapter_t *pAdapter;
6050 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 struct sockaddr *psta_mac_addr = addr;
6052 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306053 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006054
6055 ENTER();
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306056 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6057 if (NULL == pAdapter)
6058 {
6059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6060 "%s: Adapter is NULL",__func__);
6061 return -EINVAL;
6062 }
6063 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6064 ret = wlan_hdd_validate_context(pHddCtx);
6065 if (0 != ret)
6066 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05306067 return ret;
6068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006069
6070 memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN);
6072
6073 EXIT();
6074 return halStatus;
6075}
6076
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05306077/**---------------------------------------------------------------------------
6078
6079 \brief hdd_set_mac_address() -
6080
6081 Wrapper function to protect __hdd_set_mac_address() function from ssr
6082
6083 \param - dev - Pointer to the net device.
6084 - addr - Pointer to the sockaddr.
6085 \return - 0 for success, non zero for failure
6086
6087 --------------------------------------------------------------------------*/
6088static int hdd_set_mac_address(struct net_device *dev, void *addr)
6089{
6090 int ret;
6091
6092 vos_ssr_protect(__func__);
6093 ret = __hdd_set_mac_address(dev, addr);
6094 vos_ssr_unprotect(__func__);
6095
6096 return ret;
6097}
6098
Jeff Johnson295189b2012-06-20 16:38:30 -07006099tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx)
6100{
6101 int i;
6102 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
6103 {
Abhishek Singheb183782014-02-06 13:37:21 +05306104 if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 break;
6106 }
6107
6108 if( VOS_MAX_CONCURRENCY_PERSONA == i)
6109 return NULL;
6110
6111 pHddCtx->cfg_ini->intfAddrMask |= (1 << i);
6112 return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0];
6113}
6114
6115void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr)
6116{
6117 int i;
6118 for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
6119 {
6120 if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) )
6121 {
6122 pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i);
6123 break;
6124 }
6125 }
6126 return;
6127}
6128
6129#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6130 static struct net_device_ops wlan_drv_ops = {
6131 .ndo_open = hdd_open,
6132 .ndo_stop = hdd_stop,
6133 .ndo_uninit = hdd_uninit,
6134 .ndo_start_xmit = hdd_hard_start_xmit,
6135 .ndo_tx_timeout = hdd_tx_timeout,
6136 .ndo_get_stats = hdd_stats,
6137 .ndo_do_ioctl = hdd_ioctl,
6138 .ndo_set_mac_address = hdd_set_mac_address,
6139 .ndo_select_queue = hdd_select_queue,
6140#ifdef WLAN_FEATURE_PACKET_FILTERING
6141#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0))
6142 .ndo_set_rx_mode = hdd_set_multicast_list,
6143#else
6144 .ndo_set_multicast_list = hdd_set_multicast_list,
6145#endif //LINUX_VERSION_CODE
6146#endif
6147 };
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 static struct net_device_ops wlan_mon_drv_ops = {
6149 .ndo_open = hdd_mon_open,
Katya Nigame7b69a82015-04-28 15:24:06 +05306150 .ndo_stop = hdd_mon_stop,
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 .ndo_uninit = hdd_uninit,
6152 .ndo_start_xmit = hdd_mon_hard_start_xmit,
6153 .ndo_tx_timeout = hdd_tx_timeout,
6154 .ndo_get_stats = hdd_stats,
Katya Nigame7b69a82015-04-28 15:24:06 +05306155 .ndo_do_ioctl = hdd_mon_ioctl,
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 .ndo_set_mac_address = hdd_set_mac_address,
6157 };
Mahesh A Saptasagar305e2632015-03-04 12:57:33 +05306158
Jeff Johnson295189b2012-06-20 16:38:30 -07006159#endif
6160
6161void hdd_set_station_ops( struct net_device *pWlanDev )
6162{
6163#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 pWlanDev->netdev_ops = &wlan_drv_ops;
6165#else
6166 pWlanDev->open = hdd_open;
6167 pWlanDev->stop = hdd_stop;
6168 pWlanDev->uninit = hdd_uninit;
6169 pWlanDev->hard_start_xmit = NULL;
6170 pWlanDev->tx_timeout = hdd_tx_timeout;
6171 pWlanDev->get_stats = hdd_stats;
6172 pWlanDev->do_ioctl = hdd_ioctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 pWlanDev->set_mac_address = hdd_set_mac_address;
6174#endif
6175}
6176
Katya Nigam1fd24402015-02-16 14:52:19 +05306177void hdd_set_ibss_ops( hdd_adapter_t *pAdapter )
6178{
6179 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6180 wlan_drv_ops.ndo_start_xmit = hdd_ibss_hard_start_xmit;
6181 #else
6182 pAdapter->dev->hard_start_xmit = hdd_ibss_hard_start_xmit;
6183 #endif
6184}
6185
Jeff Johnsoneed415b2013-01-18 16:11:20 -08006186static hdd_adapter_t* hdd_alloc_station_adapter( hdd_context_t *pHddCtx, tSirMacAddr macAddr, const char* name )
Jeff Johnson295189b2012-06-20 16:38:30 -07006187{
6188 struct net_device *pWlanDev = NULL;
6189 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 /*
6191 * cfg80211 initialization and registration....
6192 */
Anand N Sunkadc34abbd2015-07-29 09:52:59 +05306193 pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name,
6194#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
6195 NET_NAME_UNKNOWN,
6196#endif
6197 ether_setup, NUM_TX_QUEUES);
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 if(pWlanDev != NULL)
6199 {
6200
6201 //Save the pointer to the net_device in the HDD adapter
6202 pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev );
6203
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) );
6205
6206 pAdapter->dev = pWlanDev;
6207 pAdapter->pHddCtx = pHddCtx;
6208 pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC;
Agarwal Ashish47d18112014-08-04 19:55:07 +05306209 spin_lock_init(&pAdapter->lock_for_active_session);
Jeff Johnson295189b2012-06-20 16:38:30 -07006210
6211 init_completion(&pAdapter->session_open_comp_var);
6212 init_completion(&pAdapter->session_close_comp_var);
6213 init_completion(&pAdapter->disconnect_comp_var);
6214 init_completion(&pAdapter->linkup_event_var);
6215 init_completion(&pAdapter->cancel_rem_on_chan_var);
6216 init_completion(&pAdapter->rem_on_chan_ready_event);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05306217 init_completion(&pAdapter->pno_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07006218#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6219 init_completion(&pAdapter->offchannel_tx_event);
6220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 init_completion(&pAdapter->tx_action_cnf_event);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006222#ifdef FEATURE_WLAN_TDLS
6223 init_completion(&pAdapter->tdls_add_station_comp);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006224 init_completion(&pAdapter->tdls_del_station_comp);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006225 init_completion(&pAdapter->tdls_mgmt_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05306226 init_completion(&pAdapter->tdls_link_establish_req_comp);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006227#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 init_completion(&pHddCtx->mc_sus_event_var);
6229 init_completion(&pHddCtx->tx_sus_event_var);
Gopichand Nakkala05621412013-06-19 19:37:38 +05306230 init_completion(&pHddCtx->rx_sus_event_var);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07006231 init_completion(&pAdapter->ula_complete);
Sameer Thalappilda4eb6a2013-09-25 11:45:07 -07006232 init_completion(&pAdapter->change_country_code);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233
Rajeev79dbe4c2013-10-05 11:03:42 +05306234#ifdef FEATURE_WLAN_BATCH_SCAN
6235 init_completion(&pAdapter->hdd_set_batch_scan_req_var);
6236 init_completion(&pAdapter->hdd_get_batch_scan_req_var);
6237 pAdapter->pBatchScanRsp = NULL;
6238 pAdapter->numScanList = 0;
Rajeev Kumar20140c12013-10-21 19:39:02 -07006239 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
Kiet Lamaa8e15a2014-02-11 23:30:06 -08006240 pAdapter->prev_batch_id = 0;
Rajeev79dbe4c2013-10-05 11:03:42 +05306241 mutex_init(&pAdapter->hdd_batch_scan_lock);
6242#endif
6243
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 pAdapter->isLinkUpSvcNeeded = FALSE;
6245 pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE;
6246 //Init the net_device structure
6247 strlcpy(pWlanDev->name, name, IFNAMSIZ);
6248
6249 vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr));
6250 vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr));
6251 pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT;
6252 pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM;
6253
6254 hdd_set_station_ops( pAdapter->dev );
6255
6256 pWlanDev->destructor = free_netdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 pWlanDev->ieee80211_ptr = &pAdapter->wdev ;
6258 pAdapter->wdev.wiphy = pHddCtx->wiphy;
6259 pAdapter->wdev.netdev = pWlanDev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 /* set pWlanDev's parent to underlying device */
6261 SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev);
Kumar Anand82c009f2014-05-29 00:29:42 -07006262
6263 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 }
6265
6266 return pAdapter;
6267}
6268
6269VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held )
6270{
6271 struct net_device *pWlanDev = pAdapter->dev;
6272 //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
6273 //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6274 //eHalStatus halStatus = eHAL_STATUS_SUCCESS;
6275
6276 if( rtnl_lock_held )
6277 {
Madan Mohan Koyyalamudid8ac8662012-11-06 19:04:56 -08006278 if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) {
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 )
6280 {
6281 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__);
6282 return VOS_STATUS_E_FAILURE;
6283 }
6284 }
6285 if (register_netdevice(pWlanDev))
6286 {
6287 hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__);
6288 return VOS_STATUS_E_FAILURE;
6289 }
6290 }
6291 else
6292 {
6293 if(register_netdev(pWlanDev))
6294 {
6295 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__);
6296 return VOS_STATUS_E_FAILURE;
6297 }
6298 }
6299 set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags);
6300
6301 return VOS_STATUS_SUCCESS;
6302}
6303
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006304static eHalStatus hdd_smeCloseSessionCallback(void *pContext)
Jeff Johnson295189b2012-06-20 16:38:30 -07006305{
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006306 hdd_adapter_t *pAdapter = pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07006307
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006308 if (NULL == pAdapter)
6309 {
6310 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__);
6311 return eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 }
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006313
6314 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6315 {
6316 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__);
6317 return eHAL_STATUS_NOT_INITIALIZED;
6318 }
6319
6320 clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
6321
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006322#ifndef WLAN_OPEN_SOURCE
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006323 /* need to make sure all of our scheduled work has completed.
6324 * This callback is called from MC thread context, so it is safe to
6325 * to call below flush workqueue API from here.
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006326 *
6327 * Even though this is called from MC thread context, if there is a faulty
6328 * work item in the system, that can hang this call forever. So flushing
6329 * this global work queue is not safe; and now we make sure that
6330 * individual work queues are stopped correctly. But the cancel work queue
6331 * is a GPL only API, so the proprietary version of the driver would still
6332 * rely on the global work queue flush.
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006333 */
6334 flush_scheduled_work();
Sameer Thalappilbee426e2013-10-30 10:30:30 -07006335#endif
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006336
6337 /* We can be blocked while waiting for scheduled work to be
6338 * flushed, and the adapter structure can potentially be freed, in
6339 * which case the magic will have been reset. So make sure the
6340 * magic is still good, and hence the adapter structure is still
6341 * valid, before signaling completion */
6342 if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic)
6343 {
6344 complete(&pAdapter->session_close_comp_var);
6345 }
6346
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 return eHAL_STATUS_SUCCESS;
6348}
6349
6350VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter )
6351{
6352 struct net_device *pWlanDev = pAdapter->dev;
6353 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
6354 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6355 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
6356 VOS_STATUS status = VOS_STATUS_E_FAILURE;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306357 long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006358
Nirav Shah7e3c8132015-06-22 23:51:42 +05306359 spin_lock_init( &pAdapter->sta_hash_lock);
6360 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
6361
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 INIT_COMPLETION(pAdapter->session_open_comp_var);
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07006363 sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 //Open a SME session for future operation
6365 halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07006366 (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 if ( !HAL_STATUS_SUCCESS( halStatus ) )
6368 {
6369 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006370 "sme_OpenSession() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 halStatus, halStatus );
6372 status = VOS_STATUS_E_FAILURE;
6373 goto error_sme_open;
6374 }
6375
6376 //Block on a completion variable. Can't wait forever though.
Vinay Krishna Eranna0fe2e7c2014-04-09 21:32:08 +05306377 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 &pAdapter->session_open_comp_var,
6379 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306380 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 {
6382 hddLog(VOS_TRACE_LEVEL_FATAL,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306383 "Session is not opened within timeout period code %ld", rc );
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 status = VOS_STATUS_E_FAILURE;
6385 goto error_sme_open;
6386 }
6387
6388 // Register wireless extensions
6389 if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev)))
6390 {
6391 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006392 "hdd_register_wext() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 halStatus, halStatus );
6394 status = VOS_STATUS_E_FAILURE;
6395 goto error_register_wext;
6396 }
Katya Nigam1fd24402015-02-16 14:52:19 +05306397
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 //Safe to register the hard_start_xmit function again
Katya Nigam1fd24402015-02-16 14:52:19 +05306399 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
6400 wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit;
6401 #else
6402 pWlanDev->hard_start_xmit = hdd_hard_start_xmit;
6403 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006404
6405 //Set the Connection State to Not Connected
Abhishek Singhf4669da2014-05-26 15:07:49 +05306406 hddLog(VOS_TRACE_LEVEL_INFO,
6407 "%s: Set HDD connState to eConnectionState_NotConnected",
6408 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6410
6411 //Set the default operation channel
6412 pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel;
6413
6414 /* Make the default Auth Type as OPEN*/
6415 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6416
6417 if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) )
6418 {
6419 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006420 "hdd_init_tx_rx() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 status, status );
6422 goto error_init_txrx;
6423 }
6424
6425 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6426
6427 if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) )
6428 {
6429 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006430 "hdd_wmm_adapter_init() failed with status code %08d [x%08x]",
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 status, status );
6432 goto error_wmm_init;
6433 }
6434
6435 set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6436
6437 return VOS_STATUS_SUCCESS;
6438
6439error_wmm_init:
6440 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6441 hdd_deinit_tx_rx(pAdapter);
6442error_init_txrx:
6443 hdd_UnregisterWext(pWlanDev);
6444error_register_wext:
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006445 if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 {
6447 INIT_COMPLETION(pAdapter->session_close_comp_var);
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006448 if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal,
mukul sharmabab477d2015-06-11 17:14:55 +05306449 pAdapter->sessionId, VOS_TRUE,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006450 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306452 unsigned long rc;
6453
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306455 rc = wait_for_completion_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 &pAdapter->session_close_comp_var,
Jeff Johnsonc6ab5b92013-04-15 17:02:05 -07006457 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306458 if (rc <= 0)
6459 hddLog(VOS_TRACE_LEVEL_ERROR,
6460 FL("Session is not opened within timeout period code %ld"), rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 }
6462}
6463error_sme_open:
6464 return status;
6465}
6466
Jeff Johnson295189b2012-06-20 16:38:30 -07006467void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter )
6468{
6469 hdd_cfg80211_state_t *cfgState;
6470
6471 cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter );
6472
6473 if( NULL != cfgState->buf )
6474 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306475 long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 INIT_COMPLETION(pAdapter->tx_action_cnf_event);
6477 rc = wait_for_completion_interruptible_timeout(
6478 &pAdapter->tx_action_cnf_event,
6479 msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306480 if (rc <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 {
Sudhir Sattayappa Kohalli8ee532d2013-02-15 13:16:26 -08006482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306483 "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld"
6484 , __func__, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 }
6486 }
6487 return;
6488}
Jeff Johnson295189b2012-06-20 16:38:30 -07006489
c_hpothu002231a2015-02-05 14:58:51 +05306490void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held )
Jeff Johnson295189b2012-06-20 16:38:30 -07006491{
6492 ENTER();
6493 switch ( pAdapter->device_mode )
6494 {
Katya Nigam1fd24402015-02-16 14:52:19 +05306495 case WLAN_HDD_IBSS:
6496 {
6497 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6498 {
6499 hdd_ibss_deinit_tx_rx( pAdapter );
6500 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6501 }
6502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 case WLAN_HDD_INFRA_STATION:
6504 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006505 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 {
6507 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6508 {
6509 hdd_deinit_tx_rx( pAdapter );
6510 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6511 }
6512
6513 if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6514 {
6515 hdd_wmm_adapter_close( pAdapter );
6516 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6517 }
6518
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 break;
6521 }
6522
6523 case WLAN_HDD_SOFTAP:
6524 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 {
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05306526
6527 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
6528 {
6529 hdd_wmm_adapter_close( pAdapter );
6530 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
6531 }
6532
Jeff Johnson295189b2012-06-20 16:38:30 -07006533 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006534
c_hpothu002231a2015-02-05 14:58:51 +05306535 hdd_unregister_hostapd(pAdapter, rtnl_held);
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 hdd_set_conparam( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 break;
6538 }
6539
6540 case WLAN_HDD_MONITOR:
6541 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags))
6543 {
6544 hdd_deinit_tx_rx( pAdapter );
6545 clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
6546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 break;
6548 }
6549
6550
6551 default:
6552 break;
6553 }
6554
6555 EXIT();
6556}
6557
6558void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held )
6559{
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006560 struct net_device *pWlanDev = NULL;
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306561
6562 ENTER();
6563 if (NULL == pAdapter)
6564 {
6565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6566 "%s: HDD adapter is Null", __func__);
6567 return;
6568 }
6569
6570 pWlanDev = pAdapter->dev;
Jeff Johnson295189b2012-06-20 16:38:30 -07006571
Rajeev79dbe4c2013-10-05 11:03:42 +05306572#ifdef FEATURE_WLAN_BATCH_SCAN
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306573 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
6574 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Rajeev Kumarf999e582014-01-09 17:33:29 -08006575 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306576 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
6577 )
6578 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08006579 if (pAdapter)
Rajeev79dbe4c2013-10-05 11:03:42 +05306580 {
Rajeev Kumarf999e582014-01-09 17:33:29 -08006581 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
6582 {
6583 hdd_deinit_batch_scan(pAdapter);
6584 }
Rajeev79dbe4c2013-10-05 11:03:42 +05306585 }
Rajeev Kumarf999e582014-01-09 17:33:29 -08006586 }
Rajeev79dbe4c2013-10-05 11:03:42 +05306587#endif
6588
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) {
6590 if( rtnl_held )
6591 {
6592 unregister_netdevice(pWlanDev);
6593 }
6594 else
6595 {
6596 unregister_netdev(pWlanDev);
6597 }
6598 // note that the pAdapter is no longer valid at this point
6599 // since the memory has been reclaimed
6600 }
6601
Srinivas, Dasari693dfc52013-12-27 17:29:09 +05306602 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006603}
6604
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006605void hdd_set_pwrparams(hdd_context_t *pHddCtx)
6606{
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306607 VOS_STATUS status;
6608 hdd_adapter_t *pAdapter = NULL;
6609 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006610
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306611 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006612
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306613 /*loop through all adapters.*/
6614 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006615 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306616 pAdapter = pAdapterNode->pAdapter;
6617 if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode)
6618 && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) )
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006619
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306620 { // we skip this registration for modes other than STA and P2P client modes.
6621 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6622 pAdapterNode = pNext;
6623 continue;
6624 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006625
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306626 //Apply Dynamic DTIM For P2P
6627 //Only if ignoreDynamicDtimInP2pMode is not set in ini
6628 if ((pHddCtx->cfg_ini->enableDynamicDTIM ||
6629 pHddCtx->cfg_ini->enableModulatedDTIM) &&
6630 ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6631 ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) &&
6632 !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) &&
6633 (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) &&
6634 (eConnectionState_Associated ==
6635 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) &&
6636 (pHddCtx->cfg_ini->fIsBmpsEnabled))
6637 {
6638 tSirSetPowerParamsReq powerRequest = { 0 };
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006639
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306640 powerRequest.uIgnoreDTIM = 1;
6641 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
6642
6643 if (pHddCtx->cfg_ini->enableModulatedDTIM)
6644 {
6645 powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM;
6646 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
6647 }
6648 else
6649 {
6650 powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM;
6651 }
6652
6653 /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM
6654 * specified during Enter/Exit BMPS when LCD off*/
6655 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
6656 NULL, eANI_BOOLEAN_FALSE);
6657 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
6658 NULL, eANI_BOOLEAN_FALSE);
6659
6660 /* switch to the DTIM specified in cfg.ini */
6661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6662 "Switch to DTIM %d", powerRequest.uListenInterval);
6663 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
6664 break;
6665
6666 }
6667
6668 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6669 pAdapterNode = pNext;
6670 }
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006671}
6672
6673void hdd_reset_pwrparams(hdd_context_t *pHddCtx)
6674{
6675 /*Switch back to DTIM 1*/
6676 tSirSetPowerParamsReq powerRequest = { 0 };
6677
6678 powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value;
6679 powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value;
Yue Mac24062f2013-05-13 17:01:29 -07006680 powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM;
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08006681
6682 /* Update ignoreDTIM and ListedInterval in CFG with default values */
6683 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM,
6684 NULL, eANI_BOOLEAN_FALSE);
6685 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval,
6686 NULL, eANI_BOOLEAN_FALSE);
6687
6688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6689 "Switch to DTIM%d",powerRequest.uListenInterval);
6690 sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE);
6691
6692}
6693
Jeff Johnson295189b2012-06-20 16:38:30 -07006694VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx)
6695{
6696 VOS_STATUS status = VOS_STATUS_SUCCESS;
Sushant Kaushik4928e542014-12-29 15:25:54 +05306697 if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx))
6698 {
6699 hddLog( LOGE, FL("Wlan Unload in progress"));
6700 return VOS_STATUS_E_PERM;
6701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
6703 {
6704 sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
6705 }
6706
6707 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
6708 {
6709 sme_StartAutoBmpsTimer(pHddCtx->hHal);
6710 }
6711
6712 if (pHddCtx->cfg_ini->fIsImpsEnabled)
6713 {
6714 sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
6715 }
6716
6717 return status;
6718}
6719
6720VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type)
6721{
6722 hdd_adapter_t *pAdapter = NULL;
6723 eHalStatus halStatus;
6724 VOS_STATUS status = VOS_STATUS_E_INVAL;
6725 v_BOOL_t disableBmps = FALSE;
6726 v_BOOL_t disableImps = FALSE;
6727
6728 switch(session_type)
6729 {
6730 case WLAN_HDD_INFRA_STATION:
6731 case WLAN_HDD_SOFTAP:
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 case WLAN_HDD_P2P_CLIENT:
6733 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 //Exit BMPS -> Is Sta/P2P Client is already connected
6735 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6736 if((NULL != pAdapter)&&
6737 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6738 {
6739 disableBmps = TRUE;
6740 }
6741
6742 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6743 if((NULL != pAdapter)&&
6744 hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
6745 {
6746 disableBmps = TRUE;
6747 }
6748
6749 //Exit both Bmps and Imps incase of Go/SAP Mode
6750 if((WLAN_HDD_SOFTAP == session_type) ||
6751 (WLAN_HDD_P2P_GO == session_type))
6752 {
6753 disableBmps = TRUE;
6754 disableImps = TRUE;
6755 }
6756
6757 if(TRUE == disableImps)
6758 {
6759 if (pHddCtx->cfg_ini->fIsImpsEnabled)
6760 {
6761 sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
6762 }
6763 }
6764
6765 if(TRUE == disableBmps)
6766 {
6767 if(pHddCtx->cfg_ini->fIsBmpsEnabled)
6768 {
6769 halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
6770
6771 if(eHAL_STATUS_SUCCESS != halStatus)
6772 {
6773 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006774 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 VOS_ASSERT(0);
6776 return status;
6777 }
6778 }
6779
6780 if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled)
6781 {
6782 halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal);
6783
6784 if(eHAL_STATUS_SUCCESS != halStatus)
6785 {
6786 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006787 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Stop Auto Bmps Timer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 VOS_ASSERT(0);
6789 return status;
6790 }
6791 }
6792 }
6793
6794 if((TRUE == disableBmps) ||
6795 (TRUE == disableImps))
6796 {
6797 /* Now, get the chip into Full Power now */
6798 INIT_COMPLETION(pHddCtx->full_pwr_comp_var);
6799 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk,
6800 pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD);
6801
6802 if(halStatus != eHAL_STATUS_SUCCESS)
6803 {
6804 if(halStatus == eHAL_STATUS_PMC_PENDING)
6805 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306806 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 //Block on a completion variable. Can't wait forever though
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306808 ret = wait_for_completion_interruptible_timeout(
6809 &pHddCtx->full_pwr_comp_var,
6810 msecs_to_jiffies(1000));
6811 if (ret <= 0)
6812 {
6813 hddLog(VOS_TRACE_LEVEL_ERROR,
6814 "%s: wait on full_pwr_comp_var failed %ld",
6815 __func__, ret);
6816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 }
6818 else
6819 {
6820 status = VOS_STATUS_E_FAILURE;
Arif Hussain6d2a3322013-11-17 19:50:10 -08006821 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 VOS_ASSERT(0);
6823 return status;
6824 }
6825 }
6826
6827 status = VOS_STATUS_SUCCESS;
6828 }
6829
6830 break;
6831 }
6832 return status;
6833}
Katya Nigame7b69a82015-04-28 15:24:06 +05306834void hdd_init_mon_mode (hdd_adapter_t *pAdapter)
6835 {
6836 hdd_mon_ctx_t *pMonCtx = NULL;
6837 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6838
6839 pMonCtx->state = 0;
6840 pMonCtx->ChannelNo = 1;
6841 pMonCtx->ChannelBW = 20;
Katya Nigamd7d3a1f2015-06-11 14:04:24 +05306842 pMonCtx->crcCheckEnabled = 1;
6843 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
6844 pMonCtx->is80211to803ConReq = 1;
Katya Nigame7b69a82015-04-28 15:24:06 +05306845 pMonCtx->numOfMacFilters = 0;
6846 }
6847
Jeff Johnson295189b2012-06-20 16:38:30 -07006848
6849hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type,
Jeff Johnsoneed415b2013-01-18 16:11:20 -08006850 const char *iface_name, tSirMacAddr macAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 tANI_U8 rtnl_held )
6852{
6853 hdd_adapter_t *pAdapter = NULL;
6854 hdd_adapter_list_node_t *pHddAdapterNode = NULL;
6855 VOS_STATUS status = VOS_STATUS_E_FAILURE;
6856 VOS_STATUS exitbmpsStatus;
6857
Arif Hussain6d2a3322013-11-17 19:50:10 -08006858 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s iface =%s type = %d",__func__,iface_name,session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006859
Nirav Shah436658f2014-02-28 17:05:45 +05306860 if(macAddr == NULL)
6861 {
6862 /* Not received valid macAddr */
6863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6864 "%s:Unable to add virtual intf: Not able to get"
6865 "valid mac address",__func__);
6866 return NULL;
6867 }
6868
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 //Disable BMPS incase of Concurrency
6870 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type);
6871
6872 if(VOS_STATUS_E_FAILURE == exitbmpsStatus)
6873 {
6874 //Fail to Exit BMPS
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306875 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 VOS_ASSERT(0);
6877 return NULL;
6878 }
6879
6880 switch(session_type)
6881 {
6882 case WLAN_HDD_INFRA_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07006884 case WLAN_HDD_P2P_DEVICE:
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 {
6886 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
6887
6888 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306889 {
6890 hddLog(VOS_TRACE_LEVEL_FATAL,
6891 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006892 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006894
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306895#ifdef FEATURE_WLAN_TDLS
6896 /* A Mutex Lock is introduced while changing/initializing the mode to
6897 * protect the concurrent access for the Adapters by TDLS module.
6898 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306899 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306900#endif
6901
Jeff Johnsone7245742012-09-05 17:12:55 -07006902 pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ?
6903 NL80211_IFTYPE_P2P_CLIENT:
6904 NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 pAdapter->device_mode = session_type;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306907#ifdef FEATURE_WLAN_TDLS
6908 mutex_unlock(&pHddCtx->tdls_lock);
6909#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05306910
6911 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 if( VOS_STATUS_SUCCESS != status )
6913 goto err_free_netdev;
6914
6915 status = hdd_register_interface( pAdapter, rtnl_held );
6916 if( VOS_STATUS_SUCCESS != status )
6917 {
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05306918#ifdef FEATURE_WLAN_TDLS
6919 mutex_lock(&pHddCtx->tdls_lock);
6920#endif
c_hpothu002231a2015-02-05 14:58:51 +05306921 hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05306922#ifdef FEATURE_WLAN_TDLS
6923 mutex_unlock(&pHddCtx->tdls_lock);
6924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 goto err_free_netdev;
6926 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306927
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306928 // Workqueue which gets scheduled in IPv4 notification callback.
Anand N Sunkaddc63c792015-06-03 14:33:24 +05306929 vos_init_work(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue);
Vinay Krishna Eranna4d055d42013-12-17 17:02:01 +05306930
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306931#ifdef WLAN_NS_OFFLOAD
6932 // Workqueue which gets scheduled in IPv6 notification callback.
Anand N Sunkaddc63c792015-06-03 14:33:24 +05306933 vos_init_work(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue);
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05306934#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 //Stop the Interface TX queue.
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05306936 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 netif_tx_disable(pAdapter->dev);
6938 //netif_tx_disable(pWlanDev);
6939 netif_carrier_off(pAdapter->dev);
6940
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05306941 if (WLAN_HDD_P2P_CLIENT == session_type ||
6942 WLAN_HDD_P2P_DEVICE == session_type)
6943 {
6944 /* Initialize the work queue to defer the
6945 * back to back RoC request */
Anand N Sunkaddc63c792015-06-03 14:33:24 +05306946 vos_init_delayed_work(&pAdapter->roc_work,
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05306947 hdd_p2p_roc_work_queue);
6948 }
6949
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 break;
6951 }
6952
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 case WLAN_HDD_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 case WLAN_HDD_SOFTAP:
6955 {
6956 pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name );
6957 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306958 {
6959 hddLog(VOS_TRACE_LEVEL_FATAL,
6960 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ?
6965 NL80211_IFTYPE_AP:
6966 NL80211_IFTYPE_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 pAdapter->device_mode = session_type;
6968
6969 status = hdd_init_ap_mode(pAdapter);
6970 if( VOS_STATUS_SUCCESS != status )
6971 goto err_free_netdev;
6972
Nirav Shah7e3c8132015-06-22 23:51:42 +05306973 status = hdd_sta_id_hash_attach(pAdapter);
6974 if (VOS_STATUS_SUCCESS != status)
6975 {
6976 hddLog(VOS_TRACE_LEVEL_FATAL,
6977 FL("failed to attach hash for session %d"), session_type);
6978 hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held);
6979 goto err_free_netdev;
6980 }
6981
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 status = hdd_register_hostapd( pAdapter, rtnl_held );
6983 if( VOS_STATUS_SUCCESS != status )
6984 {
c_hpothu002231a2015-02-05 14:58:51 +05306985 hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 goto err_free_netdev;
6987 }
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05306988 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 netif_tx_disable(pAdapter->dev);
6990 netif_carrier_off(pAdapter->dev);
6991
6992 hdd_set_conparam( 1 );
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05306993
6994 if (WLAN_HDD_P2P_GO == session_type)
6995 {
6996 /* Initialize the work queue to
6997 * defer the back to back RoC request */
6998 INIT_DELAYED_WORK(&pAdapter->roc_work,
6999 hdd_p2p_roc_work_queue);
7000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 break;
7002 }
7003 case WLAN_HDD_MONITOR:
7004 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
7006 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307007 {
7008 hddLog(VOS_TRACE_LEVEL_FATAL,
7009 FL("failed to allocate adapter for session %d"), session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 return NULL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007012
Katya Nigame7b69a82015-04-28 15:24:06 +05307013 // Register wireless extensions
7014 if( VOS_STATUS_SUCCESS != (status = hdd_register_wext(pAdapter->dev)))
7015 {
7016 hddLog(VOS_TRACE_LEVEL_FATAL,
7017 "hdd_register_wext() failed with status code %08d [x%08x]",
7018 status, status );
7019 status = VOS_STATUS_E_FAILURE;
7020 }
7021
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR;
7023 pAdapter->device_mode = session_type;
Jeff Johnson295189b2012-06-20 16:38:30 -07007024#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
7025 pAdapter->dev->netdev_ops = &wlan_mon_drv_ops;
7026#else
7027 pAdapter->dev->open = hdd_mon_open;
7028 pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit;
Katya Nigame7b69a82015-04-28 15:24:06 +05307029 pAdapter->dev->stop = hdd_mon_stop;
7030 pAdapter->dev->do_ioctl = hdd_mon_ioctl;
Jeff Johnson295189b2012-06-20 16:38:30 -07007031#endif
Katya Nigame7b69a82015-04-28 15:24:06 +05307032 status = hdd_register_interface( pAdapter, rtnl_held );
7033 hdd_init_mon_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 hdd_init_tx_rx( pAdapter );
7035 set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
Katya Nigame7b69a82015-04-28 15:24:06 +05307036 //Stop the Interface TX queue.
7037 netif_tx_disable(pAdapter->dev);
7038 netif_carrier_off(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 }
7040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 case WLAN_HDD_FTM:
7042 {
7043 pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name );
7044
7045 if( NULL == pAdapter )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307046 {
7047 hddLog(VOS_TRACE_LEVEL_FATAL,
7048 FL("failed to allocate adapter for session %d"), session_type);
7049 return NULL;
7050 }
7051
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning
7053 * message while loading driver in FTM mode. */
7054 pAdapter->wdev.iftype = NL80211_IFTYPE_STATION;
7055 pAdapter->device_mode = session_type;
7056 status = hdd_register_interface( pAdapter, rtnl_held );
Madan Mohan Koyyalamudif89ac9f2013-09-19 16:58:12 +05307057
7058 hdd_init_tx_rx( pAdapter );
7059
7060 //Stop the Interface TX queue.
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05307061 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Madan Mohan Koyyalamudif89ac9f2013-09-19 16:58:12 +05307062 netif_tx_disable(pAdapter->dev);
7063 netif_carrier_off(pAdapter->dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07007064 }
7065 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 default:
7067 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307068 hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d",
7069 __func__, session_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 VOS_ASSERT(0);
7071 return NULL;
7072 }
7073 }
7074
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 if( VOS_STATUS_SUCCESS == status )
7076 {
7077 //Add it to the hdd's session list.
7078 pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) );
7079 if( NULL == pHddAdapterNode )
7080 {
7081 status = VOS_STATUS_E_NOMEM;
7082 }
7083 else
7084 {
7085 pHddAdapterNode->pAdapter = pAdapter;
7086 status = hdd_add_adapter_back ( pHddCtx,
7087 pHddAdapterNode );
7088 }
7089 }
7090
7091 if( VOS_STATUS_SUCCESS != status )
7092 {
7093 if( NULL != pAdapter )
7094 {
7095 hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held );
7096 pAdapter = NULL;
7097 }
7098 if( NULL != pHddAdapterNode )
7099 {
7100 vos_mem_free( pHddAdapterNode );
7101 }
7102
7103 goto resume_bmps;
7104 }
7105
7106 if(VOS_STATUS_SUCCESS == status)
7107 {
7108 wlan_hdd_set_concurrency_mode(pHddCtx, session_type);
7109
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007110 //Initialize the WoWL service
7111 if(!hdd_init_wowl(pAdapter))
7112 {
7113 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__);
7114 goto err_free_netdev;
7115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 return pAdapter;
7118
7119err_free_netdev:
7120 free_netdev(pAdapter->dev);
7121 wlan_hdd_release_intf_addr( pHddCtx,
7122 pAdapter->macAddressCurrent.bytes );
7123
7124resume_bmps:
7125 //If bmps disabled enable it
7126 if(VOS_STATUS_SUCCESS == exitbmpsStatus)
7127 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307128 if (pHddCtx->hdd_wlan_suspended)
7129 {
7130 hdd_set_pwrparams(pHddCtx);
7131 }
7132 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 }
7134 return NULL;
7135}
7136
7137VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
7138 tANI_U8 rtnl_held )
7139{
7140 hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext;
7141 VOS_STATUS status;
7142
7143 status = hdd_get_front_adapter ( pHddCtx, &pCurrent );
7144 if( VOS_STATUS_SUCCESS != status )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307145 {
7146 hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d",
7147 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007150
7151 while ( pCurrent->pAdapter != pAdapter )
7152 {
7153 status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext );
7154 if( VOS_STATUS_SUCCESS != status )
7155 break;
7156
7157 pCurrent = pNext;
7158 }
7159 pAdapterNode = pCurrent;
7160 if( VOS_STATUS_SUCCESS == status )
7161 {
7162 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
7163 hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307164
7165#ifdef FEATURE_WLAN_TDLS
7166
7167 /* A Mutex Lock is introduced while changing/initializing the mode to
7168 * protect the concurrent access for the Adapters by TDLS module.
7169 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05307170 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307171#endif
7172
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 hdd_remove_adapter( pHddCtx, pAdapterNode );
7174 vos_mem_free( pAdapterNode );
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08007175 pAdapterNode = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007176
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307177#ifdef FEATURE_WLAN_TDLS
7178 mutex_unlock(&pHddCtx->tdls_lock);
7179#endif
7180
Jeff Johnson295189b2012-06-20 16:38:30 -07007181
7182 /* If there is a single session of STA/P2P client, re-enable BMPS */
Agarwal Ashish51325b52014-06-16 16:50:49 +05307183 if ((!vos_concurrent_open_sessions_running()) &&
7184 ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) ||
7185 (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05307187 if (pHddCtx->hdd_wlan_suspended)
7188 {
7189 hdd_set_pwrparams(pHddCtx);
7190 }
7191 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 }
7193
7194 return VOS_STATUS_SUCCESS;
7195 }
7196
7197 return VOS_STATUS_E_FAILURE;
7198}
7199
7200VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx )
7201{
7202 hdd_adapter_list_node_t *pHddAdapterNode;
7203 VOS_STATUS status;
7204
7205 ENTER();
7206
7207 do
7208 {
7209 status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode );
7210 if( pHddAdapterNode && VOS_STATUS_SUCCESS == status )
7211 {
7212 hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE );
7213 vos_mem_free( pHddAdapterNode );
7214 }
7215 }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status );
7216
7217 EXIT();
7218
7219 return VOS_STATUS_SUCCESS;
7220}
7221
7222void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter)
7223{
7224 v_U8_t addIE[1] = {0};
7225
7226 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7227 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL,
7228 eANI_BOOLEAN_FALSE) )
7229 {
7230 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007231 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 }
7233
7234 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7235 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
7236 eANI_BOOLEAN_FALSE) )
7237 {
7238 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007239 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 }
7241
7242 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7243 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
7244 eANI_BOOLEAN_FALSE) )
7245 {
7246 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007247 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 }
7249}
7250
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307251VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
7252 const v_BOOL_t bCloseSession )
Jeff Johnson295189b2012-06-20 16:38:30 -07007253{
7254 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7255 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307256 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 union iwreq_data wrqu;
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307258 v_U8_t retry = 0;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307259 long ret;
Nirav Shah7e3c8132015-06-22 23:51:42 +05307260 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007261
Anand N Sunkad26d71b92014-12-24 18:08:22 +05307262 if (pHddCtx->isLogpInProgress) {
7263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7264 "%s:LOGP in Progress. Ignore!!!",__func__);
7265 return VOS_STATUS_E_FAILURE;
7266 }
7267
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 ENTER();
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307269
Bhargav Shah784e6a52015-07-22 16:52:35 +05307270 if ( VOS_TRUE == bCloseSession )
7271 {
7272 status = hdd_sta_id_hash_detach(pAdapter);
7273 if (status != VOS_STATUS_SUCCESS)
7274 hddLog(VOS_TRACE_LEVEL_ERROR,
7275 FL("sta id hash detach failed"));
7276 }
Nirav Shah7e3c8132015-06-22 23:51:42 +05307277
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307278 pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 switch(pAdapter->device_mode)
7280 {
7281 case WLAN_HDD_INFRA_STATION:
7282 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007283 case WLAN_HDD_P2P_DEVICE:
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307284 {
7285 hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagare4d05d42015-07-02 16:17:20 +05307286#ifdef FEATURE_WLAN_TDLS
7287 mutex_lock(&pHddCtx->tdls_lock);
7288 wlan_hdd_tdls_exit(pAdapter, TRUE);
7289 mutex_unlock(&pHddCtx->tdls_lock);
7290#endif
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307291 if( hdd_connIsConnected(pstation) ||
7292 (pstation->conn_info.connState == eConnectionState_Connecting) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 {
7294 if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS)
7295 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
7296 pAdapter->sessionId,
7297 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
7298 else
7299 halStatus = sme_RoamDisconnect(pHddCtx->hHal,
7300 pAdapter->sessionId,
7301 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7302 //success implies disconnect command got queued up successfully
7303 if(halStatus == eHAL_STATUS_SUCCESS)
7304 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307305 ret = wait_for_completion_interruptible_timeout(
7306 &pAdapter->disconnect_comp_var,
7307 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7308 if (ret <= 0)
7309 {
7310 hddLog(VOS_TRACE_LEVEL_ERROR,
7311 "%s: wait on disconnect_comp_var failed %ld",
7312 __func__, ret);
7313 }
7314 }
7315 else
7316 {
7317 hddLog(LOGE, "%s: failed to post disconnect event to SME",
7318 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007319 }
7320 memset(&wrqu, '\0', sizeof(wrqu));
7321 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7322 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7323 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
7324 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307325 else if(pstation->conn_info.connState ==
7326 eConnectionState_Disconnecting)
7327 {
7328 ret = wait_for_completion_interruptible_timeout(
7329 &pAdapter->disconnect_comp_var,
7330 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7331 if (ret <= 0)
7332 {
7333 hddLog(VOS_TRACE_LEVEL_ERROR,
7334 FL("wait on disconnect_comp_var failed %ld"), ret);
7335 }
7336 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307337 else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending)
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 {
Kaushik, Sushant4975a572014-10-21 16:07:48 +05307339 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307340 eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307342 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
7343 {
7344 while (pAdapter->is_roc_inprogress)
7345 {
7346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7347 "%s: ROC in progress for session %d!!!",
7348 __func__, pAdapter->sessionId);
7349 // waiting for ROC to expire
7350 msleep(500);
7351 /* In GO present case , if retry exceeds 3,
7352 it means something went wrong. */
7353 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION )
7354 {
7355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7356 "%s: ROC completion is not received.!!!", __func__);
Deepthi Gowri70498252015-01-20 15:56:45 +05307357 if (eHAL_STATUS_SUCCESS !=
7358 sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter),
7359 pAdapter->sessionId ))
7360 {
7361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7362 FL("Failed to Cancel Remain on Channel"));
7363 }
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307364 wait_for_completion_interruptible_timeout(
7365 &pAdapter->cancel_rem_on_chan_var,
7366 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
7367 break;
7368 }
7369 }
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307370 vos_flush_delayed_work(&pAdapter->roc_work);
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307371 }
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05307372#ifdef WLAN_NS_OFFLOAD
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307373 vos_flush_work(&pAdapter->ipv6NotifierWorkQueue);
Vinay Krishna Erannad5b2be22013-12-01 17:00:15 +05307374#endif
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307375
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307376 vos_flush_work(&pAdapter->ipv4NotifierWorkQueue);
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05307377
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307378 /* It is possible that the caller of this function does not
7379 * wish to close the session
7380 */
7381 if (VOS_TRUE == bCloseSession &&
7382 test_bit(SME_SESSION_OPENED, &pAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 {
7384 INIT_COMPLETION(pAdapter->session_close_comp_var);
7385 if (eHAL_STATUS_SUCCESS ==
mukul sharmabab477d2015-06-11 17:14:55 +05307386 sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, VOS_FALSE,
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307387 hdd_smeCloseSessionCallback, pAdapter))
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307389 unsigned long ret;
7390
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 //Block on a completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307392 ret = wait_for_completion_timeout(
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307393 &pAdapter->session_close_comp_var,
7394 msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307395 if ( 0 >= ret)
7396 {
7397 hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld",
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307398 __func__, ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 }
7401 }
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05307402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 break;
7404
7405 case WLAN_HDD_SOFTAP:
7406 case WLAN_HDD_P2P_GO:
7407 //Any softap specific cleanup here...
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307408 if (pAdapter->device_mode == WLAN_HDD_P2P_GO) {
7409 while (pAdapter->is_roc_inprogress) {
7410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7411 "%s: ROC in progress for session %d!!!",
7412 __func__, pAdapter->sessionId);
7413 msleep(500);
7414 if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) {
7415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7416 "%s: ROC completion is not received.!!!", __func__);
7417 WLANSAP_CancelRemainOnChannel(
7418 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
7419 wait_for_completion_interruptible_timeout(
7420 &pAdapter->cancel_rem_on_chan_var,
7421 msecs_to_jiffies(WAIT_CANCEL_REM_CHAN));
7422 break;
7423 }
7424 }
Ganesh Kondabattinibabfb492014-12-17 20:25:29 +05307425
Anand N Sunkaddc63c792015-06-03 14:33:24 +05307426 vos_flush_delayed_work(&pAdapter->roc_work);
Kaushik, Sushant7005e372014-04-08 11:36:54 +05307427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 mutex_lock(&pHddCtx->sap_lock);
7429 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7430 {
7431 VOS_STATUS status;
7432 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7433
7434 //Stop Bss.
7435 status = WLANSAP_StopBss(pHddCtx->pvosContext);
7436 if (VOS_IS_STATUS_SUCCESS(status))
7437 {
7438 hdd_hostapd_state_t *pHostapdState =
7439 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7440
7441 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7442
7443 if (!VOS_IS_STATUS_SUCCESS(status))
7444 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307445 hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d",
7446 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 }
7448 }
7449 else
7450 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007451 hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 }
7453 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307454 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007455
7456 if (eHAL_STATUS_FAILURE ==
7457 ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG,
7458 0, NULL, eANI_BOOLEAN_FALSE))
7459 {
7460 hddLog(LOGE,
7461 "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007462 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 }
7464
7465 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7466 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7467 eANI_BOOLEAN_FALSE) )
7468 {
7469 hddLog(LOGE,
7470 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
7471 }
7472
7473 // Reset WNI_CFG_PROBE_RSP Flags
7474 wlan_hdd_reset_prob_rspies(pAdapter);
7475 kfree(pAdapter->sessionCtx.ap.beacon);
7476 pAdapter->sessionCtx.ap.beacon = NULL;
7477 }
7478 mutex_unlock(&pHddCtx->sap_lock);
7479 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007480
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 case WLAN_HDD_MONITOR:
7482 break;
Sameer Thalappilbee426e2013-10-30 10:30:30 -07007483
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 default:
7485 break;
7486 }
7487
7488 EXIT();
7489 return VOS_STATUS_SUCCESS;
7490}
7491
7492VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx )
7493{
7494 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7495 VOS_STATUS status;
7496 hdd_adapter_t *pAdapter;
7497
7498 ENTER();
7499
7500 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7501
7502 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7503 {
7504 pAdapter = pAdapterNode->pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07007505
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307506 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07007507
7508 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7509 pAdapterNode = pNext;
7510 }
7511
7512 EXIT();
7513
7514 return VOS_STATUS_SUCCESS;
7515}
7516
Rajeev Kumarf999e582014-01-09 17:33:29 -08007517
7518#ifdef FEATURE_WLAN_BATCH_SCAN
7519/**---------------------------------------------------------------------------
7520
7521 \brief hdd_deinit_batch_scan () - This function cleans up batch scan data
7522 structures
7523
7524 \param - pAdapter Pointer to HDD adapter
7525
7526 \return - None
7527
7528 --------------------------------------------------------------------------*/
7529void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter)
7530{
7531 tHddBatchScanRsp *pNode;
7532 tHddBatchScanRsp *pPrev;
7533
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307534 if (NULL == pAdapter)
Rajeev Kumarf999e582014-01-09 17:33:29 -08007535 {
Siddharth Bhalb3e9b792014-02-24 15:14:16 +05307536 hddLog(VOS_TRACE_LEVEL_ERROR,
7537 "%s: Adapter context is Null", __func__);
7538 return;
7539 }
7540
7541 pNode = pAdapter->pBatchScanRsp;
7542 while (pNode)
7543 {
7544 pPrev = pNode;
7545 pNode = pNode->pNext;
7546 vos_mem_free((v_VOID_t * )pPrev);
Rajeev Kumarf999e582014-01-09 17:33:29 -08007547 }
7548
7549 pAdapter->pBatchScanRsp = NULL;
7550 pAdapter->numScanList = 0;
7551 pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED;
7552 pAdapter->prev_batch_id = 0;
7553
7554 return;
7555}
7556#endif
7557
7558
Jeff Johnson295189b2012-06-20 16:38:30 -07007559VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx )
7560{
7561 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7562 VOS_STATUS status;
7563 hdd_adapter_t *pAdapter;
7564
7565 ENTER();
7566
7567 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7568
7569 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7570 {
7571 pAdapter = pAdapterNode->pAdapter;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05307572 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 netif_tx_disable(pAdapter->dev);
7574 netif_carrier_off(pAdapter->dev);
7575
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007576 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
7577
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 hdd_deinit_tx_rx(pAdapter);
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307579
Katya Nigam1fd24402015-02-16 14:52:19 +05307580 if(pAdapter->device_mode == WLAN_HDD_IBSS )
7581 hdd_ibss_deinit_tx_rx(pAdapter);
7582
Nirav Shah7e3c8132015-06-22 23:51:42 +05307583 status = hdd_sta_id_hash_detach(pAdapter);
7584 if (status != VOS_STATUS_SUCCESS)
7585 hddLog(VOS_TRACE_LEVEL_ERROR,
7586 FL("sta id hash detach failed for session id %d"),
7587 pAdapter->sessionId);
7588
Agarwal Ashish6267caa2014-08-06 19:16:21 +05307589 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
7590
Madan Mohan Koyyalamudi8c6dec82013-09-26 15:56:13 +05307591 if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags))
7592 {
7593 hdd_wmm_adapter_close( pAdapter );
7594 clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
7595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007596
Siddharth Bhal2db319d2014-12-03 12:37:18 +05307597 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7598 {
7599 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
7600 }
7601
Rajeev Kumarf999e582014-01-09 17:33:29 -08007602#ifdef FEATURE_WLAN_BATCH_SCAN
7603 if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState)
7604 {
7605 hdd_deinit_batch_scan(pAdapter);
7606 }
7607#endif
7608
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05307609#ifdef FEATURE_WLAN_TDLS
7610 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETI2d4d5c42015-03-03 14:34:19 +05307611 wlan_hdd_tdls_exit(pAdapter, TRUE);
Mahesh A Saptasagarf5b8eff2015-01-31 01:07:07 +05307612 mutex_unlock(&pHddCtx->tdls_lock);
7613#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7615 pAdapterNode = pNext;
7616 }
7617
7618 EXIT();
7619
7620 return VOS_STATUS_SUCCESS;
7621}
7622
7623VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx )
7624{
7625 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7626 VOS_STATUS status;
7627 hdd_adapter_t *pAdapter;
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307628 eConnectionState connState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007629
7630 ENTER();
7631
7632 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7633
7634 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7635 {
7636 pAdapter = pAdapterNode->pAdapter;
7637
Kumar Anand82c009f2014-05-29 00:29:42 -07007638 hdd_wmm_init( pAdapter );
7639
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 switch(pAdapter->device_mode)
7641 {
7642 case WLAN_HDD_INFRA_STATION:
7643 case WLAN_HDD_P2P_CLIENT:
Jeff Johnsone7245742012-09-05 17:12:55 -07007644 case WLAN_HDD_P2P_DEVICE:
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307645
7646 connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState;
7647
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 hdd_init_station_mode(pAdapter);
7649 /* Open the gates for HDD to receive Wext commands */
7650 pAdapter->isLinkUpSvcNeeded = FALSE;
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007651 pHddCtx->scan_info.mScanPending = FALSE;
7652 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007653
7654 //Trigger the initial scan
7655 hdd_wlan_initial_scan(pAdapter);
7656
7657 //Indicate disconnect event to supplicant if associated previously
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307658 if (eConnectionState_Associated == connState ||
7659 eConnectionState_IbssConnected == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 {
7661 union iwreq_data wrqu;
7662 memset(&wrqu, '\0', sizeof(wrqu));
7663 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
7664 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
7665 wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07007666 pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007667
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 /* indicate disconnected event to nl80211 */
7669 cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED,
7670 NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 }
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307672 else if (eConnectionState_Connecting == connState)
7673 {
7674 /*
7675 * Indicate connect failure to supplicant if we were in the
7676 * process of connecting
7677 */
7678 cfg80211_connect_result(pAdapter->dev, NULL,
7679 NULL, 0, NULL, 0,
7680 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
7681 GFP_KERNEL);
7682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 break;
7684
7685 case WLAN_HDD_SOFTAP:
7686 /* softAP can handle SSR */
7687 break;
7688
7689 case WLAN_HDD_P2P_GO:
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007690 hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant",
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 __func__);
Sameer Thalappiledf0d792013-08-09 14:31:03 -07007692 cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 break;
7694
7695 case WLAN_HDD_MONITOR:
7696 /* monitor interface start */
7697 break;
7698 default:
7699 break;
7700 }
7701
7702 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7703 pAdapterNode = pNext;
7704 }
7705
7706 EXIT();
7707
7708 return VOS_STATUS_SUCCESS;
7709}
7710
7711VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx )
7712{
7713 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7714 hdd_adapter_t *pAdapter;
7715 VOS_STATUS status;
7716 v_U32_t roamId;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307717 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007718
7719 ENTER();
7720
7721 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7722
7723 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7724 {
7725 pAdapter = pAdapterNode->pAdapter;
7726
7727 if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
7728 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
7729 {
7730 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7731 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7732
Abhishek Singhf4669da2014-05-26 15:07:49 +05307733 hddLog(VOS_TRACE_LEVEL_INFO,
7734 "%s: Set HDD connState to eConnectionState_NotConnected",
7735 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7737 init_completion(&pAdapter->disconnect_comp_var);
7738 sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId,
7739 eCSR_DISCONNECT_REASON_UNSPECIFIED);
7740
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307741 ret = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 &pAdapter->disconnect_comp_var,
7743 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307744 if (0 >= ret)
7745 hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld",
7746 __func__, ret);
Jeff Johnson295189b2012-06-20 16:38:30 -07007747
7748 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
7749 pHddCtx->isAmpAllowed = VOS_FALSE;
7750 sme_RoamConnect(pHddCtx->hHal,
7751 pAdapter->sessionId, &(pWextState->roamProfile),
7752 &roamId);
7753 }
7754
7755 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7756 pAdapterNode = pNext;
7757 }
7758
7759 EXIT();
7760
7761 return VOS_STATUS_SUCCESS;
7762}
7763
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07007764void hdd_dump_concurrency_info(hdd_context_t *pHddCtx)
7765{
7766 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7767 VOS_STATUS status;
7768 hdd_adapter_t *pAdapter;
7769 hdd_station_ctx_t *pHddStaCtx;
7770 hdd_ap_ctx_t *pHddApCtx;
7771 hdd_hostapd_state_t * pHostapdState;
7772 tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 };
7773 v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0;
7774 const char *p2pMode = "DEV";
7775 const char *ccMode = "Standalone";
7776 int n;
7777
7778 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7779 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7780 {
7781 pAdapter = pAdapterNode->pAdapter;
7782 switch (pAdapter->device_mode) {
7783 case WLAN_HDD_INFRA_STATION:
7784 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7785 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7786 staChannel = pHddStaCtx->conn_info.operationChannel;
7787 memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid));
7788 }
7789 break;
7790 case WLAN_HDD_P2P_CLIENT:
7791 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7792 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
7793 p2pChannel = pHddStaCtx->conn_info.operationChannel;
7794 memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid));
7795 p2pMode = "CLI";
7796 }
7797 break;
7798 case WLAN_HDD_P2P_GO:
7799 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7800 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7801 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7802 p2pChannel = pHddApCtx->operatingChannel;
7803 memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid));
7804 }
7805 p2pMode = "GO";
7806 break;
7807 case WLAN_HDD_SOFTAP:
7808 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7809 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7810 if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) {
7811 apChannel = pHddApCtx->operatingChannel;
7812 memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid));
7813 }
7814 break;
7815 default:
7816 break;
7817 }
7818 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7819 pAdapterNode = pNext;
7820 }
7821 if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) {
7822 ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC";
7823 }
7824 n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s",
7825 staChannel, MAC_ADDR_ARRAY(staBssid), ccMode);
7826 if (p2pChannel > 0) {
7827 n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR,
7828 p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid));
7829 }
7830 if (apChannel > 0) {
7831 n += pr_info("AP(%d) " MAC_ADDRESS_STR,
7832 apChannel, MAC_ADDR_ARRAY(apBssid));
7833 }
7834
7835 if (p2pChannel > 0 && apChannel > 0) {
7836 hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel);
7837 }
7838}
7839
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007840bool hdd_is_ssr_required( void)
Jeff Johnson295189b2012-06-20 16:38:30 -07007841{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007842 return (isSsrRequired == HDD_SSR_REQUIRED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007843}
7844
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007845/* Once SSR is disabled then it cannot be set. */
7846void hdd_set_ssr_required( e_hdd_ssr_required value)
Jeff Johnson295189b2012-06-20 16:38:30 -07007847{
Madan Mohan Koyyalamudib5da5332012-10-15 17:23:21 -07007848 if (HDD_SSR_DISABLED == isSsrRequired)
7849 return;
7850
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 isSsrRequired = value;
7852}
7853
Hema Aparna Medicharla6b4d4f32015-06-23 04:09:12 +05307854void hdd_set_pre_close( hdd_context_t *pHddCtx)
7855{
7856 sme_PreClose(pHddCtx->hHal);
7857}
7858
Jeff Johnson295189b2012-06-20 16:38:30 -07007859VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx,
7860 hdd_adapter_list_node_t** ppAdapterNode)
7861{
7862 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307863 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 status = hdd_list_peek_front ( &pHddCtx->hddAdapters,
7865 (hdd_list_node_t**) ppAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307866 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 return status;
7868}
7869
7870VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx,
7871 hdd_adapter_list_node_t* pAdapterNode,
7872 hdd_adapter_list_node_t** pNextAdapterNode)
7873{
7874 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307875 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 status = hdd_list_peek_next ( &pHddCtx->hddAdapters,
7877 (hdd_list_node_t*) pAdapterNode,
7878 (hdd_list_node_t**)pNextAdapterNode );
7879
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307880 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007881 return status;
7882}
7883
7884VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx,
7885 hdd_adapter_list_node_t* pAdapterNode)
7886{
7887 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307888 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 status = hdd_list_remove_node ( &pHddCtx->hddAdapters,
7890 &pAdapterNode->node );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307891 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 return status;
7893}
7894
7895VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx,
7896 hdd_adapter_list_node_t** ppAdapterNode)
7897{
7898 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307899 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 status = hdd_list_remove_front( &pHddCtx->hddAdapters,
7901 (hdd_list_node_t**) ppAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307902 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 return status;
7904}
7905
7906VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx,
7907 hdd_adapter_list_node_t* pAdapterNode)
7908{
7909 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307910 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 status = hdd_list_insert_back ( &pHddCtx->hddAdapters,
7912 (hdd_list_node_t*) pAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307913 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 return status;
7915}
7916
7917VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx,
7918 hdd_adapter_list_node_t* pAdapterNode)
7919{
7920 VOS_STATUS status;
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307921 spin_lock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 status = hdd_list_insert_front ( &pHddCtx->hddAdapters,
7923 (hdd_list_node_t*) pAdapterNode );
Mukul Sharmaae1266d2015-06-26 15:29:53 +05307924 spin_unlock_bh(&pHddCtx->hddAdapters.lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07007925 return status;
7926}
7927
7928hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx,
7929 tSirMacAddr macAddr )
7930{
7931 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7932 hdd_adapter_t *pAdapter;
7933 VOS_STATUS status;
7934
7935 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7936
7937 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7938 {
7939 pAdapter = pAdapterNode->pAdapter;
7940
7941 if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes,
7942 macAddr, sizeof(tSirMacAddr) ) )
7943 {
7944 return pAdapter;
7945 }
7946 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7947 pAdapterNode = pNext;
7948 }
7949
7950 return NULL;
7951
7952}
7953
7954hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name )
7955{
7956 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7957 hdd_adapter_t *pAdapter;
7958 VOS_STATUS status;
7959
7960 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7961
7962 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7963 {
7964 pAdapter = pAdapterNode->pAdapter;
7965
7966 if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name,
7967 IFNAMSIZ ) )
7968 {
7969 return pAdapter;
7970 }
7971 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7972 pAdapterNode = pNext;
7973 }
7974
7975 return NULL;
7976
7977}
7978
7979hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode )
7980{
7981 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
7982 hdd_adapter_t *pAdapter;
7983 VOS_STATUS status;
7984
7985 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
7986
7987 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
7988 {
7989 pAdapter = pAdapterNode->pAdapter;
7990
7991 if( pAdapter && (mode == pAdapter->device_mode) )
7992 {
7993 return pAdapter;
7994 }
7995 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
7996 pAdapterNode = pNext;
7997 }
7998
7999 return NULL;
8000
8001}
8002
8003//Remove this function later
8004hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx )
8005{
8006 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8007 hdd_adapter_t *pAdapter;
8008 VOS_STATUS status;
8009
8010 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8011
8012 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8013 {
8014 pAdapter = pAdapterNode->pAdapter;
8015
8016 if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode )
8017 {
8018 return pAdapter;
8019 }
8020
8021 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8022 pAdapterNode = pNext;
8023 }
8024
8025 return NULL;
8026
8027}
8028
Jeff Johnson295189b2012-06-20 16:38:30 -07008029/**---------------------------------------------------------------------------
8030
Mahesh A Saptasgar64534612014-09-23 13:13:33 +05308031 \brief hdd_get_operating_channel() -
Jeff Johnson295189b2012-06-20 16:38:30 -07008032
8033 This API returns the operating channel of the requested device mode
8034
8035 \param - pHddCtx - Pointer to the HDD context.
8036 - mode - Device mode for which operating channel is required
8037 suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT
8038 WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO.
8039 \return - channel number. "0" id the requested device is not found OR it is not connected.
8040 --------------------------------------------------------------------------*/
8041v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode )
8042{
8043 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8044 VOS_STATUS status;
8045 hdd_adapter_t *pAdapter;
8046 v_U8_t operatingChannel = 0;
8047
8048 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8049
8050 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8051 {
8052 pAdapter = pAdapterNode->pAdapter;
8053
8054 if( mode == pAdapter->device_mode )
8055 {
8056 switch(pAdapter->device_mode)
8057 {
8058 case WLAN_HDD_INFRA_STATION:
8059 case WLAN_HDD_P2P_CLIENT:
8060 if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) )
8061 operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel;
8062 break;
8063 case WLAN_HDD_SOFTAP:
8064 case WLAN_HDD_P2P_GO:
8065 /*softap connection info */
8066 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
8067 operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel;
8068 break;
8069 default:
8070 break;
8071 }
8072
8073 break; //Found the device of interest. break the loop
8074 }
8075
8076 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8077 pAdapterNode = pNext;
8078 }
8079 return operatingChannel;
8080}
8081
8082#ifdef WLAN_FEATURE_PACKET_FILTERING
8083/**---------------------------------------------------------------------------
8084
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308085 \brief __hdd_set_multicast_list() -
Jeff Johnson295189b2012-06-20 16:38:30 -07008086
8087 This used to set the multicast address list.
8088
8089 \param - dev - Pointer to the WLAN device.
8090 - skb - Pointer to OS packet (sk_buff).
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308091 \return - success/fail
Jeff Johnson295189b2012-06-20 16:38:30 -07008092
8093 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308094static void __hdd_set_multicast_list(struct net_device *dev)
Jeff Johnson295189b2012-06-20 16:38:30 -07008095{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308096 hdd_adapter_t *pAdapter;
8097 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 int mc_count;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308099 int i = 0, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 struct netdev_hw_addr *ha;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308102 ENTER();
8103
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308104 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308105 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 {
8107 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308108 "%s: Adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 return;
8110 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308111 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8112 ret = wlan_hdd_validate_context(pHddCtx);
8113 if (0 != ret)
8114 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308115 return;
8116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 if (dev->flags & IFF_ALLMULTI)
8118 {
8119 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008120 "%s: allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308121 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308123 else
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 {
8125 mc_count = netdev_mc_count(dev);
8126 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008127 "%s: mc_count = %u", __func__, mc_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07008128 if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST)
8129 {
8130 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008131 "%s: No free filter available; allow all multicast frames", __func__);
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308132 pAdapter->mc_addr_list.mc_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 return;
8134 }
8135
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308136 pAdapter->mc_addr_list.mc_cnt = mc_count;
Jeff Johnson295189b2012-06-20 16:38:30 -07008137
8138 netdev_for_each_mc_addr(ha, dev) {
8139 if (i == mc_count)
8140 break;
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308141 memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN);
8142 memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008143 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR,
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308144 __func__, i,
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308145 MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 i++;
8147 }
8148 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308149
8150 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 return;
8152}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308153
8154static void hdd_set_multicast_list(struct net_device *dev)
8155{
8156 vos_ssr_protect(__func__);
8157 __hdd_set_multicast_list(dev);
8158 vos_ssr_unprotect(__func__);
8159}
Jeff Johnson295189b2012-06-20 16:38:30 -07008160#endif
8161
8162/**---------------------------------------------------------------------------
8163
8164 \brief hdd_select_queue() -
8165
8166 This function is registered with the Linux OS for network
8167 core to decide which queue to use first.
8168
8169 \param - dev - Pointer to the WLAN device.
8170 - skb - Pointer to OS packet (sk_buff).
8171 \return - ac, Queue Index/access category corresponding to UP in IP header
8172
8173 --------------------------------------------------------------------------*/
8174v_U16_t hdd_select_queue(struct net_device *dev,
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05308175 struct sk_buff *skb
8176#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
8177 , void *accel_priv
8178#endif
8179#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
8180 , select_queue_fallback_t fallback
8181#endif
8182)
Jeff Johnson295189b2012-06-20 16:38:30 -07008183{
8184 return hdd_wmm_select_queue(dev, skb);
8185}
8186
8187
8188/**---------------------------------------------------------------------------
8189
8190 \brief hdd_wlan_initial_scan() -
8191
8192 This function triggers the initial scan
8193
8194 \param - pAdapter - Pointer to the HDD adapter.
8195
8196 --------------------------------------------------------------------------*/
8197void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter)
8198{
8199 tCsrScanRequest scanReq;
8200 tCsrChannelInfo channelInfo;
8201 eHalStatus halStatus;
Jeff Johnson02797792013-10-26 19:17:13 -07008202 tANI_U32 scanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8204
8205 vos_mem_zero(&scanReq, sizeof(tCsrScanRequest));
8206 vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff);
8207 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
8208
8209 if(sme_Is11dSupported(pHddCtx->hHal))
8210 {
8211 halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo );
8212 if ( HAL_STATUS_SUCCESS( halStatus ) )
8213 {
8214 scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels);
8215 if( !scanReq.ChannelInfo.ChannelList )
8216 {
8217 hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__);
8218 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08008219 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 return;
8221 }
8222 vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList,
8223 channelInfo.numOfChannels);
8224 scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels;
8225 vos_mem_free(channelInfo.ChannelList);
Srinivas Girigowda8d2348f2013-12-12 12:14:15 -08008226 channelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 }
8228
8229 scanReq.scanType = eSIR_PASSIVE_SCAN;
8230 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
8231 scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime;
8232 scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime;
8233 }
8234 else
8235 {
8236 scanReq.scanType = eSIR_ACTIVE_SCAN;
8237 scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
8238 scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime;
8239 scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime;
8240 }
8241
8242 halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL);
8243 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8244 {
8245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d",
8246 __func__, halStatus );
8247 }
8248
8249 if(sme_Is11dSupported(pHddCtx->hHal))
8250 vos_mem_free(scanReq.ChannelInfo.ChannelList);
8251}
8252
mukul sharmabab477d2015-06-11 17:14:55 +05308253void hdd_purge_cmd_list_all_adapters( hdd_context_t *pHddCtx )
8254{
8255 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8256 VOS_STATUS status;
8257 hdd_adapter_t *pAdapter;
8258
8259 ENTER();
8260
8261 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8262
8263 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8264 {
8265 pAdapter = pAdapterNode->pAdapter;
8266
8267 status = sme_PurgeCmdList(pHddCtx->hHal, pAdapter->sessionId);
8268 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8269 pAdapterNode = pNext;
8270 }
8271
8272 EXIT();
8273}
Jeff Johnson295189b2012-06-20 16:38:30 -07008274/**---------------------------------------------------------------------------
8275
8276 \brief hdd_full_power_callback() - HDD full power callback function
8277
8278 This is the function invoked by SME to inform the result of a full power
8279 request issued by HDD
8280
8281 \param - callbackcontext - Pointer to cookie
8282 \param - status - result of request
8283
8284 \return - None
8285
8286 --------------------------------------------------------------------------*/
8287static void hdd_full_power_callback(void *callbackContext, eHalStatus status)
8288{
Jeff Johnson72a40512013-12-19 10:14:15 -08008289 struct statsContext *pContext = callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008290
8291 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308292 "%s: context = %p, status = %d", __func__, pContext, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008293
8294 if (NULL == callbackContext)
8295 {
8296 hddLog(VOS_TRACE_LEVEL_ERROR,
8297 "%s: Bad param, context [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008298 __func__, callbackContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 return;
8300 }
8301
Jeff Johnson72a40512013-12-19 10:14:15 -08008302 /* there is a race condition that exists between this callback
8303 function and the caller since the caller could time out either
8304 before or while this code is executing. we use a spinlock to
8305 serialize these actions */
8306 spin_lock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307
8308 if (POWER_CONTEXT_MAGIC != pContext->magic)
8309 {
8310 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08008311 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 hddLog(VOS_TRACE_LEVEL_WARN,
8313 "%s: Invalid context, magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008314 __func__, pContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07008315 return;
8316 }
8317
Jeff Johnson72a40512013-12-19 10:14:15 -08008318 /* context is valid so caller is still waiting */
8319
8320 /* paranoia: invalidate the magic */
8321 pContext->magic = 0;
8322
8323 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 complete(&pContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08008325
8326 /* serialization is complete */
8327 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008328}
8329
Katya Nigamf0511f62015-05-05 16:40:57 +05308330void wlan_hdd_mon_set_typesubtype( hdd_mon_ctx_t *pMonCtx,int type)
8331{
8332 pMonCtx->typeSubtypeBitmap = 0;
8333 if( type%10 ) /* Management Packets */
8334 pMonCtx->typeSubtypeBitmap |= 0xFFFF;
8335 type/=10;
8336 if( type%10 ) /* Control Packets */
8337 pMonCtx->typeSubtypeBitmap |= 0xFFFF0000;
8338 type/=10;
8339 if( type%10 ) /* Data Packets */
8340 pMonCtx->typeSubtypeBitmap |= 0xFFFF00000000;
8341}
8342
8343VOS_STATUS wlan_hdd_mon_poststartmsg( hdd_mon_ctx_t *pMonCtx )
8344{
8345 vos_msg_t monMsg;
8346
8347 monMsg.type = WDA_MON_START_REQ;
8348 monMsg.reserved = 0;
8349 monMsg.bodyptr = (v_U8_t*)pMonCtx;
8350 monMsg.bodyval = 0;
8351
8352 if (VOS_STATUS_SUCCESS != vos_mq_post_message(
8353 VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) {
8354 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__);
8355 return VOS_STATUS_E_FAILURE;
8356 }
8357
8358 return VOS_STATUS_SUCCESS;
8359}
8360
8361void wlan_hdd_mon_poststopmsg(void)
8362{
8363 vos_msg_t monMsg;
8364
8365 monMsg.type = WDA_MON_STOP_REQ;
8366 monMsg.reserved = 0;
8367 monMsg.bodyptr = NULL;
8368 monMsg.bodyval = 0;
8369
8370 if (VOS_STATUS_SUCCESS != vos_mq_post_message(
8371 VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) {
8372 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__);
8373 }
8374}
8375
Katya Nigame7b69a82015-04-28 15:24:06 +05308376void wlan_hdd_mon_close(hdd_context_t *pHddCtx)
8377{
8378 VOS_STATUS vosStatus;
8379 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
8380 struct wiphy *wiphy = pHddCtx->wiphy;
8381
8382 hdd_adapter_t *pAdapter = hdd_get_adapter(pHddCtx,WLAN_HDD_MONITOR);
8383 if(pAdapter == NULL || pVosContext == NULL)
8384 {
8385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:pAdapter is NULL",__func__);
8386 return ;
8387 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308388
8389 wlan_hdd_mon_poststopmsg();
Katya Nigame7b69a82015-04-28 15:24:06 +05308390 hdd_UnregisterWext(pAdapter->dev);
8391
8392 vos_mon_stop( pVosContext );
8393
8394 vosStatus = vos_sched_close( pVosContext );
8395 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8396 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8397 "%s: Failed to close VOSS Scheduler",__func__);
8398 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8399 }
8400
8401 vosStatus = vos_nv_close();
8402 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8403 {
8404 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8405 "%s: Failed to close NV", __func__);
8406 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8407 }
8408
8409 vos_close(pVosContext);
8410
8411 #ifdef WLAN_KD_READY_NOTIFIER
8412 nl_srv_exit(pHddCtx->ptt_pid);
8413 #else
8414 nl_srv_exit();
8415 #endif
8416
8417 if (pHddCtx->cfg_ini)
8418 {
8419 kfree(pHddCtx->cfg_ini);
8420 pHddCtx->cfg_ini= NULL;
8421 }
8422 hdd_close_all_adapters( pHddCtx );
8423
8424 wiphy_free(wiphy) ;
8425
8426}
Jeff Johnson295189b2012-06-20 16:38:30 -07008427/**---------------------------------------------------------------------------
8428
8429 \brief hdd_wlan_exit() - HDD WLAN exit function
8430
8431 This is the driver exit point (invoked during rmmod)
8432
8433 \param - pHddCtx - Pointer to the HDD Context
8434
8435 \return - None
8436
8437 --------------------------------------------------------------------------*/
8438void hdd_wlan_exit(hdd_context_t *pHddCtx)
8439{
8440 eHalStatus halStatus;
8441 v_CONTEXT_t pVosContext = pHddCtx->pvosContext;
8442 VOS_STATUS vosStatus;
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05308443 struct wiphy *wiphy = pHddCtx->wiphy;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008444 hdd_adapter_t* pAdapter = NULL;
Jeff Johnson72a40512013-12-19 10:14:15 -08008445 struct statsContext powerContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 long lrc;
c_hpothu5ab05e92014-06-13 17:34:05 +05308447 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008448
8449 ENTER();
8450
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +05308451
Katya Nigame7b69a82015-04-28 15:24:06 +05308452 if (VOS_MONITOR_MODE == hdd_get_conparam())
8453 {
8454 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: MONITOR MODE",__func__);
8455 wlan_hdd_mon_close(pHddCtx);
8456 return;
8457 }
8458 else if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson88ba7742013-02-27 14:36:02 -08008459 {
8460 // Unloading, restart logic is no more required.
8461 wlan_hdd_restart_deinit(pHddCtx);
Jeff Johnsone7245742012-09-05 17:12:55 -07008462
Agarwal Ashishb20e0ff2014-12-17 22:50:19 +05308463#ifdef FEATURE_WLAN_TDLS
8464 /* At the time of driver unloading; if tdls connection is present;
8465 * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer.
8466 * wlan_hdd_tdls_find_peer always checks for valid context;
8467 * as load/unload in progress there can be a race condition.
8468 * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only
8469 * when tdls state is enabled.
8470 * As soon as driver set load/unload flag; tdls flag also needs
8471 * to be disabled so that hdd_rx_packet_cbk won't call
8472 * wlan_hdd_tdls_find_peer.
8473 */
8474 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE);
8475#endif
8476
c_hpothu5ab05e92014-06-13 17:34:05 +05308477 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8478 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 {
c_hpothu5ab05e92014-06-13 17:34:05 +05308480 pAdapter = pAdapterNode->pAdapter;
8481 if (NULL != pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 {
Mahesh A Saptasagar305e2632015-03-04 12:57:33 +05308483 /* Disable TX on the interface, after this hard_start_xmit() will
8484 * not be called on that interface
8485 */
8486 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
8487 netif_tx_disable(pAdapter->dev);
8488
8489 /* Mark the interface status as "down" for outside world */
8490 netif_carrier_off(pAdapter->dev);
8491
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05308492 /* DeInit the adapter. This ensures that all data packets
8493 * are freed.
8494 */
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05308495#ifdef FEATURE_WLAN_TDLS
8496 mutex_lock(&pHddCtx->tdls_lock);
8497#endif
c_hpothu002231a2015-02-05 14:58:51 +05308498 hdd_deinit_adapter(pHddCtx, pAdapter, FALSE);
Mahesh A Saptasagar02e36e82015-01-14 20:39:19 +05308499#ifdef FEATURE_WLAN_TDLS
8500 mutex_unlock(&pHddCtx->tdls_lock);
8501#endif
Agarwal Ashish9ffa5b92014-11-18 21:07:02 +05308502
c_hpothu5ab05e92014-06-13 17:34:05 +05308503 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
8504 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
8505 {
8506 wlan_hdd_cfg80211_deregister_frames(pAdapter);
8507 hdd_UnregisterWext(pAdapter->dev);
8508 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308509
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 }
c_hpothu5ab05e92014-06-13 17:34:05 +05308511 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8512 pAdapterNode = pNext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 }
mukul sharmabab477d2015-06-11 17:14:55 +05308514
8515 //Purge all sme cmd's for all interface
8516 hdd_purge_cmd_list_all_adapters(pHddCtx);
8517
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308518 // Cancel any outstanding scan requests. We are about to close all
8519 // of our adapters, but an adapter structure is what SME passes back
8520 // to our callback function. Hence if there are any outstanding scan
8521 // requests then there is a race condition between when the adapter
8522 // is closed and when the callback is invoked.We try to resolve that
8523 // race condition here by canceling any outstanding scans before we
8524 // close the adapters.
8525 // Note that the scans may be cancelled in an asynchronous manner,
8526 // so ideally there needs to be some kind of synchronization. Rather
8527 // than introduce a new synchronization here, we will utilize the
8528 // fact that we are about to Request Full Power, and since that is
8529 // synchronized, the expectation is that by the time Request Full
8530 // Power has completed all scans will be cancelled.
8531 if (pHddCtx->scan_info.mScanPending)
8532 {
Hema Aparna Medicharlaf05f6cd2015-01-21 14:44:19 +05308533 if(NULL != pAdapter)
8534 {
8535 hddLog(VOS_TRACE_LEVEL_INFO,
8536 FL("abort scan mode: %d sessionId: %d"),
8537 pAdapter->device_mode,
8538 pAdapter->sessionId);
8539 }
8540 hdd_abort_mac_scan(pHddCtx,
8541 pHddCtx->scan_info.sessionId,
8542 eCSR_SCAN_ABORT_DEFAULT);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 }
c_hpothu5ab05e92014-06-13 17:34:05 +05308545 else
Jeff Johnson88ba7742013-02-27 14:36:02 -08008546 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308547 hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__);
Hanumantha Reddy Pothula45af96b2015-02-12 16:07:58 +05308548 if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING)
8549 {
8550 INIT_COMPLETION(pHddCtx->ftm.startCmpVar);
8551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8552 "%s: in middle of FTM START", __func__);
8553 lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar,
8554 msecs_to_jiffies(20000));
8555 if(!lrc)
8556 {
8557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8558 "%s: timedout on ftmStartCmpVar fatal error", __func__);
8559 }
8560 }
Jeff Johnson88ba7742013-02-27 14:36:02 -08008561 wlan_hdd_ftm_close(pHddCtx);
8562 goto free_hdd_ctx;
8563 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308564
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 /* DeRegister with platform driver as client for Suspend/Resume */
8566 vosStatus = hddDeregisterPmOps(pHddCtx);
8567 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
8568 {
8569 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__);
8570 VOS_ASSERT(0);
8571 }
8572
8573 vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx);
8574 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
8575 {
8576 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
8577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008578
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07008579 //Stop the traffic monitor timer
8580 if ( VOS_TIMER_STATE_RUNNING ==
8581 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))
8582 {
8583 vos_timer_stop(&pHddCtx->tx_rx_trafficTmr);
8584 }
8585
8586 // Destroy the traffic monitor timer
8587 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(
8588 &pHddCtx->tx_rx_trafficTmr)))
8589 {
8590 hddLog(VOS_TRACE_LEVEL_ERROR,
8591 "%s: Cannot deallocate Traffic monitor timer", __func__);
8592 }
8593
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 //Disable IMPS/BMPS as we do not want the device to enter any power
8595 //save mode during shutdown
8596 sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE);
8597 sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE);
8598 sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE);
8599
8600 //Ensure that device is in full power as we will touch H/W during vos_Stop
8601 init_completion(&powerContext.completion);
8602 powerContext.magic = POWER_CONTEXT_MAGIC;
8603
8604 halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback,
8605 &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD);
8606
8607 if (eHAL_STATUS_SUCCESS != halStatus)
8608 {
8609 if (eHAL_STATUS_PMC_PENDING == halStatus)
8610 {
8611 /* request was sent -- wait for the response */
8612 lrc = wait_for_completion_interruptible_timeout(
8613 &powerContext.completion,
8614 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 if (lrc <= 0)
8616 {
8617 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008618 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 }
8620 }
8621 else
8622 {
8623 hddLog(VOS_TRACE_LEVEL_ERROR,
8624 "%s: Request for Full Power failed, status %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008625 __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 /* continue -- need to clean up as much as possible */
8627 }
8628 }
Hanumantha Reddy Pothula81b42b22015-05-12 13:52:00 +05308629 if ((eHAL_STATUS_SUCCESS == halStatus) ||
8630 (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0))
8631 {
8632 /* This will issue a dump command which will clean up
8633 BTQM queues and unblock MC thread */
8634 vos_fwDumpReq(274, 0, 0, 0, 0, 1);
8635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008636
Jeff Johnson72a40512013-12-19 10:14:15 -08008637 /* either we never sent a request, we sent a request and received a
8638 response or we sent a request and timed out. if we never sent a
8639 request or if we sent a request and got a response, we want to
8640 clear the magic out of paranoia. if we timed out there is a
8641 race condition such that the callback function could be
8642 executing at the same time we are. of primary concern is if the
8643 callback function had already verified the "magic" but had not
8644 yet set the completion variable when a timeout occurred. we
8645 serialize these activities by invalidating the magic while
8646 holding a shared spinlock which will cause us to block if the
8647 callback is currently executing */
8648 spin_lock(&hdd_context_lock);
8649 powerContext.magic = 0;
8650 spin_unlock(&hdd_context_lock);
8651
Hema Aparna Medicharlaa6cf65e2015-06-01 16:23:28 +05308652 /* If Device is shutdown, no point for SME to wait for responses
8653 from device. Pre Close SME */
8654 if(wcnss_device_is_shutdown())
8655 {
8656 sme_PreClose(pHddCtx->hHal);
8657 }
Yue Ma0d4891e2013-08-06 17:01:45 -07008658 hdd_debugfs_exit(pHddCtx);
8659
Ratheesh S P35ed8b12015-04-27 14:01:07 +05308660#ifdef WLAN_NS_OFFLOAD
8661 hddLog(LOGE, FL("Unregister IPv6 notifier"));
8662 unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier);
8663#endif
8664 hddLog(LOGE, FL("Unregister IPv4 notifier"));
8665 unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier);
8666
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 // Unregister the Net Device Notifier
8668 unregister_netdevice_notifier(&hdd_netdev_notifier);
8669
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 hdd_stop_all_adapters( pHddCtx );
8671
Jeff Johnson295189b2012-06-20 16:38:30 -07008672#ifdef WLAN_BTAMP_FEATURE
8673 vosStatus = WLANBAP_Stop(pVosContext);
8674 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8675 {
8676 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8677 "%s: Failed to stop BAP",__func__);
8678 }
8679#endif //WLAN_BTAMP_FEATURE
8680
8681 //Stop all the modules
8682 vosStatus = vos_stop( pVosContext );
8683 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8684 {
8685 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8686 "%s: Failed to stop VOSS",__func__);
8687 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8688 }
8689
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 //This requires pMac access, Call this before vos_close().
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 hdd_unregister_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008692
8693 //Close the scheduler before calling vos_close to make sure no thread is
8694 // scheduled after the each module close is called i.e after all the data
8695 // structures are freed.
8696 vosStatus = vos_sched_close( pVosContext );
8697 if (!VOS_IS_STATUS_SUCCESS(vosStatus)) {
8698 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
8699 "%s: Failed to close VOSS Scheduler",__func__);
8700 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8701 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008702#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
8703 /* Destroy the wake lock */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308704 vos_wake_lock_destroy(&pHddCtx->rx_wake_lock);
Jeff Johnsone7245742012-09-05 17:12:55 -07008705#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -08008706 /* Destroy the wake lock */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308707 vos_wake_lock_destroy(&pHddCtx->sap_wake_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008708
Mihir Shete7a24b5f2013-12-21 12:18:31 +05308709#ifdef CONFIG_ENABLE_LINUX_REG
8710 vosStatus = vos_nv_close();
8711 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
8712 {
8713 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
8714 "%s: Failed to close NV", __func__);
8715 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) );
8716 }
8717#endif
8718
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 //Close VOSS
8720 //This frees pMac(HAL) context. There should not be any call that requires pMac access after this.
8721 vos_close(pVosContext);
8722
Jeff Johnson295189b2012-06-20 16:38:30 -07008723 //Close Watchdog
8724 if(pHddCtx->cfg_ini->fIsLogpEnabled)
8725 vos_watchdog_close(pVosContext);
8726
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308727 //Clean up HDD Nlink Service
8728 send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0);
Gopichand Nakkalaa0358482013-06-12 17:05:47 +05308729
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308730#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +05308731 if (pHddCtx->cfg_ini->wlanLoggingEnable)
Vinay Krishna Erannad938c422014-03-10 17:14:21 +05308732 {
8733 wlan_logging_sock_deactivate_svc();
8734 }
8735#endif
8736
Vinay Krishna Erannaef30b522014-08-26 17:48:16 +05308737#ifdef WLAN_KD_READY_NOTIFIER
8738 nl_srv_exit(pHddCtx->ptt_pid);
8739#else
8740 nl_srv_exit();
8741#endif /* WLAN_KD_READY_NOTIFIER */
8742
8743
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 hdd_close_all_adapters( pHddCtx );
8745
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 /* free the power on lock from platform driver */
8747 if (free_riva_power_on_lock("wlan"))
8748 {
8749 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock",
8750 __func__);
8751 }
8752
Jeff Johnson88ba7742013-02-27 14:36:02 -08008753free_hdd_ctx:
c_hpothu78c7b602014-05-17 17:35:49 +05308754
8755 //Free up dynamically allocated members inside HDD Adapter
8756 if (pHddCtx->cfg_ini)
8757 {
8758 kfree(pHddCtx->cfg_ini);
8759 pHddCtx->cfg_ini= NULL;
8760 }
8761
Leo Changf04ddad2013-09-18 13:46:38 -07008762 /* FTM mode, WIPHY did not registered
8763 If un-register here, system crash will happen */
8764 if (VOS_FTM_MODE != hdd_get_conparam())
8765 {
8766 wiphy_unregister(wiphy) ;
8767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 wiphy_free(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 if (hdd_is_ssr_required())
8770 {
8771 /* WDI timeout had happened during unload, so SSR is needed here */
Madan Mohan Koyyalamudi3246f5b2012-10-15 15:40:02 -07008772 subsystem_restart("wcnss");
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 msleep(5000);
8774 }
8775 hdd_set_ssr_required (VOS_FALSE);
8776}
8777
8778
8779/**---------------------------------------------------------------------------
8780
8781 \brief hdd_update_config_from_nv() - Function to update the contents of
8782 the running configuration with parameters taken from NV storage
8783
8784 \param - pHddCtx - Pointer to the HDD global context
8785
8786 \return - VOS_STATUS_SUCCESS if successful
8787
8788 --------------------------------------------------------------------------*/
8789static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx)
8790{
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 v_BOOL_t itemIsValid = VOS_FALSE;
8792 VOS_STATUS status;
8793 v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA];
8794 v_U8_t macLoop;
8795
8796 /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/
8797 status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid);
8798 if(status != VOS_STATUS_SUCCESS)
8799 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008800 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 return VOS_STATUS_E_FAILURE;
8802 }
8803
8804 if (itemIsValid == VOS_TRUE)
8805 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008806 hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV");
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0],
8808 VOS_MAX_CONCURRENCY_PERSONA);
8809 if(status != VOS_STATUS_SUCCESS)
8810 {
8811 /* Get MAC from NV fail, not update CFG info
8812 * INI MAC value will be used for MAC setting */
Arif Hussain6d2a3322013-11-17 19:50:10 -08008813 hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 return VOS_STATUS_E_FAILURE;
8815 }
8816
8817 /* If first MAC is not valid, treat all others are not valid
8818 * Then all MACs will be got from ini file */
8819 if(vos_is_macaddr_zero(&macFromNV[0]))
8820 {
8821 /* MAC address in NV file is not configured yet */
8822 hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file");
8823 return VOS_STATUS_E_INVAL;
8824 }
8825
8826 /* Get MAC address from NV, update CFG info */
8827 for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++)
8828 {
8829 if(vos_is_macaddr_zero(&macFromNV[macLoop]))
8830 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308831 hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop);
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 /* This MAC is not valid, skip it
8833 * This MAC will be got from ini file */
8834 }
8835 else
8836 {
8837 vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0],
8838 (v_U8_t *)&macFromNV[macLoop].bytes[0],
8839 VOS_MAC_ADDR_SIZE);
8840 }
8841 }
8842 }
8843 else
8844 {
8845 hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid");
8846 return VOS_STATUS_E_FAILURE;
8847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008848
Jeff Johnson295189b2012-06-20 16:38:30 -07008849
8850 return VOS_STATUS_SUCCESS;
8851}
8852
8853/**---------------------------------------------------------------------------
8854
8855 \brief hdd_post_voss_start_config() - HDD post voss start config helper
8856
8857 \param - pAdapter - Pointer to the HDD
8858
8859 \return - None
8860
8861 --------------------------------------------------------------------------*/
8862VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx)
8863{
8864 eHalStatus halStatus;
8865 v_U32_t listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308866 tANI_U32 ignoreDtim;
Jeff Johnson295189b2012-06-20 16:38:30 -07008867
Jeff Johnson295189b2012-06-20 16:38:30 -07008868
8869 // Send ready indication to the HDD. This will kick off the MAC
8870 // into a 'running' state and should kick off an initial scan.
8871 halStatus = sme_HDDReadyInd( pHddCtx->hHal );
8872 if ( !HAL_STATUS_SUCCESS( halStatus ) )
8873 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05308874 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status "
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 "code %08d [x%08x]",__func__, halStatus, halStatus );
8876 return VOS_STATUS_E_FAILURE;
8877 }
8878
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308879 // Set default LI and ignoreDtim into HDD context,
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 // otherwise under some race condition, HDD will set 0 LI value into RIVA,
8881 // And RIVA will crash
8882 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval);
8883 pHddCtx->hdd_actual_LI_value = listenInterval;
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308884 wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim);
8885 pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim;
8886
8887
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 return VOS_STATUS_SUCCESS;
8889}
8890
Jeff Johnson295189b2012-06-20 16:38:30 -07008891/* wake lock APIs for HDD */
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308892void hdd_prevent_suspend(uint32_t reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07008893{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308894
8895 vos_wake_lock_acquire(&wlan_wake_lock, reason);
8896
Jeff Johnson295189b2012-06-20 16:38:30 -07008897}
8898
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308899void hdd_allow_suspend(uint32_t reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07008900{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308901
8902 vos_wake_lock_release(&wlan_wake_lock, reason);
8903
Jeff Johnson295189b2012-06-20 16:38:30 -07008904}
8905
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308906void hdd_prevent_suspend_timeout(v_U32_t timeout, uint32_t reason)
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008907{
Sushant Kaushik83392fa2015-05-05 17:44:40 +05308908
8909 vos_wake_lock_timeout_release(&wlan_wake_lock, timeout,
8910 reason);
8911
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008912}
8913
Jeff Johnson295189b2012-06-20 16:38:30 -07008914/**---------------------------------------------------------------------------
8915
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008916 \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability
8917 information between Host and Riva
8918
8919 This function gets reported version of FW
8920 It also finds the version of Riva headers used to compile the host
8921 It compares the above two and prints a warning if they are different
8922 It gets the SW and HW version string
8923 Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg
8924 indicating the features they support through a bitmap
8925
8926 \param - pHddCtx - Pointer to HDD context
8927
8928 \return - void
8929
8930 --------------------------------------------------------------------------*/
8931
8932void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx)
8933{
8934
8935 tSirVersionType versionCompiled;
8936 tSirVersionType versionReported;
8937 tSirVersionString versionString;
8938 tANI_U8 fwFeatCapsMsgSupported = 0;
8939 VOS_STATUS vstatus;
8940
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008941 memset(&versionCompiled, 0, sizeof(versionCompiled));
8942 memset(&versionReported, 0, sizeof(versionReported));
8943
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008944 /* retrieve and display WCNSS version information */
8945 do {
8946
8947 vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal,
8948 &versionCompiled);
8949 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8950 {
8951 hddLog(VOS_TRACE_LEVEL_FATAL,
8952 "%s: unable to retrieve WCNSS WLAN compiled version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008953 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008954 break;
8955 }
8956
8957 vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal,
8958 &versionReported);
8959 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8960 {
8961 hddLog(VOS_TRACE_LEVEL_FATAL,
8962 "%s: unable to retrieve WCNSS WLAN reported version",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008963 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07008964 break;
8965 }
8966
8967 if ((versionCompiled.major != versionReported.major) ||
8968 (versionCompiled.minor != versionReported.minor) ||
8969 (versionCompiled.version != versionReported.version) ||
8970 (versionCompiled.revision != versionReported.revision))
8971 {
8972 pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, "
8973 "Host expected %u.%u.%u.%u\n",
8974 WLAN_MODULE_NAME,
8975 (int)versionReported.major,
8976 (int)versionReported.minor,
8977 (int)versionReported.version,
8978 (int)versionReported.revision,
8979 (int)versionCompiled.major,
8980 (int)versionCompiled.minor,
8981 (int)versionCompiled.version,
8982 (int)versionCompiled.revision);
8983 }
8984 else
8985 {
8986 pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n",
8987 WLAN_MODULE_NAME,
8988 (int)versionReported.major,
8989 (int)versionReported.minor,
8990 (int)versionReported.version,
8991 (int)versionReported.revision);
8992 }
8993
8994 vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal,
8995 versionString,
8996 sizeof(versionString));
8997 if (!VOS_IS_STATUS_SUCCESS(vstatus))
8998 {
8999 hddLog(VOS_TRACE_LEVEL_FATAL,
9000 "%s: unable to retrieve WCNSS software version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009001 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009002 break;
9003 }
9004
9005 pr_info("%s: WCNSS software version %s\n",
9006 WLAN_MODULE_NAME, versionString);
9007
9008 vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal,
9009 versionString,
9010 sizeof(versionString));
9011 if (!VOS_IS_STATUS_SUCCESS(vstatus))
9012 {
9013 hddLog(VOS_TRACE_LEVEL_FATAL,
9014 "%s: unable to retrieve WCNSS hardware version string",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009015 __func__);
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009016 break;
9017 }
9018
9019 pr_info("%s: WCNSS hardware version %s\n",
9020 WLAN_MODULE_NAME, versionString);
9021
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07009022 /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message
9023 2.Host-FW capability exchange message is only present on riva 1.1 so
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009024 send the message only if it the riva is 1.1
9025 minor numbers for different riva branches:
9026 0 -> (1.0)Mainline Build
9027 1 -> (1.1)Mainline Build
9028 2->(1.04) Stability Build
9029 */
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07009030 if (((versionReported.major>0) || (versionReported.minor>1) ||
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009031 ((versionReported.minor>=1) && (versionReported.version>=1)))
9032 && ((versionReported.major == 1) && (versionReported.minor >= 1)))
9033 fwFeatCapsMsgSupported = 1;
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -07009034
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009035 if (fwFeatCapsMsgSupported)
Yathish9f22e662012-12-10 14:21:35 -08009036 {
9037#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9038 if(!pHddCtx->cfg_ini->fEnableActiveModeOffload)
9039 sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD);
9040#endif
Ravi Joshid2ca7c42013-07-23 08:37:49 -07009041 /* Indicate if IBSS heartbeat monitoring needs to be offloaded */
9042 if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload)
9043 {
9044 sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD);
9045 }
9046
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009047 sme_featureCapsExchange(pHddCtx->hHal);
Yathish9f22e662012-12-10 14:21:35 -08009048 }
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009049
9050 } while (0);
9051
9052}
Neelansh Mittaledafed22014-09-04 18:54:39 +05309053void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len)
9054{
9055 struct sk_buff *skb;
9056 struct nlmsghdr *nlh;
9057 tAniMsgHdr *ani_hdr;
Hanumantha Reddy Pothulacf2c7ea2015-04-27 14:50:47 +05309058 int flags = GFP_KERNEL;
Neelansh Mittaledafed22014-09-04 18:54:39 +05309059
Hanumantha Reddy Pothulacf2c7ea2015-04-27 14:50:47 +05309060 if (in_interrupt() || irqs_disabled() || in_atomic())
9061 flags = GFP_ATOMIC;
9062
9063 skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags);
Neelansh Mittaledafed22014-09-04 18:54:39 +05309064
9065 if(skb == NULL) {
9066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9067 "%s: alloc_skb failed", __func__);
9068 return;
9069 }
9070
9071 nlh = (struct nlmsghdr *)skb->data;
9072 nlh->nlmsg_pid = 0; /* from kernel */
9073 nlh->nlmsg_flags = 0;
9074 nlh->nlmsg_seq = 0;
9075 nlh->nlmsg_type = WLAN_NL_MSG_SVC;
9076
9077 ani_hdr = NLMSG_DATA(nlh);
9078 ani_hdr->type = type;
9079
9080 switch(type) {
9081 case WLAN_SVC_SAP_RESTART_IND:
9082 ani_hdr->length = 0;
9083 nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr)));
9084 skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr)));
9085 break;
9086 default:
9087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9088 "Attempt to send unknown nlink message %d", type);
9089 kfree_skb(skb);
9090 return;
9091 }
9092
9093 nl_srv_bcast(skb);
9094
9095 return;
9096}
9097
9098
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009099
9100/**---------------------------------------------------------------------------
9101
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309102 \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz
9103
9104 \param - pHddCtx - Pointer to the hdd context
9105
9106 \return - true if hardware supports 5GHz
9107
9108 --------------------------------------------------------------------------*/
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05309109boolean hdd_is_5g_supported(hdd_context_t * pHddCtx)
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309110{
9111 /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1);
9112 * then hardware support 5Ghz.
9113 */
9114 if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode())
9115 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309116 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309117 return true;
9118 }
9119 else
9120 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309121 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz",
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309122 __func__);
9123 return false;
9124 }
9125}
9126
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309127/**---------------------------------------------------------------------------
9128
9129 \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto
9130 generate function
9131
9132 This is generate the random mac address for WLAN interface
9133
9134 \param - pHddCtx - Pointer to HDD context
9135 idx - Start interface index to get auto
9136 generated mac addr.
9137 mac_addr - Mac address
9138
9139 \return - 0 for success, < 0 for failure
9140
9141 --------------------------------------------------------------------------*/
9142
9143static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx,
9144 int idx, v_MACADDR_t mac_addr)
9145{
9146 int i;
9147 unsigned int serialno;
9148 serialno = wcnss_get_serial_number();
9149
9150 if (0 != serialno)
9151 {
9152 /* MAC address has 3 bytes of OUI so we have a maximum of 3
9153 bytes of the serial number that can be used to generate
9154 the other 3 bytes of the MAC address. Mask off all but
9155 the lower 3 bytes (this will also make sure we don't
9156 overflow in the next step) */
9157 serialno &= 0x00FFFFFF;
9158
9159 /* we need a unique address for each session */
9160 serialno *= VOS_MAX_CONCURRENCY_PERSONA;
9161
9162 /* autogen other Mac addresses */
9163 for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++)
9164 {
9165 /* start with the entire default address */
9166 pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr;
9167 /* then replace the lower 3 bytes */
9168 pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF;
9169 pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF;
9170 pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF;
9171
9172 serialno++;
9173 hddLog(VOS_TRACE_LEVEL_ERROR,
9174 "%s: Derived Mac Addr: "
9175 MAC_ADDRESS_STR, __func__,
9176 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes));
9177 }
9178
9179 }
9180 else
9181 {
9182 hddLog(LOGE, FL("Failed to Get Serial NO"));
9183 return -1;
9184 }
9185 return 0;
9186}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309187
Katya Nigame7b69a82015-04-28 15:24:06 +05309188int wlan_hdd_mon_open(hdd_context_t *pHddCtx)
9189{
9190 VOS_STATUS status;
9191 v_CONTEXT_t pVosContext= NULL;
9192 hdd_adapter_t *pAdapter= NULL;
9193
9194 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9195
9196 if (NULL == pVosContext)
9197 {
9198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9199 "%s: Trying to open VOSS without a PreOpen", __func__);
9200 VOS_ASSERT(0);
9201 return VOS_STATUS_E_FAILURE;
9202 }
9203
9204 status = vos_nv_open();
9205 if (!VOS_IS_STATUS_SUCCESS(status))
9206 {
9207 /* NV module cannot be initialized */
9208 hddLog( VOS_TRACE_LEVEL_FATAL,
9209 "%s: vos_nv_open failed", __func__);
9210 return VOS_STATUS_E_FAILURE;
9211 }
9212
9213 status = vos_init_wiphy_from_nv_bin();
9214 if (!VOS_IS_STATUS_SUCCESS(status))
9215 {
9216 /* NV module cannot be initialized */
9217 hddLog( VOS_TRACE_LEVEL_FATAL,
9218 "%s: vos_init_wiphy failed", __func__);
9219 goto err_vos_nv_close;
9220 }
9221
9222 status = vos_open( &pVosContext, pHddCtx->parent_dev);
9223 if ( !VOS_IS_STATUS_SUCCESS( status ))
9224 {
9225 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
9226 goto err_vos_nv_close;
9227 }
9228
9229 status = vos_mon_start( pVosContext );
9230 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9231 {
9232 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
9233 goto err_vosclose;
9234 }
9235
9236 WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk );
9237 WDA_featureCapsExchange(pVosContext);
9238 wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx);
9239
9240 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_MONITOR, "wlan%d",
9241 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9242 if( pAdapter == NULL )
9243 {
9244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9245 goto err_close_adapter;
9246 }
9247
9248 //Initialize the nlink service
9249 if(nl_srv_init() != 0)
9250 {
9251 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
9252 goto err_close_adapter;
9253 }
9254 return VOS_STATUS_SUCCESS;
9255
9256err_close_adapter:
9257 hdd_close_all_adapters( pHddCtx );
9258 vos_mon_stop( pVosContext );
9259err_vosclose:
9260 status = vos_sched_close( pVosContext );
9261 if (!VOS_IS_STATUS_SUCCESS(status)) {
9262 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
9263 "%s: Failed to close VOSS Scheduler", __func__);
9264 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
9265 }
9266 vos_close(pVosContext );
9267
9268err_vos_nv_close:
9269 vos_nv_close();
9270
9271return status;
9272}
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309273/**---------------------------------------------------------------------------
9274
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309275 \brief hdd_11d_scan_done - callback to be executed when 11d scan is
9276 completed to flush out the scan results
9277
9278 11d scan is done during driver load and is a passive scan on all
9279 channels supported by the device, 11d scans may find some APs on
9280 frequencies which are forbidden to be used in the regulatory domain
9281 the device is operating in. If these APs are notified to the supplicant
9282 it may try to connect to these APs, thus flush out all the scan results
9283 which are present in SME after 11d scan is done.
9284
9285 \return - eHalStatus
9286
9287 --------------------------------------------------------------------------*/
9288static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext,
9289 tANI_U32 scanId, eCsrScanStatus status)
9290{
9291 ENTER();
9292
9293 sme_ScanFlushResult(halHandle, 0);
9294
9295 EXIT();
9296
9297 return eHAL_STATUS_SUCCESS;
9298}
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309299/**---------------------------------------------------------------------------
9300
9301 \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame
9302 logging is completed successfully.
9303
9304 \return - None
9305
9306 --------------------------------------------------------------------------*/
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309307void hdd_init_frame_logging_done(void *fwlogInitCbContext, VOS_STATUS status)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309308{
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309309 hdd_context_t* pHddCtx = (hdd_context_t*)fwlogInitCbContext;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309310
9311 if (NULL == pHddCtx)
9312 {
9313 hddLog(VOS_TRACE_LEVEL_ERROR,
9314 "%s: HDD context is NULL",__func__);
9315 return;
9316 }
9317
Mahesh A Saptasagarfabb1a02015-06-29 12:17:04 +05309318 if ((VOS_STATUS_SUCCESS == status) &&
9319 (TRUE == pHddCtx->cfg_ini->enableMgmtLogging))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309320 {
9321 hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful"));
9322 pHddCtx->mgmt_frame_logging = TRUE;
9323 }
9324 else
9325 {
9326 hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success"));
9327 pHddCtx->mgmt_frame_logging = FALSE;
9328 }
9329
9330 return;
9331}
9332/**---------------------------------------------------------------------------
9333
9334 \brief hdd_init_frame_logging - function to initialize frame logging.
9335 Currently only Mgmt Frames are logged in both TX
9336 and Rx direction and are sent to userspace
9337 application using logger thread when queried.
9338
9339 \return - None
9340
9341 --------------------------------------------------------------------------*/
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309342void hdd_init_frame_logging(hdd_context_t* pHddCtx)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309343{
9344 eHalStatus halStatus = eHAL_STATUS_FAILURE;
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309345 tpSirFWLoggingInitParam wlanFWLoggingInitParam;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309346
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309347 if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING) &&
9348 TRUE != sme_IsFeatureSupportedByFW(LOGGING_ENHANCEMENT))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309349 {
9350 hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW"));
9351 return;
9352 }
9353
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309354 wlanFWLoggingInitParam = vos_mem_malloc(sizeof(tSirFWLoggingInitParam));
9355 if(NULL == wlanFWLoggingInitParam)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309356 {
9357 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_mem_alloc failed ", __func__);
9358 return;
9359 }
9360
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309361 vos_mem_set(wlanFWLoggingInitParam, sizeof(tSirFWLoggingInitParam), 0);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309362
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309363 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Configuring %s %s %s Logging",__func__,
9364 pHddCtx->cfg_ini->enableFWLogging?"FW Log,":"",
9365 pHddCtx->cfg_ini->enableContFWLogging ? "Cont FW log,":"",
9366 pHddCtx->cfg_ini->enableMgmtLogging ? "Mgmt Pkt Log":"");
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309367
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309368 if (pHddCtx->cfg_ini->enableFWLogging ||
9369 pHddCtx->cfg_ini->enableContFWLogging)
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309370 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309371 wlanFWLoggingInitParam->enableFlag |= WLAN_QXDM_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309372 }
9373
Sushant Kaushik46804902015-07-08 14:46:03 +05309374 if (pHddCtx->cfg_ini->enableMgmtLogging)
9375 {
9376 wlanFWLoggingInitParam->enableFlag |= WLAN_FRAME_LOG_EN;
9377 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309378 if (pHddCtx->cfg_ini->enableBMUHWtracing)
9379 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309380 wlanFWLoggingInitParam->enableFlag |= WLAN_BMUHW_TRACE_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309381 }
9382
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309383 wlanFWLoggingInitParam->frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT;
9384 wlanFWLoggingInitParam->frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES;
9385 wlanFWLoggingInitParam->bufferMode = WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR;
9386 wlanFWLoggingInitParam->continuousFrameLogging =
9387 pHddCtx->cfg_ini->enableContFWLogging;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309388
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309389 wlanFWLoggingInitParam->enableFlag &= ~WLAN_DPU_TXP_LOG_EN;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309390
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309391 wlanFWLoggingInitParam->minLogBufferSize =
9392 pHddCtx->cfg_ini->minLoggingBufferSize;
9393 wlanFWLoggingInitParam->maxLogBufferSize =
9394 pHddCtx->cfg_ini->maxLoggingBufferSize;
9395 wlanFWLoggingInitParam->fwlogInitCallback = hdd_init_frame_logging_done;
9396 wlanFWLoggingInitParam->fwlogInitCbContext= pHddCtx;
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309397
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309398 halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, wlanFWLoggingInitParam);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309399
9400 if (eHAL_STATUS_SUCCESS != halStatus)
9401 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +05309402 vos_mem_free(wlanFWLoggingInitParam);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +05309403 }
9404
9405 return;
9406}
Mihir Shetefc7ff5b2014-01-27 11:30:05 +05309407
9408/**---------------------------------------------------------------------------
9409
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 \brief hdd_wlan_startup() - HDD init function
9411
9412 This is the driver startup code executed once a WLAN device has been detected
9413
9414 \param - dev - Pointer to the underlying device
9415
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009416 \return - 0 for success, < 0 for failure
Jeff Johnson295189b2012-06-20 16:38:30 -07009417
9418 --------------------------------------------------------------------------*/
9419
9420int hdd_wlan_startup(struct device *dev )
9421{
9422 VOS_STATUS status;
9423 hdd_adapter_t *pAdapter = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07009424 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 hdd_context_t *pHddCtx = NULL;
9426 v_CONTEXT_t pVosContext= NULL;
9427#ifdef WLAN_BTAMP_FEATURE
9428 VOS_STATUS vStatus = VOS_STATUS_SUCCESS;
9429 WLANBAP_ConfigType btAmpConfig;
9430 hdd_config_t *pConfig;
9431#endif
9432 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 struct wiphy *wiphy;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309434 v_MACADDR_t mac_addr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009435
9436 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 /*
9438 * cfg80211: wiphy allocation
9439 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309440 wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009441
9442 if(wiphy == NULL)
9443 {
9444 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08009445 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 pHddCtx = wiphy_priv(wiphy);
9448
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 //Initialize the adapter context to zeros.
9450 vos_mem_zero(pHddCtx, sizeof( hdd_context_t ));
9451
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 pHddCtx->wiphy = wiphy;
Sushant Kaushik83392fa2015-05-05 17:44:40 +05309453 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Mihir Shete18156292014-03-11 15:38:30 +05309454 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009455
9456 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
9457
Siddharth Bhalcd92b782015-06-29 12:25:40 +05309458 /* register for riva power on lock to platform driver
9459 * Locking power early to ensure FW doesn't reset by kernel while
9460 * host driver is busy initializing itself */
9461 if (req_riva_power_on_lock("wlan"))
9462 {
9463 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed",
9464 __func__);
9465 goto err_free_hdd_context;
9466 }
9467
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 /*Get vos context here bcoz vos_open requires it*/
9469 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
9470
Madan Mohan Koyyalamudi0b78e152012-11-28 15:46:51 -08009471 if(pVosContext == NULL)
9472 {
9473 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__);
9474 goto err_free_hdd_context;
9475 }
9476
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 //Save the Global VOSS context in adapter context for future.
9478 pHddCtx->pvosContext = pVosContext;
9479
9480 //Save the adapter context in global context for future.
9481 ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx;
9482
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 pHddCtx->parent_dev = dev;
9484
9485 init_completion(&pHddCtx->full_pwr_comp_var);
9486 init_completion(&pHddCtx->standby_comp_var);
9487 init_completion(&pHddCtx->req_bmps_comp_var);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009488 init_completion(&pHddCtx->scan_info.scan_req_completion_event);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08009489 init_completion(&pHddCtx->scan_info.abortscan_event_var);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309490 init_completion(&pHddCtx->wiphy_channel_update_event);
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +05309491 init_completion(&pHddCtx->ssr_comp_var);
Amar Singhala49cbc52013-10-08 18:37:44 -07009492
9493#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhalfddc28c2013-09-05 13:03:40 -07009494 init_completion(&pHddCtx->linux_reg_req);
Amar Singhala49cbc52013-10-08 18:37:44 -07009495#else
9496 init_completion(&pHddCtx->driver_crda_req);
9497#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009498
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309499 spin_lock_init(&pHddCtx->schedScan_lock);
9500
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS );
9502
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309503#ifdef FEATURE_WLAN_TDLS
9504 /* tdls_lock is initialized before an hdd_open_adapter ( which is
9505 * invoked by other instances also) to protect the concurrent
9506 * access for the Adapters by TDLS module.
9507 */
9508 mutex_init(&pHddCtx->tdls_lock);
9509#endif
Siddharth Bhal76972212014-10-15 16:22:51 +05309510 mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05309511 mutex_init(&pHddCtx->wmmLock);
9512
Agarwal Ashish1f422872014-07-22 00:11:55 +05309513 /* By default Strict Regulatory For FCC should be false */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309514
Agarwal Ashish1f422872014-07-22 00:11:55 +05309515 pHddCtx->nEnableStrictRegulatoryForFCC = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 // Load all config first as TL config is needed during vos_open
9517 pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL);
9518 if(pHddCtx->cfg_ini == NULL)
9519 {
9520 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__);
9521 goto err_free_hdd_context;
9522 }
9523
9524 vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t ));
9525
9526 // Read and parse the qcom_cfg.ini file
9527 status = hdd_parse_config_ini( pHddCtx );
9528 if ( VOS_STATUS_SUCCESS != status )
9529 {
9530 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s",
9531 __func__, WLAN_INI_FILE);
9532 goto err_config;
9533 }
Arif Hussaind5218912013-12-05 01:10:55 -08009534#ifdef MEMORY_DEBUG
9535 if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled)
9536 vos_mem_init();
9537
9538 hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d",
9539 __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled);
9540#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009541
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05309542 /* INI has been read, initialise the configuredMcastBcastFilter with
9543 * INI value as this will serve as the default value
9544 */
9545 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
9546 hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d",
9547 pHddCtx->cfg_ini->mcastBcastFilterSetting);
Gopichand Nakkalafce506f2013-07-03 23:55:16 +05309548
9549 if (false == hdd_is_5g_supported(pHddCtx))
9550 {
9551 //5Ghz is not supported.
9552 if (1 != pHddCtx->cfg_ini->nBandCapability)
9553 {
9554 hddLog(VOS_TRACE_LEVEL_INFO,
9555 "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__);
9556 pHddCtx->cfg_ini->nBandCapability = 1;
9557 }
9558 }
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309559
9560 /* If SNR Monitoring is enabled, FW has to parse all beacons
9561 * for calcaluting and storing the average SNR, so set Nth beacon
9562 * filter to 1 to enable FW to parse all the beaocons
9563 */
9564 if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring)
9565 {
9566 /* The log level is deliberately set to WARN as overriding
9567 * nthBeaconFilter to 1 will increase power cosumption and this
9568 * might just prove helpful to detect the power issue.
9569 */
9570 hddLog(VOS_TRACE_LEVEL_WARN,
9571 "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__);
9572 pHddCtx->cfg_ini->nthBeaconFilter = 1;
9573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 /*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309575 * cfg80211: Initialization ...
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 */
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08009577 if (VOS_FTM_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 {
Manjunathappa Prakasheec4ddf2014-01-13 18:23:51 -08009579 if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini))
9580 {
9581 hddLog(VOS_TRACE_LEVEL_FATAL,
9582 "%s: wlan_hdd_cfg80211_init return failure", __func__);
9583 goto err_config;
9584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009586
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009587 // Update VOS trace levels based upon the cfg.ini
9588 hdd_vos_trace_enable(VOS_MODULE_ID_BAP,
9589 pHddCtx->cfg_ini->vosTraceEnableBAP);
9590 hdd_vos_trace_enable(VOS_MODULE_ID_TL,
9591 pHddCtx->cfg_ini->vosTraceEnableTL);
9592 hdd_vos_trace_enable(VOS_MODULE_ID_WDI,
9593 pHddCtx->cfg_ini->vosTraceEnableWDI);
9594 hdd_vos_trace_enable(VOS_MODULE_ID_HDD,
9595 pHddCtx->cfg_ini->vosTraceEnableHDD);
9596 hdd_vos_trace_enable(VOS_MODULE_ID_SME,
9597 pHddCtx->cfg_ini->vosTraceEnableSME);
9598 hdd_vos_trace_enable(VOS_MODULE_ID_PE,
9599 pHddCtx->cfg_ini->vosTraceEnablePE);
Katya Nigam70d68332013-09-16 16:49:45 +05309600 hdd_vos_trace_enable(VOS_MODULE_ID_PMC,
9601 pHddCtx->cfg_ini->vosTraceEnablePMC);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009602 hdd_vos_trace_enable(VOS_MODULE_ID_WDA,
9603 pHddCtx->cfg_ini->vosTraceEnableWDA);
9604 hdd_vos_trace_enable(VOS_MODULE_ID_SYS,
9605 pHddCtx->cfg_ini->vosTraceEnableSYS);
9606 hdd_vos_trace_enable(VOS_MODULE_ID_VOSS,
9607 pHddCtx->cfg_ini->vosTraceEnableVOSS);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009608 hdd_vos_trace_enable(VOS_MODULE_ID_SAP,
9609 pHddCtx->cfg_ini->vosTraceEnableSAP);
9610 hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP,
9611 pHddCtx->cfg_ini->vosTraceEnableHDDSAP);
Varun Reddy Yeturu587e6802013-01-24 12:21:41 -08009612
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 // Update WDI trace levels based upon the cfg.ini
9614 hdd_wdi_trace_enable(eWLAN_MODULE_DAL,
9615 pHddCtx->cfg_ini->wdiTraceEnableDAL);
9616 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL,
9617 pHddCtx->cfg_ini->wdiTraceEnableCTL);
9618 hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA,
9619 pHddCtx->cfg_ini->wdiTraceEnableDAT);
9620 hdd_wdi_trace_enable(eWLAN_MODULE_PAL,
9621 pHddCtx->cfg_ini->wdiTraceEnablePAL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009622
Jeff Johnson88ba7742013-02-27 14:36:02 -08009623 if (VOS_FTM_MODE == hdd_get_conparam())
9624 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) )
9626 {
9627 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__);
9628 goto err_free_hdd_context;
9629 }
9630 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__);
Sachin Ahuja38ef5e02015-03-13 17:31:16 +05309631 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
c_hpothu2de0ef62014-04-15 16:16:15 +05309632 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 return VOS_STATUS_SUCCESS;
Jeff Johnson88ba7742013-02-27 14:36:02 -08009634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009635
Katya Nigame7b69a82015-04-28 15:24:06 +05309636 if( VOS_MONITOR_MODE == hdd_get_conparam())
9637 {
9638 if ( VOS_STATUS_SUCCESS != wlan_hdd_mon_open(pHddCtx))
9639 {
9640 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_mon_open Failed",__func__);
9641 goto err_free_hdd_context;
9642 }
9643 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Driver loaded in Monitor Mode",__func__);
9644 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
9645 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9646 return VOS_STATUS_SUCCESS;
9647 }
9648
Jeff Johnson88ba7742013-02-27 14:36:02 -08009649 //Open watchdog module
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 if(pHddCtx->cfg_ini->fIsLogpEnabled)
9651 {
9652 status = vos_watchdog_open(pVosContext,
9653 &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext));
9654
9655 if(!VOS_IS_STATUS_SUCCESS( status ))
9656 {
9657 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309658 goto err_wdclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 }
9660 }
9661
9662 pHddCtx->isLogpInProgress = FALSE;
9663 vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE);
9664
Amar Singhala49cbc52013-10-08 18:37:44 -07009665#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07009666 /* initialize the NV module. This is required so that
9667 we can initialize the channel information in wiphy
9668 from the NV.bin data. The channel information in
9669 wiphy needs to be initialized before wiphy registration */
9670
9671 status = vos_nv_open();
9672 if (!VOS_IS_STATUS_SUCCESS(status))
9673 {
9674 /* NV module cannot be initialized */
9675 hddLog( VOS_TRACE_LEVEL_FATAL,
9676 "%s: vos_nv_open failed", __func__);
Vinay Krishna Eranna2025d892014-09-18 16:51:42 +05309677 goto err_wdclose;
Amar Singhal0a402232013-10-11 20:57:16 -07009678 }
9679
9680 status = vos_init_wiphy_from_nv_bin();
9681 if (!VOS_IS_STATUS_SUCCESS(status))
9682 {
9683 /* NV module cannot be initialized */
9684 hddLog( VOS_TRACE_LEVEL_FATAL,
9685 "%s: vos_init_wiphy failed", __func__);
9686 goto err_vos_nv_close;
9687 }
9688
Amar Singhala49cbc52013-10-08 18:37:44 -07009689#endif
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05309690 vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats);
Arun Kumar Khandavalliebb19482014-03-25 13:56:53 +05309691 status = vos_open( &pVosContext, pHddCtx->parent_dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 if ( !VOS_IS_STATUS_SUCCESS( status ))
9693 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009694 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__);
Mihir Shetee1093ba2014-01-21 20:13:32 +05309695 goto err_vos_nv_close;
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 }
9697
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext );
9699
9700 if ( NULL == pHddCtx->hHal )
9701 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009702 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 goto err_vosclose;
9704 }
9705
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009706 status = vos_preStart( pHddCtx->pvosContext );
9707 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9708 {
9709 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309710 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009711 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009712
Arif Hussaineaf68602013-12-30 23:10:44 -08009713 if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan)
9714 {
9715 pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan;
9716 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d",
9717 __func__, enable_dfs_chan_scan);
9718 }
9719 if (0 == enable_11d || 1 == enable_11d)
9720 {
9721 pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d;
9722 hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d",
9723 __func__, enable_11d);
9724 }
9725
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009726 /* Note that the vos_preStart() sequence triggers the cfg download.
9727 The cfg download must occur before we update the SME config
9728 since the SME config operation must access the cfg database */
Jeff Johnson295189b2012-06-20 16:38:30 -07009729 status = hdd_set_sme_config( pHddCtx );
9730
9731 if ( VOS_STATUS_SUCCESS != status )
9732 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009733 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309734 goto err_vosclose;
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009736
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 /* In the integrated architecture we update the configuration from
9738 the INI file and from NV before vOSS has been started so that
9739 the final contents are available to send down to the cCPU */
9740
9741 // Apply the cfg.ini to cfg.dat
9742 if (FALSE == hdd_update_config_dat(pHddCtx))
9743 {
9744 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309745 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 }
9747
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309748 // Get mac addr from platform driver
9749 ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes);
9750
9751 if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309753 /* Store the mac addr for first interface */
9754 pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr;
9755
9756 hddLog(VOS_TRACE_LEVEL_ERROR,
9757 "%s: WLAN Mac Addr: "
9758 MAC_ADDRESS_STR, __func__,
9759 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
9760
9761 /* Here, passing Arg2 as 1 because we do not want to change the
9762 last 3 bytes (means non OUI bytes) of first interface mac
9763 addr.
9764 */
9765 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr))
9766 {
9767 hddLog(VOS_TRACE_LEVEL_ERROR,
9768 "%s: Failed to generate wlan interface mac addr "
9769 "using MAC from ini file ", __func__);
9770 }
9771 }
9772 else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx))
9773 {
9774 // Apply the NV to cfg.dat
9775 /* Prima Update MAC address only at here */
Jeff Johnson295189b2012-06-20 16:38:30 -07009776#ifdef WLAN_AUTOGEN_MACADDR_FEATURE
9777 /* There was not a valid set of MAC Addresses in NV. See if the
9778 default addresses were modified by the cfg.ini settings. If so,
9779 we'll use them, but if not, we'll autogenerate a set of MAC
9780 addresses based upon the device serial number */
9781
9782 static const v_MACADDR_t default_address =
9783 {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}};
Jeff Johnson295189b2012-06-20 16:38:30 -07009784
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309785 if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0],
9786 sizeof(default_address)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 {
9788 /* cfg.ini has the default address, invoke autogen logic */
9789
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309790 /* Here, passing Arg2 as 0 because we want to change the
9791 last 3 bytes (means non OUI bytes) of all the interfaces
9792 mac addr.
9793 */
9794 if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0,
9795 default_address))
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 {
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309797 hddLog(VOS_TRACE_LEVEL_ERROR,
9798 "%s: Failed to generate wlan interface mac addr "
9799 "using MAC from ini file " MAC_ADDRESS_STR, __func__,
9800 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009802 }
9803 else
9804#endif //WLAN_AUTOGEN_MACADDR_FEATURE
9805 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009806 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 "%s: Invalid MAC address in NV, using MAC from ini file "
9808 MAC_ADDRESS_STR, __func__,
9809 MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes));
9810 }
9811 }
9812 {
9813 eHalStatus halStatus;
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309814
9815 /* Set the MAC Address Currently this is used by HAL to
9816 * add self sta. Remove this once self sta is added as
9817 * part of session open.
9818 */
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID,
9820 (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0],
9821 sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) );
Hardik Kantilal Patel4d7982a2013-12-02 18:53:30 +05309822
Jeff Johnson295189b2012-06-20 16:38:30 -07009823 if (!HAL_STATUS_SUCCESS( halStatus ))
9824 {
9825 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. "
9826 "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus );
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309827 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 }
9829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009830
9831 /*Start VOSS which starts up the SME/MAC/HAL modules and everything else
9832 Note: Firmware image will be read and downloaded inside vos_start API */
9833 status = vos_start( pHddCtx->pvosContext );
9834 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9835 {
9836 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309837 goto err_vosclose;
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 }
9839
Leo Chang6cec3e22014-01-21 15:33:49 -08009840#ifdef FEATURE_WLAN_CH_AVOID
9841 /* Plug in avoid channel notification callback
9842 * This should happen before ADD_SELF_STA
9843 * FW will send first IND with ADD_SELF_STA REQ from host */
Pradeep Reddy POTTETI5c2e16d2014-06-27 16:47:38 +05309844
9845 /* check the Channel Avoidance is enabled */
9846 if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance)
9847 {
9848 sme_AddChAvoidCallback(pHddCtx->hHal,
9849 hdd_hostapd_ch_avoid_cb);
9850 }
Leo Chang6cec3e22014-01-21 15:33:49 -08009851#endif /* FEATURE_WLAN_CH_AVOID */
9852
Madan Mohan Koyyalamudi8612ec92012-09-28 15:53:07 -07009853 /* Exchange capability info between Host and FW and also get versioning info from FW */
9854 hdd_exchange_version_and_caps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07009855
Agarwal Ashishad9281b2014-06-10 14:57:30 +05309856#ifdef CONFIG_ENABLE_LINUX_REG
9857 status = wlan_hdd_init_channels(pHddCtx);
9858 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9859 {
9860 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed",
9861 __func__);
9862 goto err_vosstop;
9863 }
9864#endif
9865
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 status = hdd_post_voss_start_config( pHddCtx );
9867 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9868 {
9869 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed",
9870 __func__);
9871 goto err_vosstop;
9872 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009873
9874#ifndef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309875 wlan_hdd_cfg80211_update_reg_info( wiphy );
9876
9877 /* registration of wiphy dev with cfg80211 */
9878 if (0 > wlan_hdd_cfg80211_register(wiphy))
9879 {
9880 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9881 goto err_vosstop;
9882 }
Amar Singhala49cbc52013-10-08 18:37:44 -07009883#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009884
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309885#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309886 /* registration of wiphy dev with cfg80211 */
9887 if (0 > wlan_hdd_cfg80211_register(wiphy))
9888 {
9889 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
9890 goto err_vosstop;
9891 }
9892
Agarwal Ashish6db9d532014-09-30 18:19:10 +05309893 status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +05309894 if ( !VOS_IS_STATUS_SUCCESS( status ) )
9895 {
9896 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed",
9897 __func__);
9898 goto err_unregister_wiphy;
9899 }
9900#endif
9901
c_hpothu4a298be2014-12-22 21:12:51 +05309902 wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx);
9903
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 if (VOS_STA_SAP_MODE == hdd_get_conparam())
9905 {
9906 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d",
9907 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9908 }
9909 else
9910 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d",
9912 wlan_hdd_get_intf_addr(pHddCtx), FALSE );
9913 if (pAdapter != NULL)
9914 {
Katya Nigama7d81d72014-11-12 12:44:34 +05309915 if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && !(pHddCtx->cfg_ini->intfMacAddr[0].bytes[0] & 0x02))
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309917 vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes,
9918 pHddCtx->cfg_ini->intfMacAddr[0].bytes,
9919 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudiedfc1b72012-10-18 20:25:55 -07009920
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309921 /* Generate the P2P Device Address. This consists of the device's
9922 * primary MAC address with the locally administered bit set.
9923 */
9924 pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02;
Jeff Johnsone7245742012-09-05 17:12:55 -07009925 }
9926 else
9927 {
Gopichand Nakkala49f96f62013-02-06 14:38:17 +05309928 tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx);
9929 if (p2p_dev_addr != NULL)
9930 {
9931 vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0],
9932 p2p_dev_addr, VOS_MAC_ADDR_SIZE);
9933 }
9934 else
9935 {
9936 hddLog(VOS_TRACE_LEVEL_FATAL,
9937 "%s: Failed to allocate mac_address for p2p_device",
9938 __func__);
9939 goto err_close_adapter;
9940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009942
9943 pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d",
9944 &pHddCtx->p2pDeviceAddress.bytes[0], FALSE );
9945 if ( NULL == pP2pAdapter )
9946 {
9947 hddLog(VOS_TRACE_LEVEL_FATAL,
9948 "%s: Failed to do hdd_open_adapter for P2P Device Interface",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009949 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07009950 goto err_close_adapter;
9951 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009954
9955 if( pAdapter == NULL )
9956 {
Jeff Johnsonbc676b42013-02-14 16:04:08 -08009957 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__);
9958 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009960
Arif Hussain66559122013-11-21 10:11:40 -08009961 if (country_code)
9962 {
9963 eHalStatus ret;
Arif Hussaincb607082013-12-20 11:57:42 -08009964 INIT_COMPLETION(pAdapter->change_country_code);
Arif Hussain66559122013-11-21 10:11:40 -08009965 hdd_checkandupdate_dfssetting(pAdapter, country_code);
9966#ifndef CONFIG_ENABLE_LINUX_REG
9967 hdd_checkandupdate_phymode(pAdapter, country_code);
9968#endif
Arif Hussaineaf68602013-12-30 23:10:44 -08009969 ret = sme_ChangeCountryCode(pHddCtx->hHal,
9970 (void *)(tSmeChangeCountryCallback)
9971 wlan_hdd_change_country_code_callback,
Arif Hussain66559122013-11-21 10:11:40 -08009972 country_code,
9973 pAdapter, pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05309974 eSIR_TRUE, eSIR_TRUE);
Arif Hussain66559122013-11-21 10:11:40 -08009975 if (eHAL_STATUS_SUCCESS == ret)
9976 {
Arif Hussaincb607082013-12-20 11:57:42 -08009977 ret = wait_for_completion_interruptible_timeout(
9978 &pAdapter->change_country_code,
9979 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
9980
9981 if (0 >= ret)
9982 {
9983 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9984 "%s: SME while setting country code timed out", __func__);
9985 }
Arif Hussain66559122013-11-21 10:11:40 -08009986 }
9987 else
9988 {
Arif Hussaincb607082013-12-20 11:57:42 -08009989 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
9990 "%s: SME Change Country code from module param fail ret=%d",
9991 __func__, ret);
Arif Hussain66559122013-11-21 10:11:40 -08009992 }
9993 }
9994
Jeff Johnson295189b2012-06-20 16:38:30 -07009995#ifdef WLAN_BTAMP_FEATURE
9996 vStatus = WLANBAP_Open(pVosContext);
9997 if(!VOS_IS_STATUS_SUCCESS(vStatus))
9998 {
9999 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
10000 "%s: Failed to open BAP",__func__);
Jeff Johnsone7245742012-09-05 17:12:55 -070010001 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 }
10003
10004 vStatus = BSL_Init(pVosContext);
10005 if(!VOS_IS_STATUS_SUCCESS(vStatus))
10006 {
10007 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
10008 "%s: Failed to Init BSL",__func__);
10009 goto err_bap_close;
10010 }
10011 vStatus = WLANBAP_Start(pVosContext);
10012 if (!VOS_IS_STATUS_SUCCESS(vStatus))
10013 {
10014 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
10015 "%s: Failed to start TL",__func__);
10016 goto err_bap_close;
10017 }
10018
10019 pConfig = pHddCtx->cfg_ini;
10020 btAmpConfig.ucPreferredChannel = pConfig->preferredChannel;
10021 status = WLANBAP_SetConfig(&btAmpConfig);
10022
10023#endif //WLAN_BTAMP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -070010024
Mihir Shete9c238772014-10-15 14:35:16 +053010025 /*
10026 * UapsdMask is 0xf if U-APSD is enbaled for all AC's...
10027 * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value)
10028 * which is greater than 0xf. So the below check is safe to make
10029 * sure that there is no entry for UapsdMask in the ini
10030 */
10031 if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask)
10032 {
10033 if(IS_DYNAMIC_WMM_PS_ENABLED)
10034 {
10035 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO",
10036 __func__);
10037 pHddCtx->cfg_ini->UapsdMask =
10038 CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT;
10039 }
10040 else
10041 {
10042 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD",
10043 __func__);
10044 pHddCtx->cfg_ini->UapsdMask =
10045 CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT;
10046 }
10047 }
10048
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010049#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10050 if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE))
10051 {
10052 hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__);
10053 pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0;
10054 sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal),
10055 pHddCtx->cfg_ini->isRoamOffloadScanEnabled);
10056 }
10057#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010058
Agarwal Ashish4b87f922014-06-18 03:03:21 +053010059 wlan_hdd_tdls_init(pHddCtx);
10060
Mihir Shetefc7ff5b2014-01-27 11:30:05 +053010061 sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done);
10062
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 /* Register with platform driver as client for Suspend/Resume */
10064 status = hddRegisterPmOps(pHddCtx);
10065 if ( !VOS_IS_STATUS_SUCCESS( status ) )
10066 {
10067 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__);
10068#ifdef WLAN_BTAMP_FEATURE
10069 goto err_bap_stop;
10070#else
Jeff Johnsone7245742012-09-05 17:12:55 -070010071 goto err_close_adapter;
Jeff Johnson295189b2012-06-20 16:38:30 -070010072#endif //WLAN_BTAMP_FEATURE
10073 }
10074
Yue Ma0d4891e2013-08-06 17:01:45 -070010075 /* Open debugfs interface */
10076 if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter))
10077 {
10078 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
10079 "%s: hdd_debugfs_init failed!", __func__);
Yue Ma0d4891e2013-08-06 17:01:45 -070010080 }
10081
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 /* Register TM level change handler function to the platform */
10083 status = hddDevTmRegisterNotifyCallback(pHddCtx);
10084 if ( !VOS_IS_STATUS_SUCCESS( status ) )
10085 {
10086 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__);
10087 goto err_unregister_pmops;
10088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010089
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 // register net device notifier for device change notification
10091 ret = register_netdevice_notifier(&hdd_netdev_notifier);
10092
10093 if(ret < 0)
10094 {
10095 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__);
Siddharth Bhalcd92b782015-06-29 12:25:40 +053010096 goto err_unregister_pmops;
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 }
10098
10099 //Initialize the nlink service
10100 if(nl_srv_init() != 0)
10101 {
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010102 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 goto err_reg_netdev;
10104 }
10105
Leo Chang4ce1cc52013-10-21 18:27:15 -070010106#ifdef WLAN_KD_READY_NOTIFIER
10107 pHddCtx->kd_nl_init = 1;
10108#endif /* WLAN_KD_READY_NOTIFIER */
10109
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 //Initialize the BTC service
10111 if(btc_activate_service(pHddCtx) != 0)
10112 {
10113 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__);
10114 goto err_nl_srv;
10115 }
10116
10117#ifdef PTT_SOCK_SVC_ENABLE
10118 //Initialize the PTT service
10119 if(ptt_sock_activate_svc(pHddCtx) != 0)
10120 {
10121 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__);
10122 goto err_nl_srv;
10123 }
10124#endif
10125
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010126#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10127 if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable)
10128 {
Deepthi Gowri78083a32014-11-04 12:55:51 +053010129 if(wlan_logging_sock_activate_svc(
10130 pHddCtx->cfg_ini->wlanLoggingFEToConsole,
10131 pHddCtx->cfg_ini->wlanLoggingNumBuf))
10132 {
10133 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc"
10134 " failed", __func__);
10135 goto err_nl_srv;
10136 }
10137 //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for
10138 //EAPOL and DHCP
Sachin Ahuja8c65f382014-12-12 15:34:21 +053010139 if (!pHddCtx->cfg_ini->gEnableDebugLog)
10140 pHddCtx->cfg_ini->gEnableDebugLog =
10141 VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP;
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010142 }
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010143
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010144 if (pHddCtx->cfg_ini->wlanLoggingEnable &&
10145 (pHddCtx->cfg_ini->enableFWLogging ||
Siddharth Bhaldb963232015-06-25 19:34:35 +053010146 pHddCtx->cfg_ini->enableMgmtLogging ||
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010147 pHddCtx->cfg_ini->enableContFWLogging))
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010148 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010149 hdd_init_frame_logging(pHddCtx);
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010150 }
10151 else
10152 {
Siddharth Bhald1be97f2015-05-27 22:39:59 +053010153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Logging disabled in ini"));
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010154 }
10155
Vinay Krishna Erannad938c422014-03-10 17:14:21 +053010156#endif
Siddharth Bhalb7c421c2015-02-27 00:26:09 +053010157
10158
Sushant Kaushik215778f2015-05-21 14:05:36 +053010159 if (vos_is_multicast_logging())
10160 wlan_logging_set_log_level();
10161
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 hdd_register_mcast_bcast_filter(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 if (VOS_STA_SAP_MODE != hdd_get_conparam())
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -070010165 /* Action frame registered in one adapter which will
10166 * applicable to all interfaces
10167 */
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +053010168 wlan_hdd_cfg80211_register_frames(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010170
10171 mutex_init(&pHddCtx->sap_lock);
Mahesh A Saptasagar60627942014-10-13 13:55:14 +053010172 mutex_init(&pHddCtx->roc_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -070010173
Jeff Johnsone7245742012-09-05 17:12:55 -070010174#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
10175 /* Initialize the wake lcok */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010176 vos_wake_lock_init(&pHddCtx->rx_wake_lock,
Jeff Johnsone7245742012-09-05 17:12:55 -070010177 "qcom_rx_wakelock");
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010178
Jeff Johnsone7245742012-09-05 17:12:55 -070010179#endif
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -080010180 /* Initialize the wake lcok */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010181 vos_wake_lock_init(&pHddCtx->sap_wake_lock,
Madan Mohan Koyyalamudi69fc3ad2012-11-28 16:04:56 -080010182 "qcom_sap_wakelock");
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010183
Jeff Johnsone7245742012-09-05 17:12:55 -070010184
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010185 vos_event_init(&pHddCtx->scan_info.scan_finished_event);
10186 pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010187
Katya Nigam5c306ea2014-06-19 15:39:54 +053010188 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070010189 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE);
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010190 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Katya Nigam5c306ea2014-06-19 15:39:54 +053010191
10192#ifdef FEATURE_WLAN_SCAN_PNO
10193 /*SME must send channel update configuration to RIVA*/
10194 sme_UpdateChannelConfig(pHddCtx->hHal);
10195#endif
Abhishek Singhf644b272014-08-21 02:59:39 +053010196 /* Send the update default channel list to the FW*/
10197 sme_UpdateChannelList(pHddCtx->hHal);
Mukul Sharma45063942015-04-01 20:07:59 +053010198
10199 /* Fwr capabilities received, Set the Dot11 mode */
10200 sme_SetDefDot11Mode(pHddCtx->hHal);
10201
Abhishek Singha306a442013-11-07 18:39:01 +053010202#ifndef CONFIG_ENABLE_LINUX_REG
10203 /*updating wiphy so that regulatory user hints can be processed*/
10204 if (wiphy)
10205 {
10206 regulatory_hint(wiphy, "00");
10207 }
10208#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010209 // Initialize the restart logic
10210 wlan_hdd_restart_init(pHddCtx);
Chilam NG571c65a2013-01-19 12:27:36 +053010211
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -070010212 //Register the traffic monitor timer now
10213 if ( pHddCtx->cfg_ini->dynSplitscan)
10214 {
10215 vos_timer_init(&pHddCtx->tx_rx_trafficTmr,
10216 VOS_TIMER_TYPE_SW,
10217 hdd_tx_rx_pkt_cnt_stat_timer_handler,
10218 (void *)pHddCtx);
10219 }
Srinivas Dasari030bad32015-02-18 23:23:54 +053010220 wlan_hdd_cfg80211_nan_init(pHddCtx);
10221
Dino Mycle6fb96c12014-06-10 11:52:40 +053010222#ifdef WLAN_FEATURE_EXTSCAN
10223 sme_EXTScanRegisterCallback(pHddCtx->hHal,
10224 wlan_hdd_cfg80211_extscan_callback,
10225 pHddCtx);
10226#endif /* WLAN_FEATURE_EXTSCAN */
Vinay Krishna Erannaf97ef5c2014-12-26 17:47:19 +053010227
10228#ifdef WLAN_NS_OFFLOAD
10229 // Register IPv6 notifier to notify if any change in IP
10230 // So that we can reconfigure the offload parameters
10231 pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed;
10232 ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier);
10233 if (ret)
10234 {
10235 hddLog(LOGE, FL("Failed to register IPv6 notifier"));
10236 }
10237 else
10238 {
10239 hddLog(LOGE, FL("Registered IPv6 notifier"));
10240 }
10241#endif
10242
10243 // Register IPv4 notifier to notify if any change in IP
10244 // So that we can reconfigure the offload parameters
10245 pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed;
10246 ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier);
10247 if (ret)
10248 {
10249 hddLog(LOGE, FL("Failed to register IPv4 notifier"));
10250 }
10251 else
10252 {
10253 hddLog(LOGE, FL("Registered IPv4 notifier"));
10254 }
10255
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 goto success;
10257
10258err_nl_srv:
Leo Chang59cdc7e2013-07-10 10:08:21 -070010259#ifdef WLAN_KD_READY_NOTIFIER
10260 nl_srv_exit(pHddCtx->ptt_pid);
10261#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 nl_srv_exit();
Leo Chang59cdc7e2013-07-10 10:08:21 -070010263#endif /* WLAN_KD_READY_NOTIFIER */
Jeff Johnson295189b2012-06-20 16:38:30 -070010264err_reg_netdev:
10265 unregister_netdevice_notifier(&hdd_netdev_notifier);
10266
Jeff Johnson295189b2012-06-20 16:38:30 -070010267err_unregister_pmops:
10268 hddDevTmUnregisterNotifyCallback(pHddCtx);
10269 hddDeregisterPmOps(pHddCtx);
10270
Yue Ma0d4891e2013-08-06 17:01:45 -070010271 hdd_debugfs_exit(pHddCtx);
10272
Jeff Johnson295189b2012-06-20 16:38:30 -070010273#ifdef WLAN_BTAMP_FEATURE
10274err_bap_stop:
10275 WLANBAP_Stop(pVosContext);
10276#endif
10277
10278#ifdef WLAN_BTAMP_FEATURE
10279err_bap_close:
10280 WLANBAP_Close(pVosContext);
10281#endif
10282
Jeff Johnson295189b2012-06-20 16:38:30 -070010283err_close_adapter:
10284 hdd_close_all_adapters( pHddCtx );
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +053010285#ifdef CONFIG_ENABLE_LINUX_REG
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053010286err_unregister_wiphy:
Mahesh A Saptasagar9ecefe42014-07-15 18:43:49 +053010287#endif
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010288 wiphy_unregister(wiphy) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070010289err_vosstop:
10290 vos_stop(pVosContext);
10291
Amar Singhala49cbc52013-10-08 18:37:44 -070010292err_vosclose:
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 status = vos_sched_close( pVosContext );
10294 if (!VOS_IS_STATUS_SUCCESS(status)) {
10295 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
10296 "%s: Failed to close VOSS Scheduler", __func__);
10297 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) );
10298 }
Amar Singhala49cbc52013-10-08 18:37:44 -070010299 vos_close(pVosContext );
10300
Amar Singhal0a402232013-10-11 20:57:16 -070010301err_vos_nv_close:
10302
c_hpothue6a36282014-03-19 12:27:38 +053010303#ifdef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -070010304 vos_nv_close();
10305
c_hpothu70f8d812014-03-22 22:59:23 +053010306#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010307
10308err_wdclose:
10309 if(pHddCtx->cfg_ini->fIsLogpEnabled)
10310 vos_watchdog_close(pVosContext);
10311
Jeff Johnson295189b2012-06-20 16:38:30 -070010312err_config:
10313 kfree(pHddCtx->cfg_ini);
10314 pHddCtx->cfg_ini= NULL;
10315
10316err_free_hdd_context:
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010317 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
Siddharth Bhalcd92b782015-06-29 12:25:40 +053010318 free_riva_power_on_lock("wlan");
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 wiphy_free(wiphy) ;
10320 //kfree(wdev) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 VOS_BUG(1);
10322
Madan Mohan Koyyalamudid57ae632012-11-06 18:42:48 -080010323 if (hdd_is_ssr_required())
10324 {
10325 /* WDI timeout had happened during load, so SSR is needed here */
10326 subsystem_restart("wcnss");
10327 msleep(5000);
10328 }
10329 hdd_set_ssr_required (VOS_FALSE);
10330
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080010331 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070010332
10333success:
10334 EXIT();
10335 return 0;
10336}
10337
10338/**---------------------------------------------------------------------------
10339
Jeff Johnson32d95a32012-09-10 13:15:23 -070010340 \brief hdd_driver_init() - Core Driver Init Function
Jeff Johnson295189b2012-06-20 16:38:30 -070010341
Jeff Johnson32d95a32012-09-10 13:15:23 -070010342 This is the driver entry point - called in different timeline depending
10343 on whether the driver is statically or dynamically linked
Jeff Johnson295189b2012-06-20 16:38:30 -070010344
10345 \param - None
10346
10347 \return - 0 for success, non zero for failure
10348
10349 --------------------------------------------------------------------------*/
Jeff Johnson32d95a32012-09-10 13:15:23 -070010350static int hdd_driver_init( void)
Jeff Johnson295189b2012-06-20 16:38:30 -070010351{
10352 VOS_STATUS status;
10353 v_CONTEXT_t pVosContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 struct device *dev = NULL;
10355 int ret_status = 0;
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010356#ifdef HAVE_WCNSS_CAL_DOWNLOAD
10357 int max_retries = 0;
10358#endif
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010359#ifdef HAVE_CBC_DONE
10360 int max_cbc_retries = 0;
10361#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010362
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010363#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10364 wlan_logging_sock_init_svc();
10365#endif
10366
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 ENTER();
10368
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010369 vos_wake_lock_init(&wlan_wake_lock, "wlan");
Jeff Johnson295189b2012-06-20 16:38:30 -070010370
10371 pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME,
10372 QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR);
10373
Jeff Johnson295189b2012-06-20 16:38:30 -070010374#ifdef ANI_BUS_TYPE_PCI
10375
10376 dev = wcnss_wlan_get_device();
10377
10378#endif // ANI_BUS_TYPE_PCI
10379
10380#ifdef ANI_BUS_TYPE_PLATFORM
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010381
10382#ifdef HAVE_WCNSS_CAL_DOWNLOAD
10383 /* wait until WCNSS driver downloads NV */
10384 while (!wcnss_device_ready() && 5 >= ++max_retries) {
10385 msleep(1000);
10386 }
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010387
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010388 if (max_retries >= 5) {
10389 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__);
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010390 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010391#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10392 wlan_logging_sock_deinit_svc();
10393#endif
10394
Sameer Thalappilf58d7ec2013-04-25 20:17:12 -070010395 return -ENODEV;
10396 }
10397#endif
10398
Siddharth Bhalc7e79b62014-10-10 22:37:38 +053010399#ifdef HAVE_CBC_DONE
10400 while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) {
10401 msleep(1000);
10402 }
10403 if (max_cbc_retries >= 10) {
10404 hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__);
10405 }
10406#endif
10407
Jeff Johnson295189b2012-06-20 16:38:30 -070010408 dev = wcnss_wlan_get_device();
10409#endif // ANI_BUS_TYPE_PLATFORM
10410
10411
10412 do {
10413 if (NULL == dev) {
10414 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__);
10415 ret_status = -1;
10416 break;
10417 }
10418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419#ifdef TIMER_MANAGER
10420 vos_timer_manager_init();
10421#endif
10422
10423 /* Preopen VOSS so that it is ready to start at least SAL */
10424 status = vos_preOpen(&pVosContext);
10425
10426 if (!VOS_IS_STATUS_SUCCESS(status))
10427 {
10428 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__);
10429 ret_status = -1;
10430 break;
10431 }
10432
Sushant Kaushik02beb352015-06-04 15:15:01 +053010433 hddTraceInit();
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010434#ifndef MODULE
10435 /* For statically linked driver, call hdd_set_conparam to update curr_con_mode
10436 */
10437 hdd_set_conparam((v_UINT_t)con_mode);
10438#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010439
10440 // Call our main init function
Jeff Johnsonbc676b42013-02-14 16:04:08 -080010441 if (hdd_wlan_startup(dev))
10442 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed",
Jeff Johnsonbc676b42013-02-14 16:04:08 -080010444 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 vos_preClose( &pVosContext );
10446 ret_status = -1;
10447 break;
10448 }
10449
Jeff Johnson295189b2012-06-20 16:38:30 -070010450 } while (0);
10451
10452 if (0 != ret_status)
10453 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010454#ifdef TIMER_MANAGER
10455 vos_timer_exit();
10456#endif
10457#ifdef MEMORY_DEBUG
10458 vos_mem_exit();
10459#endif
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010460 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010461#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10462 wlan_logging_sock_deinit_svc();
10463#endif
10464
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 pr_err("%s: driver load failure\n", WLAN_MODULE_NAME);
10466 }
10467 else
10468 {
10469 //Send WLAN UP indication to Nlink Service
10470 send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0);
10471
10472 pr_info("%s: driver loaded\n", WLAN_MODULE_NAME);
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 }
10474
10475 EXIT();
10476
10477 return ret_status;
10478}
10479
Jeff Johnson32d95a32012-09-10 13:15:23 -070010480/**---------------------------------------------------------------------------
10481
10482 \brief hdd_module_init() - Init Function
10483
10484 This is the driver entry point (invoked when module is loaded using insmod)
10485
10486 \param - None
10487
10488 \return - 0 for success, non zero for failure
10489
10490 --------------------------------------------------------------------------*/
10491#ifdef MODULE
10492static int __init hdd_module_init ( void)
10493{
10494 return hdd_driver_init();
10495}
Jeff Johnson32d95a32012-09-10 13:15:23 -070010496#else /* #ifdef MODULE */
10497static int __init hdd_module_init ( void)
10498{
10499 /* Driver initialization is delayed to fwpath_changed_handler */
10500 return 0;
10501}
Jeff Johnson32d95a32012-09-10 13:15:23 -070010502#endif /* #ifdef MODULE */
10503
Jeff Johnson295189b2012-06-20 16:38:30 -070010504
10505/**---------------------------------------------------------------------------
10506
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010507 \brief hdd_driver_exit() - Exit function
Jeff Johnson295189b2012-06-20 16:38:30 -070010508
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010509 This is the driver exit point (invoked when module is unloaded using rmmod
10510 or con_mode was changed by userspace)
Jeff Johnson295189b2012-06-20 16:38:30 -070010511
10512 \param - None
10513
10514 \return - None
10515
10516 --------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010517static void hdd_driver_exit(void)
Jeff Johnson295189b2012-06-20 16:38:30 -070010518{
10519 hdd_context_t *pHddCtx = NULL;
10520 v_CONTEXT_t pVosContext = NULL;
Agarwal Ashish5e414792014-06-08 15:25:23 +053010521 v_REGDOMAIN_t regId;
Arun Kumar Khandavallie0b046d2014-03-01 21:54:25 +053010522 unsigned long rc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010523
10524 pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR);
10525
10526 //Get the global vos context
10527 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);
10528
10529 if(!pVosContext)
10530 {
10531 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__);
10532 goto done;
10533 }
10534
10535 //Get the HDD context.
10536 pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext );
10537
10538 if(!pHddCtx)
10539 {
10540 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__);
10541 }
Katya Nigame7b69a82015-04-28 15:24:06 +053010542 else if (VOS_MONITOR_MODE == hdd_get_conparam())
10543 {
10544 hddLog(VOS_TRACE_LEVEL_INFO,"%s: MONITOR MODE",__func__);
10545 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
10546 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
10547 hdd_wlan_exit(pHddCtx);
10548 vos_preClose( &pVosContext );
10549 goto done;
10550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 else
10552 {
Siddharth Bhal2e5871b2015-03-24 16:20:51 +053010553 /* We wait for active entry threads to exit from driver
10554 * by waiting until rtnl_lock is available.
10555 */
10556 rtnl_lock();
10557 rtnl_unlock();
10558
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010559 INIT_COMPLETION(pHddCtx->ssr_comp_var);
10560 if ((pHddCtx->isLogpInProgress) && (FALSE ==
10561 vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL)))
10562 {
Siddharth Bhala204f572015-01-17 02:03:36 +053010563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010564 "%s:SSR in Progress; block rmmod !!!", __func__);
Siddharth Bhala204f572015-01-17 02:03:36 +053010565 rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var,
10566 msecs_to_jiffies(30000));
10567 if(!rc)
10568 {
10569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10570 "%s:SSR timedout, fatal error", __func__);
10571 VOS_BUG(0);
10572 }
10573 }
10574
Siddharth Bhal3c29dca2015-02-19 00:41:40 +053010575 pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS;
10576 vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010577
c_hpothu8adb97b2014-12-08 19:38:20 +053010578 /* Driver Need to send country code 00 in below condition
10579 * 1) If gCountryCodePriority is set to 1; and last country
10580 * code set is through 11d. This needs to be done in case
10581 * when NV country code is 00.
10582 * This Needs to be done as when kernel store last country
10583 * code and if stored country code is not through 11d,
10584 * in sme_HandleChangeCountryCodeByUser we will disable 11d
10585 * in next load/unload as soon as we get any country through
10586 * 11d. In sme_HandleChangeCountryCodeByUser
10587 * pMsg->countryCode will be last countryCode and
10588 * pMac->scan.countryCode11d will be country through 11d so
10589 * due to mismatch driver will disable 11d.
10590 *
10591 */
Agarwal Ashish8db39882014-07-30 21:56:07 +053010592
c_hpothu8adb97b2014-12-08 19:38:20 +053010593 if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) &&
Agarwal Ashish8dcd2862014-07-25 11:58:52 +053010594 pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority &&
Abhishek Singh2a705962014-10-30 14:47:28 +053010595 sme_Is11dSupported(pHddCtx->hHal)))
c_hpothu8adb97b2014-12-08 19:38:20 +053010596 {
10597 hddLog(VOS_TRACE_LEVEL_INFO,
Agarwal Ashish8dcd2862014-07-25 11:58:52 +053010598 FL("CountryCode 00 is being set while unloading driver"));
c_hpothu8adb97b2014-12-08 19:38:20 +053010599 vos_nv_getRegDomainFromCountryCode(&regId , "00", COUNTRY_USER);
10600 }
Agarwal Ashish5e414792014-06-08 15:25:23 +053010601
c_hpothu8adb97b2014-12-08 19:38:20 +053010602 //Do all the cleanup before deregistering the driver
10603 hdd_wlan_exit(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 }
10605
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 vos_preClose( &pVosContext );
10607
10608#ifdef TIMER_MANAGER
10609 vos_timer_exit();
10610#endif
10611#ifdef MEMORY_DEBUG
10612 vos_mem_exit();
10613#endif
10614
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010615#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
10616 wlan_logging_sock_deinit_svc();
10617#endif
10618
Jeff Johnson295189b2012-06-20 16:38:30 -070010619done:
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010620 vos_wake_lock_destroy(&wlan_wake_lock);
Vinay Krishna Eranna273ec5a2014-05-10 18:05:25 +053010621
Jeff Johnson295189b2012-06-20 16:38:30 -070010622 pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME);
10623}
10624
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010625/**---------------------------------------------------------------------------
10626
10627 \brief hdd_module_exit() - Exit function
10628
10629 This is the driver exit point (invoked when module is unloaded using rmmod)
10630
10631 \param - None
10632
10633 \return - None
10634
10635 --------------------------------------------------------------------------*/
10636static void __exit hdd_module_exit(void)
10637{
10638 hdd_driver_exit();
10639}
10640
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010641#ifdef MODULE
10642static int fwpath_changed_handler(const char *kmessage,
10643 struct kernel_param *kp)
10644{
Jeff Johnson76052702013-04-16 13:55:05 -070010645 return param_set_copystring(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010646}
10647
10648static int con_mode_handler(const char *kmessage,
10649 struct kernel_param *kp)
10650{
Madan Mohan Koyyalamudif2f8d8b2012-10-11 17:06:59 -070010651 return param_set_int(kmessage, kp);
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010652}
10653#else /* #ifdef MODULE */
10654/**---------------------------------------------------------------------------
10655
Jeff Johnson76052702013-04-16 13:55:05 -070010656 \brief kickstart_driver
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010657
Jeff Johnson76052702013-04-16 13:55:05 -070010658 This is the driver entry point
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010659 - delayed driver initialization when driver is statically linked
Jeff Johnson76052702013-04-16 13:55:05 -070010660 - invoked when module parameter fwpath is modified from userspace to signal
10661 initializing the WLAN driver or when con_mode is modified from userspace
10662 to signal a switch in operating mode
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010663
10664 \return - 0 for success, non zero for failure
10665
10666 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -070010667static int kickstart_driver(void)
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010668{
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010669 int ret_status;
10670
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010671 if (!wlan_hdd_inited) {
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010672 ret_status = hdd_driver_init();
10673 wlan_hdd_inited = ret_status ? 0 : 1;
10674 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010675 }
10676
10677 hdd_driver_exit();
Jeff Johnson76052702013-04-16 13:55:05 -070010678
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010679 msleep(200);
Jeff Johnson76052702013-04-16 13:55:05 -070010680
Madan Mohan Koyyalamudi62e60052012-10-05 14:27:22 -070010681 ret_status = hdd_driver_init();
10682 wlan_hdd_inited = ret_status ? 0 : 1;
10683 return ret_status;
Madan Mohan Koyyalamudic2ec3bd2012-09-18 19:49:40 -070010684}
10685
Jeff Johnson295189b2012-06-20 16:38:30 -070010686/**---------------------------------------------------------------------------
10687
Jeff Johnson76052702013-04-16 13:55:05 -070010688 \brief fwpath_changed_handler() - Handler Function
10689
10690 Handle changes to the fwpath parameter
10691
10692 \return - 0 for success, non zero for failure
10693
10694 --------------------------------------------------------------------------*/
10695static int fwpath_changed_handler(const char *kmessage,
10696 struct kernel_param *kp)
10697{
10698 int ret;
10699
10700 ret = param_set_copystring(kmessage, kp);
10701 if (0 == ret)
10702 ret = kickstart_driver();
10703 return ret;
10704}
10705
10706/**---------------------------------------------------------------------------
10707
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010708 \brief con_mode_handler() -
10709
10710 Handler function for module param con_mode when it is changed by userspace
10711 Dynamically linked - do nothing
10712 Statically linked - exit and init driver, as in rmmod and insmod
10713
Jeff Johnson76052702013-04-16 13:55:05 -070010714 \param -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010715
Jeff Johnson76052702013-04-16 13:55:05 -070010716 \return -
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010717
10718 --------------------------------------------------------------------------*/
Jeff Johnson76052702013-04-16 13:55:05 -070010719static int con_mode_handler(const char *kmessage, struct kernel_param *kp)
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010720{
Jeff Johnson76052702013-04-16 13:55:05 -070010721 int ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010722
Jeff Johnson76052702013-04-16 13:55:05 -070010723 ret = param_set_int(kmessage, kp);
10724 if (0 == ret)
10725 ret = kickstart_driver();
10726 return ret;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010727}
10728#endif /* #ifdef MODULE */
10729
10730/**---------------------------------------------------------------------------
10731
Jeff Johnson295189b2012-06-20 16:38:30 -070010732 \brief hdd_get_conparam() -
10733
10734 This is the driver exit point (invoked when module is unloaded using rmmod)
10735
10736 \param - None
10737
10738 \return - tVOS_CON_MODE
10739
10740 --------------------------------------------------------------------------*/
10741tVOS_CON_MODE hdd_get_conparam ( void )
10742{
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010743#ifdef MODULE
Jeff Johnson295189b2012-06-20 16:38:30 -070010744 return (tVOS_CON_MODE)con_mode;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010745#else
10746 return (tVOS_CON_MODE)curr_con_mode;
10747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010748}
10749void hdd_set_conparam ( v_UINT_t newParam )
10750{
10751 con_mode = newParam;
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070010752#ifndef MODULE
10753 curr_con_mode = con_mode;
10754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010755}
10756/**---------------------------------------------------------------------------
10757
10758 \brief hdd_softap_sta_deauth() - function
10759
10760 This to take counter measure to handle deauth req from HDD
10761
10762 \param - pAdapter - Pointer to the HDD
10763
10764 \param - enable - boolean value
10765
10766 \return - None
10767
10768 --------------------------------------------------------------------------*/
10769
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010770VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter,
10771 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070010772{
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010774 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -070010775
10776 ENTER();
10777
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070010778 hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)",
10779 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010780
10781 //Ignore request to deauth bcmc station
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010782 if (pDelStaParams->peerMacAddr[0] & 0x1)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010783 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -070010784
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010785 vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010786
10787 EXIT();
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010788 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -070010789}
10790
10791/**---------------------------------------------------------------------------
10792
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010793 \brief hdd_del_all_sta() - function
10794
10795 This function removes all the stations associated on stopping AP/P2P GO.
10796
10797 \param - pAdapter - Pointer to the HDD
10798
10799 \return - None
10800
10801 --------------------------------------------------------------------------*/
10802
10803int hdd_del_all_sta(hdd_adapter_t *pAdapter)
10804{
10805 v_U16_t i;
10806 VOS_STATUS vos_status;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010807 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10808 ptSapContext pSapCtx = NULL;
10809 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10810 if(pSapCtx == NULL){
10811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10812 FL("psapCtx is NULL"));
10813 return 1;
10814 }
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010815 ENTER();
10816
10817 hddLog(VOS_TRACE_LEVEL_INFO,
10818 "%s: Delete all STAs associated.",__func__);
10819 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
10820 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
10821 )
10822 {
10823 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
10824 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010825 if ((pSapCtx->aStaInfo[i].isUsed) &&
10826 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010827 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010828 struct tagCsrDelStaParams delStaParams;
10829
10830 WLANSAP_PopulateDelStaParams(
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010831 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053010832 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
10833 SIR_MAC_MGMT_DEAUTH >> 4,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053010834 &delStaParams);
10835 vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams);
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010836 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010837 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +053010838 }
10839 }
10840 }
10841
10842 EXIT();
10843 return 0;
10844}
10845
10846/**---------------------------------------------------------------------------
10847
Jeff Johnson295189b2012-06-20 16:38:30 -070010848 \brief hdd_softap_sta_disassoc() - function
10849
10850 This to take counter measure to handle deauth req from HDD
10851
10852 \param - pAdapter - Pointer to the HDD
10853
10854 \param - enable - boolean value
10855
10856 \return - None
10857
10858 --------------------------------------------------------------------------*/
10859
10860void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress)
10861{
10862 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10863
10864 ENTER();
10865
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010866 hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010867
10868 //Ignore request to disassoc bcmc station
10869 if( pDestMacAddress[0] & 0x1 )
10870 return;
10871
10872 WLANSAP_DisassocSta(pVosContext,pDestMacAddress);
10873}
10874
10875void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable)
10876{
10877 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10878
10879 ENTER();
10880
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +053010881 hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -070010882
10883 WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable);
10884}
10885
Jeff Johnson295189b2012-06-20 16:38:30 -070010886/**---------------------------------------------------------------------------
10887 *
10888 * \brief hdd_get__concurrency_mode() -
10889 *
10890 *
10891 * \param - None
10892 *
10893 * \return - CONCURRENCY MODE
10894 *
10895 * --------------------------------------------------------------------------*/
10896tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void )
10897{
10898 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
10899 hdd_context_t *pHddCtx;
10900
10901 if (NULL != pVosContext)
10902 {
10903 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
10904 if (NULL != pHddCtx)
10905 {
10906 return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode;
10907 }
10908 }
10909
10910 /* we are in an invalid state :( */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010911 hddLog(LOGE, "%s: Invalid context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 return VOS_STA;
10913}
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010914v_BOOL_t
10915wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx)
10916{
10917 hdd_adapter_t *pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010918
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010919 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO);
10920 if (pAdapter == NULL)
10921 {
10922 hddLog(VOS_TRACE_LEVEL_INFO,
10923 FL("GO doesn't exist"));
10924 return TRUE;
10925 }
10926 if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
10927 {
10928 hddLog(VOS_TRACE_LEVEL_INFO,
10929 FL("GO started"));
10930 return TRUE;
10931 }
10932 else
10933 /* wait till GO changes its interface to p2p device */
10934 hddLog(VOS_TRACE_LEVEL_INFO,
10935 FL("Del_bss called, avoid apps suspend"));
10936 return FALSE;
10937
10938}
Jeff Johnson295189b2012-06-20 16:38:30 -070010939/* Decide whether to allow/not the apps power collapse.
10940 * Allow apps power collapse if we are in connected state.
10941 * if not, allow only if we are in IMPS */
10942v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx)
10943{
10944 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
Srikant Kuppafef66a72013-01-30 17:32:44 -080010945 tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal);
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010946 tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 hdd_config_t *pConfig = pHddCtx->cfg_ini;
10948 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10949 hdd_adapter_t *pAdapter = NULL;
10950 VOS_STATUS status;
Yathish9f22e662012-12-10 14:21:35 -080010951 tVOS_CONCURRENCY_MODE concurrent_state = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010952
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 if (VOS_STA_SAP_MODE == hdd_get_conparam())
10954 return TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010955
Yathish9f22e662012-12-10 14:21:35 -080010956 concurrent_state = hdd_get_concurrency_mode();
10957
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010958 if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) &&
10959 !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx)))
10960 return FALSE;
Yathish9f22e662012-12-10 14:21:35 -080010961#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010962
Yathish9f22e662012-12-10 14:21:35 -080010963 if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) ||
Sushant Kaushikabb7ee62014-07-18 16:20:12 +053010964 (concurrent_state == (VOS_STA | VOS_P2P_GO)))&&
Yathish9f22e662012-12-10 14:21:35 -080010965 (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
10966 return TRUE;
10967#endif
10968
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 /*loop through all adapters. TBD fix for Concurrency */
10970 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10971 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10972 {
10973 pAdapter = pAdapterNode->pAdapter;
10974 if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
10975 || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
10976 {
Srikant Kuppafef66a72013-01-30 17:32:44 -080010977 if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled)
c_hpothu4e8faac2014-05-16 17:38:44 +053010978 && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD
c_hpothu1c6957d2015-01-06 18:19:47 +053010979 && pmcState != STOPPED && pmcState != STANDBY &&
10980 pmcState != WOWL)) ||
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010981 (eANI_BOOLEAN_TRUE == scanRspPending) ||
10982 (eANI_BOOLEAN_TRUE == inMiddleOfRoaming))
Jeff Johnson295189b2012-06-20 16:38:30 -070010983 {
Mukul Sharma4be88422015-03-09 20:29:07 +053010984 if(pmcState == FULL_POWER &&
10985 sme_IsCoexScoIndicationSet(pHddCtx->hHal))
10986 {
10987 /*
10988 * When SCO indication comes from Coex module , host will
10989 * enter in to full power mode, but this should not prevent
10990 * apps processor power collapse.
10991 */
10992 hddLog(LOG1,
10993 FL("Allow apps power collapse"
10994 "even when sco indication is set"));
10995 return TRUE;
10996 }
Srikant Kuppafef66a72013-01-30 17:32:44 -080010997 hddLog( LOGE, "%s: do not allow APPS power collapse-"
Srinivas Girigowdaa553c462013-03-07 19:42:52 -080010998 "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d",
10999 __func__, pmcState, scanRspPending, inMiddleOfRoaming );
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 return FALSE;
11001 }
11002 }
11003 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11004 pAdapterNode = pNext;
11005 }
11006 return TRUE;
11007}
11008
Madan Mohan Koyyalamudic72a4d62012-11-08 14:59:34 -080011009/* Decides whether to send suspend notification to Riva
11010 * if any adapter is in BMPS; then it is required */
11011v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx)
11012{
11013 tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal);
11014 hdd_config_t *pConfig = pHddCtx->cfg_ini;
11015
11016 if (pConfig->fIsBmpsEnabled && (pmcState == BMPS))
11017 {
11018 return TRUE;
11019 }
11020 return FALSE;
11021}
11022
Jeff Johnson295189b2012-06-20 16:38:30 -070011023void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11024{
11025 switch(mode)
11026 {
Chilam Ngc4244af2013-04-01 15:37:32 -070011027 case VOS_STA_MODE:
11028 case VOS_P2P_CLIENT_MODE:
11029 case VOS_P2P_GO_MODE:
11030 case VOS_STA_SAP_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -070011031 pHddCtx->concurrency_mode |= (1 << mode);
Agarwal Ashish51325b52014-06-16 16:50:49 +053011032 pHddCtx->no_of_open_sessions[mode]++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 break;
11034 default:
11035 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011037 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
11038 "Number of open sessions for mode %d = %d"),
11039 pHddCtx->concurrency_mode, mode,
11040 pHddCtx->no_of_open_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070011041}
11042
11043
11044void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11045{
11046 switch(mode)
11047 {
Chilam Ngc4244af2013-04-01 15:37:32 -070011048 case VOS_STA_MODE:
11049 case VOS_P2P_CLIENT_MODE:
11050 case VOS_P2P_GO_MODE:
11051 case VOS_STA_SAP_MODE:
Agarwal Ashish51325b52014-06-16 16:50:49 +053011052 pHddCtx->no_of_open_sessions[mode]--;
11053 if (!(pHddCtx->no_of_open_sessions[mode]))
11054 pHddCtx->concurrency_mode &= (~(1 << mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 break;
11056 default:
11057 break;
11058 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053011059 hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x "
11060 "Number of open sessions for mode %d = %d"),
11061 pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]);
11062
11063}
11064/**---------------------------------------------------------------------------
11065 *
11066 * \brief wlan_hdd_incr_active_session()
11067 *
11068 * This function increments the number of active sessions
11069 * maintained per device mode
11070 * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented
11071 * Incase of SAP/P2P GO upon bss start it is incremented
11072 *
11073 * \param pHddCtx - HDD Context
11074 * \param mode - device mode
11075 *
11076 * \return - None
11077 *
11078 * --------------------------------------------------------------------------*/
11079void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11080{
11081 switch (mode) {
11082 case VOS_STA_MODE:
11083 case VOS_P2P_CLIENT_MODE:
11084 case VOS_P2P_GO_MODE:
11085 case VOS_STA_SAP_MODE:
11086 pHddCtx->no_of_active_sessions[mode]++;
11087 break;
11088 default:
11089 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
11090 break;
11091 }
11092 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
11093 mode,
11094 pHddCtx->no_of_active_sessions[mode]);
11095}
11096
11097/**---------------------------------------------------------------------------
11098 *
11099 * \brief wlan_hdd_decr_active_session()
11100 *
11101 * This function decrements the number of active sessions
11102 * maintained per device mode
11103 * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented
11104 * Incase of SAP/P2P GO upon bss stop it is decremented
11105 *
11106 * \param pHddCtx - HDD Context
11107 * \param mode - device mode
11108 *
11109 * \return - None
11110 *
11111 * --------------------------------------------------------------------------*/
11112void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode)
11113{
11114 switch (mode) {
11115 case VOS_STA_MODE:
11116 case VOS_P2P_CLIENT_MODE:
11117 case VOS_P2P_GO_MODE:
11118 case VOS_STA_SAP_MODE:
Agarwal Ashish5325f522014-08-06 00:58:44 +053011119 if (pHddCtx->no_of_active_sessions[mode] > 0)
11120 pHddCtx->no_of_active_sessions[mode]--;
11121 else
11122 hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions"
11123 "is already Zero"));
Agarwal Ashish51325b52014-06-16 16:50:49 +053011124 break;
11125 default:
11126 hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode);
11127 break;
11128 }
11129 hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"),
11130 mode,
11131 pHddCtx->no_of_active_sessions[mode]);
Jeff Johnson295189b2012-06-20 16:38:30 -070011132}
11133
Jeff Johnsone7245742012-09-05 17:12:55 -070011134/**---------------------------------------------------------------------------
11135 *
11136 * \brief wlan_hdd_restart_init
11137 *
11138 * This function initalizes restart timer/flag. An internal function.
11139 *
11140 * \param - pHddCtx
11141 *
11142 * \return - None
11143 *
11144 * --------------------------------------------------------------------------*/
11145
11146static void wlan_hdd_restart_init(hdd_context_t *pHddCtx)
11147{
11148 /* Initialize */
11149 pHddCtx->hdd_restart_retries = 0;
11150 atomic_set(&pHddCtx->isRestartInProgress, 0);
11151 vos_timer_init(&pHddCtx->hdd_restart_timer,
11152 VOS_TIMER_TYPE_SW,
11153 wlan_hdd_restart_timer_cb,
11154 pHddCtx);
11155}
11156/**---------------------------------------------------------------------------
11157 *
11158 * \brief wlan_hdd_restart_deinit
11159 *
11160 * This function cleans up the resources used. An internal function.
11161 *
11162 * \param - pHddCtx
11163 *
11164 * \return - None
11165 *
11166 * --------------------------------------------------------------------------*/
11167
11168static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx)
11169{
11170
11171 VOS_STATUS vos_status;
11172 /* Block any further calls */
11173 atomic_set(&pHddCtx->isRestartInProgress, 1);
11174 /* Cleanup */
11175 vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer );
11176 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011177 hddLog(LOGE, FL("Failed to stop HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011178 vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer);
11179 if (!VOS_IS_STATUS_SUCCESS(vos_status))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011180 hddLog(LOGE, FL("Failed to destroy HDD restart timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070011181
11182}
11183
11184/**---------------------------------------------------------------------------
11185 *
11186 * \brief wlan_hdd_framework_restart
11187 *
11188 * This function uses a cfg80211 API to start a framework initiated WLAN
11189 * driver module unload/load.
11190 *
11191 * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT).
11192 *
11193 *
11194 * \param - pHddCtx
11195 *
11196 * \return - VOS_STATUS_SUCCESS: Success
11197 * VOS_STATUS_E_EMPTY: Adapter is Empty
11198 * VOS_STATUS_E_NOMEM: No memory
11199
11200 * --------------------------------------------------------------------------*/
11201
11202static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx)
11203{
11204 VOS_STATUS status = VOS_STATUS_SUCCESS;
11205 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011206 int len = (sizeof (struct ieee80211_mgmt));
11207 struct ieee80211_mgmt *mgmt = NULL;
11208
11209 /* Prepare the DEAUTH managment frame with reason code */
11210 mgmt = kzalloc(len, GFP_KERNEL);
11211 if(mgmt == NULL)
11212 {
11213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11214 "%s: memory allocation failed (%d bytes)", __func__, len);
11215 return VOS_STATUS_E_NOMEM;
11216 }
11217 mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK;
Jeff Johnsone7245742012-09-05 17:12:55 -070011218
11219 /* Iterate over all adapters/devices */
11220 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011221 if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status))
11222 {
11223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11224 FL("fail to get adapter: %p %d"), pAdapterNode, status);
11225 goto end;
11226 }
11227
Jeff Johnsone7245742012-09-05 17:12:55 -070011228 do
11229 {
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011230 if(pAdapterNode->pAdapter &&
11231 WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic)
Jeff Johnsone7245742012-09-05 17:12:55 -070011232 {
11233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11234 "restarting the driver(intf:\'%s\' mode:%d :try %d)",
11235 pAdapterNode->pAdapter->dev->name,
11236 pAdapterNode->pAdapter->device_mode,
11237 pHddCtx->hdd_restart_retries + 1);
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011238 /*
11239 * CFG80211 event to restart the driver
11240 *
11241 * 'cfg80211_send_unprot_deauth' sends a
11242 * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state
11243 * of SME(Linux Kernel) state machine.
11244 *
11245 * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart
11246 * the driver.
11247 *
11248 */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053011249#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
11250 cfg80211_rx_unprot_mlme_mgmt(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len);
11251#else
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011252 cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len );
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053011253#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011254 }
11255 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11256 pAdapterNode = pNext;
11257 } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status));
11258
Hanumantha Reddy Pothulada0fe362015-02-27 18:37:03 +053011259 end:
Madan Mohan Koyyalamudifc19e442013-05-09 18:24:08 -070011260 /* Free the allocated management frame */
11261 kfree(mgmt);
11262
Jeff Johnsone7245742012-09-05 17:12:55 -070011263 /* Retry until we unload or reach max count */
11264 if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT)
11265 vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS);
11266
11267 return status;
11268
11269}
11270/**---------------------------------------------------------------------------
11271 *
11272 * \brief wlan_hdd_restart_timer_cb
11273 *
11274 * Restart timer callback. An internal function.
11275 *
11276 * \param - User data:
11277 *
11278 * \return - None
11279 *
11280 * --------------------------------------------------------------------------*/
11281
11282void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback)
11283{
11284 hdd_context_t *pHddCtx = usrDataForCallback;
11285 wlan_hdd_framework_restart(pHddCtx);
11286 return;
11287
11288}
11289
11290
11291/**---------------------------------------------------------------------------
11292 *
11293 * \brief wlan_hdd_restart_driver
11294 *
11295 * This function sends an event to supplicant to restart the WLAN driver.
11296 *
11297 * This function is called from vos_wlanRestart.
11298 *
11299 * \param - pHddCtx
11300 *
11301 * \return - VOS_STATUS_SUCCESS: Success
11302 * VOS_STATUS_E_EMPTY: Adapter is Empty
11303 * VOS_STATUS_E_ALREADY: Request already in progress
11304
11305 * --------------------------------------------------------------------------*/
11306VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx)
11307{
11308 VOS_STATUS status = VOS_STATUS_SUCCESS;
11309
11310 /* A tight check to make sure reentrancy */
11311 if(atomic_xchg(&pHddCtx->isRestartInProgress, 1))
11312 {
Mihir Shetefd528652014-06-23 19:07:50 +053011313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsone7245742012-09-05 17:12:55 -070011314 "%s: WLAN restart is already in progress", __func__);
11315
11316 return VOS_STATUS_E_ALREADY;
11317 }
Sameer Thalappil0c164f52013-03-28 15:27:56 -070011318 /* Send reset FIQ to WCNSS to invoke SSR. */
Madan Mohan Koyyalamudie388b342012-11-08 15:03:16 -080011319#ifdef HAVE_WCNSS_RESET_INTR
Siddharth Bhal864e7e82015-04-07 20:07:24 +053011320 wcnss_reset_fiq(TRUE);
Madan Mohan Koyyalamudibb8f0172012-09-28 15:36:06 -070011321#endif
Madan Mohan Koyyalamudi5aef2af2012-10-05 11:56:27 -070011322
Jeff Johnsone7245742012-09-05 17:12:55 -070011323 return status;
11324}
11325
Mihir Shetee1093ba2014-01-21 20:13:32 +053011326/**---------------------------------------------------------------------------
11327 *
11328 * \brief wlan_hdd_init_channels
11329 *
11330 * This function is used to initialize the channel list in CSR
11331 *
11332 * This function is called from hdd_wlan_startup
11333 *
11334 * \param - pHddCtx: HDD context
11335 *
11336 * \return - VOS_STATUS_SUCCESS: Success
11337 * VOS_STATUS_E_FAULT: Failure reported by SME
11338
11339 * --------------------------------------------------------------------------*/
11340static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx)
11341{
11342 eHalStatus status;
11343
11344 status = sme_InitChannels(pHddCtx->hHal);
11345 if (HAL_STATUS_SUCCESS(status))
11346 {
11347 return VOS_STATUS_SUCCESS;
11348 }
11349 else
11350 {
11351 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)",
11352 __func__, status);
11353 return VOS_STATUS_E_FAULT;
11354 }
11355}
11356
Mihir Shete04206452014-11-20 17:50:58 +053011357#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +053011358VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx, driver_load_type init )
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053011359{
11360 eHalStatus status;
11361
Agarwal Ashish6db9d532014-09-30 18:19:10 +053011362 status = sme_InitChannelsForCC(pHddCtx->hHal, init);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +053011363 if (HAL_STATUS_SUCCESS(status))
11364 {
11365 return VOS_STATUS_SUCCESS;
11366 }
11367 else
11368 {
11369 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)",
11370 __func__, status);
11371 return VOS_STATUS_E_FAULT;
11372 }
11373}
Mihir Shete04206452014-11-20 17:50:58 +053011374#endif
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -070011375/*
11376 * API to find if there is any STA or P2P-Client is connected
11377 */
11378VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx)
11379{
11380 return sme_isSta_p2p_clientConnected(pHddCtx->hHal);
11381}
Jeff Johnsone7245742012-09-05 17:12:55 -070011382
Mihir Shetee2ae82a2015-03-16 14:08:49 +053011383
11384/*
11385 * API to find if the firmware will send logs using DXE channel
11386 */
11387v_U8_t hdd_is_fw_logging_enabled(void)
11388{
11389 hdd_context_t *pHddCtx;
11390
11391 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD,
11392 vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
11393
Sachin Ahuja084313e2015-05-21 17:57:10 +053011394 return (pHddCtx && pHddCtx->cfg_ini->enableMgmtLogging);
Mihir Shetee2ae82a2015-03-16 14:08:49 +053011395}
11396
Agarwal Ashish57e84372014-12-05 18:26:53 +053011397/*
Mihir Shetebe94ebb2015-05-26 12:07:14 +053011398 * API to find if the firmware will send trace logs using DXE channel
11399 */
11400v_U8_t hdd_is_fw_ev_logging_enabled(void)
11401{
11402 hdd_context_t *pHddCtx;
11403
11404 pHddCtx = vos_get_context(VOS_MODULE_ID_HDD,
11405 vos_get_global_context(VOS_MODULE_ID_HDD, NULL));
11406
11407 return (pHddCtx && pHddCtx->cfg_ini->enableFWLogging);
11408}
11409/*
Agarwal Ashish57e84372014-12-05 18:26:53 +053011410 * API to find if there is any session connected
11411 */
11412VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx)
11413{
11414 return sme_is_any_session_connected(pHddCtx->hHal);
11415}
11416
11417
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011418int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter)
11419{
11420 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11421 hdd_scaninfo_t *pScanInfo = NULL;
Girish Gowli4bf7a632014-06-12 13:42:11 +053011422 long status = 0;
c_hpothua3d45d52015-01-05 14:11:17 +053011423 tSirAbortScanStatus abortScanStatus;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011424
11425 pScanInfo = &pHddCtx->scan_info;
Ratnam Rachuric7681132015-06-30 10:35:13 +053011426 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011427 if (pScanInfo->mScanPending)
11428 {
c_hpothua3d45d52015-01-05 14:11:17 +053011429 abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
11430 eCSR_SCAN_ABORT_DEFAULT);
11431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11432 FL("abortScanStatus: %d"), abortScanStatus);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011433
c_hpothua3d45d52015-01-05 14:11:17 +053011434 /* If there is active scan command lets wait for the completion else
11435 * there is no need to wait as scan command might be in the SME pending
11436 * command list.
11437 */
11438 if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY)
11439 {
c_hpothua3d45d52015-01-05 14:11:17 +053011440 status = wait_for_completion_interruptible_timeout(
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011441 &pScanInfo->abortscan_event_var,
11442 msecs_to_jiffies(5000));
c_hpothua3d45d52015-01-05 14:11:17 +053011443 if (0 >= status)
11444 {
11445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowli4bf7a632014-06-12 13:42:11 +053011446 "%s: Timeout or Interrupt occurred while waiting for abort"
11447 "scan, status- %ld", __func__, status);
c_hpothua3d45d52015-01-05 14:11:17 +053011448 return -ETIMEDOUT;
11449 }
11450 }
11451 else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE)
11452 {
11453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11454 FL("hdd_abort_mac_scan failed"));
11455 return -VOS_STATUS_E_FAILURE;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011456 }
11457 }
Girish Gowli4bf7a632014-06-12 13:42:11 +053011458 return 0;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053011459}
11460
c_hpothu225aa7c2014-10-22 17:45:13 +053011461VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx)
11462{
11463 hdd_adapter_t *pAdapter;
11464 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11465 VOS_STATUS vosStatus;
11466
11467 vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
11468 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
11469 {
11470 pAdapter = pAdapterNode->pAdapter;
11471 if (NULL != pAdapter)
11472 {
11473 if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode ||
11474 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ||
11475 WLAN_HDD_P2P_GO == pAdapter->device_mode)
11476 {
11477 hddLog(LOG1, FL("abort ROC deviceMode: %d"),
11478 pAdapter->device_mode);
11479 if (VOS_STATUS_SUCCESS !=
11480 wlan_hdd_cancel_existing_remain_on_channel(pAdapter))
11481 {
11482 hddLog(LOGE, FL("failed to abort ROC"));
11483 return VOS_STATUS_E_FAILURE;
11484 }
11485 }
11486 }
11487 vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11488 pAdapterNode = pNext;
11489 }
11490 return VOS_STATUS_SUCCESS;
11491}
Mahesh A Saptasagard477b092015-02-06 15:12:16 +053011492
Mihir Shete0be28772015-02-17 18:42:14 +053011493hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx)
11494{
11495 hdd_adapter_t *pAdapter;
11496 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11497 hdd_cfg80211_state_t *cfgState;
11498 hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL;
11499 VOS_STATUS vosStatus;
11500
11501 vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode);
11502 while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus)
11503 {
11504 pAdapter = pAdapterNode->pAdapter;
11505 if (NULL != pAdapter)
11506 {
11507 cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter);
11508 pRemainChanCtx = cfgState->remain_on_chan_ctx;
11509 if (pRemainChanCtx)
11510 break;
11511 }
11512 vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext);
11513 pAdapterNode = pNext;
11514 }
11515 return pRemainChanCtx;
11516}
11517
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +053011518/**
11519 * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels
11520 *
11521 * @pHddCtx: HDD context within host driver
11522 * @dfsScanMode: dfsScanMode passed from ioctl
11523 *
11524 */
11525
11526VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx,
11527 tANI_U8 dfsScanMode)
11528{
11529 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
11530 hdd_adapter_t *pAdapter;
11531 VOS_STATUS vosStatus;
11532 hdd_station_ctx_t *pHddStaCtx;
11533 eHalStatus status = eHAL_STATUS_SUCCESS;
11534
11535 if(!pHddCtx)
11536 {
11537 hddLog(LOGE, FL("HDD context is Null"));
11538 return eHAL_STATUS_FAILURE;
11539 }
11540
11541 if (pHddCtx->scan_info.mScanPending)
11542 {
11543 hddLog(LOG1, FL("Aborting scan for sessionId: %d"),
11544 pHddCtx->scan_info.sessionId);
11545 hdd_abort_mac_scan(pHddCtx,
11546 pHddCtx->scan_info.sessionId,
11547 eCSR_SCAN_ABORT_DEFAULT);
11548 }
11549
11550 if (!dfsScanMode)
11551 {
11552 vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode);
11553 while ((NULL != pAdapterNode) &&
11554 (VOS_STATUS_SUCCESS == vosStatus))
11555 {
11556 pAdapter = pAdapterNode->pAdapter;
11557
11558 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
11559 {
11560 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11561
11562 if(!pHddStaCtx)
11563 {
11564 hddLog(LOGE, FL("HDD STA context is Null"));
11565 return eHAL_STATUS_FAILURE;
11566 }
11567
11568 /* if STA is already connected on DFS channel,
11569 disconnect immediately*/
11570 if (hdd_connIsConnected(pHddStaCtx) &&
11571 (NV_CHANNEL_DFS ==
11572 vos_nv_getChannelEnabledState(
11573 pHddStaCtx->conn_info.operationChannel)))
11574 {
11575 status = sme_RoamDisconnect(pHddCtx->hHal,
11576 pAdapter->sessionId,
11577 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11578 hddLog(LOG1, FL("Client connected on DFS channel %d,"
11579 "sme_RoamDisconnect returned with status: %d"
11580 "for sessionid: %d"), pHddStaCtx->conn_info.
11581 operationChannel, status, pAdapter->sessionId);
11582 }
11583 }
11584
11585 vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode,
11586 &pNext);
11587 pAdapterNode = pNext;
11588 }
11589 }
11590
11591 sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode);
11592 sme_UpdateDFSRoamMode(pHddCtx->hHal,
11593 (dfsScanMode != DFS_CHNL_SCAN_DISABLED));
11594
11595 status = sme_HandleDFSChanScan(pHddCtx->hHal);
11596 if (!HAL_STATUS_SUCCESS(status))
11597 {
11598 hddLog(LOGE,
11599 FL("Failed in sme_HandleDFSChanScan (err=%d)"), status);
11600 return status;
11601 }
11602
11603 return status;
11604}
11605
Nirav Shah7e3c8132015-06-22 23:51:42 +053011606static int hdd_log2_ceil(unsigned value)
11607{
11608 /* need to switch to unsigned math so that negative values
11609 * will right-shift towards 0 instead of -1
11610 */
11611 unsigned tmp = value;
11612 int log2 = -1;
11613
11614 if (value == 0)
11615 return 0;
11616
11617 while (tmp) {
11618 log2++;
11619 tmp >>= 1;
11620 }
11621 if (1U << log2 != value)
11622 log2++;
11623
11624 return log2;
11625}
11626
11627/**
11628 * hdd_sta_id_hash_attach() - initialize sta id to macaddr hash
11629 * @pAdapter: adapter handle
11630 *
11631 * Return: vos status
11632 */
11633VOS_STATUS hdd_sta_id_hash_attach(hdd_adapter_t *pAdapter)
11634{
11635 int hash_elem, log2, i;
11636
11637 spin_lock_bh( &pAdapter->sta_hash_lock);
11638 if (pAdapter->is_sta_id_hash_initialized == VOS_TRUE) {
11639 spin_unlock_bh( &pAdapter->sta_hash_lock);
11640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11641 "%s: hash already attached for session id %d",
11642 __func__, pAdapter->sessionId);
11643 return VOS_STATUS_SUCCESS;
11644 }
11645 spin_unlock_bh( &pAdapter->sta_hash_lock);
11646
11647 hash_elem = WLAN_MAX_STA_COUNT;
11648 hash_elem *= HDD_STA_ID_HASH_MULTIPLIER;
11649 log2 = hdd_log2_ceil(hash_elem);
11650 hash_elem = 1 << log2;
11651
11652 pAdapter->sta_id_hash.mask = hash_elem - 1;
11653 pAdapter->sta_id_hash.idx_bits = log2;
11654 pAdapter->sta_id_hash.bins =
11655 vos_mem_malloc(hash_elem *sizeof(hdd_list_t));
11656 if (!pAdapter->sta_id_hash.bins) {
11657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11658 "%s: malloc failed for session %d",
11659 __func__, pAdapter->sessionId);
11660 return VOS_STATUS_E_NOMEM;
11661 }
11662
11663 for (i = 0; i < hash_elem; i++)
11664 hdd_list_init(&pAdapter->sta_id_hash.bins[i], WLAN_MAX_STA_COUNT);
11665
11666 spin_lock_bh( &pAdapter->sta_hash_lock);
11667 pAdapter->is_sta_id_hash_initialized = VOS_TRUE;
11668 spin_unlock_bh( &pAdapter->sta_hash_lock);
11669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11670 "%s: Station ID Hash attached for session id %d",
11671 __func__, pAdapter->sessionId);
11672
11673 return VOS_STATUS_SUCCESS;
11674}
11675
11676/**
11677 * hdd_sta_id_hash_detach() - deinit sta_id to macaddr hash
11678 * @pAdapter: adapter handle
11679 *
11680 * Return: vos status
11681 */
11682VOS_STATUS hdd_sta_id_hash_detach(hdd_adapter_t *pAdapter)
11683{
11684 int hash_elem, i;
11685 v_SIZE_t size;
11686
11687 spin_lock_bh( &pAdapter->sta_hash_lock);
11688 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11689 spin_unlock_bh( &pAdapter->sta_hash_lock);
11690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11691 "%s: hash not initialized for session id %d",
11692 __func__, pAdapter->sessionId);
11693 return VOS_STATUS_SUCCESS;
11694 }
11695
11696 pAdapter->is_sta_id_hash_initialized = VOS_FALSE;
11697 spin_unlock_bh( &pAdapter->sta_hash_lock);
11698
11699 hash_elem = 1 << pAdapter->sta_id_hash.idx_bits;
11700
11701 /* free all station info*/
11702 for (i = 0; i < hash_elem; i++) {
11703 hdd_list_size(&pAdapter->sta_id_hash.bins[i], &size);
11704 if (size != 0) {
11705 VOS_STATUS status;
11706 hdd_staid_hash_node_t *sta_info_node = NULL;
11707 hdd_staid_hash_node_t *next_node = NULL;
11708 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[i],
11709 (hdd_list_node_t**) &sta_info_node );
11710
11711 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11712 {
11713 status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[i],
11714 &sta_info_node->node);
11715 vos_mem_free(sta_info_node);
11716
11717 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[i],
11718 (hdd_list_node_t*)sta_info_node,
11719 (hdd_list_node_t**)&next_node);
11720 sta_info_node = next_node;
11721 }
11722 }
11723 }
11724
11725 vos_mem_free(pAdapter->sta_id_hash.bins);
11726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11727 "%s: Station ID Hash detached for session id %d",
11728 __func__, pAdapter->sessionId);
11729 return VOS_STATUS_SUCCESS;
11730}
11731
11732/**
11733 * hdd_sta_id_hash_calculate_index() - derive index from macaddr
11734 * @pAdapter: adapter handle
11735 * @mac_addr_in: input mac address
11736 *
11737 * Return: index derived from mac address
11738 */
11739int hdd_sta_id_hash_calculate_index(hdd_adapter_t *pAdapter,
11740 v_MACADDR_t *mac_addr_in)
11741{
11742 uint16 index;
11743 struct hdd_align_mac_addr_t * mac_addr =
11744 (struct hdd_align_mac_addr_t *)mac_addr_in;
11745
11746 index = mac_addr->bytes_ab ^
11747 mac_addr->bytes_cd ^ mac_addr->bytes_ef;
11748 index ^= index >> pAdapter->sta_id_hash.idx_bits;
11749 index &= pAdapter->sta_id_hash.mask;
11750 return index;
11751}
11752
11753/**
11754 * hdd_sta_id_hash_add_entry() - add entry in hash
11755 * @pAdapter: adapter handle
11756 * @sta_id: station id
11757 * @mac_addr: mac address
11758 *
11759 * Return: vos status
11760 */
11761VOS_STATUS hdd_sta_id_hash_add_entry(hdd_adapter_t *pAdapter,
11762 v_U8_t sta_id, v_MACADDR_t *mac_addr)
11763{
11764 uint16 index;
11765 hdd_staid_hash_node_t *sta_info_node = NULL;
11766
11767 spin_lock_bh( &pAdapter->sta_hash_lock);
11768 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11769 spin_unlock_bh( &pAdapter->sta_hash_lock);
Bhargav Shah784e6a52015-07-22 16:52:35 +053011770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Nirav Shah7e3c8132015-06-22 23:51:42 +053011771 "%s: hash is not initialized for session id %d",
11772 __func__, pAdapter->sessionId);
11773 return VOS_STATUS_E_FAILURE;
11774 }
11775
11776 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr);
11777 sta_info_node = vos_mem_malloc(sizeof(hdd_staid_hash_node_t));
11778 if (!sta_info_node) {
11779 spin_unlock_bh( &pAdapter->sta_hash_lock);
11780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11781 "%s: malloc failed", __func__);
11782 return VOS_STATUS_E_NOMEM;
11783 }
11784
11785 sta_info_node->sta_id = sta_id;
11786 vos_mem_copy(&sta_info_node->mac_addr, mac_addr, sizeof(v_MACADDR_t));
11787
11788 hdd_list_insert_back ( &pAdapter->sta_id_hash.bins[index],
11789 (hdd_list_node_t*) sta_info_node );
11790 spin_unlock_bh( &pAdapter->sta_hash_lock);
11791 return VOS_STATUS_SUCCESS;
11792}
11793
11794/**
11795 * hdd_sta_id_hash_remove_entry() - remove entry from hash
11796 * @pAdapter: adapter handle
11797 * @sta_id: station id
11798 * @mac_addr: mac address
11799 *
11800 * Return: vos status
11801 */
11802VOS_STATUS hdd_sta_id_hash_remove_entry(hdd_adapter_t *pAdapter,
11803 v_U8_t sta_id, v_MACADDR_t *mac_addr)
11804{
11805 uint16 index;
11806 VOS_STATUS status;
11807 hdd_staid_hash_node_t *sta_info_node = NULL;
11808 hdd_staid_hash_node_t *next_node = NULL;
11809
11810 spin_lock_bh( &pAdapter->sta_hash_lock);
11811 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11812 spin_unlock_bh( &pAdapter->sta_hash_lock);
11813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11814 "%s: hash is not initialized for session id %d",
11815 __func__, pAdapter->sessionId);
11816 return VOS_STATUS_E_FAILURE;
11817 }
11818
11819 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr);
11820 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index],
11821 (hdd_list_node_t**) &sta_info_node );
11822
11823 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11824 {
11825 if (sta_info_node->sta_id == sta_id) {
11826 status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[index],
11827 &sta_info_node->node);
11828 vos_mem_free(sta_info_node);
11829 break;
11830 }
11831 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index],
11832 (hdd_list_node_t*)sta_info_node, (hdd_list_node_t**)&next_node);
11833 sta_info_node = next_node;
11834 }
11835 spin_unlock_bh( &pAdapter->sta_hash_lock);
11836 return status;
11837}
11838
11839/**
11840 * hdd_sta_id_find_from_mac_addr() - find sta id from mac address
11841 * @pAdapter: adapter handle
11842 * @mac_addr_in: mac address
11843 *
11844 * Return: station id
11845 */
11846int hdd_sta_id_find_from_mac_addr(hdd_adapter_t *pAdapter,
11847 v_MACADDR_t *mac_addr_in)
11848{
11849 uint8 is_found = 0;
11850 uint8 sta_id = HDD_WLAN_INVALID_STA_ID;
11851 uint16 index;
11852 VOS_STATUS status;
11853 hdd_staid_hash_node_t *sta_info_node = NULL;
11854 hdd_staid_hash_node_t *next_node = NULL;
11855
11856 spin_lock_bh( &pAdapter->sta_hash_lock);
11857 if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) {
11858 spin_unlock_bh( &pAdapter->sta_hash_lock);
11859 hddLog(VOS_TRACE_LEVEL_ERROR,
11860 FL("hash is not initialized for session id %d"),
11861 pAdapter->sessionId);
11862 return HDD_WLAN_INVALID_STA_ID;
11863 }
11864
11865 index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr_in);
11866 status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index],
11867 (hdd_list_node_t**) &sta_info_node );
11868
11869 while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status )
11870 {
11871 if (vos_mem_compare(&sta_info_node->mac_addr,
11872 mac_addr_in, sizeof(v_MACADDR_t))) {
11873 is_found = 1;
11874 sta_id = sta_info_node->sta_id;
11875 break;
11876 }
11877 status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index],
11878 (hdd_list_node_t*)sta_info_node,
11879 (hdd_list_node_t**)&next_node);
11880 sta_info_node = next_node;
11881 }
11882 spin_unlock_bh( &pAdapter->sta_hash_lock);
11883 return sta_id;
11884}
11885
Jeff Johnson295189b2012-06-20 16:38:30 -070011886//Register the module init/exit functions
11887module_init(hdd_module_init);
11888module_exit(hdd_module_exit);
11889
11890MODULE_LICENSE("Dual BSD/GPL");
11891MODULE_AUTHOR("Qualcomm Atheros, Inc.");
11892MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER");
11893
Madan Mohan Koyyalamudi2331c8a2012-09-18 18:14:48 -070011894module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode,
11895 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011896
Jeff Johnson76052702013-04-16 13:55:05 -070011897module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011898 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Arif Hussain66559122013-11-21 10:11:40 -080011899
11900module_param(enable_dfs_chan_scan, int,
11901 S_IRUSR | S_IRGRP | S_IROTH);
11902
11903module_param(enable_11d, int,
11904 S_IRUSR | S_IRGRP | S_IROTH);
11905
11906module_param(country_code, charp,
11907 S_IRUSR | S_IRGRP | S_IROTH);